From b03a01f07b7b9f10600fbf2793f52abcf9463e3e Mon Sep 17 00:00:00 2001 From: Jason Newell Date: Thu, 7 Mar 2013 19:47:33 -0600 Subject: [PATCH 1/9] Stable. Continuous works with step=1 only. --- examples/continuous/ajax.html | 67 ++++ examples/continuous/auto_reverse.html | 104 +++++++ .../continuous/custom_step_and_visible.html | 102 ++++++ examples/continuous/gotopage.html | 121 +++++++ examples/continuous/html.html | 294 ++++++++++++++++++ examples/continuous/lightbox.html | 126 ++++++++ examples/continuous/links.html | 93 ++++++ examples/continuous/margin.html | 99 ++++++ examples/continuous/multi.html | 281 +++++++++++++++++ examples/continuous/simple.html | 52 ++++ examples/continuous/vertical.html | 101 ++++++ widget/lib/jquery.ui.rcarousel.js | 144 ++++++--- 12 files changed, 1537 insertions(+), 47 deletions(-) create mode 100644 examples/continuous/ajax.html create mode 100644 examples/continuous/auto_reverse.html create mode 100644 examples/continuous/custom_step_and_visible.html create mode 100644 examples/continuous/gotopage.html create mode 100644 examples/continuous/html.html create mode 100644 examples/continuous/lightbox.html create mode 100644 examples/continuous/links.html create mode 100644 examples/continuous/margin.html create mode 100644 examples/continuous/multi.html create mode 100644 examples/continuous/simple.html create mode 100644 examples/continuous/vertical.html diff --git a/examples/continuous/ajax.html b/examples/continuous/ajax.html new file mode 100644 index 0000000..a242e0d --- /dev/null +++ b/examples/continuous/ajax.html @@ -0,0 +1,67 @@ + + + + + rcarousel - load elements on demand + + + + + + + + +
+

Loading elements on demand.

+ + +

+ +

May not work locally in some browsers.

+
+ + + + + + + + diff --git a/examples/continuous/auto_reverse.html b/examples/continuous/auto_reverse.html new file mode 100644 index 0000000..4b749f2 --- /dev/null +++ b/examples/continuous/auto_reverse.html @@ -0,0 +1,104 @@ + + + + + rcarousel – Auto mode + + + + + + + + +
+

carousel with Auto mode, custom interval between slides and reversed direction

+ +
+ + next + prev +
+
+ + + + + + + diff --git a/examples/continuous/custom_step_and_visible.html b/examples/continuous/custom_step_and_visible.html new file mode 100644 index 0000000..7a8927d --- /dev/null +++ b/examples/continuous/custom_step_and_visible.html @@ -0,0 +1,102 @@ + + + + + rcarousel - custom step and visible + + + + + + + + +
+

custom number of visible elements (5) and step (2)

+
+ + next + prev +
+
+ + + + + + + diff --git a/examples/continuous/gotopage.html b/examples/continuous/gotopage.html new file mode 100644 index 0000000..eabf620 --- /dev/null +++ b/examples/continuous/gotopage.html @@ -0,0 +1,121 @@ + + + + + rcarousel – custom navigation + + + + + + + + +
+

more advanced example: callbacks, custom navigation and auto mode

+ +
+ +
+
+
+ + + + + + + diff --git a/examples/continuous/html.html b/examples/continuous/html.html new file mode 100644 index 0000000..8dab092 --- /dev/null +++ b/examples/continuous/html.html @@ -0,0 +1,294 @@ + + + + + rcarousel - html content + + + + + + + + + +
+

Any HTML element in slides

+ +
+ + next + prev +
+
+
+ + + + + + + + diff --git a/examples/continuous/lightbox.html b/examples/continuous/lightbox.html new file mode 100644 index 0000000..423fd8e --- /dev/null +++ b/examples/continuous/lightbox.html @@ -0,0 +1,126 @@ + + + + + rcarousel – carousel with a lightbox + + + + + + + + + + + +
+

rcarousel + rlightbox. Click on a thumb to see them in action.

+ +
+ +
+
+
+ + + + + + + + diff --git a/examples/continuous/links.html b/examples/continuous/links.html new file mode 100644 index 0000000..9d1914b --- /dev/null +++ b/examples/continuous/links.html @@ -0,0 +1,93 @@ + + + + + rcarousel - images with links + + + + + + + + +
+

images with links

+ +
+ + next + prev +
+
+ + + + + + + diff --git a/examples/continuous/margin.html b/examples/continuous/margin.html new file mode 100644 index 0000000..9c78868 --- /dev/null +++ b/examples/continuous/margin.html @@ -0,0 +1,99 @@ + + + + + rcarousel - margin between elements + + + + + + + + +
+

carousel with margin between elements

+ +
+ + next + prev +
+
+ + + + + + + diff --git a/examples/continuous/multi.html b/examples/continuous/multi.html new file mode 100644 index 0000000..f89f90c --- /dev/null +++ b/examples/continuous/multi.html @@ -0,0 +1,281 @@ + + + + + rcarousel – multi carousels on a page + + + + + + + + +
+

multiple carousels on a page

