nivo-rails-am 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +49 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +20 -0
- data/README.md +55 -0
- data/README.md~ +29 -0
- data/README.rdoc +16 -0
- data/README.rdoc~ +16 -0
- data/Rakefile +1 -0
- data/app/helpers/nivo_helper.rb +15 -0
- data/lib/nivo-rails-am.rb +8 -0
- data/lib/nivo-rails-am.rb~ +0 -0
- data/lib/nivo/rails/engine.rb +6 -0
- data/lib/nivo/version.rb +5 -0
- data/lib/nivo/version.rb~ +5 -0
- data/nivo-rails-am.gemspec +21 -0
- data/nivo-rails-am.gemspec~ +21 -0
- data/test/helper.rb +18 -0
- data/test/test_nivo-rails-am.rb +7 -0
- data/vendor/assets/images/bar/arrows.png +0 -0
- data/vendor/assets/images/bar/bullets.png +0 -0
- data/vendor/assets/images/bar/loading.gif +0 -0
- data/vendor/assets/images/dark/.DS_Store +0 -0
- data/vendor/assets/images/dark/arrows.png +0 -0
- data/vendor/assets/images/dark/bullets.png +0 -0
- data/vendor/assets/images/dark/loading.gif +0 -0
- data/vendor/assets/images/default/arrows.png +0 -0
- data/vendor/assets/images/default/bullets.png +0 -0
- data/vendor/assets/images/default/loading.gif +0 -0
- data/vendor/assets/images/light/arrows.png +0 -0
- data/vendor/assets/images/light/bullets.png +0 -0
- data/vendor/assets/images/light/loading.gif +0 -0
- data/vendor/assets/javascripts/jquery.nivo.slider.pack.js +10 -0
- data/vendor/assets/javascripts/nivo.js +662 -0
- data/vendor/assets/stylesheets/nivo.css +509 -0
- data/vendor/assets/stylesheets/nivo.css~ +509 -0
- metadata +97 -0
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
coverage.data
|
4
|
+
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
|
8
|
+
# yard generated
|
9
|
+
doc
|
10
|
+
.yardoc
|
11
|
+
|
12
|
+
# bundler
|
13
|
+
.bundle
|
14
|
+
|
15
|
+
# jeweler generated
|
16
|
+
pkg
|
17
|
+
|
18
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
19
|
+
#
|
20
|
+
# * Create a file at ~/.gitignore
|
21
|
+
# * Include files you want ignored
|
22
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
23
|
+
#
|
24
|
+
# After doing this, these files will be ignored in all your git projects,
|
25
|
+
# saving you from having to 'pollute' every project you touch with them
|
26
|
+
#
|
27
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
28
|
+
#
|
29
|
+
# For MacOS:
|
30
|
+
#
|
31
|
+
#.DS_Store
|
32
|
+
|
33
|
+
# For TextMate
|
34
|
+
#*.tmproj
|
35
|
+
#tmtags
|
36
|
+
|
37
|
+
# For emacs:
|
38
|
+
#*~
|
39
|
+
#\#*
|
40
|
+
#.\#*
|
41
|
+
|
42
|
+
# For vim:
|
43
|
+
#*.swp
|
44
|
+
|
45
|
+
# For redcar:
|
46
|
+
#.redcar
|
47
|
+
|
48
|
+
# For rubinius:
|
49
|
+
#*.rbc
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Robin Dupret
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Ad88
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Nivo::Rails
|
2
|
+
|
3
|
+
Integrating the awesome Nivo slider slideshow in Rails > 3.1
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'nivo-rails-am'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install nivo-rails-am
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
In .erb file, just do following:
|
22
|
+
|
23
|
+
<%= nivo_slider(:theme => :dark,:id => "slider") do %>
|
24
|
+
|
25
|
+
<%= image_tag 'slider/toystory.jpg', :title => "#htmlcaption0" %>
|
26
|
+
<%= image_tag 'slider/walle.jpg', :title => "#htmlcaption1" %>
|
27
|
+
<%= image_tag 'slider/up.jpg', :title => "#htmlcaption2" %>
|
28
|
+
<%= image_tag 'slider/nemo.jpg', :title => "#htmlcaption3" %>
|
29
|
+
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
|
33
|
+
<div id="htmlcaption0" class="nivo-html-caption">
|
34
|
+
<strong><bold>Toy Movie</bold></strong> needs <em>backers</em> click <a href="#">link</a>
|
35
|
+
</div>
|
36
|
+
<div id="htmlcaption1" class="nivo-html-caption">
|
37
|
+
<strong><bold>Robot Movie</bold></strong> needs <em>backers</em> click <a href="#">link</a>
|
38
|
+
</div>
|
39
|
+
<div id="htmlcaption2" class="nivo-html-caption">
|
40
|
+
<strong><bold>Flying Grandpa Movie</bold></strong> needs <em>backers</em> click <a href="#">link</a>
|
41
|
+
</div>
|
42
|
+
<div id="htmlcaption3" class="nivo-html-caption">
|
43
|
+
<strong><bold>Fish and Bird Movie</bold></strong> needs <em>backers</em> click <a href="#">link</a>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<%= javascript_include_tag 'slider/init.nivo.slider' %>
|
47
|
+
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create new Pull Request
|
data/README.md~
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Nivo::Rails
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'nivo-rails-am'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install nivo-rails-am
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/README.rdoc
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
= nivo-rails-am
|
2
|
+
|
3
|
+
Modified nivo-rails
|
4
|
+
|
5
|
+
== Contributing to nivo-rails-am
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
See LICENSE.txt for further details.
|
16
|
+
|
data/README.rdoc~
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
= nivo-rails-am
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to nivo-rails-am
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
See LICENSE.txt for further details.
|
16
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module NivoHelper
|
2
|
+
def nivo_slider(hash = {}, &block)
|
3
|
+
options = { :theme => :default, :id => "" }
|
4
|
+
options.merge!(hash)
|
5
|
+
klass = "slider-wrapper theme-#{options[:theme]}"
|
6
|
+
id = options[:id]
|
7
|
+
|
8
|
+
content_tag(:div, :class => klass) do
|
9
|
+
content_tag(:div, :id => id, :class => "#{options[:class]}nivoSlider") do
|
10
|
+
yield
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
File without changes
|
data/lib/nivo/version.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'nivo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "nivo-rails-am"
|
8
|
+
gem.version = Nivo::Rails::VERSION
|
9
|
+
gem.authors = ["Robin Dupret","Ad Merican"]
|
10
|
+
gem.email = ["robin.dupret@gmail.com"]
|
11
|
+
gem.description = %q{Nivo slider with Ruby on Rails}
|
12
|
+
gem.summary = %q{This gem allows you to use modified nivo-rails slider with Ruby on Rails}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.homepage = "https://github.com/am2828/nivo-rails-am"
|
20
|
+
gem.add_development_dependency("rake")
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'nivo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "nivo-rails-am"
|
8
|
+
gem.version = Nivo::Rails::VERSION
|
9
|
+
gem.authors = ["Robin Dupret","Ad Merican"]
|
10
|
+
gem.email = ["robin.dupret@gmail.com"]
|
11
|
+
gem.description = %q{Nivo slider with Ruby on Rails}
|
12
|
+
gem.summary = %q{This gem allows you to use modified nivo-rails slider with Ruby on Rails}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency("rake")
|
21
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'nivo-rails-am'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery Nivo Slider v3.2
|
3
|
+
* http://nivo.dev7studios.com
|
4
|
+
*
|
5
|
+
* Copyright 2012, Dev7studios
|
6
|
+
* Free to use and abuse under the MIT license.
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function(e){var t=function(t,n){var r=e.extend({},e.fn.nivoSlider.defaults,n);var i={currentSlide:0,currentImage:"",totalSlides:0,running:false,paused:false,stop:false,controlNavEl:false};var s=e(t);s.data("nivo:vars",i).addClass("nivoSlider");var o=s.children();o.each(function(){var t=e(this);var n="";if(!t.is("img")){if(t.is("a")){t.addClass("nivo-imageLink");n=t}t=t.find("img:first")}var r=r===0?t.attr("width"):t.width(),s=s===0?t.attr("height"):t.height();if(n!==""){n.css("display","none")}t.css("display","none");i.totalSlides++});if(r.randomStart){r.startSlide=Math.floor(Math.random()*i.totalSlides)}if(r.startSlide>0){if(r.startSlide>=i.totalSlides){r.startSlide=i.totalSlides-1}i.currentSlide=r.startSlide}if(e(o[i.currentSlide]).is("img")){i.currentImage=e(o[i.currentSlide])}else{i.currentImage=e(o[i.currentSlide]).find("img:first")}if(e(o[i.currentSlide]).is("a")){e(o[i.currentSlide]).css("display","block")}var u=e("<img/>").addClass("nivo-main-image");u.attr("src",i.currentImage.attr("src")).show();s.append(u);e(window).resize(function(){s.children("img").width(s.width());u.attr("src",i.currentImage.attr("src"));u.stop().height("auto");e(".nivo-slice").remove();e(".nivo-box").remove()});s.append(e('<div class="nivo-caption"></div>'));var a=function(t){var n=e(".nivo-caption",s);if(i.currentImage.attr("title")!=""&&i.currentImage.attr("title")!=undefined){var r=i.currentImage.attr("title");if(r.substr(0,1)=="#")r=e(r).html();if(n.css("display")=="block"){setTimeout(function(){n.html(r)},t.animSpeed)}else{n.html(r);n.stop().fadeIn(t.animSpeed)}}else{n.stop().fadeOut(t.animSpeed)}};a(r);var f=0;if(!r.manualAdvance&&o.length>1){f=setInterval(function(){d(s,o,r,false)},r.pauseTime)}if(r.directionNav){s.append('<div class="nivo-directionNav"><a class="nivo-prevNav">'+r.prevText+'</a><a class="nivo-nextNav">'+r.nextText+"</a></div>");e(s).on("click","a.nivo-prevNav",function(){if(i.running){return false}clearInterval(f);f="";i.currentSlide-=2;d(s,o,r,"prev")});e(s).on("click","a.nivo-nextNav",function(){if(i.running){return false}clearInterval(f);f="";d(s,o,r,"next")})}if(r.controlNav){i.controlNavEl=e('<div class="nivo-controlNav"></div>');s.after(i.controlNavEl);for(var l=0;l<o.length;l++){if(r.controlNavThumbs){i.controlNavEl.addClass("nivo-thumbs-enabled");var c=o.eq(l);if(!c.is("img")){c=c.find("img:first")}if(c.attr("data-thumb"))i.controlNavEl.append('<a class="nivo-control" rel="'+l+'"><img src="'+c.attr("data-thumb")+'" alt="" /></a>')}else{i.controlNavEl.append('<a class="nivo-control" rel="'+l+'">'+(l+1)+"</a>")}}e("a:eq("+i.currentSlide+")",i.controlNavEl).addClass("active");e("a",i.controlNavEl).bind("click",function(){if(i.running)return false;if(e(this).hasClass("active"))return false;clearInterval(f);f="";u.attr("src",i.currentImage.attr("src"));i.currentSlide=e(this).attr("rel")-1;d(s,o,r,"control")})}if(r.pauseOnHover){s.hover(function(){i.paused=true;clearInterval(f);f=""},function(){i.paused=false;if(f===""&&!r.manualAdvance){f=setInterval(function(){d(s,o,r,false)},r.pauseTime)}})}s.bind("nivo:animFinished",function(){u.attr("src",i.currentImage.attr("src"));i.running=false;e(o).each(function(){if(e(this).is("a")){e(this).css("display","none")}});if(e(o[i.currentSlide]).is("a")){e(o[i.currentSlide]).css("display","block")}if(f===""&&!i.paused&&!r.manualAdvance){f=setInterval(function(){d(s,o,r,false)},r.pauseTime)}r.afterChange.call(this)});var h=function(t,n,r){if(e(r.currentImage).parent().is("a"))e(r.currentImage).parent().css("display","block");e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").width(t.width()).css("visibility","hidden").show();var i=e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").parent().is("a")?e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").parent().height():e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").height();for(var s=0;s<n.slices;s++){var o=Math.round(t.width()/n.slices);if(s===n.slices-1){t.append(e('<div class="nivo-slice" name="'+s+'"><img src="'+r.currentImage.attr("src")+'" style="position:absolute; width:'+t.width()+"px; height:auto; display:block !important; top:0; left:-"+(o+s*o-o)+'px;" /></div>').css({left:o*s+"px",width:t.width()-o*s+"px",height:i+"px",opacity:"0",overflow:"hidden"}))}else{t.append(e('<div class="nivo-slice" name="'+s+'"><img src="'+r.currentImage.attr("src")+'" style="position:absolute; width:'+t.width()+"px; height:auto; display:block !important; top:0; left:-"+(o+s*o-o)+'px;" /></div>').css({left:o*s+"px",width:o+"px",height:i+"px",opacity:"0",overflow:"hidden"}))}}e(".nivo-slice",t).height(i);u.stop().animate({height:e(r.currentImage).height()},n.animSpeed)};var p=function(t,n,r){if(e(r.currentImage).parent().is("a"))e(r.currentImage).parent().css("display","block");e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").width(t.width()).css("visibility","hidden").show();var i=Math.round(t.width()/n.boxCols),s=Math.round(e('img[src="'+r.currentImage.attr("src")+'"]',t).not(".nivo-main-image,.nivo-control img").height()/n.boxRows);for(var o=0;o<n.boxRows;o++){for(var a=0;a<n.boxCols;a++){if(a===n.boxCols-1){t.append(e('<div class="nivo-box" name="'+a+'" rel="'+o+'"><img src="'+r.currentImage.attr("src")+'" style="position:absolute; width:'+t.width()+"px; height:auto; display:block; top:-"+s*o+"px; left:-"+i*a+'px;" /></div>').css({opacity:0,left:i*a+"px",top:s*o+"px",width:t.width()-i*a+"px"}));e('.nivo-box[name="'+a+'"]',t).height(e('.nivo-box[name="'+a+'"] img',t).height()+"px")}else{t.append(e('<div class="nivo-box" name="'+a+'" rel="'+o+'"><img src="'+r.currentImage.attr("src")+'" style="position:absolute; width:'+t.width()+"px; height:auto; display:block; top:-"+s*o+"px; left:-"+i*a+'px;" /></div>').css({opacity:0,left:i*a+"px",top:s*o+"px",width:i+"px"}));e('.nivo-box[name="'+a+'"]',t).height(e('.nivo-box[name="'+a+'"] img',t).height()+"px")}}}u.stop().animate({height:e(r.currentImage).height()},n.animSpeed)};var d=function(t,n,r,i){var s=t.data("nivo:vars");if(s&&s.currentSlide===s.totalSlides-1){r.lastSlide.call(this)}if((!s||s.stop)&&!i){return false}r.beforeChange.call(this);if(!i){u.attr("src",s.currentImage.attr("src"))}else{if(i==="prev"){u.attr("src",s.currentImage.attr("src"))}if(i==="next"){u.attr("src",s.currentImage.attr("src"))}}s.currentSlide++;if(s.currentSlide===s.totalSlides){s.currentSlide=0;r.slideshowEnd.call(this)}if(s.currentSlide<0){s.currentSlide=s.totalSlides-1}if(e(n[s.currentSlide]).is("img")){s.currentImage=e(n[s.currentSlide])}else{s.currentImage=e(n[s.currentSlide]).find("img:first")}if(r.controlNav){e("a",s.controlNavEl).removeClass("active");e("a:eq("+s.currentSlide+")",s.controlNavEl).addClass("active")}a(r);e(".nivo-slice",t).remove();e(".nivo-box",t).remove();var o=r.effect,f="";if(r.effect==="random"){f=new Array("sliceDownRight","sliceDownLeft","sliceUpRight","sliceUpLeft","sliceUpDown","sliceUpDownLeft","fold","fade","boxRandom","boxRain","boxRainReverse","boxRainGrow","boxRainGrowReverse");o=f[Math.floor(Math.random()*(f.length+1))];if(o===undefined){o="fade"}}if(r.effect.indexOf(",")!==-1){f=r.effect.split(",");o=f[Math.floor(Math.random()*f.length)];if(o===undefined){o="fade"}}if(s.currentImage.attr("data-transition")){o=s.currentImage.attr("data-transition")}s.running=true;var l=0,c=0,d="",m="",g="",y="";if(o==="sliceDown"||o==="sliceDownRight"||o==="sliceDownLeft"){h(t,r,s);l=0;c=0;d=e(".nivo-slice",t);if(o==="sliceDownLeft"){d=e(".nivo-slice",t)._reverse()}d.each(function(){var n=e(this);n.css({top:"0px"});if(c===r.slices-1){setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="sliceUp"||o==="sliceUpRight"||o==="sliceUpLeft"){h(t,r,s);l=0;c=0;d=e(".nivo-slice",t);if(o==="sliceUpLeft"){d=e(".nivo-slice",t)._reverse()}d.each(function(){var n=e(this);n.css({bottom:"0px"});if(c===r.slices-1){setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="sliceUpDown"||o==="sliceUpDownRight"||o==="sliceUpDownLeft"){h(t,r,s);l=0;c=0;var b=0;d=e(".nivo-slice",t);if(o==="sliceUpDownLeft"){d=e(".nivo-slice",t)._reverse()}d.each(function(){var n=e(this);if(c===0){n.css("top","0px");c++}else{n.css("bottom","0px");c=0}if(b===r.slices-1){setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1.0"},r.animSpeed)},100+l)}l+=50;b++})}else if(o==="fold"){h(t,r,s);l=0;c=0;e(".nivo-slice",t).each(function(){var n=e(this);var i=n.width();n.css({top:"0px",width:"0px"});if(c===r.slices-1){setTimeout(function(){n.animate({width:i,opacity:"1.0"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({width:i,opacity:"1.0"},r.animSpeed)},100+l)}l+=50;c++})}else if(o==="fade"){h(t,r,s);m=e(".nivo-slice:first",t);m.css({width:t.width()+"px"});m.animate({opacity:"1.0"},r.animSpeed*2,"",function(){t.trigger("nivo:animFinished")})}else if(o==="slideInRight"){h(t,r,s);m=e(".nivo-slice:first",t);m.css({width:"0px",opacity:"1"});m.animate({width:t.width()+"px"},r.animSpeed*2,"",function(){t.trigger("nivo:animFinished")})}else if(o==="slideInLeft"){h(t,r,s);m=e(".nivo-slice:first",t);m.css({width:"0px",opacity:"1",left:"",right:"0px"});m.animate({width:t.width()+"px"},r.animSpeed*2,"",function(){m.css({left:"0px",right:""});t.trigger("nivo:animFinished")})}else if(o==="boxRandom"){p(t,r,s);g=r.boxCols*r.boxRows;c=0;l=0;y=v(e(".nivo-box",t));y.each(function(){var n=e(this);if(c===g-1){setTimeout(function(){n.animate({opacity:"1"},r.animSpeed,"",function(){t.trigger("nivo:animFinished")})},100+l)}else{setTimeout(function(){n.animate({opacity:"1"},r.animSpeed)},100+l)}l+=20;c++})}else if(o==="boxRain"||o==="boxRainReverse"||o==="boxRainGrow"||o==="boxRainGrowReverse"){p(t,r,s);g=r.boxCols*r.boxRows;c=0;l=0;var w=0;var E=0;var S=[];S[w]=[];y=e(".nivo-box",t);if(o==="boxRainReverse"||o==="boxRainGrowReverse"){y=e(".nivo-box",t)._reverse()}y.each(function(){S[w][E]=e(this);E++;if(E===r.boxCols){w++;E=0;S[w]=[]}});for(var x=0;x<r.boxCols*2;x++){var T=x;for(var N=0;N<r.boxRows;N++){if(T>=0&&T<r.boxCols){(function(n,i,s,u,a){var f=e(S[n][i]);var l=f.width();var c=f.height();if(o==="boxRainGrow"||o==="boxRainGrowReverse"){f.width(0).height(0)}if(u===a-1){setTimeout(function(){f.animate({opacity:"1",width:l,height:c},r.animSpeed/1.3,"",function(){t.trigger("nivo:animFinished")})},100+s)}else{setTimeout(function(){f.animate({opacity:"1",width:l,height:c},r.animSpeed/1.3)},100+s)}})(N,T,l,c,g);c++}T--}l+=100}}};var v=function(e){for(var t,n,r=e.length;r;t=parseInt(Math.random()*r,10),n=e[--r],e[r]=e[t],e[t]=n);return e};var m=function(e){if(this.console&&typeof console.log!=="undefined"){console.log(e)}};this.stop=function(){if(!e(t).data("nivo:vars").stop){e(t).data("nivo:vars").stop=true;m("Stop Slider")}};this.start=function(){if(e(t).data("nivo:vars").stop){e(t).data("nivo:vars").stop=false;m("Start Slider")}};r.afterLoad.call(this);return this};e.fn.nivoSlider=function(n){return this.each(function(r,i){var s=e(this);if(s.data("nivoslider")){return s.data("nivoslider")}var o=new t(this,n);s.data("nivoslider",o)})};e.fn.nivoSlider.defaults={effect:"random",slices:15,boxCols:8,boxRows:4,animSpeed:500,pauseTime:3e3,startSlide:0,directionNav:true,controlNav:true,controlNavThumbs:false,pauseOnHover:true,manualAdvance:false,prevText:"Prev",nextText:"Next",randomStart:false,beforeChange:function(){},afterChange:function(){},slideshowEnd:function(){},lastSlide:function(){},afterLoad:function(){}};e.fn._reverse=[].reverse})(jQuery)
|
@@ -0,0 +1,662 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery Nivo Slider v3.2
|
3
|
+
* http://nivo.dev7studios.com
|
4
|
+
*
|
5
|
+
* Copyright 2012, Dev7studios
|
6
|
+
* Free to use and abuse under the MIT license.
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function($) {
|
11
|
+
var NivoSlider = function(element, options){
|
12
|
+
// Defaults are below
|
13
|
+
var settings = $.extend({}, $.fn.nivoSlider.defaults, options);
|
14
|
+
|
15
|
+
// Useful variables. Play carefully.
|
16
|
+
var vars = {
|
17
|
+
currentSlide: 0,
|
18
|
+
currentImage: '',
|
19
|
+
totalSlides: 0,
|
20
|
+
running: false,
|
21
|
+
paused: false,
|
22
|
+
stop: false,
|
23
|
+
controlNavEl: false
|
24
|
+
};
|
25
|
+
|
26
|
+
// Get this slider
|
27
|
+
var slider = $(element);
|
28
|
+
slider.data('nivo:vars', vars).addClass('nivoSlider');
|
29
|
+
|
30
|
+
// Find our slider children
|
31
|
+
var kids = slider.children();
|
32
|
+
kids.each(function() {
|
33
|
+
var child = $(this);
|
34
|
+
var link = '';
|
35
|
+
if(!child.is('img')){
|
36
|
+
if(child.is('a')){
|
37
|
+
child.addClass('nivo-imageLink');
|
38
|
+
link = child;
|
39
|
+
}
|
40
|
+
child = child.find('img:first');
|
41
|
+
}
|
42
|
+
// Get img width & height
|
43
|
+
var childWidth = (childWidth === 0) ? child.attr('width') : child.width(),
|
44
|
+
childHeight = (childHeight === 0) ? child.attr('height') : child.height();
|
45
|
+
|
46
|
+
if(link !== ''){
|
47
|
+
link.css('display','none');
|
48
|
+
}
|
49
|
+
child.css('display','none');
|
50
|
+
vars.totalSlides++;
|
51
|
+
});
|
52
|
+
|
53
|
+
// If randomStart
|
54
|
+
if(settings.randomStart){
|
55
|
+
settings.startSlide = Math.floor(Math.random() * vars.totalSlides);
|
56
|
+
}
|
57
|
+
|
58
|
+
// Set startSlide
|
59
|
+
if(settings.startSlide > 0){
|
60
|
+
if(settings.startSlide >= vars.totalSlides) { settings.startSlide = vars.totalSlides - 1; }
|
61
|
+
vars.currentSlide = settings.startSlide;
|
62
|
+
}
|
63
|
+
|
64
|
+
// Get initial image
|
65
|
+
if($(kids[vars.currentSlide]).is('img')){
|
66
|
+
vars.currentImage = $(kids[vars.currentSlide]);
|
67
|
+
} else {
|
68
|
+
vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
|
69
|
+
}
|
70
|
+
|
71
|
+
// Show initial link
|
72
|
+
if($(kids[vars.currentSlide]).is('a')){
|
73
|
+
$(kids[vars.currentSlide]).css('display','block');
|
74
|
+
}
|
75
|
+
|
76
|
+
// Set first background
|
77
|
+
var sliderImg = $('<img/>').addClass('nivo-main-image');
|
78
|
+
sliderImg.attr('src', vars.currentImage.attr('src')).show();
|
79
|
+
slider.append(sliderImg);
|
80
|
+
|
81
|
+
// Detect Window Resize
|
82
|
+
$(window).resize(function() {
|
83
|
+
slider.children('img').width(slider.width());
|
84
|
+
sliderImg.attr('src', vars.currentImage.attr('src'));
|
85
|
+
sliderImg.stop().height('auto');
|
86
|
+
$('.nivo-slice').remove();
|
87
|
+
$('.nivo-box').remove();
|
88
|
+
});
|
89
|
+
|
90
|
+
//Create caption
|
91
|
+
slider.append($('<div class="nivo-caption"></div>'));
|
92
|
+
|
93
|
+
// Process caption function
|
94
|
+
var processCaption = function(settings){
|
95
|
+
var nivoCaption = $('.nivo-caption', slider);
|
96
|
+
if(vars.currentImage.attr('title') != '' && vars.currentImage.attr('title') != undefined){
|
97
|
+
var title = vars.currentImage.attr('title');
|
98
|
+
if(title.substr(0,1) == '#') title = $(title).html();
|
99
|
+
|
100
|
+
if(nivoCaption.css('display') == 'block'){
|
101
|
+
setTimeout(function(){
|
102
|
+
nivoCaption.html(title);
|
103
|
+
}, settings.animSpeed);
|
104
|
+
} else {
|
105
|
+
nivoCaption.html(title);
|
106
|
+
nivoCaption.stop().fadeIn(settings.animSpeed);
|
107
|
+
}
|
108
|
+
} else {
|
109
|
+
nivoCaption.stop().fadeOut(settings.animSpeed);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
//Process initial caption
|
114
|
+
processCaption(settings);
|
115
|
+
|
116
|
+
// In the words of Super Mario "let's a go!"
|
117
|
+
var timer = 0;
|
118
|
+
if(!settings.manualAdvance && kids.length > 1){
|
119
|
+
timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime);
|
120
|
+
}
|
121
|
+
|
122
|
+
// Add Direction nav
|
123
|
+
if(settings.directionNav){
|
124
|
+
slider.append('<div class="nivo-directionNav"><a class="nivo-prevNav">'+ settings.prevText +'</a><a class="nivo-nextNav">'+ settings.nextText +'</a></div>');
|
125
|
+
|
126
|
+
$(slider).on('click', 'a.nivo-prevNav', function(){
|
127
|
+
if(vars.running) { return false; }
|
128
|
+
clearInterval(timer);
|
129
|
+
timer = '';
|
130
|
+
vars.currentSlide -= 2;
|
131
|
+
nivoRun(slider, kids, settings, 'prev');
|
132
|
+
});
|
133
|
+
|
134
|
+
$(slider).on('click', 'a.nivo-nextNav', function(){
|
135
|
+
if(vars.running) { return false; }
|
136
|
+
clearInterval(timer);
|
137
|
+
timer = '';
|
138
|
+
nivoRun(slider, kids, settings, 'next');
|
139
|
+
});
|
140
|
+
}
|
141
|
+
|
142
|
+
// Add Control nav
|
143
|
+
if(settings.controlNav){
|
144
|
+
vars.controlNavEl = $('<div class="nivo-controlNav"></div>');
|
145
|
+
slider.after(vars.controlNavEl);
|
146
|
+
for(var i = 0; i < kids.length; i++){
|
147
|
+
if(settings.controlNavThumbs){
|
148
|
+
vars.controlNavEl.addClass('nivo-thumbs-enabled');
|
149
|
+
var child = kids.eq(i);
|
150
|
+
if(!child.is('img')){
|
151
|
+
child = child.find('img:first');
|
152
|
+
}
|
153
|
+
if(child.attr('data-thumb')) vars.controlNavEl.append('<a class="nivo-control" rel="'+ i +'"><img src="'+ child.attr('data-thumb') +'" alt="" /></a>');
|
154
|
+
} else {
|
155
|
+
vars.controlNavEl.append('<a class="nivo-control" rel="'+ i +'">'+ (i + 1) +'</a>');
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
//Set initial active link
|
160
|
+
$('a:eq('+ vars.currentSlide +')', vars.controlNavEl).addClass('active');
|
161
|
+
|
162
|
+
$('a', vars.controlNavEl).bind('click', function(){
|
163
|
+
if(vars.running) return false;
|
164
|
+
if($(this).hasClass('active')) return false;
|
165
|
+
clearInterval(timer);
|
166
|
+
timer = '';
|
167
|
+
sliderImg.attr('src', vars.currentImage.attr('src'));
|
168
|
+
vars.currentSlide = $(this).attr('rel') - 1;
|
169
|
+
nivoRun(slider, kids, settings, 'control');
|
170
|
+
});
|
171
|
+
}
|
172
|
+
|
173
|
+
//For pauseOnHover setting
|
174
|
+
if(settings.pauseOnHover){
|
175
|
+
slider.hover(function(){
|
176
|
+
vars.paused = true;
|
177
|
+
clearInterval(timer);
|
178
|
+
timer = '';
|
179
|
+
}, function(){
|
180
|
+
vars.paused = false;
|
181
|
+
// Restart the timer
|
182
|
+
if(timer === '' && !settings.manualAdvance){
|
183
|
+
timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime);
|
184
|
+
}
|
185
|
+
});
|
186
|
+
}
|
187
|
+
|
188
|
+
// Event when Animation finishes
|
189
|
+
slider.bind('nivo:animFinished', function(){
|
190
|
+
sliderImg.attr('src', vars.currentImage.attr('src'));
|
191
|
+
vars.running = false;
|
192
|
+
// Hide child links
|
193
|
+
$(kids).each(function(){
|
194
|
+
if($(this).is('a')){
|
195
|
+
$(this).css('display','none');
|
196
|
+
}
|
197
|
+
});
|
198
|
+
// Show current link
|
199
|
+
if($(kids[vars.currentSlide]).is('a')){
|
200
|
+
$(kids[vars.currentSlide]).css('display','block');
|
201
|
+
}
|
202
|
+
// Restart the timer
|
203
|
+
if(timer === '' && !vars.paused && !settings.manualAdvance){
|
204
|
+
timer = setInterval(function(){ nivoRun(slider, kids, settings, false); }, settings.pauseTime);
|
205
|
+
}
|
206
|
+
// Trigger the afterChange callback
|
207
|
+
settings.afterChange.call(this);
|
208
|
+
});
|
209
|
+
|
210
|
+
// Add slices for slice animations
|
211
|
+
var createSlices = function(slider, settings, vars) {
|
212
|
+
if($(vars.currentImage).parent().is('a')) $(vars.currentImage).parent().css('display','block');
|
213
|
+
$('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show();
|
214
|
+
var sliceHeight = ($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().is('a')) ? $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').parent().height() : $('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height();
|
215
|
+
|
216
|
+
for(var i = 0; i < settings.slices; i++){
|
217
|
+
var sliceWidth = Math.round(slider.width()/settings.slices);
|
218
|
+
|
219
|
+
if(i === settings.slices-1){
|
220
|
+
slider.append(
|
221
|
+
$('<div class="nivo-slice" name="'+i+'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block !important; top:0; left:-'+ ((sliceWidth + (i * sliceWidth)) - sliceWidth) +'px;" /></div>').css({
|
222
|
+
left:(sliceWidth*i)+'px',
|
223
|
+
width:(slider.width()-(sliceWidth*i))+'px',
|
224
|
+
height:sliceHeight+'px',
|
225
|
+
opacity:'0',
|
226
|
+
overflow:'hidden'
|
227
|
+
})
|
228
|
+
);
|
229
|
+
} else {
|
230
|
+
slider.append(
|
231
|
+
$('<div class="nivo-slice" name="'+i+'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block !important; top:0; left:-'+ ((sliceWidth + (i * sliceWidth)) - sliceWidth) +'px;" /></div>').css({
|
232
|
+
left:(sliceWidth*i)+'px',
|
233
|
+
width:sliceWidth+'px',
|
234
|
+
height:sliceHeight+'px',
|
235
|
+
opacity:'0',
|
236
|
+
overflow:'hidden'
|
237
|
+
})
|
238
|
+
);
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
$('.nivo-slice', slider).height(sliceHeight);
|
243
|
+
sliderImg.stop().animate({
|
244
|
+
height: $(vars.currentImage).height()
|
245
|
+
}, settings.animSpeed);
|
246
|
+
};
|
247
|
+
|
248
|
+
// Add boxes for box animations
|
249
|
+
var createBoxes = function(slider, settings, vars){
|
250
|
+
if($(vars.currentImage).parent().is('a')) $(vars.currentImage).parent().css('display','block');
|
251
|
+
$('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').width(slider.width()).css('visibility', 'hidden').show();
|
252
|
+
var boxWidth = Math.round(slider.width()/settings.boxCols),
|
253
|
+
boxHeight = Math.round($('img[src="'+ vars.currentImage.attr('src') +'"]', slider).not('.nivo-main-image,.nivo-control img').height() / settings.boxRows);
|
254
|
+
|
255
|
+
|
256
|
+
for(var rows = 0; rows < settings.boxRows; rows++){
|
257
|
+
for(var cols = 0; cols < settings.boxCols; cols++){
|
258
|
+
if(cols === settings.boxCols-1){
|
259
|
+
slider.append(
|
260
|
+
$('<div class="nivo-box" name="'+ cols +'" rel="'+ rows +'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block; top:-'+ (boxHeight*rows) +'px; left:-'+ (boxWidth*cols) +'px;" /></div>').css({
|
261
|
+
opacity:0,
|
262
|
+
left:(boxWidth*cols)+'px',
|
263
|
+
top:(boxHeight*rows)+'px',
|
264
|
+
width:(slider.width()-(boxWidth*cols))+'px'
|
265
|
+
|
266
|
+
})
|
267
|
+
);
|
268
|
+
$('.nivo-box[name="'+ cols +'"]', slider).height($('.nivo-box[name="'+ cols +'"] img', slider).height()+'px');
|
269
|
+
} else {
|
270
|
+
slider.append(
|
271
|
+
$('<div class="nivo-box" name="'+ cols +'" rel="'+ rows +'"><img src="'+ vars.currentImage.attr('src') +'" style="position:absolute; width:'+ slider.width() +'px; height:auto; display:block; top:-'+ (boxHeight*rows) +'px; left:-'+ (boxWidth*cols) +'px;" /></div>').css({
|
272
|
+
opacity:0,
|
273
|
+
left:(boxWidth*cols)+'px',
|
274
|
+
top:(boxHeight*rows)+'px',
|
275
|
+
width:boxWidth+'px'
|
276
|
+
})
|
277
|
+
);
|
278
|
+
$('.nivo-box[name="'+ cols +'"]', slider).height($('.nivo-box[name="'+ cols +'"] img', slider).height()+'px');
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
sliderImg.stop().animate({
|
284
|
+
height: $(vars.currentImage).height()
|
285
|
+
}, settings.animSpeed);
|
286
|
+
};
|
287
|
+
|
288
|
+
// Private run method
|
289
|
+
var nivoRun = function(slider, kids, settings, nudge){
|
290
|
+
// Get our vars
|
291
|
+
var vars = slider.data('nivo:vars');
|
292
|
+
|
293
|
+
// Trigger the lastSlide callback
|
294
|
+
if(vars && (vars.currentSlide === vars.totalSlides - 1)){
|
295
|
+
settings.lastSlide.call(this);
|
296
|
+
}
|
297
|
+
|
298
|
+
// Stop
|
299
|
+
if((!vars || vars.stop) && !nudge) { return false; }
|
300
|
+
|
301
|
+
// Trigger the beforeChange callback
|
302
|
+
settings.beforeChange.call(this);
|
303
|
+
|
304
|
+
// Set current background before change
|
305
|
+
if(!nudge){
|
306
|
+
sliderImg.attr('src', vars.currentImage.attr('src'));
|
307
|
+
} else {
|
308
|
+
if(nudge === 'prev'){
|
309
|
+
sliderImg.attr('src', vars.currentImage.attr('src'));
|
310
|
+
}
|
311
|
+
if(nudge === 'next'){
|
312
|
+
sliderImg.attr('src', vars.currentImage.attr('src'));
|
313
|
+
}
|
314
|
+
}
|
315
|
+
|
316
|
+
vars.currentSlide++;
|
317
|
+
// Trigger the slideshowEnd callback
|
318
|
+
if(vars.currentSlide === vars.totalSlides){
|
319
|
+
vars.currentSlide = 0;
|
320
|
+
settings.slideshowEnd.call(this);
|
321
|
+
}
|
322
|
+
if(vars.currentSlide < 0) { vars.currentSlide = (vars.totalSlides - 1); }
|
323
|
+
// Set vars.currentImage
|
324
|
+
if($(kids[vars.currentSlide]).is('img')){
|
325
|
+
vars.currentImage = $(kids[vars.currentSlide]);
|
326
|
+
} else {
|
327
|
+
vars.currentImage = $(kids[vars.currentSlide]).find('img:first');
|
328
|
+
}
|
329
|
+
|
330
|
+
// Set active links
|
331
|
+
if(settings.controlNav){
|
332
|
+
$('a', vars.controlNavEl).removeClass('active');
|
333
|
+
$('a:eq('+ vars.currentSlide +')', vars.controlNavEl).addClass('active');
|
334
|
+
}
|
335
|
+
|
336
|
+
// Process caption
|
337
|
+
processCaption(settings);
|
338
|
+
|
339
|
+
// Remove any slices from last transition
|
340
|
+
$('.nivo-slice', slider).remove();
|
341
|
+
|
342
|
+
// Remove any boxes from last transition
|
343
|
+
$('.nivo-box', slider).remove();
|
344
|
+
|
345
|
+
var currentEffect = settings.effect,
|
346
|
+
anims = '';
|
347
|
+
|
348
|
+
// Generate random effect
|
349
|
+
if(settings.effect === 'random'){
|
350
|
+
anims = new Array('sliceDownRight','sliceDownLeft','sliceUpRight','sliceUpLeft','sliceUpDown','sliceUpDownLeft','fold','fade',
|
351
|
+
'boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse');
|
352
|
+
currentEffect = anims[Math.floor(Math.random()*(anims.length + 1))];
|
353
|
+
if(currentEffect === undefined) { currentEffect = 'fade'; }
|
354
|
+
}
|
355
|
+
|
356
|
+
// Run random effect from specified set (eg: effect:'fold,fade')
|
357
|
+
if(settings.effect.indexOf(',') !== -1){
|
358
|
+
anims = settings.effect.split(',');
|
359
|
+
currentEffect = anims[Math.floor(Math.random()*(anims.length))];
|
360
|
+
if(currentEffect === undefined) { currentEffect = 'fade'; }
|
361
|
+
}
|
362
|
+
|
363
|
+
// Custom transition as defined by "data-transition" attribute
|
364
|
+
if(vars.currentImage.attr('data-transition')){
|
365
|
+
currentEffect = vars.currentImage.attr('data-transition');
|
366
|
+
}
|
367
|
+
|
368
|
+
// Run effects
|
369
|
+
vars.running = true;
|
370
|
+
var timeBuff = 0,
|
371
|
+
i = 0,
|
372
|
+
slices = '',
|
373
|
+
firstSlice = '',
|
374
|
+
totalBoxes = '',
|
375
|
+
boxes = '';
|
376
|
+
|
377
|
+
if(currentEffect === 'sliceDown' || currentEffect === 'sliceDownRight' || currentEffect === 'sliceDownLeft'){
|
378
|
+
createSlices(slider, settings, vars);
|
379
|
+
timeBuff = 0;
|
380
|
+
i = 0;
|
381
|
+
slices = $('.nivo-slice', slider);
|
382
|
+
if(currentEffect === 'sliceDownLeft') { slices = $('.nivo-slice', slider)._reverse(); }
|
383
|
+
|
384
|
+
slices.each(function(){
|
385
|
+
var slice = $(this);
|
386
|
+
slice.css({ 'top': '0px' });
|
387
|
+
if(i === settings.slices-1){
|
388
|
+
setTimeout(function(){
|
389
|
+
slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
|
390
|
+
}, (100 + timeBuff));
|
391
|
+
} else {
|
392
|
+
setTimeout(function(){
|
393
|
+
slice.animate({opacity:'1.0' }, settings.animSpeed);
|
394
|
+
}, (100 + timeBuff));
|
395
|
+
}
|
396
|
+
timeBuff += 50;
|
397
|
+
i++;
|
398
|
+
});
|
399
|
+
} else if(currentEffect === 'sliceUp' || currentEffect === 'sliceUpRight' || currentEffect === 'sliceUpLeft'){
|
400
|
+
createSlices(slider, settings, vars);
|
401
|
+
timeBuff = 0;
|
402
|
+
i = 0;
|
403
|
+
slices = $('.nivo-slice', slider);
|
404
|
+
if(currentEffect === 'sliceUpLeft') { slices = $('.nivo-slice', slider)._reverse(); }
|
405
|
+
|
406
|
+
slices.each(function(){
|
407
|
+
var slice = $(this);
|
408
|
+
slice.css({ 'bottom': '0px' });
|
409
|
+
if(i === settings.slices-1){
|
410
|
+
setTimeout(function(){
|
411
|
+
slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
|
412
|
+
}, (100 + timeBuff));
|
413
|
+
} else {
|
414
|
+
setTimeout(function(){
|
415
|
+
slice.animate({opacity:'1.0' }, settings.animSpeed);
|
416
|
+
}, (100 + timeBuff));
|
417
|
+
}
|
418
|
+
timeBuff += 50;
|
419
|
+
i++;
|
420
|
+
});
|
421
|
+
} else if(currentEffect === 'sliceUpDown' || currentEffect === 'sliceUpDownRight' || currentEffect === 'sliceUpDownLeft'){
|
422
|
+
createSlices(slider, settings, vars);
|
423
|
+
timeBuff = 0;
|
424
|
+
i = 0;
|
425
|
+
var v = 0;
|
426
|
+
slices = $('.nivo-slice', slider);
|
427
|
+
if(currentEffect === 'sliceUpDownLeft') { slices = $('.nivo-slice', slider)._reverse(); }
|
428
|
+
|
429
|
+
slices.each(function(){
|
430
|
+
var slice = $(this);
|
431
|
+
if(i === 0){
|
432
|
+
slice.css('top','0px');
|
433
|
+
i++;
|
434
|
+
} else {
|
435
|
+
slice.css('bottom','0px');
|
436
|
+
i = 0;
|
437
|
+
}
|
438
|
+
|
439
|
+
if(v === settings.slices-1){
|
440
|
+
setTimeout(function(){
|
441
|
+
slice.animate({opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
|
442
|
+
}, (100 + timeBuff));
|
443
|
+
} else {
|
444
|
+
setTimeout(function(){
|
445
|
+
slice.animate({opacity:'1.0' }, settings.animSpeed);
|
446
|
+
}, (100 + timeBuff));
|
447
|
+
}
|
448
|
+
timeBuff += 50;
|
449
|
+
v++;
|
450
|
+
});
|
451
|
+
} else if(currentEffect === 'fold'){
|
452
|
+
createSlices(slider, settings, vars);
|
453
|
+
timeBuff = 0;
|
454
|
+
i = 0;
|
455
|
+
|
456
|
+
$('.nivo-slice', slider).each(function(){
|
457
|
+
var slice = $(this);
|
458
|
+
var origWidth = slice.width();
|
459
|
+
slice.css({ top:'0px', width:'0px' });
|
460
|
+
if(i === settings.slices-1){
|
461
|
+
setTimeout(function(){
|
462
|
+
slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
|
463
|
+
}, (100 + timeBuff));
|
464
|
+
} else {
|
465
|
+
setTimeout(function(){
|
466
|
+
slice.animate({ width:origWidth, opacity:'1.0' }, settings.animSpeed);
|
467
|
+
}, (100 + timeBuff));
|
468
|
+
}
|
469
|
+
timeBuff += 50;
|
470
|
+
i++;
|
471
|
+
});
|
472
|
+
} else if(currentEffect === 'fade'){
|
473
|
+
createSlices(slider, settings, vars);
|
474
|
+
|
475
|
+
firstSlice = $('.nivo-slice:first', slider);
|
476
|
+
firstSlice.css({
|
477
|
+
'width': slider.width() + 'px'
|
478
|
+
});
|
479
|
+
|
480
|
+
firstSlice.animate({ opacity:'1.0' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); });
|
481
|
+
} else if(currentEffect === 'slideInRight'){
|
482
|
+
createSlices(slider, settings, vars);
|
483
|
+
|
484
|
+
firstSlice = $('.nivo-slice:first', slider);
|
485
|
+
firstSlice.css({
|
486
|
+
'width': '0px',
|
487
|
+
'opacity': '1'
|
488
|
+
});
|
489
|
+
|
490
|
+
firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){ slider.trigger('nivo:animFinished'); });
|
491
|
+
} else if(currentEffect === 'slideInLeft'){
|
492
|
+
createSlices(slider, settings, vars);
|
493
|
+
|
494
|
+
firstSlice = $('.nivo-slice:first', slider);
|
495
|
+
firstSlice.css({
|
496
|
+
'width': '0px',
|
497
|
+
'opacity': '1',
|
498
|
+
'left': '',
|
499
|
+
'right': '0px'
|
500
|
+
});
|
501
|
+
|
502
|
+
firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed*2), '', function(){
|
503
|
+
// Reset positioning
|
504
|
+
firstSlice.css({
|
505
|
+
'left': '0px',
|
506
|
+
'right': ''
|
507
|
+
});
|
508
|
+
slider.trigger('nivo:animFinished');
|
509
|
+
});
|
510
|
+
} else if(currentEffect === 'boxRandom'){
|
511
|
+
createBoxes(slider, settings, vars);
|
512
|
+
|
513
|
+
totalBoxes = settings.boxCols * settings.boxRows;
|
514
|
+
i = 0;
|
515
|
+
timeBuff = 0;
|
516
|
+
|
517
|
+
boxes = shuffle($('.nivo-box', slider));
|
518
|
+
boxes.each(function(){
|
519
|
+
var box = $(this);
|
520
|
+
if(i === totalBoxes-1){
|
521
|
+
setTimeout(function(){
|
522
|
+
box.animate({ opacity:'1' }, settings.animSpeed, '', function(){ slider.trigger('nivo:animFinished'); });
|
523
|
+
}, (100 + timeBuff));
|
524
|
+
} else {
|
525
|
+
setTimeout(function(){
|
526
|
+
box.animate({ opacity:'1' }, settings.animSpeed);
|
527
|
+
}, (100 + timeBuff));
|
528
|
+
}
|
529
|
+
timeBuff += 20;
|
530
|
+
i++;
|
531
|
+
});
|
532
|
+
} else if(currentEffect === 'boxRain' || currentEffect === 'boxRainReverse' || currentEffect === 'boxRainGrow' || currentEffect === 'boxRainGrowReverse'){
|
533
|
+
createBoxes(slider, settings, vars);
|
534
|
+
|
535
|
+
totalBoxes = settings.boxCols * settings.boxRows;
|
536
|
+
i = 0;
|
537
|
+
timeBuff = 0;
|
538
|
+
|
539
|
+
// Split boxes into 2D array
|
540
|
+
var rowIndex = 0;
|
541
|
+
var colIndex = 0;
|
542
|
+
var box2Darr = [];
|
543
|
+
box2Darr[rowIndex] = [];
|
544
|
+
boxes = $('.nivo-box', slider);
|
545
|
+
if(currentEffect === 'boxRainReverse' || currentEffect === 'boxRainGrowReverse'){
|
546
|
+
boxes = $('.nivo-box', slider)._reverse();
|
547
|
+
}
|
548
|
+
boxes.each(function(){
|
549
|
+
box2Darr[rowIndex][colIndex] = $(this);
|
550
|
+
colIndex++;
|
551
|
+
if(colIndex === settings.boxCols){
|
552
|
+
rowIndex++;
|
553
|
+
colIndex = 0;
|
554
|
+
box2Darr[rowIndex] = [];
|
555
|
+
}
|
556
|
+
});
|
557
|
+
|
558
|
+
// Run animation
|
559
|
+
for(var cols = 0; cols < (settings.boxCols * 2); cols++){
|
560
|
+
var prevCol = cols;
|
561
|
+
for(var rows = 0; rows < settings.boxRows; rows++){
|
562
|
+
if(prevCol >= 0 && prevCol < settings.boxCols){
|
563
|
+
/* Due to some weird JS bug with loop vars
|
564
|
+
being used in setTimeout, this is wrapped
|
565
|
+
with an anonymous function call */
|
566
|
+
(function(row, col, time, i, totalBoxes) {
|
567
|
+
var box = $(box2Darr[row][col]);
|
568
|
+
var w = box.width();
|
569
|
+
var h = box.height();
|
570
|
+
if(currentEffect === 'boxRainGrow' || currentEffect === 'boxRainGrowReverse'){
|
571
|
+
box.width(0).height(0);
|
572
|
+
}
|
573
|
+
if(i === totalBoxes-1){
|
574
|
+
setTimeout(function(){
|
575
|
+
box.animate({ opacity:'1', width:w, height:h }, settings.animSpeed/1.3, '', function(){ slider.trigger('nivo:animFinished'); });
|
576
|
+
}, (100 + time));
|
577
|
+
} else {
|
578
|
+
setTimeout(function(){
|
579
|
+
box.animate({ opacity:'1', width:w, height:h }, settings.animSpeed/1.3);
|
580
|
+
}, (100 + time));
|
581
|
+
}
|
582
|
+
})(rows, prevCol, timeBuff, i, totalBoxes);
|
583
|
+
i++;
|
584
|
+
}
|
585
|
+
prevCol--;
|
586
|
+
}
|
587
|
+
timeBuff += 100;
|
588
|
+
}
|
589
|
+
}
|
590
|
+
};
|
591
|
+
|
592
|
+
// Shuffle an array
|
593
|
+
var shuffle = function(arr){
|
594
|
+
for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i, 10), x = arr[--i], arr[i] = arr[j], arr[j] = x);
|
595
|
+
return arr;
|
596
|
+
};
|
597
|
+
|
598
|
+
// For debugging
|
599
|
+
var trace = function(msg){
|
600
|
+
if(this.console && typeof console.log !== 'undefined') { console.log(msg); }
|
601
|
+
};
|
602
|
+
|
603
|
+
// Start / Stop
|
604
|
+
this.stop = function(){
|
605
|
+
if(!$(element).data('nivo:vars').stop){
|
606
|
+
$(element).data('nivo:vars').stop = true;
|
607
|
+
trace('Stop Slider');
|
608
|
+
}
|
609
|
+
};
|
610
|
+
|
611
|
+
this.start = function(){
|
612
|
+
if($(element).data('nivo:vars').stop){
|
613
|
+
$(element).data('nivo:vars').stop = false;
|
614
|
+
trace('Start Slider');
|
615
|
+
}
|
616
|
+
};
|
617
|
+
|
618
|
+
// Trigger the afterLoad callback
|
619
|
+
settings.afterLoad.call(this);
|
620
|
+
|
621
|
+
return this;
|
622
|
+
};
|
623
|
+
|
624
|
+
$.fn.nivoSlider = function(options) {
|
625
|
+
return this.each(function(key, value){
|
626
|
+
var element = $(this);
|
627
|
+
// Return early if this element already has a plugin instance
|
628
|
+
if (element.data('nivoslider')) { return element.data('nivoslider'); }
|
629
|
+
// Pass options to plugin constructor
|
630
|
+
var nivoslider = new NivoSlider(this, options);
|
631
|
+
// Store plugin object in this element's data
|
632
|
+
element.data('nivoslider', nivoslider);
|
633
|
+
});
|
634
|
+
};
|
635
|
+
|
636
|
+
//Default settings
|
637
|
+
$.fn.nivoSlider.defaults = {
|
638
|
+
effect: 'random',
|
639
|
+
slices: 15,
|
640
|
+
boxCols: 8,
|
641
|
+
boxRows: 4,
|
642
|
+
animSpeed: 500,
|
643
|
+
pauseTime: 3000,
|
644
|
+
startSlide: 0,
|
645
|
+
directionNav: true,
|
646
|
+
controlNav: true,
|
647
|
+
controlNavThumbs: false,
|
648
|
+
pauseOnHover: true,
|
649
|
+
manualAdvance: false,
|
650
|
+
prevText: 'Prev',
|
651
|
+
nextText: 'Next',
|
652
|
+
randomStart: false,
|
653
|
+
beforeChange: function(){},
|
654
|
+
afterChange: function(){},
|
655
|
+
slideshowEnd: function(){},
|
656
|
+
lastSlide: function(){},
|
657
|
+
afterLoad: function(){}
|
658
|
+
};
|
659
|
+
|
660
|
+
$.fn._reverse = [].reverse;
|
661
|
+
|
662
|
+
})(jQuery);
|