PageSourceSearch

https://smtrucker.ru/bitrix/resources/intec.core/js/core.js?177858795733562

js smtrucker.ru collected 2026-10-04 19:55:25 UTC 33,562 bytes, 1,058 lines download raw bytes

1(function ($) {
2
3    // Convert form values to object
4    $.fn.serializeObject = function() {
5        var object = {};
6
7        $.each(this.serializeArray(), function() {
8            if (object[this.name]) {
9                if (!object[this.name].push) {
10                    object[this.name] = [object[this.name]];
11                }
12                object[this.name].push(this.value || '');
13            } else {
14                object[this.name] = this.value || '';
15            }
16        });
17
18        return object;
19    };
20
21    // Running event when element sizes change
22    $.fn.checkSizes = function (timeout) {
23        var $target = $(this),
24            width = $target.width(),
25            height = $target.height();
26
27        if ($target.data('isChecksizes'))
28            return;
29
30        if (!api.isNumber(timeout))
31            timeout = 500;
32
33        function checkSizes () {
34            var newWidth = $target.width(),
35                newHeight = $target.height(),
36                changed = false;
37
38            if (height !== newHeight) {
39                height = newHeight;
40                changed = true;
41            }
42
43            if (width !== newWidth) {
44                width = newWidth;
45                changed = true;
46            }
47
48            if (changed) {
49                $target.trigger('resize');
50            }
51        }
52
53        $target.data('isChecksizes', true);
54        setInterval(checkSizes, timeout);
55    };
56
57    var wrapper = function (object) {
58        this.get = function () {
59            return object;
60        };
61    };
62
63    var api = function (object) {
64        if (object instanceof wrapper)
65            return object;
66
67        return new wrapper(object);
68    };
69
70    api.type = {
71        'string': 'string',
72        'number': 'number',
73        'integer': 'integer',
74        'float': 'float',
75        'nan': 'nan',
76        'object': 'object',
77        'array': 'array',
78        'function': 'function',
79        'null': 'null',
80        'undefined': 'undefined',
81        'boolean': 'boolean'
82    };
83
84    api.isWrapper = function (object) {
85        return object instanceof wrapper;
86    };
87    api.isString = function (object) {
88        return typeof object == api.type.string;
89    };
90    api.toString = function (object) {
91        return String(object);
92    };
93    api.isNumber = function (object) {
94        return typeof object == api.type.number;
95    };
96    api.toNumber = function (object) {
97        return Number(object);
98    };
99    api.isInteger = function (object) {
100        if (api.isNumber(object))
101            return object % 1 === 0;
102
103        return false;
104    };
105    api.toInteger = function (object) {
106        return parseInt(object);
107    };
108    api.isFloat = function (object) {
109        if (api.isNumber(object))
110            return object % 1 !== 0;
111
112        return false;
113    };
114    api.toFloat = function (object) {
115        return parseFloat(object);
116    };
117    api.isNaN = function (object) {
118        return isNaN(object);
119    };
120    api.isObject = function (object) {
121        return typeof object == api.type.object && object !== null && !(object instanceof Array);
122    };
123    api.isArray = function (object) {
124        return (object instanceof Array);
125    };
126    api.isFunction = function (object) {
127        return typeof object == api.type.function;
128    };
129    api.isNull = function (object) {
130        return object === null;
131    };
132    api.isUndefined = function (object) {
133        return typeof object == api.type.undefined;
134    };
135    api.isBoolean = function (object) {
136        return typeof object == api.type.boolean;
137    };
138    api.toBoolean = function (object) {
139        return Boolean(object);
140    };
141    api.isDeclared = function (object) {
142        return !api.isNull(object) && !api.isUndefined(object);
143    };
144    api.isEmpty = function (object) {
145        if (!api.isDeclared(object))
146            return true;
147
148        if (api.isNumber(object))
149            return api.isNaN(object);
150
151        if (api.isBoolean(object))
152            return object === false;
153
154        if (api.isArray(object) || api.isString(object))
155            return object.length === 0;
156
157        if (api.isObject(object))
158            return api.isEmpty(Object.getOwnPropertyNames(object));
159
160        return false;
161    };
162    api.is = function () {
163        if (arguments.length == 0)
164            return false;
165
166        var object = arguments[0];
167        var types = Array.prototype.slice.call(arguments, 1);
168        var result = false;
169
170        if (types.length == 0)
171            return false;
172
173        if (api.isArray(types[0]))
174            types = types[0];
175
176        api.each(types, function (index, type) {
177            switch (type) {
178                case api.type.string:   result = api.isString(object);      break;
179                case api.type.number:   result = api.isNumber(object);      break;
180                case api.type.integer:  result = api.isInteger(object);     break;
181                case api.type.float:    result = api.isFloat(object);       break;
182                case api.type.nan:      result = api.isNaN(object);         break;
183                case api.type.object:   result = api.isObject(object);      break;
184                case api.type.array:    result = api.isArray(object);       break;
185                case api.type.function: result = api.isFunction(object);    break;
186                case api.type.null:     result = api.isNull(object);        break;
187                case api.type.undefined:result = api.isUndefined(object);   break;
188                case api.type.boolean:  result = api.isBoolean(object);     break;
189            }
190
191            if (result)
192                return false;
193        });
194
195        return result;
196    };
197    api.to = function (object, type) {
198        var result = object;
199
200        switch (type) {
201            case api.type.string: result = api.toString(object); break;
202            case api.type.number: result = api.toNumber(object); break;
203            case api.type.integer: result = api.toInteger(object); break;
204            case api.type.float: result = api.toFloat(object); break;
205            case api.type.boolean: result = api.toBoolean(object); break;
206        }
207
208        return result;
209    };
210    api.each = function (object, callback) {
211        var key;
212
213        if (api.isFunction(callback)) {
214            if (api.isObject(object)) {
215                for (key in object) {
216                    if (object.hasOwnProperty(key)) {
217                        if (callback(key, object[key]) == false) {
218                            break;
219                        }
220                    }
221                }
222            } else if (api.isArray(object)) {
223                var length = object.length;
224
225                for (key = 0; key < length; key++) {
226                    if (callback(key, object[key]) == false) {
227                        break;
228                    }
229                }
230            }
231        }
232    };
233    api.some = function (object, callback) {
234        var result = false;
235
236        if (api.isFunction(callback)) {
237            api.each(object, function (key, element) {
238                if (callback(key, element) == true) {
239                    result = true;
240                    return false;
241                }
242            });
243        }
244
245        return result;
246    };
247    api.every = function (object, callback) {
248        var result = true;
249
250        if (api.isFunction(callback)) {
251            api.each(object, function (key, element) {
252                if (callback(key, element) == false) {
253                    result = false;
254                    return false;
255                }
256            });
257        }
258
259        return result;
260    };
261    api.extend = function (object) {
262        var objects = Array.prototype.slice.call(arguments, 1);
263
264        if (!api.isObject(object) && !api.isArray(object) && !api.isFunction(object))
265            object = {};
266
267        api.each(objects, function (key, extender) {
268            if (!api.isObject(extender) && !api.isArray(extender) && !api.isFunction(extender))
269                return;
270
271            api.each(extender, function (key, value) {
272                if (api.isObject(value) || api.isArray(value)) {
273                    if (!api.isObject(object[key]) && !api.isArray(object[key]))
274                        object[key] = api.isArray(value) ? [] : {};
275
276                    api.extend(object[key], value);
277                } else {
278                    object[key] = value;
279                }
280            });
281        });
282
283        return object;
284    };
285    api.inherit = function (children, parent) {
286        if (!api.isObject(children) && !api.isObject(parent))
287            return;
288
289        var object = function () {};
290
291        object.prototype = parent.prototype;
292        children.prototype = new object();
293        children.prototype.constructor = children;
294        children.superclass = parent;
295    };
296    api.bind = function (method, context) {
297        if (!api.isFunction(method))
298            return null;
299
300        return function () {
301            return method.apply(context, arguments);
302        }
303    };
304
305    api.objectToArray = function (obj) {
306        return Object.keys(obj).map(function (key) { return obj[key]; });
307    };
308
309    api.isEqual = function (a, b) {
310        if (api.isObject(a) && api.isObject(b)) {
311            var aKeys = Object.keys(a),
312                bKeys = Object.keys(b);
313
314            if (aKeys.length != bKeys.length )
315                return false;
316
317            return !aKeys.filter(function(key){
318                if (api.is(a[key], [api.type.object, api.type.array])) {
319                    return !api.isEqual(a[key], b[key]);
320                }
321                return a[key] !== b[key];
322            }).length;
323        }
324
325        return false;
326    };
327
328    api.inArray = function (needle, haystack, isStrict) {
329        var result = false;
330        isStrict = !!isStrict;
331
332        api.each(haystack, function(key, value) {
333            if (api.is(needle, [api.type.object, api.type.array])) {
334                if (api.isEqual(needle, value)) {
335                    result = true;
336                    return false;
337                }
338            } else if (isStrict && value === needle || !isStrict && value == needle) {
339                result = true;
340                return false;
341            }
342
343        });
344
345        return result;
346    };
347
348    api.proxy = function (callback, context) {
349        if (!api.isFunction(callback))
350            return undefined;
351
352        return function () {
353            return callback.apply(context, arguments);
354        }
355    };
356
357    api.throttle = function (callback, timeout, late) {
358        var wait = false;
359
360        return function () {
361            if (!wait) {
362                if (!late)
363                    callback.call();
364
365                wait = true;
366
367                setTimeout(function () {
368                    wait = false;
369
370                    if (late)
371                        callback.call();
372                }, timeout);
373            }
374        };
375    };
376
377    api.array = {};
378
379    /**
380     * api.array.clone
381     * @param array
382     * @returns {Array}
383     */
384    api.array.clone = function (array) {
385        var result = [];
386
387        if (!api.isArray(array))
388            return result;
389
390        api.each(array, function (index, value) {
391            result.push(value);
392        });
393
394        return result;
395    };
396
397    /**
398     * api.array.find
399     * @param object
400     * @param array
401     * @param comparator
402     * @returns {Object}
403     */
404    api.array.find = function (object, array, comparator) {
405        var result = null;
406
407        if (!api.isArray(array))
408            return result;
409
410        if (array.indexOf(object) !== -1) {
411            result = object;
412        } else if (api.isFunction(comparator)) {
413            api.each(array, function (index, item) {
414                if (comparator(index, item, object) === true) {
415                    result = item;
416                    return false;
417                }
418            });
419        }
420
421        return result;
422    };
423
424    /**
425     * api.array.rebuild
426     * @param array
427     * @param builder
428     */
429    api.array.rebuild = function (array, builder) {
430        var result = [];
431
432        if (api.isArray(array))
433            if (api.isFunction(builder)) {
434                api.each(array, function (index, item) {
435                    result.push(builder(index, item));
436                });
437            } else {
438                api.each(array, function (index, item) {
439                    result.push(item);
440                });
441            }
442
443        return result;
444    };
445
446    api.object = {};
447
448    /**
449     * api.object.scan
450     * Рекурсивный сканер объекта.
451     * Сканирует весь объект рекурсивно и предоставляет доступ к каждому свойству, не явÐ
451»ÑÑŽÑ‰ÐµÐ¼ÑƒÑÑ объектом.
452     */
453    api.object.scan = (function () {
454        var Event;
455        var handler;
456
457        Event = function (path, getter, setter) {
458            var self = this;
459
460            Object.defineProperty(self, 'path', {
461                'configurable': true,
462                'enumerable': true,
463                'get': function () {
464                    return api.array.clone(path);
465                }
466            });
467
468            Object.defineProperty(self, 'pathString', {
469                'configurable': true,
470                'enumerable': true,
471                'get': function () {
472                    return self.path.join('.');
473                }
474            });
475
476            Object.defineProperty(self, 'value', {
477                'configurable': true,
478                'enumerable': true,
479                'get': getter,
480                'set': setter
481            });
482        };
483
484        handler = function (object, basePath, callback) {
485            api.each(object, function (key, value) {
486                var path;
487
488                path = api.array.clone(basePath);
489                path.push(key);
490
491                if (api.isObject(value)) {
492                    handler(value, path, callback);
493                } else {
494                    callback(new Event(path, function () {
495                        return object[key];
496                    }, function (value) {
497                        object[key] = value;
498                    }));
499                }
500            });
501        };
502
503        return function (object, callback) {
504            if (!api.isObject(object) || !api.isFunction(callback))
505                return;
506
507            handler(object, [], callback);
508        };
509    })();
510
511    /**
512     * api.object.configure
513     * Рекурсивно обходит свойства объекта, которые присутствуют в объекте с данными
514     * и устанавливает в них значения в соответствии с объектом данных.
515     */
516    api.object.configure = (function () {
517        var Event;
518        var handler;
519
520        Event = function (path, oldValue, value) {
521            var self = this;
522            var isCancelled = false;
523
524            Object.defineProperty(self, 'path', {
525                'configurable': true,
526                'enumerable': true,
527                'get': function () {
528                    return api.array.clone(path);
529                }
530            });
531
532            Object.defineProperty(self, 'pathString', {
533                'configurable': true,
534                'enumerable': true,
535                'get': function () {
536                    return self.path.join('.');
537                }
538            });
539
540            Object.defineProperty(self, 'value', {
541                'configurable': true,
542                'enumerable': true,
543                'get': function () {
544                    return value;
545                },
546                'set': function (data) {
547                    value = data;
548                }
549            });
550
551            Object.defineProperty(self, 'oldValue', {
552                'configurable': true,
553                'enumerable': true,
554                'get': function () {
555                    return oldValue;
556                },
557                'set': function (data) {
558                    oldValue = data;
559                }
560            });
561
562            Object.defineProperty(self, 'isCancelled', {
563                'configurable': true,
564                'enumerable': true,
565                'get': function () {
566                    return isCancelled;
567                }
568            });
569
570            self.cancel = function () {
571                isCancelled = true;
572            };
573        };
574
575        handler = function (object, data, basePath, callback) {
576            api.each(object, function (key, value) {
577                var path;
578                var event;
579
580                path = api.array.clone(basePath);
581                path.push(key);
582
583                if (api.isFunction(value))
584                    return;
585
586                if (api.isObject(value)) {
587                    if (api.isObject(data[key]))
588                        handler(value, data[key], path, callback);
589                } else if (!api.isUndefined(data[key])) {
590                    if (callback !== null) {
591                        event = new Event(path, value, api.isArray(data[key]) ? api.extend([], data[key]) : data[key]);
592                        callback(event);
593
594                        if (event.isCancelled)
595                            return;
596
597                        value = event.value;
598                    } else {
599                        value = api.isArray(data[key]) ? api.extend([], data[key]) : data[key];
600                    }
601
602                    if (api.isArray(object[key])) {
603                        if (object[key].length > 0)
604                            object[key].splice(0, object[key].length);
605
606                        api.each(value, function (index, part) {
607                            object[key].push(part);
608                        });
609                        object[key] = value;
610                    } else {
611                        object[key] = value;
612                    }
613                }
614            });
615        };
616
617        return function (object, data, callback) {
618            if (!api.isFunction(callback))
619                callback = null;
620
621            if (!api.isObject(object) || !api.isObject(data))
622                return;
623
624            handler(object, data, [], callback);
625        };
626    })();
627
628    /**
629     * api.object.getValue
630     * Рекурсивно получает значение свойства из объекта.
631     */
632    api.object.getValue = function (object, path) {
633        if (!api.isObject(object))
634            return undefined;
635
636        if (api.isArray(path)) {
637            path = api.array.rebuild(path);
638        } else {
639            return object[path];
640        }
641
642        while (true) {
643            if (path.length === 0)
644                return object;
645
646            if (!api.isObject(object))
647                return undefined;
648
649            var part = path.shift();
650
651            object = object[part];
652        }
653    };
654
655    /**
656     * api.object.getValue
657     * Рекурсивно устанавливает значение свойства в объект.
658     */
659    api.object.setValue = function (object, path, value) {
660        if (!api.isObject(object))
661            return;
662
663        if (api.isArray(path)) {
664            path = api.array.rebuild(path);
665        } else {
666            object[path] = value;
667            return;
668        }
669
670        if (path.length === 0)
671            return;
672
673        while (true) {
674            var part = path.shift();
675            var candidate;
676
677            if (path.length === 0) {
678                object[part] = value;
679                return;
680            } else {
681                candidate = object[part];
682
683                if (!api.isDeclared(candidate)) {
684                    object[part] = {};
685                    object = object[part];
686                } else if (api.isObject(candidate) || !api.isArray(candidate) || !api.isFunction(candidate)) {
687                    object = candidate;
688                }
689            }
690        }
691    };
692
693    api.string = {};
694    api.string.replace = function (string, rules) {
695        string = api.toString(string);
696
697        if (!api.isObject(rules))
698            return string;
699
700        api.each(rules, function (from, to) {
701            string = string.replace(new RegExp(RegExp.escape(from), 'g'), to);
702        });
703
704        return string;
705    };
706
707    api.ext = {};
708
709    /** Класс событий **/
710    (function () {
711        var getName = function (name) {
712            name = api.toString(name);
713            return name.split('.').shift();
714        };
715        var getNamespace = function (name) {
716            var namespace;
717            namespace = api.toString(name);
718            namespace = namespace.split('.');
719            namespace.shift();
720            namespace = namespace.join('.');
721            return namespace.length ? namespace : null;
722        };
723
724        var event = function () {
725            var self = this;
726
727            self.once = false;
728            self.name = null;
729            self.context = null;
730            self.function = null;
731        };
732        event.prototype.getName = function () {
733            return getName(this.name);
734        };
735        event.prototype.getNamespace = function () {
736            return getNamespace(this.name);
737        };
738        event.prototype.fire = function (context, parameters) {
739            var self = this;
740            parameters.unshift(self);
741            if (this.context) context = this.context;
742            return self.function.apply(context, parameters);
743        };
744
745        var events = function (context, available) {
746            var self = this;
747            var list = [];
748
749            list.add = function (events, callback, context, once) {
750                var self = this;
751
752                if (api.isFunction(callback) && (
753                        api.isString(events) ||
754                        api.isArray(events) ||
755                        api.isObject(events)
756                    ) && !api.isEmpty(events)) {
757                    if (api.isString(events)) { events = events.split(' '); }
758
759                    api.each(events, function (index, eventName) {
760                        var name = event.prototype.getName.call({ name: eventName });
761
762                        if (api.isEmpty(available) || api.some(available, function (key, value) {
763                                return name == value;
764                            })) {
765                            var instance = new event();
766
767                            instance.name = eventName;
768                            instance.once = once;
769                            instance.function = callback;
770                            instance.context = context;
771
772                            self.push(instance);
773                        }
774                    });
775                }
776            };
777
778            list.removeAt = function (id) {
779                var self = this;
780                if (api.isUndefined(id) || api.isNull(id)) return;
781                if (!api.isArray(id)) id = [id];
782                var shift = 0;
783
784                api.each(id, function (index, id) {
785                    self.splice(id - shift, 1);
786                    shift++;
787                });
788            };
789
790            list.remove = function (events, callback) {
791                var self = this;
792                var indexes = [];
793
794                if (!api.isString(events) && !api.isArray(events) && !api.isObject(events)) { return; }
795                if (api.isString(events)) { events = events.split(' '); }
796
797                api.each(self, function (index, instance) {
798                    api.each(events, function (index, eventName) {
799                        var name = getName(eventName);
800                        var namespace = getNamespace(eventName);
801
802                        if (name != instance.getName())
803                            return true;
804
805                        if (namespace !== null)
806                            if (namespace !== instance.getNamespace())
807                                return true;
808
809                        if (api.isFunction(callback))
810                            if (instance.function != callback)
811                                return true;
812
813                        indexes.push(index);
814                        return true;
815                    });
816                });
817
818                self.removeAt(indexes);
819            };
820
821            self.setContext = function (object) { context = object; };
822            self.getContext = function () { return context; };
823
824            self.on = function (events, callback, context) {
825                list.add(events, callback, context, false);
826            };
827
828            self.once = function (events, callback, context) {
829                list.add(events, callback, context, true);
830            };
831
832            self.off = function (events, callback) {
833                list.remove(events, callback);
834            };
835
836            //event, argument1, ..., argumentN
837            self.trigger = function () {
838                if (arguments.length == 0) return false;
839
840                var eventName = arguments[0];
841                var name = event.prototype.getName.call({ name: eventName });
842                var namespace = event.prototype.getNamespace.call({ name: eventName });
843                var indexes = [];
844                var result = true;
845                var tempParameters = arguments;
846
847                api.each(list, function (index, instance) {
848                    var parameters = Array.prototype.slice.call(tempParameters, 1);
849
850                    if (name != instance.getName())
851                        return true;
852
853                    if (namespace !== null)
854                        if (namespace !== instance.getNamespace())
855                            return true;
856
857                    if (instance.fire(context, parameters) === false)
858                        result = false;
859
860                    if (instance.once) indexes.push(index);
861                });
862
863                list.removeAt(indexes);
864                return result;
865            };
866        };
867
868        api.ext.events = function (context, available) {
869            return new events(context, available)
870        };
871    })();
872
873    api.fn = wrapper.prototype;
874    api.fn.isString = function () { return api.isString(this.get()) };
875    api.fn.toString = function () { return api.toString(this.get()) };
876    api.fn.isNumber = function () { return api.isNumber(this.get()) };
877    api.fn.toNumber = function () { return api.toNumber(this.get()) };
878    api.fn.isInteger = function () { return api.isInteger(this.get()) };
879    api.fn.toInteger = function () { return api.toInteger(this.get()) };
880    api.fn.isFloat = function () { return api.isFloat(this.get()) };
881    api.fn.toFloat = function () { return api.toFloat(this.get()) };
882    api.fn.isNaN = function () { return api.isNaN(this.get()) };
883    api.fn.isObject = function () { return api.isObject(this.get()) };
884    api.fn.isArray = function () { return api.isArray(this.get()) };
885    api.fn.isFunction = function () { return api.isFunction(this.get()) };
886    api.fn.isNull = function () { return api.isNull(this.get()) };
887    api.fn.isUndefined = function () { return api.isUndefined(this.get()) };
888    api.fn.isBoolean = function () { return api.isBoolean(this.get()) };
889    api.fn.isDeclared = function () { return api.isDeclared(this.get()) };
890    api.fn.isEmpty = function () { return api.isEmpty(this.get()) };
891    api.fn.is = function () {
892        Array.prototype.unshift.call(arguments, this.get());
893        return api.is.apply(api, arguments);
894    };
895    api.fn.to = function (type) { return api.to(this.get(), type); };
896    api.fn.each = function (callback) { api.each(this.get(), callback); return this; };
897    api.fn.some = function (callback) { api.some(this.get(), callback); return this; };
898    api.fn.every = function (callback) { api.every(this.get(), callback); return this; };
899
900    api.ui = {};
901    api.ui.update = function () {
902        api.each(api.ui.controls, function (key, constructor) {
903            $('[data-ui-' + key + ']').each(function () {
904                var element = $(this);
905                if (element.parent().is('label.api-ui-switch')) {
906                    return;
907                }
908                var attribute = 'ui' + key.charAt(0).toUpperCase() + key.slice(1);
909                var object = element.data(attribute);
910
911                if (!(object instanceof constructor)) {
912                    try {
913                        object = eval('(' + object + ')');
914                    } catch (error) {}
915
916                    element.data(attribute, new constructor(element, api.isObject(object) ? object : {}));
917                }
918            })
919        });
920    };
921    api.ui.controls = {};
922    api.ui.controls.switch = function (element, settings) {
923        var wrap, control, flag;
924        var self = this;
925
926        element = $(element);
927        settings = api.extend({}, api.ui.controls.switch.settings, settings);
928
929        self.getElement = function () {
930            return element;
931        };
932        self.getWrap = function () {
933            return wrap;
934        };
935        self.getControl = function () {
936            return control;
937        };
938        self.getFlag = function () {
939            return flag;
940        };
941
942        self.isBuilt = function () {
943            return api.isDeclared(wrap) && api.isDeclared(control) && api.isDeclared(flag);
944        };
945
946        self.build = function () {
947            if (self.isBuilt())
948                return;
949
950            wrap = $('<label />', {
951                'class': settings.classes.wrap
952            }).insertBefore(element);
953            element.appendTo(wrap);
954            control = $('<div />', {
955                'class': settings.classes.control
956            }).appendTo(wrap);
957            flag = $('<div />', {
958                'class': settings.classes.flag
959            }).appendTo(control);
960
961            element.on('change.api.ui.checkbox', function () {
962                wrap.removeClass(settings.classes.active);
963
964                if (element.prop('checked')) {
965                    wrap.addClass(settings.classes.active);
966                }
967            });
968
969            wrap.on('mouseover.api.ui.switch', function () {
970                wrap.addClass(settings.classes.hover);
971            }).on('mouseout.api.ui.switch', function () {
972                wrap.removeClass(settings.classes.hover);
973            });
974
975            if (element.prop('checked')) {
976                wrap.addClass(settings.classes.active);
977            }
978        };
979
980        self.destroy = function () {
981            if (!self.isBuilt())
982                return;
983
984            element.off('change.api.ui.switch');
985            wrap.off('mouseover.api.ui.switch')
986                .off('mouseout.api.ui.switch')
987                .off('click.api.ui.switch');
988
989            element.insertBefore(wrap);
990            flag.remove();
991            control.remove();
992            wrap.remove();
993        };
994
995        self.build();
996    };
997    api.ui.controls.switch.settings = {
998        'classes': {
999            'wrap': 'api-ui-switch',
1000            'control': 'api-ui-switch-control',
1001            'flag': 'api-ui-switch-control-flag',
1002            'hover': 'api-ui-switch-hover',
1003            'active': 'api-ui-switch-active'
1004        }
1005    };
1006
1007    if (!api.isFunction(RegExp.escape)) {
1008        RegExp.escape = function (value) {
1009            if (api.isString(value))
1010                return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
1011
1012            return value;
1013        };
1014    }
1015
1016    if (!api.isFunction(Math.count)) {
1017        Math.count = {};
1018        Math.count.decimals = function (value) {
1019            var count = 0;
1020
1021            value = api.toFloat(value);
1022
1023            while (value % 1 !== 0) {
1024                value = value * 10;
1025                count++;
1026            }
1027
1028            return count;
1029        };
1030        Math.count.integers = function (value) {
1031            var count = 0;
1032
1033            value = api.toFloat(value);
1034
1035            while (value !== 0) {
1036                value = Math.floor(value / 10);
1037                count++;
1038            }
1039
1040            return count;
1041        }
1042    }
1043
1044    if (!api.isFunction(Math.extend)) {
1045        Math.extend = function (value, rank) {
1046            value = api.toFloat(value);
1047
1048            for (i = 0; i < rank; i++)
1049                value = value * 10;
1050
1051            return value;
1052        }
1053    }
1054
1055    api.$ = $;
1056
1057    window.intec = api;
1058})(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.