vendor: 3,160 bytes, lines 1-164
1/** 2 * IASCallbacks v2.3.1 3 * https://infiniteajaxscroll.com 4 * 5 * This file is part of the Infinite AJAX Scroll package 6 * 7 * Copyright 2014-2018 Webcreate (Jeroen Fiege) 8 */ 9 10var IASCallbacks = function (aJquery) { 11 this.list = []; 12 this.fireStack = []; 13 this.isFiring = false; 14 this.isDisabled = false; 15 this.Deferred = aJquery.Deferred; 16 17 /** 18 * Calls all added callbacks 19 * 20 * @private 21 * @param args 22 */ 23 this.fire = function (args) { 24 var context = args[0], 25 deferred = args[1], 26 callbackArguments = args[2]; 27 28 this.isFiring = true; 29 30 for (var i = 0, l = this.list.length; i < l; i++) { 31 if (this.list[i] != undefined) { 32 if (false === this.list[i].fn.apply(context, callbackArguments)) { 33 deferred.reject(); 34 35 break; 36 } 37 } 38 } 39 40 this.isFiring = false; 41 42 deferred.resolve(); 43 44 if (this.fireStack.length) { 45 this.fire(this.fireStack.shift()); 46 } 47 }; 48 49 /** 50 * Returns index of the callback in the list in a similar way as 51 * the indexOf function. 52 * 53 * @param callback 54 * @param {number} index index to start the search from 55 * @returns {number} 56 */ 57 this.inList = function (callback, index) { 58 index = index || 0; 59 60 for (var i = index, length = this.list.length; i < length; i++) { 61 if (this.list[i].fn === callback || (callback.guid && this.list[i].fn.guid && callback.guid === this.list[i].fn.guid)) { 62 return i; 63 } 64 } 65 66 return -1; 67 }; 68 69 return this; 70}; 71 72IASCallbacks.prototype = { 73 /** 74 * Adds a callback 75 * 76 * @param callback 77 * @returns {IASCallbacks} 78 * @param priority 79 */ 80 add: function (callback, priority) { 81 var callbackObject = {fn: callback, priority: priority}; 82 83 priority = priority || 0; 84 85 for (var i = 0, length = this.list.length; i < length; i++) { 86 if (priority > this.list[i].priority) { 87 this.list.splice(i, 0, callbackObject); 88 89 return this; 90 } 91 } 92 93 this.list.push(callbackObject); 94 95 return this; 96 }, 97 98 /** 99 * Removes a callback 100 * 101 * @param callback 102 * @returns {IASCallbacks} 103 */ 104 remove: function (callback) { 105 var index = 0; 106 107 while (( index = this.inList(callback, index) ) > -1) { 108 this.list.splice(index, 1); 109 } 110 111 return this; 112 }, 113 114 /** 115 * Checks if callback is added 116 * 117 * @param callback 118 * @returns {*} 119 */ 120 has: function (callback) { 121 return (this.inList(callback) > -1); 122 }, 123 124 125 /** 126 * Calls callbacks with a context 127 * 128 * @param context 129 * @param args 130 * @returns {object|void} 131 */ 132 fireWith: function (context, args) { 133 var deferred = this.Deferred(); 134 135 if (this.isDisabled) { 136 return deferred.reject(); 137 } 138 139 args = args || []; 140 args = [ context, deferred, args.slice ? args.slice() : args ]; 141 142 if (this.isFiring) { 143 this.fireStack.push(args); 144 } else { 145 this.fire(args); 146 } 147 148 return deferred; 149 }, 150 151 /** 152 * Disable firing of new events 153 */ 154 disable: function () { 155 this.isDisabled = true; 156 }, 157 158 /** 159 * Enable firing of new events 160 */ 161 enable: function () { 162 this.isDisabled = false; 163 } 164};
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.