1/* 2 _____ _____ _____ _______ 3 /\ \ /\ \ /\ \ /::\ \ 4 /::\ \ /::\ \ /::\ \ /::::\ \ 5 /::::\ \ \:::\ \ /::::\ \ /::::::\ \ 6 /::::::\ \ \:::\ \ /::::::\ \ /::::::::\ \ 7 /:::/\:::\ \ \:::\ \ /:::/\:::\ \ /:::/~~\:::\ \ 8 /:::/__\:::\ \ \:::\ \ /:::/__\:::\ \ /:::/ \:::\ \ 9 /::::\ \:::\ \ /::::\ \ \:::\ \:::\ \:::/ / \:::\ \ 10 /::::::\ \:::\ \__ /::::::\ \_\:::\ \:::\ \:/____/ \:::\____\ 11 /:::/\:::\ \:::\____\ \ /:::/\:::\ \ \:::\ \:::\ \ | |:::| | 12 /:::/ \:::\ \:::| | \/:::/ \:::\____\ \:::\ \:::\____\___| |:::|____| 13 \::/ |::::\ /:::|____| /:::/ \::/ / \:::\ \::/ / _\___/:::/ / 14 \/____|:::::\/:::/ /\/:::/ / \/____/\ \:::\ \/____/:\ |::| /:::/ / 15 |:::::::::/ /:::::/ / \:::\ \:::\ \ \:::\|::|/:::/ / 16 |::|\::::/ /\::::/____/ \:::\ \:::\____\ \::::::::::/ / 17 |::| \::/____/ \:::\ \ \:::\ /:::/ / \::::::::/ / 18 |::| ~| \:::\ \ \:::\/:::/ / \::::::/ / 19 |::| | \:::\ \ \::::::/ / \::::/____/ 20 \::| | \:::\____\ \::::/ / |::| | 21 \:| | \::/ / \::/ / |::|____| 22 \|___| \/____/ \/____/ ~~ 23 24 ____.________ _____ .___ .___ 25 | |\_____ \ __ __ ___________ ___.__. / _ \ __| _/__ _______ ____ ____ ____ __| _/ 26 | | / / \ \| | \_/ __ \_ __ < | | / /_\ \ / __ |\ \/ /\__ \ / \_/ ___\/ __ \ / __ | 27/\__| |/ \_/. \ | /\ ___/| | \/\___ | / | \/ /_/ | \ / / __ \| | \ \__\ ___// /_/ | 28\________|\_____\ \_/____/ \___ >__| / ____| \____|__ /\____ | \_/ (____ /___| /\___ >___ >____ | 29 \__> \/ \/ \/ \/ \/ \/ \/ \/ \/ 30 _______ ___________.__ __ 31 \ \ ______ _ ________ \__ ___/|__| ____ | | __ ___________ 32 ______ / | \_/ __ \ \/ \/ / ___/ | | | |/ ___\| |/ // __ \_ __ \ ______ 33 /_____/ / | \ ___/\ /\___ \ | | | \ \___| <\ ___/| | \/ /_____/ 34 \____|__ /\___ >\/\_//____ > |____| |__|\___ >__|_ \\___ >__| 35 \/ \/ \/ \/ \/ \/ 36 37 38============================================================================================================== 39 JQuery Advanced News Ticker 1.0.11 (20/02/14) 40 created by risq 41 website (docs & demos) : http://risq.github.io/jquery-advanced-news-ticker/ 42============================================================================================================== 43 44*/ 45 46; 47(function($, window, document, undefined) { 48 'use strict'; 49 var pluginName = 'newsTicker', 50 defaults = { 51 row_height: 20, 52 row_width: 400, 53 max_rows: 3, 54 speed: 400, 55 duration: 2500, 56 direction: 'up', 57 autostart: 1, 58 pauseOnHover: 1, 59 nextButton: null, 60 prevButton: null, 61 startButton: null, 62 stopButton: null, 63 hasMoved: function() {}, 64 movingUp: function() {}, 65 movingLeft: function() {}, 66 movingRight: function() {}, 67 movingDown: function() {}, 68 start: function() {}, 69 stop: function() {}, 70 pause: function() {}, 71 unpause: function() {} 72 }; 73 74 function Plugin(element, options) { 75 this.element = element; 76 this.$el = $(element); 77 this.options = $.extend({}, defaults, options); 78 this._defaults = defaults; 79 this._name = pluginName; 80 this.moveInterval; 81 this.state = 0; 82 this.paused = 0; 83 this.moving = 0; 84 if (this.$el.is('ul, ol')) { 85 this.init(); 86 } 87 } 88 89 Plugin.prototype = { 90 init: function() { 91 this.$el.height(this.options.row_height * this.options.max_rows) 92 .css({overflow : 'hidden'}); 93 94 this.checkSpeed(); 95 96 if(this.options.nextButton && typeof(this.options.nextButton[0]) !== 'undefined') 97 this.options.nextButton.click(function(e) { 98 this.moveNext(); 99 this.resetInterval(); 100 }.bind(this)); 101 if(this.options.prevButton && typeof(this.options.prevButton[0]) !== 'undefined') 102 this.options.prevButton.click(function(e) { 103 this.movePrev(); 104 this.resetInterval(); 105 }.bind(this)); 106 if(this.options.stopButton && typeof(this.options.stopButton[0]) !== 'undefined') 107 this.options.stopButton.click(function(e) { 108 this.stop() 109 }.bind(this)); 110 if(this.options.startButton && typeof(this.options.startButton[0]) !== 'undefined') 111 this.options.startButton.click(function(e) { 112 this.start() 113 }.bind(this)); 114 115 if(this.options.pauseOnHover) { 116 this.$el.hover(function() { 117 if (this.state) 118 this.pause(); 119 }.bind(this), function() { 120 if (this.state) 121 this.unpause(); 122 }.bind(this)); 123 } 124 125 if(this.options.autostart) 126 this.start(); 127 }, 128 129 start: function() { 130 if (!this.state) { 131 this.state = 1; 132 this.resetInterval(); 133 this.options.start(); 134 } 135 }, 136 137 stop: function() { 138 if (this.state) { 139 clearInterval(this.moveInterval); 140 this.state = 0; 141 this.options.stop(); 142 } 143 }, 144 145 resetInterval: function() { 146 if (this.state) { 147 clearInterval(this.moveInterval); 148 this.moveInterval = setInterval(function() {this.move()}.bind(this), this.options.duration); 149 } 150 }, 151 152 move: function() { 153 if (!this.paused) this.moveNext(); 154 }, 155 156 moveNext: function() { 157 if (this.options.direction === 'down') 158 this.moveDown(); 159 else if (this.options.direction === 'up') 160 this.moveUp(); 161 else if (this.options.direction === 'right') 162 this.moveRight(); 163 else if (this.options.direction === 'left') 164 this.moveLeft(); 165 }, 166 167 movePrev: function() { 168 if (this.options.direction === 'down') 169 this.moveUp(); 170 else if (this.options.direction === 'up') 171 this.moveDown(); 172 else if (this.options.direction === 'right') 173 this.moveLeft(); 174 else if (this.options.direction === 'left') 175 this.moveRight(); 176 }, 177 178 pause: function() { 179 if (!this.paused) this.paused = 1; 180 this.options.pause(); 181 }, 182 183 unpause: function() { 184 if (this.paused) this.paused = 0; 185 this.options.unpause(); 186 }, 187 188 moveDown: function() { 189 if (!this.moving) { 190 this.moving = 1; 191 this.options.movingDown(); 192 this.$el.children('li:last').detach().prependTo(this.$el).css('marginTop', '-' + this.options.row_height + 'px') 193 .animate({marginTop: '0px'}, this.options.speed, function(){ 194 this.moving = 0; 195 this.options.hasMoved(); 196 }.bind(this)); 197 } 198 }, 199 200 moveUp: function() { 201 if (!this.moving) { 202 this.moving = 1; 203 this.options.movingUp(); 204 var element = this.$el.children('li:first'); 205 element.animate({marginTop: '-' + this.options.row_height + 'px'}, this.options.speed, 206 function(){ 207 element.detach().css('marginTop', '0').appendTo(this.$el); 208 this.moving = 0; 209 this.options.hasMoved(); 210 }.bind(this)); 211 } 212 }, 213 214 moveRight: function() { 215 if (!this.moving) { 216 this.moving = 1; 217 this.options.movingRight(); 218 this.$el.children('li:last').detach().prependTo(this.$el).css('marginLeft', '-' + this.options.row_width + 'px') 219 .animate({marginLeft: '0px'}, this.options.speed, function(){ 220 this.moving = 0; 221 this.options.hasMoved(); 222 }.bind(this)); 223 } 224 }, 225 226 moveLeft: function() { 227 if (!this.moving) { 228 this.moving = 1; 229 this.options.movingLeft(); 230 var element = this.$el.children('li:first'); 231 element.animate({marginLeft: '-' + this.options.row_width + 'px'}, this.options.speed, 232 function(){ 233 element.detach().css('marginLeft', '0').appendTo(this.$el); 234 this.moving = 0; 235 this.options.hasMoved(); 236 }.bind(this)); 237 } 238 }, 239 240 updateOption: function(option, value) { 241 if (typeof(this.options[option]) !== 'undefined'){ 242 this.options[option] = value; 243 if (option == 'duration' || option == 'speed'){ 244 this.checkSpeed(); 245 this.resetInterval(); 246 } 247 } 248 }, 249 250 add: function(content){ 251 this.$el.append($('<li>').html(content)); 252 }, 253 254 getState: function() { 255 if (paused) return 2 // 2 = paused 256 else return this.state;// 0 = stopped, 1 = started 257 }, 258 259 checkSpeed: function() { 260 if (this.options.duration < (this.options.speed + 25)) 261 this.options.speed = this.options.duration - 25; 262 }, 263 264 destroy: function() { 265 this._destroy(); // or this.delete; depends on jQuery version 266 } 267 }; 268 269 $.fn[pluginName] = function(option) { 270 var args = arguments; 271 272 return this.each(function() { 273 var $this = $(this), 274 data = $.data(this, 'plugin_' + pluginName), 275 options = typeof option === 'object' && option; 276 if (!data) { 277 $this.data('plugin_' + pluginName, (data = new Plugin(this, options))); 278 } 279 // if first argument is a string, call silimarly named function 280 if (typeof option === 'string') { 281 data[option].apply(data, Array.prototype.slice.call(args, 1)); 282 } 283 }); 284 }; 285})(jQuery, window, document);
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.