PageSourceSearch

http://cathedral.uz.ua/wp-content/plugins/ditty-news-ticker/assets/js/ditty-news-ticker.js?ver=2.1.10

js cathedral.uz.ua collected 2026-10-02 21:44:09 UTC 36,608 bytes, 1,408 lines download raw bytes

1/**
2 * Ditty News Ticker
3 * Date: 10/06/2014
4 *
5 * @author Metaphor Creations
6 * @version 1.4.12
7 *
8 **/
9
10( function($) {
11
12	var methods = {
13
14		init : function( options ) {
15
16			return this.each( function(){
17
18				// Create default options
19				var settings = {
20					id										: '',
21					type									: 'scroll',
22					scroll_direction			: 'left',
23					scroll_speed					: 10,
24					scroll_pause					: 0,
25					scroll_spacing				: 40,
26					scroll_units					: 10,
27					scroll_init						: 0,
28					scroll_loop						: 1,
29					rotate_type						: 'fade',
30					auto_rotate						: 0,
31					rotate_delay					: 10,
32					rotate_pause					: 0,
33					rotate_speed					: 10,
34					rotate_ease						: 'easeOutExpo',
35					nav_reverse						: 0,
36					disable_touchswipe		: 0,
37					offset								: 20,
38					before_change					: function(){},
39					after_change					: function(){},
40					after_load						: function(){}
41				};
42
43
44				// Useful variables. Play carefully.
45        var vars = {
46        	id							: settings.id,
47	        tick_count			: 0,
48	        previous_tick		: 0,
49	        current_tick		: 0,
50	        next_tick				: 0,
51	        reverse					: 0,
52	        running					: 0,
53	        paused					: 0
54        };
55
56				// Add any set options
57				if (options) {
58					$.extend(settings, options);
59				}
60
61				// Create variables
62				var $container = $(this),
63						$ticker = $container.find('.mtphr-dnt-tick-contents'),
64						$nav_prev = $container.find('.mtphr-dnt-nav-prev'),
65						$nav_next = $container.find('.mtphr-dnt-nav-next'),
66						$nav_controls = $container.find('.mtphr-dnt-control-links'),
67						$play_pause = $container.find('.mtphr-dnt-play-pause'),
68						ticker_width = $ticker.outerWidth(),
69						ticker_height = 0,
70						ticks = [],
71						ticker_scroll,
72						ticker_scroll_resize = true,
73						ticker_delay,
74						rotate_adjustment = settings.rotate_type,
75						after_change_timeout,
76						ticker_pause = false,
77						offset = 20,
78						touch_down_x,
79						touch_down_y,
80						touch_link = '',
81						touch_target = '';
82
83				// Add the vars
84				$ticker.data('ditty:vars', vars);
85
86				
87
88
89
90		    /**
91		     * Initialize the ticker
92		     *
93		     * @since 1.0.0
94		     */
95		    function mtphr_dnt_init() {
96			    
97			    // Save the tick count & total
98					vars.tick_count = $ticker.find('.mtphr-dnt-tick').length;
99		    
100			    // Start the first tick
101					if( vars.tick_count > 0 ) {
102	
103						// Setup a ticker scroll
104						if( settings.type == 'scroll' ) {
105							mtphr_dnt_scroll_setup();
106	
107						// Setup a ticker rotator
108						} else if( settings.type == 'rotate' ) {
109							mtphr_dnt_rotator_setup();
110						}
111			    }
112			    
113			    // Trigger the afterLoad callback
114	        settings.after_load.call($container, $ticker);
115	        $container.trigger('mtphr_dnt_after_load_single', [vars, ticks]);
116	        $('body').trigger('mtphr_dnt_after_load', [$container, vars, ticks]);
117		    }
118
119
120
121		    /**
122		     * Setup the ticker scroll
123		     *
124		     * @since 1.1.0
125		     */
126		    function mtphr_dnt_scroll_set_height() {
127			    // Loop through the tick items
128					$ticker.find('.mtphr-dnt-tick').each( function(index) {
129
130						// Find the greatest tick height
131						if( $(this).height() > ticker_height ) {
132							ticker_height = $(this).height();
133						}
134
135						if( settings.scroll_direction == 'up' || settings.scroll_direction == 'down' ) {
136							$(this).css('height', 'auto');
137						}
138					});
139
140					// Set the ticker height
141					$ticker.css('height',ticker_height+'px');
142		    }
143		    
144		    function mtphr_dnt_scroll_setup() {
145
146		    	var $first = $ticker.find('.mtphr-dnt-tick:first');
147		    	if( $first.attr('style') ) {
148			    	var style = $first.attr('style');
149			    	var style_array = style.split('width:');
150			    	ticker_scroll_resize = (style_array.length > 1) ? false : true;
151		    	}
152		    	
153		    	// Reset the ticks
154		    	ticks = [];
155
156		    	//mtphr_dnt_scroll_set_height();
157					
158					$ticker.imagesLoaded( function() {
159					  mtphr_dnt_scroll_set_height();
160					  
161					  // Loop through the tick items
162						$ticker.find('.mtphr-dnt-tick').each( function(index) {
163	
164							// Make sure the ticker is visible
165							$(this).show();
166	
167							// Add the tick data
168							var tick = [{'headline':$(this)}];
169	
170							// Add the tick to the array
171							ticks.push(tick);
172						});
173	
174						// Set the initial position of the ticks
175						mtphr_dnt_scroll_reset_ticks();
176	
177						// Start the scroll loop
178						mtphr_dnt_scroll_loop();
179					});	
180
181					// Clear the loop on mouse hover
182					$ticker.hover(
183					  function () {
184					  	if( settings.scroll_pause ) {
185					    	mtphr_dnt_scroll_pause();
186					    }
187					  },
188					  function () {
189					  	if( settings.scroll_pause && !vars.paused ) {
190					    	mtphr_dnt_scroll_play();
191					    }
192					  }
193					);
194		    }
195		    
196		    function mtphr_dnt_scroll_pause() {
197			    clearInterval( ticker_scroll );
198		    }
199		    
200		    function mtphr_dnt_scroll_play() {
201			    mtphr_dnt_scroll_loop();
202		    }
203
204		    /**
205		     * Create the ticker scroll loop
206		     *
207		     * @since 1.0.8
208		     */
209		    function mtphr_dnt_scroll_loop() {
210
211			    // Start the ticker timer
212			    clearInterval( ticker_scroll );
213					ticker_scroll = setInterval( function() {
214
215						for( var i=0; i<vars.tick_count; i++ ) {
216
217							if( ticks[i][0].visible == true ) {
218
219								var pos = 'reset';
220
221								if( settings.scroll_direction == 'left' || settings.scroll_direction == 'right' ) {
222
223									pos = (settings.scroll_direction == 'left') ? mtphr_dnt_scroll_left(i) : mtphr_dnt_scroll_right(i);
224									if( pos == 'reset' ) {
225										pos = ticks[i][0].reset;
226										ticks[i][0].headline.stop(true,true).css('left',pos+'px');
227									} else {
228										ticks[i][0].headline.stop(true,true).animate( {
229											left: pos+'px'
230										}, 100, 'linear' );
231									}
232								} else {
233
234									pos = (settings.scroll_direction == 'up') ? mtphr_dnt_scroll_up(i) : mtphr_dnt_scroll_down(i);
235									if( pos == 'reset' ) {
236										pos = ticks[i][0].reset;
237										ticks[i][0].headline.stop(true,true).css('top',pos+'px');
238									} else {
239										ticks[i][0].headline.stop(true,true).animate( {
240											top: pos+'px'
241										}, 100, 'linear' );
242									}
243								}
244
245								ticks[i][0].position = pos;
246							}
247						}
248			    }, 100);
249		    }
250
251		    /**
252		     * Scroll the ticker left
253		     *
254		     * @since 1.0.0
255		     */
256		    function mtphr_dnt_scroll_left( i ) {
257
258			    // Find the new position
259					var pos = parseFloat(ticks[i][0].position - settings.scroll_speed);
260
261					// Reset the tick if off the screen
262					if( pos < -(ticks[i][0].headline.width()+settings.offset) ) {
263						pos = mtphr_dnt_scroll_check_current(i);
264					} else if( pos < parseFloat(ticker_width-ticks[i][0].headline.width()-settings.scroll_spacing) ) {
265						mtphr_dnt_scroll_check_next(i);
266					}
267
268					return pos;
269		    }
270
271		    /**
272		     * Scroll the ticker right
273		     *
274		     * @since 1.0.0
275		     */
276		    function mtphr_dnt_scroll_right( i ) {
277
278			    // Find the new position
279					var pos = ticks[i][0].position + settings.scroll_speed;
280
281					// Reset the tick if off the screen
282					if( pos > ticker_width+settings.offset ) {
283						pos = mtphr_dnt_scroll_check_current(i);
284					} else if( pos > settings.scroll_spacing ) {
285						mtphr_dnt_scroll_check_next(i);
286					}
287
288					return pos;
289		    }
290
291		    /**
292		     * Scroll the ticker up
293		     *
294		     * @since 1.0.0
295		     */
296		    function mtphr_dnt_scroll_up( i ) {
297
298			    // Find the new position
299					var pos = ticks[i][0].position - settings.scroll_speed;
300
301					// Reset the tick if off the screen
302					if( pos < -(ticks[i][0].headline.height()+settings.offset) ) {
303						pos = mtphr_dnt_scroll_check_current(i);
304					} else if( pos < ticker_height-ticks[i][0].headline.height()-settings.scroll_spacing ) {
305						mtphr_dnt_scroll_check_next(i);
306					}
307
308					return pos;
309		    }
310
311		    /**
312		     * Scroll the ticker down
313		     *
314		     * @since 1.0.0
315		     */
316		    function mtphr_dnt_scroll_down( i ) {
317
318			    // Find the new position
319					var pos = ticks[i][0].position + settings.scroll_speed;
320
321					// Reset the tick if off the screen
322					if( pos > ticker_height+settings.offset ) {
323						pos = mtphr_dnt_scroll_check_current(i);
324					} else if( pos > settings.scroll_spacing ) {
325						mtphr_dnt_scroll_check_next(i);
326					}
327
328					return pos;
329		    }
330
331		    /**
332		     * Check the current tick position
333		     *
334		     * @since 1.0.0
335		     */
336		    function mtphr_dnt_scroll_check_current( i ) {
337
338					if( vars.tick_count > 1 ) {
339						ticks[i][0].visible = false;
340					}
341					
342					// Add a scroll complete trigger
343					if( vars.tick_count == (i+1) ) {
344						$container.trigger('mtphr_dnt_scroll_complete', [vars, ticks]);
345	          $('body').trigger('mtphr_dnt_scroll_complete', [$container, vars, ticks]);
346					}
347
348					return 'reset';
349		    }
350		    
351		    
352		    function mtphr_dnt_set_scroll_vars( i ) {
353			    
354			    if( ticks[i][0].visible == false ) {
355						vars.previous_tick = parseInt(i-1);
356						if( vars.previous_tick < 0 ) {
357							vars.previous_tick = parseInt(vars.tick_count-1);
358						}
359						vars.current_tick = i;
360						vars.next_tick = parseInt(i+1);
361						if( vars.next_tick >= vars.tick_count ) {
362							vars.next_tick = 0;
363						}
364					}
365		    }
366
367		    /**
368		     * Check the next tick visibility
369		     *
370		     * @since 1.0.0
371		     */
372		    function mtphr_dnt_scroll_check_next( i ) {
373
374					if( i==(vars.tick_count-1) ) {
375						if( settings.scroll_loop ) {
376							mtphr_dnt_set_scroll_vars(0);
377							ticks[0][0].visible = true;
378						}
379					} else {
380						mtphr_dnt_set_scroll_vars(parseInt(i+1));
381						ticks[(i+1)][0].visible = true;
382					}
383		    }
384
385		    /**
386		     * Resize the scroll ticks
387		     *
388		     * @since 1.1.0
389		     */
390		    function mtphr_dnt_scroll_resize_ticks() {
391
392			    for( var i=0; i<vars.tick_count; i++ ) {
393
394				    // Set the tick position
395						var position;
396
397						var $tick = ticks[i][0].headline;
398
399						switch( settings.scroll_direction ) {
400							case 'left':
401								position = ticker_width+settings.offset;
402								if( ticks[i][0].visible == false ) {
403									$tick.css('left',position+'px');
404								}
405								break;
406
407							case 'right':
408								position = parseInt('-'+($tick.width()+settings.offset));
409								if( ticks[i][0].visible == false ) {
410									$tick.css('left',position+'px');
411								}
412								break;
413
414							case 'up':
415								if( ticker_scroll_resize ) {
416									$tick.css('width',ticker_width);
417								}
418								position = parseInt(ticker_height+settings.offset);
419								if( ticks[i][0].visible == false ) {
420									$tick.css('top',position+'px');
421								}
422								break;
423
424							case 'down':
425								if( ticker_scroll_resize ) {
426									$tick.css('width',ticker_width);
427								}
428								position = parseInt('-'+($tick.height()+settings.offset));
429								if( ticks[i][0].visible == false ) {
430									$tick.css('top',position+'px');
431								}
432								break;
433						}
434
435						// Adjust the tick data
436						ticks[i][0].width = $tick.width();
437						ticks[i][0].height = $tick.height();
438						if( ticks[i][0].visible == false ) {
439							ticks[i][0].position = position;
440						}
441						ticks[i][0].reset = position;
442			    }
443		    }
444
445		    /**
446		     * Reset the scroller for vertical scrolls
447		     *
448		     * @since 1.1.0
449		     */
450		    function mtphr_dnt_scroll_reset_ticks() {
451
452		    	for( var i=0; i<vars.tick_count; i++ ) {
453
454		    		var $tick = ticks[i][0].headline;
455		    		
456						switch( settings.scroll_direction ) {
457							case 'left':
458								position = ticker_width+settings.offset;
459								$tick.stop(true,true).css('left',position+'px');
460								break;
461
462							case 'right':
463								position = parseInt('-'+($tick.width()+settings.offset));
464								$tick.stop(true,true).css('left',position+'px');
465								break;
466
467							case 'up':
468								if( ticker_scroll_resize ) {
469									$tick.css('width',ticker_width);
470								}
471								position = parseInt(ticker_height+settings.offset);
472								$tick.stop(true,true).css('top',position+'px');
473								break;
474
475							case 'down':
476								if( ticker_scroll_resize ) {
477									$tick.css('width',ticker_width);
478								}
479								position = parseInt('-'+($tick.height()+settings.offset));
480								$tick.stop(true,true).css('top',position+'px');
481								break;
482						}
483
484						ticks[i][0].width = $tick.width();
485						ticks[i][0].height = $tick.height();
486						ticks[i][0].position = position;
487						ticks[i][0].reset = position;
488						ticks[i][0].visible = false;
489			    }
490
491					// Reset the current tick
492					vars.current_tick = 0;
493
494					// Set the first tick visibility
495					ticks[vars.current_tick][0].visible = true;
496
497					// Set the ticks to display on init
498					if( settings.scroll_init ) {
499
500						var position = 0;
501						if( settings.scroll_direction == 'left' ) {
502							position = ticker_width*.1;
503						} else if( settings.scroll_direction == 'right' ) {
504							position = ticker_width*.9;
505						} else if( settings.scroll_direction == 'up' ) {
506							position = ticker_height*.1;
507						} else if( settings.scroll_direction == 'down' ) {
508							position = ticker_height*.9;
509						}
510
511						for( var i=0; i<vars.tick_count; i++ ) {
512
513			    		var $tick = ticks[i][0].headline;
514
515							switch( settings.scroll_direction ) {
516								case 'left':
517									if( position < ticker_width ) {
518										$tick.stop(true,true).css('left',position+'px');
519										ticks[i][0].position = position;
520										ticks[i][0].visible = true;
521										position = position + ticks[i][0].width + settings.scroll_spacing;
522									}
523									break;
524
525								case 'right':
526									if( position > 0 ) {
527										position = position - ticks[i][0].width;
528										$tick.stop(true,true).css('left',position+'px');
529										ticks[i][0].position = position;
530										ticks[i][0].visible = true;
531										position = position - settings.scroll_spacing;
532									}
533									break;
534
535								case 'up':
536									if( position < ticker_height ) {
537										$tick.stop(true,true).css('top',position+'px');
538										ticks[i][0].position = position;
539										ticks[i][0].visible = true;
540										position = position + ticks[i][0].height + settings.scroll_spacing;
541									}
542									break;
543
544								case 'down':
545									if( position > 0 ) {
546										position = position - ticks[i][0].height;
547										$tick.stop(true,true).css('top',position+'px');
548										ticks[i][0].position = position;
549										ticks[i][0].visible = true;
550										position = position - settings.scroll_spacing;
551									}
552									break;
553							}
554						}
555			    }
556		    }
557
558				
559				function mtphr_dnt_rotator_play() {
560					mtphr_dnt_rotator_delay();
561				}
562				
563				function mtphr_dnt_rotator_pause() {
564					clearInterval( ticker_delay );
565				}
566
567
568		    /**
569		     * Setup the ticker rotator
570		     *
571		     * @since 1.0.8
572		     */
573		    function mtphr_dnt_rotator_setup() {
574
575		    	// Loop through the tick items
576					$ticker.find('.mtphr-dnt-tick').each( function(index) {
577
578						// Add the tick to the array
579						ticks.push($(this));
580						$(this).imagesLoaded( function() {
581						  mtphr_dnt_rotator_resize_ticks();
582						});
583					});
584
585					// Resize the ticks
586					mtphr_dnt_rotator_resize_ticks();
587					
588					// Loop through the tick items
589					$ticker.find('.mtphr-dnt-tick').show();
590
591					// Find the rotation type and create the dynamic rotation init function
592					var rotate_init_name = 'mtphr_dnt_rotator_'+settings.rotate_type+'_init';
593					var mtphr_dnt_rotator_type_init = eval('('+rotate_init_name+')');
594					mtphr_dnt_rotator_type_init( $ticker, ticks, parseInt(settings.rotate_speed*100), settings.rotate_ease );
595					mtphr_dnt_rotator_update_links( 0 );
596
597					// Start the rotator rotate
598					if( settings.auto_rotate ) {
599						mtphr_dnt_rotator_play();
600					}
601
602					// Clear the loop on mouse hover
603					$ticker.hover(
604					  function (e) {
605					  	if( settings.auto_rotate && settings.rotate_pause && !vars.running ) {
606					    	mtphr_dnt_rotator_pause();
607					    }
608					  },
609					  function () {
610					  	if( settings.auto_rotate && settings.rotate_pause  && !vars.running && !vars.paused ) {
611					    	mtphr_dnt_rotator_play();
612					    }
613					  }
614					);
615		    }
616
617		    /**
618		     * Create the ticker rotator loop
619		     *
620		     * @since 1.0.0
621		     */
622		    function mtphr_dnt_rotator_delay() {
623
624			    // Start the ticker timer
625			    mtphr_dnt_rotator_pause();
626					ticker_delay = setInterval( function() {
627
628						// Find the new tick
629			    	var new_tick = parseInt(vars.current_tick + 1);
630						if( new_tick == vars.tick_count ) {
631							new_tick = 0;
632						}
633
634						mtphr_dnt_rotator_update( new_tick );
635
636			    }, parseInt(settings.rotate_delay*1000));
637		    }
638
639		    /**
640		     * Create the rotator update call
641		     *
642		     * @since 1.1.7
643		     */
644		    function mtphr_dnt_rotator_update( new_tick ) {
645
646		    	if( vars.current_tick != new_tick ) {
647
648			    	// Clear the interval
649			    	if( settings.auto_rotate ) {
650				    	mtphr_dnt_rotator_pause();
651				    }
652				    
653				    // Set the next variable
654						vars.next_tick = new_tick;
655
656			    	// Trigger the before change callback
657	          settings.before_change.call( $container, $ticker );
658	          $container.trigger('mtphr_dnt_before_change_single', [vars, ticks]);
659	          $('body').trigger('mtphr_dnt_before_change', [$container, vars, ticks]);
660
661	          // Set the running variable
662	          vars.running = 1;
663
664				    // Rotate the current tick out
665						mtphr_dnt_rotator_out( new_tick );
666
667						// Rotate the new tick in
668						mtphr_dnt_rotator_in( new_tick );
669
670						// Set the previous & current tick
671						vars.previous_tick = vars.current_tick;
672						vars.current_tick = new_tick;
673
674						// Trigger the after change callback
675						after_change_timeout = setTimeout( function() {
676
677							settings.after_change.call( $container, $ticker );
678							$container.trigger('mtphr_dnt_after_change_single', [vars, ticks]);
679							$('body').trigger('mtphr_dnt_after_change', [$container, vars, ticks]);
680
681							// Reset the rotator type & variables
682							rotate_adjustment = settings.rotate_type;
683							vars.reverse = 0;
684							vars.running = 0;
685
686							// Restart the interval
687							if( settings.auto_rotate && !vars.paused ) {
688					    	mtphr_dnt_rotator_delay();
689					    }
690
691						}, parseInt(settings.rotate_speed*100) );
692					}
693		    }
694
695		    /**
696		     * Update the control links
697		     *
698		     * @since 1.0.0
699		     */
700		    function mtphr_dnt_rotator_update_links( new_tick ) {
701
702			    if( $nav_controls ) {
703          	$nav_controls.children('a').removeClass('active');
704          	$nav_controls.children('a[href="'+new_tick+'"]').addClass('active');
705          }
706		    }
707
708		    /**
709		     * Create the rotator in function calls
710		     *
711		     * @since 1.0.0
712		     */
713		    function mtphr_dnt_rotator_in( new_tick ) {
714
715		    	// Update the links
716		    	mtphr_dnt_rotator_update_links( new_tick );
717
718			    // Find the rotation type and create the dynamic rotation in function
719					var rotate_in_name = 'mtphr_dnt_rotator_'+rotate_adjustment+'_in';
720					var mtphr_dnt_rotator_type_in = eval('('+rotate_in_name+')');
721					mtphr_dnt_rotator_type_in( $ticker, $(ticks[new_tick]), $(ticks[vars.current_tick]), parseInt(settings.rotate_speed*100), settings.rotate_ease );
722		    }
723
724		    /**
725		     * Create the rotator out function calls
726		     *
727		     * @since 1.0.0
728		     */
729		    function mtphr_dnt_rotator_out( new_tick ) {
730
731			    // Find the rotation type and create the dynamic rotation out function
732					var rotate_out_name = 'mtphr_dnt_rotator_'+rotate_adjustment+'_out';
733					var mtphr_dnt_rotator_type_out = eval('('+rotate_out_name+')');
734					mtphr_dnt_rotator_type_out( $ticker, $(ticks[vars.current_tick]), $(ticks[new_tick]), parseInt(settings.rotate_speed*100), settings.rotate_ease );
735		    }
736
737		    /**
738		     * Resize the rotator ticks
739		     *
740		     * @since 1.0.8
741		     */
742		    function mtphr_dnt_rotator_resize_ticks() {
743
744			    for( var i=0; i<vars.tick_count; i++ ) {
745
746				    // Set the width of the tick
747				    $(ticks[i]).width( ticker_width+'px' );
748				    if( vars.current_tick !== i ) {
749					    $(ticks[i]).css({
750								left: parseFloat(ticker_width+settings.offset)+'px'
751							});
752						}
753			    }
754
755			    // Resize the ticker
756			    var h = $(ticks[vars.current_tick]).height();
757					$ticker.stop().css( 'height', h+'px' );
758		    }
759
760
761
762
763		    /**
764		     * Rotator fade scripts
765		     *
766		     * @since 1.0.0
767		     */
768				function mtphr_dnt_rotator_fade_init( $ticker, ticks, rotate_speed, ease ) {
769
770					// Get the first tick
771					$tick = ticks[0];
772
773					// Find the width of the tick
774					var h = $tick.height();
775
776					// Set the height of the ticker
777					$ticker.css( 'height', h+'px' );
778					$tick.css({
779						opacity: 1,
780						left:  'auto' 
781					});
782			  }
783
784				// Show the new tick
785				function mtphr_dnt_rotator_fade_in( $ticker, $tick, $prev, rotate_speed, ease ) {
786			    $tick.css({
787				    opacity: 0,
788				    left: 'auto'
789				  });
790				  $tick.stop().animate( {
791						opacity: 1
792					}, rotate_speed, ease );
793
794			    var h = $tick.height();
795
796					// Resize the ticker
797					$ticker.stop().animate( {
798						height: h+'px'
799					}, rotate_speed, ease );
800			  }
801
802			  // Hide the old tick
803			  function mtphr_dnt_rotator_fade_out( $ticker, $tick, $next, rotate_speed, ease ) {
804			    $tick.stop().animate( {
805						opacity: 0
806					}, rotate_speed, ease, function() {
807						$(this).css({
808							left: parseFloat(ticker_width+settings.offset)+'px'
809						});
810						$tick.remove();
811						$ticker.append( $tick );
812					});
813			  }
814
815
816
817
818			  /**
819		     * Rotator slide left scripts
820		     *
821		     * @since 1.0.0
822		     */
823				function mtphr_dnt_rotator_slide_left_init( $ticker, ticks, rotate_speed, ease ) {
824
825					// Get the first tick
826					$tick = ticks[0];
827
828					// Find the dimensions of the tick
829					var h = $tick.height();
830
831					// Set the height of the ticker
832					$ticker.css( 'height', h+'px' );
833
834					// Set the initial position of the width & make sure it's visible
835					$tick.css({
836						opacity: 1,
837						left:  0 
838					});
839			  }
840
841				// Show the new tick
842				function mtphr_dnt_rotator_slide_left_in( $ticker, $tick, $prev, rotate_speed, ease ) {
843
844					// Find the dimensions of the tick
845					var h = $tick.height();
846
847					// Set the initial position of the width & make sure it's visible
848					$tick.css({
849						opacity: 1,
850						left: parseFloat(ticker_width+settings.offset)+'px',
851					});
852
853					// Resize the ticker
854					$ticker.stop().animate( {
855						height: h+'px'
856					}, rotate_speed, ease, function() {
857					});
858
859					// Slide the tick in
860					$tick.stop().animate( {
861						left: '0'
862					}, rotate_speed, ease, function() {
863					});
864			  }
865
866			  // Hide the old tick
867			  function mtphr_dnt_rotator_slide_left_out( $ticker, $tick, $next, rotate_speed, ease ) {
868
869			    // Find the dimensions of the tick
870					var h = $tick.height();
871
872					// Slide the tick in
873					$tick.stop().animate( {
874						left: '-'+parseFloat(ticker_width+settings.offset)+'px'
875					}, rotate_speed, ease, function() {
876						$tick.css({
877							opacity: 0,
878						});
879						$tick.remove();
880						$ticker.append( $tick );
881					});
882			  }
883
884
885
886
887			  /**
888			   * Rotator slide right scripts
889			   *
890			   * @since 1.0.0
891			   */
892				function mtphr_dnt_rotator_slide_right_init( $ticker, ticks, rotate_speed, ease ) {
893
894					// Get the first tick
895					$tick = ticks[0];
896
897					// Find the dimensions of the tick
898					var h = $tick.height();
899
900					// Set the height of the ticker
901					$ticker.css( 'height', h+'px' );
902
903					// Set the initial position of the width & make sure it's visible
904					$tick.css({
905						opacity: 1,
906						left:  0 
907					});
908			  }
909
910				// Show the new tick
911				function mtphr_dnt_rotator_slide_right_in( $ticker, $tick, $prev, rotate_speed, ease ) {
912
913					// Find the dimensions of the tick
914					var h = $tick.height();
915
916					// Set the initial position of the width & make sure it's visible
917					$tick.css({
918						opacity: 1,
919						left: '-'+parseFloat(ticker_width+settings.offset)+'px'
920					});
921
922					// Resize the ticker
923					$ticker.stop().animate( {
924						height: h+'px'
925					}, rotate_speed, ease, function() {
926					});
927
928					// Slide the tick in
929					$tick.stop().animate( {
930						left: '0'
931					}, rotate_speed, ease );
932			  }
933
934			  // Hide the old tick
935			  function mtphr_dnt_rotator_slide_right_out( $ticker, $tick, $next, rotate_speed, ease ) {
936
937					// Slide the tick in
938					$tick.stop().animate( {
939						left: parseFloat(ticker_width+settings.offset)+'px'
940					}, rotate_speed, ease, function() {
941						$tick.css({
942							opacity: 0,
943						});
944						$tick.remove();
945						$ticker.append( $tick );
946					});
947			  }
948
949
950
951
952			  /**
953			   * Rotator slide down scripts
954			   *
955			   * @since 1.0.0
956			   */
957				function mtphr_dnt_rotator_slide_down_init( $ticker, ticks, rotate_speed, ease ) {
958
959					// Get the first tick
960					$tick = ticks[0];
961
962					// Find the height of the tick
963					var h = $tick.height();
964
965					// Set the height of the ticker
966					$ticker.css( 'height', h+'px' );
967
968					// Set the initial position of the width & make sure it's visible
969					$tick.css({
970						opacity: 1,
971						top: 0,
972						left: 'auto'
973					});
974			  }
975
976				// Show the new tick
977				function mtphr_dnt_rotator_slide_down_in( $ticker, $tick, $prev, rotate_speed, ease ) {
978
979					// Find the height of the tick
980					var h = $tick.height();
981
982					// Set the initial position of the width & make sure it's visible
983					$tick.css({
984						opacity: 1,
985						top: '-'+parseFloat(h+settings.offset)+'px',
986						left: 'auto'
987					});
988
989					// Resize the ticker
990					$ticker.stop().animate( {
991						height: h+'px'
992					}, rotate_speed, ease );
993
994					// Slide the tick in
995					$tick.stop().animate( {
996						top: '0'
997					}, rotate_speed, ease );
998			  }
999
1000			  // Hide the old tick
1001			  function mtphr_dnt_rotator_slide_down_out( $ticker, $tick, $next, rotate_speed, ease ) {
1002
1003			    // Find the height of the next tick
1004					var h = $next.height();
1005
1006					// Slide the tick in
1007					$tick.stop().animate( {
1008						top: parseFloat(h+settings.offset)+'px'
1009					}, rotate_speed, ease, function() {
1010						$tick.css({
1011							opacity: 0,
1012						});
1013						$tick.remove();
1014						$ticker.append( $tick );
1015					});
1016			  }
1017
1018
1019
1020
1021			  /**
1022			   * Rotator slide up scripts
1023			   *
1024			   * @since 1.0.0
1025			   */
1026				function mtphr_dnt_rotator_slide_up_init( $ticker, ticks, rotate_speed, ease ) {
1027
1028					// Get the first tick
1029					$tick = ticks[0];
1030
1031					// Find the height of the tick
1032					var h = $tick.height();
1033
1034					// Set the height of the ticker
1035					$ticker.css({
1036						height: h+'px',
1037						left: 'auto'
1038					});
1039
1040					// Set the initial position of the width & make sure it's visible
1041					$tick.css({
1042						opacity: 1,
1043						top: 0
1044					});
1045			  }
1046
1047				// Show the new tick
1048				function mtphr_dnt_rotator_slide_up_in( $ticker, $tick, $prev, rotate_speed, ease ) {
1049
1050					// Find the height of the tick
1051					var h = $tick.height();
1052
1053					// Set the initial position of the width & make sure it's visible
1054					$tick.css({
1055						opacity: 1,
1056						top: parseFloat($prev.height()+settings.offset)+'px',
1057						left: 'auto'
1058					});
1059
1060					// Resize the ticker
1061					$ticker.stop().animate( {
1062						height: h+'px'
1063					}, rotate_speed, ease );
1064
1065					// Slide the tick in
1066					$tick.stop().animate( {
1067						top: '0'
1068					}, rotate_speed, ease );
1069			  }
1070
1071			  // Hide the old tick
1072			  function mtphr_dnt_rotator_slide_up_out( $ticker, $tick, $next, rotate_speed, ease ) {
1073
1074			    // Find the height of the next tick
1075					var h = $tick.height();
1076
1077					// Slide the tick in
1078					$tick.stop().animate( {
1079						top: '-'+parseFloat(h+settings.offset)+'px'
1080					}, rotate_speed, ease, function() {
1081						$tick.css({
1082							opacity: 0,
1083						});
1084						$tick.remove();
1085						$ticker.append( $tick );
1086					});
1087			  }
1088			  
1089			  
1090			  
1091			  
1092			  /* --------------------------------------------------------- */
1093			  /* !Set the next item */
1094			  /* --------------------------------------------------------- */
1095			  
1096			  function mtphr_dnt_next() {
1097				  
1098				  if(vars.running) return false;
1099
1100		    	// Find the new tick
1101		    	var new_tick = parseInt(vars.current_tick + 1);
1102					if( new_tick == vars.tick_count ) {
1103						new_tick = 0;
1104					}
1105					mtphr_dnt_rotator_update( new_tick );
1106			  }
1107			  
1108			  /* --------------------------------------------------------- */
1109			  /* !Set the previous item */
1110			  /* --------------------------------------------------------- */
1111			  
1112			  function mtphr_dnt_prev() {
1113				  
1114				  if(vars.running) return false;
1115
1116		    	// Find the new tick
1117		    	var new_tick = parseInt(vars.current_tick-1);
1118					if( new_tick < 0 ) {
1119						new_tick = vars.tick_count-1;
1120					}
1121					if( settings.nav_reverse ) {
1122						if( settings.rotate_type == 'slide_left' ) {
1123							rotate_adjustment = 'slide_right';
1124						} else if( settings.rotate_type == 'slide_right' ) {
1125							rotate_adjustment = 'slide_left';
1126						} else if( settings.rotate_type == 'slide_down' ) {
1127							rotate_adjustment = 'slide_up';
1128						} else if( settings.rotate_type == 'slide_up' ) {
1129							rotate_adjustment = 'slide_down';
1130						}
1131						vars.reverse = 1;
1132					}
1133					mtphr_dnt_rotator_update( new_tick );
1134			  }
1135
1136
1137		    /**
1138		     * Navigation clicks
1139		     *
1140		     * @since 1.0.0
1141		     */
1142		    if( $nav_prev && settings.type == 'rotate' ) {
1143
1144		    	$nav_prev.bind('click', function( e ) {
1145		    		e.preventDefault();
1146						mtphr_dnt_prev();
1147		    	});
1148
1149		    	$nav_next.bind('click', function(e) {
1150		    		e.preventDefault();
1151						mtphr_dnt_next();
1152		    	});
1153		    }
1154
1155
1156
1157
1158		    /**
1159		     * Nav controls
1160		     *
1161		     * @since 1.0.2
1162		     */
1163		    if( $nav_controls && settings.type == 'rotate' ) {
1164
1165			    $nav_controls.children('a').bind('click', function( e ) {
1166		    		e.preventDefault();
1167
1168		    		// Find the new tick
1169			    	var new_tick = parseInt( $(this).attr('href') );
1170
1171		    		if(vars.running) return false;
1172		    		if(new_tick == vars.current_tick) return false;
1173
1174			    	var reverse = ( new_tick < vars.current_tick ) ? 1 : 0;
1175
1176		    		if( settings.nav_reverse && reverse ) {
1177							if( settings.rotate_type == 'slide_left' ) {
1178								rotate_adjustment = 'slide_right';
1179							} else if( settings.rotate_type == 'slide_right' ) {
1180								rotate_adjustment = 'slide_left';
1181							} else if( settings.rotate_type == 'slide_down' ) {
1182								rotate_adjustment = 'slide_up';
1183							} else if( settings.rotate_type == 'slide_up' ) {
1184								rotate_adjustment = 'slide_down';
1185							}
1186							vars.reverse = 1;
1187						}
1188						mtphr_dnt_rotator_update( new_tick );
1189		    	});
1190		    }
1191		    
1192		    
1193		    
1194		    /* --------------------------------------------------------- */
1195		    /* !Play and pause - 2.0.4 */
1196		    /* --------------------------------------------------------- */
1197		    
1198		    function mtphr_dnt_play_pause_toggle( play ) {
1199			    if( play ) {
1200				    vars.paused = false;
1201				    $play_pause.removeClass('paused');
1202				    if( settings.type == 'scroll' ) {
1203				    	mtphr_dnt_scroll_play();
1204				    } else {
1205					    mtphr_dnt_rotator_play();
1206				    }
1207			    } else {
1208				    vars.paused = true;
1209				    $play_pause.addClass('paused');
1210				    if( settings.type == 'scroll' ) {
1211				    	mtphr_dnt_scroll_pause();
1212				    } else {
1213					    mtphr_dnt_rotator_pause();
1214				    }
1215			    }
1216			    $container.trigger('mtphr_dnt_play_pause', [vars, ticks]);
1217		    }
1218		    
1219		    $play_pause.bind('click', function(e) {
1220			    e.preventDefault();
1221			    mtphr_dnt_play_pause_toggle( vars.paused );
1222		    });
1223
1224
1225
1226
1227		    /* --------------------------------------------------------- */
1228		    /* !Mobile swipe - 1.5.0 */
1229		    /* --------------------------------------------------------- */
1230		    
1231				if( settings.type == 'rotate' && !settings.disable_touchswipe ) {
1232					
1233					$ticker.swipe( {
1234						triggerOnTouchEnd : true,
1235		        swipeLeft: function(event, distance, duration, fingerCount, fingerData) {
1236		          
1237		          if(vars.running) return false;
1238
1239				    	// Find the new tick
1240				    	var new_tick = parseInt(vars.current_tick + 1);
1241							if( new_tick == vars.tick_count ) {
1242								new_tick = 0;
1243							}
1244							if( settings.rotate_type == 'slide_left' || settings.rotate_type == 'slide_right' ) {
1245								rotate_adjustment = 'slide_left';
1246							}
1247							mtphr_dnt_rotator_update( new_tick );
1248		        },
1249		        swipeRight: function(event, distance, duration, fingerCount, fingerData) {
1250		          
1251		          if(vars.running) return false;
1252
1253				    	// Find the new tick
1254				    	var new_tick = parseInt(vars.current_tick-1);
1255							if( new_tick < 0 ) {
1256								new_tick = vars.tick_count-1;
1257							}
1258							if( settings.rotate_type == 'slide_left' || settings.rotate_type == 'slide_right' ) {
1259								rotate_adjustment = 'slide_right';
1260							}
1261							if( settings.nav_reverse ) {
1262								if( settings.rotate_type == 'slide_down' ) {
1263									rotate_adjustment = 'slide_up';
1264								} else if( settings.rotate_type == 'slide_up' ) {
1265									rotate_adjustment = 'slide_down';
1266								}
1267								vars.reverse = 1;
1268							}
1269							mtphr_dnt_rotator_update( new_tick );
1270		        }
1271		      });
1272				}
1273				
1274				
1275				
1276				/* --------------------------------------------------------- */
1277		    /* !Listen for external events - 1.4.1 */
1278		    /* --------------------------------------------------------- */
1279
1280		    $container.on('mtphr_dnt_next', function( e ) {
1281		    	mtphr_dnt_next();
1282				});
1283				
1284				$container.on('mtphr_dnt_prev', function( e ) {
1285		    	mtphr_dnt_prev();
1286				});
1287				
1288				$container.on('mtphr_dnt_goto', function( e, pos ) {
1289		    	mtphr_dnt_rotator_update( parseInt(pos) );
1290				});
1291				
1292				$container.on('mtphr_dnt_pause', function( e, pos ) {
1293		    	mtphr_dnt_play_pause_toggle();
1294				});
1295				
1296				$container.on('mtphr_dnt_play', function( e, pos ) {
1297		    	mtphr_dnt_play_pause_toggle( true );
1298				});
1299
1300
1301
1302		    /**
1303		     * Resize listener
1304		     * Reset the ticker width
1305		     *
1306		     * @since 1.4.1
1307		     */
1308		    $(window).resize( function() {
1309
1310			    // Resize the tickers if the width is different
1311			    if( $ticker.outerWidth() != ticker_width ) {
1312
1313				    ticker_width = $ticker.outerWidth();
1314
1315				    if( settings.type == 'scroll' ) {
1316				    	if( settings.scroll_direction=='up' || settings.scroll_direction=='down' ) {
1317				    		if( ticker_scroll_resize ) {
1318				    			mtphr_dnt_scroll_reset_ticks();
1319				    		} else {
1320					    		mtphr_dnt_scroll_resize_ticks();
1321				    		}
1322				    	} else {
1323					    	mtphr_dnt_scroll_resize_ticks();
1324				    	}
1325				    } else if( settings.type == 'rotate' ) {
1326					    mtphr_dnt_rotator_resize_ticks();
1327				    }
1328			    }
1329		    });
1330		    
1331		    
1332		    /* --------------------------------------------------------- */
1333		    /* !Listen for resize event from other plugins - 1.4.1 */
1334		    /* --------------------------------------------------------- */
1335				
1336				$container.on('mtphr_dnt_resize_single', function( e ) {
1337					if( settings.type == 'scroll' ) {
1338						mtphr_dnt_scroll_resize_ticks();
1339					} else if( settings.type == 'rotate' ) {
1340				    mtphr_dnt_rotator_resize_ticks();
1341			    }
1342				});
1343		    $('body').on('mtphr_dnt_resize', function( e, id ) {
1344		    	if( id && (id.indexOf(settings.id) >= 0) ) {
1345						if( settings.type == 'scroll' ) {
1346							mtphr_dnt_scroll_resize_ticks();
1347						} else if( settings.type == 'rotate' ) {
1348					    mtphr_dnt_rotator_resize_ticks();
1349				    } 
1350			    }
1351				});
1352				
1353				$container.on('mtphr_dnt_replace_ticks', function( e, ticks, delay ) {
1354					
1355					clearInterval( ticker_scroll );
1356					$container.find('.mtphr-dnt-tick').remove();
1357					
1358					ticks.each( function(index) {
1359						$ticker.append( $(this) );
1360					});
1361
1362					setTimeout( function() {
1363						mtphr_dnt_init();
1364					}, delay );
1365					
1366				});
1367				
1368				if( $container.width() == 0 ) {
1369			    
1370			    var mtphr_dnt_init_timer = setInterval( function() {
1371
1372			    	if( $container.width() > 10 ) {
1373				    	clearInterval(mtphr_dnt_init_timer);
1374				    	ticker_width = $ticker.outerWidth();
1375				    	mtphr_dnt_init();
1376			    	}
1377			    	
1378			    }, 100 );
1379			    
1380		    } else {
1381			    mtphr_dnt_init();
1382		    }
1383
1384			});
1385		}
1386	};
1387
1388
1389
1390
1391
1392	/**
1393	 * Setup the class
1394	 *
1395	 * @since 1.0.0
1396	 */
1397	$.fn.ditty_news_ticker = function( method ) {
1398
1399		if ( methods[method] ) {
1400			return methods[method].apply( this, Array.prototype.slice.call(arguments, 1) );
1401		} else if ( typeof method === 'object' || !method ) {
1402			return methods.init.apply( this, arguments );
1403		} else {
1404			$.error( 'Method ' +  method + ' does not exist in ditty_news_ticker' );
1405		}
1406	};
1407
1408})( 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.