[javascript] casper.js

Viewer

copydownloadembedprintName: casper.js
  1. !(function (o) {
  2.     "use strict";
  3.     (o.fn.fitVids = function (e) {
  4.         var t,
  5.             i,
  6.             n = { customSelector: null, ignore: null };
  7.         return (
  8.             document.getElementById("fit-vids-style") ||
  9.                 ((= document.head || document.getElementsByTagName("head")[0]),
  10.                 ((= document.createElement("div")).innerHTML =
  11.                     '<p>x</p><style id="fit-vids-style">.fluid-width-video-container{flex-grow: 1;width:100%;}.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}</style>'),
  12.                 t.appendChild(i.childNodes[1])),
  13.             e && o.extend(n, e),
  14.             this.each(function () {
  15.                 var e = ['iframe[src*="player.vimeo.com"]', 'iframe[src*="youtube.com"]', 'iframe[src*="youtube-nocookie.com"]', 'iframe[src*="kickstarter.com"][src*="video.html"]', "object", "embed"];
  16.                 n.customSelector && e.push(n.customSelector);
  17.                 var r = ".fitvidsignore";
  18.                 n.ignore && (= r + ", " + n.ignore);
  19.                 e = o(this).find(e.join(","));
  20.                 (= (= e.not("object object")).not(r)).each(function () {
  21.                     var e,
  22.                         t,
  23.                         i = o(this);
  24.                     0 < i.parents(r).length ||
  25.                         ("embed" === this.tagName.toLowerCase() && i.parent("object").length) ||
  26.                         i.parent(".fluid-width-video-wrapper").length ||
  27.                         (i.css("height") || i.css("width") || (!isNaN(i.attr("height")) && !isNaN(i.attr("width"))) || (i.attr("height", 9), i.attr("width", 16)),
  28.                         (=
  29.                             ("object" === this.tagName.toLowerCase() || (i.attr("height") && !isNaN(parseInt(i.attr("height"), 10))) ? parseInt(i.attr("height"), 10) : i.height()) /
  30.                             (isNaN(parseInt(i.attr("width"), 10)) ? i.width() : parseInt(i.attr("width"), 10))),
  31.                         i.attr("name") || ((= "fitvid" + o.fn.fitVids._count), i.attr("name", t), o.fn.fitVids._count++),
  32.                         i
  33.                             .wrap('<div class="fluid-width-video-container"><div class="fluid-width-video-wrapper"></div></div>')
  34.                             .parent(".fluid-width-video-wrapper")
  35.                             .css("padding-top", 100 * e + "%"),
  36.                         i.removeAttr("height").removeAttr("width"));
  37.                 });
  38.             })
  39.         );
  40.     }),
  41.         (o.fn.fitVids._count = 0);
  42. })(window.jQuery || window.Zepto),
  43.     (function (e) {
  44.         e.addEventListener("DOMContentLoaded", function () {
  45.             e.querySelectorAll(".kg-gallery-image img").forEach(function (e) {
  46.                 var t = e.closest(".kg-gallery-image"),
  47.                     e = e.attributes.width.value / e.attributes.height.value;
  48.                 t.style.flex = e + " 1 0%";
  49.             });
  50.         });
  51.     })((window, document)),
  52.     (function (t, i) {
  53.         var r,
  54.             n,
  55.             o,
  56.             s,
  57.             a,
  58.             d,
  59.             l,
  60.             c = i.querySelector("link[rel=next]");
  61.         function u() {
  62.             if (404 === this.status) return t.removeEventListener("scroll", f), void t.removeEventListener("resize", v);
  63.             this.response.querySelectorAll(".post-card").forEach(function (e) {
  64.                 r.appendChild(i.importNode(e, !0));
  65.             });
  66.             var e = this.response.querySelector("link[rel=next]");
  67.             e ? (c.href = e.href) : (t.removeEventListener("scroll", f), t.removeEventListener("resize", v)), (= i.documentElement.scrollHeight), (= o = !1);
  68.         }
  69.         function e() {
  70.             var e;
  71.             s || (+ d <= l - n ? (= !1) : ((= !0), ((= new t.XMLHttpRequest()).responseType = "document"), e.addEventListener("load", u), e.open("GET", c.href), e.send(null)));
  72.         }
  73.         function h() {
  74.             o || t.requestAnimationFrame(e), (= !0);
  75.         }
  76.         function f() {
  77.             (= t.scrollY), h();
  78.         }
  79.         function v() {
  80.             (= t.innerHeight), (= i.documentElement.scrollHeight), h();
  81.         }
  82.         !||
  83.             ((= i.querySelector(".post-feed")) && ((= o = !(= 300)), (= t.scrollY), (= t.innerHeight), (= i.documentElement.scrollHeight), t.addEventListener("scroll", f, { passive: !0 }), t.addEventListener("resize", v), h()));
  84.     })(window, document),
  85.     (function (s, a) {
  86.         s.Casper || (s.Casper = {}),
  87.             (s.Casper.stickyNavTitle = function (e) {
  88.                 var t = a.querySelector(e.navSelector),
  89.                     i = a.querySelector(e.titleSelector),
  90.                     r = s.scrollY,
  91.                     n = !1;
  92.                 function o() {
  93.                     i.getBoundingClientRect().top + s.scrollY + (i.offsetHeight + 35) <= r ? t.classList.add(e.activeClass) : t.classList.remove(e.activeClass), (= !1);
  94.                 }
  95.                 s.addEventListener(
  96.                     "scroll",
  97.                     function () {
  98.                         (= s.scrollY),
  99.                             (function () {
  100.                                 n || requestAnimationFrame(o);
  101.                                 n = !0;
  102.                             })();
  103.                     },
  104.                     { passive: !0 }
  105.                 ),
  106.                     o();
  107.             });
  108.     })(window, document);
  109. //# sourceMappingURL=casper.js.map
  110.  

Editor

You can edit this paste and save as new: