spree_carousels 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ tmp
8
+ nbproject
9
+ *.swp
10
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,204 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ spree_carousels (1.1.3)
5
+ spree_core (~> 1.1.3)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.8)
11
+ actionpack (= 3.2.8)
12
+ mail (~> 2.4.4)
13
+ actionpack (3.2.8)
14
+ activemodel (= 3.2.8)
15
+ activesupport (= 3.2.8)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.0)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.1.3)
23
+ active_utils (1.0.4)
24
+ activesupport (>= 2.3.11)
25
+ i18n
26
+ activemerchant (1.20.4)
27
+ active_utils (>= 1.0.2)
28
+ activesupport (>= 2.3.11)
29
+ braintree (>= 2.0.0)
30
+ builder (>= 2.0.0)
31
+ i18n
32
+ json (>= 1.5.1)
33
+ money (<= 3.7.1)
34
+ activemodel (3.2.8)
35
+ activesupport (= 3.2.8)
36
+ builder (~> 3.0.0)
37
+ activerecord (3.2.8)
38
+ activemodel (= 3.2.8)
39
+ activesupport (= 3.2.8)
40
+ arel (~> 3.0.2)
41
+ tzinfo (~> 0.3.29)
42
+ activeresource (3.2.8)
43
+ activemodel (= 3.2.8)
44
+ activesupport (= 3.2.8)
45
+ activesupport (3.2.8)
46
+ i18n (~> 0.6)
47
+ multi_json (~> 1.0)
48
+ acts_as_list (0.1.4)
49
+ addressable (2.3.2)
50
+ arel (3.0.2)
51
+ aws-sdk (1.3.9)
52
+ httparty (~> 0.7)
53
+ json (~> 1.4)
54
+ nokogiri (>= 1.4.4)
55
+ uuidtools (~> 2.1)
56
+ braintree (2.16.0)
57
+ builder (>= 2.0.0)
58
+ builder (3.0.0)
59
+ capybara (1.0.1)
60
+ mime-types (>= 1.16)
61
+ nokogiri (>= 1.3.3)
62
+ rack (>= 1.0.0)
63
+ rack-test (>= 0.5.4)
64
+ selenium-webdriver (~> 2.0)
65
+ xpath (~> 0.1.4)
66
+ childprocess (0.3.5)
67
+ ffi (~> 1.0, >= 1.0.6)
68
+ cocaine (0.3.0)
69
+ deface (0.9.1)
70
+ nokogiri (~> 1.5.0)
71
+ rails (~> 3.1)
72
+ diff-lcs (1.1.3)
73
+ erubis (2.7.0)
74
+ factory_girl (2.6.4)
75
+ activesupport (>= 2.3.9)
76
+ ffaker (1.12.1)
77
+ ffi (1.1.5)
78
+ highline (1.6.11)
79
+ hike (1.2.1)
80
+ httparty (0.8.3)
81
+ multi_json (~> 1.0)
82
+ multi_xml
83
+ i18n (0.6.1)
84
+ journey (1.0.4)
85
+ jquery-rails (2.0.3)
86
+ railties (>= 3.1.0, < 5.0)
87
+ thor (~> 0.14)
88
+ json (1.7.5)
89
+ kaminari (0.14.0)
90
+ actionpack (>= 3.0.0)
91
+ activesupport (>= 3.0.0)
92
+ libwebsocket (0.1.5)
93
+ addressable
94
+ mail (2.4.4)
95
+ i18n (>= 0.4.0)
96
+ mime-types (~> 1.16)
97
+ treetop (~> 1.4.8)
98
+ mime-types (1.19)
99
+ money (3.7.1)
100
+ i18n (~> 0.4)
101
+ multi_json (1.3.6)
102
+ multi_xml (0.5.1)
103
+ nested_set (1.7.0)
104
+ activerecord (>= 3.0.0)
105
+ railties (>= 3.0.0)
106
+ nokogiri (1.5.5)
107
+ paperclip (2.7.0)
108
+ activerecord (>= 2.3.0)
109
+ activesupport (>= 2.3.2)
110
+ cocaine (>= 0.0.2)
111
+ mime-types
112
+ polyamorous (0.5.0)
113
+ activerecord (~> 3.0)
114
+ polyglot (0.3.3)
115
+ rack (1.4.1)
116
+ rack-cache (1.2)
117
+ rack (>= 0.4)
118
+ rack-ssl (1.3.2)
119
+ rack
120
+ rack-test (0.6.1)
121
+ rack (>= 1.0)
122
+ rails (3.2.8)
123
+ actionmailer (= 3.2.8)
124
+ actionpack (= 3.2.8)
125
+ activerecord (= 3.2.8)
126
+ activeresource (= 3.2.8)
127
+ activesupport (= 3.2.8)
128
+ bundler (~> 1.0)
129
+ railties (= 3.2.8)
130
+ railties (3.2.8)
131
+ actionpack (= 3.2.8)
132
+ activesupport (= 3.2.8)
133
+ rack-ssl (~> 1.3.2)
134
+ rake (>= 0.8.7)
135
+ rdoc (~> 3.4)
136
+ thor (>= 0.14.6, < 2.0)
137
+ rake (0.9.2.2)
138
+ ransack (0.6.0)
139
+ actionpack (~> 3.0)
140
+ activerecord (~> 3.0)
141
+ polyamorous (~> 0.5.0)
142
+ rdoc (3.12)
143
+ json (~> 1.4)
144
+ rspec (2.11.0)
145
+ rspec-core (~> 2.11.0)
146
+ rspec-expectations (~> 2.11.0)
147
+ rspec-mocks (~> 2.11.0)
148
+ rspec-core (2.11.1)
149
+ rspec-expectations (2.11.2)
150
+ diff-lcs (~> 1.1.3)
151
+ rspec-mocks (2.11.2)
152
+ rspec-rails (2.11.0)
153
+ actionpack (>= 3.0)
154
+ activesupport (>= 3.0)
155
+ railties (>= 3.0)
156
+ rspec (~> 2.11.0)
157
+ rubyzip (0.9.9)
158
+ selenium-webdriver (2.25.0)
159
+ childprocess (>= 0.2.5)
160
+ libwebsocket (~> 0.1.3)
161
+ multi_json (~> 1.0)
162
+ rubyzip
163
+ spree_core (1.1.3)
164
+ activemerchant (= 1.20.4)
165
+ acts_as_list (= 0.1.4)
166
+ aws-sdk (~> 1.3.4)
167
+ deface (>= 0.9.0)
168
+ ffaker (~> 1.12.0)
169
+ highline (= 1.6.11)
170
+ jquery-rails (~> 2.0.0)
171
+ kaminari (>= 0.13.0)
172
+ nested_set (= 1.7.0)
173
+ paperclip (~> 2.7)
174
+ rails (~> 3.2.6)
175
+ ransack (~> 0.6.0)
176
+ state_machine (= 1.1.2)
177
+ stringex (~> 1.3.2)
178
+ sprockets (2.1.3)
179
+ hike (~> 1.2)
180
+ rack (~> 1.0)
181
+ tilt (~> 1.1, != 1.3.0)
182
+ sqlite3 (1.3.6)
183
+ state_machine (1.1.2)
184
+ stringex (1.3.3)
185
+ thor (0.16.0)
186
+ tilt (1.3.3)
187
+ treetop (1.4.10)
188
+ polyglot
189
+ polyglot (>= 0.3.1)
190
+ tzinfo (0.3.33)
191
+ uuidtools (2.1.3)
192
+ xpath (0.1.4)
193
+ nokogiri (~> 1.3)
194
+
195
+ PLATFORMS
196
+ ruby
197
+
198
+ DEPENDENCIES
199
+ capybara (= 1.0.1)
200
+ factory_girl (~> 2.6.4)
201
+ ffaker
202
+ rspec-rails (~> 2.9)
203
+ spree_carousels!
204
+ sqlite3
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2012 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ SpreeCarousels
2
+ ==============
3
+
4
+ Introduction goes here.
5
+
6
+
7
+ Example
8
+ =======
9
+
10
+ Example goes here.
11
+
12
+ Testing
13
+ -------
14
+
15
+ Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
16
+
17
+ $ bundle
18
+ $ bundle exec rake test_app
19
+ $ bundle exec rspec spec
20
+
21
+ Copyright (c) 2012 [name of extension creator], released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/packagetask'
4
+ require 'rubygems/package_task'
5
+ require 'rspec/core/rake_task'
6
+ require 'spree/core/testing_support/common_rake'
7
+
8
+ RSpec::Core::RakeTask.new
9
+
10
+ task :default => [:spec]
11
+
12
+ spec = eval(File.read('spree_carousels.gemspec'))
13
+
14
+ Gem::PackageTask.new(spec) do |p|
15
+ p.gem_spec = spec
16
+ end
17
+
18
+ desc 'Release to gemcutter'
19
+ task :release => :package do
20
+ require 'rake/gemcutter'
21
+ Rake::Gemcutter::Tasks.new(spec).define
22
+ Rake::Task['gem:push'].invoke
23
+ end
24
+
25
+ desc 'Generates a dummy app for testing'
26
+ task :test_app do
27
+ ENV['LIB_NAME'] = 'spree_carousels'
28
+ Rake::Task['common:test_app'].invoke
29
+ end
data/Versionfile ADDED
@@ -0,0 +1,11 @@
1
+ # This file is used to designate compatibilty with different versions of Spree
2
+ # Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
3
+
4
+ # Examples
5
+ #
6
+ # '1.2.x' => { :branch => 'master' }
7
+ # '1.1.x' => { :branch => '1-1-stable' }
8
+ # '1.0.x' => { :branch => '1-0-stable' }
9
+ # '0.70.x' => { :branch => '0-70-stable' }
10
+ # '0.40.x' => { :tag => 'v1.0.0', :version => '1.0.0' }
11
+
@@ -0,0 +1 @@
1
+ //= require admin/spree_core
@@ -0,0 +1,24 @@
1
+ #= require store/spree_core
2
+ #= require jquery.carouFredSel-5.6.1
3
+
4
+ $(document).bind('ready',->
5
+ console.log($('.carousel').length)
6
+ $('.carousel').each((index, element) ->
7
+ element = $(element)
8
+ element.find('.carousel-listing').carouFredSel({
9
+ circular : false,
10
+ infinite : false,
11
+ auto : false,
12
+ prev : {
13
+ button : element.find('.prev'),
14
+ key : "left",
15
+ items : 1,
16
+ },
17
+ next : {
18
+ button : element.find('.next'),
19
+ key : "right",
20
+ items : 1,
21
+ }
22
+ })
23
+ )
24
+ )
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_core
3
+ */
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require store/spree_core
3
+ */
@@ -0,0 +1,6 @@
1
+ Spree::Taxonomy.purposes << 'carousel'
2
+
3
+ Spree::Taxonomy.class_eval do
4
+ scope :published_carousels, published.where(purpose: 'carousel')
5
+ has_many :products, through: :taxons
6
+ end
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(
2
+ virtual_path: "spree/home/index",
3
+ partial: 'spree/spree_carousels/taxon_carousels',
4
+ replace: "code[erb-loud]:contains('spree/shared/products')",
5
+ name: 'add_home_page_taxon_carousels')
@@ -0,0 +1,12 @@
1
+ <% if Spree::Config[:show_zero_stock_products] || product.has_stock? %>
2
+ <li id="product_<%= product.id %>" class="columns three" data-hook="products_list_item" itemscope itemtype="http://schema.org/Product">
3
+ <div class="product-image">
4
+ <%= link_to small_image(product, :itemprop => "image"), product, :itemprop => 'url' %>
5
+ </div>
6
+ <div class="white">
7
+ <div class="arrow-up"></div>
8
+ </div>
9
+ <%= link_to truncate(product.name, :length => 50), product, :class => 'info', :itemprop => "name", :title => product.name %>
10
+ <span class="price selling" itemprop="price"><%= number_to_currency product.price %></span>
11
+ </li>
12
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <ul id="products" class="inline carousel-listing" data-hook>
2
+ <% reset_cycle('default') %>
3
+ <%= render partial: 'spree/products/product', collection: products %>
4
+ </ul>
@@ -0,0 +1,19 @@
1
+ <div class="carousels full-size-carousels marginator">
2
+
3
+ <% Spree::Taxonomy.published_carousels.each do |carousel| %>
4
+
5
+ <div class="carousel <%= carousel.style %>">
6
+ <div class="carousel-title">
7
+ <%= carousel.name %>:
8
+ </div>
9
+ <div class="carousel-products">
10
+ <%= render partial: 'spree/products/products', locals: { products: carousel.products } %>
11
+ </div>
12
+ <div class="clearfix"></div>
13
+ <a class="prev" href="#"><span>prev</span></a>
14
+ <a class="next" href="#"><span>next</span></a>
15
+ </div>
16
+
17
+ <% end %>
18
+
19
+ </div>
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ # Add your extension routes here
3
+ end
@@ -0,0 +1,2700 @@
1
+ /*
2
+ * jQuery carouFredSel 5.6.1
3
+ * Demo's and documentation:
4
+ * caroufredsel.frebsite.nl
5
+ *
6
+ * Copyright (c) 2012 Fred Heusschen
7
+ * www.frebsite.nl
8
+ *
9
+ * Dual licensed under the MIT and GPL licenses.
10
+ * http://en.wikipedia.org/wiki/MIT_License
11
+ * http://en.wikipedia.org/wiki/GNU_General_Public_License
12
+ */
13
+
14
+
15
+ (function($) {
16
+
17
+
18
+
19
+ // LOCAL
20
+
21
+ if ($.fn.carouFredSel) return;
22
+
23
+ $.fn.carouFredSel = function(options, configs) {
24
+ if (this.length == 0) {
25
+ debug(true, 'No element found for "'+this.selector+'".');
26
+ return this;
27
+ }
28
+ if (this.length > 1) {
29
+ return this.each(function() {
30
+ $(this).carouFredSel(options, configs);
31
+ });
32
+ }
33
+
34
+ var $cfs = this,
35
+ $tt0 = this[0];
36
+
37
+ if ($cfs.data('cfs_isCarousel')) {
38
+ var starting_position = $cfs.triggerHandler('_cfs_triggerEvent', 'currentPosition');
39
+ $cfs.trigger('_cfs_triggerEvent', ['destroy', true]);
40
+ } else {
41
+ var starting_position = false;
42
+ }
43
+
44
+ $cfs._cfs_init = function(o, setOrig, start) {
45
+ o = go_getObject($tt0, o);
46
+
47
+ var obs = ['items', 'scroll', 'auto', 'prev', 'next', 'pagination'];
48
+ for (var a = 0, l = obs.length; a < l; a++) {
49
+ o[obs[a]] = go_getObject($tt0, o[obs[a]]);
50
+ }
51
+
52
+ if (typeof o.scroll == 'number') {
53
+ if (o.scroll <= 50) o.scroll = { 'items' : o.scroll };
54
+ else o.scroll = { 'duration' : o.scroll };
55
+ } else {
56
+ if (typeof o.scroll == 'string') o.scroll = { 'easing' : o.scroll };
57
+ }
58
+
59
+ if (typeof o.items == 'number') o.items = { 'visible' : o.items };
60
+ else if ( o.items == 'variable') o.items = { 'visible' : o.items,
61
+ 'width' : o.items,
62
+ 'height' : o.items };
63
+
64
+ if (typeof o.items != 'object') o.items = {};
65
+ if (setOrig) opts_orig = $.extend(true, {}, $.fn.carouFredSel.defaults, o);
66
+
67
+ opts = $.extend(true, {}, $.fn.carouFredSel.defaults, o);
68
+
69
+ if (typeof opts.items.visibleConf != 'object') opts.items.visibleConf = {};
70
+
71
+ if (opts.items.start == 0 && typeof start == 'number') {
72
+ opts.items.start = start;
73
+ }
74
+
75
+ crsl.upDateOnWindowResize = (opts.responsive);
76
+ crsl.direction = (opts.direction == 'up' || opts.direction == 'left') ? 'next' : 'prev';
77
+
78
+ var dims = [
79
+ ['width' , 'innerWidth' , 'outerWidth' , 'height' , 'innerHeight' , 'outerHeight' , 'left', 'top' , 'marginRight' , 0, 1, 2, 3],
80
+ ['height' , 'innerHeight' , 'outerHeight' , 'width' , 'innerWidth' , 'outerWidth' , 'top' , 'left', 'marginBottom', 3, 2, 1, 0]
81
+ ];
82
+
83
+ var dn = dims[0].length,
84
+ dx = (opts.direction == 'right' || opts.direction == 'left') ? 0 : 1;
85
+
86
+ opts.d = {};
87
+ for (var d = 0; d < dn; d++) {
88
+ opts.d[dims[0][d]] = dims[dx][d];
89
+ }
90
+
91
+ var all_itm = $cfs.children();
92
+
93
+
94
+ // check visible items
95
+ switch (typeof opts.items.visible) {
96
+
97
+ // min and max visible items
98
+ case 'object':
99
+ opts.items.visibleConf.min = opts.items.visible.min;
100
+ opts.items.visibleConf.max = opts.items.visible.max;
101
+ opts.items.visible = false;
102
+ break;
103
+
104
+ case 'string':
105
+ // variable visible items
106
+ if (opts.items.visible == 'variable') {
107
+ opts.items.visibleConf.variable = true;
108
+
109
+ // adjust string visible items
110
+ } else {
111
+ opts.items.visibleConf.adjust = opts.items.visible;
112
+ }
113
+ opts.items.visible = false;
114
+ break;
115
+
116
+ // function visible items
117
+ case 'function':
118
+ opts.items.visibleConf.adjust = opts.items.visible;
119
+ opts.items.visible = false;
120
+ break;
121
+ }
122
+
123
+ // set items filter
124
+ if (typeof opts.items.filter == 'undefined') {
125
+ opts.items.filter = (all_itm.filter(':hidden').length > 0) ? ':visible' : '*';
126
+ }
127
+
128
+ // primary size set to auto -> measure largest size and set it
129
+ if (opts[opts.d['width']] == 'auto') {
130
+ opts[opts.d['width']] = ms_getTrueLargestSize(all_itm, opts, 'outerWidth');
131
+ }
132
+ // primary size percentage
133
+ if (ms_isPercentage(opts[opts.d['width']]) && !opts.responsive) {
134
+ opts[opts.d['width']] = ms_getPercentage(ms_getTrueInnerSize($wrp.parent(), opts, 'innerWidth'), opts[opts.d['width']]);
135
+ crsl.upDateOnWindowResize = true;
136
+ }
137
+
138
+ // secondary size set to auto -> measure largest size and set it
139
+ if (opts[opts.d['height']] == 'auto') {
140
+ opts[opts.d['height']] = ms_getTrueLargestSize(all_itm, opts, 'outerHeight');
141
+ }
142
+
143
+ // primary item-size not set
144
+ if (!opts.items[opts.d['width']]) {
145
+ // responsive carousel -> set to largest
146
+ if (opts.responsive) {
147
+ debug(true, 'Set a '+opts.d['width']+' for the items!');
148
+ opts.items[opts.d['width']] = ms_getTrueLargestSize(all_itm, opts, 'outerWidth');
149
+ // non-responsive -> measure it or set to "variable"
150
+ } else {
151
+ opts.items[opts.d['width']] = (ms_hasVariableSizes(all_itm, opts, 'outerWidth'))
152
+ ? 'variable'
153
+ : all_itm[opts.d['outerWidth']](true);
154
+ }
155
+ }
156
+
157
+ // secondary item-size not set -> measure it or set to "variable"
158
+ if (!opts.items[opts.d['height']]) {
159
+ opts.items[opts.d['height']] = (ms_hasVariableSizes(all_itm, opts, 'outerHeight'))
160
+ ? 'variable'
161
+ : all_itm[opts.d['outerHeight']](true);
162
+ }
163
+
164
+ // secondary size not set -> set to secondary item-size
165
+ if (!opts[opts.d['height']]) {
166
+ opts[opts.d['height']] = opts.items[opts.d['height']];
167
+ }
168
+
169
+ // visible-items not set
170
+ if (!opts.items.visible && !opts.responsive) {
171
+ // primary item-size variable -> set visible items variable
172
+ if (opts.items[opts.d['width']] == 'variable') {
173
+ opts.items.visibleConf.variable = true;
174
+ }
175
+ if (!opts.items.visibleConf.variable) {
176
+ // primary size is number -> calculate visible-items
177
+ if (typeof opts[opts.d['width']] == 'number') {
178
+ opts.items.visible = Math.floor(opts[opts.d['width']] / opts.items[opts.d['width']]);
179
+ } else {
180
+ // measure and calculate primary size and visible-items
181
+ var maxS = ms_getTrueInnerSize($wrp.parent(), opts, 'innerWidth');
182
+ opts.items.visible = Math.floor(maxS / opts.items[opts.d['width']]);
183
+ opts[opts.d['width']] = opts.items.visible * opts.items[opts.d['width']];
184
+ if (!opts.items.visibleConf.adjust) opts.align = false;
185
+ }
186
+ if (opts.items.visible == 'Infinity' || opts.items.visible < 1) {
187
+ debug(true, 'Not a valid number of visible items: Set to "variable".');
188
+ opts.items.visibleConf.variable = true;
189
+ }
190
+ }
191
+ }
192
+
193
+ // primary size not set -> calculate it or set to "variable"
194
+ if (!opts[opts.d['width']]) {
195
+ opts[opts.d['width']] = 'variable';
196
+ if (!opts.responsive && opts.items.filter == '*' && !opts.items.visibleConf.variable && opts.items[opts.d['width']] != 'variable') {
197
+ opts[opts.d['width']] = opts.items.visible * opts.items[opts.d['width']];
198
+ opts.align = false;
199
+ }
200
+ }
201
+
202
+ // variable primary item-sizes with variabe visible-items
203
+ if (opts.items.visibleConf.variable) {
204
+ opts.maxDimention = (opts[opts.d['width']] == 'variable')
205
+ ? ms_getTrueInnerSize($wrp.parent(), opts, 'innerWidth')
206
+ : opts[opts.d['width']];
207
+ if (opts.align === false) {
208
+ opts[opts.d['width']] = 'variable';
209
+ }
210
+ opts.items.visible = gn_getVisibleItemsNext(all_itm, opts, 0);
211
+
212
+ // set visible items by filter
213
+ } else if (opts.items.filter != '*') {
214
+ opts.items.visibleConf.org = opts.items.visible;
215
+ opts.items.visible = gn_getVisibleItemsNextFilter(all_itm, opts, 0);
216
+ }
217
+
218
+ // align not set -> set to center if primary size is number
219
+ if (typeof opts.align == 'undefined') {
220
+ opts.align = (opts[opts.d['width']] == 'variable')
221
+ ? false
222
+ : 'center';
223
+ }
224
+
225
+ opts.items.visible = cf_getItemsAdjust(opts.items.visible, opts, opts.items.visibleConf.adjust, $tt0);
226
+ opts.items.visibleConf.old = opts.items.visible;
227
+ opts.usePadding = false;
228
+
229
+
230
+ if (opts.responsive) {
231
+
232
+ if (!opts.items.visibleConf.min) opts.items.visibleConf.min = opts.items.visible;
233
+ if (!opts.items.visibleConf.max) opts.items.visibleConf.max = opts.items.visible;
234
+
235
+ opts.align = false;
236
+ opts.padding = [0, 0, 0, 0];
237
+
238
+ var isVisible = $wrp.is(':visible');
239
+ if (isVisible) $wrp.hide();
240
+ var fullS = ms_getPercentage(ms_getTrueInnerSize($wrp.parent(), opts, 'innerWidth'), opts[opts.d['width']]);
241
+
242
+ if (typeof opts[opts.d['width']] == 'number' && fullS < opts[opts.d['width']]) {
243
+ fullS = opts[opts.d['width']];
244
+ }
245
+ if (isVisible) $wrp.show();
246
+
247
+ var visb = cf_getItemAdjustMinMax(Math.ceil(fullS / opts.items[opts.d['width']]), opts.items.visibleConf);
248
+ if (visb > all_itm.length) {
249
+ visb = all_itm.length;
250
+ }
251
+
252
+ var newS = Math.floor(fullS/visb),
253
+ seco = opts[opts.d['height']],
254
+ secp = ms_isPercentage(seco);
255
+
256
+ all_itm.each(function() {
257
+ var $t = $(this),
258
+ nw = newS - ms_getPaddingBorderMargin($t, opts, 'Width');
259
+
260
+ $t[opts.d['width']](nw);
261
+ if (secp) {
262
+ $t[opts.d['height']](ms_getPercentage(nw, seco));
263
+ }
264
+ });
265
+
266
+ opts.items.visible = visb;
267
+ opts.items[opts.d['width']] = newS;
268
+ opts[opts.d['width']] = visb * newS;
269
+
270
+ } else {
271
+
272
+ opts.padding = cf_getPadding(opts.padding);
273
+
274
+ if (opts.align == 'top') opts.align = 'left';
275
+ if (opts.align == 'bottom') opts.align = 'right';
276
+
277
+
278
+ switch (opts.align) {
279
+ // align: center, left or right
280
+ case 'center':
281
+ case 'left':
282
+ case 'right':
283
+ if (opts[opts.d['width']] != 'variable') {
284
+ var p = cf_getAlignPadding(gi_getCurrentItems(all_itm, opts), opts);
285
+ opts.usePadding = true;
286
+ opts.padding[opts.d[1]] = p[1];
287
+ opts.padding[opts.d[3]] = p[0];
288
+ }
289
+ break;
290
+
291
+ // padding
292
+ default:
293
+ opts.align = false;
294
+ opts.usePadding = (
295
+ opts.padding[0] == 0 &&
296
+ opts.padding[1] == 0 &&
297
+ opts.padding[2] == 0 &&
298
+ opts.padding[3] == 0
299
+ ) ? false : true;
300
+ break;
301
+ }
302
+ }
303
+
304
+ if (typeof opts.cookie == 'boolean' && opts.cookie) opts.cookie = 'caroufredsel_cookie_'+$cfs.attr('id');
305
+ if (typeof opts.items.minimum != 'number') opts.items.minimum = opts.items.visible;
306
+ if (typeof opts.scroll.duration != 'number') opts.scroll.duration = 500;
307
+ if (typeof opts.scroll.items == 'undefined') opts.scroll.items = (opts.items.visibleConf.variable || opts.items.filter != '*') ? 'visible' : opts.items.visible;
308
+
309
+ opts.auto = go_getNaviObject($tt0, opts.auto, 'auto');
310
+ opts.prev = go_getNaviObject($tt0, opts.prev);
311
+ opts.next = go_getNaviObject($tt0, opts.next);
312
+ opts.pagination = go_getNaviObject($tt0, opts.pagination, 'pagination');
313
+
314
+ opts.auto = $.extend(true, {}, opts.scroll, opts.auto);
315
+ opts.prev = $.extend(true, {}, opts.scroll, opts.prev);
316
+ opts.next = $.extend(true, {}, opts.scroll, opts.next);
317
+ opts.pagination = $.extend(true, {}, opts.scroll, opts.pagination);
318
+
319
+ if (typeof opts.pagination.keys != 'boolean') opts.pagination.keys = false;
320
+ if (typeof opts.pagination.anchorBuilder != 'function'
321
+ && opts.pagination.anchorBuilder !== false) opts.pagination.anchorBuilder = $.fn.carouFredSel.pageAnchorBuilder;
322
+ if (typeof opts.auto.play != 'boolean') opts.auto.play = true;
323
+ if (typeof opts.auto.delay != 'number') opts.auto.delay = 0;
324
+ if (typeof opts.auto.pauseOnEvent == 'undefined') opts.auto.pauseOnEvent = true;
325
+ if (typeof opts.auto.pauseOnResize != 'boolean') opts.auto.pauseOnResize = true;
326
+ if (typeof opts.auto.pauseDuration != 'number') opts.auto.pauseDuration = (opts.auto.duration < 10) ? 2500 : opts.auto.duration * 5;
327
+
328
+ if (opts.synchronise) {
329
+ opts.synchronise = cf_getSynchArr(opts.synchronise);
330
+ }
331
+ if (conf.debug) {
332
+ debug(conf, 'Carousel width: '+opts.width);
333
+ debug(conf, 'Carousel height: '+opts.height);
334
+ if (opts.maxDimention) debug(conf, 'Available '+opts.d['width']+': '+opts.maxDimention);
335
+ debug(conf, 'Item widths: '+opts.items.width);
336
+ debug(conf, 'Item heights: '+opts.items.height);
337
+ debug(conf, 'Number of items visible: '+opts.items.visible);
338
+ if (opts.auto.play) debug(conf, 'Number of items scrolled automatically: '+opts.auto.items);
339
+ if (opts.prev.button) debug(conf, 'Number of items scrolled backward: '+opts.prev.items);
340
+ if (opts.next.button) debug(conf, 'Number of items scrolled forward: '+opts.next.items);
341
+ }
342
+ }; // /init
343
+
344
+ $cfs._cfs_build = function() {
345
+ $cfs.data('cfs_isCarousel', true);
346
+
347
+ var orgCSS = {
348
+ 'textAlign' : $cfs.css('textAlign'),
349
+ 'float' : $cfs.css('float'),
350
+ 'position' : $cfs.css('position'),
351
+ 'top' : $cfs.css('top'),
352
+ 'right' : $cfs.css('right'),
353
+ 'bottom' : $cfs.css('bottom'),
354
+ 'left' : $cfs.css('left'),
355
+ 'width' : $cfs.css('width'),
356
+ 'height' : $cfs.css('height'),
357
+ 'marginTop' : $cfs.css('marginTop'),
358
+ 'marginRight' : $cfs.css('marginRight'),
359
+ 'marginBottom' : $cfs.css('marginBottom'),
360
+ 'marginLeft' : $cfs.css('marginLeft')
361
+ };
362
+
363
+ switch (orgCSS.position) {
364
+ case 'absolute':
365
+ var newPosition = 'absolute';
366
+ break;
367
+ case 'fixed':
368
+ var newPosition = 'fixed';
369
+ break;
370
+ default:
371
+ var newPosition = 'relative';
372
+ }
373
+
374
+ $wrp.css(orgCSS).css({
375
+ 'overflow' : 'hidden',
376
+ 'position' : newPosition
377
+ });
378
+
379
+ $cfs.data('cfs_origCss', orgCSS).css({
380
+ 'textAlign' : 'left',
381
+ 'float' : 'none',
382
+ 'position' : 'absolute',
383
+ 'top' : 0,
384
+ 'left' : 0,
385
+ 'marginTop' : 0,
386
+ 'marginRight' : 0,
387
+ 'marginBottom' : 0,
388
+ 'marginLeft' : 0
389
+ });
390
+
391
+ if (opts.usePadding) {
392
+ $cfs.children().each(function() {
393
+ var m = parseInt($(this).css(opts.d['marginRight']));
394
+ if (isNaN(m)) m = 0;
395
+ $(this).data('cfs_origCssMargin', m);
396
+ });
397
+ }
398
+
399
+ }; // /build
400
+
401
+ $cfs._cfs_bind_events = function() {
402
+ $cfs._cfs_unbind_events();
403
+
404
+ // stop event
405
+ $cfs.bind(cf_e('stop', conf), function(e, imm) {
406
+ e.stopPropagation();
407
+
408
+ // button
409
+ if (!crsl.isStopped) {
410
+ if (opts.auto.button) {
411
+ opts.auto.button.addClass(cf_c('stopped', conf));
412
+ }
413
+ }
414
+
415
+ // set stopped
416
+ crsl.isStopped = true;
417
+
418
+ if (opts.auto.play) {
419
+ opts.auto.play = false;
420
+ $cfs.trigger(cf_e('pause', conf), imm);
421
+ }
422
+ return true;
423
+ });
424
+
425
+ // finish event
426
+ $cfs.bind(cf_e('finish', conf), function(e) {
427
+ e.stopPropagation();
428
+ if (crsl.isScrolling) {
429
+ sc_stopScroll(scrl);
430
+ }
431
+ return true;
432
+ });
433
+
434
+ // pause event
435
+ $cfs.bind(cf_e('pause', conf), function(e, imm, res) {
436
+ e.stopPropagation();
437
+ tmrs = sc_clearTimers(tmrs);
438
+
439
+ // immediately pause
440
+ if (imm && crsl.isScrolling) {
441
+ scrl.isStopped = true;
442
+ var nst = getTime() - scrl.startTime;
443
+ scrl.duration -= nst;
444
+ if (scrl.pre) scrl.pre.duration -= nst;
445
+ if (scrl.post) scrl.post.duration -= nst;
446
+ sc_stopScroll(scrl, false);
447
+ }
448
+
449
+ // update remaining pause-time
450
+ if (!crsl.isPaused && !crsl.isScrolling) {
451
+ if (res) tmrs.timePassed += getTime() - tmrs.startTime;
452
+ }
453
+
454
+ // button
455
+ if (!crsl.isPaused) {
456
+ if (opts.auto.button) {
457
+ opts.auto.button.addClass(cf_c('paused', conf));
458
+ }
459
+ }
460
+
461
+ // set paused
462
+ crsl.isPaused = true;
463
+
464
+ // pause pause callback
465
+ if (opts.auto.onPausePause) {
466
+ var dur1 = opts.auto.pauseDuration - tmrs.timePassed,
467
+ perc = 100 - Math.ceil( dur1 * 100 / opts.auto.pauseDuration );
468
+ opts.auto.onPausePause.call($tt0, perc, dur1);
469
+ }
470
+ return true;
471
+ });
472
+
473
+ // play event
474
+ $cfs.bind(cf_e('play', conf), function(e, dir, del, res) {
475
+ e.stopPropagation();
476
+ tmrs = sc_clearTimers(tmrs);
477
+
478
+ // sort params
479
+ var v = [dir, del, res],
480
+ t = ['string', 'number', 'boolean'],
481
+ a = cf_sortParams(v, t);
482
+
483
+ var dir = a[0],
484
+ del = a[1],
485
+ res = a[2];
486
+
487
+ if (dir != 'prev' && dir != 'next') dir = crsl.direction;
488
+ if (typeof del != 'number') del = 0;
489
+ if (typeof res != 'boolean') res = false;
490
+
491
+ // stopped?
492
+ if (res) {
493
+ crsl.isStopped = false;
494
+ opts.auto.play = true;
495
+ }
496
+ if (!opts.auto.play) {
497
+ e.stopImmediatePropagation();
498
+ return debug(conf, 'Carousel stopped: Not scrolling.');
499
+ }
500
+
501
+ // button
502
+ if (crsl.isPaused) {
503
+ if (opts.auto.button) {
504
+ opts.auto.button.removeClass(cf_c('stopped', conf));
505
+ opts.auto.button.removeClass(cf_c('paused', conf));
506
+ }
507
+ }
508
+
509
+ // set playing
510
+ crsl.isPaused = false;
511
+ tmrs.startTime = getTime();
512
+
513
+ // timeout the scrolling
514
+ var dur1 = opts.auto.pauseDuration + del;
515
+ dur2 = dur1 - tmrs.timePassed;
516
+ perc = 100 - Math.ceil(dur2 * 100 / dur1);
517
+
518
+ tmrs.auto = setTimeout(function() {
519
+ if (opts.auto.onPauseEnd) {
520
+ opts.auto.onPauseEnd.call($tt0, perc, dur2);
521
+ }
522
+ if (crsl.isScrolling) {
523
+ $cfs.trigger(cf_e('play', conf), dir);
524
+ } else {
525
+ $cfs.trigger(cf_e(dir, conf), opts.auto);
526
+ }
527
+ }, dur2);
528
+
529
+ // pause start callback
530
+ if (opts.auto.onPauseStart) {
531
+ opts.auto.onPauseStart.call($tt0, perc, dur2);
532
+ }
533
+
534
+ return true;
535
+ });
536
+
537
+ // resume event
538
+ $cfs.bind(cf_e('resume', conf), function(e) {
539
+ e.stopPropagation();
540
+ if (scrl.isStopped) {
541
+ scrl.isStopped = false;
542
+ crsl.isPaused = false;
543
+ crsl.isScrolling = true;
544
+ scrl.startTime = getTime();
545
+ sc_startScroll(scrl);
546
+ } else {
547
+ $cfs.trigger(cf_e('play', conf));
548
+ }
549
+ return true;
550
+ });
551
+
552
+ // prev + next events
553
+ $cfs.bind(cf_e('prev', conf)+' '+cf_e('next', conf), function(e, obj, num, clb) {
554
+ e.stopPropagation();
555
+
556
+ // stopped or hidden carousel, don't scroll, don't queue
557
+ if (crsl.isStopped || $cfs.is(':hidden')) {
558
+ e.stopImmediatePropagation();
559
+ return debug(conf, 'Carousel stopped or hidden: Not scrolling.');
560
+ }
561
+
562
+ // not enough items
563
+ if (opts.items.minimum >= itms.total) {
564
+ e.stopImmediatePropagation();
565
+ return debug(conf, 'Not enough items ('+itms.total+', '+opts.items.minimum+' needed): Not scrolling.');
566
+ }
567
+
568
+ // get config
569
+ var v = [obj, num, clb],
570
+ t = ['object', 'number/string', 'function'],
571
+ a = cf_sortParams(v, t);
572
+
573
+ var obj = a[0],
574
+ num = a[1],
575
+ clb = a[2];
576
+
577
+ var eType = e.type.slice(conf.events.prefix.length);
578
+
579
+ if (typeof obj != 'object' || obj == null) obj = opts[eType];
580
+ if (typeof clb == 'function') obj.onAfter = clb;
581
+
582
+ if (typeof num != 'number') {
583
+ if (opts.items.filter != '*') {
584
+ num = 'visible';
585
+ } else {
586
+ var arr = [num, obj.items, opts[eType].items];
587
+ for (var a = 0, l = arr.length; a < l; a++) {
588
+ if (typeof arr[a] == 'number' || arr[a] == 'page' || arr[a] == 'visible') {
589
+ num = arr[a];
590
+ break;
591
+ }
592
+ }
593
+ }
594
+ switch(num) {
595
+ case 'page':
596
+ e.stopImmediatePropagation();
597
+ return $cfs.triggerHandler(eType+'Page', [obj, clb]);
598
+ break;
599
+
600
+ case 'visible':
601
+ if (!opts.items.visibleConf.variable && opts.items.filter == '*') {
602
+ num = opts.items.visible;
603
+ }
604
+ break;
605
+ }
606
+ }
607
+
608
+ // resume animation, add current to queue
609
+ if (scrl.isStopped) {
610
+ $cfs.trigger(cf_e('resume', conf));
611
+ $cfs.trigger(cf_e('queue', conf), [eType, [obj, num, clb]]);
612
+ e.stopImmediatePropagation();
613
+ return debug(conf, 'Carousel resumed scrolling.');
614
+ }
615
+
616
+ // queue if scrolling
617
+ if (obj.duration > 0) {
618
+ if (crsl.isScrolling) {
619
+ if (obj.queue) $cfs.trigger(cf_e('queue', conf), [eType, [obj, num, clb]]);
620
+ e.stopImmediatePropagation();
621
+ return debug(conf, 'Carousel currently scrolling.');
622
+ }
623
+ }
624
+
625
+ // test conditions callback
626
+ if (obj.conditions && !obj.conditions.call($tt0)) {
627
+ e.stopImmediatePropagation();
628
+ return debug(conf, 'Callback "conditions" returned false.');
629
+ }
630
+
631
+ tmrs.timePassed = 0;
632
+ $cfs.trigger('_cfs_triggerEvent', ['slide_'+eType, [obj, num]]);
633
+
634
+ // synchronise
635
+ if (opts.synchronise) {
636
+ var s = opts.synchronise,
637
+ c = [obj, num];
638
+ for (var j = 0, l = s.length; j < l; j++) {
639
+ var d = eType;
640
+
641
+ if (!s[j][1]) c[0] = s[j][0].triggerHandler('_cfs_triggerEvent', ['configuration', d]);
642
+ if (!s[j][2]) d = (d == 'prev') ? 'next' : 'prev';
643
+ c[1] = num + s[j][3];
644
+ s[j][0].trigger('_cfs_triggerEvent', ['slide_'+d, c]);
645
+ }
646
+ }
647
+ return true;
648
+ });
649
+
650
+ // prev event
651
+ $cfs.bind(cf_e('slide_prev', conf), function(e, sO, nI) {
652
+ e.stopPropagation();
653
+ var a_itm = $cfs.children();
654
+
655
+ // non-circular at start, scroll to end
656
+ if (!opts.circular) {
657
+ if (itms.first == 0) {
658
+ if (opts.infinite) {
659
+ $cfs.trigger(cf_e('next', conf), itms.total-1);
660
+ }
661
+ return e.stopImmediatePropagation();
662
+ }
663
+ }
664
+
665
+ if (opts.usePadding) sz_resetMargin(a_itm, opts);
666
+
667
+ // find number of items to scroll
668
+ if (typeof nI != 'number') {
669
+ if (opts.items.visibleConf.variable) {
670
+ nI = gn_getVisibleItemsPrev(a_itm, opts, itms.total-1);
671
+ } else if (opts.items.filter != '*') {
672
+ var xI = (typeof sO.items == 'number') ? sO.items : gn_getVisibleOrg($cfs, opts);
673
+ nI = gn_getScrollItemsPrevFilter(a_itm, opts, itms.total-1, xI);
674
+ } else {
675
+ nI = opts.items.visible;
676
+ }
677
+ nI = cf_getAdjust(nI, opts, sO.items, $tt0);
678
+ }
679
+
680
+ // prevent non-circular from scrolling to far
681
+ if (!opts.circular) {
682
+ if (itms.total - nI < itms.first) {
683
+ nI = itms.total - itms.first;
684
+ }
685
+ }
686
+
687
+ // set new number of visible items
688
+ opts.items.visibleConf.old = opts.items.visible;
689
+ if (opts.items.visibleConf.variable) {
690
+ var vI = gn_getVisibleItemsNext(a_itm, opts, itms.total-nI);
691
+ if (opts.items.visible+nI <= vI && nI < itms.total) {
692
+ nI++;
693
+ vI = gn_getVisibleItemsNext(a_itm, opts, itms.total-nI);
694
+ }
695
+ opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
696
+ } else if (opts.items.filter != '*') {
697
+ var vI = gn_getVisibleItemsNextFilter(a_itm, opts, itms.total-nI);
698
+ opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
699
+ }
700
+
701
+ if (opts.usePadding) sz_resetMargin(a_itm, opts, true);
702
+
703
+ // scroll 0, don't scroll
704
+ if (nI == 0) {
705
+ e.stopImmediatePropagation();
706
+ return debug(conf, '0 items to scroll: Not scrolling.');
707
+ }
708
+ debug(conf, 'Scrolling '+nI+' items backward.');
709
+
710
+ // save new config
711
+ itms.first += nI;
712
+ while (itms.first >= itms.total) {
713
+ itms.first -= itms.total;
714
+ }
715
+
716
+ // non-circular callback
717
+ if (!opts.circular) {
718
+ if (itms.first == 0 && sO.onEnd) sO.onEnd.call($tt0);
719
+ if (!opts.infinite) nv_enableNavi(opts, itms.first, conf);
720
+ }
721
+
722
+ // rearrange items
723
+ $cfs.children().slice(itms.total-nI, itms.total).prependTo($cfs);
724
+ if (itms.total < opts.items.visible + nI) {
725
+ $cfs.children().slice(0, (opts.items.visible+nI)-itms.total).clone(true).appendTo($cfs);
726
+ }
727
+
728
+ // the needed items
729
+ var a_itm = $cfs.children(),
730
+ c_old = gi_getOldItemsPrev(a_itm, opts, nI),
731
+ c_new = gi_getNewItemsPrev(a_itm, opts),
732
+ l_cur = a_itm.eq(nI-1),
733
+ l_old = c_old.last(),
734
+ l_new = c_new.last();
735
+
736
+ if (opts.usePadding) sz_resetMargin(a_itm, opts);
737
+ if (opts.align) {
738
+ var p = cf_getAlignPadding(c_new, opts),
739
+ pL = p[0],
740
+ pR = p[1];
741
+ } else {
742
+ var pL = 0,
743
+ pR = 0;
744
+ }
745
+ var oL = (pL < 0) ? opts.padding[opts.d[3]] : 0;
746
+
747
+ // hide items for fx directscroll
748
+ if (sO.fx == 'directscroll' && opts.items.visible < nI) {
749
+ var hiddenitems = a_itm.slice(opts.items.visibleConf.old, nI),
750
+ orgW = opts.items[opts.d['width']];
751
+ hiddenitems.each(function() {
752
+ var hi = $(this);
753
+ hi.data('isHidden', hi.is(':hidden')).hide();
754
+ });
755
+ opts.items[opts.d['width']] = 'variable';
756
+ } else {
757
+ var hiddenitems = false;
758
+ }
759
+
760
+ // save new sizes
761
+ var i_siz = ms_getTotalSize(a_itm.slice(0, nI), opts, 'width'),
762
+ w_siz = cf_mapWrapperSizes(ms_getSizes(c_new, opts, true), opts, !opts.usePadding);
763
+
764
+ if (hiddenitems) opts.items[opts.d['width']] = orgW;
765
+
766
+ if (opts.usePadding) {
767
+ sz_resetMargin(a_itm, opts, true);
768
+ if (pR >= 0) {
769
+ sz_resetMargin(l_old, opts, opts.padding[opts.d[1]]);
770
+ }
771
+ sz_resetMargin(l_cur, opts, opts.padding[opts.d[3]]);
772
+ }
773
+ if (opts.align) {
774
+ opts.padding[opts.d[1]] = pR;
775
+ opts.padding[opts.d[3]] = pL;
776
+ }
777
+
778
+ // animation configuration
779
+ var a_cfs = {},
780
+ a_dur = sO.duration;
781
+
782
+ if (sO.fx == 'none') a_dur = 0;
783
+ else if (a_dur == 'auto') a_dur = opts.scroll.duration / opts.scroll.items * nI;
784
+ else if (a_dur <= 0) a_dur = 0;
785
+ else if (a_dur < 10) a_dur = i_siz / a_dur;
786
+
787
+ scrl = sc_setScroll(a_dur, sO.easing);
788
+
789
+ // animate wrapper
790
+ if (opts[opts.d['width']] == 'variable' || opts[opts.d['height']] == 'variable') {
791
+ scrl.anims.push([$wrp, w_siz]);
792
+ }
793
+
794
+ // animate items
795
+ if (opts.usePadding) {
796
+ var new_m = opts.padding[opts.d[3]];
797
+
798
+ if (l_new.not(l_cur).length) {
799
+ var a_cur = {};
800
+ a_cur[opts.d['marginRight']] = l_cur.data('cfs_origCssMargin');
801
+
802
+ if (pL < 0) l_cur.css(a_cur);
803
+ else scrl.anims.push([l_cur, a_cur]);
804
+ }
805
+
806
+ if (l_new.not(l_old).length) {
807
+ var a_old = {};
808
+ a_old[opts.d['marginRight']] = l_old.data('cfs_origCssMargin');
809
+ scrl.anims.push([l_old, a_old]);
810
+ }
811
+
812
+ if (pR >= 0) {
813
+ var a_new = {};
814
+ a_new[opts.d['marginRight']] = l_new.data('cfs_origCssMargin') + opts.padding[opts.d[1]];
815
+ scrl.anims.push([l_new, a_new]);
816
+ }
817
+ } else {
818
+ var new_m = 0;
819
+ }
820
+
821
+ // animate carousel
822
+ a_cfs[opts.d['left']] = new_m;
823
+
824
+ // onBefore callback
825
+ var args = [c_old, c_new, w_siz, a_dur];
826
+ if (sO.onBefore) sO.onBefore.apply($tt0, args);
827
+ clbk.onBefore = sc_callCallbacks(clbk.onBefore, $tt0, args);
828
+
829
+
830
+
831
+ // ALTERNATIVE EFFECTS
832
+
833
+ // extra animation arrays
834
+ switch(sO.fx) {
835
+ case 'fade':
836
+ case 'crossfade':
837
+ case 'cover':
838
+ case 'uncover':
839
+ scrl.pre = sc_setScroll(scrl.duration, scrl.easing);
840
+ scrl.post = sc_setScroll(scrl.duration, scrl.easing);
841
+ scrl.duration = 0;
842
+ break;
843
+ }
844
+
845
+ // create copy
846
+ switch(sO.fx) {
847
+ case 'crossfade':
848
+ case 'cover':
849
+ case 'uncover':
850
+ var $cf2 = $cfs.clone().appendTo($wrp);
851
+ break;
852
+ }
853
+ switch(sO.fx) {
854
+ case 'uncover':
855
+ $cf2.children().slice(0, nI).remove();
856
+ case 'crossfade':
857
+ case 'cover':
858
+ $cf2.children().slice(opts.items.visible).remove();
859
+ break;
860
+ }
861
+
862
+ // animations
863
+ switch(sO.fx) {
864
+ case 'fade':
865
+ scrl.pre.anims.push([$cfs, { 'opacity': 0 }]);
866
+ break;
867
+ case 'crossfade':
868
+ $cf2.css({ 'opacity': 0 });
869
+ scrl.pre.anims.push([$cfs, { 'width': '+=0' }, function() { $cf2.remove(); }]);
870
+ scrl.post.anims.push([$cf2, { 'opacity': 1 }]);
871
+ break;
872
+ case 'cover':
873
+ scrl = fx_cover(scrl, $cfs, $cf2, opts, true);
874
+ break;
875
+ case 'uncover':
876
+ scrl = fx_uncover(scrl, $cfs, $cf2, opts, true, nI);
877
+ break;
878
+ }
879
+
880
+ // /ALTERNATIVE EFFECTS
881
+
882
+
883
+ // complete callback
884
+ var a_complete = function() {
885
+
886
+ var overFill = opts.items.visible+nI-itms.total;
887
+ if (overFill > 0) {
888
+ $cfs.children().slice(itms.total).remove();
889
+ c_old = $( $cfs.children().slice(itms.total-(opts.items.visible-overFill)).get().concat( $cfs.children().slice(0, overFill).get() ) );
890
+ }
891
+ if (hiddenitems) {
892
+ hiddenitems.each(function() {
893
+ var hi = $(this);
894
+ if (!hi.data('isHidden')) hi.show();
895
+ });
896
+ }
897
+ if (opts.usePadding) {
898
+ var l_itm = $cfs.children().eq(opts.items.visible+nI-1);
899
+ l_itm.css(opts.d['marginRight'], l_itm.data('cfs_origCssMargin'));
900
+ }
901
+
902
+ scrl.anims = [];
903
+ if (scrl.pre) scrl.pre = sc_setScroll(scrl.orgDuration, scrl.easing);
904
+
905
+ var fn = function() {
906
+ switch(sO.fx) {
907
+ case 'fade':
908
+ case 'crossfade':
909
+ $cfs.css('filter', '');
910
+ break;
911
+ }
912
+
913
+ scrl.post = sc_setScroll(0, null);
914
+ crsl.isScrolling = false;
915
+
916
+ var args = [c_old, c_new, w_siz];
917
+ if (sO.onAfter) sO.onAfter.apply($tt0, args);
918
+ clbk.onAfter = sc_callCallbacks(clbk.onAfter, $tt0, args);
919
+
920
+ if (queu.length) {
921
+ $cfs.trigger(cf_e(queu[0][0], conf), queu[0][1]);
922
+ queu.shift();
923
+ }
924
+ if (!crsl.isPaused) $cfs.trigger(cf_e('play', conf));
925
+ };
926
+ switch(sO.fx) {
927
+ case 'fade':
928
+ scrl.pre.anims.push([$cfs, { 'opacity': 1 }, fn]);
929
+ sc_startScroll(scrl.pre);
930
+ break;
931
+ case 'uncover':
932
+ scrl.pre.anims.push([$cfs, { 'width': '+=0' }, fn]);
933
+ sc_startScroll(scrl.pre);
934
+ break;
935
+ default:
936
+ fn();
937
+ break;
938
+ }
939
+ };
940
+
941
+ scrl.anims.push([$cfs, a_cfs, a_complete]);
942
+ crsl.isScrolling = true;
943
+ $cfs.css(opts.d['left'], -(i_siz-oL));
944
+ tmrs = sc_clearTimers(tmrs);
945
+ sc_startScroll(scrl);
946
+ cf_setCookie(opts.cookie, $cfs.triggerHandler(cf_e('currentPosition', conf)));
947
+
948
+ $cfs.trigger(cf_e('updatePageStatus', conf), [false, w_siz]);
949
+
950
+ return true;
951
+ });
952
+
953
+ // next event
954
+ $cfs.bind(cf_e('slide_next', conf), function(e, sO, nI) {
955
+ e.stopPropagation();
956
+ var a_itm = $cfs.children();
957
+
958
+ // non-circular at end, scroll to start
959
+ if (!opts.circular) {
960
+ if (itms.first == opts.items.visible) {
961
+ if (opts.infinite) {
962
+ $cfs.trigger(cf_e('prev', conf), itms.total-1);
963
+ }
964
+ return e.stopImmediatePropagation();
965
+ }
966
+ }
967
+
968
+ if (opts.usePadding) sz_resetMargin(a_itm, opts);
969
+
970
+ // find number of items to scroll
971
+ if (typeof nI != 'number') {
972
+ if (opts.items.filter != '*') {
973
+ var xI = (typeof sO.items == 'number') ? sO.items : gn_getVisibleOrg($cfs, opts);
974
+ nI = gn_getScrollItemsNextFilter(a_itm, opts, 0, xI);
975
+ } else {
976
+ nI = opts.items.visible;
977
+ }
978
+ nI = cf_getAdjust(nI, opts, sO.items, $tt0);
979
+ }
980
+
981
+ var lastItemNr = (itms.first == 0) ? itms.total : itms.first;
982
+
983
+ // prevent non-circular from scrolling to far
984
+ if (!opts.circular) {
985
+ if (opts.items.visibleConf.variable) {
986
+ var vI = gn_getVisibleItemsNext(a_itm, opts, nI),
987
+ xI = gn_getVisibleItemsPrev(a_itm, opts, lastItemNr-1);
988
+ } else {
989
+ var vI = opts.items.visible,
990
+ xI = opts.items.visible;
991
+ }
992
+
993
+ if (nI + vI > lastItemNr) {
994
+ nI = lastItemNr - xI;
995
+ }
996
+ }
997
+
998
+ // set new number of visible items
999
+ opts.items.visibleConf.old = opts.items.visible;
1000
+ if (opts.items.visibleConf.variable) {
1001
+ var vI = gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr);
1002
+ while (opts.items.visible-nI >= vI && nI < itms.total) {
1003
+ nI++;
1004
+ vI = gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr);
1005
+ }
1006
+ opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
1007
+ } else if (opts.items.filter != '*') {
1008
+ var vI = gn_getVisibleItemsNextFilter(a_itm, opts, nI);
1009
+ opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
1010
+ }
1011
+
1012
+ if (opts.usePadding) sz_resetMargin(a_itm, opts, true);
1013
+
1014
+ // scroll 0, don't scroll
1015
+ if (nI == 0) {
1016
+ e.stopImmediatePropagation();
1017
+ return debug(conf, '0 items to scroll: Not scrolling.');
1018
+ }
1019
+ debug(conf, 'Scrolling '+nI+' items forward.');
1020
+
1021
+ // save new config
1022
+ itms.first -= nI;
1023
+ while (itms.first < 0) {
1024
+ itms.first += itms.total;
1025
+ }
1026
+
1027
+ // non-circular callback
1028
+ if (!opts.circular) {
1029
+ if (itms.first == opts.items.visible && sO.onEnd) sO.onEnd.call($tt0);
1030
+ if (!opts.infinite) nv_enableNavi(opts, itms.first, conf);
1031
+ }
1032
+
1033
+ // rearrange items
1034
+ if (itms.total < opts.items.visible+nI) {
1035
+ $cfs.children().slice(0, (opts.items.visible+nI)-itms.total).clone(true).appendTo($cfs);
1036
+ }
1037
+
1038
+ // the needed items
1039
+ var a_itm = $cfs.children(),
1040
+ c_old = gi_getOldItemsNext(a_itm, opts),
1041
+ c_new = gi_getNewItemsNext(a_itm, opts, nI),
1042
+ l_cur = a_itm.eq(nI-1),
1043
+ l_old = c_old.last(),
1044
+ l_new = c_new.last();
1045
+
1046
+ if (opts.usePadding) sz_resetMargin(a_itm, opts);
1047
+ if (opts.align) {
1048
+ var p = cf_getAlignPadding(c_new, opts),
1049
+ pL = p[0],
1050
+ pR = p[1];
1051
+ } else {
1052
+ var pL = 0,
1053
+ pR = 0;
1054
+ }
1055
+
1056
+ // hide items for fx directscroll
1057
+ if (sO.fx == 'directscroll' && opts.items.visibleConf.old < nI) {
1058
+ var hiddenitems = a_itm.slice(opts.items.visibleConf.old, nI),
1059
+ orgW = opts.items[opts.d['width']];
1060
+ hiddenitems.each(function() {
1061
+ var hi = $(this);
1062
+ hi.data('isHidden', hi.is(':hidden')).hide();
1063
+ });
1064
+ opts.items[opts.d['width']] = 'variable';
1065
+ } else {
1066
+ var hiddenitems = false;
1067
+ }
1068
+
1069
+ // save new sizes
1070
+ var i_siz = ms_getTotalSize(a_itm.slice(0, nI), opts, 'width'),
1071
+ w_siz = cf_mapWrapperSizes(ms_getSizes(c_new, opts, true), opts, !opts.usePadding);
1072
+
1073
+ if (hiddenitems) opts.items[opts.d['width']] = orgW;
1074
+
1075
+ if (opts.align) {
1076
+ if (opts.padding[opts.d[1]] < 0) {
1077
+ opts.padding[opts.d[1]] = 0;
1078
+ }
1079
+ }
1080
+ if (opts.usePadding) {
1081
+ sz_resetMargin(a_itm, opts, true);
1082
+ sz_resetMargin(l_old, opts, opts.padding[opts.d[1]]);
1083
+ }
1084
+ if (opts.align) {
1085
+ opts.padding[opts.d[1]] = pR;
1086
+ opts.padding[opts.d[3]] = pL;
1087
+ }
1088
+
1089
+ // animation configuration
1090
+ var a_cfs = {},
1091
+ a_dur = sO.duration;
1092
+
1093
+ if (sO.fx == 'none') a_dur = 0;
1094
+ else if (a_dur == 'auto') a_dur = opts.scroll.duration / opts.scroll.items * nI;
1095
+ else if (a_dur <= 0) a_dur = 0;
1096
+ else if (a_dur < 10) a_dur = i_siz / a_dur;
1097
+
1098
+ scrl = sc_setScroll(a_dur, sO.easing);
1099
+
1100
+ // animate wrapper
1101
+ if (opts[opts.d['width']] == 'variable' || opts[opts.d['height']] == 'variable') {
1102
+ scrl.anims.push([$wrp, w_siz]);
1103
+ }
1104
+
1105
+ // animate items
1106
+ if (opts.usePadding) {
1107
+ var l_new_m = l_new.data('cfs_origCssMargin');
1108
+ if (pR >= 0) {
1109
+ l_new_m += opts.padding[opts.d[1]];
1110
+ }
1111
+ l_new.css(opts.d['marginRight'], l_new_m);
1112
+
1113
+ if (l_cur.not(l_old).length) {
1114
+ var a_old = {};
1115
+ a_old[opts.d['marginRight']] = l_old.data('cfs_origCssMargin');
1116
+ scrl.anims.push([l_old, a_old]);
1117
+ }
1118
+
1119
+ var c_new_m = l_cur.data('cfs_origCssMargin');
1120
+ if (pL >= 0) {
1121
+ c_new_m += opts.padding[opts.d[3]];
1122
+ }
1123
+ var a_cur = {};
1124
+ a_cur[opts.d['marginRight']] = c_new_m;
1125
+ scrl.anims.push([l_cur, a_cur]);
1126
+
1127
+ }
1128
+
1129
+ // animate carousel
1130
+ a_cfs[opts.d['left']] = -i_siz;
1131
+ if (pL < 0) {
1132
+ a_cfs[opts.d['left']] += pL;
1133
+ }
1134
+
1135
+ // onBefore callback
1136
+ var args = [c_old, c_new, w_siz, a_dur];
1137
+ if (sO.onBefore) sO.onBefore.apply($tt0, args);
1138
+ clbk.onBefore = sc_callCallbacks(clbk.onBefore, $tt0, args);
1139
+
1140
+
1141
+
1142
+ // ALTERNATIVE EFFECTS
1143
+
1144
+ // extra animation arrays
1145
+ switch(sO.fx) {
1146
+ case 'fade':
1147
+ case 'crossfade':
1148
+ case 'cover':
1149
+ case 'uncover':
1150
+ scrl.pre = sc_setScroll(scrl.duration, scrl.easing);
1151
+ scrl.post = sc_setScroll(scrl.duration, scrl.easing);
1152
+ scrl.duration = 0;
1153
+ break;
1154
+ }
1155
+
1156
+ // create copy
1157
+ switch(sO.fx) {
1158
+ case 'crossfade':
1159
+ case 'cover':
1160
+ case 'uncover':
1161
+ var $cf2 = $cfs.clone().appendTo($wrp);
1162
+ break;
1163
+ }
1164
+ switch(sO.fx) {
1165
+ case 'uncover':
1166
+ $cf2.children().slice(opts.items.visibleConf.old).remove();
1167
+ break;
1168
+ case 'crossfade':
1169
+ case 'cover':
1170
+ $cf2.children().slice(0, nI).remove();
1171
+ $cf2.children().slice(opts.items.visible).remove();
1172
+ break;
1173
+ }
1174
+
1175
+ // animations
1176
+ switch(sO.fx) {
1177
+ case 'fade':
1178
+ scrl.pre.anims.push([$cfs, { 'opacity': 0 }]);
1179
+ break;
1180
+ case 'crossfade':
1181
+ $cf2.css({ 'opacity': 0 });
1182
+ scrl.pre.anims.push([$cfs, { 'width': '+=0' }, function() { $cf2.remove(); }]);
1183
+ scrl.post.anims.push([$cf2, { 'opacity': 1 }]);
1184
+ break;
1185
+ case 'cover':
1186
+ scrl = fx_cover(scrl, $cfs, $cf2, opts, false);
1187
+ break;
1188
+ case 'uncover':
1189
+ scrl = fx_uncover(scrl, $cfs, $cf2, opts, false, nI);
1190
+ break;
1191
+ }
1192
+
1193
+ // /ALTERNATIVE EFFECTS
1194
+
1195
+
1196
+ // complete callback
1197
+ var a_complete = function() {
1198
+
1199
+ var overFill = opts.items.visible+nI-itms.total,
1200
+ new_m = (opts.usePadding) ? opts.padding[opts.d[3]] : 0;
1201
+ $cfs.css(opts.d['left'], new_m);
1202
+ if (overFill > 0) {
1203
+ $cfs.children().slice(itms.total).remove();
1204
+ }
1205
+ var l_itm = $cfs.children().slice(0, nI).appendTo($cfs).last();
1206
+ if (overFill > 0) {
1207
+ c_new = gi_getCurrentItems(a_itm, opts);
1208
+ }
1209
+ if (hiddenitems) {
1210
+ hiddenitems.each(function() {
1211
+ var hi = $(this);
1212
+ if (!hi.data('isHidden')) hi.show();
1213
+ });
1214
+ }
1215
+ if (opts.usePadding) {
1216
+ if (itms.total < opts.items.visible+nI) {
1217
+ var l_cur = $cfs.children().eq(opts.items.visible-1);
1218
+ l_cur.css(opts.d['marginRight'], l_cur.data('cfs_origCssMargin') + opts.padding[opts.d[3]]);
1219
+ }
1220
+ l_itm.css(opts.d['marginRight'], l_itm.data('cfs_origCssMargin'));
1221
+ }
1222
+
1223
+ scrl.anims = [];
1224
+ if (scrl.pre) scrl.pre = sc_setScroll(scrl.orgDuration, scrl.easing);
1225
+
1226
+ var fn = function() {
1227
+ switch(sO.fx) {
1228
+ case 'fade':
1229
+ case 'crossfade':
1230
+ $cfs.css('filter', '');
1231
+ break;
1232
+ }
1233
+
1234
+ scrl.post = sc_setScroll(0, null);
1235
+ crsl.isScrolling = false;
1236
+
1237
+ var args = [c_old, c_new, w_siz];
1238
+ if (sO.onAfter) sO.onAfter.apply($tt0, args);
1239
+ clbk.onAfter = sc_callCallbacks(clbk.onAfter, $tt0, args);
1240
+
1241
+ if (queu.length) {
1242
+ $cfs.trigger(cf_e(queu[0][0], conf), queu[0][1]);
1243
+ queu.shift();
1244
+ }
1245
+ if (!crsl.isPaused) $cfs.trigger(cf_e('play', conf));
1246
+ };
1247
+ switch(sO.fx) {
1248
+ case 'fade':
1249
+ scrl.pre.anims.push([$cfs, { 'opacity': 1 }, fn]);
1250
+ sc_startScroll(scrl.pre);
1251
+ break;
1252
+ case 'uncover':
1253
+ scrl.pre.anims.push([$cfs, { 'width': '+=0' }, fn]);
1254
+ sc_startScroll(scrl.pre);
1255
+ break;
1256
+ default:
1257
+ fn();
1258
+ break;
1259
+ }
1260
+ };
1261
+
1262
+ scrl.anims.push([$cfs, a_cfs, a_complete]);
1263
+ crsl.isScrolling = true;
1264
+ tmrs = sc_clearTimers(tmrs);
1265
+ sc_startScroll(scrl);
1266
+ cf_setCookie(opts.cookie, $cfs.triggerHandler(cf_e('currentPosition', conf)));
1267
+
1268
+ $cfs.trigger(cf_e('updatePageStatus', conf), [false, w_siz]);
1269
+
1270
+ return true;
1271
+ });
1272
+
1273
+ // slideTo event
1274
+ $cfs.bind(cf_e('slideTo', conf), function(e, num, dev, org, obj, dir, clb) {
1275
+ e.stopPropagation();
1276
+
1277
+ var v = [num, dev, org, obj, dir, clb],
1278
+ t = ['string/number/object', 'number', 'boolean', 'object', 'string', 'function'],
1279
+ a = cf_sortParams(v, t);
1280
+
1281
+ var obj = a[3],
1282
+ dir = a[4],
1283
+ clb = a[5];
1284
+
1285
+ num = gn_getItemIndex(a[0], a[1], a[2], itms, $cfs);
1286
+
1287
+ if (num == 0) return;
1288
+ if (typeof obj != 'object') obj = false;
1289
+
1290
+ if (crsl.isScrolling) {
1291
+ if (typeof obj != 'object' || obj.duration > 0) return false;
1292
+ }
1293
+
1294
+ if (dir != 'prev' && dir != 'next') {
1295
+ if (opts.circular) {
1296
+ if (num <= itms.total / 2) dir = 'next';
1297
+ else dir = 'prev';
1298
+ } else {
1299
+ if (itms.first == 0 ||
1300
+ itms.first > num) dir = 'next';
1301
+ else dir = 'prev';
1302
+ }
1303
+ }
1304
+
1305
+ if (dir == 'prev') num = itms.total-num;
1306
+ $cfs.trigger(cf_e(dir, conf), [obj, num, clb]);
1307
+
1308
+ return true;
1309
+ });
1310
+
1311
+ // prevPage event
1312
+ $cfs.bind(cf_e('prevPage', conf), function(e, obj, clb) {
1313
+ e.stopPropagation();
1314
+ var cur = $cfs.triggerHandler(cf_e('currentPage', conf));
1315
+ return $cfs.triggerHandler(cf_e('slideToPage', conf), [cur-1, obj, 'prev', clb]);
1316
+ });
1317
+
1318
+ // nextPage event
1319
+ $cfs.bind(cf_e('nextPage', conf), function(e, obj, clb) {
1320
+ e.stopPropagation();
1321
+ var cur = $cfs.triggerHandler(cf_e('currentPage', conf));
1322
+ return $cfs.triggerHandler(cf_e('slideToPage', conf), [cur+1, obj, 'next', clb]);
1323
+ });
1324
+
1325
+ // slideToPage event
1326
+ $cfs.bind(cf_e('slideToPage', conf), function(e, pag, obj, dir, clb) {
1327
+ e.stopPropagation();
1328
+ if (typeof pag != 'number') pag = $cfs.triggerHandler(cf_e('currentPage', conf));
1329
+ var ipp = opts.pagination.items || opts.items.visible,
1330
+ max = Math.ceil(itms.total / ipp)-1;
1331
+ if (pag < 0) pag = max;
1332
+ if (pag > max) pag = 0;
1333
+ return $cfs.triggerHandler(cf_e('slideTo', conf), [pag*ipp, 0, true, obj, dir, clb]);
1334
+ });
1335
+
1336
+ // jumpToStart event
1337
+ $cfs.bind(cf_e('jumpToStart', conf), function(e, s) {
1338
+ e.stopPropagation();
1339
+ if (s) s = gn_getItemIndex(s, 0, true, itms, $cfs);
1340
+ else s = 0;
1341
+
1342
+ s += itms.first;
1343
+ if (s != 0) {
1344
+ while (s > itms.total) s -= itms.total;
1345
+ $cfs.prepend($cfs.children().slice(s, itms.total));
1346
+ }
1347
+ return true;
1348
+ });
1349
+
1350
+ // synchronise event
1351
+ $cfs.bind(cf_e('synchronise', conf), function(e, s) {
1352
+ e.stopPropagation();
1353
+ if (s) s = cf_getSynchArr(s);
1354
+ else if (opts.synchronise) s = opts.synchronise;
1355
+ else return debug(conf, 'No carousel to synchronise.');
1356
+
1357
+ var n = $cfs.triggerHandler(cf_e('currentPosition', conf)),
1358
+ x = true;
1359
+ for (var j = 0, l = s.length; j < l; j++) {
1360
+ if (!s[j][0].triggerHandler(cf_e('slideTo', conf), [n, s[j][3], true])) {
1361
+ x = false;
1362
+ }
1363
+ }
1364
+ return x;
1365
+ });
1366
+
1367
+ // queue event
1368
+ $cfs.bind(cf_e('queue', conf), function(e, dir, opt) {
1369
+ e.stopPropagation();
1370
+ if (typeof dir == 'function') {
1371
+ dir.call($tt0, queu);
1372
+ } else if (is_array(dir)) {
1373
+ queu = dir;
1374
+ } else if (typeof dir != 'undefined') {
1375
+ queu.push([dir, opt]);
1376
+ }
1377
+ return queu;
1378
+ });
1379
+
1380
+ // insertItem event
1381
+ $cfs.bind(cf_e('insertItem', conf), function(e, itm, num, org, dev) {
1382
+ e.stopPropagation();
1383
+
1384
+ var v = [itm, num, org, dev],
1385
+ t = ['string/object', 'string/number/object', 'boolean', 'number'],
1386
+ a = cf_sortParams(v, t);
1387
+
1388
+ var itm = a[0],
1389
+ num = a[1],
1390
+ org = a[2],
1391
+ dev = a[3];
1392
+
1393
+ if (typeof itm == 'object' &&
1394
+ typeof itm.jquery == 'undefined') itm = $(itm);
1395
+ if (typeof itm == 'string') itm = $(itm);
1396
+ if (typeof itm != 'object' ||
1397
+ typeof itm.jquery == 'undefined' ||
1398
+ itm.length == 0) return debug(conf, 'Not a valid object.');
1399
+
1400
+ if (typeof num == 'undefined') num = 'end';
1401
+
1402
+ if (opts.usePadding) {
1403
+ itm.each(function() {
1404
+ var m = parseInt($(this).css(opts.d['marginRight']));
1405
+ if (isNaN(m)) m = 0;
1406
+ $(this).data('cfs_origCssMargin', m);
1407
+ });
1408
+ }
1409
+
1410
+ var orgNum = num,
1411
+ before = 'before';
1412
+
1413
+ if (num == 'end') {
1414
+ if (org) {
1415
+ if (itms.first == 0) {
1416
+ num = itms.total-1;
1417
+ before = 'after';
1418
+ } else {
1419
+ num = itms.first;
1420
+ itms.first += itm.length
1421
+ }
1422
+ if (num < 0) num = 0;
1423
+ } else {
1424
+ num = itms.total-1;
1425
+ before = 'after';
1426
+ }
1427
+ } else {
1428
+ num = gn_getItemIndex(num, dev, org, itms, $cfs);
1429
+ }
1430
+ if (orgNum != 'end' && !org) {
1431
+ if (num < itms.first) itms.first += itm.length;
1432
+ }
1433
+ if (itms.first >= itms.total) itms.first -= itms.total;
1434
+
1435
+ var $cit = $cfs.children().eq(num);
1436
+ if ($cit.length) {
1437
+ $cit[before](itm);
1438
+ } else {
1439
+ $cfs.append(itm);
1440
+ }
1441
+
1442
+ itms.total = $cfs.children().length;
1443
+
1444
+ var sz = $cfs.triggerHandler('updateSizes');
1445
+ nv_showNavi(opts, itms.total, conf);
1446
+ nv_enableNavi(opts, itms.first, conf);
1447
+ $cfs.trigger(cf_e('linkAnchors', conf));
1448
+ $cfs.trigger(cf_e('updatePageStatus', conf), [true, sz]);
1449
+
1450
+ return true;
1451
+ });
1452
+
1453
+ // removeItem event
1454
+ $cfs.bind(cf_e('removeItem', conf), function(e, num, org, dev) {
1455
+ e.stopPropagation();
1456
+
1457
+ var v = [num, org, dev],
1458
+ t = ['string/number/object', 'boolean', 'number'],
1459
+ a = cf_sortParams(v, t);
1460
+
1461
+ num = a[0];
1462
+ org = a[1];
1463
+ dev = a[2];
1464
+
1465
+ var removed = false;
1466
+ if (num instanceof $ && num.length > 1)
1467
+ {
1468
+ $removed = $();
1469
+ num.each(function(i, el) {
1470
+ var $rem = $cfs.trigger(cf_e('removeItem', conf), [$(this), org, dev]);
1471
+ if ($rem) $removed = $removed.add($rem);
1472
+ });
1473
+ return $removed;
1474
+ }
1475
+
1476
+ if (typeof num == 'undefined' || num == 'end') {
1477
+ $removed = $cfs.children().last();
1478
+ } else {
1479
+ num = gn_getItemIndex(num, dev, org, itms, $cfs);
1480
+ var $removed = $cfs.children().eq(num);
1481
+ if ($removed.length){
1482
+ if (num < itms.first) itms.first -= $removed.length;
1483
+ }
1484
+ }
1485
+ if ($removed && $removed.length) {
1486
+ $removed.detach();
1487
+ itms.total = $cfs.children().length;
1488
+ var sz = $cfs.triggerHandler('updateSizes');
1489
+ nv_showNavi(opts, itms.total, conf);
1490
+ nv_enableNavi(opts, itms.first, conf);
1491
+ $cfs.trigger(cf_e('updatePageStatus', conf), [true, sz]);
1492
+ }
1493
+
1494
+ return $removed;
1495
+ });
1496
+
1497
+ // onBefore and onAfter event
1498
+ $cfs.bind(cf_e('onBefore', conf)+' '+cf_e('onAfter', conf), function(e, fn) {
1499
+ e.stopPropagation();
1500
+ var eType = e.type.slice(conf.events.prefix.length);
1501
+ if (is_array(fn)) clbk[eType] = fn;
1502
+ if (typeof fn == 'function') clbk[eType].push(fn);
1503
+ return clbk[eType];
1504
+ });
1505
+
1506
+ // currentPosition event
1507
+ $cfs.bind(cf_e('currentPosition', conf), function(e, fn) {
1508
+ e.stopPropagation();
1509
+ if (itms.first == 0) var val = 0;
1510
+ else var val = itms.total - itms.first;
1511
+ if (typeof fn == 'function') fn.call($tt0, val);
1512
+ return val;
1513
+ });
1514
+
1515
+ // currentPage event
1516
+ $cfs.bind(cf_e('currentPage', conf), function(e, fn) {
1517
+ e.stopPropagation();
1518
+ var ipp = opts.pagination.items || opts.items.visible;
1519
+ var max = Math.ceil(itms.total/ipp-1);
1520
+ if (itms.first == 0) var nr = 0;
1521
+ else if (itms.first < itms.total % ipp) var nr = 0;
1522
+ else if (itms.first == ipp && !opts.circular) var nr = max;
1523
+ else var nr = Math.round((itms.total-itms.first)/ipp);
1524
+ if (nr < 0) nr = 0;
1525
+ if (nr > max) nr = max;
1526
+ if (typeof fn == 'function') fn.call($tt0, nr);
1527
+ return nr;
1528
+ });
1529
+
1530
+ // currentVisible event
1531
+ $cfs.bind(cf_e('currentVisible', conf), function(e, fn) {
1532
+ e.stopPropagation();
1533
+ $i = gi_getCurrentItems($cfs.children(), opts);
1534
+ if (typeof fn == 'function') fn.call($tt0, $i);
1535
+ return $i;
1536
+ });
1537
+
1538
+ // slice event
1539
+ $cfs.bind(cf_e('slice', conf), function(e, f, l, fn) {
1540
+ e.stopPropagation();
1541
+
1542
+ if (itms.total == 0) return false;
1543
+
1544
+ var v = [f, l, fn],
1545
+ t = ['number', 'number', 'function'],
1546
+ a = cf_sortParams(v, t);
1547
+
1548
+ f = (typeof a[0] == 'number') ? a[0] : 0;
1549
+ l = (typeof a[1] == 'number') ? a[1] : itms.total;
1550
+ fn = a[2];
1551
+
1552
+ f += itms.first;
1553
+ l += itms.first;
1554
+
1555
+ while (f > itms.total) { f -= itms.total }
1556
+ while (l > itms.total) { l -= itms.total }
1557
+ while (f < 0) { f += itms.total }
1558
+ while (l < 0) { l += itms.total }
1559
+
1560
+ var $iA = $cfs.children();
1561
+
1562
+ if (l > f) {
1563
+ var $i = $iA.slice(f, l);
1564
+ } else {
1565
+ var $i = $( $iA.slice(f, itms.total).get().concat( $iA.slice(0, l).get() ) );
1566
+ }
1567
+
1568
+ if (typeof fn == 'function') fn.call($tt0, $i);
1569
+ return $i;
1570
+ });
1571
+
1572
+ // isPaused, isStopped and isScrolling events
1573
+ $cfs.bind(cf_e('isPaused', conf)+' '+cf_e('isStopped', conf)+' '+cf_e('isScrolling', conf), function(e, fn) {
1574
+ e.stopPropagation();
1575
+ var eType = e.type.slice(conf.events.prefix.length);
1576
+ if (typeof fn == 'function') fn.call($tt0, crsl[eType]);
1577
+ return crsl[eType];
1578
+ });
1579
+
1580
+ // configuration event
1581
+ $cfs.bind(cf_e('configuration', conf), function(e, a, b, c) {
1582
+ e.stopPropagation();
1583
+ var reInit = false;
1584
+
1585
+ // return entire configuration-object
1586
+ if (typeof a == 'function') {
1587
+ a.call($tt0, opts);
1588
+
1589
+ // set multiple options via object
1590
+ } else if (typeof a == 'object') {
1591
+ opts_orig = $.extend(true, {}, opts_orig, a);
1592
+ if (b !== false) reInit = true;
1593
+ else opts = $.extend(true, {}, opts, a);
1594
+
1595
+ } else if (typeof a != 'undefined') {
1596
+
1597
+ // callback function for specific option
1598
+ if (typeof b == 'function') {
1599
+ var val = eval('opts.'+a);
1600
+ if (typeof val == 'undefined') val = '';
1601
+ b.call($tt0, val);
1602
+
1603
+ // set individual option
1604
+ } else if (typeof b != 'undefined') {
1605
+ if (typeof c !== 'boolean') c = true;
1606
+ eval('opts_orig.'+a+' = b');
1607
+ if (c !== false) reInit = true;
1608
+ else eval('opts.'+a+' = b');
1609
+
1610
+ // return value for specific option
1611
+ } else {
1612
+ return eval('opts.'+a);
1613
+ }
1614
+ }
1615
+ if (reInit) {
1616
+ sz_resetMargin($cfs.children(), opts);
1617
+ $cfs._cfs_init(opts_orig);
1618
+ $cfs._cfs_bind_buttons();
1619
+ var siz = sz_setSizes($cfs, opts, false);
1620
+ $cfs.trigger(cf_e('updatePageStatus', conf), [true, siz]);
1621
+ }
1622
+ return opts;
1623
+ });
1624
+
1625
+ // linkAnchors event
1626
+ $cfs.bind(cf_e('linkAnchors', conf), function(e, $con, sel) {
1627
+ e.stopPropagation();
1628
+ if (typeof $con == 'undefined' || $con.length == 0) $con = $('body');
1629
+ else if (typeof $con == 'string') $con = $($con);
1630
+ if (typeof $con != 'object') return debug(conf, 'Not a valid object.');
1631
+ if (typeof sel != 'string' || sel.length == 0) sel = 'a.caroufredsel';
1632
+ $con.find(sel).each(function() {
1633
+ var h = this.hash || '';
1634
+ if (h.length > 0 && $cfs.children().index($(h)) != -1) {
1635
+ $(this).unbind('click').click(function(e) {
1636
+ e.preventDefault();
1637
+ $cfs.trigger(cf_e('slideTo', conf), h);
1638
+ });
1639
+ }
1640
+ });
1641
+ return true;
1642
+ });
1643
+
1644
+ // updatePageStatus event
1645
+ $cfs.bind(cf_e('updatePageStatus', conf), function(e, build, sizes) {
1646
+ e.stopPropagation();
1647
+ if (!opts.pagination.container) return;
1648
+
1649
+ if (build) {
1650
+ var ipp = opts.pagination.items || opts.items.visible,
1651
+ l = Math.ceil(itms.total/ipp);
1652
+
1653
+ if (opts.pagination.anchorBuilder) {
1654
+ opts.pagination.container.children().remove();
1655
+ opts.pagination.container.each(function() {
1656
+ for (var a = 0; a < l; a++) {
1657
+ var i = $cfs.children().eq( gn_getItemIndex(a*ipp, 0, true, itms, $cfs) );
1658
+ $(this).append(opts.pagination.anchorBuilder(a+1, i));
1659
+ }
1660
+ });
1661
+ }
1662
+ opts.pagination.container.each(function() {
1663
+ $(this).children().unbind(opts.pagination.event).each(function(a) {
1664
+ $(this).bind(opts.pagination.event, function(e) {
1665
+ e.preventDefault();
1666
+ $cfs.trigger(cf_e('slideTo', conf), [a*ipp, 0, true, opts.pagination]);
1667
+ });
1668
+ });
1669
+ });
1670
+ }
1671
+ opts.pagination.container.each(function() {
1672
+ $(this).children().removeClass(cf_c('selected', conf)).eq($cfs.triggerHandler(cf_e('currentPage', conf))).addClass(cf_c('selected', conf));
1673
+ });
1674
+ return true;
1675
+ });
1676
+
1677
+ // updateSizes event
1678
+ $cfs.bind(cf_e('updateSizes', conf), function(e) {
1679
+ var a_itm = $cfs.children(),
1680
+ vI = opts.items.visible;
1681
+
1682
+ if (opts.items.visibleConf.variable) vI = gn_getVisibleItemsNext(a_itm, opts, 0);
1683
+ else if (opts.items.filter != '*') vI = gn_getVisibleItemsNextFilter(a_itm, opts, 0);
1684
+
1685
+ if (!opts.circular && itms.first != 0 && vI > itms.first) {
1686
+ if (opts.items.visibleConf.variable) {
1687
+ var nI = gn_getVisibleItemsPrev(a_itm, opts, itms.first) - itms.first;
1688
+ } else if (opts.items.filter != '*') {
1689
+ var nI = gn_getVisibleItemsPrevFilter(a_itm, opts, itms.first) - itms.first;
1690
+ } else {
1691
+ nI = opts.items.visible - itms.first;
1692
+ }
1693
+ debug(conf, 'Preventing non-circular: sliding '+nI+' items backward.');
1694
+ $cfs.trigger('prev', nI);
1695
+ }
1696
+ opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
1697
+ return sz_setSizes($cfs, opts);
1698
+ });
1699
+
1700
+ // destroy event
1701
+ $cfs.bind(cf_e('destroy', conf), function(e, orgOrder) {
1702
+ e.stopPropagation();
1703
+ tmrs = sc_clearTimers(tmrs);
1704
+
1705
+ $cfs.data('cfs_isCarousel', false);
1706
+ $cfs.trigger(cf_e('finish', conf));
1707
+ if (orgOrder) {
1708
+ $cfs.trigger(cf_e('jumpToStart', conf));
1709
+ }
1710
+ if (opts.usePadding) {
1711
+ sz_resetMargin($cfs.children(), opts);
1712
+ }
1713
+
1714
+ $cfs.css($cfs.data('cfs_origCss'));
1715
+ $cfs._cfs_unbind_events();
1716
+ $cfs._cfs_unbind_buttons();
1717
+ $wrp.replaceWith($cfs);
1718
+
1719
+ return true;
1720
+ });
1721
+
1722
+ // triggerEvent, making prefixed and namespaced events accessible from the outside
1723
+ $cfs.bind('_cfs_triggerEvent', function(e, n, o) {
1724
+ e.stopPropagation();
1725
+ return $cfs.triggerHandler(cf_e(n, conf), o);
1726
+ });
1727
+ }; // /bind_events
1728
+
1729
+ $cfs._cfs_unbind_events = function() {
1730
+ $cfs.unbind(cf_e('', conf));
1731
+ $cfs.unbind(cf_e('', conf, false));
1732
+ }; // /unbind_events
1733
+
1734
+ $cfs._cfs_bind_buttons = function() {
1735
+ $cfs._cfs_unbind_buttons();
1736
+ nv_showNavi(opts, itms.total, conf);
1737
+ nv_enableNavi(opts, itms.first, conf);
1738
+
1739
+ if (opts.auto.pauseOnHover) {
1740
+ var pC = bt_pauseOnHoverConfig(opts.auto.pauseOnHover);
1741
+ $wrp.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
1742
+ .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
1743
+ }
1744
+
1745
+ if (opts.auto.button) {
1746
+ opts.auto.button.bind(cf_e(opts.auto.event, conf, false), function(e) {
1747
+ e.preventDefault();
1748
+ var ev = false,
1749
+ pC = null;
1750
+
1751
+ if (crsl.isPaused) {
1752
+ ev = 'play';
1753
+ } else if (opts.auto.pauseOnEvent) {
1754
+ ev = 'pause';
1755
+ pC = bt_pauseOnHoverConfig(opts.auto.pauseOnEvent);
1756
+ }
1757
+ if (ev) {
1758
+ $cfs.trigger(cf_e(ev, conf), pC);
1759
+ }
1760
+ });
1761
+ }
1762
+ if (opts.prev.button) {
1763
+ opts.prev.button.bind(cf_e(opts.prev.event, conf, false), function(e) {
1764
+ e.preventDefault();
1765
+ $cfs.trigger(cf_e('prev', conf));
1766
+ });
1767
+ if (opts.prev.pauseOnHover) {
1768
+ var pC = bt_pauseOnHoverConfig(opts.prev.pauseOnHover);
1769
+ opts.prev.button.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
1770
+ .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
1771
+ }
1772
+ }
1773
+
1774
+ if (opts.next.button) {
1775
+ opts.next.button.bind(cf_e(opts.next.event, conf, false), function(e) {
1776
+ e.preventDefault();
1777
+ $cfs.trigger(cf_e('next', conf));
1778
+ });
1779
+ if (opts.next.pauseOnHover) {
1780
+ var pC = bt_pauseOnHoverConfig(opts.next.pauseOnHover);
1781
+ opts.next.button.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
1782
+ .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
1783
+ }
1784
+ }
1785
+ if ($.fn.mousewheel) {
1786
+ if (opts.prev.mousewheel) {
1787
+ if (!crsl.mousewheelPrev) {
1788
+ crsl.mousewheelPrev = true;
1789
+ $wrp.mousewheel(function(e, delta) {
1790
+ if (delta > 0) {
1791
+ e.preventDefault();
1792
+ var num = bt_mousesheelNumber(opts.prev.mousewheel);
1793
+ $cfs.trigger(cf_e('prev', conf), num);
1794
+ }
1795
+ });
1796
+ }
1797
+ }
1798
+ if (opts.next.mousewheel) {
1799
+ if (!crsl.mousewheelNext) {
1800
+ crsl.mousewheelNext = true;
1801
+ $wrp.mousewheel(function(e, delta) {
1802
+ if (delta < 0) {
1803
+ e.preventDefault();
1804
+ var num = bt_mousesheelNumber(opts.next.mousewheel);
1805
+ $cfs.trigger(cf_e('next', conf), num);
1806
+ }
1807
+ });
1808
+ }
1809
+ }
1810
+ }
1811
+ if ($.fn.touchwipe) {
1812
+ var wP = (opts.prev.wipe) ? function() { $cfs.trigger(cf_e('prev', conf)) } : null,
1813
+ wN = (opts.next.wipe) ? function() { $cfs.trigger(cf_e('next', conf)) } : null;
1814
+
1815
+ if (wN || wN) {
1816
+ if (!crsl.touchwipe) {
1817
+ crsl.touchwipe = true;
1818
+ var twOps = {
1819
+ 'min_move_x': 30,
1820
+ 'min_move_y': 30,
1821
+ 'preventDefaultEvents': true
1822
+ };
1823
+ switch (opts.direction) {
1824
+ case 'up':
1825
+ case 'down':
1826
+ twOps.wipeUp = wP;
1827
+ twOps.wipeDown = wN;
1828
+ break;
1829
+ default:
1830
+ twOps.wipeLeft = wN;
1831
+ twOps.wipeRight = wP;
1832
+ }
1833
+ $wrp.touchwipe(twOps);
1834
+ }
1835
+ }
1836
+ }
1837
+ if (opts.pagination.container) {
1838
+ if (opts.pagination.pauseOnHover) {
1839
+ var pC = bt_pauseOnHoverConfig(opts.pagination.pauseOnHover);
1840
+ opts.pagination.container.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
1841
+ .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
1842
+ }
1843
+ }
1844
+ if (opts.prev.key || opts.next.key) {
1845
+ $(document).bind(cf_e('keyup', conf, false, true, true), function(e) {
1846
+ var k = e.keyCode;
1847
+ if (k == opts.next.key) {
1848
+ e.preventDefault();
1849
+ $cfs.trigger(cf_e('next', conf));
1850
+ }
1851
+ if (k == opts.prev.key) {
1852
+ e.preventDefault();
1853
+ $cfs.trigger(cf_e('prev', conf));
1854
+ }
1855
+ });
1856
+ }
1857
+ if (opts.pagination.keys) {
1858
+ $(document).bind(cf_e('keyup', conf, false, true, true), function(e) {
1859
+ var k = e.keyCode;
1860
+ if (k >= 49 && k < 58) {
1861
+ k = (k-49) * opts.items.visible;
1862
+ if (k <= itms.total) {
1863
+ e.preventDefault();
1864
+ $cfs.trigger(cf_e('slideTo', conf), [k, 0, true, opts.pagination]);
1865
+ }
1866
+ }
1867
+ });
1868
+ }
1869
+ if (opts.auto.play) {
1870
+ $cfs.trigger(cf_e('play', conf), opts.auto.delay);
1871
+ }
1872
+
1873
+ if (crsl.upDateOnWindowResize) {
1874
+ var $w = $(window),
1875
+ _windowWidth = $w.width(),
1876
+ _windowHeight = $w.height();
1877
+
1878
+ $w.bind(cf_e('resize', conf, false, true, true), function(e) {
1879
+ if ($w.width() != _windowWidth || $w.height() != _windowHeight) {
1880
+ $cfs.trigger(cf_e('finish', conf));
1881
+ if (opts.auto.pauseOnResize && !crsl.isPaused) {
1882
+ $cfs.trigger(cf_e('play', conf));
1883
+ }
1884
+ sz_resetMargin($cfs.children(), opts);
1885
+ $cfs._cfs_init(opts_orig);
1886
+ var siz = sz_setSizes($cfs, opts, false);
1887
+ $cfs.trigger(cf_e('updatePageStatus', conf), [true, siz]);
1888
+
1889
+ _windowWidth = $w.width();
1890
+ _windowHeight = $w.height();
1891
+ }
1892
+ });
1893
+ }
1894
+
1895
+ }; // /bind_buttons
1896
+
1897
+ $cfs._cfs_unbind_buttons = function() {
1898
+ var ns1 = cf_e('', conf),
1899
+ ns2 = cf_e('', conf, false);
1900
+ ns3 = cf_e('', conf, false, true, true);
1901
+
1902
+ $(document).unbind(ns3);
1903
+ $(window).unbind(ns3);
1904
+ $wrp.unbind(ns2);
1905
+
1906
+ if (opts.auto.button) opts.auto.button.unbind(ns2);
1907
+ if (opts.prev.button) opts.prev.button.unbind(ns2);
1908
+ if (opts.next.button) opts.next.button.unbind(ns2);
1909
+ if (opts.pagination.container) {
1910
+ opts.pagination.container.unbind(ns2);
1911
+ if (opts.pagination.anchorBuilder) {
1912
+ opts.pagination.container.children().remove();
1913
+ }
1914
+ }
1915
+
1916
+ nv_showNavi(opts, 'hide', conf);
1917
+ nv_enableNavi(opts, 'removeClass', conf);
1918
+
1919
+ }; // /unbind_buttons
1920
+
1921
+
1922
+
1923
+ // START
1924
+
1925
+ var crsl = {
1926
+ 'direction' : 'next',
1927
+ 'isPaused' : true,
1928
+ 'isScrolling' : false,
1929
+ 'isStopped' : false,
1930
+
1931
+ 'mousewheelNext': false,
1932
+ 'mousewheelPrev': false,
1933
+ 'touchwipe' : false
1934
+ },
1935
+ itms = {
1936
+ 'total' : $cfs.children().length,
1937
+ 'first' : 0
1938
+ },
1939
+ tmrs = {
1940
+ 'timer' : null,
1941
+ 'auto' : null,
1942
+ 'queue' : null,
1943
+ 'startTime' : getTime(),
1944
+ 'timePassed' : 0
1945
+ },
1946
+ scrl = {
1947
+ 'isStopped' : false,
1948
+ 'duration' : 0,
1949
+ 'startTime' : 0,
1950
+ 'easing' : '',
1951
+ 'anims' : []
1952
+ },
1953
+ clbk = {
1954
+ 'onBefore' : [],
1955
+ 'onAfter' : []
1956
+ },
1957
+ queu = [],
1958
+ conf = $.extend(true, {}, $.fn.carouFredSel.configs, configs),
1959
+ opts = {},
1960
+ opts_orig = options,
1961
+ $wrp = $cfs.wrap('<'+conf.wrapper.element+' class="'+conf.wrapper.classname+'" />').parent();
1962
+
1963
+ conf.selector = $cfs.selector;
1964
+ conf.serialNumber = $.fn.carouFredSel.serialNumber++;
1965
+
1966
+ // create carousel
1967
+ $cfs._cfs_init(opts_orig, true, starting_position);
1968
+ $cfs._cfs_build();
1969
+ $cfs._cfs_bind_events();
1970
+ $cfs._cfs_bind_buttons();
1971
+
1972
+ // find item to start
1973
+ if (is_array(opts.items.start)) {
1974
+ var start_arr = opts.items.start;
1975
+ } else {
1976
+ var start_arr = [];
1977
+ if (opts.items.start != 0) {
1978
+ start_arr.push(opts.items.start);
1979
+ }
1980
+ }
1981
+ if (opts.cookie) {
1982
+ start_arr.unshift(cf_readCookie(opts.cookie));
1983
+ }
1984
+ if (start_arr.length > 0) {
1985
+ for (var a = 0, l = start_arr.length; a < l; a++) {
1986
+ var s = start_arr[a];
1987
+ if (s == 0) {
1988
+ continue;
1989
+ }
1990
+ if (s === true) {
1991
+ s = window.location.hash;
1992
+ if (s.length < 1) {
1993
+ continue;
1994
+ }
1995
+ } else if (s === 'random') {
1996
+ s = Math.floor(Math.random()*itms.total);
1997
+ }
1998
+ if ($cfs.triggerHandler(cf_e('slideTo', conf), [s, 0, true, { fx: 'none' }])) {
1999
+ break;
2000
+ }
2001
+ }
2002
+ }
2003
+ var siz = sz_setSizes($cfs, opts, false),
2004
+ itm = gi_getCurrentItems($cfs.children(), opts);
2005
+
2006
+ if (opts.onCreate) {
2007
+ opts.onCreate.call($tt0, itm, siz);
2008
+ }
2009
+
2010
+ $cfs.trigger(cf_e('updatePageStatus', conf), [true, siz]);
2011
+ $cfs.trigger(cf_e('linkAnchors', conf));
2012
+
2013
+ return $cfs;
2014
+ };
2015
+
2016
+
2017
+ // GLOBAL PUBLIC
2018
+
2019
+ $.fn.carouFredSel.serialNumber = 1;
2020
+ $.fn.carouFredSel.defaults = {
2021
+ 'synchronise' : false,
2022
+ 'infinite' : true,
2023
+ 'circular' : true,
2024
+ 'responsive' : false,
2025
+ 'direction' : 'left',
2026
+ 'items' : {
2027
+ 'start' : 0
2028
+ },
2029
+ 'scroll' : {
2030
+ 'easing' : 'swing',
2031
+ 'duration' : 500,
2032
+ 'pauseOnHover' : false,
2033
+ 'mousewheel' : false,
2034
+ 'wipe' : false,
2035
+ 'event' : 'click',
2036
+ 'queue' : false
2037
+ }
2038
+ };
2039
+ $.fn.carouFredSel.configs = {
2040
+ 'debug' : false,
2041
+ 'events' : {
2042
+ 'prefix' : '',
2043
+ 'namespace' : 'cfs'
2044
+ },
2045
+ 'wrapper' : {
2046
+ 'element' : 'div',
2047
+ 'classname' : 'caroufredsel_wrapper'
2048
+ },
2049
+ 'classnames' : {}
2050
+ };
2051
+ $.fn.carouFredSel.pageAnchorBuilder = function(nr, itm) {
2052
+ return '<a href="#"><span>'+nr+'</span></a>';
2053
+ };
2054
+
2055
+
2056
+ // GLOBAL PRIVATE
2057
+
2058
+ // scrolling functions
2059
+ function sc_setScroll(d, e) {
2060
+ return {
2061
+ anims : [],
2062
+ duration : d,
2063
+ orgDuration : d,
2064
+ easing : e,
2065
+ startTime : getTime()
2066
+ };
2067
+ }
2068
+ function sc_startScroll(s) {
2069
+ if (typeof s.pre == 'object') {
2070
+ sc_startScroll(s.pre);
2071
+ }
2072
+ for (var a = 0, l = s.anims.length; a < l; a++) {
2073
+ var b = s.anims[a];
2074
+ if (!b) continue;
2075
+ if (b[3]) b[0].stop();
2076
+ b[0].animate(b[1], {
2077
+ complete: b[2],
2078
+ duration: s.duration,
2079
+ easing: s.easing
2080
+ });
2081
+ }
2082
+ if (typeof s.post == 'object') {
2083
+ sc_startScroll(s.post);
2084
+ }
2085
+ }
2086
+ function sc_stopScroll(s, finish) {
2087
+ if (typeof finish != 'boolean') finish = true;
2088
+ if (typeof s.pre == 'object') {
2089
+ sc_stopScroll(s.pre, finish);
2090
+ }
2091
+ for (var a = 0, l = s.anims.length; a < l; a++) {
2092
+ var b = s.anims[a];
2093
+ b[0].stop(true);
2094
+ if (finish) {
2095
+ b[0].css(b[1]);
2096
+ if (typeof b[2] == 'function') b[2]();
2097
+ }
2098
+ }
2099
+ if (typeof s.post == 'object') {
2100
+ sc_stopScroll(s.post, finish);
2101
+ }
2102
+ }
2103
+ function sc_clearTimers(t) {
2104
+ if (t.auto) clearTimeout(t.auto);
2105
+ return t;
2106
+ }
2107
+ function sc_callCallbacks(cbs, t, args) {
2108
+ if (cbs.length) {
2109
+ for (var a = 0, l = cbs.length; a < l; a++) {
2110
+ cbs[a].apply(t, args);
2111
+ }
2112
+ }
2113
+ return [];
2114
+ }
2115
+
2116
+ // fx functions
2117
+ function fx_fade(sO, c, x, d, f) {
2118
+ var o = {
2119
+ 'duration' : d,
2120
+ 'easing' : sO.easing
2121
+ };
2122
+ if (typeof f == 'function') o.complete = f;
2123
+ c.animate({
2124
+ opacity: x
2125
+ }, o);
2126
+ }
2127
+ function fx_cover(sc, c1, c2, o, prev) {
2128
+ var old_w = ms_getSizes(gi_getOldItemsNext(c1.children(), o), o, true)[0],
2129
+ new_w = ms_getSizes(c2.children(), o, true)[0],
2130
+ cur_l = (prev) ? -new_w : old_w,
2131
+ css_o = {},
2132
+ ani_o = {};
2133
+
2134
+ css_o[o.d['width']] = new_w;
2135
+ css_o[o.d['left']] = cur_l;
2136
+ ani_o[o.d['left']] = 0;
2137
+
2138
+ sc.pre.anims.push([c1, { 'opacity': 1 }]);
2139
+ sc.post.anims.push([c2, ani_o, function() { $(this).remove(); }]);
2140
+ c2.css(css_o);
2141
+ return sc;
2142
+ }
2143
+ function fx_uncover(sc, c1, c2, o, prev, n) {
2144
+ var new_w = ms_getSizes(gi_getNewItemsNext(c1.children(), o, n), o, true)[0],
2145
+ old_w = ms_getSizes(c2.children(), o, true)[0],
2146
+ cur_l = (prev) ? -old_w : new_w,
2147
+ css_o = {},
2148
+ ani_o = {};
2149
+
2150
+ css_o[o.d['width']] = old_w;
2151
+ css_o[o.d['left']] = 0;
2152
+ ani_o[o.d['left']] = cur_l;
2153
+ sc.post.anims.push([c2, ani_o, function() { $(this).remove(); }]);
2154
+ c2.css(css_o);
2155
+ return sc;
2156
+ }
2157
+
2158
+ // navigation functions
2159
+ function nv_showNavi(o, t, c) {
2160
+ if (t == 'show' || t == 'hide') {
2161
+ var f = t;
2162
+ } else if (o.items.minimum >= t) {
2163
+ debug(c, 'Not enough items: hiding navigation ('+t+' items, '+o.items.minimum+' needed).');
2164
+ var f = 'hide';
2165
+ } else {
2166
+ var f = 'show';
2167
+ }
2168
+ var s = (f == 'show') ? 'removeClass' : 'addClass',
2169
+ h = cf_c('hidden', c);
2170
+ if (o.auto.button) o.auto.button[f]()[s](h);
2171
+ if (o.prev.button) o.prev.button[f]()[s](h);
2172
+ if (o.next.button) o.next.button[f]()[s](h);
2173
+ if (o.pagination.container) o.pagination.container[f]()[s](h);
2174
+ }
2175
+ function nv_enableNavi(o, f, c) {
2176
+ if (o.circular || o.infinite) return;
2177
+ var fx = (f == 'removeClass' || f == 'addClass') ? f : false,
2178
+ di = cf_c('disabled', c);
2179
+ if (o.auto.button && fx) {
2180
+ o.auto.button[fx](di);
2181
+ }
2182
+ if (o.prev.button) {
2183
+ var fn = fx || (f == 0) ? 'addClass' : 'removeClass';
2184
+ o.prev.button[fn](di);
2185
+ }
2186
+ if (o.next.button) {
2187
+ var fn = fx || (f == o.items.visible) ? 'addClass' : 'removeClass';
2188
+ o.next.button[fn](di);
2189
+ }
2190
+ }
2191
+
2192
+ // get object functions
2193
+ function go_getObject($tt, obj) {
2194
+ if (typeof obj == 'function') obj = obj.call($tt);
2195
+ if (typeof obj == 'undefined') obj = {};
2196
+ return obj;
2197
+ }
2198
+ function go_getNaviObject($tt, obj, type) {
2199
+ if (typeof type != 'string') type = '';
2200
+
2201
+ obj = go_getObject($tt, obj);
2202
+ if (typeof obj == 'string') {
2203
+ var temp = cf_getKeyCode(obj);
2204
+ if (temp == -1) obj = $(obj);
2205
+ else obj = temp;
2206
+ }
2207
+
2208
+ // pagination
2209
+ if (type == 'pagination') {
2210
+ if (typeof obj == 'boolean') obj = { 'keys': obj };
2211
+ if (typeof obj.jquery != 'undefined') obj = { 'container': obj };
2212
+ if (typeof obj.container == 'function') obj.container = obj.container.call($tt);
2213
+ if (typeof obj.container == 'string') obj.container = $(obj.container);
2214
+ if (typeof obj.items != 'number') obj.items = false;
2215
+
2216
+ // auto
2217
+ } else if (type == 'auto') {
2218
+ if (typeof obj.jquery != 'undefined') obj = { 'button': obj };
2219
+ if (typeof obj == 'boolean') obj = { 'play': obj };
2220
+ if (typeof obj == 'number') obj = { 'pauseDuration': obj };
2221
+ if (typeof obj.button == 'function') obj.button = obj.button.call($tt);
2222
+ if (typeof obj.button == 'string') obj.button = $(obj.button);
2223
+
2224
+ // prev + next
2225
+ } else {
2226
+ if (typeof obj.jquery != 'undefined') obj = { 'button': obj };
2227
+ if (typeof obj == 'number') obj = { 'key': obj };
2228
+ if (typeof obj.button == 'function') obj.button = obj.button.call($tt);
2229
+ if (typeof obj.button == 'string') obj.button = $(obj.button);
2230
+ if (typeof obj.key == 'string') obj.key = cf_getKeyCode(obj.key);
2231
+ }
2232
+
2233
+ return obj;
2234
+ }
2235
+
2236
+ // get number functions
2237
+ function gn_getItemIndex(num, dev, org, items, $cfs) {
2238
+ if (typeof num == 'string') {
2239
+ if (isNaN(num)) num = $(num);
2240
+ else num = parseInt(num);
2241
+ }
2242
+ if (typeof num == 'object') {
2243
+ if (typeof num.jquery == 'undefined') num = $(num);
2244
+ num = $cfs.children().index(num);
2245
+ if (num == -1) num = 0;
2246
+ if (typeof org != 'boolean') org = false;
2247
+ } else {
2248
+ if (typeof org != 'boolean') org = true;
2249
+ }
2250
+ if (isNaN(num)) num = 0;
2251
+ else num = parseInt(num);
2252
+ if (isNaN(dev)) dev = 0;
2253
+ else dev = parseInt(dev);
2254
+
2255
+ if (org) {
2256
+ num += items.first;
2257
+ }
2258
+ num += dev;
2259
+ if (items.total > 0) {
2260
+ while (num >= items.total) { num -= items.total; }
2261
+ while (num < 0) { num += items.total; }
2262
+ }
2263
+ return num;
2264
+ }
2265
+
2266
+ // items prev
2267
+ function gn_getVisibleItemsPrev(i, o, s) {
2268
+ var t = 0,
2269
+ x = 0;
2270
+
2271
+ for (var a = s; a >= 0; a--) {
2272
+ var j = i.eq(a);
2273
+ t += (j.is(':visible')) ? j[o.d['outerWidth']](true) : 0;
2274
+ if (t > o.maxDimention) return x;
2275
+ if (a == 0) a = i.length;
2276
+ x++;
2277
+ }
2278
+ }
2279
+ function gn_getVisibleItemsPrevFilter(i, o, s) {
2280
+ return gn_getItemsPrevFilter(i, o.items.filter, o.items.visibleConf.org, s);
2281
+ }
2282
+ function gn_getScrollItemsPrevFilter(i, o, s, m) {
2283
+ return gn_getItemsPrevFilter(i, o.items.filter, m, s);
2284
+ }
2285
+ function gn_getItemsPrevFilter(i, f, m, s) {
2286
+ var t = 0,
2287
+ x = 0;
2288
+
2289
+ for (var a = s, l = i.length; a >= 0; a--) {
2290
+ x++;
2291
+ if (x == l) return x;
2292
+
2293
+ var j = i.eq(a);
2294
+ if (j.is(f)) {
2295
+ t++;
2296
+ if (t == m) return x;
2297
+ }
2298
+ if (a == 0) a = l;
2299
+ }
2300
+ }
2301
+
2302
+ function gn_getVisibleOrg($c, o) {
2303
+ return o.items.visibleConf.org || $c.children().slice(0, o.items.visible).filter(o.items.filter).length;
2304
+ }
2305
+
2306
+ // items next
2307
+ function gn_getVisibleItemsNext(i, o, s) {
2308
+ var t = 0,
2309
+ x = 0;
2310
+
2311
+ for (var a = s, l = i.length-1; a <= l; a++) {
2312
+ var j = i.eq(a);
2313
+
2314
+ t += (j.is(':visible')) ? j[o.d['outerWidth']](true) : 0;
2315
+ if (t > o.maxDimention) return x;
2316
+
2317
+ x++;
2318
+ if (x == l+1) return x;
2319
+ if (a == l) a = -1;
2320
+ }
2321
+ }
2322
+ function gn_getVisibleItemsNextTestCircular(i, o, s, l) {
2323
+ var v = gn_getVisibleItemsNext(i, o, s);
2324
+ if (!o.circular) {
2325
+ if (s + v > l) v = l - s;
2326
+ }
2327
+ return v;
2328
+ }
2329
+ function gn_getVisibleItemsNextFilter(i, o, s) {
2330
+ return gn_getItemsNextFilter(i, o.items.filter, o.items.visibleConf.org, s, o.circular);
2331
+ }
2332
+ function gn_getScrollItemsNextFilter(i, o, s, m) {
2333
+ return gn_getItemsNextFilter(i, o.items.filter, m+1, s, o.circular) - 1;
2334
+ }
2335
+ function gn_getItemsNextFilter(i, f, m, s, c) {
2336
+ var t = 0,
2337
+ x = 0;
2338
+
2339
+ for (var a = s, l = i.length-1; a <= l; a++) {
2340
+ x++;
2341
+ if (x == l) return x;
2342
+
2343
+ var j = i.eq(a);
2344
+ if (j.is(f)) {
2345
+ t++;
2346
+ if (t == m) return x;
2347
+ }
2348
+ if (a == l) a = -1;
2349
+ }
2350
+ }
2351
+
2352
+ // get items functions
2353
+ function gi_getCurrentItems(i, o) {
2354
+ return i.slice(0, o.items.visible);
2355
+ }
2356
+ function gi_getOldItemsPrev(i, o, n) {
2357
+ return i.slice(n, o.items.visibleConf.old+n);
2358
+ }
2359
+ function gi_getNewItemsPrev(i, o) {
2360
+ return i.slice(0, o.items.visible);
2361
+ }
2362
+ function gi_getOldItemsNext(i, o) {
2363
+ return i.slice(0, o.items.visibleConf.old);
2364
+ }
2365
+ function gi_getNewItemsNext(i, o, n) {
2366
+ return i.slice(n, o.items.visible+n);
2367
+ }
2368
+
2369
+ // sizes functions
2370
+ function sz_resetMargin(i, o, m) {
2371
+ var x = (typeof m == 'boolean') ? m : false;
2372
+ if (typeof m != 'number') m = 0;
2373
+ i.each(function() {
2374
+ var j = $(this);
2375
+ var t = parseInt(j.css(o.d['marginRight']));
2376
+ if (isNaN(t)) t = 0;
2377
+ j.data('cfs_tempCssMargin', t);
2378
+ j.css(o.d['marginRight'], ((x) ? j.data('cfs_tempCssMargin') : m + j.data('cfs_origCssMargin')));
2379
+ });
2380
+ }
2381
+ function sz_setSizes($c, o, p) {
2382
+ var $w = $c.parent(),
2383
+ $i = $c.children(),
2384
+ $v = gi_getCurrentItems($i, o),
2385
+ sz = cf_mapWrapperSizes(ms_getSizes($v, o, true), o, p);
2386
+
2387
+ $w.css(sz);
2388
+
2389
+ if (o.usePadding) {
2390
+ var p = o.padding,
2391
+ r = p[o.d[1]];
2392
+ if (o.align) {
2393
+ if (r < 0) r = 0;
2394
+ }
2395
+ var $l = $v.last();
2396
+ $l.css(o.d['marginRight'], $l.data('cfs_origCssMargin') + r);
2397
+ $c.css(o.d['top'], p[o.d[0]]);
2398
+ $c.css(o.d['left'], p[o.d[3]]);
2399
+ }
2400
+
2401
+ $c.css(o.d['width'], sz[o.d['width']]+(ms_getTotalSize($i, o, 'width')*2));
2402
+ $c.css(o.d['height'], ms_getLargestSize($i, o, 'height'));
2403
+ return sz;
2404
+ }
2405
+
2406
+ // measuring functions
2407
+ function ms_getSizes(i, o, wrapper) {
2408
+ var s1 = ms_getTotalSize(i, o, 'width', wrapper),
2409
+ s2 = ms_getLargestSize(i, o, 'height', wrapper);
2410
+ return [s1, s2];
2411
+ }
2412
+ function ms_getLargestSize(i, o, dim, wrapper) {
2413
+ if (typeof wrapper != 'boolean') wrapper = false;
2414
+ if (typeof o[o.d[dim]] == 'number' && wrapper) return o[o.d[dim]];
2415
+ if (typeof o.items[o.d[dim]] == 'number') return o.items[o.d[dim]];
2416
+ var di2 = (dim.toLowerCase().indexOf('width') > -1) ? 'outerWidth' : 'outerHeight';
2417
+ return ms_getTrueLargestSize(i, o, di2);
2418
+ }
2419
+ function ms_getTrueLargestSize(i, o, dim) {
2420
+ var s = 0;
2421
+
2422
+ for (var a = 0, l = i.length; a < l; a++) {
2423
+ var j = i.eq(a);
2424
+
2425
+ var m = (j.is(':visible')) ? j[o.d[dim]](true) : 0;
2426
+ if (s < m) s = m;
2427
+ }
2428
+ return s;
2429
+ }
2430
+ function ms_getTrueInnerSize($el, o, dim) {
2431
+ if (!$el.is(':visible')) return 0;
2432
+
2433
+ var siz = $el[o.d[dim]](),
2434
+ arr = (o.d[dim].toLowerCase().indexOf('width') > -1) ? ['paddingLeft', 'paddingRight'] : ['paddingTop', 'paddingBottom'];
2435
+
2436
+ for (var a = 0, l = arr.length; a < l; a++) {
2437
+ var m = parseInt($el.css(arr[a]));
2438
+ siz -= (isNaN(m)) ? 0 : m;
2439
+ }
2440
+ return siz;
2441
+ }
2442
+ function ms_getTotalSize(i, o, dim, wrapper) {
2443
+ if (typeof wrapper != 'boolean') wrapper = false;
2444
+ if (typeof o[o.d[dim]] == 'number' && wrapper) return o[o.d[dim]];
2445
+ if (typeof o.items[o.d[dim]] == 'number') return o.items[o.d[dim]] * i.length;
2446
+
2447
+ var d = (dim.toLowerCase().indexOf('width') > -1) ? 'outerWidth' : 'outerHeight',
2448
+ s = 0;
2449
+
2450
+ for (var a = 0, l = i.length; a < l; a++) {
2451
+ var j = i.eq(a);
2452
+ s += (j.is(':visible')) ? j[o.d[d]](true) : 0;
2453
+ }
2454
+ return s;
2455
+ }
2456
+ function ms_hasVariableSizes(i, o, dim) {
2457
+ var s = false,
2458
+ v = false;
2459
+
2460
+ for (var a = 0, l = i.length; a < l; a++) {
2461
+ var j = i.eq(a);
2462
+
2463
+ var c = (j.is(':visible')) ? j[o.d[dim]](true) : 0;
2464
+ if (s === false) s = c;
2465
+ else if (s != c) v = true;
2466
+ if (s == 0) v = true;
2467
+ }
2468
+ return v;
2469
+ }
2470
+ function ms_getPaddingBorderMargin(i, o, d) {
2471
+ return i[o.d['outer'+d]](true) - ms_getTrueInnerSize(i, o, 'inner'+d);
2472
+ }
2473
+ function ms_isPercentage(x) {
2474
+ return (typeof x == 'string' && x.slice(-1) == '%');
2475
+ }
2476
+ function ms_getPercentage(s, o) {
2477
+ if (ms_isPercentage(o)) {
2478
+ o = o.slice(0, -1);
2479
+ if (isNaN(o)) return s;
2480
+ s *= o/100;
2481
+ }
2482
+ return s;
2483
+ }
2484
+
2485
+ // config functions
2486
+ function cf_e(n, c, pf, ns, rd) {
2487
+ if (typeof pf != 'boolean') pf = true;
2488
+ if (typeof ns != 'boolean') ns = true;
2489
+ if (typeof rd != 'boolean') rd = false;
2490
+
2491
+ if (pf) n = c.events.prefix + n;
2492
+ if (ns) n = n +'.'+ c.events.namespace;
2493
+ if (ns && rd) n += c.serialNumber;
2494
+
2495
+ return n;
2496
+ }
2497
+ function cf_c(n, c) {
2498
+ return (typeof c.classnames[n] == 'string') ? c.classnames[n] : n;
2499
+ }
2500
+ function cf_mapWrapperSizes(ws, o, p) {
2501
+ if (typeof p != 'boolean') p = true;
2502
+ var pad = (o.usePadding && p) ? o.padding : [0, 0, 0, 0];
2503
+ var wra = {};
2504
+ wra[o.d['width']] = ws[0] + pad[1] + pad[3];
2505
+ wra[o.d['height']] = ws[1] + pad[0] + pad[2];
2506
+
2507
+ return wra;
2508
+ }
2509
+ function cf_sortParams(vals, typs) {
2510
+ var arr = [];
2511
+ for (var a = 0, l1 = vals.length; a < l1; a++) {
2512
+ for (var b = 0, l2 = typs.length; b < l2; b++) {
2513
+ if (typs[b].indexOf(typeof vals[a]) > -1 && typeof arr[b] == 'undefined') {
2514
+ arr[b] = vals[a];
2515
+ break;
2516
+ }
2517
+ }
2518
+ }
2519
+ return arr;
2520
+ }
2521
+ function cf_getPadding(p) {
2522
+ if (typeof p == 'undefined') return [0, 0, 0, 0];
2523
+
2524
+ if (typeof p == 'number') return [p, p, p, p];
2525
+ else if (typeof p == 'string') p = p.split('px').join('').split('em').join('').split(' ');
2526
+
2527
+ if (!is_array(p)) {
2528
+ return [0, 0, 0, 0];
2529
+ }
2530
+ for (var i = 0; i < 4; i++) {
2531
+ p[i] = parseInt(p[i]);
2532
+ }
2533
+ switch (p.length) {
2534
+ case 0: return [0, 0, 0, 0];
2535
+ case 1: return [p[0], p[0], p[0], p[0]];
2536
+ case 2: return [p[0], p[1], p[0], p[1]];
2537
+ case 3: return [p[0], p[1], p[2], p[1]];
2538
+ default: return [p[0], p[1], p[2], p[3]];
2539
+ }
2540
+ }
2541
+ function cf_getAlignPadding(itm, o) {
2542
+ var x = (typeof o[o.d['width']] == 'number') ? Math.ceil(o[o.d['width']] - ms_getTotalSize(itm, o, 'width')) : 0;
2543
+ switch (o.align) {
2544
+ case 'left': return [0, x];
2545
+ case 'right': return [x, 0];
2546
+ case 'center':
2547
+ default:
2548
+ return [Math.ceil(x/2), Math.floor(x/2)];
2549
+ }
2550
+ }
2551
+ function cf_getAdjust(x, o, a, $t) {
2552
+ var v = x;
2553
+ if (typeof a == 'function') {
2554
+ v = a.call($t, v);
2555
+
2556
+ } else if (typeof a == 'string') {
2557
+ var p = a.split('+'),
2558
+ m = a.split('-');
2559
+
2560
+ if (m.length > p.length) {
2561
+ var neg = true,
2562
+ sta = m[0],
2563
+ adj = m[1];
2564
+ } else {
2565
+ var neg = false,
2566
+ sta = p[0],
2567
+ adj = p[1];
2568
+ }
2569
+
2570
+ switch(sta) {
2571
+ case 'even':
2572
+ v = (x % 2 == 1) ? x-1 : x;
2573
+ break;
2574
+ case 'odd':
2575
+ v = (x % 2 == 0) ? x-1 : x;
2576
+ break;
2577
+ default:
2578
+ v = x;
2579
+ break;
2580
+ }
2581
+ adj = parseInt(adj);
2582
+ if (!isNaN(adj)) {
2583
+ if (neg) adj = -adj;
2584
+ v += adj;
2585
+ }
2586
+ }
2587
+ if (typeof v != 'number') v = 1;
2588
+ if (v < 1) v = 1;
2589
+ return v;
2590
+ }
2591
+ function cf_getItemsAdjust(x, o, a, $t) {
2592
+ return cf_getItemAdjustMinMax(cf_getAdjust(x, o, a, $t), o.items.visibleConf);
2593
+ }
2594
+ function cf_getItemAdjustMinMax(v, i) {
2595
+ if (typeof i.min == 'number' && v < i.min) v = i.min;
2596
+ if (typeof i.max == 'number' && v > i.max) v = i.max;
2597
+ if (v < 1) v = 1;
2598
+ return v;
2599
+ }
2600
+ function cf_getSynchArr(s) {
2601
+ if (!is_array(s)) s = [[s]];
2602
+ if (!is_array(s[0])) s = [s];
2603
+ for (var j = 0, l = s.length; j < l; j++) {
2604
+ if (typeof s[j][0] == 'string') s[j][0] = $(s[j][0]);
2605
+ if (typeof s[j][1] != 'boolean') s[j][1] = true;
2606
+ if (typeof s[j][2] != 'boolean') s[j][2] = true;
2607
+ if (typeof s[j][3] != 'number') s[j][3] = 0;
2608
+ }
2609
+ return s;
2610
+ }
2611
+ function cf_getKeyCode(k) {
2612
+ if (k == 'right') return 39;
2613
+ if (k == 'left') return 37;
2614
+ if (k == 'up') return 38;
2615
+ if (k == 'down') return 40;
2616
+ return -1;
2617
+ }
2618
+ function cf_setCookie(n, v) {
2619
+ if (n) document.cookie = n+'='+v+'; path=/';
2620
+ }
2621
+ function cf_readCookie(n) {
2622
+ n += '=';
2623
+ var ca = document.cookie.split(';');
2624
+ for (var a = 0, l = ca.length; a < l; a++) {
2625
+ var c = ca[a];
2626
+ while (c.charAt(0) == ' ') {
2627
+ c = c.slice(1);
2628
+ }
2629
+ if (c.indexOf(n) == 0) {
2630
+ return c.slice(n.length);
2631
+ }
2632
+ }
2633
+ return 0;
2634
+ }
2635
+
2636
+ // buttons functions
2637
+ function bt_pauseOnHoverConfig(p) {
2638
+ if (p && typeof p == 'string') {
2639
+ var i = (p.indexOf('immediate') > -1) ? true : false,
2640
+ r = (p.indexOf('resume') > -1) ? true : false;
2641
+ } else {
2642
+ var i = r = false;
2643
+ }
2644
+ return [i, r];
2645
+ }
2646
+ function bt_mousesheelNumber(mw) {
2647
+ return (typeof mw == 'number') ? mw : null
2648
+ }
2649
+
2650
+ // helper functions
2651
+ function is_array(a) {
2652
+ return typeof(a) == 'object' && (a instanceof Array);
2653
+ }
2654
+
2655
+ function getTime() {
2656
+ return new Date().getTime();
2657
+ }
2658
+
2659
+ function debug(d, m) {
2660
+ if (typeof d == 'object') {
2661
+ var s = ' ('+d.selector+')';
2662
+ d = d.debug;
2663
+ } else {
2664
+ var s = '';
2665
+ }
2666
+ if (!d) return false;
2667
+
2668
+ if (typeof m == 'string') m = 'carouFredSel'+s+': ' + m;
2669
+ else m = ['carouFredSel'+s+':', m];
2670
+
2671
+ if (window.console && window.console.log) window.console.log(m);
2672
+ return false;
2673
+ }
2674
+
2675
+
2676
+ // CAROUFREDSEL ALL LOWERCASE
2677
+
2678
+ $.fn.caroufredsel = function(o, c) {
2679
+ return this.carouFredSel(o, c);
2680
+ };
2681
+
2682
+
2683
+ // EASING FUNCTIONS
2684
+
2685
+ $.extend($.easing, {
2686
+ 'quadratic' : function(t) {
2687
+ var t2 = t * t;
2688
+ return t * (-t2 * t + 4 * t2 - 6 * t + 4);
2689
+ },
2690
+ 'cubic' : function(t) {
2691
+ return t * (4 * t * t - 9 * t + 6);
2692
+ },
2693
+ 'elastic' : function(t) {
2694
+ var t2 = t * t;
2695
+ return t * (33 * t2 * t2 - 106 * t2 * t + 126 * t2 - 67 * t + 15);
2696
+ }
2697
+ });
2698
+
2699
+
2700
+ })(jQuery);