PageSourceSearch

https://mollereiendom.no/wp-content/plugins/bb-ultimate-addon/modules/fancy-text/js/typed.js?ver=7.1.2

js mollereiendom.no collected 2026-10-05 01:19:48 UTC 12,509 bytes, 267 lines download raw bytes

1// The MIT License (MIT)
2// Typed.js | Copyright (c) 2014 Matt Boldt | www.mattboldt.com
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9// The above copyright notice and this permission notice shall be included in
10// all copies or substantial portions of the Software.
11// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17// THE SOFTWARE.
18!function($){
19    "use strict";
20    var Typed = function(el, options){
21        // chosen element to manipulate text
22        this.el = $(el);
23        // options
24        this.options = $.extend({}, $.fn.typed.defaults, options);
25        // text content of element
26        this.baseText = this.el.text() || this.el.attr('placeholder') || '';
27        // typing speed
28        this.typeSpeed = this.options.typeSpeed;
29        // add a delay before typing starts
30        this.startDelay = this.options.startDelay;
31        // backspacing speed
32        this.backSpeed = this.options.backSpeed;
33        // amount of time to wait before backspacing
34        this.backDelay = this.options.backDelay;
35        // input strings of text
36        this.strings = this.options.strings;
37        // character number position of current string
38        this.strPos = 0;
39        // current array position
40        this.arrayPos = 0;
41        // number to stop backspacing on.
42        // default 0, can change depending on how many chars
43        // you want to remove at the time
44        this.stopNum = 0;
45        // Looping logic
46        this.loop = this.options.loop;
47        this.loopCount = this.options.loopCount;
48        this.curLoop = 0;
49        // for stopping
50        this.stop = false;
51        // show cursor
52        this.showCursor = this.isInput ? false : this.options.showCursor;
53        // custom cursor
54        this.cursorChar = this.options.cursorChar;
55        // attribute to type
56        this.isInput = this.el.is('input');
57        this.attr = this.options.attr || (this.isInput ? 'placeholder' : null);
58        // All systems go!
59        this.build();
60    };
61        Typed.prototype =  {
62            constructor: Typed
63            , init: function(){
64                // begin the loop w/ first current string (global self.string)
65                // current string will be passed as an argument each time after this
66                var self = this;
67                self.timeout = setTimeout(function() {
68                    // Start typing
69                    self.typewrite(self.strings[self.arrayPos], self.strPos);
70                }, self.startDelay);
71            }
72            , build: function(){
73                // Insert cursor
74                if (this.showCursor === true){
75                  this.cursor = $("<span class=\"typed-cursor\">" + this.cursorChar + "</span>");
76                  if(this.el.parent().find('.typed-cursor').length == 0) // fix multiple cursor using brower full dimesion
77				  	this.el.after(this.cursor);
78                }
79                this.init();
80            }
81            // pass current string state to each function, types 1 char per call
82            , typewrite: function(curString, curStrPos){
83                // exit when stopped
84                if(this.stop === true)
85                   return;
86                // varying values for setTimeout during typing
87                // can't be global since number changes each time loop is executed
88                var humanize = Math.round(Math.random() * (100 - 30)) + this.typeSpeed;
89                var self = this;
90                // ------------- optional ------------- //
91                // backpaces a certain string faster
92                // ------------------------------------ //
93                // if (self.arrayPos == 1){
94                //  self.backDelay = 50;
95                // }
96                // else{ self.backDelay = 500; }
97                // contain typing function in a timeout humanize'd delay
98                self.timeout = setTimeout(function() {
99                    // check for an escape character before a pause value
100                    // format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^
101                    // single ^ are removed from string
102                    var charPause = 0;
103                    var substr = curString.substr(curStrPos);
104                    if (substr.charAt(0) === '^') {
105                        var skip = 1;  // skip atleast 1
106                        if(/^\^\d+/.test(substr)) {
107                           substr = /\d+/.exec(substr)[0];
108                           skip += substr.length;
109                           charPause = parseInt(substr);
110                        }
111                        // strip out the escape character and pause value so they're not printed
112                        curString = curString.substring(0,curStrPos)+curString.substring(curStrPos+skip);
113                    }
114                    // timeout for any pause after a character
115                    self.timeout = setTimeout(function() {
116                        if(curStrPos === curString.length) {
117                           // fires callback function
118                           self.options.onStringTyped(self.arrayPos);
119                            // is this the final string
120                           if(self.arrayPos === self.strings.length-1) {
121                              // animation that occurs on the last typed string
122                              self.options.callback();
123                              self.curLoop++;
124                              // quit if we wont loop back
125                              if(self.loop === false || self.curLoop === self.loopCount)
126                                 return;
127                           }
128                           self.timeout = setTimeout(function(){
129                              self.backspace(curString, curStrPos);
130                           }, self.backDelay);
131                        } else {
132                           /* call before functions if applicable */
133                           if(curStrPos === 0)
134                              self.options.preStringTyped(self.arrayPos);
135                           // start typing each new char into existing string
136                           // curString: arg, self.baseText: original text inside element
137                           var nextString = self.baseText + curString.substr(0, curStrPos+1);
138                           if (self.attr) {
139                            self.el.attr(self.attr, nextString);
140                           } else {
141                            self.el.text(nextString);
142                           }
143                           // add characters one by one
144                           curStrPos++;
145                           // loop the function
146                           self.typewrite(curString, curStrPos);
147                        }
148                    // end of character pause
149                    }, charPause);
150                // humanized value for typing
151                }, humanize);
152            }
153            , backspace: function(curString, curStrPos){
154                // exit when stopped
155                if (this.stop === true) {
156                   return;
157                }
158                // varying values for setTimeout during typing
159                // can't be global since number changes each time loop is executed
160                var humanize = Math.round(Math.random() * (100 - 30)) + this.backSpeed;
161                var self = this;
162                self.timeout = setTimeout(function() {
163                    // ----- this part is optional ----- //
164                    // check string array position
165                    // on the first string, only delete one word
166                    // the stopNum actually represents the amount of chars to
167                    // keep in the current string. In my case it's 14.
168                    // if (self.arrayPos == 1){
169                    //  self.stopNum = 14;
170                    // }
171                    //every other time, delete the whole typed string
172                    // else{
173                    //  self.stopNum = 0;
174                    // }
175                    // ----- continue important stuff ----- //
176                    // replace text with base text + typed characters
177                    var nextString = self.baseText + curString.substr(0, curStrPos);
178                    if (self.attr) {
179                     self.el.attr(self.attr, nextString);
180                    } else {
181                     self.el.text(nextString);
182                    }
183                    // if the number (id of character in current string) is
184                    // less than the stop number, keep going
185                    if (curStrPos > self.stopNum){
186                        // subtract characters one by one
187                        curStrPos--;
188                        // loop the function
189                        self.backspace(curString, curStrPos);
190                    }
191                    // if the stop number has been reached, increase
192                    // array position to next string
193                    else if (curStrPos <= self.stopNum) {
194                        self.arrayPos++;
195                        if(self.arrayPos === self.strings.length) {
196                           self.arrayPos = 0;
197                           self.init();
198                        } else
199                            self.typewrite(self.strings[self.arrayPos], curStrPos);
200                    }
201                // humanized value for typing
202                }, humanize);
203            }
204            // Start & Stop currently not working
205            // , stop: function() {
206            //     var self = this;
207            //     self.stop = true;
208            //     clearInterval(self.timeout);
209            // }
210            // , start: function() {
211            //     var self = this;
212            //     if(self.stop === false)
213            //        return;
214            //     this.stop = false;
215            //     this.init();
216            // }
217            // Reset and rebuild the element
218            , reset: function(){
219                var self = this;
220                clearInterval(self.timeout);
221                var id = this.el.attr('id');
222                this.el.after('<span id="' + id + '"/>')
223                this.el.remove();
224                this.cursor.remove();
225                // Send the callback
226                self.options.resetCallback();
227            }
228        };
229    $.fn.typed = function (option) {
230        return this.each(function () {
231          var $this = $(this)
232            , data = $this.data('typed')
233            , options = typeof option == 'object' && option;
234          if (!data) $this.data('typed', (data = new Typed(this, options)));
235          if (typeof option == 'string') data[option]();
236        });
237    };
238    $.fn.typed.defaults = {
239        strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"],
240        // typing speed
241        typeSpeed: 0,
242        // time before typing starts
243        startDelay: 0,
244        // backspacing speed
245        backSpeed: 0,
246        // time before backspacing
247        backDelay: 500,
248        // loop
249        loop: false,
250        // false = infinite
251        loopCount: false,
252        // show cursor
253        showCursor: true,
254        // character for cursor
255        cursorChar: "|",
256        // attribute to type (null == text)
257        attr: null,
258        // call when done callback function
259        callback: function() {},
260        // starting callback function before each string
261        preStringTyped: function() {},
262        //callback for every typed string
263        onStringTyped: function() {},
264        // callback for reset
265        resetCallback: function() {}
266    };
267}(window.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.