Skip to content
Browse files

adding a simple carousel for youtube search results; simple styling f…

…or cloudcast show page
  • Loading branch information...
1 parent ab5e763 commit 80e579400887787f761907a9d36776628e0ac0a3 @robustdj committed Apr 7, 2012
View
29 Gemfile.lock
@@ -1,31 +1,51 @@
GEM
remote: http://rubygems.org/
specs:
+ addressable (2.2.7)
archive-tar-minitar (0.5.2)
awesome_print (0.4.0)
builder (3.0.0)
columnize (0.3.2)
daemons (1.1.8)
diff-lcs (1.1.2)
eventmachine (0.12.10)
+ faraday (0.7.6)
+ addressable (~> 2.2)
+ multipart-post (~> 1.1)
+ rack (~> 1.1)
foreman (0.41.0)
thor (>= 0.13.6)
+ git (1.2.5)
haml (3.1.2)
heroku (2.8.1)
launchy (>= 0.3.2)
rest-client (~> 1.6.1)
rubyzip
term-ansicolor (~> 1.0.5)
+ jeweler (1.8.3)
+ bundler (~> 1.0)
+ git (>= 1.2.5)
+ rake
+ rdoc
+ json (1.6.6)
launchy (2.0.3)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mime-types (1.16)
+ multi_json (1.2.0)
+ multipart-post (1.1.5)
oauth (0.4.5)
+ oauth2 (0.5.2)
+ faraday (~> 0.7)
+ multi_json (~> 1.0)
rack (1.2.2)
rack-flash (0.1.1)
rack
rack-test (0.5.7)
rack (>= 1.0)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.5.0)
@@ -50,6 +70,7 @@ GEM
sass (3.1.7)
shotgun (0.9)
rack (>= 1.0)
+ simple_oauth (0.1.5)
sinatra (1.2.1)
rack (~> 1.1)
tilt (>= 1.2.2, < 2.0)
@@ -60,9 +81,13 @@ GEM
rack (>= 1.0.0)
thor (0.14.6)
tilt (1.2.2)
- youtube_it (1.4.3)
+ youtube_it (2.1.4)
builder
- oauth (>= 0.4.4)
+ faraday (~> 0.7.3)
+ jeweler (~> 1.8.3)
+ oauth (~> 0.4.4)
+ oauth2 (~> 0.5.2)
+ simple_oauth (~> 0.1.5)
PLATFORMS
ruby
View
6 mixtube.rb
@@ -30,12 +30,16 @@
end
get '/query_youtube' do
- client = YouTubeIt::Client.new(:dev_key => YOUTUBE_KEY)
+ client = YouTubeIt::Client.new(:dev_key => ENV['YOUTUBE_KEY'])
@videos = client.videos_by(:query => params[:q]).videos
content_type :json
@videos.map{|video| {:image_url => video.thumbnails[1].url, :embed => video.embed_html, :title => video.title, :unique_id => video.unique_id}}.to_json
end
+get '/youtube/:yt_id' do
+ haml :youtube, :layout => false
+end
+
get '/oauth' do
redirect "https://www.mixcloud.com/oauth/authorize?client_id=#{MIXCLOUD_API_KEY}&redirect_uri=http://localhost:9393/mixtube_callback"
end
View
BIN public/images/left.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/images/red_record.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN public/images/right.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2,692 public/javascripts/jquery.carouFredSel.js
@@ -0,0 +1,2692 @@
+/*
+ * jQuery carouFredSel 5.5.0
+ * Demo's and documentation:
+ * caroufredsel.frebsite.nl
+ *
+ * Copyright (c) 2012 Fred Heusschen
+ * www.frebsite.nl
+ *
+ * Dual licensed under the MIT and GPL licenses.
+ * http://en.wikipedia.org/wiki/MIT_License
+ * http://en.wikipedia.org/wiki/GNU_General_Public_License
+ */
+
+
+(function($) {
+
+
+
+ // LOCAL
+
+ if ($.fn.carouFredSel) return;
+
+ $.fn.carouFredSel = function(options, configs) {
+ if (this.length == 0) {
+ debug(true, 'No element found for "'+this.selector+'".');
+ return this;
+ }
+ if (this.length > 1) {
+ return this.each(function() {
+ $(this).carouFredSel(options, configs);
+ });
+ }
+
+ var $cfs = this,
+ $tt0 = this[0];
+
+ if ($cfs.data('cfs_isCarousel')) {
+ var starting_position = $cfs.triggerHandler('_cfs_currentPosition');
+ $cfs.trigger('_cfs_destroy', true);
+ } else {
+ var starting_position = false;
+ }
+
+ $cfs._cfs_init = function(o, setOrig, start) {
+ o = go_getObject($tt0, o);
+
+
+ // DEPRECATED
+ if (o.debug) {
+ conf.debug = o.debug;
+ debug(conf, 'The "debug" option should be moved to the second configuration-object.');
+ }
+ // /DEPRECATED
+
+
+ var obs = ['items', 'scroll', 'auto', 'prev', 'next', 'pagination'];
+ for (var a = 0, l = obs.length; a < l; a++) {
+ o[obs[a]] = go_getObject($tt0, o[obs[a]]);
+ }
+
+ if (typeof o.scroll == 'number') {
+ if (o.scroll <= 50) o.scroll = { 'items' : o.scroll };
+ else o.scroll = { 'duration' : o.scroll };
+ } else {
+ if (typeof o.scroll == 'string') o.scroll = { 'easing' : o.scroll };
+ }
+
+ if (typeof o.items == 'number') o.items = { 'visible' : o.items };
+ else if ( o.items == 'variable') o.items = { 'visible' : o.items,
+ 'width' : o.items,
+ 'height' : o.items };
+
+ if (typeof o.items != 'object') o.items = {};
+ if (setOrig) opts_orig = $.extend(true, {}, $.fn.carouFredSel.defaults, o);
+
+ opts = $.extend(true, {}, $.fn.carouFredSel.defaults, o);
+
+ if (typeof opts.items.visibleConf != 'object') opts.items.visibleConf = {};
+
+ if (opts.items.start == 0 && typeof start == 'number') {
+ opts.items.start = start;
+ }
+
+ crsl.upDateOnWindowResize = (opts.responsive);
+ crsl.direction = (opts.direction == 'up' || opts.direction == 'left') ? 'next' : 'prev';
+
+ var dims = [
+ ['width' , 'innerWidth' , 'outerWidth' , 'height' , 'innerHeight' , 'outerHeight' , 'left', 'top' , 'marginRight' , 0, 1, 2, 3],
+ ['height' , 'innerHeight' , 'outerHeight' , 'width' , 'innerWidth' , 'outerWidth' , 'top' , 'left', 'marginBottom', 3, 2, 1, 0]
+ ];
+
+ var dn = dims[0].length,
+ dx = (opts.direction == 'right' || opts.direction == 'left') ? 0 : 1;
+
+ opts.d = {};
+ for (var d = 0; d < dn; d++) {
+ opts.d[dims[0][d]] = dims[dx][d];
+ }
+
+ var all_itm = $cfs.children();
+
+
+ // check visible items
+ switch (typeof opts.items.visible) {
+
+ // min and max visible items
+ case 'object':
+ opts.items.visibleConf.min = opts.items.visible.min;
+ opts.items.visibleConf.max = opts.items.visible.max;
+ opts.items.visible = false;
+ break;
+
+ case 'string':
+ // variable visible items
+ if (opts.items.visible == 'variable') {
+ opts.items.visibleConf.variable = true;
+
+ // adjust string visible items
+ } else {
+ opts.items.visibleConf.adjust = opts.items.visible;
+ }
+ opts.items.visible = false;
+ break;
+
+ // function visible items
+ case 'function':
+ opts.items.visibleConf.adjust = opts.items.visible;
+ opts.items.visible = false;
+ break;
+ }
+
+ // set items filter
+ if (typeof opts.items.filter == 'undefined') {
+ opts.items.filter = (all_itm.filter(':hidden').length > 0) ? ':visible' : '*';
+ }
+
+ // primary size set to auto -> measure largest size and set it
+ if (opts[opts.d['width']] == 'auto') {
+ opts[opts.d['width']] = ms_getTrueLargestSize(all_itm, opts, 'outerWidth');
+ }
+ // primary size percentage
+ if (ms_isPercentage(opts[opts.d['width']]) && !opts.responsive) {
+ opts[opts.d['width']] = ms_getPercentage(ms_getTrueInnerSize($wrp.parent(), opts, 'innerWidth'), opts[opts.d['width']]);
+ crsl.upDateOnWindowResize = true;
+ }
+
+ // secondary size set to auto -> measure largest size and set it
+ if (opts[opts.d['height']] == 'auto') {
+ opts[opts.d['height']] = ms_getTrueLargestSize(all_itm, opts, 'outerHeight');
+ }
+
+ // primary item-size not set
+ if (!opts.items[opts.d['width']]) {
+// responsive carousel -> set to largest
+if (opts.responsive) {
+ debug(true, 'Set a '+opts.d['width']+' for the items!');
+ opts.items[opts.d['width']] = ms_getTrueLargestSize(all_itm, opts, 'outerWidth');
+ // non-responsive -> measure it or set to "variable"
+} else {
+ opts.items[opts.d['width']] = (ms_hasVariableSizes(all_itm, opts, 'outerWidth'))
+ ? 'variable'
+ : all_itm[opts.d['outerWidth']](true);
+}
+ }
+
+ // secondary item-size not set -> measure it or set to "variable"
+ if (!opts.items[opts.d['height']]) {
+ opts.items[opts.d['height']] = (ms_hasVariableSizes(all_itm, opts, 'outerHeight'))
+ ? 'variable'
+ : all_itm[opts.d['outerHeight']](true);
+ }
+
+ // secondary size not set -> set to secondary item-size
+ if (!opts[opts.d['height']]) {
+ opts[opts.d['height']] = opts.items[opts.d['height']];
+ }
+
+ // visible-items not set
+ if (!opts.items.visible && !opts.responsive) {
+ // primary item-size variable -> set visible items variable
+ if (opts.items[opts.d['width']] == 'variable') {
+ opts.items.visibleConf.variable = true;
+ }
+ if (!opts.items.visibleConf.variable) {
+ // primary size is number -> calculate visible-items
+ if (typeof opts[opts.d['width']] == 'number') {
+ opts.items.visible = Math.floor(opts[opts.d['width']] / opts.items[opts.d['width']]);
+ } else {
+ // measure and calculate primary size and visible-items
+ var maxS = ms_getTrueInnerSize($wrp.parent(), opts, 'innerWidth');
+ opts.items.visible = Math.floor(maxS / opts.items[opts.d['width']]);
+ opts[opts.d['width']] = opts.items.visible * opts.items[opts.d['width']];
+ if (!opts.items.visibleConf.adjust) opts.align = false;
+ }
+ if (opts.items.visible == 'Infinity' || opts.items.visible < 1) {
+ debug(true, 'Not a valid number of visible items: Set to "variable".');
+ opts.items.visibleConf.variable = true;
+ }
+ }
+ }
+
+ // primary size not set -> calculate it or set to "variable"
+ if (!opts[opts.d['width']]) {
+ opts[opts.d['width']] = 'variable';
+ if (!opts.responsive && opts.items.filter == '*' && !opts.items.visibleConf.variable && opts.items[opts.d['width']] != 'variable') {
+ opts[opts.d['width']] = opts.items.visible * opts.items[opts.d['width']];
+ opts.align = false;
+ }
+ }
+
+ // variable primary item-sizes with variabe visible-items
+ if (opts.items.visibleConf.variable) {
+ opts.maxDimention = (opts[opts.d['width']] == 'variable')
+ ? ms_getTrueInnerSize($wrp.parent(), opts, 'innerWidth')
+ : opts[opts.d['width']];
+ if (opts.align === false) {
+ opts[opts.d['width']] = 'variable';
+ }
+ opts.items.visible = gn_getVisibleItemsNext(all_itm, opts, 0);
+
+ // set visible items by filter
+ } else if (opts.items.filter != '*') {
+ opts.items.visibleConf.org = opts.items.visible;
+ opts.items.visible = gn_getVisibleItemsNextFilter(all_itm, opts, 0);
+ }
+
+ // align not set -> set to center if primary size is number
+ if (typeof opts.align == 'undefined') {
+ opts.align = (opts[opts.d['width']] == 'variable')
+ ? false
+ : 'center';
+ }
+
+ opts.items.visible = cf_getItemsAdjust(opts.items.visible, opts, opts.items.visibleConf.adjust, $tt0);
+ opts.items.visibleConf.old = opts.items.visible;
+ opts.usePadding = false;
+
+
+if (opts.responsive) {
+
+ if (!opts.items.visibleConf.min) opts.items.visibleConf.min = opts.items.visible;
+ if (!opts.items.visibleConf.max) opts.items.visibleConf.max = opts.items.visible;
+
+ opts.align = false;
+ opts.padding = [0, 0, 0, 0];
+
+ var isVisible = $wrp.is(':visible');
+ if (isVisible) $wrp.hide();
+ var fullS = ms_getPercentage(ms_getTrueInnerSize($wrp.parent(), opts, 'innerWidth'), opts[opts.d['width']]);
+
+ if (typeof opts[opts.d['width']] == 'number' && fullS < opts[opts.d['width']]) {
+ fullS = opts[opts.d['width']];
+ }
+ if (isVisible) $wrp.show();
+
+ var visb = cf_getItemAdjustMinMax(Math.ceil(fullS / opts.items[opts.d['width']]), opts.items.visibleConf);
+ if (visb > all_itm.length) {
+ visb = all_itm.length;
+ }
+
+ var newS = Math.floor(fullS/visb),
+ seco = opts[opts.d['height']],
+ secp = ms_isPercentage(seco);
+
+ all_itm.each(function() {
+ var $t = $(this),
+ nw = newS - ms_getPaddingBorderMargin($t, opts, 'Width');
+
+ $t[opts.d['width']](nw);
+ if (secp) {
+ $t[opts.d['height']](ms_getPercentage(nw, seco));
+ }
+ });
+
+ opts.items.visible = visb;
+ opts.items[opts.d['width']] = newS;
+ opts[opts.d['width']] = visb * newS;
+
+} else {
+
+ opts.padding = cf_getPadding(opts.padding);
+
+ if (opts.align == 'top') opts.align = 'left';
+ if (opts.align == 'bottom') opts.align = 'right';
+
+
+ switch (opts.align) {
+ // align: center, left or right
+ case 'center':
+ case 'left':
+ case 'right':
+ if (opts[opts.d['width']] != 'variable') {
+ var p = cf_getAlignPadding(gi_getCurrentItems(all_itm, opts), opts);
+ opts.usePadding = true;
+ opts.padding[opts.d[1]] = p[1];
+ opts.padding[opts.d[3]] = p[0];
+ }
+ break;
+
+ // padding
+ default:
+ opts.align = false;
+ opts.usePadding = (
+ opts.padding[0] == 0 &&
+ opts.padding[1] == 0 &&
+ opts.padding[2] == 0 &&
+ opts.padding[3] == 0
+ ) ? false : true;
+ break;
+ }
+}
+
+ if (typeof opts.cookie == 'boolean' && opts.cookie) opts.cookie = 'caroufredsel_cookie_'+$cfs.attr('id');
+ if (typeof opts.items.minimum != 'number') opts.items.minimum = opts.items.visible;
+ if (typeof opts.scroll.duration != 'number') opts.scroll.duration = 500;
+ if (typeof opts.scroll.items == 'undefined') opts.scroll.items = (opts.items.visibleConf.variable || opts.items.filter != '*') ? 'visible' : opts.items.visible;
+
+ opts.auto = go_getNaviObject($tt0, opts.auto, 'auto');
+ opts.prev = go_getNaviObject($tt0, opts.prev);
+ opts.next = go_getNaviObject($tt0, opts.next);
+ opts.pagination = go_getNaviObject($tt0, opts.pagination, 'pagination');
+
+ opts.auto = $.extend(true, {}, opts.scroll, opts.auto);
+ opts.prev = $.extend(true, {}, opts.scroll, opts.prev);
+ opts.next = $.extend(true, {}, opts.scroll, opts.next);
+ opts.pagination = $.extend(true, {}, opts.scroll, opts.pagination);
+
+ if (typeof opts.pagination.keys != 'boolean') opts.pagination.keys = false;
+ if (typeof opts.pagination.anchorBuilder != 'function'
+ && opts.pagination.anchorBuilder !== false) opts.pagination.anchorBuilder = $.fn.carouFredSel.pageAnchorBuilder;
+ if (typeof opts.auto.play != 'boolean') opts.auto.play = true;
+ if (typeof opts.auto.delay != 'number') opts.auto.delay = 0;
+ if (typeof opts.auto.pauseOnEvent == 'undefined') opts.auto.pauseOnEvent = true;
+ if (typeof opts.auto.pauseOnResize != 'boolean') opts.auto.pauseOnResize = true;
+ if (typeof opts.auto.pauseDuration != 'number') opts.auto.pauseDuration = (opts.auto.duration < 10) ? 2500 : opts.auto.duration * 5;
+
+ if (opts.synchronise) {
+ opts.synchronise = cf_getSynchArr(opts.synchronise);
+ }
+ if (conf.debug) {
+ debug(conf, 'Carousel width: '+opts.width);
+ debug(conf, 'Carousel height: '+opts.height);
+ if (opts.maxDimention) debug(conf, 'Available '+opts.d['width']+': '+opts.maxDimention);
+ debug(conf, 'Item widths: '+opts.items.width);
+ debug(conf, 'Item heights: '+opts.items.height);
+ debug(conf, 'Number of items visible: '+opts.items.visible);
+ if (opts.auto.play) debug(conf, 'Number of items scrolled automatically: '+opts.auto.items);
+ if (opts.prev.button) debug(conf, 'Number of items scrolled backward: '+opts.prev.items);
+ if (opts.next.button) debug(conf, 'Number of items scrolled forward: '+opts.next.items);
+ }
+ }; // /init
+
+ $cfs._cfs_build = function() {
+ $cfs.data('cfs_isCarousel', true);
+
+ var orgCSS = {
+ 'textAlign' : $cfs.css('textAlign'),
+ 'float' : $cfs.css('float'),
+ 'position' : $cfs.css('position'),
+ 'top' : $cfs.css('top'),
+ 'right' : $cfs.css('right'),
+ 'bottom' : $cfs.css('bottom'),
+ 'left' : $cfs.css('left'),
+ 'width' : $cfs.css('width'),
+ 'height' : $cfs.css('height'),
+ 'marginTop' : $cfs.css('marginTop'),
+ 'marginRight' : $cfs.css('marginRight'),
+ 'marginBottom' : $cfs.css('marginBottom'),
+ 'marginLeft' : $cfs.css('marginLeft')
+ };
+
+ switch (orgCSS.position) {
+ case 'absolute':
+ var newPosition = 'absolute';
+ break;
+ case 'fixed':
+ var newPosition = 'fixed';
+ break;
+ default:
+ var newPosition = 'relative';
+ }
+
+ $wrp.css(orgCSS).css({
+ 'overflow' : 'hidden',
+ 'position' : newPosition
+ });
+
+ $cfs.data('cfs_origCss', orgCSS).css({
+ 'textAlign' : 'left',
+ 'float' : 'none',
+ 'position' : 'absolute',
+ 'top' : 0,
+ 'left' : 0,
+ 'marginTop' : 0,
+ 'marginRight' : 0,
+ 'marginBottom' : 0,
+ 'marginLeft' : 0
+ });
+
+ if (opts.usePadding) {
+ $cfs.children().each(function() {
+ var m = parseInt($(this).css(opts.d['marginRight']));
+ if (isNaN(m)) m = 0;
+ $(this).data('cfs_origCssMargin', m);
+ });
+ }
+
+ }; // /build
+
+ $cfs._cfs_bind_events = function() {
+ $cfs._cfs_unbind_events();
+
+ // stop event
+ $cfs.bind(cf_e('stop', conf), function(e, imm) {
+ e.stopPropagation();
+
+ // button
+ if (!crsl.isStopped) {
+ if (opts.auto.button) {
+ opts.auto.button.addClass(cf_c('stopped', conf));
+ }
+ }
+
+ // set stopped
+ crsl.isStopped = true;
+
+ if (opts.auto.play) {
+ opts.auto.play = false;
+ $cfs.trigger(cf_e('pause', conf), imm);
+ }
+ return true;
+ });
+
+ // finish event
+ $cfs.bind(cf_e('finish', conf), function(e) {
+ e.stopPropagation();
+ if (crsl.isScrolling) {
+ sc_stopScroll(scrl);
+ }
+ return true;
+ });
+
+ // pause event
+ $cfs.bind(cf_e('pause', conf), function(e, imm, res) {
+ e.stopPropagation();
+ tmrs = sc_clearTimers(tmrs);
+
+ // immediately pause
+ if (imm && crsl.isScrolling) {
+ scrl.isStopped = true;
+ var nst = getTime() - scrl.startTime;
+ scrl.duration -= nst;
+ if (scrl.pre) scrl.pre.duration -= nst;
+ if (scrl.post) scrl.post.duration -= nst;
+ sc_stopScroll(scrl, false);
+ }
+
+ // update remaining pause-time
+ if (!crsl.isPaused && !crsl.isScrolling) {
+ if (res) tmrs.timePassed += getTime() - tmrs.startTime;
+ }
+
+ // button
+ if (!crsl.isPaused) {
+ if (opts.auto.button) {
+ opts.auto.button.addClass(cf_c('paused', conf));
+ }
+ }
+
+ // set paused
+ crsl.isPaused = true;
+
+ // pause pause callback
+ if (opts.auto.onPausePause) {
+ var dur1 = opts.auto.pauseDuration - tmrs.timePassed,
+ perc = 100 - Math.ceil( dur1 * 100 / opts.auto.pauseDuration );
+ opts.auto.onPausePause.call($tt0, perc, dur1);
+ }
+ return true;
+ });
+
+ // play event
+ $cfs.bind(cf_e('play', conf), function(e, dir, del, res) {
+ e.stopPropagation();
+ tmrs = sc_clearTimers(tmrs);
+
+ // sort params
+ var v = [dir, del, res],
+ t = ['string', 'number', 'boolean'],
+ a = cf_sortParams(v, t);
+
+ var dir = a[0],
+ del = a[1],
+ res = a[2];
+
+ if (dir != 'prev' && dir != 'next') dir = crsl.direction;
+ if (typeof del != 'number') del = 0;
+ if (typeof res != 'boolean') res = false;
+
+ // stopped?
+ if (res) {
+ crsl.isStopped = false;
+ opts.auto.play = true;
+ }
+ if (!opts.auto.play) {
+ e.stopImmediatePropagation();
+ return debug(conf, 'Carousel stopped: Not scrolling.');
+ }
+
+ // button
+ if (crsl.isPaused) {
+ if (opts.auto.button) {
+ opts.auto.button.removeClass(cf_c('stopped', conf));
+ opts.auto.button.removeClass(cf_c('paused', conf));
+ }
+ }
+
+ // set playing
+ crsl.isPaused = false;
+ tmrs.startTime = getTime();
+
+ // timeout the scrolling
+ var dur1 = opts.auto.pauseDuration + del;
+ dur2 = dur1 - tmrs.timePassed;
+ perc = 100 - Math.ceil(dur2 * 100 / dur1);
+
+ tmrs.auto = setTimeout(function() {
+ if (opts.auto.onPauseEnd) {
+ opts.auto.onPauseEnd.call($tt0, perc, dur2);
+ }
+ if (crsl.isScrolling) {
+ $cfs.trigger(cf_e('play', conf), dir);
+ } else {
+ $cfs.trigger(cf_e(dir, conf), opts.auto);
+ }
+ }, dur2);
+
+ // pause start callback
+ if (opts.auto.onPauseStart) {
+ opts.auto.onPauseStart.call($tt0, perc, dur2);
+ }
+
+ return true;
+ });
+
+ // resume event
+ $cfs.bind(cf_e('resume', conf), function(e) {
+ e.stopPropagation();
+ if (scrl.isStopped) {
+ scrl.isStopped = false;
+ crsl.isPaused = false;
+ crsl.isScrolling = true;
+ scrl.startTime = getTime();
+ sc_startScroll(scrl);
+ } else {
+ $cfs.trigger(cf_e('play', conf));
+ }
+ return true;
+ });
+
+ // prev + next events
+ $cfs.bind(cf_e('prev', conf)+' '+cf_e('next', conf), function(e, obj, num, clb) {
+ e.stopPropagation();
+
+ // stopped or hidden carousel, don't scroll, don't queue
+ if (crsl.isStopped || $cfs.is(':hidden')) {
+ e.stopImmediatePropagation();
+ return debug(conf, 'Carousel stopped or hidden: Not scrolling.');
+ }
+
+ // not enough items
+ if (opts.items.minimum >= itms.total) {
+ e.stopImmediatePropagation();
+ return debug(conf, 'Not enough items ('+itms.total+', '+opts.items.minimum+' needed): Not scrolling.');
+ }
+
+ // get config
+ var v = [obj, num, clb],
+ t = ['object', 'number/string', 'function'],
+ a = cf_sortParams(v, t);
+
+ var obj = a[0],
+ num = a[1],
+ clb = a[2];
+
+ var eType = e.type.substr(conf.events.prefix.length);
+
+ if (typeof obj != 'object' || obj == null) obj = opts[eType];
+ if (typeof clb == 'function') obj.onAfter = clb;
+
+ if (typeof num != 'number') {
+ if (opts.items.filter != '*') {
+ num = 'visible';
+ } else {
+ var arr = [num, obj.items, opts[eType].items];
+ for (var a = 0, l = arr.length; a < l; a++) {
+ if (typeof arr[a] == 'number' || arr[a] == 'page' || arr[a] == 'visible') {
+ num = arr[a];
+ break;
+ }
+ }
+ }
+ switch(num) {
+ case 'page':
+ e.stopImmediatePropagation();
+ return $cfs.triggerHandler(eType+'Page', [obj, clb]);
+ break;
+
+ case 'visible':
+ if (!opts.items.visibleConf.variable && opts.items.filter == '*') {
+ num = opts.items.visible;
+ }
+ break;
+ }
+ }
+
+ // resume animation, add current to queue
+ if (scrl.isStopped) {
+ $cfs.trigger(cf_e('resume', conf));
+ $cfs.trigger(cf_e('queue', conf), [eType, [obj, num, clb]]);
+ e.stopImmediatePropagation();
+ return debug(conf, 'Carousel resumed scrolling.');
+ }
+
+ // queue if scrolling
+ if (obj.duration > 0) {
+ if (crsl.isScrolling) {
+ if (obj.queue) $cfs.trigger(cf_e('queue', conf), [eType, [obj, num, clb]]);
+ e.stopImmediatePropagation();
+ return debug(conf, 'Carousel currently scrolling.');
+ }
+ }
+
+ // test conditions callback
+ if (obj.conditions && !obj.conditions.call($tt0)) {
+ e.stopImmediatePropagation();
+ return debug(conf, 'Callback "conditions" returned false.');
+ }
+
+ tmrs.timePassed = 0;
+ $cfs.trigger('_cfs_slide_'+eType, [obj, num]);
+
+ // synchronise
+ if (opts.synchronise) {
+ var s = opts.synchronise,
+ c = [obj, num];
+ for (var j = 0, l = s.length; j < l; j++) {
+ var d = eType;
+ if (!s[j][1]) c[0] = s[j][0].triggerHandler('_cfs_configuration', eType);
+ if (!s[j][2]) d = (d == 'prev') ? 'next' : 'prev';
+ c[1] = num + s[j][3];
+ s[j][0].trigger('_cfs_slide_'+d, c);
+ }
+ }
+ return true;
+ });
+
+ // prev event, accessible from outside
+ $cfs.bind(cf_e('_cfs_slide_prev', conf, false), function(e, sO, nI) {
+ e.stopPropagation();
+ var a_itm = $cfs.children();
+
+ // non-circular at start, scroll to end
+ if (!opts.circular) {
+ if (itms.first == 0) {
+ if (opts.infinite) {
+ $cfs.trigger(cf_e('next', conf), itms.total-1);
+ }
+ return e.stopImmediatePropagation();
+ }
+ }
+
+ if (opts.usePadding) sz_resetMargin(a_itm, opts);
+
+ // find number of items to scroll
+ if (typeof nI != 'number') {
+ if (opts.items.visibleConf.variable) {
+ nI = gn_getVisibleItemsPrev(a_itm, opts, itms.total-1);
+ } else if (opts.items.filter != '*') {
+ var xI = (typeof sO.items == 'number') ? sO.items : gn_getVisibleOrg($cfs, opts);
+ nI = gn_getScrollItemsPrevFilter(a_itm, opts, itms.total-1, xI);
+ } else {
+ nI = opts.items.visible;
+ }
+ nI = cf_getAdjust(nI, opts, sO.items, $tt0);
+ }
+
+ // prevent non-circular from scrolling to far
+ if (!opts.circular) {
+ if (itms.total - nI < itms.first) {
+ nI = itms.total - itms.first;
+ }
+ }
+
+ // set new number of visible items
+ opts.items.visibleConf.old = opts.items.visible;
+ if (opts.items.visibleConf.variable) {
+ var vI = gn_getVisibleItemsNext(a_itm, opts, itms.total-nI);
+ if (opts.items.visible+nI <= vI && nI < itms.total) {
+ nI++;
+ vI = gn_getVisibleItemsNext(a_itm, opts, itms.total-nI);
+ }
+ opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
+ } else if (opts.items.filter != '*') {
+ var vI = gn_getVisibleItemsNextFilter(a_itm, opts, itms.total-nI);
+ opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
+ }
+
+ if (opts.usePadding) sz_resetMargin(a_itm, opts, true);
+
+ // scroll 0, don't scroll
+ if (nI == 0) {
+ e.stopImmediatePropagation();
+ return debug(conf, '0 items to scroll: Not scrolling.');
+ }
+ debug(conf, 'Scrolling '+nI+' items backward.');
+
+ // save new config
+ itms.first += nI;
+ while (itms.first >= itms.total) {
+ itms.first -= itms.total;
+ }
+
+ // non-circular callback
+ if (!opts.circular) {
+ if (itms.first == 0 && sO.onEnd) sO.onEnd.call($tt0);
+ if (!opts.infinite) nv_enableNavi(opts, itms.first, conf);
+ }
+
+ // rearrange items
+ $cfs.children().slice(itms.total-nI, itms.total).prependTo($cfs);
+ if (itms.total < opts.items.visible + nI) {
+ $cfs.children().slice(0, (opts.items.visible+nI)-itms.total).clone(true).appendTo($cfs);
+ }
+
+ // the needed items
+ var a_itm = $cfs.children(),
+ c_old = gi_getOldItemsPrev(a_itm, opts, nI),
+ c_new = gi_getNewItemsPrev(a_itm, opts),
+ l_cur = a_itm.eq(nI-1),
+ l_old = c_old.last(),
+ l_new = c_new.last();
+
+ if (opts.usePadding) sz_resetMargin(a_itm, opts);
+ if (opts.align) {
+ var p = cf_getAlignPadding(c_new, opts),
+ pL = p[0],
+ pR = p[1];
+ } else {
+ var pL = 0,
+ pR = 0;
+ }
+ var oL = (pL < 0) ? opts.padding[opts.d[3]] : 0;
+
+ // hide items for fx directscroll
+ if (sO.fx == 'directscroll' && opts.items.visible < nI) {
+ var hiddenitems = a_itm.slice(opts.items.visibleConf.old, nI),
+ orgW = opts.items[opts.d['width']];
+ hiddenitems.each(function() {
+ var hi = $(this);
+ hi.data('isHidden', hi.is(':hidden')).hide();
+ });
+ opts.items[opts.d['width']] = 'variable';
+ } else {
+ var hiddenitems = false;
+ }
+
+ // save new sizes
+ var i_siz = ms_getTotalSize(a_itm.slice(0, nI), opts, 'width'),
+ w_siz = cf_mapWrapperSizes(ms_getSizes(c_new, opts, true), opts, !opts.usePadding);
+
+ if (hiddenitems) opts.items[opts.d['width']] = orgW;
+
+ if (opts.usePadding) {
+ sz_resetMargin(a_itm, opts, true);
+ if (pR >= 0) {
+ sz_resetMargin(l_old, opts, opts.padding[opts.d[1]]);
+ }
+ sz_resetMargin(l_cur, opts, opts.padding[opts.d[3]]);
+ }
+ if (opts.align) {
+ opts.padding[opts.d[1]] = pR;
+ opts.padding[opts.d[3]] = pL;
+ }
+
+ // animation configuration
+ var a_cfs = {},
+ a_dur = sO.duration;
+
+ if (sO.fx == 'none') a_dur = 0;
+ else if (a_dur == 'auto') a_dur = opts.scroll.duration / opts.scroll.items * nI;
+ else if (a_dur <= 0) a_dur = 0;
+ else if (a_dur < 10) a_dur = i_siz / a_dur;
+
+ scrl = sc_setScroll(a_dur, sO.easing);
+
+ // animate wrapper
+ if (opts[opts.d['width']] == 'variable' || opts[opts.d['height']] == 'variable') {
+ scrl.anims.push([$wrp, w_siz]);
+ }
+
+ // animate items
+ if (opts.usePadding) {
+ var new_m = opts.padding[opts.d[3]];
+
+ if (l_new.not(l_cur).length) {
+ var a_cur = {};
+ a_cur[opts.d['marginRight']] = l_cur.data('cfs_origCssMargin');
+
+ if (pL < 0) l_cur.css(a_cur);
+ else scrl.anims.push([l_cur, a_cur]);
+ }
+
+ if (l_new.not(l_old).length) {
+ var a_old = {};
+ a_old[opts.d['marginRight']] = l_old.data('cfs_origCssMargin');
+ scrl.anims.push([l_old, a_old]);
+ }
+
+ if (pR >= 0) {
+ var a_new = {};
+ a_new[opts.d['marginRight']] = l_new.data('cfs_origCssMargin') + opts.padding[opts.d[1]];
+ scrl.anims.push([l_new, a_new]);
+ }
+ } else {
+ var new_m = 0;
+ }
+
+ // animate carousel
+ a_cfs[opts.d['left']] = new_m;
+
+ // onBefore callback
+ var args = [c_old, c_new, w_siz, a_dur];
+ if (sO.onBefore) sO.onBefore.apply($tt0, args);
+ clbk.onBefore = sc_callCallbacks(clbk.onBefore, $tt0, args);
+
+
+
+ // ALTERNATIVE EFFECTS
+
+ // extra animation arrays
+ switch(sO.fx) {
+ case 'fade':
+ case 'crossfade':
+ case 'cover':
+ case 'uncover':
+ scrl.pre = sc_setScroll(scrl.duration, scrl.easing);
+ scrl.post = sc_setScroll(scrl.duration, scrl.easing);
+ scrl.duration = 0;
+ break;
+ }
+
+ // create copy
+ switch(sO.fx) {
+ case 'crossfade':
+ case 'cover':
+ case 'uncover':
+ var $cf2 = $cfs.clone().appendTo($wrp);
+ break;
+ }
+ switch(sO.fx) {
+ case 'uncover':
+ $cf2.children().slice(0, nI).remove();
+ case 'crossfade':
+ case 'cover':
+ $cf2.children().slice(opts.items.visible).remove();
+ break;
+ }
+
+ // animations
+ switch(sO.fx) {
+ case 'fade':
+ scrl.pre.anims.push([$cfs, { 'opacity': 0 }]);
+ break;
+ case 'crossfade':
+ $cf2.css({ 'opacity': 0 });
+ scrl.pre.anims.push([$cfs, { 'width': '+=0' }, function() { $cf2.remove(); }]);
+ scrl.post.anims.push([$cf2, { 'opacity': 1 }]);
+ break;
+ case 'cover':
+ scrl = fx_cover(scrl, $cfs, $cf2, opts, true);
+ break;
+ case 'uncover':
+ scrl = fx_uncover(scrl, $cfs, $cf2, opts, true, nI);
+ break;
+ }
+
+ // /ALTERNATIVE EFFECTS
+
+
+ // complete callback
+ var a_complete = function() {
+
+ var overFill = opts.items.visible+nI-itms.total;
+ if (overFill > 0) {
+ $cfs.children().slice(itms.total).remove();
+ c_old = $cfs.children().slice(itms.total-(nI-overFill)).get().concat( $cfs.children().slice(0, overFill).get() );
+ }
+ if (hiddenitems) {
+ hiddenitems.each(function() {
+ var hi = $(this);
+ if (!hi.data('isHidden')) hi.show();
+ });
+ }
+ if (opts.usePadding) {
+ var l_itm = $cfs.children().eq(opts.items.visible+nI-1);
+ l_itm.css(opts.d['marginRight'], l_itm.data('cfs_origCssMargin'));
+ }
+
+ scrl.anims = [];
+ if (scrl.pre) scrl.pre = sc_setScroll(scrl.orgDuration, scrl.easing);
+
+ var fn = function() {
+ switch(sO.fx) {
+ case 'fade':
+ case 'crossfade':
+ $cfs.css('filter', '');
+ break;
+ }
+
+ scrl.post = sc_setScroll(0, null);
+ crsl.isScrolling = false;
+
+ var args = [c_old, c_new, w_siz];
+ if (sO.onAfter) sO.onAfter.apply($tt0, args);
+ clbk.onAfter = sc_callCallbacks(clbk.onAfter, $tt0, args);
+
+ if (queu.length) {
+ $cfs.trigger(cf_e(queu[0][0], conf), queu[0][1]);
+ queu.shift();
+ }
+ if (!crsl.isPaused) $cfs.trigger(cf_e('play', conf));
+ };
+ switch(sO.fx) {
+ case 'fade':
+ scrl.pre.anims.push([$cfs, { 'opacity': 1 }, fn]);
+ sc_startScroll(scrl.pre);
+ break;
+ case 'uncover':
+ scrl.pre.anims.push([$cfs, { 'width': '+=0' }, fn]);
+ sc_startScroll(scrl.pre);
+ break;
+ default:
+ fn();
+ break;
+ }
+ };
+
+ scrl.anims.push([$cfs, a_cfs, a_complete]);
+ crsl.isScrolling = true;
+ $cfs.css(opts.d['left'], -(i_siz-oL));
+ tmrs = sc_clearTimers(tmrs);
+ sc_startScroll(scrl);
+ cf_setCookie(opts.cookie, $cfs.triggerHandler(cf_e('currentPosition', conf)));
+
+ $cfs.trigger(cf_e('updatePageStatus', conf), [false, w_siz]);
+
+ return true;
+ });
+
+ // next event, accessible from outside
+ $cfs.bind(cf_e('_cfs_slide_next', conf, false), function(e, sO, nI) {
+ e.stopPropagation();
+ var a_itm = $cfs.children();
+
+ // non-circular at end, scroll to start
+ if (!opts.circular) {
+ if (itms.first == opts.items.visible) {
+ if (opts.infinite) {
+ $cfs.trigger(cf_e('prev', conf), itms.total-1);
+ }
+ return e.stopImmediatePropagation();
+ }
+ }
+
+ if (opts.usePadding) sz_resetMargin(a_itm, opts);
+
+ // find number of items to scroll
+ if (typeof nI != 'number') {
+ if (opts.items.filter != '*') {
+ var xI = (typeof sO.items == 'number') ? sO.items : gn_getVisibleOrg($cfs, opts);
+ nI = gn_getScrollItemsNextFilter(a_itm, opts, 0, xI);
+ } else {
+ nI = opts.items.visible;
+ }
+ nI = cf_getAdjust(nI, opts, sO.items, $tt0);
+ }
+
+ var lastItemNr = (itms.first == 0) ? itms.total : itms.first;
+
+ // prevent non-circular from scrolling to far
+ if (!opts.circular) {
+ if (opts.items.visibleConf.variable) {
+ var vI = gn_getVisibleItemsNext(a_itm, opts, nI),
+ xI = gn_getVisibleItemsPrev(a_itm, opts, lastItemNr-1);
+ } else {
+ var vI = opts.items.visible,
+ xI = opts.items.visible;
+ }
+
+ if (nI + vI > lastItemNr) {
+ nI = lastItemNr - xI;
+ }
+ }
+
+ // set new number of visible items
+ opts.items.visibleConf.old = opts.items.visible;
+ if (opts.items.visibleConf.variable) {
+ var vI = gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr);
+ while (opts.items.visible-nI >= vI && nI < itms.total) {
+ nI++;
+ vI = gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr);
+ }
+ opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
+ } else if (opts.items.filter != '*') {
+ var vI = gn_getVisibleItemsNextFilter(a_itm, opts, nI);
+ opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
+ }
+
+ if (opts.usePadding) sz_resetMargin(a_itm, opts, true);
+
+ // scroll 0, don't scroll
+ if (nI == 0) {
+ e.stopImmediatePropagation();
+ return debug(conf, '0 items to scroll: Not scrolling.');
+ }
+ debug(conf, 'Scrolling '+nI+' items forward.');
+
+ // save new config
+ itms.first -= nI;
+ while (itms.first < 0) {
+ itms.first += itms.total;
+ }
+
+ // non-circular callback
+ if (!opts.circular) {
+ if (itms.first == opts.items.visible && sO.onEnd) sO.onEnd.call($tt0);
+ if (!opts.infinite) nv_enableNavi(opts, itms.first, conf);
+ }
+
+ // rearrange items
+ if (itms.total < opts.items.visible+nI) {
+ $cfs.children().slice(0, (opts.items.visible+nI)-itms.total).clone(true).appendTo($cfs);
+ }
+
+ // the needed items
+ var a_itm = $cfs.children(),
+ c_old = gi_getOldItemsNext(a_itm, opts),
+ c_new = gi_getNewItemsNext(a_itm, opts, nI),
+ l_cur = a_itm.eq(nI-1),
+ l_old = c_old.last(),
+ l_new = c_new.last();
+
+ if (opts.usePadding) sz_resetMargin(a_itm, opts);
+ if (opts.align) {
+ var p = cf_getAlignPadding(c_new, opts),
+ pL = p[0],
+ pR = p[1];
+ } else {
+ var pL = 0,
+ pR = 0;
+ }
+
+ // hide items for fx directscroll
+ if (sO.fx == 'directscroll' && opts.items.visibleConf.old < nI) {
+ var hiddenitems = a_itm.slice(opts.items.visibleConf.old, nI),
+ orgW = opts.items[opts.d['width']];
+ hiddenitems.each(function() {
+ var hi = $(this);
+ hi.data('isHidden', hi.is(':hidden')).hide();
+ });
+ opts.items[opts.d['width']] = 'variable';
+ } else {
+ var hiddenitems = false;
+ }
+
+ // save new sizes
+ var i_siz = ms_getTotalSize(a_itm.slice(0, nI), opts, 'width'),
+ w_siz = cf_mapWrapperSizes(ms_getSizes(c_new, opts, true), opts, !opts.usePadding);
+
+ if (hiddenitems) opts.items[opts.d['width']] = orgW;
+
+ if (opts.align) {
+ if (opts.padding[opts.d[1]] < 0) {
+ opts.padding[opts.d[1]] = 0;
+ }
+ }
+ if (opts.usePadding) {
+ sz_resetMargin(a_itm, opts, true);
+ sz_resetMargin(l_old, opts, opts.padding[opts.d[1]]);
+ }
+ if (opts.align) {
+ opts.padding[opts.d[1]] = pR;
+ opts.padding[opts.d[3]] = pL;
+ }
+
+ // animation configuration
+ var a_cfs = {},
+ a_dur = sO.duration;
+
+ if (sO.fx == 'none') a_dur = 0;
+ else if (a_dur == 'auto') a_dur = opts.scroll.duration / opts.scroll.items * nI;
+ else if (a_dur <= 0) a_dur = 0;
+ else if (a_dur < 10) a_dur = i_siz / a_dur;
+
+ scrl = sc_setScroll(a_dur, sO.easing);
+
+ // animate wrapper
+ if (opts[opts.d['width']] == 'variable' || opts[opts.d['height']] == 'variable') {
+ scrl.anims.push([$wrp, w_siz]);
+ }
+
+ // animate items
+ if (opts.usePadding) {
+ var l_new_m = l_new.data('cfs_origCssMargin');
+ if (pR >= 0) {
+ l_new_m += opts.padding[opts.d[1]];
+ }
+ l_new.css(opts.d['marginRight'], l_new_m);
+
+ if (l_cur.not(l_old).length) {
+ var a_old = {};
+ a_old[opts.d['marginRight']] = l_old.data('cfs_origCssMargin');
+ scrl.anims.push([l_old, a_old]);
+ }
+
+ var c_new_m = l_cur.data('cfs_origCssMargin');
+ if (pL >= 0) {
+ c_new_m += opts.padding[opts.d[3]];
+ }
+ var a_cur = {};
+ a_cur[opts.d['marginRight']] = c_new_m;
+ scrl.anims.push([l_cur, a_cur]);
+
+ }
+
+ // animate carousel
+ a_cfs[opts.d['left']] = -i_siz;
+ if (pL < 0) {
+ a_cfs[opts.d['left']] += pL;
+ }
+
+ // onBefore callback
+ var args = [c_old, c_new, w_siz, a_dur];
+ if (sO.onBefore) sO.onBefore.apply($tt0, args);
+ clbk.onBefore = sc_callCallbacks(clbk.onBefore, $tt0, args);
+
+
+
+ // ALTERNATIVE EFFECTS
+
+ // extra animation arrays
+ switch(sO.fx) {
+ case 'fade':
+ case 'crossfade':
+ case 'cover':
+ case 'uncover':
+ scrl.pre = sc_setScroll(scrl.duration, scrl.easing);
+ scrl.post = sc_setScroll(scrl.duration, scrl.easing);
+ scrl.duration = 0;
+ break;
+ }
+
+ // create copy
+ switch(sO.fx) {
+ case 'crossfade':
+ case 'cover':
+ case 'uncover':
+ var $cf2 = $cfs.clone().appendTo($wrp);
+ break;
+ }
+ switch(sO.fx) {
+ case 'uncover':
+ $cf2.children().slice(opts.items.visibleConf.old).remove();
+ break;
+ case 'crossfade':
+ case 'cover':
+ $cf2.children().slice(0, nI).remove();
+ $cf2.children().slice(opts.items.visible).remove();
+ break;
+ }
+
+ // animations
+ switch(sO.fx) {
+ case 'fade':
+ scrl.pre.anims.push([$cfs, { 'opacity': 0 }]);
+ break;
+ case 'crossfade':
+ $cf2.css({ 'opacity': 0 });
+ scrl.pre.anims.push([$cfs, { 'width': '+=0' }, function() { $cf2.remove(); }]);
+ scrl.post.anims.push([$cf2, { 'opacity': 1 }]);
+ break;
+ case 'cover':
+ scrl = fx_cover(scrl, $cfs, $cf2, opts, false);
+ break;
+ case 'uncover':
+ scrl = fx_uncover(scrl, $cfs, $cf2, opts, false, nI);
+ break;
+ }
+
+ // /ALTERNATIVE EFFECTS
+
+
+ // complete callback
+ var a_complete = function() {
+
+ var overFill = opts.items.visible+nI-itms.total,
+ new_m = (opts.usePadding) ? opts.padding[opts.d[3]] : 0;
+ $cfs.css(opts.d['left'], new_m);
+ if (overFill > 0) {
+ $cfs.children().slice(itms.total).remove();
+ }
+ var l_itm = $cfs.children().slice(0, nI).appendTo($cfs).last();
+ if (overFill > 0) {
+ c_new = gi_getCurrentItems(a_itm, opts);
+ }
+ if (hiddenitems) {
+ hiddenitems.each(function() {
+ var hi = $(this);
+ if (!hi.data('isHidden')) hi.show();
+ });
+ }
+ if (opts.usePadding) {
+ if (itms.total < opts.items.visible+nI) {
+ var l_cur = $cfs.children().eq(opts.items.visible-1);
+ l_cur.css(opts.d['marginRight'], l_cur.data('cfs_origCssMargin') + opts.padding[opts.d[3]]);
+ }
+ l_itm.css(opts.d['marginRight'], l_itm.data('cfs_origCssMargin'));
+ }
+
+ scrl.anims = [];
+ if (scrl.pre) scrl.pre = sc_setScroll(scrl.orgDuration, scrl.easing);
+
+ var fn = function() {
+ switch(sO.fx) {
+ case 'fade':
+ case 'crossfade':
+ $cfs.css('filter', '');
+ break;
+ }
+
+ scrl.post = sc_setScroll(0, null);
+ crsl.isScrolling = false;
+
+ var args = [c_old, c_new, w_siz];
+ if (sO.onAfter) sO.onAfter.apply($tt0, args);
+ clbk.onAfter = sc_callCallbacks(clbk.onAfter, $tt0, args);
+
+ if (queu.length) {
+ $cfs.trigger(cf_e(queu[0][0], conf), queu[0][1]);
+ queu.shift();
+ }
+ if (!crsl.isPaused) $cfs.trigger(cf_e('play', conf));
+ };
+ switch(sO.fx) {
+ case 'fade':
+ scrl.pre.anims.push([$cfs, { 'opacity': 1 }, fn]);
+ sc_startScroll(scrl.pre);
+ break;
+ case 'uncover':
+ scrl.pre.anims.push([$cfs, { 'width': '+=0' }, fn]);
+ sc_startScroll(scrl.pre);
+ break;
+ default:
+ fn();
+ break;
+ }
+ };
+
+ scrl.anims.push([$cfs, a_cfs, a_complete]);
+ crsl.isScrolling = true;
+ tmrs = sc_clearTimers(tmrs);
+ sc_startScroll(scrl);
+ cf_setCookie(opts.cookie, $cfs.triggerHandler(cf_e('currentPosition', conf)));
+
+ $cfs.trigger(cf_e('updatePageStatus', conf), [false, w_siz]);
+
+ return true;
+ });
+
+ // slideTo event
+ $cfs.bind(cf_e('slideTo', conf), function(e, num, dev, org, obj, dir, clb) {
+ e.stopPropagation();
+
+ var v = [num, dev, org, obj, dir, clb],
+ t = ['string/number/object', 'number', 'boolean', 'object', 'string', 'function'],
+ a = cf_sortParams(v, t);
+
+ var obj = a[3],
+ dir = a[4],
+ clb = a[5];
+
+ num = gn_getItemIndex(a[0], a[1], a[2], itms, $cfs);
+
+ if (num == 0) return;
+ if (typeof obj != 'object') obj = false;
+
+ if (crsl.isScrolling) {
+ if (typeof obj != 'object' || obj.duration > 0) return false;
+ }
+
+ if (dir != 'prev' && dir != 'next') {
+ if (opts.circular) {
+ if (num <= itms.total / 2) dir = 'next';
+ else dir = 'prev';
+ } else {
+ if (itms.first == 0 ||
+ itms.first > num) dir = 'next';
+ else dir = 'prev';
+ }
+ }
+
+ if (dir == 'prev') num = itms.total-num;
+ $cfs.trigger(cf_e(dir, conf), [obj, num, clb]);
+
+ return true;
+ });
+
+ // prevPage event
+ $cfs.bind(cf_e('prevPage', conf), function(e, obj, clb) {
+ e.stopPropagation();
+ var cur = $cfs.triggerHandler(cf_e('currentPage', conf));
+ return $cfs.triggerHandler(cf_e('slideToPage', conf), [cur-1, obj, 'prev', clb]);
+ });
+
+ // nextPage event
+ $cfs.bind(cf_e('nextPage', conf), function(e, obj, clb) {
+ e.stopPropagation();
+ var cur = $cfs.triggerHandler(cf_e('currentPage', conf));
+ return $cfs.triggerHandler(cf_e('slideToPage', conf), [cur+1, obj, 'next', clb]);
+ });
+
+ // slideToPage event
+ $cfs.bind(cf_e('slideToPage', conf), function(e, pag, obj, dir, clb) {
+ e.stopPropagation();
+ if (typeof pag != 'number') pag = $cfs.triggerHandler(cf_e('currentPage', conf));
+ var ipp = opts.pagination.items || opts.items.visible,
+ max = Math.floor(itms.total / ipp)-1;
+ if (pag < 0) pag = max;
+ if (pag > max) pag = 0;
+ return $cfs.triggerHandler(cf_e('slideTo', conf), [pag*ipp, 0, true, obj, dir, clb]);
+ });
+
+ // jumpToStart event
+ $cfs.bind(cf_e('jumpToStart', conf), function(e, s) {
+ e.stopPropagation();
+ if (s) s = gn_getItemIndex(s, 0, true, itms, $cfs);
+ else s = 0;
+
+ s += itms.first;
+ if (s != 0) {
+ while (s > itms.total) s -= itms.total;
+ $cfs.prepend($cfs.children().slice(s, itms.total));
+ }
+ return true;
+ });
+
+ // synchronise event
+ $cfs.bind(cf_e('synchronise', conf), function(e, s) {
+ e.stopPropagation();
+ if (s) s = cf_getSynchArr(s);
+ else if (opts.synchronise) s = opts.synchronise;
+ else return debug(conf, 'No carousel to synchronise.');
+
+ var n = $cfs.triggerHandler(cf_e('currentPosition', conf)),
+ x = true;
+ for (var j = 0, l = s.length; j < l; j++) {
+ if (!s[j][0].triggerHandler(cf_e('slideTo', conf), [n, s[j][3], true])) {
+ x = false;
+ }
+ }
+ return x;
+ });
+
+ // queue event
+ $cfs.bind(cf_e('queue', conf), function(e, dir, opt) {
+ e.stopPropagation();
+ if (typeof dir == 'function') {
+ dir.call($tt0, queu);
+ } else if (is_array(dir)) {
+ queu = dir;
+ } else if (typeof dir != 'undefined') {
+ queu.push([dir, opt]);
+ }
+ return queu;
+ });
+
+ // insertItem event
+ $cfs.bind(cf_e('insertItem', conf), function(e, itm, num, org, dev) {
+ e.stopPropagation();
+
+ var v = [itm, num, org, dev],
+ t = ['string/object', 'string/number/object', 'boolean', 'number'],
+ a = cf_sortParams(v, t);
+
+ var itm = a[0],
+ num = a[1],
+ org = a[2],
+ dev = a[3];
+
+ if (typeof itm == 'object' &&
+ typeof itm.jquery == 'undefined') itm = $(itm);
+ if (typeof itm == 'string') itm = $(itm);
+ if (typeof itm != 'object' ||
+ typeof itm.jquery == 'undefined' ||
+ itm.length == 0) return debug(conf, 'Not a valid object.');
+
+ if (typeof num == 'undefined') num = 'end';
+
+ if (opts.usePadding) {
+ itm.each(function() {
+ var m = parseInt($(this).css(opts.d['marginRight']));
+ if (isNaN(m)) m = 0;
+ $(this).data('cfs_origCssMargin', m);
+ });
+ }
+
+ var orgNum = num,
+ before = 'before';
+
+ if (num == 'end') {
+ if (org) {
+ if (itms.first == 0) {
+ num = itms.total-1;
+ before = 'after';
+ } else {
+ num = itms.first;
+ itms.first += itm.length
+ }
+ if (num < 0) num = 0;
+ } else {
+ num = itms.total-1;
+ before = 'after';
+ }
+ } else {
+ num = gn_getItemIndex(num, dev, org, itms, $cfs);
+ }
+ if (orgNum != 'end' && !org) {
+ if (num < itms.first) itms.first += itm.length;
+ }
+ if (itms.first >= itms.total) itms.first -= itms.total;
+
+ var $cit = $cfs.children().eq(num);
+ if ($cit.length) {
+ $cit[before](itm);
+ } else {
+ $cfs.append(itm);
+ }
+
+ itms.total = $cfs.children().length;
+
+ var sz = $cfs.triggerHandler('updateSizes');
+ nv_showNavi(opts, itms.total, conf);
+ nv_enableNavi(opts, itms.first, conf);
+ $cfs.trigger(cf_e('linkAnchors', conf));
+ $cfs.trigger(cf_e('updatePageStatus', conf), [true, sz]);
+
+ return true;
+ });
+
+ // removeItem event
+ $cfs.bind(cf_e('removeItem', conf), function(e, num, org, dev) {
+ e.stopPropagation();
+
+ var v = [num, org, dev],
+ t = ['string/number/object', 'boolean', 'number'],
+ a = cf_sortParams(v, t);
+
+ var num = a[0],
+ org = a[1],
+ dev = a[2];
+
+ if (typeof num == 'undefined' || num == 'end') {
+ $cfs.children().last().remove();
+ } else {
+ num = gn_getItemIndex(num, dev, org, itms, $cfs);
+ var $cit = $cfs.children().eq(num);
+ if ($cit.length){
+ if (num < itms.first) itms.first -= $cit.length;
+ $cit.remove();
+ }
+ }
+ itms.total = $cfs.children().length;
+
+ var sz = $cfs.triggerHandler('updateSizes');
+ nv_showNavi(opts, itms.total, conf);
+ nv_enableNavi(opts, itms.first, conf);
+ $cfs.trigger(cf_e('updatePageStatus', conf), [true, sz]);
+
+ return true;
+ });
+
+ // onBefore and onAfter event
+ $cfs.bind(cf_e('onBefore', conf)+' '+cf_e('onAfter', conf), function(e, fn) {
+ e.stopPropagation();
+ var eType = e.type.substr(conf.events.prefix.length);
+ if (is_array(fn)) clbk[eType] = fn;
+ if (typeof fn == 'function') clbk[eType].push(fn);
+ return clbk[eType];
+ });
+
+ // currentPosition event, accessible from outside
+ $cfs.bind(cf_e('_cfs_currentPosition', conf, false), function(e, fn) {
+ e.stopPropagation();
+ return $cfs.triggerHandler(cf_e('currentPosition', conf), fn);
+ });
+ $cfs.bind(cf_e('currentPosition', conf), function(e, fn) {
+ e.stopPropagation();
+ if (itms.first == 0) var val = 0;
+ else var val = itms.total - itms.first;
+ if (typeof fn == 'function') fn.call($tt0, val);
+ return val;
+ });
+
+ // currentPage event
+ $cfs.bind(cf_e('currentPage', conf), function(e, fn) {
+ e.stopPropagation();
+ var ipp = opts.pagination.items || opts.items.visible;
+ var max = Math.ceil(itms.total/ipp-1);
+ if (itms.first == 0) var nr = 0;
+ else if (itms.first < itms.total % ipp) var nr = 0;
+ else if (itms.first == ipp && !opts.circular) var nr = max;
+ else var nr = Math.round((itms.total-itms.first)/ipp);
+ if (nr < 0) nr = 0;
+ if (nr > max) nr = max;
+ if (typeof fn == 'function') fn.call($tt0, nr);
+ return nr;
+ });
+
+ // currentVisible event
+ $cfs.bind(cf_e('currentVisible', conf), function(e, fn) {
+ e.stopPropagation();
+ $i = gi_getCurrentItems($cfs.children(), opts);
+ if (typeof fn == 'function') fn.call($tt0, $i);
+ return $i;
+ });
+
+ // slice event
+ $cfs.bind(cf_e('slice', conf), function(e, f, l, fn) {
+ e.stopPropagation();
+
+ var v = [f, l, fn],
+ t = ['number', 'number', 'function'],
+ a = cf_sortParams(v, t);
+
+ f = (typeof a[0] == 'number') ? a[0] : 0,
+ l = (typeof a[1] == 'number') ? a[1] : itms.total,
+ fn = a[2];
+
+ f += itms.first;
+ l += itms.first;
+
+ while (f > itms.total) { f -= itms.total }
+ while (l > itms.total) { l -= itms.total }
+ while (f < 0) { f += itms.total }
+ while (l < 0) { l += itms.total }
+
+ var $iA = $cfs.children();
+
+ if (l > f) {
+ var $i = $iA.slice(f, l);
+ } else {
+ var $i = $iA.slice(f, itms.total).get().concat( $iA.slice(0, l).get() );
+ }
+
+ if (typeof fn == 'function') fn.call($tt0, $i);
+ return $i;
+ });
+
+ // isPaused, isStopped and isScrolling events
+ $cfs.bind(cf_e('isPaused', conf)+' '+cf_e('isStopped', conf)+' '+cf_e('isScrolling', conf), function(e, fn) {
+ e.stopPropagation();
+ var eType = e.type.substr(conf.events.prefix.length);
+ if (typeof fn == 'function') fn.call($tt0, crsl[eType]);
+ return crsl[eType];
+ });
+
+ // configuration event, accessible from outside
+ $cfs.bind(cf_e('_cfs_configuration', conf, false), function(e, a, b, c) {
+ e.stopPropagation();
+ return $cfs.triggerHandler(cf_e('configuration', conf), [a, b, c]);
+ });
+ $cfs.bind(cf_e('configuration', conf), function(e, a, b, c) {
+ e.stopPropagation();
+ var reInit = false;
+
+ // return entire configuration-object
+ if (typeof a == 'function') {
+ a.call($tt0, opts);
+
+ // set multiple options via object
+ } else if (typeof a == 'object') {
+ opts_orig = $.extend(true, {}, opts_orig, a);
+ if (b !== false) reInit = true;
+ else opts = $.extend(true, {}, opts, a);
+
+ } else if (typeof a != 'undefined') {
+
+ // callback function for specific option
+ if (typeof b == 'function') {
+ var val = eval('opts.'+a);
+ if (typeof val == 'undefined') val = '';
+ b.call($tt0, val);
+
+ // set individual option
+ } else if (typeof b != 'undefined') {
+ if (typeof c !== 'boolean') c = true;
+ eval('opts_orig.'+a+' = b');
+ if (c !== false) reInit = true;
+ else eval('opts.'+a+' = b');
+
+ // return value for specific option
+ } else {
+ return eval('opts.'+a);
+ }
+ }
+ if (reInit) {
+ sz_resetMargin($cfs.children(), opts);
+ $cfs._cfs_init(opts_orig);
+ $cfs._cfs_bind_buttons();
+ var siz = sz_setSizes($cfs, opts, false);
+ $cfs.trigger(cf_e('updatePageStatus', conf), [true, siz]);
+ }
+ return opts;
+ });
+
+ // linkAnchors event
+ $cfs.bind(cf_e('linkAnchors', conf), function(e, $con, sel) {
+ e.stopPropagation();
+ if (typeof $con == 'undefined' || $con.length == 0) $con = $('body');
+ else if (typeof $con == 'string') $con = $($con);
+ if (typeof $con != 'object') return debug(conf, 'Not a valid object.');
+ if (typeof sel != 'string' || sel.length == 0) sel = 'a.caroufredsel';
+ $con.find(sel).each(function() {
+ var h = this.hash || '';
+ if (h.length > 0 && $cfs.children().index($(h)) != -1) {
+ $(this).unbind('click').click(function(e) {
+ e.preventDefault();
+ $cfs.trigger(cf_e('slideTo', conf), h);
+ });
+ }
+ });
+ return true;
+ });
+
+ // updatePageStatus event
+ $cfs.bind(cf_e('updatePageStatus', conf), function(e, build, sizes) {
+ e.stopPropagation();
+ if (!opts.pagination.container) return;
+
+ if (build) {
+ var ipp = opts.pagination.items || opts.items.visible,
+ l = Math.ceil(itms.total/ipp);
+
+ if (opts.pagination.anchorBuilder) {
+ opts.pagination.container.children().remove();
+ opts.pagination.container.each(function() {
+ for (var a = 0; a < l; a++) {
+ var i = $cfs.children().eq( gn_getItemIndex(a*ipp, 0, true, itms, $cfs) );
+ $(this).append(opts.pagination.anchorBuilder(a+1, i));
+ }
+ });
+ }
+ opts.pagination.container.each(function() {
+ $(this).children().unbind(opts.pagination.event).each(function(a) {
+ $(this).bind(opts.pagination.event, function(e) {
+ e.preventDefault();
+ $cfs.trigger(cf_e('slideTo', conf), [a*ipp, 0, true, opts.pagination]);
+ });
+ });
+ });
+ }
+ opts.pagination.container.each(function() {
+ $(this).children().removeClass(cf_c('selected', conf)).eq($cfs.triggerHandler(cf_e('currentPage', conf))).addClass(cf_c('selected', conf));
+ });
+ return true;
+ });
+
+ // updateSizes event
+ $cfs.bind(cf_e('updateSizes', conf), function(e) {
+ var a_itm = $cfs.children(),
+ vI = opts.items.visible;
+
+ if (opts.items.visibleConf.variable) vI = gn_getVisibleItemsNext(a_itm, opts, 0);
+ else if (opts.items.filter != '*') vI = gn_getVisibleItemsNextFilter(a_itm, opts, 0);
+
+ if (!opts.circular && itms.first != 0 && vI > itms.first) {
+ if (opts.items.visibleConf.variable) {
+ var nI = gn_getVisibleItemsPrev(a_itm, opts, itms.first) - itms.first;
+ } else if (opts.items.filter != '*') {
+ var nI = gn_getVisibleItemsPrevFilter(a_itm, opts, itms.first) - itms.first;
+ } else {
+ nI = opts.items.visible - itms.first;
+ }
+ debug(conf, 'Preventing non-circular: sliding '+nI+' items backward.');
+ $cfs.trigger('prev', nI);
+ }
+ opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
+ return sz_setSizes($cfs, opts);
+ });
+
+ // destroy event, accessible from outside
+ $cfs.bind(cf_e('_cfs_destroy', conf, false), function(e, orgOrder) {
+ e.stopPropagation();
+ $cfs.trigger(cf_e('destroy', conf), orgOrder);
+ return true;
+ });
+ $cfs.bind(cf_e('destroy', conf), function(e, orgOrder) {
+ e.stopPropagation();
+ tmrs = sc_clearTimers(tmrs);
+
+ $cfs.data('cfs_isCarousel', false);
+ $cfs.trigger(cf_e('finish', conf));
+ if (orgOrder) {
+ $cfs.trigger(cf_e('jumpToStart', conf));
+ }
+ if (opts.usePadding) {
+ sz_resetMargin($cfs.children(), opts);
+ }
+
+ $cfs.css($cfs.data('cfs_origCss'));
+ $cfs._cfs_unbind_events();
+ $cfs._cfs_unbind_buttons();
+ $wrp.replaceWith($cfs);
+
+ return true;
+ });
+ }; // /bind_events
+
+ $cfs._cfs_unbind_events = function() {
+ $cfs.unbind(cf_e('', conf));
+ $cfs.unbind(cf_e('', conf, false));
+ }; // /unbind_events
+
+ $cfs._cfs_bind_buttons = function() {
+ $cfs._cfs_unbind_buttons();
+ nv_showNavi(opts, itms.total, conf);
+ nv_enableNavi(opts, itms.first, conf);
+
+ if (opts.auto.pauseOnHover) {
+ var pC = bt_pauseOnHoverConfig(opts.auto.pauseOnHover);
+ $wrp.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
+ .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
+ }
+
+ if (opts.auto.button) {
+ opts.auto.button.bind(cf_e(opts.auto.event, conf, false), function(e) {
+ e.preventDefault();
+ var ev = false,
+ pC = null;
+
+ if (crsl.isPaused) {
+ ev = 'play';
+ } else if (opts.auto.pauseOnEvent) {
+ ev = 'pause';
+ pC = bt_pauseOnHoverConfig(opts.auto.pauseOnEvent);
+ }
+ if (ev) {
+ $cfs.trigger(cf_e(ev, conf), pC);
+ }
+ });
+ }
+ if (opts.prev.button) {
+ opts.prev.button.bind(cf_e(opts.prev.event, conf, false), function(e) {
+ e.preventDefault();
+ $cfs.trigger(cf_e('prev', conf));
+ });
+ if (opts.prev.pauseOnHover) {
+ var pC = bt_pauseOnHoverConfig(opts.prev.pauseOnHover);
+ opts.prev.button.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
+ .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
+ }
+ }
+
+ if (opts.next.button) {
+ opts.next.button.bind(cf_e(opts.next.event, conf, false), function(e) {
+ e.preventDefault();
+ $cfs.trigger(cf_e('next', conf));
+ });
+ if (opts.next.pauseOnHover) {
+ var pC = bt_pauseOnHoverConfig(opts.next.pauseOnHover);
+ opts.next.button.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
+ .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
+ }
+ }
+ if ($.fn.mousewheel) {
+ if (opts.prev.mousewheel) {
+ if (!crsl.mousewheelPrev) {
+ crsl.mousewheelPrev = true;
+ $wrp.mousewheel(function(e, delta) {
+ if (delta > 0) {
+ e.preventDefault();
+ var num = bt_mousesheelNumber(opts.prev.mousewheel);
+ $cfs.trigger(cf_e('prev', conf), num);
+ }
+ });
+ }
+ }
+ if (opts.next.mousewheel) {
+ if (!crsl.mousewheelNext) {
+ crsl.mousewheelNext = true;
+ $wrp.mousewheel(function(e, delta) {
+ if (delta < 0) {
+ e.preventDefault();
+ var num = bt_mousesheelNumber(opts.next.mousewheel);
+ $cfs.trigger(cf_e('next', conf), num);
+ }
+ });
+ }
+ }
+ }
+ if ($.fn.touchwipe) {
+ var wP = (opts.prev.wipe) ? function() { $cfs.trigger(cf_e('prev', conf)) } : null,
+ wN = (opts.next.wipe) ? function() { $cfs.trigger(cf_e('next', conf)) } : null;
+
+ if (wN || wN) {
+ if (!crsl.touchwipe) {
+ crsl.touchwipe = true;
+ var twOps = {
+ 'min_move_x': 30,
+ 'min_move_y': 30,
+ 'preventDefaultEvents': true
+ };
+ switch (opts.direction) {
+ case 'up':
+ case 'down':
+ twOps.wipeUp = wN;
+ twOps.wipeDown = wP;
+ break;
+ default:
+ twOps.wipeLeft = wN;
+ twOps.wipeRight = wP;
+ }
+ $wrp.touchwipe(twOps);
+ }
+ }
+ }
+ if (opts.pagination.container) {
+ if (opts.pagination.pauseOnHover) {
+ var pC = bt_pauseOnHoverConfig(opts.pagination.pauseOnHover);
+ opts.pagination.container.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
+ .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
+ }
+ }
+ if (opts.prev.key || opts.next.key) {
+ $(document).bind(cf_e('keyup', conf, false, true, true), function(e) {
+ var k = e.keyCode;
+ if (k == opts.next.key) {
+ e.preventDefault();
+ $cfs.trigger(cf_e('next', conf));
+ }
+ if (k == opts.prev.key) {
+ e.preventDefault();
+ $cfs.trigger(cf_e('prev', conf));
+ }
+ });
+ }
+ if (opts.pagination.keys) {
+ $(document).bind(cf_e('keyup', conf, false, true, true), function(e) {
+ var k = e.keyCode;
+ if (k >= 49 && k < 58) {
+ k = (k-49) * opts.items.visible;
+ if (k <= itms.total) {
+ e.preventDefault();
+ $cfs.trigger(cf_e('slideTo', conf), [k, 0, true, opts.pagination]);
+ }
+ }
+ });
+ }
+ if (opts.auto.play) {
+ $cfs.trigger(cf_e('play', conf), opts.auto.delay);
+ }
+
+if (crsl.upDateOnWindowResize) {
+ $(window).bind(cf_e('resize', conf, false, true, true), function(e) {
+ $cfs.trigger(cf_e('finish', conf));
+ if (opts.auto.pauseOnResize && !crsl.isPaused) {
+ $cfs.trigger(cf_e('play', conf));
+ }
+ sz_resetMargin($cfs.children(), opts);
+ $cfs._cfs_init(opts_orig);
+ var siz = sz_setSizes($cfs, opts, false);
+ $cfs.trigger(cf_e('updatePageStatus', conf), [true, siz]);
+ });
+}
+
+ }; // /bind_buttons
+
+ $cfs._cfs_unbind_buttons = function() {
+ var ns1 = cf_e('', conf),
+ ns2 = cf_e('', conf, false);
+ ns3 = cf_e('', conf, false, true, true);
+
+ $(document).unbind(ns3);
+ $(window).unbind(ns3);
+ $wrp.unbind(ns2);
+
+ if (opts.auto.button) opts.auto.button.unbind(ns2);
+ if (opts.prev.button) opts.prev.button.unbind(ns2);
+ if (opts.next.button) opts.next.button.unbind(ns2);
+ if (opts.pagination.container) {
+ opts.pagination.container.unbind(ns2);
+ if (opts.pagination.anchorBuilder) {
+ opts.pagination.container.children().remove();
+ }
+ }
+
+ nv_showNavi(opts, 'hide', conf);
+ nv_enableNavi(opts, 'removeClass', conf);
+
+ }; // /unbind_buttons
+
+
+
+ // START
+
+ var crsl = {
+ 'direction' : 'next',
+ 'isPaused' : true,
+ 'isScrolling' : false,
+ 'isStopped' : false,
+
+ 'mousewheelNext': false,
+ 'mousewheelPrev': false,
+ 'touchwipe' : false
+ },
+ itms = {
+ 'total' : $cfs.children().length,
+ 'first' : 0
+ },
+ tmrs = {
+ 'timer' : null,
+ 'auto' : null,
+ 'queue' : null,
+ 'startTime' : getTime(),
+ 'timePassed' : 0
+ },
+ scrl = {
+ 'isStopped' : false,
+ 'duration' : 0,
+ 'startTime' : 0,
+ 'easing' : '',
+ 'anims' : []
+ },
+ clbk = {
+ 'onBefore' : [],
+ 'onAfter' : []
+ },
+ queu = [],
+ conf = $.extend(true, {}, $.fn.carouFredSel.configs, configs),
+ opts = {},
+ opts_orig = options,
+ $wrp = $cfs.wrap('<'+conf.wrapper.element+' class="'+conf.wrapper.classname+'" />').parent();
+
+ conf.selector = $cfs.selector;
+ conf.serialNumber = $.fn.carouFredSel.serialNumber++;
+
+ // create carousel
+ $cfs._cfs_init(opts_orig, true, starting_position);
+ $cfs._cfs_build();
+ $cfs._cfs_bind_events();
+ $cfs._cfs_bind_buttons();
+
+ // find item to start
+ if (is_array(opts.items.start)) {
+ var start_arr = opts.items.start;
+ } else {
+ var start_arr = [];
+ if (opts.items.start != 0) {
+ start_arr.push(opts.items.start);
+ }
+ }
+ if (opts.cookie) {
+ start_arr.unshift(cf_readCookie(opts.cookie));
+ }
+ if (start_arr.length > 0) {
+ for (var a = 0, l = start_arr.length; a < l; a++) {
+ var s = start_arr[a];
+ if (s == 0) {
+ continue;
+ }
+ if (s === true) {
+ s = window.location.hash;
+ if (s.length < 1) {
+ continue;
+ }
+ } else if (s === 'random') {
+ s = Math.floor(Math.random()*itms.total);
+ }
+ if ($cfs.triggerHandler(cf_e('slideTo', conf), [s, 0, true, { fx: 'none' }])) {
+ break;
+ }
+ }
+ }
+ var siz = sz_setSizes($cfs, opts, false),
+ itm = gi_getCurrentItems($cfs.children(), opts);
+
+ if (opts.onCreate) {
+ opts.onCreate.call($tt0, itm, siz);
+ }
+
+ $cfs.trigger(cf_e('updatePageStatus', conf), [true, siz]);
+ $cfs.trigger(cf_e('linkAnchors', conf));
+
+ return $cfs;
+ };
+
+
+ // GLOBAL PUBLIC
+
+ $.fn.carouFredSel.serialNumber = 1;
+ $.fn.carouFredSel.defaults = {
+ 'synchronise' : false,
+ 'infinite' : true,
+ 'circular' : true,
+ 'responsive' : false,
+ 'direction' : 'left',
+ 'items' : {
+ 'start' : 0
+ },
+ 'scroll' : {
+ 'easing' : 'swing',
+ 'duration' : 500,
+ 'pauseOnHover' : false,
+ 'mousewheel' : false,
+ 'wipe' : false,
+ 'event' : 'click',
+ 'queue' : false
+ }
+ };
+ $.fn.carouFredSel.configs = {
+ 'debug' : false,
+ 'events' : {
+ 'prefix' : '',
+ 'namespace' : 'cfs'
+ },
+ 'wrapper' : {
+ 'element' : 'div',
+ 'classname' : 'caroufredsel_wrapper'
+ },
+ 'classnames' : {}
+ };
+ $.fn.carouFredSel.pageAnchorBuilder = function(nr, itm) {
+ return '<a href="#"><span>'+nr+'</span></a>';
+ };
+
+
+ // GLOBAL PRIVATE
+
+ // scrolling functions
+ function sc_setScroll(d, e) {
+ return {
+ anims : [],
+ duration : d,
+ orgDuration : d,
+ easing : e,
+ startTime : getTime()