-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgwdpagedeck_min.js
12 lines (12 loc) · 6.24 KB
/
gwdpagedeck_min.js
1
2
3
4
5
6
7
8
9
10
11
12
-function(){"use strict";var k=["-ms-","-moz-","-webkit-",""],l=function(a,c){for(var b,d,e=0;e<k.length;++e)b=k[e]+"transition-duration",d=""+c,a.style.setProperty(b,d)};function m(a,c,b,d,e,g,f){this.h=a;this.f=c;this.m=b;a=d||"none";this.g=e="none"===a?0:e||1E3;this.d=g||"linear";this.e=[];if(e){g=f||"top";if(f=this.h){f.classList.add("gwd-page");f.classList.add("center");f="center";if("push"==a)switch(g){case "top":f="top";break;case "bottom":f="bottom";break;case "left":f="left";break;case "right":f="right"}this.e.push(f);"fade"==a&&this.e.push("transparent")}f=this.f;e="center";if("none"!=a&&"fade"!=a)switch(g){case "top":e="bottom";break;case "bottom":e="top";
break;case "left":e="right";break;case "right":e="left"}f.classList.add(e);f.classList.add("gwd-page");"fade"==a&&f.classList.add("transparent")}}m.prototype.start=function(){if(this.g){var a=this.h,c=this.f;n(c,this.r.bind(this));a&&(l(a,this.g+"ms"),a.classList.add(this.d));l(c,this.g+"ms");c.classList.add(this.d);c.setAttribute("gwd-reflow",c.offsetWidth);if(a)for(var b=0;b<this.e.length;++b)a.classList.add(this.e[b]);p(c)}else this.m()};
var q=function(a,c,b,d){b="transform: matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,"+b+","+d+",0,1);";return a+"."+c+"{-webkit-"+b+"-moz-"+b+"-ms-"+b+b+"}"},r="center top bottom left right transparent".split(" "),p=function(a){r.forEach(function(c){a.classList.remove(c)})},n=function(a,c){var b=function(){a.removeEventListener("webkitTransitionEnd",b);a.removeEventListener("transitionend",b);c()};a.addEventListener("webkitTransitionEnd",b);a.addEventListener("transitionend",b)};
m.prototype.r=function(){var a=this.h;a&&(p(a),l(a,0),a.classList.remove(this.d));l(this.f,0);this.f.classList.remove(this.d);this.m()};var t=function(a,c,b){var d;b?(d=document.createEvent("CustomEvent"),d.initCustomEvent(a,!0,!0,b)):(d=document.createEvent("Event"),d.initEvent(a,!0,!0));c.dispatchEvent(d)};document.registerElement&&document.registerElement("gwd-pagedeck",{prototype:Object.create(HTMLDivElement.prototype,{createdCallback:{value:function(){window.addEventListener("WebComponentsReady",this.handleWebComponentsReadyEvent_.bind(this),!1);this.l=this.forwardDeviceEventsToCurrentPage_.bind(this,"shake");this.k=this.forwardDeviceEventsToCurrentPage_.bind(this,"rotatetoportrait");this.j=this.forwardDeviceEventsToCurrentPage_.bind(this,"rotatetolandscape");this.a=[];this.n=this.handlePageLoaded_.bind(this);
this.q=this.endPageTransition_.bind(this);this.c=this.o=null;this.b=-1;this.i=!1;this.classList.add("gwd-pagedeck")},enumerable:!0},handleWebComponentsReadyEvent_:{value:function(){this.a=Array.prototype.slice.call(this.querySelectorAll("div[is=gwd-page]"));this.a.forEach(function(a){a.classList.add("gwd-page")});for(t("beforepagesdetached",this,{pages:this.a.slice()});this.firstChild;)this.removeChild(this.firstChild);-1==this.b&&void 0!==this.p&&this.goToPage(this.p)},enumerable:!1},attachedCallback:{value:function(){if(!this.o){var a,
c=this.id;a=this.offsetWidth;var b=this.offsetHeight,c=(c&&"#")+c+".gwd-pagedeck > .gwd-page";a=q(c,"center",0,0)+q(c,"top",0,b)+q(c,"bottom",0,-b)+q(c,"left",a,0)+q(c,"right",-a,0);b=document.createElement("style");void 0!==b.cssText?b.cssText=a:b.innerHTML=a;document.head.appendChild(b);this.o=b}this.addEventListener("pageload",this.n,!1);document.body.addEventListener("shake",this.l,!0);document.body.addEventListener("rotatetoportrait",this.k,!0);document.body.addEventListener("rotatetolandscape",
this.j,!0)},enumerable:!0},detachedCallback:{value:function(){this.removeEventListener("pageload",this.n,!1);document.body.removeEventListener("shake",this.l,!0);document.body.removeEventListener("rotatetoportrait",this.k,!0);document.body.removeEventListener("rotatetolandscape",this.j,!0)},enumerable:!0},goToPageImpl_:{value:function(a,c,b,d,e){if(!(this.b==a||0>a||a>this.a.length-1||this.c)){var g=this.a[this.b],f=this.a[a];this.b=a;this.c=new m(g,f,this.q,c,b,d,e);this.appendChild(f);var h=f.gwdLoad&&
!f.gwdIsLoaded();this.i=h;setTimeout(function(){h?f.gwdLoad():this.startPageTransition_()}.bind(this),0)}},enumerable:!1},handlePageLoaded_:{value:function(a){this.i&&a.target.parentNode==this&&(this.startPageTransition_(),this.i=!1)}},startPageTransition_:{value:function(){t("pagetransitionstart",this);this.c.start()},enumerable:!1},endPageTransition_:{value:function(){this.c&&(this.c=null);var a=this.firstChild,c=this.lastChild,b=a==c;t("pagetransitionend",this,{outgoingPage:b?null:a,incomingPage:c});
b||this.removeChild(a);c.gwdPresent()},enumerable:!1},findPageIndexByAttributeValue:{value:function(a,c){for(var b=this.a.length,d,e=0;e<b;e++)if(d=this.a[e],"boolean"==typeof c){if(d.hasAttribute(a))return e}else if(d.getAttribute(a)==c)return e;return-1},enumerable:!0},goToNextPage:{value:function(a,c,b,d,e){var g=this.b,f=g+1;f>=this.a.length&&(f=a?0:g);this.goToPageImpl_(f,c,b,d,e)},enumerable:!0},goToPreviousPage:{value:function(a,c,b,d,e){var g=this.b,f=this.a.length,h=g-1;0>h&&(h=a?f-1:g);
this.goToPageImpl_(h,c,b,d,e)},enumerable:!0},goToPage:{value:function(a,c,b,d,e){this.a.length?(a="number"==typeof a?a:this.findPageIndexByAttributeValue("id",a),0<=a&&this.goToPageImpl_(a,c,b,d,e)):this.p=a},enumerable:!0},currentIndex:{get:function(){return 0<=this.b?this.b:void 0},enumerable:!0},getPages:{value:function(){return this.a}},getPage:{value:function(a){if("number"!=typeof a){if(!a)return null;a=this.findPageIndexByAttributeValue("id",a)}return 0>a||a>this.a.length-1?null:this.a[a]},
enumerable:!0},getDefaultPage:{value:function(){var a=this.getAttribute("default-page");return a?this.getPage(this.findPageIndexByAttributeValue("id",a)):this.getPage(0)},enumerable:!0},getOrientationSpecificPage:{value:function(a,c){var b=this.getPage(c),d=b.getAttribute("alt-orientation-page");if(!d)return b;var e=b.isPortrait(),g=1==a,d=this.getPage(d);return g==e?b:d},enumerable:!0},forwardDeviceEventsToCurrentPage_:{value:function(a,c){if(c.target==document.body){var b=this.getPage(this.b);t(a,
b)}},enumerable:!1},getElementById:{value:function(a){for(var c=this.a.length,b=0;b<c;b++){var d=this.a[b].querySelector("#"+a);if(d)return d}return null},enumerable:!0},getElementsBySelector:{value:function(a){for(var c=this.a.length,b=[],d=0;d<c;d++){var e=this.a[d].querySelectorAll(a);e&&(b=b.concat(Array.prototype.slice.call(e)))}return b},enumerable:!0}}),"extends":"div"});}()