vendor: 15,924 bytes, lines 1-534
1(function() { 2 var MutationObserver, Util, WeakMap, getComputedStyle, getComputedStyleRX, 3 bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 4 indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; 5 6 Util = (function() { 7 function Util() {} 8 9 Util.prototype.extend = function(custom, defaults) { 10 var key, value; 11 for (key in defaults) { 12 value = defaults[key]; 13 if (custom[key] == null) { 14 custom[key] = value; 15 } 16 } 17 return custom; 18 }; 19 20 Util.prototype.isMobile = function(agent) { 21 return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(agent); 22 }; 23 24 Util.prototype.createEvent = function(event, bubble, cancel, detail) { 25 var customEvent; 26 if (bubble == null) { 27 bubble = false; 28 } 29 if (cancel == null) { 30 cancel = false; 31 } 32 if (detail == null) { 33 detail = null; 34 } 35 if (document.createEvent != null) { 36 customEvent = document.createEvent('CustomEvent'); 37 customEvent.initCustomEvent(event, bubble, cancel, detail); 38 } else if (document.createEventObject != null) { 39 customEvent = document.createEventObject(); 40 customEvent.eventType = event; 41 } else { 42 customEvent.eventName = event; 43 } 44 return customEvent; 45 }; 46 47 Util.prototype.emitEvent = function(elem, event) { 48 if (elem.dispatchEvent != null) { 49 return elem.dispatchEvent(event); 50 } else if (event in (elem != null)) { 51 return elem[event](); 52 } else if (("on" + event) in (elem != null)) { 53 return elem["on" + event](); 54 } 55 }; 56 57 Util.prototype.addEvent = function(elem, event, fn) { 58 if (elem.addEventListener != null) { 59 return elem.addEventListener(event, fn, false); 60 } else if (elem.attachEvent != null) { 61 return elem.attachEvent("on" + event, fn); 62 } else { 63 return elem[event] = fn; 64 } 65 }; 66 67 Util.prototype.removeEvent = function(elem, event, fn) { 68 if (elem.removeEventListener != null) { 69 return elem.removeEventListener(event, fn, false); 70 } else if (elem.detachEvent != null) { 71 return elem.detachEvent("on" + event, fn); 72 } else { 73 return delete elem[event]; 74 } 75 }; 76 77 Util.prototype.innerHeight = function() { 78 if ('innerHeight' in window) { 79 return window.innerHeight; 80 } else { 81 return document.documentElement.clientHeight; 82 } 83 }; 84 85 return Util; 86 87 })(); 88 89 WeakMap = this.WeakMap || this.MozWeakMap || (WeakMap = (function() { 90 function WeakMap() { 91 this.keys = []; 92 this.values = []; 93 } 94 95 WeakMap.prototype.get = function(key) { 96 var i, item, j, len, ref; 97 ref = this.keys; 98 for (i = j = 0, len = ref.length; j < len; i = ++j) { 99 item = ref[i]; 100 if (item === key) { 101 return this.values[i]; 102 } 103 } 104 }; 105 106 WeakMap.prototype.set = function(key, value) { 107 var i, item, j, len, ref; 108 ref = this.keys; 109 for (i = j = 0, len = ref.length; j < len; i = ++j) { 110 item = ref[i]; 111 if (item === key) { 112 this.values[i] = value; 113 return; 114 } 115 } 116 this.keys.push(key); 117 return this.values.push(value); 118 }; 119 120 return WeakMap; 121 122 })()); 123 124 MutationObserver = this.MutationObserver || this.WebkitMutationObserver || this.MozMutationObserver || (MutationObserver = (function() { 125 function MutationObserver() { 126 if (typeof console !== "undefined" && console !== null) { 127 console.warn('MutationObserver is not supported by your browser.'); 128 } 129 if (typeof console !== "undefined" && console !== null) { 130 console.warn('PTLAnim.js cannot detect dom mutations, please call .sync() after loading new content.'); 131 } 132 } 133 134 MutationObserver.notSupported = true; 135 136 MutationObserver.prototype.observe = function() {}; 137 138 return MutationObserver; 139 140 })()); 141 142 getComputedStyle = this.getComputedStyle || function(el, pseudo) { 143 this.getPropertyValue = function(prop) { 144 var ref; 145 if (prop === 'float') { 146 prop = 'styleFloat'; 147 } 148 if (getComputedStyleRX.test(prop)) { 149 prop.replace(getComputedStyleRX, function(_, _char) { 150 return _char.toUpperCase(); 151 }); 152 } 153 return ((ref = el.currentStyle) != null ? ref[prop] : void 0) || null; 154 }; 155 return this; 156 }; 157 158 getComputedStyleRX = /(\-([a-z]){1})/g; 159 160 this.PTLAnim = (function() { 161 162 PTLAnim.prototype.defaults = { 163 boxClass: 'panim', 164 animateClass: 'animated', 165 offset: 0, 166 mobile: true, 167 live: true, 168 callback: null, 169 scrollContainer: null 170 }; 171 172 function PTLAnim(options) { 173 if (options == null) { 174 options = {}; 175 } 176 this.scrollCallback = bind(this.scrollCallback, this); 177 this.scrollHandler = bind(this.scrollHandler, this); 178 this.resetAnimation = bind(this.resetAnimation, this); 179 this.start = bind(this.start, this); 180 this.scrolled = true; 181 this.config = this.util().extend(options, this.defaults); 182 if (options.scrollContainer != null) { 183 this.config.scrollContainer = document.querySelector(options.scrollContainer); 184 } 185 this.animationNameCache = new WeakMap(); 186 this.panimEvent = this.util().createEvent(this.config.boxClass); 187 }; 188 189 PTLAnim.prototype.init = function() { 190 var ref; 191 this.element = window.document.documentElement; 192 if ((ref = document.readyState) === "interactive" || ref === "complete") { 193 this.start(); 194 } else { 195 this.util().addEvent(document, 'DOMContentLoaded', this.start); 196 } 197 return this.finished = []; 198 }; 199 200 PTLAnim.prototype.start = function() { 201 var box, j, len, ref; 202 this.stopped = false; 203 this.boxes = (function() { 204 var j, len, ref, results; 205 ref = this.element.querySelectorAll("." + this.config.boxClass); 206 results = []; 207 for (j = 0, len = ref.length; j < len; j++) { 208 box = ref[j]; 209 results.push(box); 210 } 211 return results; 212 }).call(this); 213 this.all = (function() { 214 var j, len, ref, results; 215 ref = this.boxes; 216 results = []; 217 for (j = 0, len = ref.length; j < len; j++) { 218 box = ref[j]; 219 results.push(box); 220 } 221 return results; 222 }).call(this); 223 if (this.boxes.length) { 224 if (this.disabled()) { 225 this.resetStyle(); 226 } else { 227 ref = this.boxes; 228 for (j = 0, len = ref.length; j < len; j++) { 229 box = ref[j]; 230 this.applyStyle(box, true); 231 } 232 } 233 } 234 if (!this.disabled()) { 235 this.util().addEvent(this.config.scrollContainer || window, 'scroll', this.scrollHandler); 236 this.util().addEvent(window, 'resize', this.scrollHandler); 237 this.interval = setInterval(this.scrollCallback, 50); 238 } 239 240 241 if (this.config.live) { 242 return new MutationObserver((function(_this) { 243 return function(records) { 244 var k, len1, node, record, results; 245 results = []; 246 for (k = 0, len1 = records.length; k < len1; k++) { 247 record = records[k]; 248 results.push((function() { 249 var l, len2, ref1, results1; 250 ref1 = record.addedNodes || []; 251 results1 = []; 252 for (l = 0, len2 = ref1.length; l < len2; l++) { 253 node = ref1[l]; 254 results1.push(this.doSync(node)); 255 } 256 return results1; 257 }).call(_this)); 258 } 259 return results; 260 }; 261 })(this)).observe(document.body, { 262 childList: true, 263 subtree: true 264 }); 265 } 266 }; 267 268 PTLAnim.prototype.stop = function() { 269 this.stopped = true; 270 this.util().removeEvent(this.config.scrollContainer || window, 'scroll', this.scrollHandler); 271 this.util().removeEvent(window, 'resize', this.scrollHandler); 272 if (this.interval != null) { 273 return clearInterval(this.interval); 274 } 275 }; 276 277 PTLAnim.prototype.sync = function(element) { 278 if (MutationObserver.notSupported) { 279 return this.doSync(this.element); 280 } 281 }; 282 283 PTLAnim.prototype.doSync = function(element) { 284 var box, j, len, ref, results; 285 if (element == null) { 286 element = this.element; 287 } 288 if (element.nodeType !== 1) { 289 return; 290 } 291 element = element.parentNode || element; 292 ref = element.querySelectorAll("." + this.config.boxClass); 293 results = []; 294 for (j = 0, len = ref.length; j < len; j++) { 295 box = ref[j]; 296 if (indexOf.call(this.all, box) < 0) { 297 this.boxes.push(box); 298 this.all.push(box); 299 if (this.stopped || this.disabled()) { 300 this.resetStyle(); 301 } else { 302 this.applyStyle(box, true); 303 } 304 results.push(this.scrolled = true); 305 } else { 306 results.push(void 0); 307 } 308 } 309 return results; 310 }; 311 312 PTLAnim.prototype.show = function(box) { 313 314 /*if (jQuery(box).hasClass('ptl-callb')) { 315 this.config.callback(box); 316 return; 317 }*/ 318 319 this.applyStyle(box); 320 box.className = box.className + " " + this.config.animateClass; 321 322 this.util().emitEvent(box, this.panimEvent); 323 this.util().addEvent(box, 'animationend', this.resetAnimation); 324 this.util().addEvent(box, 'oanimationend', this.resetAnimation); 325 this.util().addEvent(box, 'webkitAnimationEnd', this.resetAnimation); 326 this.util().addEvent(box, 'MSAnimationEnd', this.resetAnimation); 327 return box; 328 }; 329 330 PTLAnim.prototype.applyStyle = function(box, hidden) { 331 var delay, duration, iteration; 332 duration = box.getAttribute('data-panim-duration'); 333 delay = box.getAttribute('data-panim-delay'); 334 iteration = box.getAttribute('data-panim-iteration'); 335 return this.animate((function(_this) { 336 return function() { 337 return _this.customStyle(box, hidden, duration, delay, iteration); 338 }; 339 })(this)); 340 }; 341 342 PTLAnim.prototype.animate = (function() { 343 if ('requestAnimationFrame' in window) { 344 return function(callback) { 345 return window.requestAnimationFrame(callback); 346 }; 347 } else { 348 return function(callback) { 349 return callback(); 350 }; 351 } 352 })(); 353 354 PTLAnim.prototype.resetStyle = function() { 355 var box, j, len, ref, results; 356 ref = this.boxes; 357 results = []; 358 for (j = 0, len = ref.length; j < len; j++) { 359 box = ref[j]; 360 results.push(box.style.visibility = 'visible'); 361 } 362 return results; 363 }; 364 365 PTLAnim.prototype.resetAnimation = function(event) { 366 var target; 367 if (event.type.toLowerCase().indexOf('animationend') >= 0) { 368 target = event.target || event.srcElement; 369 return target.className = target.className.replace(this.config.animateClass, '').trim(); 370 } 371 }; 372 373 PTLAnim.prototype.customStyle = function(box, hidden, duration, delay, iteration) { 374 if (hidden) { 375 this.cacheAnimationName(box); 376 } 377 box.style.visibility = hidden ? 'hidden' : 'visible'; 378 if (duration) { 379 this.vendorSet(box.style, { 380 animationDuration: duration 381 }); 382 } 383 if (delay) { 384 this.vendorSet(box.style, { 385 animationDelay: delay 386 }); 387 } 388 if (iteration) { 389 this.vendorSet(box.style, { 390 animationIterationCount: iteration 391 }); 392 } 393 this.vendorSet(box.style, { 394 animationName: hidden ? 'none' : this.cachedAnimationName(box) 395 }); 396 return box; 397 }; 398 399 PTLAnim.prototype.vendors = ["moz", "webkit"]; 400 401 PTLAnim.prototype.vendorSet = function(elem, properties) { 402 var name, results, value, vendor; 403 results = []; 404 for (name in properties) { 405 value = properties[name]; 406 elem["" + name] = value; 407 results.push((function() { 408 var j, len, ref, results1; 409 ref = this.vendors; 410 results1 = []; 411 for (j = 0, len = ref.length; j < len; j++) { 412 vendor = ref[j]; 413 results1.push(elem["" + vendor + (name.charAt(0).toUpperCase()) + (name.substr(1))] = value); 414 } 415 return results1; 416 }).call(this)); 417 } 418 return results; 419 }; 420 421 PTLAnim.prototype.vendorCSS = function(elem, property) { 422 var j, len, ref, result, style, vendor; 423 style = getComputedStyle(elem); 424 result = style.getPropertyCSSValue(property); 425 ref = this.vendors; 426 for (j = 0, len = ref.length; j < len; j++) { 427 vendor = ref[j]; 428 result = result || style.getPropertyCSSValue("-" + vendor + "-" + property); 429 } 430 return result; 431 }; 432 433 PTLAnim.prototype.animationName = function(box) { 434 var animationName, error; 435 try { 436 animationName = this.vendorCSS(box, 'animation-name').cssText; 437 } catch (error) { 438 animationName = getComputedStyle(box).getPropertyValue('animation-name'); 439 } 440 if (animationName === 'none') { 441 return ''; 442 } else { 443 return animationName; 444 } 445 }; 446 447 PTLAnim.prototype.cacheAnimationName = function(box) { 448 return this.animationNameCache.set(box, this.animationName(box)); 449 }; 450 451 PTLAnim.prototype.cachedAnimationName = function(box) { 452 return this.animationNameCache.get(box); 453 }; 454 455 PTLAnim.prototype.scrollHandler = function() { 456 return this.scrolled = true; 457 }; 458 459 PTLAnim.prototype.scrollCallback = function() { 460 461 var box; 462 if(this.scrolled) { 463 this.scrolled = false; 464 465 this.boxes = (function() { 466 var j, len, ref, results; 467 ref = this.boxes; 468 469 470 results = []; 471 for (j = 0, len = ref.length; j < len; j++) { 472 box = ref[j]; 473 474 if (!(box)) { 475 continue; 476 } 477 478 if (this.isVisible(box)) { 479 //don't let it go 480 if (!jQuery(box).hasClass('ptl-callb')) { 481 482 this.show(box); 483 continue; 484 } 485 else 486 this.config.callbackloop(box); 487 } 488 results.push(box); 489 } 490 return results; 491 }) 492 .call(this); 493 494 if (!(this.boxes.length || this.config.live)) { 495 return this.stop(); 496 } 497 } 498 }; 499 500 PTLAnim.prototype.offsetTop = function(element) { 501 var top; 502 while (element.offsetTop === void 0) { 503 element = element.parentNode; 504 } 505 top = element.offsetTop; 506 while (element = element.offsetParent) { 507 top += element.offsetTop; 508 } 509 return top; 510 }; 511 512 PTLAnim.prototype.isVisible = function(box) { 513 var bottom, offset, top, viewBottom, viewTop; 514 offset = box.getAttribute('data-panim-offset') || this.config.offset; 515 viewTop = (this.config.scrollContainer && this.config.scrollContainer.scrollTop) || window.pageYOffset; 516 viewBottom = viewTop + Math.min(this.element.clientHeight, this.util().innerHeight()) - offset; 517 top = this.offsetTop(box); 518 bottom = top + box.clientHeight; 519 return top <= viewBottom && bottom >= viewTop; 520 }; 521 522 PTLAnim.prototype.util = function() { 523 return this._util != null ? this._util : this._util = new Util(); 524 }; 525 526 PTLAnim.prototype.disabled = function() { 527 return !this.config.mobile && this.util().isMobile(navigator.userAgent); 528 }; 529 530 return PTLAnim; 531 532 })(); 533 534}).call(this);
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.