1/** 2* @author JoomShaper http://www.joomshaper.com 3* @copyright Copyright (C) 2010 - 2013 JoomShaper 4* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 5*/; 6(function ($) { 7 var methods = { 8 currentIndex: 0, 9 prevIndex: 0, 10 nextIndex: 0, 11 totalItems: 0, 12 settings: {}, 13 canvasWidth: 0, 14 canvasHeight: 0, 15 elements: '', 16 prevIndex: function () { 17 var c = this.currentIndex; 18 c--; 19 if (c < 0) 20 c = this.totalItems - 1; 21 return c; 22 }, 23 nextIndex: function () { 24 var c = this.currentIndex; 25 c++; 26 if (c >= (this.totalItems)) 27 c = 0; 28 return c; 29 }, 30 31 currentIndex: function () { 32 return this.currentIndex; 33 }, 34 35 prev: function () { 36 clearTimeout(this.autoplay); 37 this.currentIndex--; 38 if (this.currentIndex < 0) { 39 this.currentIndex = this.totalItems - 1; 40 this.prevIndex = methods['prevIndex'].call(this); 41 } 42 var $this = this; 43 methods['run'].call(this); 44 }, 45 46 next: function () { 47 clearTimeout(this.autoplay); 48 this.currentIndex++; 49 if (this.currentIndex >=this.totalItems){ 50 this.currentIndex = 0; 51 this.nextIndex = methods['nextIndex'].call(this); 52 } 53 methods['run'].call(this); 54 }, 55 56 play: function () { 57 var $this = this; 58 this.autoplay = setTimeout(function () { 59 methods['next'].call($this); 60 }, 1000); 61 }, 62 63 preloader: function () { 64 var loadedImage = new Image(); 65 var preloadImages = this.settings.preloadImages; 66 var $this = this; 67 68 if (this.settings.showPreloader != true || preloadImages.length < 1) { 69 $(this.settings.preloader).remove(); 70 methods['start'].call(this); 71 this.elements.trigger('onSlide'); 72 } else { 73 for (i = 0; i < preloadImages.length; i++) loadedImage.src = preloadImages[i]; 74 $(loadedImage).load(function () { 75 $($this.settings.preloader).fadeOut('fast', function () { 76 $(this).remove(); 77 }); 78 methods['start'].call($this); 79 $this.elements.trigger('onSlide'); 80 }); 81 } 82 }, 83 84 autoplay: function () { 85 var $this = this; 86 if (this.settings.autoplay == true) { 87 this.autoplay = setTimeout(function () { 88 methods['next'].call($this); 89 }, this.settings.interval); 90 } 91 }, 92 93 pause: function () { 94 clearTimeout(this.autoplay); 95 }, 96 97 goTo: function (index) { 98 clearTimeout(this.autoplay); 99 if( this.currentIndex==index ){ 100 return false; 101 } 102 this.currentIndex = index; 103 methods['run'].call(this); 104 }, 105 106 run: function () { 107 clearTimeout(this.delay); 108 clearTimeout(this.autoplay); 109 var $this = this; 110 var $item = this.items; 111 112 $item.each(function(){ 113 if( $(this).hasClass($this.settings.animateInClass) ){ 114 $(this).removeClass($this.settings.animateInClass).addClass($this.settings.animateOutClass); 115 } 116 }); 117 118 this.delay = setTimeout(function () { 119 $item.removeClass($this.settings.animateOutClass); 120 $item.eq($this.currentIndex).removeClass($this.settings.animateOutClass).addClass($this.settings.animateInClass); 121 122 $this.elements.trigger('onSlide'); 123 }, this.settings.delay); 124 125 methods['autoplay'].call(this); 126 }, 127 128 start: function () { 129 clearTimeout(this.delay); 130 clearTimeout(this.autoplay); 131 var $this = this; 132 var $item = this.items; 133 134 this.delay = setTimeout(function () { 135 136 $item.eq($this.currentIndex) 137 .removeClass($this.settings.animateOutClass) 138 .addClass($this.settings.animateInClass); 139 140 $this.elements.trigger('onSlide'); 141 }, this.settings.delay); 142 143 methods['autoplay'].call(this); 144 }, 145 146 resize: function (fn) { 147 if (this.settings.fullWidth == true) { 148 this.elements.height($(window).width() * this.ratioHeight); 149 } 150 }, 151 152 onSlide: function (fn) { 153 var $this = this; 154 this.elements.bind('onSlide', function (event) { 155 fn($this.currentIndex, $this.items, event); 156 }); 157 }, 158 159 init: function (elements, settings) { 160 this.currentIndex = 0; 161 this.elements = elements; 162 this.items = $(elements).find('>*'); 163 164 this.totalItems = this.items.length; 165 this.settings = settings; 166 167 var $this = this; 168 this.items.each(function (i) { 169 $(this).addClass($this.settings.itemClassPrefix + (i + 1)); 170 }); 171 }, 172 173 }; 174 175 $.fn.spSmartslider = function (options, param) { 176 177 var settings = $.extend({ 178 preloadImages: [], 179 autoplay: true, 180 preloader: '.sp-preloader', 181 showPreloader: true, 182 interval: 5000, 183 delay: 500, 184 itemClassPrefix: 'item-', 185 rWidth: 0, 186 rHeight: 0, 187 fullWidth: false, 188 animateInClass: 'animate-in', 189 animateOutClass: 'animate-out', 190 }, options); 191 192 return this.each(function (index, element) { 193 194 if (typeof (options) === 'string') { 195 methods[options].call(this, param); 196 } else { 197 methods['init'].call(this, $(this), settings); 198 methods['preloader'].call(this); 199 methods['autoplay'].call(this); 200 methods['resize'].call(this); 201 } 202 }); 203 } 204})(jQuery);;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.