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 max_rows: 3, 53 speed: 400, 54 duration: 2500, 55 direction: 'up', 56 autostart: 1, 57 pauseOnHover: 1, 58 nextButton: null, 59 prevButton: null, 60 startButton: null, 61 stopButton: null, 62 hasMoved: function() {}, 63 movingUp: function() {}, 64 movingDown: function() {}, 65 start: function() {}, 66 stop: function() {}, 67 pause: function() {}, 68 unpause: function() {} 69 }; 70 71 function Plugin(element, options) { 72 this.element = element; 73 this.$el = $(element); 74 this.options = $.extend({}, defaults, options); 75 this._defaults = defaults; 76 this._name = pluginName; 77 this.moveInterval; 78 this.state = 0; 79 this.paused = 0; 80 this.moving = 0; 81 if (this.$el.is('ul, ol')) { 82 this.init(); 83 } 84 } 85 86 Plugin.prototype = { 87 init: function() { 88 this.$el.height(this.options.row_height * this.options.max_rows) 89 .css({overflow : 'hidden'}); 90 91 this.checkSpeed(); 92 93 if(this.options.nextButton && typeof(this.options.nextButton[0]) !== 'undefined') 94 this.options.nextButton.click(function(e) { 95 this.moveNext(); 96 this.resetInterval(); 97 }.bind(this)); 98 if(this.options.prevButton && typeof(this.options.prevButton[0]) !== 'undefined') 99 this.options.prevButton.click(function(e) { 100 this.movePrev(); 101 this.resetInterval(); 102 }.bind(this)); 103 if(this.options.stopButton && typeof(this.options.stopButton[0]) !== 'undefined') 104 this.options.stopButton.click(function(e) { 105 this.stop() 106 }.bind(this)); 107 if(this.options.startButton && typeof(this.options.startButton[0]) !== 'undefined') 108 this.options.startButton.click(function(e) { 109 this.start() 110 }.bind(this)); 111 112 if(this.options.pauseOnHover) { 113 this.$el.hover(function() { 114 if (this.state) 115 this.pause(); 116 }.bind(this), function() { 117 if (this.state) 118 this.unpause(); 119 }.bind(this)); 120 } 121 122 if(this.options.autostart) 123 this.start(); 124 }, 125 126 start: function() { 127 if (!this.state) { 128 this.state = 1; 129 this.resetInterval(); 130 this.options.start(); 131 } 132 }, 133 134 stop: function() { 135 if (this.state) { 136 clearInterval(this.moveInterval); 137 this.state = 0; 138 this.options.stop(); 139 } 140 }, 141 142 resetInterval: function() { 143 if (this.state) { 144 clearInterval(this.moveInterval); 145 this.moveInterval = setInterval(function() {this.move()}.bind(this), this.options.duration); 146 } 147 }, 148 149 move: function() { 150 if (!this.paused) this.moveNext(); 151 }, 152 153 moveNext: function() { 154 if (this.options.direction === 'down') 155 this.moveDown(); 156 else if (this.options.direction === 'up') 157 this.moveUp(); 158 }, 159 160 movePrev: function() { 161 if (this.options.direction === 'down') 162 this.moveUp(); 163 else if (this.options.direction === 'up') 164 this.moveDown(); 165 }, 166 167 pause: function() { 168 if (!this.paused) this.paused = 1; 169 this.options.pause(); 170 }, 171 172 unpause: function() { 173 if (this.paused) this.paused = 0; 174 this.options.unpause(); 175 }, 176 177 moveDown: function() { 178 if (!this.moving) { 179 this.moving = 1; 180 this.options.movingDown(); 181 this.$el.children('li:last').detach().prependTo(this.$el).css('marginTop', '-' + this.options.row_height + 'px') 182 .animate({marginTop: '0px'}, this.options.speed, function(){ 183 this.moving = 0; 184 this.options.hasMoved(); 185 }.bind(this)); 186 } 187 }, 188 189 moveUp: function() { 190 if (!this.moving) { 191 this.moving = 1; 192 this.options.movingUp(); 193 var element = this.$el.children('li:first'); 194 element.animate({marginTop: '-' + this.options.row_height + 'px'}, this.options.speed, 195 function(){ 196 element.detach().css('marginTop', '0').appendTo(this.$el); 197 this.moving = 0; 198 this.options.hasMoved(); 199 }.bind(this)); 200 } 201 }, 202 203 updateOption: function(option, value) { 204 if (typeof(this.options[option]) !== 'undefined'){ 205 this.options[option] = value; 206 if (option == 'duration' || option == 'speed'){ 207 this.checkSpeed(); 208 this.resetInterval(); 209 } 210 } 211 }, 212 213 add: function(content){ 214 this.$el.append($('<li>').html(content)); 215 }, 216 217 getState: function() { 218 if (paused) return 2 // 2 = paused 219 else return this.state;// 0 = stopped, 1 = started 220 }, 221 222 checkSpeed: function() { 223 if (this.options.duration < (this.options.speed + 25)) 224 this.options.speed = this.options.duration - 25; 225 }, 226 227 destroy: function() { 228 this._destroy(); // or this.delete; depends on jQuery version 229 } 230 }; 231 232 $.fn[pluginName] = function(option) { 233 var args = arguments; 234 235 return this.each(function() { 236 var $this = $(this), 237 data = $.data(this, 'plugin_' + pluginName), 238 options = typeof option === 'object' && option; 239 if (!data) { 240 $this.data('plugin_' + pluginName, (data = new Plugin(this, options))); 241 } 242 // if first argument is a string, call silimarly named function 243 if (typeof option === 'string') { 244 data[option].apply(data, Array.prototype.slice.call(args, 1)); 245 } 246 }); 247 }; 248})(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.