PageSourceSearch

https://wls-group.co.uk/wp-content/themes/wls/js/lib/jquery.textillate.js?ver=2021.05.16

js wls-group.co.uk collected 2026-10-09 23:34:57 UTC 8,034 bytes, 289 lines download raw bytes

vendor: 8,034 bytes, lines 1-289
1/*
2 * textillate.js
3 * http://jschr.github.com/textillate
4 * MIT licensed
5 *
6 * Copyright (C) 2012-2013 Jordan Schroter
7 */
8
9(function ($) {
10  "use strict";
11
12  function isInEffect (effect) {
13    return /In/.test(effect) || $.inArray(effect, $.fn.textillate.defaults.inEffects) >= 0;
14  };
15
16  function isOutEffect (effect) {
17    return /Out/.test(effect) || $.inArray(effect, $.fn.textillate.defaults.outEffects) >= 0;
18  };
19
20
21  function stringToBoolean(str) {
22    if (str !== "true" && str !== "false") return str;
23    return (str === "true");
24  };
25
26  // custom get data api method
27  function getData (node) {
28    var attrs = node.attributes || []
29      , data = {};
30
31    if (!attrs.length) return data;
32
33    $.each(attrs, function (i, attr) {
34      var nodeName = attr.nodeName.replace(/delayscale/, 'delayScale');
35      if (/^data-in-*/.test(nodeName)) {
36        data.in = data.in || {};
37        data.in[nodeName.replace(/data-in-/, '')] = stringToBoolean(attr.nodeValue);
38      } else if (/^data-out-*/.test(nodeName)) {
39        data.out = data.out || {};
40        data.out[nodeName.replace(/data-out-/, '')] =stringToBoolean(attr.nodeValue);
41      } else if (/^data-*/.test(nodeName)) {
42        data[nodeName.replace(/data-/, '')] = stringToBoolean(attr.nodeValue);
43      }
44    })
45
46    return data;
47  }
48
49  function shuffle (o) {
50      for (var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
51      return o;
52  }
53
54  function animate ($t, effect, cb) {
55    $t.addClass('animated ' + effect)
56      .css('visibility', 'visible')
57      .show();
58
59    $t.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
60        $t.removeClass('animated ' + effect);
61        cb && cb();
62    });
63  }
64
65  function animateTokens ($tokens, options, cb) {
66    var that = this
67      , count = $tokens.length;
68
69    if (!count) {
70      cb && cb();
71      return;
72    }
73
74    if (options.shuffle) $tokens = shuffle($tokens);
75    if (options.reverse) $tokens = $tokens.toArray().reverse();
76
77    $.each($tokens, function (i, t) {
78      var $token = $(t);
79
80      function complete () {
81        if (isInEffect(options.effect)) {
82          $token.css('visibility', 'visible');
83        } else if (isOutEffect(options.effect)) {
84          $token.css('visibility', 'hidden');
85        }
86        count -= 1;
87        if (!count && cb) cb();
88      }
89
90      var delay = options.sync ? options.delay : options.delay * i * options.delayScale;
91
92      $token.text() ?
93        setTimeout(function () { animate($token, options.effect, complete) }, delay) :
94        complete();
95    });
96  };
97
98  var Textillate = function (element, options) {
99    var base = this
100      , $element = $(element);
101
102    base.init = function () {
103      base.$texts = $element.find(options.selector);
104
105      if (!base.$texts.length) {
106        base.$texts = $('<ul class="texts"><li>' + $element.html() + '</li></ul>');
107        $element.html(base.$texts);
108      }
109
110      base.$texts.hide();
111
112      base.$current = $('<span>')
113        .html(base.$texts.find(':first-child').html())
114        .prependTo($element);
115
116      if (isInEffect(options.in.effect)) {
117        base.$current.css('visibility', 'hidden');
118      } else if (isOutEffect(options.out.effect)) {
119        base.$current.css('visibility', 'visible');
120      }
121
122      base.setOptions(options);
123
124      base.timeoutRun = null;
125
126      setTimeout(function () {
127        base.options.autoStart && base.start();
128      }, base.options.initialDelay)
129    };
130
131    base.setOptions = function (options) {
132      base.options = options;
133    };
134
135    base.triggerEvent = function (name) {
136      var e = $.Event(name + '.tlt');
137      $element.trigger(e, base);
138      return e;
139    };
140
141    base.in = function (index, cb) {
142      index = index || 0;
143
144      var $elem = base.$texts.find(':nth-child(' + ((index||0) + 1) + ')')
145        , options = $.extend(true, {}, base.options, $elem.length ? getData($elem[0]) : {})
146        , $tokens;
147
148      $elem.addClass('current');
149
150      base.triggerEvent('inAnimationBegin');
151      $element.attr('data-active', $elem.data('id'));
152
153      base.$current
154        .html($elem.html())
155        .lettering('words');
156
157      // split words to individual characters if token type is set to 'char'
158      if (base.options.type == "char") {
159        base.$current.find('[class^="word"]')
160            .css({
161              'display': 'inline-block',
162              // fix for poor ios performance
163              '-webkit-transform': 'translate3d(0,0,0)',
164              '-moz-transform': 'translate3d(0,0,0)',
165              '-o-transform': 'translate3d(0,0,0)',
166              'transform': 'translate3d(0,0,0)'
167            })
168            .each(function () { $(this).lettering() });
169      }
170
171      $tokens = base.$current
172        .find('[class^="' + base.options.type + '"]')
173        .css('display', 'inline-block');
174
175      if (isInEffect(options.in.effect)) {
176        $tokens.css('visibility', 'hidden');
177      } else if (isOutEffect(options.in.effect)) {
178        $tokens.css('visibility', 'visible');
179      }
180
181      base.currentIndex = index;
182
183      animateTokens($tokens, options.in, function () {
184        base.triggerEvent('inAnimationEnd');
185        if (options.in.callback) options.in.callback();
186        if (cb) cb(base);
187      });
188    };
189
190    base.out = function (cb) {
191      var $elem = base.$texts.find(':nth-child(' + ((base.currentIndex||0) + 1) + ')')
192        , $tokens = base.$current.find('[class^="' + base.options.type + '"]')
193        , options = $.extend(true, {}, base.options, $elem.length ? getData($elem[0]) : {})
194
195      base.triggerEvent('outAnimationBegin');
196
197      animateTokens($tokens, options.out, function () {
198        $elem.removeClass('current');
199        base.triggerEvent('outAnimationEnd');
200        $element.removeAttr('data-active');
201        if (options.out.callback) options.out.callback();
202        if (cb) cb(base);
203      });
204    };
205
206    base.start = function (index) {
207      setTimeout(function () {
208        base.triggerEvent('start');
209
210        (function run (index) {
211          base.in(index, function () {
212            var length = base.$texts.children().length;
213
214            index += 1;
215
216            if (!base.options.loop && index >= length) {
217              if (base.options.callback) base.options.callback();
218              base.triggerEvent('end');
219            } else {
220              index = index % length;
221
222              base.timeoutRun = setTimeout(function () {
223                base.out(function () {
224                  run(index)
225                });
226              }, base.options.minDisplayTime);
227            }
228          });
229        }(index || 0));
230      }, base.options.initialDelay);
231    };
232
233    base.stop = function () {
234      if (base.timeoutRun) {
235        clearInterval(base.timeoutRun);
236        base.timeoutRun = null;
237      }
238    };
239
240    base.init();
241  }
242
243  $.fn.textillate = function (settings, args) {
244    return this.each(function () {
245      var $this = $(this)
246        , data = $this.data('textillate')
247        , options = $.extend(true, {}, $.fn.textillate.defaults, getData(this), typeof settings == 'object' && settings);
248
249      if (!data) {
250        $this.data('textillate', (data = new Textillate(this, options)));
251      } else if (typeof settings == 'string') {
252        data[settings].apply(data, [].concat(args));
253      } else {
254        data.setOptions.call(data, options);
255      }
256    })
257  };
258
259  $.fn.textillate.defaults = {
260    selector: '.texts',
261    loop: false,
262    minDisplayTime: 2000,
263    initialDelay: 0,
264    in: {
265      effect: 'fadeInLeftBig',
266      delayScale: 1.5,
267      delay: 50,
268      sync: false,
269      reverse: false,
270      shuffle: false,
271      callback: function () {}
272    },
273    out: {
274      effect: 'hinge',
275      delayScale: 1.5,
276      delay: 50,
277      sync: false,
278      reverse: false,
279      shuffle: false,
280      callback: function () {}
281    },
282    autoStart: true,
283    inEffects: [],
284    outEffects: [ 'hinge' ],
285    callback: function () {},
286    type: 'char'
287  };
288
289}(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.