+ +
+
+ + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/examples/continuous/simple.html b/examples/continuous/simple.html new file mode 100644 index 0000000..52e23d3 --- /dev/null +++ b/examples/continuous/simple.html @@ -0,0 +1,52 @@ + + + + + rcarousel – simple carousel + + + + + + + + +
+

simple carousel without navigation but with Auto mode

+ + +
+ + + + + + + + diff --git a/examples/continuous/vertical.html b/examples/continuous/vertical.html new file mode 100644 index 0000000..6e44905 --- /dev/null +++ b/examples/continuous/vertical.html @@ -0,0 +1,101 @@ + + + + + rcarousel – vertical carousel + + + + + + + + +
+

vertical carousel

+ +
+ + next + prev +
+
+ + + + + + + diff --git a/widget/lib/jquery.ui.rcarousel.js b/widget/lib/jquery.ui.rcarousel.js index 4d89e4a..815662b 100644 --- a/widget/lib/jquery.ui.rcarousel.js +++ b/widget/lib/jquery.ui.rcarousel.js @@ -223,7 +223,7 @@ throw new Error( "margin should be a positive number" ); } break; - } + } } ); }, @@ -253,10 +253,21 @@ data = $( this.element ).data( "data" ), _visible = options.visible, _pathsLen = data.paths.length; - + + // when the continuous option is not used: // 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] + // comments below this that refer to pagination or our 'example' + // make the assumption that this continuous option is not set, + // or is set to a falsy value + + // when the continuous option is used: + // having 6 elements: A, B, C, D, E, F the algorithm + // creates 6 pages for 'visible: 1' and 'step: 1': + // [ABCDE], [BCDEF], [CDEFA], [DEFAB], [EFABC], [FABCD] + // be sure to test performance, because this is likely to increase your + // memory usage for large numbers of elements or steps other than 1 function _init() { // init creates the last page [FGHIJ] and remembers it @@ -267,8 +278,14 @@ // init last page for ( var i = _pathsLen - 1; i >= _pathsLen - _visible; i-- ) { - data.lastPage.unshift( data.paths[i] ); + console.log(i); + if ( options.continuous ) { + data.lastPage.unshift( data.paths[(_pathsLen - 1) % i] ); + } else { + data.lastPage.unshift( data.paths[i] ); + } } + console.log(data); // and first page for ( var i = 0; i < _visible; i++ ) { @@ -304,62 +321,84 @@ return _index; } - function _paginate() { - var _isBeginning = true, + function _paginate(continuous) { + + if ( continuous ) { + var _indicies; + + for ( var _index = 0; _index < _pathsLen; _index++ ) { + _indicies = []; + + for ( var i = _index; i < _index + _visible; i++ ) { + if ( i >= _pathsLen ) { + _indicies[_indicies.length] = i % ( _pathsLen ); + } else { + _indicies[_indicies.length] = i; + } + + } + + data.pages[_index] = []; + for ( var i in _indicies ) { + data.pages[_index].push( data.paths[_indicies[i]] ); + } + } + } else { + var _isBeginning = true, _complement = false, _start = options.step, _end, _index, _oldFirstEl, _oldLastEl; - // continue until you reach the last page - // we start from the 2nd page (1st page has been already initiated) - while ( !_islastPage(data.pages[data.pages.length - 1]) || _isBeginning ) { - _isBeginning = false; - - _end = _start + _visible; - - // we cannot exceed _pathsLen - 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 - // we must assure that we have always ‘visible’ (5 in our example) elements - if ( _end - _start < _visible ) { - _complement = true; - } else { - _complement = false; - } - - 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 ); + // continue until you reach the last page + // we start from the 2nd page (1st page has been already initiated) + while ( !_islastPage(data.pages[data.pages.length - 1]) || _isBeginning ) { + _isBeginning = false; + + _end = _start + _visible; + + // we cannot exceed _pathsLen + if ( _end > _pathsLen ) { + _end = _pathsLen; + } - // next step - _start += options.step; + // when we run ouf of elements (_end - _start < _visible) we must add the difference at the begining + // in our the 3rd page is [FGHIJ] and J element is added in the second step + // first we add [FGHI] as old elements + // we must assure that we have always ‘visible’ (5 in our example) elements + if ( _end - _start < _visible ) { + _complement = true; + } else { + _complement = false; + } + + 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; + } } } } // go! _init(); - _paginate(); + _paginate(options.continuous); }, + + getCurrentPage: function() { var data = $( this.element ).data( "data" ); return data.pageIndex + 1; @@ -422,6 +461,11 @@ self = this, options = this.options, data = $( this.element ).data( "data" ); + + if ( options.continuous ) { + // we are always loading a new page + self._trigger("pageLoading", null, {next: true}); + } // pick pages if ( data.appended ) { @@ -530,6 +574,11 @@ data = $root.data( "data" ), self = this; + if ( options.continuous ) { + // we are always loading a new page + self._trigger("pageLoading", null, {next: true}); + } + // pick pages if ( data.appended ) { _oldPage = data.oldPage; @@ -625,7 +674,7 @@ }); - // reset to deafult + // reset to default data.appended = false; }, @@ -731,6 +780,7 @@ } }, + _setStep: function(s) { // calculate a step var _step, From ccfc4152bc45e9e326d795a4d817f0eaac00328c Mon Sep 17 00:00:00 2001 From: Jason Newell Date: Thu, 7 Mar 2013 22:12:34 -0600 Subject: [PATCH 2/9] Continuous: true working with step: 2. Needs testing and cleanup. --- .../continuous/custom_step_and_visible.html | 4 +- widget/lib/jquery.ui.rcarousel.js | 88 +++++++++++++------ 2 files changed, 63 insertions(+), 29 deletions(-) diff --git a/examples/continuous/custom_step_and_visible.html b/examples/continuous/custom_step_and_visible.html index 7a8927d..787f35f 100644 --- a/examples/continuous/custom_step_and_visible.html +++ b/examples/continuous/custom_step_and_visible.html @@ -63,11 +63,9 @@

