diff --git a/widget/css/rcarousel.css b/widget/css/rcarousel.css index fed18fc..c54e286 100644 --- a/widget/css/rcarousel.css +++ b/widget/css/rcarousel.css @@ -7,17 +7,17 @@ width: 300px } -.ui-carousel > .wrapper { +.ui-carousel > .rcarousel-wrapper { margin: 0; padding: 0; width: 9999px; } -.ui-carousel > .wrapper > * { +.ui-carousel > .rcarousel-wrapper > * { border: 0; display: block; float: left; height: 100px; overflow: hidden; - width: 100px; -} \ No newline at end of file + width: 100px; +} diff --git a/widget/lib/jquery.ui.rcarousel.js b/widget/lib/jquery.ui.rcarousel.js index 4d89e4a..ac7cb11 100644 --- a/widget/lib/jquery.ui.rcarousel.js +++ b/widget/lib/jquery.ui.rcarousel.js @@ -15,23 +15,23 @@ this._createDataObject(); data = $root.data( "data" ); - // create wrapper inside root element; this is needed for animating + // create rcarousel-wrapper inside root element; this is needed for animating $root .addClass( "ui-carousel" ) .children() - .wrapAll( "
" ); - + .wrapAll( "
" ); + // save all children of root element in ‘paths’ array this._saveElements(); // make pages using paginate algorithm - this._generatePages(); - + this._generatePages(); + this._loadElements(); - + this._setCarouselWidth(); this._setCarouselHeight(); - + // handle default event handlers $( options.navigation.next ).click( function( event ) { @@ -39,17 +39,17 @@ event.preventDefault(); } ); - + $( options.navigation.prev ).click( function( event ) { _self.prev(); event.preventDefault(); } - ); - + ); + data.navigation.next = $( options.navigation.next ); data.navigation.prev = $( options.navigation.prev ); - + // stop on hover feature $root.hover( function() { @@ -65,27 +65,27 @@ } } ); - + this._setStep(); - + // if auto mode is enabled run it if ( options.auto.enabled ) { this._autoMode( options.auto.direction ); } - + // broadcast event this._trigger( "start" ); }, - + _addElement: function( jQueryElement, direction ) { var $root = $( this.element ), - $content = $root.find( "div.wrapper" ), + $content = $root.find( "div.rcarousel-wrapper" ), options = this.options; jQueryElement .width( options.width ) .height( options.height ); - + if ( options.orientation === "horizontal" ) { $( jQueryElement ).css( "marginRight", options.margin ); } else { @@ -94,34 +94,34 @@ "float": "none" }); } - + if ( direction === "prev" ) { - + // clone event handlers and data as well $content.prepend( jQueryElement.clone(true, true) ); } else { $content.append( jQueryElement.clone(true, true) ); - } + } }, - + append: function( jqElements ) { var $root = $( this.element ), data = $root.data( "data" ); - + // add new elements jqElements.each( function( i, el ) { data.paths.push( $(el) ); } ); - + data.oldPage = data.pages[data.oldPageIndex].slice(0); data.appended = true; - + // rebuild pages this._generatePages(); }, - + _autoMode: function( direction ) { var options = this.options, data = $( this.element ).data( "data" ); @@ -132,12 +132,12 @@ data.interval = setTimeout( $.proxy(this.prev, this), options.auto.interval ); } }, - + _checkOptionsValidity: function( options ) { var i, self = this, _correctSteps = ""; - + // for every element in options object check its validity $.each(options, function( key, value ) { @@ -149,7 +149,7 @@ throw new Error( "visible should be defined as a positive integer" ); } break; - + case "step": if ( !value || typeof value !== "number" || value <= 0 || (Math.ceil(value) - value > 0) ) { throw new Error( "step should be defined as a positive integer" ); @@ -160,64 +160,64 @@ for ( i = 1; i <= Math.floor(options.visible); i++ ) { _correctSteps += ( i < Math.floor(value) ) ? i + ", " : i; } - + throw new Error( "Only following step values are correct: " + _correctSteps ); } break; - + case "width": // width & height is defined by default so you can omit them to some extent if ( !value || typeof value !== "number" || value <= 0 || Math.ceil(value) - value > 0 ) { throw new Error( "width should be defined as a positive integer" ); } break; - + case "height": if ( !value || typeof value !== "number" || value <= 0 || Math.ceil(value) - value > 0 ) { throw new Error("height should be defined as a positive integer"); } break; - + case "speed": if ( !value && value !== 0 ) { throw new Error("speed should be defined as a number or a string"); } - + if ( typeof value === "number" && value < 0 ) { throw new Error( "speed should be a positive number" ); } else if ( typeof value === "string" && !(value === "slow" || value === "normal" || value === "fast") ) { throw new Error( 'Only "slow", "normal" and "fast" values are valid' ); } break; - + case "navigation": if ( !value || $.isPlainObject(value) === false ) { throw new Error( "navigation should be defined as an object with at least one of the properties: 'prev' or 'next' in it"); } - + if ( value.prev && typeof value.prev !== "string" ) { throw new Error( "navigation.prev should be defined as a string and point to '.class' or '#id' of an element" ); } - + if ( value.next && typeof value.next !== "string" ) { throw new Error(" navigation.next should be defined as a string and point to '.class' or '#id' of an element" ); } break; - + case "auto": if ( typeof value.direction !== "string" ) { throw new Error( "direction should be defined as a string" ); } - + if ( !(value.direction === "next" || value.direction === "prev") ) { throw new Error( "direction: only 'right' and 'left' values are valid" ); } - + if ( isNaN(value.interval) || typeof value.interval !== "number" || value.interval < 0 || Math.ceil(value.interval) - value.interval > 0 ) { throw new Error( "interval should be a positive number" ); } break; - + case "margin": if ( isNaN(value) || typeof value !== "number" || value < 0 || Math.ceil(value) - value > 0 ) { throw new Error( "margin should be a positive number" ); @@ -227,7 +227,7 @@ } ); }, - + _createDataObject: function() { var $root = $( this.element ); @@ -246,14 +246,14 @@ } ); }, - + _generatePages: function() { var self = this, options = this.options, data = $( this.element ).data( "data" ), _visible = options.visible, _pathsLen = data.paths.length; - + // having 10 elements: A, B, C, D, E, F, G, H, I, J the algorithm // creates 3 pages for ‘visible: 5’ and ‘step: 4’: // [ABCDE], [EFGHI], [FGHIJ] @@ -269,11 +269,11 @@ for ( var i = _pathsLen - 1; i >= _pathsLen - _visible; i-- ) { data.lastPage.unshift( data.paths[i] ); } - + // and first page for ( var i = 0; i < _visible; i++ ) { data.pages[0][data.pages[0].length] = data.paths[i]; - } + } } function _islastPage( page ) { @@ -287,7 +287,7 @@ break; } } - + return _isLast; } @@ -321,7 +321,7 @@ if ( _end > _pathsLen ) { _end = _pathsLen; } - + // when we run ouf of elements (_end - _start < _visible) we must add the difference at the begining // in our example the 3rd page is [FGHIJ] and J element is added in the second step // first we add [FGHI] as old elements @@ -333,22 +333,22 @@ } if ( _complement ) { - + // first add old elemets; for 3rd page it adds [FGHI…] // remember the page we add to (_index) _oldFirstEl = _start - ( _visible - (_end - _start) ); _oldLastEl = _oldFirstEl + ( _visible - (_end - _start) ); _index = _append( _oldFirstEl, _oldLastEl ); - + // then add new elements; for 3th page it is J element: // [fghiJ] _append( _start, _end, _index ); } else { - + // normal pages like [ABCDE], [EFGHI] _append( _start, _end ); - + // next step _start += options.step; } @@ -359,17 +359,17 @@ _init(); _paginate(); }, - + getCurrentPage: function() { var data = $( this.element ).data( "data" ); return data.pageIndex + 1; }, - + getTotalPages: function() { var data = $( this.element ).data( "data" ); return data.pages.length; }, - + goToPage: function( page ) { var _by, data = $( this.element ).data( "data" ); @@ -382,21 +382,21 @@ } else if ( page < 0 ) { page = 0; } - + data.pageIndex = page; _by = page - data.oldPageIndex; - + if ( _by >= 0 ) { //move by n elements from current index this._goToNextPage( _by ); } else { this._goToPrevPage( _by ); } - + data.oldPageIndex = page; } }, - + _loadElements: function(elements, direction) { var options = this.options, data = $( this.element ).data( "data" ), @@ -415,7 +415,7 @@ } } }, - + _goToPrevPage: function( by ) { var _page, _oldPage, _dist, _index, _animOpts, $lastEl, _unique, _pos, _theSame, $root = $( this.element ), @@ -426,11 +426,11 @@ // pick pages if ( data.appended ) { _oldPage = data.oldPage; - } else { + } else { _oldPage = data.pages[data.oldPageIndex]; } - - _index = data.oldPageIndex + by; + + _index = data.oldPageIndex + by; _page = data.pages[_index].slice( 0 ); // For example, the first time widget was initiated there were 5 @@ -442,7 +442,7 @@ // we compare the same // pages, that is, the 2nd page from 5 elements and the 2nd from // 10 elements. Thus what we do next is to decrement the index and - // loads the first page from 10 elements. + // loads the first page from 10 elements. $( _page ).each( function( i, el ) { if ( el.get(0) === $(_oldPage[i]).get(0) ) { @@ -452,16 +452,16 @@ } } ); - + if ( data.appended && _theSame ) { if ( data.pageIndex === 0 ) { _index = data.pageIndex = data.pages.length - 1; } else { _index = --data.pageIndex; } - + _page = data.pages[_index].slice( 0 ); - } + } // check if last element from _page appears in _oldPage // for [ABCDFGHIJ] elements there are 3 pages for ‘visible’ = 6 and @@ -487,7 +487,7 @@ } --_pos; } - } + } // load new elements self._loadElements( _page, "prev" ); @@ -511,35 +511,35 @@ if ( !data.hoveredOver && options.auto.enabled ) { // if autoMode is on and you change page manually clearInterval( data.interval ); - + self._autoMode( options.auto.direction ); } // scrolling is finished, send an event self._trigger("pageLoaded", null, {page: _index}); }); - + // reset to deafult - data.appended = false; + data.appended = false; }, - + _goToNextPage: function( by ) { var _page, _oldPage, _dist, _index, _animOpts, $firstEl, _unique, _pos, _theSame, $root = $( this.element ), options = this.options, - data = $root.data( "data" ), + data = $root.data( "data" ), self = this; // pick pages if ( data.appended ) { _oldPage = data.oldPage; - } else { + } else { _oldPage = data.pages[data.oldPageIndex]; } - - _index = data.oldPageIndex + by; + + _index = data.oldPageIndex + by; _page = data.pages[_index].slice( 0 ); - + // For example, the first time widget was initiated there were 5 // elements: A, B, C, D, E and 2 pages for visible 4 and step 3: // ABCD and BCDE. Then a user loaded next 5 elements so there were @@ -559,7 +559,7 @@ } } ); - + if ( data.appended && _theSame ) { _page = data.pages[++data.pageIndex].slice( 0 ); } @@ -588,35 +588,35 @@ ++_pos; } } - - // load new elements + + // load new elements this._loadElements( _page, "next" ); // calculate the distance _dist = options.width * _page.length + ( options.margin * _page.length ); - + if ( options.orientation === "horizontal" ) { _animOpts = {scrollLeft: "+=" + _dist}; } else { _animOpts = {scrollTop: "+=" + _dist}; } - + $root .animate(_animOpts, options.speed, function() { self._removeOldElements( "first", _page.length ); - + if ( options.orientation === "horizontal" ) { $root.scrollLeft( 0 ); } else { $root.scrollTop( 0 ); } - + data.animated = false; if ( !data.hoveredOver && options.auto.enabled ) { // if autoMode is on and you change page manually clearInterval( data.interval ); - + self._autoMode( options.auto.direction ); } @@ -624,22 +624,22 @@ self._trigger( "pageLoaded", null, {page: _index}); }); - + // reset to deafult data.appended = false; }, - + next: function() { var options = this.options, data = $( this.element ).data( "data" ); if ( !data.animated ) { data.animated = true; - + if ( !data.appended ) { ++data.pageIndex; - } - + } + if ( data.pageIndex > data.pages.length - 1 ) { data.pageIndex = 0; } @@ -649,7 +649,7 @@ data.oldPageIndex = data.pageIndex; } }, - + prev: function() { var options = this.options, data = $( this.element ).data( "data" ); @@ -660,7 +660,7 @@ if ( !data.appended ) { --data.pageIndex; } - + if ( data.pageIndex < 0 ) { data.pageIndex = data.pages.length - 1; } @@ -670,7 +670,7 @@ data.oldPageIndex = data.pageIndex; } }, - + _removeOldElements: function(position, length) { // remove 'step' elements var $root = $( this.element ); @@ -678,37 +678,37 @@ for ( var i = 0; i < length; i++ ) { if ( position === "first" ) { $root - .find( "div.wrapper" ) + .find( "div.rcarousel-wrapper" ) .children() .first() .remove(); } else { $root - .find( "div.wrapper" ) + .find( "div.rcarousel-wrapper" ) .children() .last() .remove(); } } }, - + _saveElements: function() { var $el, $root = $( this.element ), - $elements = $root.find( "div.wrapper" ).children(), + $elements = $root.find( "div.rcarousel-wrapper" ).children(), data = $root.data( "data" ); - + $elements.each( function( i, el ) { $el = $( el ); - + // keep element’s data and events data.paths.push( $el.clone(true, true) ); $el.remove(); } - ); + ); }, - + _setOption: function( key, value ) { var _newOptions, options = this.options, @@ -720,11 +720,11 @@ options.speed = value; $.Widget.prototype._setOption.apply( this, arguments ); break; - + case "auto": _newOptions = $.extend( options.auto, value ); this._checkOptionsValidity({auto: _newOptions}); - + if ( options.auto.enabled ) { this._autoMode( options.auto.direction ); } @@ -742,11 +742,11 @@ options.step = _step; data.step = options.width * _step; }, - + _setCarouselHeight: function() { var _newHeight, $root = $( this.element ), - data = $( this.element ).data( "data" ), + data = $( this.element ).data( "data" ), options = this.options; if ( options.orientation === "vertical" ) { @@ -757,7 +757,7 @@ $root.height(_newHeight); }, - + _setCarouselWidth: function() { var _newWidth, $root = $( this.element ), @@ -776,7 +776,7 @@ overflow: "hidden" }); }, - + options: { visible: 3, step: 3, @@ -797,4 +797,4 @@ } } }); -}(jQuery)); \ No newline at end of file +}(jQuery)); diff --git a/widget/lib/jquery.ui.rcarousel.min.js b/widget/lib/jquery.ui.rcarousel.min.js index cd37610..743b2bc 100644 --- a/widget/lib/jquery.ui.rcarousel.min.js +++ b/widget/lib/jquery.ui.rcarousel.min.js @@ -1 +1 @@ -(function(a){a.widget("ui.rcarousel",{_create:function(){var d,e=a(this.element),b=this,c=this.options;this._checkOptionsValidity(this.options);this._createDataObject();d=e.data("data");e.addClass("ui-carousel").children().wrapAll("
");this._saveElements();this._generatePages();this._loadElements();this._setCarouselWidth();this._setCarouselHeight();a(c.navigation.next).click(function(f){b.next();f.preventDefault()});a(c.navigation.prev).click(function(f){b.prev();f.preventDefault()});d.navigation.next=a(c.navigation.next);d.navigation.prev=a(c.navigation.prev);e.hover(function(){if(c.auto.enabled){clearInterval(d.interval);d.hoveredOver=true}},function(){if(c.auto.enabled){d.hoveredOver=false;b._autoMode(c.auto.direction)}});this._setStep();if(c.auto.enabled){this._autoMode(c.auto.direction)}this._trigger("start")},_addElement:function(f,e){var d=a(this.element),c=d.find("div.wrapper"),b=this.options;f.width(b.width).height(b.height);if(b.orientation==="horizontal"){a(f).css("marginRight",b.margin)}else{a(f).css({marginBottom:b.margin,"float":"none"})}if(e==="prev"){c.prepend(f.clone(true,true))}else{c.append(f.clone(true,true))}},append:function(d){var c=a(this.element),b=c.data("data");d.each(function(e,f){b.paths.push(a(f))});b.oldPage=b.pages[b.oldPageIndex].slice(0);b.appended=true;this._generatePages()},_autoMode:function(d){var b=this.options,c=a(this.element).data("data");if(d==="next"){c.interval=setTimeout(a.proxy(this.next,this),b.auto.interval)}else{c.interval=setTimeout(a.proxy(this.prev,this),b.auto.interval)}},_checkOptionsValidity:function(c){var d,b=this,e="";a.each(c,function(f,g){switch(f){case"visible":if(!g||typeof g!=="number"||g<=0||(Math.ceil(g)-g>0)){throw new Error("visible should be defined as a positive integer")}break;case"step":if(!g||typeof g!=="number"||g<=0||(Math.ceil(g)-g>0)){throw new Error("step should be defined as a positive integer")}else{if(g>b.options.visible){for(d=1;d<=Math.floor(c.visible);d++){e+=(d0){throw new Error("width should be defined as a positive integer")}break;case"height":if(!g||typeof g!=="number"||g<=0||Math.ceil(g)-g>0){throw new Error("height should be defined as a positive integer")}break;case"speed":if(!g&&g!==0){throw new Error("speed should be defined as a number or a string")}if(typeof g==="number"&&g<0){throw new Error("speed should be a positive number")}else{if(typeof g==="string"&&!(g==="slow"||g==="normal"||g==="fast")){throw new Error('Only "slow", "normal" and "fast" values are valid')}}break;case"navigation":if(!g||a.isPlainObject(g)===false){throw new Error("navigation should be defined as an object with at least one of the properties: 'prev' or 'next' in it")}if(g.prev&&typeof g.prev!=="string"){throw new Error("navigation.prev should be defined as a string and point to '.class' or '#id' of an element")}if(g.next&&typeof g.next!=="string"){throw new Error(" navigation.next should be defined as a string and point to '.class' or '#id' of an element")}break;case"auto":if(typeof g.direction!=="string"){throw new Error("direction should be defined as a string")}if(!(g.direction==="next"||g.direction==="prev")){throw new Error("direction: only 'right' and 'left' values are valid")}if(isNaN(g.interval)||typeof g.interval!=="number"||g.interval<0||Math.ceil(g.interval)-g.interval>0){throw new Error("interval should be a positive number")}break;case"margin":if(isNaN(g)||typeof g!=="number"||g<0||Math.ceil(g)-g>0){throw new Error("margin should be a positive number")}break}})},_createDataObject:function(){var b=a(this.element);b.data("data",{paths:[],pathsLen:0,pages:[],lastPage:[],oldPageIndex:0,pageIndex:0,navigation:{},animated:false,appended:false,hoveredOver:false})},_generatePages:function(){var i=this,j=this.options,c=a(this.element).data("data"),b=j.visible,h=c.paths.length;function f(){c.pages=[];c.lastPage=[];c.pages[0]=[];for(var k=h-1;k>=h-b;k--){c.lastPage.unshift(c.paths[k])}for(var k=0;kh){k=h}if(k-mc.pages.length-1){d=c.pages.length-1}else{if(d<0){d=0}}c.pageIndex=d;b=d-c.oldPageIndex;if(b>=0){this._goToNextPage(b)}else{this._goToPrevPage(b)}c.oldPageIndex=d}},_loadElements:function(b,h){var k=this.options,e=a(this.element).data("data"),f=h||"next",j=b||e.pages[k.startAtPage],c=0,g=j.length;if(f==="next"){for(var d=c;d=c;d--){this._addElement(j[d],f)}}},_goToPrevPage:function(k){var c,j,f,l,g,m,n,p,b,h=a(this.element),o=this,q=this.options,e=a(this.element).data("data");if(e.appended){j=e.oldPage}else{j=e.pages[e.oldPageIndex]}l=e.oldPageIndex+k;c=e.pages[l].slice(0);a(c).each(function(r,s){if(s.get(0)===a(j[r]).get(0)){b=true}else{b=false}});if(e.appended&&b){if(e.pageIndex===0){l=e.pageIndex=e.pages.length-1}else{l=--e.pageIndex}c=e.pages[l].slice(0)}m=c[c.length-1].get(0);for(var d=j.length-1;d>=0;d--){if(m===a(j[d]).get(0)){n=false;p=d;break}else{n=true}}if(!n){while(p>=0){if(c[c.length-1].get(0)===j[p].get(0)){c.pop()}--p}}o._loadElements(c,"prev");f=q.width*c.length+(q.margin*c.length);if(q.orientation==="horizontal"){g={scrollLeft:0};h.scrollLeft(f)}else{g={scrollTop:0};h.scrollTop(f)}h.animate(g,q.speed,function(){o._removeOldElements("last",c.length);e.animated=false;if(!e.hoveredOver&&q.auto.enabled){clearInterval(e.interval);o._autoMode(q.auto.direction)}o._trigger("pageLoaded",null,{page:l})});e.appended=false},_goToNextPage:function(l){var c,k,f,m,g,j,n,p,b,h=a(this.element),q=this.options,e=h.data("data"),o=this;if(e.appended){k=e.oldPage}else{k=e.pages[e.oldPageIndex]}m=e.oldPageIndex+l;c=e.pages[m].slice(0);a(c).each(function(r,s){if(s.get(0)===a(k[r]).get(0)){b=true}else{b=false}});if(e.appended&&b){c=e.pages[++e.pageIndex].slice(0)}j=c[0].get(0);for(var d=0;dc.pages.length-1){c.pageIndex=0}this._goToNextPage(c.pageIndex-c.oldPageIndex);c.oldPageIndex=c.pageIndex}},prev:function(){var b=this.options,c=a(this.element).data("data");if(!c.animated){c.animated=true;if(!c.appended){--c.pageIndex}if(c.pageIndex<0){c.pageIndex=c.pages.length-1}this._goToPrevPage(c.pageIndex-c.oldPageIndex);c.oldPageIndex=c.pageIndex}},_removeOldElements:function(b,d){var e=a(this.element);for(var c=0;c");this._saveElements();this._generatePages();this._loadElements();this._setCarouselWidth();this._setCarouselHeight();a(c.navigation.next).click(function(f){b.next();f.preventDefault()});a(c.navigation.prev).click(function(f){b.prev();f.preventDefault()});d.navigation.next=a(c.navigation.next);d.navigation.prev=a(c.navigation.prev);e.hover(function(){if(c.auto.enabled){clearInterval(d.interval);d.hoveredOver=true}},function(){if(c.auto.enabled){d.hoveredOver=false;b._autoMode(c.auto.direction)}});this._setStep();if(c.auto.enabled){this._autoMode(c.auto.direction)}this._trigger("start")},_addElement:function(f,e){var d=a(this.element),c=d.find("div.rcarousel-wrapper"),b=this.options;f.width(b.width).height(b.height);if(b.orientation==="horizontal"){a(f).css("marginRight",b.margin)}else{a(f).css({marginBottom:b.margin,"float":"none"})}if(e==="prev"){c.prepend(f.clone(true,true))}else{c.append(f.clone(true,true))}},append:function(d){var c=a(this.element),b=c.data("data");d.each(function(e,f){b.paths.push(a(f))});b.oldPage=b.pages[b.oldPageIndex].slice(0);b.appended=true;this._generatePages()},_autoMode:function(d){var b=this.options,c=a(this.element).data("data");if(d==="next"){c.interval=setTimeout(a.proxy(this.next,this),b.auto.interval)}else{c.interval=setTimeout(a.proxy(this.prev,this),b.auto.interval)}},_checkOptionsValidity:function(c){var d,b=this,e="";a.each(c,function(f,g){switch(f){case"visible":if(!g||typeof g!=="number"||g<=0||(Math.ceil(g)-g>0)){throw new Error("visible should be defined as a positive integer")}break;case"step":if(!g||typeof g!=="number"||g<=0||(Math.ceil(g)-g>0)){throw new Error("step should be defined as a positive integer")}else{if(g>b.options.visible){for(d=1;d<=Math.floor(c.visible);d++){e+=(d0){throw new Error("width should be defined as a positive integer")}break;case"height":if(!g||typeof g!=="number"||g<=0||Math.ceil(g)-g>0){throw new Error("height should be defined as a positive integer")}break;case"speed":if(!g&&g!==0){throw new Error("speed should be defined as a number or a string")}if(typeof g==="number"&&g<0){throw new Error("speed should be a positive number")}else{if(typeof g==="string"&&!(g==="slow"||g==="normal"||g==="fast")){throw new Error('Only "slow", "normal" and "fast" values are valid')}}break;case"navigation":if(!g||a.isPlainObject(g)===false){throw new Error("navigation should be defined as an object with at least one of the properties: 'prev' or 'next' in it")}if(g.prev&&typeof g.prev!=="string"){throw new Error("navigation.prev should be defined as a string and point to '.class' or '#id' of an element")}if(g.next&&typeof g.next!=="string"){throw new Error(" navigation.next should be defined as a string and point to '.class' or '#id' of an element")}break;case"auto":if(typeof g.direction!=="string"){throw new Error("direction should be defined as a string")}if(!(g.direction==="next"||g.direction==="prev")){throw new Error("direction: only 'right' and 'left' values are valid")}if(isNaN(g.interval)||typeof g.interval!=="number"||g.interval<0||Math.ceil(g.interval)-g.interval>0){throw new Error("interval should be a positive number")}break;case"margin":if(isNaN(g)||typeof g!=="number"||g<0||Math.ceil(g)-g>0){throw new Error("margin should be a positive number")}break}})},_createDataObject:function(){var b=a(this.element);b.data("data",{paths:[],pathsLen:0,pages:[],lastPage:[],oldPageIndex:0,pageIndex:0,navigation:{},animated:false,appended:false,hoveredOver:false})},_generatePages:function(){var i=this,j=this.options,c=a(this.element).data("data"),b=j.visible,h=c.paths.length;function f(){c.pages=[];c.lastPage=[];c.pages[0]=[];for(var k=h-1;k>=h-b;k--){c.lastPage.unshift(c.paths[k])}for(var k=0;kh){k=h}if(k-mc.pages.length-1){d=c.pages.length-1}else{if(d<0){d=0}}c.pageIndex=d;b=d-c.oldPageIndex;if(b>=0){this._goToNextPage(b)}else{this._goToPrevPage(b)}c.oldPageIndex=d}},_loadElements:function(b,h){var k=this.options,e=a(this.element).data("data"),f=h||"next",j=b||e.pages[k.startAtPage],c=0,g=j.length;if(f==="next"){for(var d=c;d=c;d--){this._addElement(j[d],f)}}},_goToPrevPage:function(k){var c,j,f,l,g,m,n,p,b,h=a(this.element),o=this,q=this.options,e=a(this.element).data("data");if(e.appended){j=e.oldPage}else{j=e.pages[e.oldPageIndex]}l=e.oldPageIndex+k;c=e.pages[l].slice(0);a(c).each(function(r,s){if(s.get(0)===a(j[r]).get(0)){b=true}else{b=false}});if(e.appended&&b){if(e.pageIndex===0){l=e.pageIndex=e.pages.length-1}else{l=--e.pageIndex}c=e.pages[l].slice(0)}m=c[c.length-1].get(0);for(var d=j.length-1;d>=0;d--){if(m===a(j[d]).get(0)){n=false;p=d;break}else{n=true}}if(!n){while(p>=0){if(c[c.length-1].get(0)===j[p].get(0)){c.pop()}--p}}o._loadElements(c,"prev");f=q.width*c.length+(q.margin*c.length);if(q.orientation==="horizontal"){g={scrollLeft:0};h.scrollLeft(f)}else{g={scrollTop:0};h.scrollTop(f)}h.animate(g,q.speed,function(){o._removeOldElements("last",c.length);e.animated=false;if(!e.hoveredOver&&q.auto.enabled){clearInterval(e.interval);o._autoMode(q.auto.direction)}o._trigger("pageLoaded",null,{page:l})});e.appended=false},_goToNextPage:function(l){var c,k,f,m,g,j,n,p,b,h=a(this.element),q=this.options,e=h.data("data"),o=this;if(e.appended){k=e.oldPage}else{k=e.pages[e.oldPageIndex]}m=e.oldPageIndex+l;c=e.pages[m].slice(0);a(c).each(function(r,s){if(s.get(0)===a(k[r]).get(0)){b=true}else{b=false}});if(e.appended&&b){c=e.pages[++e.pageIndex].slice(0)}j=c[0].get(0);for(var d=0;dc.pages.length-1){c.pageIndex=0}this._goToNextPage(c.pageIndex-c.oldPageIndex);c.oldPageIndex=c.pageIndex}},prev:function(){var b=this.options,c=a(this.element).data("data");if(!c.animated){c.animated=true;if(!c.appended){--c.pageIndex}if(c.pageIndex<0){c.pageIndex=c.pages.length-1}this._goToPrevPage(c.pageIndex-c.oldPageIndex);c.oldPageIndex=c.pageIndex}},_removeOldElements:function(b,d){var e=a(this.element);for(var c=0;c