/** * jCarousel - Riding carousels with jQuery * http://sorgalla.com/jcarousel/ * * Copyright (c) 2006 Jan Sorgalla (http://sorgalla.com) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * Built on top of the jQuery library * http://jquery.com * * Inspired by the "Carousel Component" by Bill Scott * http://billwscott.com/carousel/ */ /*=======================================================================*/ /* jCarousel for Galleria WP : V1.2.3 Build 705 6/19 2008 */ /*=======================================================================*/ (function($) { /** * Creates a carousel for all matched elements. * * @example jQuery("#mycarousel").jcarousel(); * @before * @result * *
*
*
*
*
*
    *
  • First item
  • *
  • Second item
  • *
*
*
*
* * @name jcarousel * @type jQuery * @param Hash o A set of key/value pairs to set as configuration properties. * @cat Plugins/jCarousel */ jQuery.fn.jcarousel = function(o) { return this.each(function() { new $jc(this, o); }); }; // Default configuration properties. var defaults = { vertical: false, start: 1, offset: 1, size: null, scroll: null, visible: null, thumb_w: null, // b6 6/06 thumb_h: null, // b6 6/06 auto_hide: 1, // b705 6/19 animation: 'normal', easing: 'swing', auto: 0, wrap: null, initCallback: null, reloadCallback: null, itemLoadCallback: null, itemFirstInCallback: null, itemFirstOutCallback: null, itemLastInCallback: null, itemLastOutCallback: null, itemVisibleInCallback: null, itemVisibleOutCallback: null, buttonNextHTML: '
', buttonPrevHTML: '
', buttonNextEvent: 'click', buttonPrevEvent: 'click', buttonNextCallback: null, buttonPrevCallback: null }; /** * The jCarousel object. * * @constructor * @name jQuery.jcarousel * @param Object e The element to create the carousel for. * @param Hash o A set of key/value pairs to set as configuration properties. * @cat Plugins/jCarousel */ jQuery.jcarousel = function(e, o) { this.options = jQuery.extend({}, defaults, o || {}); this.locked = false; this.container = null; this.clip = null; this.list = null; this.buttonNext = null; this.buttonPrev = null; this.wh = !this.options.vertical ? 'width' : 'height'; this.lt = !this.options.vertical ? 'left' : 'top'; // Extract skin class var skin = '', split = e.className.split(' '); for (var i = 0; i < split.length; i++) { if (split[i].indexOf('jcarousel-skin') != -1) { jQuery(e).removeClass(split[i]); var skin = split[i]; break; } } if (e.nodeName == 'UL' || e.nodeName == 'OL') { this.list = jQuery(e); this.container = this.list.parent(); if (this.container.hasClass('jcarousel-clip')) { if (!this.container.parent().hasClass('jcarousel-container')) this.container = this.container.wrap('
'); this.container = this.container.parent(); } else if (!this.container.hasClass('jcarousel-container')) this.container = this.list.wrap('
').parent(); } else { this.container = jQuery(e); this.list = jQuery(e).find('>ul,>ol,div>ul,div>ol'); } if (skin != '' && this.container.parent()[0].className.indexOf('jcarousel-skin') == -1) this.container.wrap('
'); this.clip = this.list.parent(); // DIV if (!this.clip.length || !this.clip.hasClass('jcarousel-clip')) this.clip = this.list.wrap('
').parent(); this.buttonPrev = jQuery('.jcarousel-prev', this.container); if (this.buttonPrev.size() == 0 && this.options.buttonPrevHTML != null) this.buttonPrev = this.clip.before(this.options.buttonPrevHTML).prev(); this.buttonPrev.addClass(this.className('jcarousel-prev')); this.buttonNext = jQuery('.jcarousel-next', this.container); if (this.buttonNext.size() == 0 && this.options.buttonNextHTML != null) this.buttonNext = this.clip.before(this.options.buttonNextHTML).prev(); this.buttonNext.addClass(this.className('jcarousel-next')); // DIV class=jcarousel-next this.container.addClass(this.className('jcarousel-container')); // DIV class=jcarousel-container this.clip.addClass(this.className('jcarousel-clip')); // DIV class=jcarousel-clip this.list.addClass(this.className('jcarousel-list')); // UL var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null; var li = this.list.children('li'); var self = this; //================================================================================================// // Galleria WP V1.2.0b6 added by Y2 : 6/06 2008 // //================================================================================================// var ul = this.list; this.container_wrapper = this.container.parent(); // DIV class=jcarousel-skin-xxxxx var num_of_li_elements = li.size(); var container_wrapper_width = this.container_wrapper.width(); var container_wrapper_height = this.container_wrapper.height(); var div_container_width = this.container.width(); var div_container_height = this.container.height(); var div_clip_width = this.clip.width(); var div_clip_height = this.clip.height(); var ul_width = this.list.width(); var ul_height = this.list.height(); var prevButtonWidth = this.buttonPrev.width(); var prevButtonHeight = this.buttonPrev.height(); var nextButtonWidth = this.buttonNext.width(); var nextButtonHeight = this.buttonNext.height(); var new_ul_wrapper_width = 0; var new_ul_wrapper_height = 0; var num_of_thumbs = 0; var li_width = 0; var li_height = 0; var max_clip_width = div_container_width - prevButtonWidth - nextButtonWidth ; var max_clip_height = div_container_height - prevButtonHeight - nextButtonHeight ; var li_extra_width = $jc.intval(li.css('borderLeftWidth')) + $jc.intval(li.css( 'borderRightWidth')); var li_extra_height = $jc.intval(li.css('borderTopWidth')) + $jc.intval(li.css( 'borderBottomWidth')); if ( !this.options.vertical ) { // Horizontal Scroll Mode if ( this.options.thumb_w > 0 ) { // [ width ] li_width = this.options.thumb_w; if ( this.options.visible > 0 ) { // [ columns & width ] num_of_thumbs = this.options.visible; } else { // [ width ] num_of_thumbs = Math.floor( max_clip_width / (li_width + li_extra_width) ) ; } } else { if ( this.options.visible > 0 ) { // [ columns ] num_of_thumbs = this.options.visible; var max_available_width = max_clip_width - ( li_extra_width * num_of_thumbs ) ; li_width = Math.floor( max_available_width / num_of_thumbs ); } else { // [ nothing ] li_width = li.width(); // default CSS width property will be used num_of_thumbs = Math.floor( max_clip_width / ( li_width + li_extra_width) ) ; } } // height li_height = ( this.options.thumb_h > 0 ) ? this.options.thumb_h : li.height(); // 6/14 2008 // force to set max_clip_height max_clip_height = li_height + li_extra_height; } else { // Vertical Scroll Mode if ( this.options.thumb_h > 0 ) { // [ height ] li_height = this.options.thumb_h; if ( this.options.visible > 0 ) { // [ height & columns ] num_of_thumbs = this.options.visible; } else { // [ height ] num_of_thumbs = Math.floor( max_clip_height / (li_height + li_extra_height) ); } } else { if ( this.options.visible > 0 ) { // [ columns ] num_of_thumbs = this.options.visible; var max_available_height = max_clip_height - ( li_extra_height * num_of_thumbs ) ; li_height = Math.floor( max_available_height / num_of_thumbs ); } else { // [ nothing ] li_height = li.height(); // default CSS height property will be used num_of_thumbs = Math.floor( max_clip_height / (li_height + li_extra_height) ); } } // width li_width = ( this.options.thumb_w > 0 ) ? this.options.thumb_w : li.width();// 6/14 2008 // force to set max_clip_width max_clip_width = li_width + li_extra_width; } // adjust visible number if ( num_of_li_elements < num_of_thumbs ) { num_of_thumbs = num_of_li_elements; } this.options.visible = num_of_thumbs; // adjust number of steps (PrevButton/NextButton) if ( !this.options.scroll ) this.options.scroll = num_of_thumbs; //====================================================== // calculates thumbnail width and set
  • attributes //====================================================== if ( li.size() > 0) { var wh = 0; var i = this.options.offset; li.each(function() { //== adds sequential class self.format(this, i++); //wh += self.dimension(this, di); //== set CSS "width" attribute to each
  • items wh += self.dimension2( this, li_width, li_height ); }); //== set total width/height to the