custom number of visible elements (5) and step (2)

- next prev @@ -81,7 +79,7 @@

custom number of visible elements (5) and step (2)

- - - - - - diff --git a/examples/continuous/lightbox.html b/examples/continuous/lightbox.html index 423fd8e..eaafb8f 100644 --- a/examples/continuous/lightbox.html +++ b/examples/continuous/lightbox.html @@ -35,12 +35,12 @@
-

rcarousel + rlightbox. Click on a thumb to see them in action.

+

rcarousel + rlightbox. Click on a thumb to see them in action.

@@ -44,7 +44,8 @@

simple carousel without navigation but with Auto mode

diff --git a/examples/continuous/vertical.html b/examples/continuous/vertical.html index 6e44905..b4b4bb6 100644 --- a/examples/continuous/vertical.html +++ b/examples/continuous/vertical.html @@ -50,7 +50,7 @@ @@ -82,7 +82,8 @@

vertical carousel

simple carousel without navigation but with Auto mode jQuery(function($) { $("#carousel").rcarousel({ auto: {enabled: true}, - seamless: true + seamless: { + enabled: true + } }); }); diff --git a/examples/continuous/vertical.html b/examples/continuous/vertical.html index b4b4bb6..cef0d07 100644 --- a/examples/continuous/vertical.html +++ b/examples/continuous/vertical.html @@ -83,7 +83,9 @@

vertical carousel

