-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.currentdots.min.js
6 lines (6 loc) · 2.54 KB
/
jquery.currentdots.min.js
1
2
3
4
5
6
/*! jQuery.currentDots (https://github.com/Takazudo/jQuery.currentDots)
* lastupdate: 2013-06-13
* version: 0.3.0
* author: 'Takazudo' Takeshi Takatsudo <takazudo@gmail.com>
* License: MIT */
(function(){var t={}.hasOwnProperty,i=function(i,e){function n(){this.constructor=i}for(var s in e)t.call(e,s)&&(i[s]=e[s]);return n.prototype=e.prototype,i.prototype=new n,i.__super__=e.prototype,i};(function(t,e){var n;return n={},n.DotItem=function(e){function s(i,e){this.$el=i,this.active=null,this.options=t.extend({},n.DotItem.defaults,e),this._eventify(),this.deactivate()}return i(s,e),s.defaults={index:null,class_activeItem:null,class_inactiveItem:null},s.prototype._eventify=function(){var t=this;return this.$el.bind("click",function(i){var e;return i.preventDefault(),e={index:t.options.index},t.trigger("click",e)}),this},s.prototype.deactivate=function(){return this.active===!1?this:(this.active=!1,this.$el.removeClass(this.options.class_activeItem),this.options.class_inactiveItem&&this.$el.addClass(this.options.class_inactiveItem),this)},s.prototype.activate=function(){return this.active===!0?this:(this.active=!0,this.$el.addClass(this.options.class_activeItem),this.options.class_inactiveItem&&this.$el.removeClass(this.options.class_inactiveItem),this)},s}(e.EveEve),n.DotCollection=function(e){function s(i,e){this.$el=i,this.options=t.extend({},n.DotCollection.defaults,e),this._createItems(),"number"===t.type(this.options.initialActiveIndex)&&this.to(this.options.initialActiveIndex)}return i(s,e),s.defaults={selector_item:null,class_activeItem:null,initialActiveIndex:0},s.prototype._createItems=function(){var i=this;return this._items=[],this.$el.find(this.options.selector_item).each(function(e,s){var o,c;c={class_activeItem:i.options.class_activeItem,index:e},i.options.class_inactiveItem&&(c.class_inactiveItem=i.options.class_inactiveItem),o=new n.DotItem(t(s),c),o.on("click",function(t){return i.to(t.index),i.trigger("itemclick",t)}),i._items.push(o)}),this},s.prototype.deactivateWithout=function(t){var i,e,n,s;for(s=this._items,e=0,n=s.length;n>e;e++)i=s[e],i!==t&&i.deactivate();return this},s.prototype.activate=function(t){var i,e,n,s;for(s=this._items,e=0,n=s.length;n>e;e++)if(i=s[e],i===t){i.activate();break}return this},s.prototype.to=function(t){var i;return i=this._items[t],this.deactivateWithout(i),this.activate(i),this},s}(e.EveEve),t.fn.currentDots=function(i){return this.each(function(e,s){var o,c;o=t(s),c=new n.DotCollection(o,i),o.data("currentDots",c)})},t.CurrentDotsNs=n,t.CurrentDots=n.DotCollection})(jQuery,window,document)}).call(this);