vendor: 9,059 bytes, lines 1-275
1// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ 2// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating 3// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel 4// MIT license 5 6(function() { 7 var lastTime = 0; 8 var vendors = ['ms', 'moz', 'webkit', 'o']; 9 for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { 10 window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; 11 window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] 12 || window[vendors[x]+'CancelRequestAnimationFrame']; 13 } 14 15 if (!window.requestAnimationFrame) 16 window.requestAnimationFrame = function(callback, element) { 17 var currTime = new Date().getTime(); 18 var timeToCall = Math.max(0, 16 - (currTime - lastTime)); 19 var id = window.setTimeout(function() { callback(currTime + timeToCall); }, 20 timeToCall); 21 lastTime = currTime + timeToCall; 22 return id; 23 }; 24 25 if (!window.cancelAnimationFrame) 26 window.cancelAnimationFrame = function(id) { 27 clearTimeout(id); 28 }; 29}()); 30 31(function (root) { 32 33 // Store setTimeout reference so promise-polyfill will be unaffected by 34 // other code modifying setTimeout (like sinon.useFakeTimers()) 35 var setTimeoutFunc = setTimeout; 36 37 function noop() {} 38 39 // Polyfill for Function.prototype.bind 40 function bind(fn, thisArg) { 41 return function () { 42 fn.apply(thisArg, arguments); 43 }; 44 } 45 46 function Promise(fn) { 47 if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new'); 48 if (typeof fn !== 'function') throw new TypeError('not a function'); 49 this._state = 0; 50 this._handled = false; 51 this._value = undefined; 52 this._deferreds = []; 53 54 doResolve(fn, this); 55 } 56 57 function handle(self, deferred) { 58 while (self._state === 3) { 59 self = self._value; 60 } 61 if (self._state === 0) { 62 self._deferreds.push(deferred); 63 return; 64 } 65 self._handled = true; 66 Promise._immediateFn(function () { 67 var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected; 68 if (cb === null) { 69 (self._state === 1 ? resolve : reject)(deferred.promise, self._value); 70 return; 71 } 72 var ret; 73 try { 74 ret = cb(self._value); 75 } catch (e) { 76 reject(deferred.promise, e); 77 return; 78 } 79 resolve(deferred.promise, ret); 80 }); 81 } 82 83 function resolve(self, newValue) { 84 try { 85 // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure 86 if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.'); 87 if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { 88 var then = newValue.then; 89 if (newValue instanceof Promise) { 90 self._state = 3; 91 self._value = newValue; 92 finale(self); 93 return; 94 } else if (typeof then === 'function') { 95 doResolve(bind(then, newValue), self); 96 return; 97 } 98 } 99 self._state = 1; 100 self._value = newValue; 101 finale(self); 102 } catch (e) { 103 reject(self, e); 104 } 105 } 106 107 function reject(self, newValue) { 108 self._state = 2; 109 self._value = newValue; 110 finale(self); 111 } 112 113 function finale(self) { 114 if (self._state === 2 && self._deferreds.length === 0) { 115 Promise._immediateFn(function() { 116 if (!self._handled) { 117 Promise._unhandledRejectionFn(self._value); 118 } 119 }); 120 } 121 122 for (var i = 0, len = self._deferreds.length; i < len; i++) { 123 handle(self, self._deferreds[i]); 124 } 125 self._deferreds = null; 126 } 127 128 function Handler(onFulfilled, onRejected, promise) { 129 this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; 130 this.onRejected = typeof onRejected === 'function' ? onRejected : null; 131 this.promise = promise; 132 } 133 134 /** 135 * Take a potentially misbehaving resolver function and make sure 136 * onFulfilled and onRejected are only called once. 137 * 138 * Makes no guarantees about asynchrony. 139 */ 140 function doResolve(fn, self) { 141 var done = false; 142 try { 143 fn(function (value) { 144 if (done) return; 145 done = true; 146 resolve(self, value); 147 }, function (reason) { 148 if (done) return; 149 done = true; 150 reject(self, reason); 151 }); 152 } catch (ex) { 153 if (done) return; 154 done = true; 155 reject(self, ex); 156 } 157 } 158 159 Promise.prototype['catch'] = function (onRejected) { 160 return this.then(null, onRejected); 161 }; 162 163 Promise.prototype.then = function (onFulfilled, onRejected) { 164 var prom = new (this.constructor)(noop); 165 166 handle(this, new Handler(onFulfilled, onRejected, prom)); 167 return prom; 168 }; 169 170 Promise.all = function (arr) { 171 var args = Array.prototype.slice.call(arr); 172 173 return new Promise(function (resolve, reject) { 174 if (args.length === 0) return resolve([]); 175 var remaining = args.length; 176 177 function res(i, val) { 178 try { 179 if (val && (typeof val === 'object' || typeof val === 'function')) { 180 var then = val.then; 181 if (typeof then === 'function') { 182 then.call(val, function (val) { 183 res(i, val); 184 }, reject); 185 return; 186 } 187 } 188 args[i] = val; 189 if (--remaining === 0) { 190 resolve(args); 191 } 192 } catch (ex) { 193 reject(ex); 194 } 195 } 196 197 for (var i = 0; i < args.length; i++) { 198 res(i, args[i]); 199 } 200 }); 201 }; 202 203 Promise.resolve = function (value) { 204 if (value && typeof value === 'object' && value.constructor === Promise) { 205 return value; 206 } 207 208 return new Promise(function (resolve) { 209 resolve(value); 210 }); 211 }; 212 213 Promise.reject = function (value) { 214 return new Promise(function (resolve, reject) { 215 reject(value); 216 }); 217 }; 218 219 Promise.race = function (values) { 220 return new Promise(function (resolve, reject) { 221 for (var i = 0, len = values.length; i < len; i++) { 222 values[i].then(resolve, reject); 223 } 224 }); 225 }; 226 227 // Use polyfill for setImmediate for performance gains 228 Promise._immediateFn = (typeof setImmediate === 'function' && function (fn) { setImmediate(fn); }) || 229 function (fn) { 230 setTimeoutFunc(fn, 0); 231 }; 232 233 Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) { 234 if (typeof console !== 'undefined' && console) { 235 console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console 236 } 237 }; 238 239 /** 240 * Set the immediate function to execute callbacks 241 * @param fn {function} Function to execute 242 * @deprecated 243 */ 244 Promise._setImmediateFn = function _setImmediateFn(fn) { 245 Promise._immediateFn = fn; 246 }; 247 248 /** 249 * Change the function to execute on unhandled rejection 250 * @param {function} fn Function to execute on unhandled rejection 251 * @deprecated 252 */ 253 Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) { 254 Promise._unhandledRejectionFn = fn; 255 }; 256 257 if (typeof module !== 'undefined' && module.exports) { 258 module.exports = Promise; 259 } else if (!root.Promise) { 260 root.Promise = Promise; 261 } 262 263 })(this); 264 265 266 267 268 269 270 271 272 273 274 /*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/ 275;if("document" in self&&!("classList" in document.createElement("_"))){(function(j){"use strict";if(!("Element" in j)){return}var a="classList",f="prototype",m=j.Element[f],b=Object,k=String[f].trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){var p=0,o=this.length;for(;p<o;p++){if(p in this&&this[p]===q){return p}}return -1},n=function(o,p){this.name=o;
275this.code=DOMException[o];this.message=p},g=function(p,o){if(o===""){throw new n("SYNTAX_ERR","An invalid or illegal string was specified")}if(/\s/.test(o)){throw new n("INVALID_CHARACTER_ERR","String contains an invalid character")}return c.call(p,o)},d=function(s){var r=k.call(s.getAttribute("class")||""),q=r?r.split(/\s+/):[],p=0,o=q.length;for(;p<o;p++){this.push(q[p])}this._updateClassName=function(){s.setAttribute("class",this.toString())}},e=d[f]=[],i=function(){return new d(this)};n[f]=Error[f];e.item=function(o){return this[o]||null};e.contains=function(o){o+="";return g(this,o)!==-1};e.add=function(){var s=arguments,r=0,p=s.length,q,o=false;do{q=s[r]+"";if(g(this,q)===-1){this.push(q);o=true}}while(++r<p);if(o){this._updateClassName()}};e.remove=function(){var t=arguments,s=0,p=t.length,r,o=false;do{r=t[s]+"";var q=g(this,r);if(q!==-1){this.splice(q,1);o=true}}while(++s<p);if(o){this._updateClassName()}};e.toggle=function(p,q){p+="";var o=this.contains(p),r=o?q!==true&&"remove":q!==false&&"add";if(r){this[r](p)}return !o};e.toString=function(){return this.join(" ")};if(b.defineProperty){var l={get:i,enumerable:true,configurable:true};try{b.defineProperty(m,a,l)}catch(h){if(h.number===-2146823252){l.enumerable=false;b.defineProperty(m,a,l)}}}else{if(b[f].__defineGetter__){m.__defineGetter__(a,i)}}}(self))}; 276 277 278 279 280 281/** 282 * Input Placeholder Polyfill 283 * MIT Licensed 284 * Created by Christopher Rolfe 285 */ 286if (!('placeholder' in document.createElement("input"))) { 287 288 // Get all the inputs 289 var inputs = document.getElementsByTagName('input'); 290 291 // Loop over them 292 for (var i = 0; i < inputs.length; i++) { 293 // If they don't have a preset value 294 if (!inputs[i].value) { 295 // The set the placeholder 296 inputs[i].value = inputs[i].getAttribute('placeholder'); 297 } 298 299 // Attach event listeners for click and blur 300 // Click so that we can clear the placeholder if we need to 301 // Blur to re-add it if needed 302 if (inputs[i].addEventListener) { 303 inputs[i].addEventListener('click', hidePlaceholderOnFocus, false); 304 inputs[i].addEventListener('blur', unfocusOnAnElement, false); 305 } else if (inputs[i].attachEvent) { 306 inputs[i].attachEvent('onclick', hidePlaceholderOnFocus); 307 inputs[i].attachEvent('onblur', unfocusOnAnElement); 308 } 309 } 310 311 /** 312 * When the input value is the same as the placeholder clear it 313 */ 314 function hidePlaceholderOnFocus(event) { 315 target = (event.currentTarget) ? event.currentTarget : event.srcElement; 316 317 if (target.value == target.getAttribute('placeholder')) { 318 target.value = ''; 319 } 320 } 321 322 /** 323 * When the input has an empty value put the placeholder back in 324 */ 325 function unfocusOnAnElement(event) { 326 target = (event.currentTarget) ? event.currentTarget : event.srcElement; 327 328 if (target.value == '') { 329 target.value = target.getAttribute('placeholder'); 330 } 331 } 332 }
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.