Skip to content
This repository
Browse code

Don't use own plugin registry, register directly to jQuery

  • Loading branch information...
commit c1c2b55be27df851d46ef0fa659b51102ef921de 1 parent 079b15b
Jan Sorgalla authored
12 dist/jquery.jcarousel-core.js
@@ -158,16 +158,8 @@
158 158 };
159 159 };
160 160
161   - var registry = {};
162   -
163 161 jCarousel.plugin = function(pluginName, pluginPrototype) {
164   - if (arguments.length === 1) {
165   - return typeof registry[pluginName] !== 'undefined' ?
166   - registry[pluginName] :
167   - $.error('Plugin with name ' + pluginName + ' does not exists');
168   - }
169   -
170   - var Plugin = registry[pluginName] = function(element, options) {
  162 + var Plugin = $[pluginName] = function(element, options) {
171 163 this._element = $(element);
172 164 this.options(options);
173 165
@@ -175,7 +167,7 @@
175 167 this.create();
176 168 };
177 169
178   - Plugin.prototype = $.extend(
  170 + Plugin.fn = Plugin.prototype = $.extend(
179 171 {},
180 172 jCarousel.base(pluginName),
181 173 pluginPrototype
2  dist/jquery.jcarousel-core.min.js
@@ -2,4 +2,4 @@
2 2 * http://sorgalla.com/jcarousel/
3 3 * Copyright 2012 Jan Sorgalla
4 4 * Released under the MIT license */
5   -(function(e){"use strict";var t=e.jCarousel={};t.version="0.3.0-beta";var n=/^([+\-]=)?(.+)$/;t.parseTarget=function(e){var t=!1,r=typeof e!="object"?n.exec(e):null;return r?(e=parseInt(r[2],10)||0,r[1]&&(t=!0,r[1]==="-="&&(e*=-1))):typeof e!="object"&&(e=parseInt(e,10)||0),{target:e,relative:t}},t.detectCarousel=function(e){var t;while(e.size()>0){t=e.filter("[data-jcarousel]");if(t.size()>0)return t;t=e.find("[data-jcarousel]");if(t.size()>0)return t;e=e.parent()}return null},t.base=function(n){return{version:t.version,_options:{},_element:null,_carousel:null,_init:e.noop,_create:e.noop,_destroy:e.noop,_reload:e.noop,create:function(){return this._element.attr("data-"+n.toLowerCase(),!0).data(n,this),!1===this._trigger("create")?this:(this._create(),this._trigger("createend"),this)},destroy:function(){return!1===this._trigger("destroy")?this:(this._destroy(),this._trigger("destroyend"),this._element.removeData(n).removeAttr("data-"+n.toLowerCase()),this)},reload:function(e){return!1===this._trigger("reload")?this:(e&&this.options(e),this._reload(),this._trigger("reloadend"),this)},element:function(){return this._element},options:function(t,n){if(arguments.length===0)return e.extend({},this._options);if(typeof t=="string"){if(typeof n=="undefined")return typeof this._options[t]=="undefined"?null:this._options[t];this._options[t]=n}else this._options=e.extend({},this._options,t);return this},carousel:function(){return this._carousel||(this._carousel=t.detectCarousel(this.options("carousel")||this._element),this._carousel||e.error('Could not detect carousel for plugin "'+n+'"')),this._carousel},_trigger:function(t,r,i){var s=e.Event((t+"."+n).toLowerCase());return(r||this._element).trigger(s,[this].concat(i||[])),!s.isDefaultPrevented()}}};var r={};t.plugin=function(n,i){if(arguments.length===1)return typeof r[n]!="undefined"?r[n]:e.error("Plugin with name "+n+" does not exists");var s=r[n]=function(t,n){this._element=e(t),this.options(n),this._init(),this.create()};return s.prototype=e.extend({},t.base(n),i),e.fn[n]=function(t){var r=Array.prototype.slice.call(arguments,1),i=this;return typeof t=="string"?this.each(function(){var s=e(this).data(n);if(!s)return e.error("Cannot call methods on "+n+" prior to initialization; "+'attempted to call method "'+t+'"');if(!e.isFunction(s[t])||t.charAt(0)==="_")return e.error('No such method "'+t+'" for '+n+" instance");var o=s[t].apply(s,r);if(o!==s&&typeof o!="undefined")return i=o,!1}):this.each(function(){var r=e(this).data(n);r?r.reload(t):new s(this,t)}),i},s}})(jQuery),function(e,t){"use strict";var n=function(e){return parseFloat(e)||0};e.jCarousel.plugin("jcarousel",{animating:!1,tail:0,inTail:!1,resizeTimer:null,lt:null,vertical:!1,rtl:!1,circular:!1,_options:{list:function(){return this.element().children().eq(0)},items:function(){return this.list().children()},animation:400,wrap:null,vertical:null,rtl:null,center:!1},_list:null,_items:null,_target:null,_first:null,_last:null,_visible:null,_fullyvisible:null,_init:function(){var t=this;return this.onWindowResize=function(){t.resizeTimer&&clearTimeout(t.resizeTimer),t.resizeTimer=setTimeout(function(){t.reload()},100)},this.onAnimationComplete=function(n){t.animating=!1;var r=t.list().find("[data-jcarousel-clone]");r.size()>0&&(r.remove(),t._reload()),t._trigger("animateend"),e.isFunction(n)&&n.call(t,!0)},this},_create:function(){this._reload(),e(t).bind("resize.jcarousel",this.onWindowResize)},_destroy:function(){e(t).unbind("resize.jcarousel",this.onWindowResize)},_reload:function(){this.vertical=this.options("vertical"),this.vertical==null&&(this.vertical=this.list().height()>this.list().width()),this.rtl=this.options("rtl"),this.rtl==null&&(this.rtl=function(t){if((""+t.attr("dir")).toLowerCase()==="rtl")return!0;var n=!1;return t.parents("[dir]").each(function(){if(/rtl/i.test(e(this).attr("dir")))return n=!0,!1}),n}(this._element)),this.lt=this.vertical?"top":"left",this._items=null;var t=this._target||this.closest();return this.circular=this.options("wrap")==="circular",t.size()>0?(this._prepare(t),this.list().find("[data-jcarousel-clone]").remove(),this._items=null,this.circular=this.options("wrap")==="circular"&&this._fullyvisible.size()<this.items().size(),this.list().css(this.lt,this._position(t)+"px")):this.list().css({left:0,top:0}),this},list:function(){if(this._list===null){var t=this.options("list");this._list=e.isFunction(t)?t.call(this):this._element.find(t)}return this._list},items:function(){if(this._items===null){var t=this.options("items");this._items=(e.isFunction(t)?t.call(this):this.list().find(t)).not("[data-jcarousel-clone]")}return this._items},closest:function(){var t=this,r=this.list().position()[this.lt],i=e(),s=!1,o=this.vertical?"bottom":this.rtl?"left":"right",u;return this.rtl&&!this.vertical&&(r=(r+this.list().width()-this.clipping())*-1),this.items().each(function(){i=e(this);if(s)return!1;var a=t.dimension(i);r+=a;if(r>=0){u=a-n(i.css("margin-"+o));if(!(Math.abs(r)-a+u/2<=0))return!1;s=!0}}),i},target:function(){return this._target},first:function(){return this._first},last:function(){return this._last},visible:function(){return this._visible},fullyvisible:function(){return this._fullyvisible},hasNext:function(){if(!1===this._trigger("hasnext"))return!0;var e=this.options("wrap"),t=this.items().size()-1;return t>=0&&(e&&e!=="first"||this._last.index()<t||this.tail&&!this.inTail)?!0:!1},hasPrev:function(){if(!1===this._trigger("hasprev"))return!0;var e=this.options("wrap");return this.items().size()>0&&(e&&e!=="last"||this._first.index()>0||this.tail&&this.inTail)?!0:!1},clipping:function(){return this._element["inner"+(this.vertical?"Height":"Width")]()},dimension:function(e){return e["outer"+(this.vertical?"Height":"Width")](!0)},scroll:function(t,r,i){if(this.animating)return this;if(!1===this._trigger("scroll",null,[t,r]))return this;e.isFunction(r)&&(i=r,r=!0);var s=e.jCarousel.parseTarget(t);if(s.relative){var o=this.items().size()-1,u=Math.abs(s.target),a=this.options("wrap"),f,l,c,h;if(s.target>0){var p=this._last.index();if(p>=o&&this.tail)this.inTail?a==="both"||a==="last"?this._scroll(0,r,i):this._scroll(Math.min(this._target.index()+u,o),r,i):this._scrollTail(r,i);else if(p!==o||a!=="both"&&a!=="last"){f=this._target.index(),l=f+u;if(this.circular&&l>o){h=o,c=this.items().get(-1);while(h++<l)c=this.items().eq(0),c.after(c.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(c),this._items=null;this._scroll(c,r,i)}else this._scroll(Math.min(l,o),r,i)}else this._scroll(0,r,i)}else if(this.inTail)this._scroll(Math.max(this._first.index()-u+1,0),r,i);else{f=this._first.index(),l=f-u;if(f!==0||a!=="both"&&a!=="first")if(this.circular&&l<0){h=l,c=this.items().get(0);while(h++<0){c=this.items().eq(-1),c.after(c.clone(!0).attr("data-jcarousel-clone",!0)),this.list().prepend(c),this._items=null;var d=n(this.list().css(this.lt)),v=this.dimension(c);this.rtl&&!this.vertical?d+=v:d-=v,this.list().css(this.lt,d+"px")}this._scroll(c,r,i)}else this._scroll(Math.max(f-u,0),r,i);else this._scroll(o,r,i)}}else this._scroll(s.target,r,i);return this._trigger("scrollend"),this},_scroll:function(t,r,i){if(this.animating)return e.isFunction(i)&&i.call(this,!1),this;typeof t!="object"?t=this.items().eq(t):typeof t.jquery=="undefined"&&(t=e(t));if(t.size()===0)return e.isFunction(i)&&i.call(this,!1),this;this.inTail=!1,this._prepare(t);var s=this._position(t),o=n(this.list().css(this.lt));if(s===o)return e.isFunction(i)&&i.call(this,!1),this;var u={};return u[this.lt]=s+"px",this._animate(u,r,i),this},_scrollTail:function(t,n){if(this.animating||!this.tail)return e.isFunction(n)&&n.call(this,!1),this;var r=this.list().position()[this.lt];this.rtl?r+=this.tail:r-=this.tail,this.inTail=!0;var i={};return i[this.lt]=r+"px",this._update({target:this._target.next(),fullyvisible:this._fullyvisible.slice(1).add(this._visible.last())}),this._animate(i,t,n),this},_animate:function(t,n,r){if(!1===this._trigger("animate"))return e.isFunction(r)&&r.call(this,!1),this;this.animating=!0;var i=this.options("animation");if(!i||n===!1)this.list().css(t),this.onAnimationComplete(r);else{var s=this;if(e.isFunction(i))i.call(this,t,function(){s.onAnimationComplete(r)});else{var o=typeof i=="object"?i:{duration:i},u=o.complete;o.complete=function(){s.onAnimationComplete(r),e.isFunction(u)&&u.call(this)},this.list().animate(t,o)}}return this},_prepare:function(t){var r=t.index(),i=r,s=this.dimension(t),o=this.clipping(),u=this.vertical?"bottom":this.rtl?"left":"right",a={target:t,first:t,last:t,visible:t,fullyvisible:s<=o?t:e()},f,l;this.options("center")&&(s/=2,o/=2);if(s<o)for(;;){f=this.items().eq(++i);if(f.size()===0){if(!this.circular)break;f=this.items().eq(0);if(t.get(0)===f.get(0))break;f.after(f.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(f),this._items=null}s+=this.dimension(f),a.last=f,a.visible=a.visible.add(f),l=n(f.css("margin-"+u)),s-l<=o&&(a.fullyvisible=a.fullyvisible.add(f));if(s>=o)break}if(!this.circular&&s<o){i=r;for(;;){if(--i<0)break;f=this.items().eq(i);if(f.size()===0)break;s+=this.dimension(f),a.first=f,a.visible=a.visible.add(f),l=n(f.css("margin-"+u)),s-l<=o&&(a.fullyvisible=a.fullyvisible.add(f));if(s>=o)break}}return this._update(a),this.tail=0,this.options("wrap")!=="circular"&&this.options("wrap")!=="custom"&&a.last.index()===this.items().size()-1&&(s-=n(a.last.css("margin-"+u)),s>o&&(this.tail=s-o)),this},_position:function(e){var t=this._first,n=t.position()[this.lt];return this.rtl&&!this.vertical&&(n-=this.clipping()-this.dimension(t)),this.options("center")&&(n-=this.clipping()/2-this.dimension(t)/2),(e.index()>t.index()||this.inTail)&&this.tail?(n=this.rtl?n-this.tail:n+this.tail,this.inTail=!0):this.inTail=!1,-n},_update:function(t){var n=this,r={target:this._target||e(),first:this._first||e(),last:this._last||e(),visible:this._visible||e(),fullyvisible:this._fullyvisible||e()},i=(t.first||r.first).index()<r.first.index(),s,o=function(s){var o=[],u=[];t[s].each(function(){r[s].index(this)<0&&o.push(this)}),r[s].each(function(){t[s].index(this)<0&&u.push(this)}),i?o=o.reverse():u=u.reverse(),n._trigger("item"+s+"in",e(o)),n._trigger("item"+s+"out",e(u)),n["_"+s]=t[s]};for(s in t)o(s);return this}})}(jQuery,window);
  5 +(function(e){"use strict";var t=e.jCarousel={};t.version="0.3.0-beta";var n=/^([+\-]=)?(.+)$/;t.parseTarget=function(e){var t=!1,r=typeof e!="object"?n.exec(e):null;return r?(e=parseInt(r[2],10)||0,r[1]&&(t=!0,r[1]==="-="&&(e*=-1))):typeof e!="object"&&(e=parseInt(e,10)||0),{target:e,relative:t}},t.detectCarousel=function(e){var t;while(e.size()>0){t=e.filter("[data-jcarousel]");if(t.size()>0)return t;t=e.find("[data-jcarousel]");if(t.size()>0)return t;e=e.parent()}return null},t.base=function(n){return{version:t.version,_options:{},_element:null,_carousel:null,_init:e.noop,_create:e.noop,_destroy:e.noop,_reload:e.noop,create:function(){return this._element.attr("data-"+n.toLowerCase(),!0).data(n,this),!1===this._trigger("create")?this:(this._create(),this._trigger("createend"),this)},destroy:function(){return!1===this._trigger("destroy")?this:(this._destroy(),this._trigger("destroyend"),this._element.removeData(n).removeAttr("data-"+n.toLowerCase()),this)},reload:function(e){return!1===this._trigger("reload")?this:(e&&this.options(e),this._reload(),this._trigger("reloadend"),this)},element:function(){return this._element},options:function(t,n){if(arguments.length===0)return e.extend({},this._options);if(typeof t=="string"){if(typeof n=="undefined")return typeof this._options[t]=="undefined"?null:this._options[t];this._options[t]=n}else this._options=e.extend({},this._options,t);return this},carousel:function(){return this._carousel||(this._carousel=t.detectCarousel(this.options("carousel")||this._element),this._carousel||e.error('Could not detect carousel for plugin "'+n+'"')),this._carousel},_trigger:function(t,r,i){var s=e.Event((t+"."+n).toLowerCase());return(r||this._element).trigger(s,[this].concat(i||[])),!s.isDefaultPrevented()}}},t.plugin=function(n,r){var i=e[n]=function(t,n){this._element=e(t),this.options(n),this._init(),this.create()};return i.fn=i.prototype=e.extend({},t.base(n),r),e.fn[n]=function(t){var r=Array.prototype.slice.call(arguments,1),s=this;return typeof t=="string"?this.each(function(){var i=e(this).data(n);if(!i)return e.error("Cannot call methods on "+n+" prior to initialization; "+'attempted to call method "'+t+'"');if(!e.isFunction(i[t])||t.charAt(0)==="_")return e.error('No such method "'+t+'" for '+n+" instance");var o=i[t].apply(i,r);if(o!==i&&typeof o!="undefined")return s=o,!1}):this.each(function(){var r=e(this).data(n);r?r.reload(t):new i(this,t)}),s},i}})(jQuery),function(e,t){"use strict";var n=function(e){return parseFloat(e)||0};e.jCarousel.plugin("jcarousel",{animating:!1,tail:0,inTail:!1,resizeTimer:null,lt:null,vertical:!1,rtl:!1,circular:!1,_options:{list:function(){return this.element().children().eq(0)},items:function(){return this.list().children()},animation:400,wrap:null,vertical:null,rtl:null,center:!1},_list:null,_items:null,_target:null,_first:null,_last:null,_visible:null,_fullyvisible:null,_init:function(){var t=this;return this.onWindowResize=function(){t.resizeTimer&&clearTimeout(t.resizeTimer),t.resizeTimer=setTimeout(function(){t.reload()},100)},this.onAnimationComplete=function(n){t.animating=!1;var r=t.list().find("[data-jcarousel-clone]");r.size()>0&&(r.remove(),t._reload()),t._trigger("animateend"),e.isFunction(n)&&n.call(t,!0)},this},_create:function(){this._reload(),e(t).bind("resize.jcarousel",this.onWindowResize)},_destroy:function(){e(t).unbind("resize.jcarousel",this.onWindowResize)},_reload:function(){this.vertical=this.options("vertical"),this.vertical==null&&(this.vertical=this.list().height()>this.list().width()),this.rtl=this.options("rtl"),this.rtl==null&&(this.rtl=function(t){if((""+t.attr("dir")).toLowerCase()==="rtl")return!0;var n=!1;return t.parents("[dir]").each(function(){if(/rtl/i.test(e(this).attr("dir")))return n=!0,!1}),n}(this._element)),this.lt=this.vertical?"top":"left",this._items=null;var t=this._target||this.closest();return this.circular=this.options("wrap")==="circular",t.size()>0?(this._prepare(t),this.list().find("[data-jcarousel-clone]").remove(),this._items=null,this.circular=this.options("wrap")==="circular"&&this._fullyvisible.size()<this.items().size(),this.list().css(this.lt,this._position(t)+"px")):this.list().css({left:0,top:0}),this},list:function(){if(this._list===null){var t=this.options("list");this._list=e.isFunction(t)?t.call(this):this._element.find(t)}return this._list},items:function(){if(this._items===null){var t=this.options("items");this._items=(e.isFunction(t)?t.call(this):this.list().find(t)).not("[data-jcarousel-clone]")}return this._items},closest:function(){var t=this,r=this.list().position()[this.lt],i=e(),s=!1,o=this.vertical?"bottom":this.rtl?"left":"right",u;return this.rtl&&!this.vertical&&(r=(r+this.list().width()-this.clipping())*-1),this.items().each(function(){i=e(this);if(s)return!1;var a=t.dimension(i);r+=a;if(r>=0){u=a-n(i.css("margin-"+o));if(!(Math.abs(r)-a+u/2<=0))return!1;s=!0}}),i},target:function(){return this._target},first:function(){return this._first},last:function(){return this._last},visible:function(){return this._visible},fullyvisible:function(){return this._fullyvisible},hasNext:function(){if(!1===this._trigger("hasnext"))return!0;var e=this.options("wrap"),t=this.items().size()-1;return t>=0&&(e&&e!=="first"||this._last.index()<t||this.tail&&!this.inTail)?!0:!1},hasPrev:function(){if(!1===this._trigger("hasprev"))return!0;var e=this.options("wrap");return this.items().size()>0&&(e&&e!=="last"||this._first.index()>0||this.tail&&this.inTail)?!0:!1},clipping:function(){return this._element["inner"+(this.vertical?"Height":"Width")]()},dimension:function(e){return e["outer"+(this.vertical?"Height":"Width")](!0)},scroll:function(t,r,i){if(this.animating)return this;if(!1===this._trigger("scroll",null,[t,r]))return this;e.isFunction(r)&&(i=r,r=!0);var s=e.jCarousel.parseTarget(t);if(s.relative){var o=this.items().size()-1,u=Math.abs(s.target),a=this.options("wrap"),f,l,c,h;if(s.target>0){var p=this._last.index();if(p>=o&&this.tail)this.inTail?a==="both"||a==="last"?this._scroll(0,r,i):this._scroll(Math.min(this._target.index()+u,o),r,i):this._scrollTail(r,i);else if(p!==o||a!=="both"&&a!=="last"){f=this._target.index(),l=f+u;if(this.circular&&l>o){h=o,c=this.items().get(-1);while(h++<l)c=this.items().eq(0),c.after(c.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(c),this._items=null;this._scroll(c,r,i)}else this._scroll(Math.min(l,o),r,i)}else this._scroll(0,r,i)}else if(this.inTail)this._scroll(Math.max(this._first.index()-u+1,0),r,i);else{f=this._first.index(),l=f-u;if(f!==0||a!=="both"&&a!=="first")if(this.circular&&l<0){h=l,c=this.items().get(0);while(h++<0){c=this.items().eq(-1),c.after(c.clone(!0).attr("data-jcarousel-clone",!0)),this.list().prepend(c),this._items=null;var d=n(this.list().css(this.lt)),v=this.dimension(c);this.rtl&&!this.vertical?d+=v:d-=v,this.list().css(this.lt,d+"px")}this._scroll(c,r,i)}else this._scroll(Math.max(f-u,0),r,i);else this._scroll(o,r,i)}}else this._scroll(s.target,r,i);return this._trigger("scrollend"),this},_scroll:function(t,r,i){if(this.animating)return e.isFunction(i)&&i.call(this,!1),this;typeof t!="object"?t=this.items().eq(t):typeof t.jquery=="undefined"&&(t=e(t));if(t.size()===0)return e.isFunction(i)&&i.call(this,!1),this;this.inTail=!1,this._prepare(t);var s=this._position(t),o=n(this.list().css(this.lt));if(s===o)return e.isFunction(i)&&i.call(this,!1),this;var u={};return u[this.lt]=s+"px",this._animate(u,r,i),this},_scrollTail:function(t,n){if(this.animating||!this.tail)return e.isFunction(n)&&n.call(this,!1),this;var r=this.list().position()[this.lt];this.rtl?r+=this.tail:r-=this.tail,this.inTail=!0;var i={};return i[this.lt]=r+"px",this._update({target:this._target.next(),fullyvisible:this._fullyvisible.slice(1).add(this._visible.last())}),this._animate(i,t,n),this},_animate:function(t,n,r){if(!1===this._trigger("animate"))return e.isFunction(r)&&r.call(this,!1),this;this.animating=!0;var i=this.options("animation");if(!i||n===!1)this.list().css(t),this.onAnimationComplete(r);else{var s=this;if(e.isFunction(i))i.call(this,t,function(){s.onAnimationComplete(r)});else{var o=typeof i=="object"?i:{duration:i},u=o.complete;o.complete=function(){s.onAnimationComplete(r),e.isFunction(u)&&u.call(this)},this.list().animate(t,o)}}return this},_prepare:function(t){var r=t.index(),i=r,s=this.dimension(t),o=this.clipping(),u=this.vertical?"bottom":this.rtl?"left":"right",a={target:t,first:t,last:t,visible:t,fullyvisible:s<=o?t:e()},f,l;this.options("center")&&(s/=2,o/=2);if(s<o)for(;;){f=this.items().eq(++i);if(f.size()===0){if(!this.circular)break;f=this.items().eq(0);if(t.get(0)===f.get(0))break;f.after(f.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(f),this._items=null}s+=this.dimension(f),a.last=f,a.visible=a.visible.add(f),l=n(f.css("margin-"+u)),s-l<=o&&(a.fullyvisible=a.fullyvisible.add(f));if(s>=o)break}if(!this.circular&&s<o){i=r;for(;;){if(--i<0)break;f=this.items().eq(i);if(f.size()===0)break;s+=this.dimension(f),a.first=f,a.visible=a.visible.add(f),l=n(f.css("margin-"+u)),s-l<=o&&(a.fullyvisible=a.fullyvisible.add(f));if(s>=o)break}}return this._update(a),this.tail=0,this.options("wrap")!=="circular"&&this.options("wrap")!=="custom"&&a.last.index()===this.items().size()-1&&(s-=n(a.last.css("margin-"+u)),s>o&&(this.tail=s-o)),this},_position:function(e){var t=this._first,n=t.position()[this.lt];return this.rtl&&!this.vertical&&(n-=this.clipping()-this.dimension(t)),this.options("center")&&(n-=this.clipping()/2-this.dimension(t)/2),(e.index()>t.index()||this.inTail)&&this.tail?(n=this.rtl?n-this.tail:n+this.tail,this.inTail=!0):this.inTail=!1,-n},_update:function(t){var n=this,r={target:this._target||e(),first:this._first||e(),last:this._last||e(),visible:this._visible||e(),fullyvisible:this._fullyvisible||e()},i=(t.first||r.first).index()<r.first.index(),s,o=function(s){var o=[],u=[];t[s].each(function(){r[s].index(this)<0&&o.push(this)}),r[s].each(function(){t[s].index(this)<0&&u.push(this)}),i?o=o.reverse():u=u.reverse(),n._trigger("item"+s+"in",e(o)),n._trigger("item"+s+"out",e(u)),n["_"+s]=t[s]};for(s in t)o(s);return this}})}(jQuery,window);
70 dist/jquery.jcarousel-scrollintoview.js
@@ -6,54 +6,52 @@
6 6 (function($) {
7 7 'use strict';
8 8
9   - $.extend($.jCarousel.plugin('jcarousel').prototype, {
10   - scrollIntoView: function(target, animate, callback) {
11   - var items = this.items(),
12   - index = typeof target !== 'object' ? target : items.index(target),
13   - first = this._fullyvisible.first().index();
14   -
15   - if (index < first) {
16   - return this.scroll(index, animate, callback);
17   - }
  9 + $.jcarousel.fn.scrollIntoView = function(target, animate, callback) {
  10 + var items = this.items(),
  11 + index = typeof target !== 'object' ? target : items.index(target),
  12 + first = this._fullyvisible.first().index();
18 13
19   - if (index >= first && index <= this._fullyvisible.last().index()) {
20   - if ($.isFunction(callback)) {
21   - callback.call(this, false);
22   - }
  14 + if (index < first) {
  15 + return this.scroll(index, animate, callback);
  16 + }
23 17
24   - return this;
  18 + if (index >= first && index <= this._fullyvisible.last().index()) {
  19 + if ($.isFunction(callback)) {
  20 + callback.call(this, false);
25 21 }
26 22
27   - var clip = this.clipping(),
28   - lrb = this.vertical ? 'bottom' : (this.rtl ? 'left' : 'right'),
29   - wh = 0,
30   - curr;
  23 + return this;
  24 + }
31 25
32   - while (true) {
33   - curr = items.eq(index);
  26 + var clip = this.clipping(),
  27 + lrb = this.vertical ? 'bottom' : (this.rtl ? 'left' : 'right'),
  28 + wh = 0,
  29 + curr;
34 30
35   - if (curr.size() === 0) {
36   - break;
37   - }
  31 + while (true) {
  32 + curr = items.eq(index);
38 33
39   - wh += this.dimension(curr);
  34 + if (curr.size() === 0) {
  35 + break;
  36 + }
40 37
41   - if (wh >= clip) {
42   - var margin = parseFloat(curr.css('margin-' + lrb)) || 0;
43   - if ((wh - margin) !== clip) {
44   - index++;
45   - }
46   - break;
47   - }
  38 + wh += this.dimension(curr);
48 39
49   - if (index <= 0) {
50   - break;
  40 + if (wh >= clip) {
  41 + var margin = parseFloat(curr.css('margin-' + lrb)) || 0;
  42 + if ((wh - margin) !== clip) {
  43 + index++;
51 44 }
  45 + break;
  46 + }
52 47
53   - index--;
  48 + if (index <= 0) {
  49 + break;
54 50 }
55 51
56   - return this.scroll(index, animate, callback);
  52 + index--;
57 53 }
58   - });
  54 +
  55 + return this.scroll(index, animate, callback);
  56 + };
59 57 }(jQuery));
2  dist/jquery.jcarousel-scrollintoview.min.js
@@ -2,4 +2,4 @@
2 2 * http://sorgalla.com/jcarousel/
3 3 * Copyright 2012 Jan Sorgalla
4 4 * Released under the MIT license */
5   -(function(e){"use strict";e.extend(e.jCarousel.plugin("jcarousel").prototype,{scrollIntoView:function(t,n,r){var i=this.items(),s=typeof t!="object"?t:i.index(t),o=this._fullyvisible.first().index();if(s<o)return this.scroll(s,n,r);if(s>=o&&s<=this._fullyvisible.last().index())return e.isFunction(r)&&r.call(this,!1),this;var u=this.clipping(),a=this.vertical?"bottom":this.rtl?"left":"right",f=0,l;for(;;){l=i.eq(s);if(l.size()===0)break;f+=this.dimension(l);if(f>=u){var c=parseFloat(l.css("margin-"+a))||0;f-c!==u&&s++;break}if(s<=0)break;s--}return this.scroll(s,n,r)}})})(jQuery);
  5 +(function(e){"use strict";e.jcarousel.fn.scrollIntoView=function(t,n,r){var i=this.items(),s=typeof t!="object"?t:i.index(t),o=this._fullyvisible.first().index();if(s<o)return this.scroll(s,n,r);if(s>=o&&s<=this._fullyvisible.last().index())return e.isFunction(r)&&r.call(this,!1),this;var u=this.clipping(),a=this.vertical?"bottom":this.rtl?"left":"right",f=0,l;for(;;){l=i.eq(s);if(l.size()===0)break;f+=this.dimension(l);if(f>=u){var c=parseFloat(l.css("margin-"+a))||0;f-c!==u&&s++;break}if(s<=0)break;s--}return this.scroll(s,n,r)}})(jQuery);
82 dist/jquery.jcarousel.js
@@ -158,16 +158,8 @@
158 158 };
159 159 };
160 160
161   - var registry = {};
162   -
163 161 jCarousel.plugin = function(pluginName, pluginPrototype) {
164   - if (arguments.length === 1) {
165   - return typeof registry[pluginName] !== 'undefined' ?
166   - registry[pluginName] :
167   - $.error('Plugin with name ' + pluginName + ' does not exists');
168   - }
169   -
170   - var Plugin = registry[pluginName] = function(element, options) {
  162 + var Plugin = $[pluginName] = function(element, options) {
171 163 this._element = $(element);
172 164 this.options(options);
173 165
@@ -175,7 +167,7 @@
175 167 this.create();
176 168 };
177 169
178   - Plugin.prototype = $.extend(
  170 + Plugin.fn = Plugin.prototype = $.extend(
179 171 {},
180 172 jCarousel.base(pluginName),
181 173 pluginPrototype
@@ -878,56 +870,54 @@
878 870 (function($) {
879 871 'use strict';
880 872
881   - $.extend($.jCarousel.plugin('jcarousel').prototype, {
882   - scrollIntoView: function(target, animate, callback) {
883   - var items = this.items(),
884   - index = typeof target !== 'object' ? target : items.index(target),
885   - first = this._fullyvisible.first().index();
886   -
887   - if (index < first) {
888   - return this.scroll(index, animate, callback);
889   - }
  873 + $.jcarousel.fn.scrollIntoView = function(target, animate, callback) {
  874 + var items = this.items(),
  875 + index = typeof target !== 'object' ? target : items.index(target),
  876 + first = this._fullyvisible.first().index();
890 877
891   - if (index >= first && index <= this._fullyvisible.last().index()) {
892   - if ($.isFunction(callback)) {
893   - callback.call(this, false);
894   - }
  878 + if (index < first) {
  879 + return this.scroll(index, animate, callback);
  880 + }
895 881
896   - return this;
  882 + if (index >= first && index <= this._fullyvisible.last().index()) {
  883 + if ($.isFunction(callback)) {
  884 + callback.call(this, false);
897 885 }
898 886
899   - var clip = this.clipping(),
900   - lrb = this.vertical ? 'bottom' : (this.rtl ? 'left' : 'right'),
901   - wh = 0,
902   - curr;
  887 + return this;
  888 + }
903 889
904   - while (true) {
905   - curr = items.eq(index);
  890 + var clip = this.clipping(),
  891 + lrb = this.vertical ? 'bottom' : (this.rtl ? 'left' : 'right'),
  892 + wh = 0,
  893 + curr;
906 894
907   - if (curr.size() === 0) {
908   - break;
909   - }
  895 + while (true) {
  896 + curr = items.eq(index);
910 897
911   - wh += this.dimension(curr);
  898 + if (curr.size() === 0) {
  899 + break;
  900 + }
912 901
913   - if (wh >= clip) {
914   - var margin = parseFloat(curr.css('margin-' + lrb)) || 0;
915   - if ((wh - margin) !== clip) {
916   - index++;
917   - }
918   - break;
919   - }
  902 + wh += this.dimension(curr);
920 903
921   - if (index <= 0) {
922   - break;
  904 + if (wh >= clip) {
  905 + var margin = parseFloat(curr.css('margin-' + lrb)) || 0;
  906 + if ((wh - margin) !== clip) {
  907 + index++;
923 908 }
  909 + break;
  910 + }
924 911
925   - index--;
  912 + if (index <= 0) {
  913 + break;
926 914 }
927 915
928   - return this.scroll(index, animate, callback);
  916 + index--;
929 917 }
930   - });
  918 +
  919 + return this.scroll(index, animate, callback);
  920 + };
931 921 }(jQuery));
932 922
933 923 (function($) {
2  dist/jquery.jcarousel.min.js
@@ -2,4 +2,4 @@
2 2 * http://sorgalla.com/jcarousel/
3 3 * Copyright 2012 Jan Sorgalla
4 4 * Released under the MIT license */
5   -(function(e){"use strict";var t=e.jCarousel={};t.version="0.3.0-beta";var n=/^([+\-]=)?(.+)$/;t.parseTarget=function(e){var t=!1,r=typeof e!="object"?n.exec(e):null;return r?(e=parseInt(r[2],10)||0,r[1]&&(t=!0,r[1]==="-="&&(e*=-1))):typeof e!="object"&&(e=parseInt(e,10)||0),{target:e,relative:t}},t.detectCarousel=function(e){var t;while(e.size()>0){t=e.filter("[data-jcarousel]");if(t.size()>0)return t;t=e.find("[data-jcarousel]");if(t.size()>0)return t;e=e.parent()}return null},t.base=function(n){return{version:t.version,_options:{},_element:null,_carousel:null,_init:e.noop,_create:e.noop,_destroy:e.noop,_reload:e.noop,create:function(){return this._element.attr("data-"+n.toLowerCase(),!0).data(n,this),!1===this._trigger("create")?this:(this._create(),this._trigger("createend"),this)},destroy:function(){return!1===this._trigger("destroy")?this:(this._destroy(),this._trigger("destroyend"),this._element.removeData(n).removeAttr("data-"+n.toLowerCase()),this)},reload:function(e){return!1===this._trigger("reload")?this:(e&&this.options(e),this._reload(),this._trigger("reloadend"),this)},element:function(){return this._element},options:function(t,n){if(arguments.length===0)return e.extend({},this._options);if(typeof t=="string"){if(typeof n=="undefined")return typeof this._options[t]=="undefined"?null:this._options[t];this._options[t]=n}else this._options=e.extend({},this._options,t);return this},carousel:function(){return this._carousel||(this._carousel=t.detectCarousel(this.options("carousel")||this._element),this._carousel||e.error('Could not detect carousel for plugin "'+n+'"')),this._carousel},_trigger:function(t,r,i){var s=e.Event((t+"."+n).toLowerCase());return(r||this._element).trigger(s,[this].concat(i||[])),!s.isDefaultPrevented()}}};var r={};t.plugin=function(n,i){if(arguments.length===1)return typeof r[n]!="undefined"?r[n]:e.error("Plugin with name "+n+" does not exists");var s=r[n]=function(t,n){this._element=e(t),this.options(n),this._init(),this.create()};return s.prototype=e.extend({},t.base(n),i),e.fn[n]=function(t){var r=Array.prototype.slice.call(arguments,1),i=this;return typeof t=="string"?this.each(function(){var s=e(this).data(n);if(!s)return e.error("Cannot call methods on "+n+" prior to initialization; "+'attempted to call method "'+t+'"');if(!e.isFunction(s[t])||t.charAt(0)==="_")return e.error('No such method "'+t+'" for '+n+" instance");var o=s[t].apply(s,r);if(o!==s&&typeof o!="undefined")return i=o,!1}):this.each(function(){var r=e(this).data(n);r?r.reload(t):new s(this,t)}),i},s}})(jQuery),function(e,t){"use strict";var n=function(e){return parseFloat(e)||0};e.jCarousel.plugin("jcarousel",{animating:!1,tail:0,inTail:!1,resizeTimer:null,lt:null,vertical:!1,rtl:!1,circular:!1,_options:{list:function(){return this.element().children().eq(0)},items:function(){return this.list().children()},animation:400,wrap:null,vertical:null,rtl:null,center:!1},_list:null,_items:null,_target:null,_first:null,_last:null,_visible:null,_fullyvisible:null,_init:function(){var t=this;return this.onWindowResize=function(){t.resizeTimer&&clearTimeout(t.resizeTimer),t.resizeTimer=setTimeout(function(){t.reload()},100)},this.onAnimationComplete=function(n){t.animating=!1;var r=t.list().find("[data-jcarousel-clone]");r.size()>0&&(r.remove(),t._reload()),t._trigger("animateend"),e.isFunction(n)&&n.call(t,!0)},this},_create:function(){this._reload(),e(t).bind("resize.jcarousel",this.onWindowResize)},_destroy:function(){e(t).unbind("resize.jcarousel",this.onWindowResize)},_reload:function(){this.vertical=this.options("vertical"),this.vertical==null&&(this.vertical=this.list().height()>this.list().width()),this.rtl=this.options("rtl"),this.rtl==null&&(this.rtl=function(t){if((""+t.attr("dir")).toLowerCase()==="rtl")return!0;var n=!1;return t.parents("[dir]").each(function(){if(/rtl/i.test(e(this).attr("dir")))return n=!0,!1}),n}(this._element)),this.lt=this.vertical?"top":"left",this._items=null;var t=this._target||this.closest();return this.circular=this.options("wrap")==="circular",t.size()>0?(this._prepare(t),this.list().find("[data-jcarousel-clone]").remove(),this._items=null,this.circular=this.options("wrap")==="circular"&&this._fullyvisible.size()<this.items().size(),this.list().css(this.lt,this._position(t)+"px")):this.list().css({left:0,top:0}),this},list:function(){if(this._list===null){var t=this.options("list");this._list=e.isFunction(t)?t.call(this):this._element.find(t)}return this._list},items:function(){if(this._items===null){var t=this.options("items");this._items=(e.isFunction(t)?t.call(this):this.list().find(t)).not("[data-jcarousel-clone]")}return this._items},closest:function(){var t=this,r=this.list().position()[this.lt],i=e(),s=!1,o=this.vertical?"bottom":this.rtl?"left":"right",u;return this.rtl&&!this.vertical&&(r=(r+this.list().width()-this.clipping())*-1),this.items().each(function(){i=e(this);if(s)return!1;var a=t.dimension(i);r+=a;if(r>=0){u=a-n(i.css("margin-"+o));if(!(Math.abs(r)-a+u/2<=0))return!1;s=!0}}),i},target:function(){return this._target},first:function(){return this._first},last:function(){return this._last},visible:function(){return this._visible},fullyvisible:function(){return this._fullyvisible},hasNext:function(){if(!1===this._trigger("hasnext"))return!0;var e=this.options("wrap"),t=this.items().size()-1;return t>=0&&(e&&e!=="first"||this._last.index()<t||this.tail&&!this.inTail)?!0:!1},hasPrev:function(){if(!1===this._trigger("hasprev"))return!0;var e=this.options("wrap");return this.items().size()>0&&(e&&e!=="last"||this._first.index()>0||this.tail&&this.inTail)?!0:!1},clipping:function(){return this._element["inner"+(this.vertical?"Height":"Width")]()},dimension:function(e){return e["outer"+(this.vertical?"Height":"Width")](!0)},scroll:function(t,r,i){if(this.animating)return this;if(!1===this._trigger("scroll",null,[t,r]))return this;e.isFunction(r)&&(i=r,r=!0);var s=e.jCarousel.parseTarget(t);if(s.relative){var o=this.items().size()-1,u=Math.abs(s.target),a=this.options("wrap"),f,l,c,h;if(s.target>0){var p=this._last.index();if(p>=o&&this.tail)this.inTail?a==="both"||a==="last"?this._scroll(0,r,i):this._scroll(Math.min(this._target.index()+u,o),r,i):this._scrollTail(r,i);else if(p!==o||a!=="both"&&a!=="last"){f=this._target.index(),l=f+u;if(this.circular&&l>o){h=o,c=this.items().get(-1);while(h++<l)c=this.items().eq(0),c.after(c.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(c),this._items=null;this._scroll(c,r,i)}else this._scroll(Math.min(l,o),r,i)}else this._scroll(0,r,i)}else if(this.inTail)this._scroll(Math.max(this._first.index()-u+1,0),r,i);else{f=this._first.index(),l=f-u;if(f!==0||a!=="both"&&a!=="first")if(this.circular&&l<0){h=l,c=this.items().get(0);while(h++<0){c=this.items().eq(-1),c.after(c.clone(!0).attr("data-jcarousel-clone",!0)),this.list().prepend(c),this._items=null;var d=n(this.list().css(this.lt)),v=this.dimension(c);this.rtl&&!this.vertical?d+=v:d-=v,this.list().css(this.lt,d+"px")}this._scroll(c,r,i)}else this._scroll(Math.max(f-u,0),r,i);else this._scroll(o,r,i)}}else this._scroll(s.target,r,i);return this._trigger("scrollend"),this},_scroll:function(t,r,i){if(this.animating)return e.isFunction(i)&&i.call(this,!1),this;typeof t!="object"?t=this.items().eq(t):typeof t.jquery=="undefined"&&(t=e(t));if(t.size()===0)return e.isFunction(i)&&i.call(this,!1),this;this.inTail=!1,this._prepare(t);var s=this._position(t),o=n(this.list().css(this.lt));if(s===o)return e.isFunction(i)&&i.call(this,!1),this;var u={};return u[this.lt]=s+"px",this._animate(u,r,i),this},_scrollTail:function(t,n){if(this.animating||!this.tail)return e.isFunction(n)&&n.call(this,!1),this;var r=this.list().position()[this.lt];this.rtl?r+=this.tail:r-=this.tail,this.inTail=!0;var i={};return i[this.lt]=r+"px",this._update({target:this._target.next(),fullyvisible:this._fullyvisible.slice(1).add(this._visible.last())}),this._animate(i,t,n),this},_animate:function(t,n,r){if(!1===this._trigger("animate"))return e.isFunction(r)&&r.call(this,!1),this;this.animating=!0;var i=this.options("animation");if(!i||n===!1)this.list().css(t),this.onAnimationComplete(r);else{var s=this;if(e.isFunction(i))i.call(this,t,function(){s.onAnimationComplete(r)});else{var o=typeof i=="object"?i:{duration:i},u=o.complete;o.complete=function(){s.onAnimationComplete(r),e.isFunction(u)&&u.call(this)},this.list().animate(t,o)}}return this},_prepare:function(t){var r=t.index(),i=r,s=this.dimension(t),o=this.clipping(),u=this.vertical?"bottom":this.rtl?"left":"right",a={target:t,first:t,last:t,visible:t,fullyvisible:s<=o?t:e()},f,l;this.options("center")&&(s/=2,o/=2);if(s<o)for(;;){f=this.items().eq(++i);if(f.size()===0){if(!this.circular)break;f=this.items().eq(0);if(t.get(0)===f.get(0))break;f.after(f.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(f),this._items=null}s+=this.dimension(f),a.last=f,a.visible=a.visible.add(f),l=n(f.css("margin-"+u)),s-l<=o&&(a.fullyvisible=a.fullyvisible.add(f));if(s>=o)break}if(!this.circular&&s<o){i=r;for(;;){if(--i<0)break;f=this.items().eq(i);if(f.size()===0)break;s+=this.dimension(f),a.first=f,a.visible=a.visible.add(f),l=n(f.css("margin-"+u)),s-l<=o&&(a.fullyvisible=a.fullyvisible.add(f));if(s>=o)break}}return this._update(a),this.tail=0,this.options("wrap")!=="circular"&&this.options("wrap")!=="custom"&&a.last.index()===this.items().size()-1&&(s-=n(a.last.css("margin-"+u)),s>o&&(this.tail=s-o)),this},_position:function(e){var t=this._first,n=t.position()[this.lt];return this.rtl&&!this.vertical&&(n-=this.clipping()-this.dimension(t)),this.options("center")&&(n-=this.clipping()/2-this.dimension(t)/2),(e.index()>t.index()||this.inTail)&&this.tail?(n=this.rtl?n-this.tail:n+this.tail,this.inTail=!0):this.inTail=!1,-n},_update:function(t){var n=this,r={target:this._target||e(),first:this._first||e(),last:this._last||e(),visible:this._visible||e(),fullyvisible:this._fullyvisible||e()},i=(t.first||r.first).index()<r.first.index(),s,o=function(s){var o=[],u=[];t[s].each(function(){r[s].index(this)<0&&o.push(this)}),r[s].each(function(){t[s].index(this)<0&&u.push(this)}),i?o=o.reverse():u=u.reverse(),n._trigger("item"+s+"in",e(o)),n._trigger("item"+s+"out",e(u)),n["_"+s]=t[s]};for(s in t)o(s);return this}})}(jQuery,window),function(e){"use strict";e.extend(e.jCarousel.plugin("jcarousel").prototype,{scrollIntoView:function(t,n,r){var i=this.items(),s=typeof t!="object"?t:i.index(t),o=this._fullyvisible.first().index();if(s<o)return this.scroll(s,n,r);if(s>=o&&s<=this._fullyvisible.last().index())return e.isFunction(r)&&r.call(this,!1),this;var u=this.clipping(),a=this.vertical?"bottom":this.rtl?"left":"right",f=0,l;for(;;){l=i.eq(s);if(l.size()===0)break;f+=this.dimension(l);if(f>=u){var c=parseFloat(l.css("margin-"+a))||0;f-c!==u&&s++;break}if(s<=0)break;s--}return this.scroll(s,n,r)}})}(jQuery),function(e){"use strict";e.jCarousel.plugin("jcarouselControl",{_options:{target:"+=1",event:"click"},_active:null,_init:function(){this.onDestroy=e.proxy(function(){this._destroy(),this.carousel().one("createend.jcarousel",e.proxy(this._create,this))},this),this.onReload=e.proxy(this._reload,this),this.onEvent=e.proxy(function(e){e.preventDefault(),this.carousel().jcarousel("scroll",this.options("target"))},this)},_create:function(){this.carousel().one("destroy.jcarousel",this.onDestroy).bind("reloadend.jcarousel scrollend.jcarousel",this.onReload),this._element.bind(this.options("event")+".jcarouselcontrol",this.onEvent),this._reload()},_destroy:function(){this._element.unbind(".jcarouselcontrol",this.onEvent),this.carousel().unbind("destroy.jcarousel",this.onDestroy).unbind("reloadend.jcarousel scrollend.jcarousel",this.onReload)},_reload:function(){var t=e.jCarousel.parseTarget(this.options("target")),n=this.carousel(),r;if(t.relative)r=n.jcarousel(t.target>0?"hasNext":"hasPrev");else{var i=typeof t.target!="object"?n.jcarousel("items").eq(t.target):t.target;r=n.jcarousel("target").index(i)>=0}return this._active!==r&&(this._trigger(r?"active":"inactive"),this._active=r),this}})}(jQuery),function(e){"use strict";e.jCarousel.plugin("jcarouselPagination",{_options:{perPage:null,item:function(e){return'<a href="#'+e+'">'+e+"</a>"}},_pages:{},_items:{},_init:function(){this.onDestroy=e.proxy(function(){this._destroy(),this.carousel().one("createend.jcarousel",e.proxy(this._create,this))},this),this.onReload=e.proxy(this._reload,this)},_create:function(){this.carousel().one("destroy.jcarousel",this.onDestroy).bind("reloadend.jcarousel",this.onReload),this._reload()},_destroy:function(){e.fn.jcarouselControl&&e.each(this._items,function(e,t){t.jcarouselControl("destroy")}),this._element.empty(),this.carousel().unbind("destroy.jcarousel",this.onDestroy).unbind("reloadend.jcarousel",this.onReload)},_reload:function(){var t=this.options("perPage");this._pages={},this._items={},e.isFunction(t)&&(t=t.call(this));if(t==null)this._pages=this._calculatePages();else{var n=parseInt(t,10)||0,r=this.carousel().jcarousel("items"),i=1,s=0,o;for(;;){o=r.eq(s++);if(o.size()===0)break;this._pages[i]?this._pages[i]=this._pages[i].add(o):this._pages[i]=o,s%n===0&&i++}}var u=this,a=this._element.empty(),f=this.options("item");e.each(this._pages,function(t,n){var r=u._items[t]=e(f.call(u,t,n));a.append(r),e.fn.jcarouselControl&&r.jcarouselControl({carousel:u.carousel(),target:n.eq(0)})})},items:function(){return this._items},_calculatePages:function(){var e=this.carousel().data("jcarousel"),t=e.items(),n=e.clipping(),r=0,i=0,s=1,o={},u;for(;;){u=t.eq(i++);if(u.size()===0)break;o[s]?o[s]=o[s].add(u):o[s]=u,r+=e.dimension(u),r>=n&&(s++,r=0)}return o}})}(jQuery),function(e){"use strict";e.jCarousel.plugin("jcarouselAutoscroll",{_options:{target:"+=1",interval:3e3,autostart:!0},_timer:null,_init:function(){this.onDestroy=e.proxy(function(){this._destroy(),this.carousel().one("createend.jcarousel",e.proxy(this._create,this))},this),this.onAnimateEnd=e.proxy(this.start,this)},_create:function(){this.carousel().one("destroy.jcarousel",this.onDestroy),this.options("autostart")&&this.start()},_destroy:function(){this.stop(),this.carousel().unbind("destroy.jcarousel",this.onDestroy)},start:function(){return this.stop(),this.carousel().one("animateend.jcarousel",this.onAnimateEnd),this._timer=setTimeout(e.proxy(function(){this.carousel().jcarousel("scroll",this.options("target"))},this),this.options("interval")),this},stop:function(){return this._timer&&(this._timer=clearTimeout(this._timer)),this.carousel().unbind("animateend.jcarousel",this.onAnimateEnd),this}})}(jQuery);
  5 +(function(e){"use strict";var t=e.jCarousel={};t.version="0.3.0-beta";var n=/^([+\-]=)?(.+)$/;t.parseTarget=function(e){var t=!1,r=typeof e!="object"?n.exec(e):null;return r?(e=parseInt(r[2],10)||0,r[1]&&(t=!0,r[1]==="-="&&(e*=-1))):typeof e!="object"&&(e=parseInt(e,10)||0),{target:e,relative:t}},t.detectCarousel=function(e){var t;while(e.size()>0){t=e.filter("[data-jcarousel]");if(t.size()>0)return t;t=e.find("[data-jcarousel]");if(t.size()>0)return t;e=e.parent()}return null},t.base=function(n){return{version:t.version,_options:{},_element:null,_carousel:null,_init:e.noop,_create:e.noop,_destroy:e.noop,_reload:e.noop,create:function(){return this._element.attr("data-"+n.toLowerCase(),!0).data(n,this),!1===this._trigger("create")?this:(this._create(),this._trigger("createend"),this)},destroy:function(){return!1===this._trigger("destroy")?this:(this._destroy(),this._trigger("destroyend"),this._element.removeData(n).removeAttr("data-"+n.toLowerCase()),this)},reload:function(e){return!1===this._trigger("reload")?this:(e&&this.options(e),this._reload(),this._trigger("reloadend"),this)},element:function(){return this._element},options:function(t,n){if(arguments.length===0)return e.extend({},this._options);if(typeof t=="string"){if(typeof n=="undefined")return typeof this._options[t]=="undefined"?null:this._options[t];this._options[t]=n}else this._options=e.extend({},this._options,t);return this},carousel:function(){return this._carousel||(this._carousel=t.detectCarousel(this.options("carousel")||this._element),this._carousel||e.error('Could not detect carousel for plugin "'+n+'"')),this._carousel},_trigger:function(t,r,i){var s=e.Event((t+"."+n).toLowerCase());return(r||this._element).trigger(s,[this].concat(i||[])),!s.isDefaultPrevented()}}},t.plugin=function(n,r){var i=e[n]=function(t,n){this._element=e(t),this.options(n),this._init(),this.create()};return i.fn=i.prototype=e.extend({},t.base(n),r),e.fn[n]=function(t){var r=Array.prototype.slice.call(arguments,1),s=this;return typeof t=="string"?this.each(function(){var i=e(this).data(n);if(!i)return e.error("Cannot call methods on "+n+" prior to initialization; "+'attempted to call method "'+t+'"');if(!e.isFunction(i[t])||t.charAt(0)==="_")return e.error('No such method "'+t+'" for '+n+" instance");var o=i[t].apply(i,r);if(o!==i&&typeof o!="undefined")return s=o,!1}):this.each(function(){var r=e(this).data(n);r?r.reload(t):new i(this,t)}),s},i}})(jQuery),function(e,t){"use strict";var n=function(e){return parseFloat(e)||0};e.jCarousel.plugin("jcarousel",{animating:!1,tail:0,inTail:!1,resizeTimer:null,lt:null,vertical:!1,rtl:!1,circular:!1,_options:{list:function(){return this.element().children().eq(0)},items:function(){return this.list().children()},animation:400,wrap:null,vertical:null,rtl:null,center:!1},_list:null,_items:null,_target:null,_first:null,_last:null,_visible:null,_fullyvisible:null,_init:function(){var t=this;return this.onWindowResize=function(){t.resizeTimer&&clearTimeout(t.resizeTimer),t.resizeTimer=setTimeout(function(){t.reload()},100)},this.onAnimationComplete=function(n){t.animating=!1;var r=t.list().find("[data-jcarousel-clone]");r.size()>0&&(r.remove(),t._reload()),t._trigger("animateend"),e.isFunction(n)&&n.call(t,!0)},this},_create:function(){this._reload(),e(t).bind("resize.jcarousel",this.onWindowResize)},_destroy:function(){e(t).unbind("resize.jcarousel",this.onWindowResize)},_reload:function(){this.vertical=this.options("vertical"),this.vertical==null&&(this.vertical=this.list().height()>this.list().width()),this.rtl=this.options("rtl"),this.rtl==null&&(this.rtl=function(t){if((""+t.attr("dir")).toLowerCase()==="rtl")return!0;var n=!1;return t.parents("[dir]").each(function(){if(/rtl/i.test(e(this).attr("dir")))return n=!0,!1}),n}(this._element)),this.lt=this.vertical?"top":"left",this._items=null;var t=this._target||this.closest();return this.circular=this.options("wrap")==="circular",t.size()>0?(this._prepare(t),this.list().find("[data-jcarousel-clone]").remove(),this._items=null,this.circular=this.options("wrap")==="circular"&&this._fullyvisible.size()<this.items().size(),this.list().css(this.lt,this._position(t)+"px")):this.list().css({left:0,top:0}),this},list:function(){if(this._list===null){var t=this.options("list");this._list=e.isFunction(t)?t.call(this):this._element.find(t)}return this._list},items:function(){if(this._items===null){var t=this.options("items");this._items=(e.isFunction(t)?t.call(this):this.list().find(t)).not("[data-jcarousel-clone]")}return this._items},closest:function(){var t=this,r=this.list().position()[this.lt],i=e(),s=!1,o=this.vertical?"bottom":this.rtl?"left":"right",u;return this.rtl&&!this.vertical&&(r=(r+this.list().width()-this.clipping())*-1),this.items().each(function(){i=e(this);if(s)return!1;var a=t.dimension(i);r+=a;if(r>=0){u=a-n(i.css("margin-"+o));if(!(Math.abs(r)-a+u/2<=0))return!1;s=!0}}),i},target:function(){return this._target},first:function(){return this._first},last:function(){return this._last},visible:function(){return this._visible},fullyvisible:function(){return this._fullyvisible},hasNext:function(){if(!1===this._trigger("hasnext"))return!0;var e=this.options("wrap"),t=this.items().size()-1;return t>=0&&(e&&e!=="first"||this._last.index()<t||this.tail&&!this.inTail)?!0:!1},hasPrev:function(){if(!1===this._trigger("hasprev"))return!0;var e=this.options("wrap");return this.items().size()>0&&(e&&e!=="last"||this._first.index()>0||this.tail&&this.inTail)?!0:!1},clipping:function(){return this._element["inner"+(this.vertical?"Height":"Width")]()},dimension:function(e){return e["outer"+(this.vertical?"Height":"Width")](!0)},scroll:function(t,r,i){if(this.animating)return this;if(!1===this._trigger("scroll",null,[t,r]))return this;e.isFunction(r)&&(i=r,r=!0);var s=e.jCarousel.parseTarget(t);if(s.relative){var o=this.items().size()-1,u=Math.abs(s.target),a=this.options("wrap"),f,l,c,h;if(s.target>0){var p=this._last.index();if(p>=o&&this.tail)this.inTail?a==="both"||a==="last"?this._scroll(0,r,i):this._scroll(Math.min(this._target.index()+u,o),r,i):this._scrollTail(r,i);else if(p!==o||a!=="both"&&a!=="last"){f=this._target.index(),l=f+u;if(this.circular&&l>o){h=o,c=this.items().get(-1);while(h++<l)c=this.items().eq(0),c.after(c.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(c),this._items=null;this._scroll(c,r,i)}else this._scroll(Math.min(l,o),r,i)}else this._scroll(0,r,i)}else if(this.inTail)this._scroll(Math.max(this._first.index()-u+1,0),r,i);else{f=this._first.index(),l=f-u;if(f!==0||a!=="both"&&a!=="first")if(this.circular&&l<0){h=l,c=this.items().get(0);while(h++<0){c=this.items().eq(-1),c.after(c.clone(!0).attr("data-jcarousel-clone",!0)),this.list().prepend(c),this._items=null;var d=n(this.list().css(this.lt)),v=this.dimension(c);this.rtl&&!this.vertical?d+=v:d-=v,this.list().css(this.lt,d+"px")}this._scroll(c,r,i)}else this._scroll(Math.max(f-u,0),r,i);else this._scroll(o,r,i)}}else this._scroll(s.target,r,i);return this._trigger("scrollend"),this},_scroll:function(t,r,i){if(this.animating)return e.isFunction(i)&&i.call(this,!1),this;typeof t!="object"?t=this.items().eq(t):typeof t.jquery=="undefined"&&(t=e(t));if(t.size()===0)return e.isFunction(i)&&i.call(this,!1),this;this.inTail=!1,this._prepare(t);var s=this._position(t),o=n(this.list().css(this.lt));if(s===o)return e.isFunction(i)&&i.call(this,!1),this;var u={};return u[this.lt]=s+"px",this._animate(u,r,i),this},_scrollTail:function(t,n){if(this.animating||!this.tail)return e.isFunction(n)&&n.call(this,!1),this;var r=this.list().position()[this.lt];this.rtl?r+=this.tail:r-=this.tail,this.inTail=!0;var i={};return i[this.lt]=r+"px",this._update({target:this._target.next(),fullyvisible:this._fullyvisible.slice(1).add(this._visible.last())}),this._animate(i,t,n),this},_animate:function(t,n,r){if(!1===this._trigger("animate"))return e.isFunction(r)&&r.call(this,!1),this;this.animating=!0;var i=this.options("animation");if(!i||n===!1)this.list().css(t),this.onAnimationComplete(r);else{var s=this;if(e.isFunction(i))i.call(this,t,function(){s.onAnimationComplete(r)});else{var o=typeof i=="object"?i:{duration:i},u=o.complete;o.complete=function(){s.onAnimationComplete(r),e.isFunction(u)&&u.call(this)},this.list().animate(t,o)}}return this},_prepare:function(t){var r=t.index(),i=r,s=this.dimension(t),o=this.clipping(),u=this.vertical?"bottom":this.rtl?"left":"right",a={target:t,first:t,last:t,visible:t,fullyvisible:s<=o?t:e()},f,l;this.options("center")&&(s/=2,o/=2);if(s<o)for(;;){f=this.items().eq(++i);if(f.size()===0){if(!this.circular)break;f=this.items().eq(0);if(t.get(0)===f.get(0))break;f.after(f.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(f),this._items=null}s+=this.dimension(f),a.last=f,a.visible=a.visible.add(f),l=n(f.css("margin-"+u)),s-l<=o&&(a.fullyvisible=a.fullyvisible.add(f));if(s>=o)break}if(!this.circular&&s<o){i=r;for(;;){if(--i<0)break;f=this.items().eq(i);if(f.size()===0)break;s+=this.dimension(f),a.first=f,a.visible=a.visible.add(f),l=n(f.css("margin-"+u)),s-l<=o&&(a.fullyvisible=a.fullyvisible.add(f));if(s>=o)break}}return this._update(a),this.tail=0,this.options("wrap")!=="circular"&&this.options("wrap")!=="custom"&&a.last.index()===this.items().size()-1&&(s-=n(a.last.css("margin-"+u)),s>o&&(this.tail=s-o)),this},_position:function(e){var t=this._first,n=t.position()[this.lt];return this.rtl&&!this.vertical&&(n-=this.clipping()-this.dimension(t)),this.options("center")&&(n-=this.clipping()/2-this.dimension(t)/2),(e.index()>t.index()||this.inTail)&&this.tail?(n=this.rtl?n-this.tail:n+this.tail,this.inTail=!0):this.inTail=!1,-n},_update:function(t){var n=this,r={target:this._target||e(),first:this._first||e(),last:this._last||e(),visible:this._visible||e(),fullyvisible:this._fullyvisible||e()},i=(t.first||r.first).index()<r.first.index(),s,o=function(s){var o=[],u=[];t[s].each(function(){r[s].index(this)<0&&o.push(this)}),r[s].each(function(){t[s].index(this)<0&&u.push(this)}),i?o=o.reverse():u=u.reverse(),n._trigger("item"+s+"in",e(o)),n._trigger("item"+s+"out",e(u)),n["_"+s]=t[s]};for(s in t)o(s);return this}})}(jQuery,window),function(e){"use strict";e.jcarousel.fn.scrollIntoView=function(t,n,r){var i=this.items(),s=typeof t!="object"?t:i.index(t),o=this._fullyvisible.first().index();if(s<o)return this.scroll(s,n,r);if(s>=o&&s<=this._fullyvisible.last().index())return e.isFunction(r)&&r.call(this,!1),this;var u=this.clipping(),a=this.vertical?"bottom":this.rtl?"left":"right",f=0,l;for(;;){l=i.eq(s);if(l.size()===0)break;f+=this.dimension(l);if(f>=u){var c=parseFloat(l.css("margin-"+a))||0;f-c!==u&&s++;break}if(s<=0)break;s--}return this.scroll(s,n,r)}}(jQuery),function(e){"use strict";e.jCarousel.plugin("jcarouselControl",{_options:{target:"+=1",event:"click"},_active:null,_init:function(){this.onDestroy=e.proxy(function(){this._destroy(),this.carousel().one("createend.jcarousel",e.proxy(this._create,this))},this),this.onReload=e.proxy(this._reload,this),this.onEvent=e.proxy(function(e){e.preventDefault(),this.carousel().jcarousel("scroll",this.options("target"))},this)},_create:function(){this.carousel().one("destroy.jcarousel",this.onDestroy).bind("reloadend.jcarousel scrollend.jcarousel",this.onReload),this._element.bind(this.options("event")+".jcarouselcontrol",this.onEvent),this._reload()},_destroy:function(){this._element.unbind(".jcarouselcontrol",this.onEvent),this.carousel().unbind("destroy.jcarousel",this.onDestroy).unbind("reloadend.jcarousel scrollend.jcarousel",this.onReload)},_reload:function(){var t=e.jCarousel.parseTarget(this.options("target")),n=this.carousel(),r;if(t.relative)r=n.jcarousel(t.target>0?"hasNext":"hasPrev");else{var i=typeof t.target!="object"?n.jcarousel("items").eq(t.target):t.target;r=n.jcarousel("target").index(i)>=0}return this._active!==r&&(this._trigger(r?"active":"inactive"),this._active=r),this}})}(jQuery),function(e){"use strict";e.jCarousel.plugin("jcarouselPagination",{_options:{perPage:null,item:function(e){return'<a href="#'+e+'">'+e+"</a>"}},_pages:{},_items:{},_init:function(){this.onDestroy=e.proxy(function(){this._destroy(),this.carousel().one("createend.jcarousel",e.proxy(this._create,this))},this),this.onReload=e.proxy(this._reload,this)},_create:function(){this.carousel().one("destroy.jcarousel",this.onDestroy).bind("reloadend.jcarousel",this.onReload),this._reload()},_destroy:function(){e.fn.jcarouselControl&&e.each(this._items,function(e,t){t.jcarouselControl("destroy")}),this._element.empty(),this.carousel().unbind("destroy.jcarousel",this.onDestroy).unbind("reloadend.jcarousel",this.onReload)},_reload:function(){var t=this.options("perPage");this._pages={},this._items={},e.isFunction(t)&&(t=t.call(this));if(t==null)this._pages=this._calculatePages();else{var n=parseInt(t,10)||0,r=this.carousel().jcarousel("items"),i=1,s=0,o;for(;;){o=r.eq(s++);if(o.size()===0)break;this._pages[i]?this._pages[i]=this._pages[i].add(o):this._pages[i]=o,s%n===0&&i++}}var u=this,a=this._element.empty(),f=this.options("item");e.each(this._pages,function(t,n){var r=u._items[t]=e(f.call(u,t,n));a.append(r),e.fn.jcarouselControl&&r.jcarouselControl({carousel:u.carousel(),target:n.eq(0)})})},items:function(){return this._items},_calculatePages:function(){var e=this.carousel().data("jcarousel"),t=e.items(),n=e.clipping(),r=0,i=0,s=1,o={},u;for(;;){u=t.eq(i++);if(u.size()===0)break;o[s]?o[s]=o[s].add(u):o[s]=u,r+=e.dimension(u),r>=n&&(s++,r=0)}return o}})}(jQuery),function(e){"use strict";e.jCarousel.plugin("jcarouselAutoscroll",{_options:{target:"+=1",interval:3e3,autostart:!0},_timer:null,_init:function(){this.onDestroy=e.proxy(function(){this._destroy(),this.carousel().one("createend.jcarousel",e.proxy(this._create,this))},this),this.onAnimateEnd=e.proxy(this.start,this)},_create:function(){this.carousel().one("destroy.jcarousel",this.onDestroy),this.options("autostart")&&this.start()},_destroy:function(){this.stop(),this.carousel().unbind("destroy.jcarousel",this.onDestroy)},start:function(){return this.stop(),this.carousel().one("animateend.jcarousel",this.onAnimateEnd),this._timer=setTimeout(e.proxy(function(){this.carousel().jcarousel("scroll",this.options("target"))},this),this.options("interval")),this},stop:function(){return this._timer&&(this._timer=clearTimeout(this._timer)),this.carousel().unbind("animateend.jcarousel",this.onAnimateEnd),this}})}(jQuery);
12 src/core.js
@@ -156,16 +156,8 @@
156 156 };
157 157 };
158 158
159   - var registry = {};
160   -
161 159 jCarousel.plugin = function(pluginName, pluginPrototype) {
162   - if (arguments.length === 1) {
163   - return typeof registry[pluginName] !== 'undefined' ?
164   - registry[pluginName] :
165   - $.error('Plugin with name ' + pluginName + ' does not exists');
166   - }
167   -
168   - var Plugin = registry[pluginName] = function(element, options) {
  160 + var Plugin = $[pluginName] = function(element, options) {
169 161 this._element = $(element);
170 162 this.options(options);
171 163
@@ -173,7 +165,7 @@
173 165 this.create();
174 166 };
175 167
176   - Plugin.prototype = $.extend(
  168 + Plugin.fn = Plugin.prototype = $.extend(
177 169 {},
178 170 jCarousel.base(pluginName),
179 171 pluginPrototype
70 src/scrollintoview.js
@@ -8,54 +8,52 @@
8 8 (function($) {
9 9 'use strict';
10 10
11   - $.extend($.jCarousel.plugin('jcarousel').prototype, {
12   - scrollIntoView: function(target, animate, callback) {
13   - var items = this.items(),
14   - index = typeof target !== 'object' ? target : items.index(target),
15   - first = this._fullyvisible.first().index();
16   -
17   - if (index < first) {
18   - return this.scroll(index, animate, callback);
19   - }
  11 + $.jcarousel.fn.scrollIntoView = function(target, animate, callback) {
  12 + var items = this.items(),
  13 + index = typeof target !== 'object' ? target : items.index(target),
  14 + first = this._fullyvisible.first().index();
20 15
21   - if (index >= first && index <= this._fullyvisible.last().index()) {
22   - if ($.isFunction(callback)) {
23   - callback.call(this, false);
24   - }
  16 + if (index < first) {
  17 + return this.scroll(index, animate, callback);
  18 + }
25 19
26   - return this;
  20 + if (index >= first && index <= this._fullyvisible.last().index()) {
  21 + if ($.isFunction(callback)) {
  22 + callback.call(this, false);
27 23 }
28 24
29   - var clip = this.clipping(),
30   - lrb = this.vertical ? 'bottom' : (this.rtl ? 'left' : 'right'),
31   - wh = 0,
32   - curr;
  25 + return this;
  26 + }
33 27
34   - while (true) {
35   - curr = items.eq(index);
  28 + var clip = this.clipping(),
  29 + lrb = this.vertical ? 'bottom' : (this.rtl ? 'left' : 'right'),
  30 + wh = 0,
  31 + curr;
36 32
37   - if (curr.size() === 0) {
38   - break;
39   - }
  33 + while (true) {
  34 + curr = items.eq(index);
40 35
41   - wh += this.dimension(curr);
  36 + if (curr.size() === 0) {
  37 + break;
  38 + }
42 39
43   - if (wh >= clip) {
44   - var margin = parseFloat(curr.css('margin-' + lrb)) || 0;
45   - if ((wh - margin) !== clip) {
46   - index++;
47   - }
48   - break;
49   - }
  40 + wh += this.dimension(curr);
50 41
51   - if (index <= 0) {
52   - break;
  42 + if (wh >= clip) {
  43 + var margin = parseFloat(curr.css('margin-' + lrb)) || 0;
  44 + if ((wh - margin) !== clip) {
  45 + index++;
53 46 }
  47 + break;
  48 + }
54 49
55   - index--;
  50 + if (index <= 0) {
  51 + break;
56 52 }
57 53
58   - return this.scroll(index, animate, callback);
  54 + index--;
59 55 }
60   - });
  56 +
  57 + return this.scroll(index, animate, callback);
  58 + };
61 59 }(jQuery));

0 comments on commit c1c2b55

Please sign in to comment.
Something went wrong with that request. Please try again.