1/* 2 * jQuery carouFredSel 5.6.2 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 146if (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 230if (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;
vendor: 7,833 bytes, lines 490-757
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 $cfs.unbind('_cfs_triggerEvent'); 1733 }; // /unbind_events 1734 1735 $cfs._cfs_bind_buttons = function() { 1736 $cfs._cfs_unbind_buttons(); 1737 nv_showNavi(opts, itms.total, conf); 1738 nv_enableNavi(opts, itms.first, conf); 1739 1740 if (opts.auto.pauseOnHover) { 1741 var pC = bt_pauseOnHoverConfig(opts.auto.pauseOnHover);
1742 $wrp.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); }) 1743 .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); }); 1744 } 1745 1746 if (opts.auto.button) { 1747 opts.auto.button.bind(cf_e(opts.auto.event, conf, false), function(e) { 1748 e.preventDefault(); 1749 var ev = false, 1750 pC = null; 1751 1752 if (crsl.isPaused) { 1753 ev = 'play'; 1754 } else if (opts.auto.pauseOnEvent) { 1755 ev = 'pause'; 1756 pC = bt_pauseOnHoverConfig(opts.auto.pauseOnEvent); 1757 } 1758 if (ev) { 1759 $cfs.trigger(cf_e(ev, conf), pC); 1760 } 1761 }); 1762 } 1763 if (opts.prev.button) { 1764 opts.prev.button.bind(cf_e(opts.prev.event, conf, false), function(e) { 1765 e.preventDefault(); 1766 $cfs.trigger(cf_e('prev', conf)); 1767 }); 1768 if (opts.prev.pauseOnHover) { 1769 var pC = bt_pauseOnHoverConfig(opts.prev.pauseOnHover); 1770 opts.prev.button.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); }) 1771 .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); }); 1772 } 1773 } 1774 1775 if (opts.next.button) { 1776 opts.next.button.bind(cf_e(opts.next.event, conf, false), function(e) { 1777 e.preventDefault(); 1778 $cfs.trigger(cf_e('next', conf)); 1779 }); 1780 if (opts.next.pauseOnHover) { 1781 var pC = bt_pauseOnHoverConfig(opts.next.pauseOnHover); 1782 opts.next.button.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); }) 1783 .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); }); 1784 } 1785 } 1786 if ($.fn.mousewheel) { 1787 if (opts.prev.mousewheel) { 1788 if (!crsl.mousewheelPrev) { 1789 crsl.mousewheelPrev = true; 1790 $wrp.mousewheel(function(e, delta) { 1791 if (delta > 0) { 1792 e.preventDefault(); 1793 var num = bt_mousesheelNumber(opts.prev.mousewheel); 1794 $cfs.trigger(cf_e('prev', conf), num); 1795 } 1796 }); 1797 } 1798 } 1799 if (opts.next.mousewheel) { 1800 if (!crsl.mousewheelNext) { 1801 crsl.mousewheelNext = true; 1802 $wrp.mousewheel(function(e, delta) { 1803 if (delta < 0) { 1804 e.preventDefault(); 1805 var num = bt_mousesheelNumber(opts.next.mousewheel); 1806 $cfs.trigger(cf_e('next', conf), num); 1807 } 1808 }); 1809 } 1810 } 1811 } 1812 if ($.fn.touchwipe) { 1813 var wP = (opts.prev.wipe) ? function() { $cfs.trigger(cf_e('prev', conf)) } : null, 1814 wN = (opts.next.wipe) ? function() { $cfs.trigger(cf_e('next', conf)) } : null; 1815 1816 if (wN || wN) { 1817 if (!crsl.touchwipe) { 1818 crsl.touchwipe = true; 1819 var twOps = { 1820 'min_move_x': 30,
1821 'min_move_y': 30, 1822 'preventDefaultEvents': true 1823 }; 1824 switch (opts.direction) { 1825 case 'up': 1826 case 'down': 1827 twOps.wipeUp = wP; 1828 twOps.wipeDown = wN; 1829 break; 1830 default: 1831 twOps.wipeLeft = wN; 1832 twOps.wipeRight = wP; 1833 } 1834 $wrp.touchwipe(twOps); 1835 } 1836 } 1837 } 1838 if (opts.pagination.container) { 1839 if (opts.pagination.pauseOnHover) { 1840 var pC = bt_pauseOnHoverConfig(opts.pagination.pauseOnHover); 1841 opts.pagination.container.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); }) 1842 .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); }); 1843 } 1844 } 1845 if (opts.prev.key || opts.next.key) { 1846 $(document).bind(cf_e('keyup', conf, false, true, true), function(e) { 1847 var k = e.keyCode; 1848 if (k == opts.next.key) { 1849 e.preventDefault(); 1850 $cfs.trigger(cf_e('next', conf)); 1851 } 1852 if (k == opts.prev.key) { 1853 e.preventDefault(); 1854 $cfs.trigger(cf_e('prev', conf)); 1855 } 1856 }); 1857 } 1858 if (opts.pagination.keys) { 1859 $(document).bind(cf_e('keyup', conf, false, true, true), function(e) { 1860 var k = e.keyCode; 1861 if (k >= 49 && k < 58) { 1862 k = (k-49) * opts.items.visible; 1863 if (k <= itms.total) { 1864 e.preventDefault(); 1865 $cfs.trigger(cf_e('slideTo', conf), [k, 0, true, opts.pagination]); 1866 } 1867 } 1868 }); 1869 } 1870 if (opts.auto.play) { 1871 $cfs.trigger(cf_e('play', conf), opts.auto.delay); 1872 } 1873 1874 if (crsl.upDateOnWindowResize) { 1875 var $w = $(window), 1876 _windowWidth = $w.width(), 1877 _windowHeight = $w.height(); 1878 1879 $w.bind(cf_e('resize', conf, false, true, true), function(e) { 1880 if ($w.width() != _windowWidth || $w.height() != _windowHeight) { 1881 $cfs.trigger(cf_e('finish', conf)); 1882 if (opts.auto.pauseOnResize && !crsl.isPaused) { 1883 $cfs.trigger(cf_e('play', conf)); 1884 } 1885 sz_resetMargin($cfs.children(), opts); 1886 $cfs._cfs_init(opts_orig); 1887 var siz = sz_setSizes($cfs, opts, false); 1888 $cfs.trigger(cf_e('updatePageStatus', conf), [true, siz]); 1889 1890 _windowWidth = $w.width(); 1891 _windowHeight = $w.height(); 1892 } 1893 }); 1894 } 1895 1896 }; // /bind_buttons 1897 1898 $cfs._cfs_unbind_buttons = function() { 1899 var ns1 = cf_e('', conf), 1900 ns2 = cf_e('', conf, false); 1901 ns3 = cf_e('', conf, false, true, true); 1902 1903 $(document).unbind(ns3); 1904 $(window).unbind(ns3); 1905 $wrp.unbind(ns2); 1906 1907 if (opts.auto.button) opts.auto.button.unbind(ns2); 1908 if (opts.prev.button) opts.prev.button.unbind(ns2); 1909 if (opts.next.button) opts.next.button.unbind(ns2); 1910 if (opts.pagination.container) { 1911 opts.pagination.container.unbind(ns2); 1912 if (opts.pagination.anchorBuilder) { 1913 opts.pagination.container.children().remove(); 1914 } 1915 } 1916 1917 nv_showNavi(opts, 'hide', conf); 1918 nv_enableNavi(opts, 'removeClass', conf); 1919 1920 }; // /unbind_buttons 1921 1922 1923 1924 // START 1925 1926 var crsl = { 1927 'direction' : 'next', 1928 'isPaused' : true, 1929 'isScrolling' : false, 1930 'isStopped' : false, 1931 1932 'mousewheelNext': false, 1933 'mousewheelPrev': false, 1934 'touchwipe' : false 1935 }, 1936 itms = { 1937 'total' : $cfs.children().length, 1938 'first' : 0 1939 }, 1940 tmrs = { 1941 'timer' : null, 1942 'auto' : null, 1943 'queue' : null, 1944 'startTime' : getTime(), 1945 'timePassed' : 0 1946 }, 1947 scrl = { 1948 'isStopped' : false, 1949 'duration' : 0, 1950 'startTime' : 0, 1951 'easing' : '', 1952 'anims' : [] 1953 }, 1954 clbk = { 1955 'onBefore' : [], 1956 'onAfter' : [] 1957 }, 1958 queu = [], 1959 conf = $.extend(true, {}, $.fn.carouFredSel.configs, configs), 1960 opts = {}, 1961 opts_orig = options, 1962 $wrp = $cfs.wrap('<'+conf.wrapper.element+' class="'+conf.wrapper.classname+'" />').parent(); 1963 1964 conf.selector = $cfs.selector; 1965 conf.serialNumber = $.fn.carouFredSel.serialNumber++; 1966 1967 // create carousel 1968 $cfs._cfs_init(opts_orig, true, starting_position); 1969 $cfs._cfs_build(); 1970 $cfs._cfs_bind_events(); 1971 $cfs._cfs_bind_buttons(); 1972 1973 // find item to start 1974 if (is_array(opts.items.start)) { 1975 var start_arr = opts.items.start; 1976 } else { 1977 var start_arr = []; 1978 if (opts.items.start != 0) { 1979 start_arr.push(opts.items.start); 1980 } 1981 } 1982 if (opts.cookie) { 1983 start_arr.unshift(cf_readCookie(opts.cookie)); 1984 } 1985 if (start_arr.length > 0) { 1986 for (var a = 0, l = start_arr.length; a < l; a++) { 1987 var s = start_arr[a]; 1988 if (s == 0) { 1989 continue; 1990 } 1991 if (s === true) { 1992 s = window.location.hash; 1993 if (s.length < 1) { 1994 continue; 1995 } 1996 } else if (s === 'random') { 1997 s = Math.floor(Math.random()*itms.total); 1998 } 1999 if ($cfs.triggerHandler(cf_e('slideTo', conf), [s, 0, true, { fx: 'none' }])) { 2000 break; 2001 } 2002 } 2003 } 2004 var siz = sz_setSizes($cfs, opts, false), 2005 itm = gi_getCurrentItems($cfs.children(), opts); 2006 2007 if (opts.onCreate) { 2008 opts.onCreate.call($tt0, itm, siz); 2009 } 2010 2011 $cfs.trigger(cf_e('updatePageStatus', conf), [true, siz]); 2012 $cfs.trigger(cf_e('linkAnchors', conf)); 2013 2014 return $cfs; 2015 }; 2016 2017 2018 // GLOBAL PUBLIC 2019 2020 $.fn.carouFredSel.serialNumber = 1; 2021 $.fn.carouFredSel.defaults = { 2022 'synchronise' : false, 2023 'infinite' : true, 2024 'circular' : true, 2025 'responsive' : false, 2026 'direction' : 'left', 2027 'items' : { 2028 'start' : 0 2029 }, 2030 'scroll' : { 2031 'easing' : 'swing', 2032 'duration' : 500, 2033 'pauseOnHover' : false, 2034 'mousewheel' : false, 2035 'wipe' : false, 2036 'event' : 'click', 2037 'queue' : false 2038 } 2039 }; 2040 $.fn.carouFredSel.configs = { 2041 'debug' : false, 2042 'events' : { 2043 'prefix' : '', 2044 'namespace' : 'cfs' 2045 }, 2046 'wrapper' : { 2047 'element' : 'div', 2048 'classname' : 'caroufredsel_wrapper' 2049 }, 2050 'classnames' : {} 2051 }; 2052 $.fn.carouFredSel.pageAnchorBuilder = function(nr, itm) { 2053 return '<a href="#"><span>'+nr+'</span></a>'; 2054 }; 2055 2056 2057 // GLOBAL PRIVATE 2058 2059 // scrolling functions 2060 function sc_setScroll(d, e) { 2061 return { 2062 anims : [], 2063 duration : d, 2064 orgDuration : d, 2065 easing : e, 2066 startTime : getTime() 2067 }; 2068 } 2069 function sc_startScroll(s) { 2070 if (typeof s.pre == 'object') { 2071 sc_startScroll(s.pre); 2072 } 2073 for (var a = 0, l = s.anims.length; a < l; a++) { 2074 var b = s.anims[a]; 2075 if (!b) continue; 2076 if (b[3]) b[0].stop(); 2077 b[0].animate(b[1], { 2078 complete: b[2], 2079 duration: s.duration, 2080 easing: s.easing 2081 }); 2082 } 2083 if (typeof s.post == 'object') { 2084 sc_startScroll(s.post); 2085 } 2086 } 2087 function sc_stopScroll(s, finish) { 2088 if (typeof finish != 'boolean') finish = true; 2089 if (typeof s.pre == 'object') { 2090 sc_stopScroll(s.pre, finish); 2091 } 2092 for (var a = 0, l = s.anims.length; a < l; a++) { 2093 var b = s.anims[a]; 2094 b[0].stop(true); 2095 if (finish) { 2096 b[0].css(b[1]); 2097 if (typeof b[2] == 'function') b[2](); 2098 } 2099 } 2100 if (typeof s.post == 'object') { 2101 sc_stopScroll(s.post, finish); 2102 } 2103 } 2104 function sc_clearTimers(t) { 2105 if (t.auto) clearTimeout(t.auto); 2106 return t; 2107 } 2108 function sc_callCallbacks(cbs, t, args) { 2109 if (cbs.length) { 2110 for (var a = 0, l = cbs.length; a < l; a++) {
2111 cbs[a].apply(t, args); 2112 } 2113 } 2114 return []; 2115 } 2116 2117 // fx functions 2118 function fx_fade(sO, c, x, d, f) { 2119 var o = { 2120 'duration' : d, 2121 'easing' : sO.easing 2122 }; 2123 if (typeof f == 'function') o.complete = f; 2124 c.animate({ 2125 opacity: x 2126 }, o); 2127 } 2128 function fx_cover(sc, c1, c2, o, prev) { 2129 var old_w = ms_getSizes(gi_getOldItemsNext(c1.children(), o), o, true)[0], 2130 new_w = ms_getSizes(c2.children(), o, true)[0], 2131 cur_l = (prev) ? -new_w : old_w, 2132 css_o = {}, 2133 ani_o = {}; 2134 2135 css_o[o.d['width']] = new_w; 2136 css_o[o.d['left']] = cur_l; 2137 ani_o[o.d['left']] = 0; 2138 2139 sc.pre.anims.push([c1, { 'opacity': 1 }]); 2140 sc.post.anims.push([c2, ani_o, function() { $(this).remove(); }]); 2141 c2.css(css_o); 2142 return sc; 2143 } 2144 function fx_uncover(sc, c1, c2, o, prev, n) { 2145 var new_w = ms_getSizes(gi_getNewItemsNext(c1.children(), o, n), o, true)[0], 2146 old_w = ms_getSizes(c2.children(), o, true)[0], 2147 cur_l = (prev) ? -old_w : new_w, 2148 css_o = {}, 2149 ani_o = {}; 2150 2151 css_o[o.d['width']] = old_w; 2152 css_o[o.d['left']] = 0; 2153 ani_o[o.d['left']] = cur_l; 2154 sc.post.anims.push([c2, ani_o, function() { $(this).remove(); }]); 2155 c2.css(css_o); 2156 return sc; 2157 } 2158 2159 // navigation functions 2160 function nv_showNavi(o, t, c) { 2161 if (t == 'show' || t == 'hide') { 2162 var f = t; 2163 } else if (o.items.minimum >= t) { 2164 debug(c, 'Not enough items: hiding navigation ('+t+' items, '+o.items.minimum+' needed).'); 2165 var f = 'hide'; 2166 } else { 2167 var f = 'show'; 2168 } 2169 var s = (f == 'show') ? 'removeClass' : 'addClass', 2170 h = cf_c('hidden', c); 2171 if (o.auto.button) o.auto.button[f]()[s](h); 2172 if (o.prev.button) o.prev.button[f]()[s](h); 2173 if (o.next.button) o.next.button[f]()[s](h); 2174 if (o.pagination.container) o.pagination.container[f]()[s](h); 2175 } 2176 function nv_enableNavi(o, f, c) { 2177 if (o.circular || o.infinite) return; 2178 var fx = (f == 'removeClass' || f == 'addClass') ? f : false, 2179 di = cf_c('disabled', c); 2180 if (o.auto.button && fx) { 2181 o.auto.button[fx](di); 2182 } 2183 if (o.prev.button) { 2184 var fn = fx || (f == 0) ? 'addClass' : 'removeClass'; 2185 o.prev.button[fn](di); 2186 } 2187 if (o.next.button) { 2188 var fn = fx || (f == o.items.visible) ? 'addClass' : 'removeClass'; 2189 o.next.button[fn](di); 2190 } 2191 } 2192 2193 // get object functions 2194 function go_getObject($tt, obj) { 2195 if (typeof obj == 'function') obj = obj.call($tt); 2196 if (typeof obj == 'undefined') obj = {}; 2197 return obj; 2198 } 2199 function go_getNaviObject($tt, obj, type) { 2200 if (typeof type != 'string') type = ''; 2201 2202 obj = go_getObject($tt, obj); 2203 if (typeof obj == 'string') { 2204 var temp = cf_getKeyCode(obj); 2205 if (temp == -1) obj = $(obj); 2206 else obj = temp; 2207 } 2208 2209 // pagination 2210 if (type == 'pagination') { 2211 if (typeof obj == 'boolean') obj = { 'keys': obj }; 2212 if (typeof obj.jquery != 'undefined') obj = { 'container': obj }; 2213 if (typeof obj.container == 'function') obj.container = obj.container.call($tt); 2214 if (typeof obj.container == 'string') obj.container = $(obj.container); 2215 if (typeof obj.items != 'number') obj.items = false; 2216 2217 // auto 2218 } else if (type == 'auto') { 2219 if (typeof obj.jquery != 'undefined') obj = { 'button': obj }; 2220 if (typeof obj == 'boolean') obj = { 'play': obj }; 2221 if (typeof obj == 'number') obj = { 'pauseDuration': obj }; 2222 if (typeof obj.button == 'function') obj.button = obj.button.call($tt); 2223 if (typeof obj.button == 'string') obj.button = $(obj.button); 2224 2225 // prev + next 2226 } else { 2227 if (typeof obj.jquery != 'undefined') obj = { 'button': obj }; 2228 if (typeof obj == 'number') obj = { 'key': obj }; 2229 if (typeof obj.button == 'function') obj.button = obj.button.call($tt); 2230 if (typeof obj.button == 'string') obj.button = $(obj.button); 2231 if (typeof obj.key == 'string') obj.key = cf_getKeyCode(obj.key); 2232 } 2233 2234 return obj; 2235 } 2236 2237 // get number functions 2238 function gn_getItemIndex(num, dev, org, items, $cfs) { 2239 if (typeof num == 'string') { 2240 if (isNaN(num)) num = $(num); 2241 else num = parseInt(num); 2242 } 2243 if (typeof num == 'object') { 2244 if (typeof num.jquery == 'undefined') num = $(num); 2245 num = $cfs.children().index(num); 2246 if (num == -1) num = 0; 2247 if (typeof org != 'boolean') org = false;
2248 } else { 2249 if (typeof org != 'boolean') org = true; 2250 } 2251 if (isNaN(num)) num = 0; 2252 else num = parseInt(num); 2253 if (isNaN(dev)) dev = 0; 2254 else dev = parseInt(dev); 2255 2256 if (org) { 2257 num += items.first; 2258 } 2259 num += dev; 2260 if (items.total > 0) { 2261 while (num >= items.total) { num -= items.total; } 2262 while (num < 0) { num += items.total; } 2263 } 2264 return num; 2265 } 2266 2267 // items prev 2268 function gn_getVisibleItemsPrev(i, o, s) { 2269 var t = 0, 2270 x = 0; 2271 2272 for (var a = s; a >= 0; a--) { 2273 var j = i.eq(a); 2274 t += (j.is(':visible')) ? j[o.d['outerWidth']](true) : 0; 2275 if (t > o.maxDimention) return x; 2276 if (a == 0) a = i.length; 2277 x++; 2278 } 2279 } 2280 function gn_getVisibleItemsPrevFilter(i, o, s) { 2281 return gn_getItemsPrevFilter(i, o.items.filter, o.items.visibleConf.org, s); 2282 } 2283 function gn_getScrollItemsPrevFilter(i, o, s, m) { 2284 return gn_getItemsPrevFilter(i, o.items.filter, m, s); 2285 } 2286 function gn_getItemsPrevFilter(i, f, m, s) { 2287 var t = 0, 2288 x = 0; 2289 2290 for (var a = s, l = i.length; a >= 0; a--) { 2291 x++; 2292 if (x == l) return x; 2293 2294 var j = i.eq(a); 2295 if (j.is(f)) { 2296 t++; 2297 if (t == m) return x; 2298 }
2299 if (a == 0) a = l; 2300 } 2301 } 2302 2303 function gn_getVisibleOrg($c, o) { 2304 return o.items.visibleConf.org || $c.children().slice(0, o.items.visible).filter(o.items.filter).length; 2305 } 2306 2307 // items next 2308 function gn_getVisibleItemsNext(i, o, s) { 2309 var t = 0, 2310 x = 0; 2311 2312 for (var a = s, l = i.length-1; a <= l; a++) { 2313 var j = i.eq(a); 2314 2315 t += (j.is(':visible')) ? j[o.d['outerWidth']](true) : 0; 2316 if (t > o.maxDimention) return x; 2317 2318 x++; 2319 if (x == l+1) return x; 2320 if (a == l) a = -1; 2321 } 2322 } 2323 function gn_getVisibleItemsNextTestCircular(i, o, s, l) { 2324 var v = gn_getVisibleItemsNext(i, o, s); 2325 if (!o.circular) { 2326 if (s + v > l) v = l - s; 2327 } 2328 return v; 2329 } 2330 function gn_getVisibleItemsNextFilter(i, o, s) { 2331 return gn_getItemsNextFilter(i, o.items.filter, o.items.visibleConf.org, s, o.circular); 2332 } 2333 function gn_getScrollItemsNextFilter(i, o, s, m) { 2334 return gn_getItemsNextFilter(i, o.items.filter, m+1, s, o.circular) - 1; 2335 } 2336 function gn_getItemsNextFilter(i, f, m, s, c) { 2337 var t = 0, 2338 x = 0; 2339 2340 for (var a = s, l = i.length-1; a <= l; a++) { 2341 x++; 2342 if (x == l) return x; 2343 2344 var j = i.eq(a); 2345 if (j.is(f)) { 2346 t++; 2347 if (t == m) return x; 2348 }
2349 if (a == l) a = -1; 2350 } 2351 } 2352 2353 // get items functions 2354 function gi_getCurrentItems(i, o) { 2355 return i.slice(0, o.items.visible); 2356 } 2357 function gi_getOldItemsPrev(i, o, n) { 2358 return i.slice(n, o.items.visibleConf.old+n); 2359 } 2360 function gi_getNewItemsPrev(i, o) { 2361 return i.slice(0, o.items.visible); 2362 } 2363 function gi_getOldItemsNext(i, o) { 2364 return i.slice(0, o.items.visibleConf.old); 2365 } 2366 function gi_getNewItemsNext(i, o, n) { 2367 return i.slice(n, o.items.visible+n); 2368 } 2369 2370 // sizes functions 2371 function sz_resetMargin(i, o, m) { 2372 var x = (typeof m == 'boolean') ? m : false; 2373 if (typeof m != 'number') m = 0; 2374 i.each(function() { 2375 var j = $(this); 2376 var t = parseInt(j.css(o.d['marginRight'])); 2377 if (isNaN(t)) t = 0; 2378 j.data('cfs_tempCssMargin', t); 2379 j.css(o.d['marginRight'], ((x) ? j.data('cfs_tempCssMargin') : m + j.data('cfs_origCssMargin'))); 2380 }); 2381 } 2382 function sz_setSizes($c, o, p) { 2383 var $w = $c.parent(), 2384 $i = $c.children(), 2385 $v = gi_getCurrentItems($i, o), 2386 sz = cf_mapWrapperSizes(ms_getSizes($v, o, true), o, p); 2387 2388 $w.css(sz); 2389 2390 if (o.usePadding) { 2391 var p = o.padding, 2392 r = p[o.d[1]]; 2393 if (o.align) { 2394 if (r < 0) r = 0; 2395 } 2396 var $l = $v.last(); 2397 $l.css(o.d['marginRight'], $l.data('cfs_origCssMargin') + r); 2398 $c.css(o.d['top'], p[o.d[0]]); 2399 $c.css(o.d['left'], p[o.d[3]]); 2400 } 2401 2402 $c.css(o.d['width'], sz[o.d['width']]+(ms_getTotalSize($i, o, 'width')*2)); 2403 $c.css(o.d['height'], ms_getLargestSize($i, o, 'height')); 2404 return sz; 2405 } 2406 2407 // measuring functions 2408 function ms_getSizes(i, o, wrapper) { 2409 var s1 = ms_getTotalSize(i, o, 'width', wrapper), 2410 s2 = ms_getLargestSize(i, o, 'height', wrapper); 2411 return [s1, s2]; 2412 } 2413 function ms_getLargestSize(i, o, dim, wrapper) { 2414 if (typeof wrapper != 'boolean') wrapper = false;
2415 if (typeof o[o.d[dim]] == 'number' && wrapper) return o[o.d[dim]]; 2416 if (typeof o.items[o.d[dim]] == 'number') return o.items[o.d[dim]]; 2417 var di2 = (dim.toLowerCase().indexOf('width') > -1) ? 'outerWidth' : 'outerHeight'; 2418 return ms_getTrueLargestSize(i, o, di2); 2419 } 2420 function ms_getTrueLargestSize(i, o, dim) { 2421 var s = 0; 2422 2423 for (var a = 0, l = i.length; a < l; a++) { 2424 var j = i.eq(a); 2425 2426 var m = (j.is(':visible')) ? j[o.d[dim]](true) : 0; 2427 if (s < m) s = m; 2428 } 2429 return s; 2430 } 2431 function ms_getTrueInnerSize($el, o, dim) { 2432 if (!$el.is(':visible')) return 0; 2433 2434 var siz = $el[o.d[dim]](), 2435 arr = (o.d[dim].toLowerCase().indexOf('width') > -1) ? ['paddingLeft', 'paddingRight'] : ['paddingTop', 'paddingBottom']; 2436 2437 for (var a = 0, l = arr.length; a < l; a++) { 2438 var m = parseInt($el.css(arr[a])); 2439 siz -= (isNaN(m)) ? 0 : m; 2440 } 2441 return siz; 2442 } 2443 function ms_getTotalSize(i, o, dim, wrapper) { 2444 if (typeof wrapper != 'boolean') wrapper = false; 2445 if (typeof o[o.d[dim]] == 'number' && wrapper) return o[o.d[dim]]; 2446 if (typeof o.items[o.d[dim]] == 'number') return o.items[o.d[dim]] * i.length; 2447 2448 var d = (dim.toLowerCase().indexOf('width') > -1) ? 'outerWidth' : 'outerHeight', 2449 s = 0; 2450 2451 for (var a = 0, l = i.length; a < l; a++) { 2452 var j = i.eq(a); 2453 s += (j.is(':visible')) ? j[o.d[d]](true) : 0; 2454 } 2455 return s; 2456 } 2457 function ms_hasVariableSizes(i, o, dim) { 2458 var s = false, 2459 v = false; 2460 2461 for (var a = 0, l = i.length; a < l; a++) { 2462 var j = i.eq(a); 2463 2464 var c = (j.is(':visible')) ? j[o.d[dim]](true) : 0; 2465 if (s === false) s = c; 2466 else if (s != c) v = true; 2467 if (s == 0) v = true; 2468 } 2469 return v; 2470 } 2471 function ms_getPaddingBorderMargin(i, o, d) { 2472 return i[o.d['outer'+d]](true) - ms_getTrueInnerSize(i, o, 'inner'+d); 2473 } 2474 function ms_isPercentage(x) { 2475 return (typeof x == 'string' && x.slice(-1) == '%'); 2476 } 2477 function ms_getPercentage(s, o) { 2478 if (ms_isPercentage(o)) { 2479 o = o.slice(0, -1); 2480 if (isNaN(o)) return s; 2481 s *= o/100; 2482 } 2483 return s; 2484 } 2485 2486 // config functions 2487 function cf_e(n, c, pf, ns, rd) { 2488 if (typeof pf != 'boolean') pf = true; 2489 if (typeof ns != 'boolean') ns = true; 2490 if (typeof rd != 'boolean') rd = false; 2491 2492 if (pf) n = c.events.prefix + n; 2493 if (ns) n = n +'.'+ c.events.namespace; 2494 if (ns && rd) n += c.serialNumber; 2495 2496 return n; 2497 } 2498 function cf_c(n, c) { 2499 return (typeof c.classnames[n] == 'string') ? c.classnames[n] : n; 2500 } 2501 function cf_mapWrapperSizes(ws, o, p) { 2502 if (typeof p != 'boolean') p = true; 2503 var pad = (o.usePadding && p) ? o.padding : [0, 0, 0, 0]; 2504 var wra = {}; 2505 wra[o.d['width']] = ws[0] + pad[1] + pad[3]; 2506 wra[o.d['height']] = ws[1] + pad[0] + pad[2]; 2507 2508 return wra; 2509 } 2510 function cf_sortParams(vals, typs) { 2511 var arr = []; 2512 for (var a = 0, l1 = vals.length; a < l1; a++) { 2513 for (var b = 0, l2 = typs.length; b < l2; b++) { 2514 if (typs[b].indexOf(typeof vals[a]) > -1 && typeof arr[b] == 'undefined') { 2515 arr[b] = vals[a]; 2516 break; 2517 } 2518 } 2519 } 2520 return arr; 2521 } 2522 function cf_getPadding(p) { 2523 if (typeof p == 'undefined') return [0, 0, 0, 0]; 2524 2525 if (typeof p == 'number') return [p, p, p, p]; 2526 else if (typeof p == 'string') p = p.split('px').join('').split('em').join('').split(' '); 2527 2528 if (!is_array(p)) { 2529 return [0, 0, 0, 0]; 2530 } 2531 for (var i = 0; i < 4; i++) { 2532 p[i] = parseInt(p[i]); 2533 } 2534 switch (p.length) { 2535 case 0: return [0, 0, 0, 0]; 2536 case 1: return [p[0], p[0], p[0], p[0]]; 2537 case 2: return [p[0], p[1], p[0], p[1]]; 2538 case 3: return [p[0], p[1], p[2], p[1]]; 2539 default: return [p[0], p[1], p[2], p[3]]; 2540 } 2541 } 2542 function cf_getAlignPadding(itm, o) { 2543 var x = (typeof o[o.d['width']] == 'number') ? Math.ceil(o[o.d['width']] - ms_getTotalSize(itm, o, 'width')) : 0; 2544 switch (o.align) { 2545 case 'left': return [0, x]; 2546 case 'right': return [x, 0]; 2547 case 'center': 2548 default: 2549 return [Math.ceil(x/2), Math.floor(x/2)]; 2550 } 2551 } 2552 function cf_getAdjust(x, o, a, $t) { 2553 var v = x; 2554 if (typeof a == 'function') { 2555 v = a.call($t, v); 2556 2557 } else if (typeof a == 'string') { 2558 var p = a.split('+'), 2559 m = a.split('-'); 2560 2561 if (m.length > p.length) { 2562 var neg = true, 2563 sta = m[0], 2564 adj = m[1]; 2565 } else { 2566 var neg = false, 2567 sta = p[0], 2568 adj = p[1]; 2569 } 2570 2571 switch(sta) { 2572 case 'even': 2573 v = (x % 2 == 1) ? x-1 : x; 2574 break; 2575 case 'odd': 2576 v = (x % 2 == 0) ? x-1 : x; 2577 break; 2578 default: 2579 v = x; 2580 break; 2581 } 2582 adj = parseInt(adj); 2583 if (!isNaN(adj)) { 2584 if (neg) adj = -adj; 2585 v += adj; 2586 } 2587 } 2588 if (typeof v != 'number') v = 1; 2589 if (v < 1) v = 1; 2590 return v; 2591 } 2592 function cf_getItemsAdjust(x, o, a, $t) { 2593 return cf_getItemAdjustMinMax(cf_getAdjust(x, o, a, $t), o.items.visibleConf); 2594 } 2595 function cf_getItemAdjustMinMax(v, i) { 2596 if (typeof i.min == 'number' && v < i.min) v = i.min; 2597 if (typeof i.max == 'number' && v > i.max) v = i.max; 2598 if (v < 1) v = 1; 2599 return v; 2600 } 2601 function cf_getSynchArr(s) { 2602 if (!is_array(s)) s = [[s]]; 2603 if (!is_array(s[0])) s = [s]; 2604 for (var j = 0, l = s.length; j < l; j++) { 2605 if (typeof s[j][0] == 'string') s[j][0] = $(s[j][0]); 2606 if (typeof s[j][1] != 'boolean') s[j][1] = true; 2607 if (typeof s[j][2] != 'boolean') s[j][2] = true; 2608 if (typeof s[j][3] != 'number') s[j][3] = 0; 2609 } 2610 return s; 2611 } 2612 function cf_getKeyCode(k) { 2613 if (k == 'right') return 39; 2614 if (k == 'left') return 37; 2615 if (k == 'up') return 38; 2616 if (k == 'down') return 40; 2617 return -1; 2618 } 2619 function cf_setCookie(n, v) { 2620 if (n) document.cookie = n+'='+v+'; path=/'; 2621 } 2622 function cf_readCookie(n) { 2623 n += '='; 2624 var ca = document.cookie.split(';'); 2625 for (var a = 0, l = ca.length; a < l; a++) { 2626 var c = ca[a]; 2627 while (c.charAt(0) == ' ') { 2628 c = c.slice(1); 2629 } 2630 if (c.indexOf(n) == 0) { 2631 return c.slice(n.length); 2632 } 2633 } 2634 return 0; 2635 } 2636 2637 // buttons functions 2638 function bt_pauseOnHoverConfig(p) { 2639 if (p && typeof p == 'string') { 2640 var i = (p.indexOf('immediate') > -1) ? true : false, 2641 r = (p.indexOf('resume') > -1) ? true : false;
2642 } else { 2643 var i = r = false; 2644 } 2645 return [i, r]; 2646 } 2647 function bt_mousesheelNumber(mw) { 2648 return (typeof mw == 'number') ? mw : null 2649 } 2650 2651 // helper functions 2652 function is_array(a) { 2653 return typeof(a) == 'object' && (a instanceof Array); 2654 } 2655 2656 function getTime() { 2657 return new Date().getTime(); 2658 } 2659 2660 function debug(d, m) { 2661 if (typeof d == 'object') { 2662 var s = ' ('+d.selector+')'; 2663 d = d.debug; 2664 } else { 2665 var s = ''; 2666 } 2667 if (!d) return false; 2668 2669 if (typeof m == 'string') m = 'carouFredSel'+s+': ' + m; 2670 else m = ['carouFredSel'+s+':', m]; 2671 2672 if (window.console && window.console.log) window.console.log(m); 2673 return false; 2674 } 2675 2676 2677 // CAROUFREDSEL ALL LOWERCASE 2678 2679 $.fn.caroufredsel = function(o, c) { 2680 return this.carouFredSel(o, c); 2681 }; 2682 2683 2684 // EASING FUNCTIONS 2685 2686 $.extend($.easing, { 2687 'quadratic' : function(t) { 2688 var t2 = t * t; 2689 return t * (-t2 * t + 4 * t2 - 6 * t + 4); 2690 }, 2691 'cubic' : function(t) { 2692 return t * (4 * t * t - 9 * t + 6); 2693 }, 2694 'elastic' : function(t) { 2695 var t2 = t * t; 2696 return t * (33 * t2 * t2 - 106 * t2 * t + 126 * t2 - 67 * t + 15); 2697 } 2698 }); 2699 2700 2701})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.