jQuery(function($) { $("#carousel").rcarousel({ orientation: "vertical", - seamless: true + seamless: { + enabled: true + } }); $( "#ui-carousel-next" ) diff --git a/widget/lib/jquery.ui.rcarousel.js b/widget/lib/jquery.ui.rcarousel.js index 6b63459..64c9964 100644 --- a/widget/lib/jquery.ui.rcarousel.js +++ b/widget/lib/jquery.ui.rcarousel.js @@ -280,7 +280,7 @@ data.lastPage = []; data.pages[0] = []; - if ( options.seamless ) { + if ( options.seamless.enabled ) { for ( var i = _visible - (_step + 1); i >= -_step; i-- ) { data.lastPage.unshift( data.paths[((_pathsLen + i) % _pathsLen)] ); } @@ -324,7 +324,7 @@ _start += _step; - if ( options.seamless || (data.pages.length * _visible) < _pathsLen ) { + if ( options.seamless.enabled || (data.pages.length * _visible) < _pathsLen ) { // when the seamless option is enabled, we will eventually create the last page in this loop for ( var i = _start; i < _start + _visible; i++ ) { data.pages[_index].push( data.paths[i % ( _pathsLen )] ); @@ -360,7 +360,7 @@ // to keep seamless scrolling, we'll only return the // count of pages before we start repeating elements // and round down to cut off partials - if (this.options.seamless) { + if ( !this.options.seamless.honestPageCount ) { return Math.floor(data.paths.length / this.options.visible); } else { return data.pages.length; @@ -792,6 +792,10 @@ navigation: { next: "#ui-carousel-next", prev: "#ui-carousel-prev" + }, + seamless: { + enabled: true, + honestPageCount: false } } }); From b1fb8fb59c93e75a5cfbaecf623f882f710e4d2a Mon Sep 17 00:00:00 2001 From: Jason Newell Date: Sun, 10 Mar 2013 22:12:27 -0500 Subject: [PATCH 6/9] Slight modification missed in last commit. --- widget/lib/jquery.ui.rcarousel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/widget/lib/jquery.ui.rcarousel.js b/widget/lib/jquery.ui.rcarousel.js index 64c9964..d4216e8 100644 --- a/widget/lib/jquery.ui.rcarousel.js +++ b/widget/lib/jquery.ui.rcarousel.js @@ -360,7 +360,7 @@ // to keep seamless scrolling, we'll only return the // count of pages before we start repeating elements // and round down to cut off partials - if ( !this.options.seamless.honestPageCount ) { + if ( this.options.seamless.enabled && !this.options.seamless.honestPageCount ) { return Math.floor(data.paths.length / this.options.visible); } else { return data.pages.length; @@ -794,7 +794,7 @@ prev: "#ui-carousel-prev" }, seamless: { - enabled: true, + enabled: false, honestPageCount: false } } From c5ff08137732ee0f0ecea177d2403ebac36ffb1d Mon Sep 17 00:00:00 2001 From: Jason Newell Date: Mon, 11 Mar 2013 00:45:52 -0500 Subject: [PATCH 7/9] Fixed logic error when returning USEFUL page count, created seamless.html example page --- examples/seamless.html | 329 ++++++++++++++++++++++++++++++ widget/lib/jquery.ui.rcarousel.js | 18 +- 2 files changed, 338 insertions(+), 9 deletions(-) create mode 100644 examples/seamless.html diff --git a/examples/seamless.html b/examples/seamless.html new file mode 100644 index 0000000..59bc835 --- /dev/null +++ b/examples/seamless.html @@ -0,0 +1,329 @@ + + + + + rcarousel – Auto mode + + + + + + + + +
+

seamless carousels always transition by the same step, even when cycling between the first and last elements

+ +

our autoreverse example with seamless enabled

+

compare to original example
(press "prev" arrow twice after page load)

+
+ + next + prev +
+ +

vertical carousel with seamless option enabled

+

compare to original example

+ +
+ + next + prev +
+ +

go to page example with USEFUL page count returned by plugin

+

compare to original example

+

if our last page starts over again on our first element
+ (total elements not equally divisible by step)
+ we cut it off to ensure smooth page transitions

+
+ +
+
+ +

go to page example with HONEST page count returned by plugin

+

compare to original example

+

this example, with honest page count enabled, should give a clearer
+ view of the pages created when you enable seamless page transitions
+ you will probably only ever need the (default) USEFUL page count
+ but you can get the actual value if you need it +

+
+ +
+
+
+ + + + + + + diff --git a/widget/lib/jquery.ui.rcarousel.js b/widget/lib/jquery.ui.rcarousel.js index d4216e8..0570389 100644 --- a/widget/lib/jquery.ui.rcarousel.js +++ b/widget/lib/jquery.ui.rcarousel.js @@ -217,7 +217,9 @@ throw new Error( "interval should be a positive number" ); } break; - + case "auto": + + case "margin": if ( isNaN(value) || typeof value !== "number" || value < 0 || Math.ceil(value) - value > 0 ) { throw new Error( "margin should be a positive number" ); @@ -267,13 +269,12 @@ // be sure to test performance, because this can increase your // memory usage in some cases // for example, 10 elements ([A..J]) with 'visible: 4' and 'step: 3' - // will generate 10 pages: - // [ABCD], [DEFG] … [HIJA] + // will generate 10 pages: [ABCD], [DEFG] … [HIJA] // please note that example comments below refer to // the page set that is created when the seamless option // is disabled, unless otherwise noted - + function _init() { // init creates the last page [FGHIJ] and remembers it data.pages = []; @@ -323,7 +324,7 @@ data.pages[_index] = []; _start += _step; - + if ( options.seamless.enabled || (data.pages.length * _visible) < _pathsLen ) { // when the seamless option is enabled, we will eventually create the last page in this loop for ( var i = _start; i < _start + _visible; i++ ) { @@ -357,11 +358,10 @@ // we create extra pages to enable seamless scrolling // this breaks demos like 'gotopage' and 'lightbox' - // to keep seamless scrolling, we'll only return the - // count of pages before we start repeating elements + // to keep seamless scrolling, we'll only return the count of pages before we start repeating elements // and round down to cut off partials if ( this.options.seamless.enabled && !this.options.seamless.honestPageCount ) { - return Math.floor(data.paths.length / this.options.visible); + return Math.floor(data.paths.length / this.options.step); } else { return data.pages.length; } @@ -613,7 +613,7 @@ if ( !data.hoveredOver && options.auto.enabled ) { // if autoMode is on and you change page manually clearInterval( data.interval ); - + self._autoMode( options.auto.direction ); } From b3832dd22e9218a620af4452e20ff77baa1221fb Mon Sep 17 00:00:00 2001 From: Jason Newell Date: Mon, 11 Mar 2013 00:48:47 -0500 Subject: [PATCH 8/9] Removed continuous sample folder, updated minified version of widget --- examples/continuous/ajax.html | 69 ---- examples/continuous/auto_reverse.html | 108 ------ .../continuous/custom_step_and_visible.html | 102 ------ examples/continuous/gotopage.html | 124 ------- examples/continuous/lightbox.html | 129 -------- examples/continuous/links.html | 96 ------ examples/continuous/margin.html | 102 ------ examples/continuous/multi.html | 308 ------------------ examples/continuous/remote.json | 11 - examples/continuous/simple.html | 55 ---- examples/continuous/vertical.html | 104 ------ widget/lib/jquery.ui.rcarousel.min.js | 2 +- 12 files changed, 1 insertion(+), 1209 deletions(-) delete mode 100644 examples/continuous/ajax.html delete mode 100644 examples/continuous/auto_reverse.html delete mode 100644 examples/continuous/custom_step_and_visible.html delete mode 100644 examples/continuous/gotopage.html delete mode 100644 examples/continuous/lightbox.html delete mode 100644 examples/continuous/links.html delete mode 100644 examples/continuous/margin.html delete mode 100644 examples/continuous/multi.html delete mode 100644 examples/continuous/remote.json delete mode 100644 examples/continuous/simple.html delete mode 100644 examples/continuous/vertical.html diff --git a/examples/continuous/ajax.html b/examples/continuous/ajax.html deleted file mode 100644 index 0927001..0000000 --- a/examples/continuous/ajax.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - rcarousel - load elements on demand - - - - - - - - -
-

Loading elements on demand.

- - -

- -

May not work locally in some browsers.

-
- - - - - - - - diff --git a/examples/continuous/auto_reverse.html b/examples/continuous/auto_reverse.html deleted file mode 100644 index 988359c..0000000 --- a/examples/continuous/auto_reverse.html +++ /dev/null @@ -1,108 +0,0 @@ - - - - - rcarousel – Auto mode - - - - - - - - -
-

carousel with Auto mode, custom interval between slides and reversed direction

- -
- - next - prev -
-
- - - - - - - diff --git a/examples/continuous/custom_step_and_visible.html b/examples/continuous/custom_step_and_visible.html deleted file mode 100644 index eae74f2..0000000 --- a/examples/continuous/custom_step_and_visible.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - rcarousel - custom step and visible - - - - - - - - -
-

custom number of visible elements (5) and step (2)

-
- - next - prev -
-
- - - - - - - diff --git a/examples/continuous/gotopage.html b/examples/continuous/gotopage.html deleted file mode 100644 index c160b0d..0000000 --- a/examples/continuous/gotopage.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - rcarousel – custom navigation - - - - - - - - -
-

more advanced example: callbacks, custom navigation and auto mode

- -
- -
-
-
- - - - - - - diff --git a/examples/continuous/lightbox.html b/examples/continuous/lightbox.html deleted file mode 100644 index 6900826..0000000 --- a/examples/continuous/lightbox.html +++ /dev/null @@ -1,129 +0,0 @@ - - - - - rcarousel – carousel with a lightbox - - - - - - - - - - - -
-

rcarousel + rlightbox. Click on a thumb to see them in action.

- -
- -
-
-
- - - - - - - - diff --git a/examples/continuous/links.html b/examples/continuous/links.html deleted file mode 100644 index 68c599d..0000000 --- a/examples/continuous/links.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - rcarousel - images with links - - - - - - - - -
-

images with links

- -
- - next - prev -
-
- - - - - - - diff --git a/examples/continuous/margin.html b/examples/continuous/margin.html deleted file mode 100644 index dc91c55..0000000 --- a/examples/continuous/margin.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - rcarousel - margin between elements - - - - - - - - -
-

carousel with margin between elements

- -
- - next - prev -
-
- - - - - - - diff --git a/examples/continuous/multi.html b/examples/continuous/multi.html deleted file mode 100644 index 0320449..0000000 --- a/examples/continuous/multi.html +++ /dev/null @@ -1,308 +0,0 @@ - - - - - rcarousel – multi carousels on a page - - - - - - - - -
-

multiple carousels on a page

- -
-
- - - - - - - - - - -
- -
- - - - - - - - - - -
- -
- - - - - - - - - - -
- -
- - - - - - - - - - -
- -
- - - - - - - - - - -
- -
- - - - - - - - - - -
- -
- - - - - - - - - - -
- -
- - - - - - - - - - -
- -
- - - - - - - - - - -
-
-
- - - - - - - - \ No newline at end of file diff --git a/examples/continuous/remote.json b/examples/continuous/remote.json deleted file mode 100644 index c075c89..0000000 --- a/examples/continuous/remote.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "paths": [ - "../images/004.jpg", - "../images/005.jpg", - "../images/006.jpg", - "../images/007.jpg", - "../images/008.jpg", - "../images/009.jpg", - "../images/010.jpg" - ] -} \ No newline at end of file diff --git a/examples/continuous/simple.html b/examples/continuous/simple.html deleted file mode 100644 index 9669ff9..0000000 --- a/examples/continuous/simple.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - rcarousel – simple carousel - - - - - - - - -
-

simple carousel without navigation but with Auto mode

- - -
- - - - - - - - diff --git a/examples/continuous/vertical.html b/examples/continuous/vertical.html deleted file mode 100644 index cef0d07..0000000 --- a/examples/continuous/vertical.html +++ /dev/null @@ -1,104 +0,0 @@ - - - - - rcarousel – vertical carousel - - - - - - - - -
-

vertical carousel

- -
- - next - prev -
-
- - - - - - - diff --git a/widget/lib/jquery.ui.rcarousel.min.js b/widget/lib/jquery.ui.rcarousel.min.js index cd37610..ee42bf9 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();$(options.navigation.next).click(function(event){_self.next();event.preventDefault();});$(options.navigation.prev).click(function(event){_self.prev();event.preventDefault();});data.navigation.next=$(options.navigation.next);data.navigation.prev=$(options.navigation.prev);$root.hover(function(){if(options.auto.enabled){clearInterval(data.interval);data.hoveredOver=true;}},function(){if(options.auto.enabled){data.hoveredOver=false;_self._autoMode(options.auto.direction);}});this._setStep();if(options.auto.enabled){this._autoMode(options.auto.direction);}this._trigger("start");},_addElement:function(jQueryElement,direction) {var $root=$(this.element),$content=$root.find( "div.wrapper" ),options=this.options;jQueryElement.width(options.width).height(options.height);if(options.orientation==="horizontal"){$(jQueryElement).css("marginRight",options.margin);}else{$(jQueryElement).css({marginBottom:options.margin,"float":"none"});}if(direction==="prev"){$content.prepend(jQueryElement.clone(true,true));}else{$content.append(jQueryElement.clone(true,true));}},append:function(jqElements){var $root=$(this.element),data=$root.data("data" );jqElements.each(function(i,el) {data.paths.push($(el));});data.oldPage=data.pages[data.oldPageIndex].slice(0);data.appended=true;this._generatePages();},_autoMode:function(direction){var options=this.options,data=$(this.element).data( "data" );if(direction==="next"){data.interval=setTimeout($.proxy(this.next,this),options.auto.interval);}else{data.interval=setTimeout($.proxy(this.prev,this),options.auto.interval);}},_checkOptionsValidity:function(options){var i,self=this,_correctSteps="";$.each(options,function(key,value){switch(key){case"visible":if(!value||typeof value!=="number"||value<=0||(Math.ceil(value)-value>0)){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");}else if(value>self.options.visible){for(i=1;i<=Math.floor(options.visible);i++){_correctSteps+=(i0){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"auto":case"margin":if(isNaN(value)||typeof value!=="number"||value<0||Math.ceil(value)-value>0){throw new Error("margin should be a positive number");}break;}});},_createDataObject:function(){var $root=$(this.element);$root.data("data",{paths:[],pathsLen:0,pages:[],lastPage:[],oldPageIndex:0,pageIndex:0,navigation:{},animated:false,appended:false,hoveredOver:false});},_generatePages:function(){var self=this,options=this.options,data=$(this.element).data("data"),_visible=options.visible,_step=options.step,_pathsLen=data.paths.length;function _init(){data.pages=[];data.lastPage=[];data.pages[0]=[];if(options.seamless.enabled){for(var i=_visible-(_step+1);i>=-_step;i--){data.lastPage.unshift(data.paths[((_pathsLen+i)%_pathsLen)]);}}else{for(var i=_pathsLen-1;i>=_pathsLen-_visible;i--){data.lastPage.unshift(data.paths[i]);}}for(var i=0;i<_visible;i++){data.pages[0][data.pages[0].length]=data.paths[i];}}function _islastPage(page){var _isLast=false;for(var i=0;i0;i--){data.pages[_index].push(data.paths[_pathsLen-i]);}}}}_init();_paginate();},getCurrentPage:function(){var data=$(this.element).data("data");return data.pageIndex+1;},getTotalPages:function(){var data=$(this.element).data("data");if(this.options.seamless.enabled&&!this.options.seamless.honestPageCount){return Math.floor(data.paths.length/this.options.step);}else{return data.pages.length;}},goToPage:function(page){var _by,data=$(this.element).data("data");if(!data.animated&&page!==data.pageIndex){data.animated=true;if(page>data.pages.length-1){page=data.pages.length-1;}else if(page<0){page=0;}data.pageIndex=page;_by=page-data.oldPageIndex;if(_by>=0){this._goToNextPage(_by);}else{this._goToPrevPage(_by);}data.oldPageIndex=page;}},_loadElements:function(elements,direction){var options=this.options,data=$(this.element).data("data"),_dir=direction||"next",_elem=elements||data.pages[options.startAtPage],_start=0,_end=_elem.length;if(_dir==="next"){for(var i=_start;i<_end;i++){this._addElement(_elem[i],_dir);}}else{for(var i=_end-1;i>=_start;i--){this._addElement(_elem[i],_dir);}}},_goToPrevPage:function(by){var _page,_oldPage,_dist,_index,_animOpts,$lastEl,_unique,_pos,_theSame,$root=$(this.element),self=this,options=this.options,data=$(this.element).data("data");if(data.appended) {_oldPage=data.oldPage;}else{_oldPage=data.pages[data.oldPageIndex];}_index=data.oldPageIndex+by;_page=data.pages[_index].slice(0);$(_page).each(function(i,el) {if(el.get(0)===$(_oldPage[i]).get(0)) {_theSame=true;}else{_theSame=false;}});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);}$lastEl=_page[_page.length-1].get(0);for(var i=_oldPage.length-1;i>=0;i--){if($lastEl===$(_oldPage[i]).get(0)){_unique=false;_pos=i;break;}else{_unique=true;}}if(!_unique){while(_pos>=0){if(_page[_page.length-1].get(0)===_oldPage[_pos].get(0)){_page.pop();}--_pos;}}self._loadElements(_page,"prev");_dist=options.width*_page.length+(options.margin*_page.length);if(options.orientation==="horizontal"){_animOpts={scrollLeft:0};$root.scrollLeft(_dist);}else{_animOpts={scrollTop:0};$root.scrollTop(_dist);}$root.animate(_animOpts,options.speed,function(){self._removeOldElements("last",_page.length);data.animated=false;if(!data.hoveredOver&&options.auto.enabled){clearInterval(data.interval);self._autoMode(options.auto.direction);}self._trigger("pageLoaded",null,{page:_index});});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"),self=this;if(data.appended) {_oldPage=data.oldPage;}else{_oldPage=data.pages[data.oldPageIndex];}_index=data.oldPageIndex+by;_page=data.pages[_index].slice(0);$(_page).each(function(i,el) {if(el.get(0)===$(_oldPage[i]).get(0)) {_theSame=true;}else{_theSame=false;}});if(data.appended&&_theSame) {_page=data.pages[++data.pageIndex].slice(0);}$firstEl=_page[0].get(0);for(var i=0;i<_page.length;i++){if($firstEl===$(_oldPage[i]).get(0)){_unique=false;_pos=i;break;}else{_unique=true;}}if(!_unique){while(_pos<_oldPage.length){if(_page[0].get(0)===_oldPage[_pos].get(0)){_page.shift();}++_pos;}}this._loadElements(_page,"next");_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){clearInterval(data.interval);self._autoMode(options.auto.direction);}self._trigger("pageLoaded",null,{page:_index});});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;}this._goToNextPage(data.pageIndex-data.oldPageIndex);data.oldPageIndex=data.pageIndex;}},prev:function(){var options=this.options,data=$(this.element).data("data");if(!data.animated){data.animated=true;if(!data.appended) {--data.pageIndex;}if(data.pageIndex<0){data.pageIndex=data.pages.length-1;}this._goToPrevPage(data.pageIndex-data.oldPageIndex);data.oldPageIndex=data.pageIndex;}},_removeOldElements:function(position,length){var $root=$(this.element);for(var i=0;i Date: Mon, 11 Mar 2013 19:33:57 -0500 Subject: [PATCH 9/9] Replaced "honestPageCount" with functionality that will stop page generation before elements repeat. This is a desirable option in cases where page selection controls are used instead of prev/next. --- examples/seamless.html | 39 +++++++++++++++++---------- widget/lib/jquery.ui.rcarousel.js | 23 +++++++--------- widget/lib/jquery.ui.rcarousel.min.js | 25 ++++++++++++++++- 3 files changed, 59 insertions(+), 28 deletions(-) diff --git a/examples/seamless.html b/examples/seamless.html index 59bc835..2473c0d 100644 --- a/examples/seamless.html +++ b/examples/seamless.html @@ -110,9 +110,16 @@ #pages3, #pages4 { width: 92px; - height: 18px; margin: 5px auto 0 auto; } + + #pages3 { + height: 18px; + } + + #pages4 { + height: 60px; + } @@ -166,11 +173,14 @@

compare to original example

prev
-

go to page example with USEFUL page count returned by plugin

+

go to page example with repeatElements disabled

compare to original example

-

if our last page starts over again on our first element
- (total elements not equally divisible by step)
- we cut it off to ensure smooth page transitions

+

when repeatElements is disabled, the plugin will stop
+ creating pages just before the first element is about to be
+ repeated
+ this is preferable if page selection controls are used
+ instead of prev/next +

-

go to page example with HONEST page count returned by plugin

+

go to page example with repeatElements enabled (default)

compare to original example

-

this example, with honest page count enabled, should give a clearer
- view of the pages created when you enable seamless page transitions
- you will probably only ever need the (default) USEFUL page count
- but you can get the actual value if you need it +

when repeatElements is enabled more pages may
+ be generated than expected
+ this example shows undesirable behavior in cases
+ where page counts are made known to the user +

");this._saveElements();this._generatePages();this._loadElements();this._setCarouselWidth();this._setCarouselHeight();$(options.navigation.next).click(function(event){_self.next();event.preventDefault()});$(options.navigation.prev).click(function(event){_self.prev(); +event.preventDefault()});data.navigation.next=$(options.navigation.next);data.navigation.prev=$(options.navigation.prev);$root.hover(function(){if(options.auto.enabled){clearInterval(data.interval);data.hoveredOver=true}},function(){if(options.auto.enabled){data.hoveredOver=false;_self._autoMode(options.auto.direction)}});this._setStep();if(options.auto.enabled)this._autoMode(options.auto.direction);this._trigger("start")},_addElement:function(jQueryElement,direction){var $root=$(this.element),$content= +$root.find("div.wrapper"),options=this.options;jQueryElement.width(options.width).height(options.height);if(options.orientation==="horizontal")$(jQueryElement).css("marginRight",options.margin);else $(jQueryElement).css({marginBottom:options.margin,"float":"none"});if(direction==="prev")$content.prepend(jQueryElement.clone(true,true));else $content.append(jQueryElement.clone(true,true))},append:function(jqElements){var $root=$(this.element),data=$root.data("data");jqElements.each(function(i,el){data.paths.push($(el))}); +data.oldPage=data.pages[data.oldPageIndex].slice(0);data.appended=true;this._generatePages()},_autoMode:function(direction){var options=this.options,data=$(this.element).data("data");if(direction==="next")data.interval=setTimeout($.proxy(this.next,this),options.auto.interval);else data.interval=setTimeout($.proxy(this.prev,this),options.auto.interval)},_checkOptionsValidity:function(options){var i,self=this,_correctSteps="";$.each(options,function(key,value){switch(key){case "visible":if(!value|| +typeof value!=="number"||value<=0||Math.ceil(value)-value>0)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");else if(value>self.options.visible){for(i=1;i<=Math.floor(options.visible);i++)_correctSteps+=i0)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 "auto":case "margin":if(isNaN(value)||typeof value!=="number"||value<0||Math.ceil(value)-value>0)throw new Error("margin should be a positive number");break}})},_createDataObject:function(){var $root=$(this.element);$root.data("data",{paths:[],pathsLen:0,pages:[],lastPage:[],oldPageIndex:0,pageIndex:0,navigation:{},animated:false,appended:false,hoveredOver:false})},_generatePages:function(){var self=this,options=this.options,data=$(this.element).data("data"),_visible=options.visible,_step= +options.step,_pathsLen=data.paths.length;function _init(){data.pages=[];data.lastPage=[];data.pages[0]=[];if(options.seamless.enabled&&options.seamless.repeatElements)for(var i=_visible-(_step+1);i>=-_step;i--)data.lastPage.unshift(data.paths[(_pathsLen+i)%_pathsLen]);else if(options.seamless.enabled&&!options.seamless.repeatElements){var _lastElement=_pathsLen-_pathsLen%_step-1;for(var i=_lastElement;i>_lastElement-_visible;i--)data.lastPage.unshift(data.paths[i])}else for(var i=_pathsLen-1;i>=_pathsLen- +_visible;i--)data.lastPage.unshift(data.paths[i]);for(var i=0;i<_visible;i++)data.pages[0][data.pages[0].length]=data.paths[i]}function _islastPage(page){var _isLast=false;for(var i=0;i0;i--)data.pages[_index].push(data.paths[_pathsLen-i])}}_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"); +if(!data.animated&&page!==data.pageIndex){data.animated=true;if(page>data.pages.length-1)page=data.pages.length-1;else if(page<0)page=0;data.pageIndex=page;_by=page-data.oldPageIndex;if(_by>=0)this._goToNextPage(_by);else this._goToPrevPage(_by);data.oldPageIndex=page}},_loadElements:function(elements,direction){var options=this.options,data=$(this.element).data("data"),_dir=direction||"next",_elem=elements||data.pages[options.startAtPage],_start=0,_end=_elem.length;if(_dir==="next")for(var i=_start;i< +_end;i++)this._addElement(_elem[i],_dir);else for(var i=_end-1;i>=_start;i--)this._addElement(_elem[i],_dir)},_goToPrevPage:function(by){var _page,_oldPage,_dist,_index,_animOpts,$lastEl,_unique,_pos,_theSame,$root=$(this.element),self=this,options=this.options,data=$(this.element).data("data");if(data.appended)_oldPage=data.oldPage;else _oldPage=data.pages[data.oldPageIndex];_index=data.oldPageIndex+by;_page=data.pages[_index].slice(0);$(_page).each(function(i,el){if(el.get(0)===$(_oldPage[i]).get(0))_theSame= +true;else _theSame=false});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)}$lastEl=_page[_page.length-1].get(0);for(var i=_oldPage.length-1;i>=0;i--)if($lastEl===$(_oldPage[i]).get(0)){_unique=false;_pos=i;break}else _unique=true;if(!_unique)while(_pos>=0){if(_page[_page.length-1].get(0)===_oldPage[_pos].get(0))_page.pop();--_pos}self._loadElements(_page,"prev");_dist=options.width*_page.length+ +options.margin*_page.length;if(options.orientation==="horizontal"){_animOpts={scrollLeft:0};$root.scrollLeft(_dist)}else{_animOpts={scrollTop:0};$root.scrollTop(_dist)}$root.animate(_animOpts,options.speed,function(){self._removeOldElements("last",_page.length);data.animated=false;if(!data.hoveredOver&&options.auto.enabled){clearInterval(data.interval);self._autoMode(options.auto.direction)}self._trigger("pageLoaded",null,{page:_index})});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"),self=this;if(data.appended)_oldPage=data.oldPage;else _oldPage=data.pages[data.oldPageIndex];_index=data.oldPageIndex+by;_page=data.pages[_index].slice(0);$(_page).each(function(i,el){if(el.get(0)===$(_oldPage[i]).get(0))_theSame=true;else _theSame=false});if(data.appended&&_theSame)_page=data.pages[++data.pageIndex].slice(0);$firstEl=_page[0].get(0);for(var i=0;i<_page.length;i++)if($firstEl=== +$(_oldPage[i]).get(0)){_unique=false;_pos=i;break}else _unique=true;if(!_unique)while(_pos<_oldPage.length){if(_page[0].get(0)===_oldPage[_pos].get(0))_page.shift();++_pos}this._loadElements(_page,"next");_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){clearInterval(data.interval);self._autoMode(options.auto.direction)}self._trigger("pageLoaded",null,{page:_index})});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;this._goToNextPage(data.pageIndex-data.oldPageIndex);data.oldPageIndex=data.pageIndex}}, +prev:function(){var options=this.options,data=$(this.element).data("data");if(!data.animated){data.animated=true;if(!data.appended)--data.pageIndex;if(data.pageIndex<0)data.pageIndex=data.pages.length-1;this._goToPrevPage(data.pageIndex-data.oldPageIndex);data.oldPageIndex=data.pageIndex}},_removeOldElements:function(position,length){var $root=$(this.element);for(var i=0;i