PageSourceSearch

https://chaminade.edu/wp-content/plugins/ditty-news-ticker/legacy/…/static/js/ditty-news-ticker.js?ver=3.1.69

js chaminade.edu collected 2026-09-24 09:38:08 UTC 49,814 bytes, 1,703 lines download raw bytes

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