-
Notifications
You must be signed in to change notification settings - Fork 0
/
gwdgallerynavigation_min.js
6 lines (6 loc) · 2.51 KB
/
gwdgallerynavigation_min.js
1
2
3
4
5
6
(function(){'use strict';var e=function(){};goog.inherits(e,HTMLElement);e.prototype.createdCallback=function(){this.a=null;this.h=this.l.bind(this);this.g=this.j.bind(this);this.f=!1;this.b=document.createElement("div");this.b.classList.add("button-container");this.appendChild(this.b);this.b.addEventListener("click",this.i.bind(this),!0);this.c=[]};
var p=function(a){k(a);var b=a.getAttribute("for"),c=null;if(b){c=document.getElementById(b);for(var f=!1,d=a.parentNode;!c&&d&&!f;d=d.parentNode)if((f="body"==d.tagName.toLowerCase())||d.hasAttribute("data-gwd-group"))c=d.querySelector('[data-gwd-grp-id="'+b+'"]')}a:if(c){b="currentIndex frameCount frameSnapInterval getFrame goToFrame goForwards goBackwards rotateOnce".split(" ");for(f=0;f<b.length;++f)if(!(b[f]in c)){b=!1;break a}b=!0}else b=!1;b&&(a.a=c,c.addEventListener("frameactivated",a.g),
c.gwdIsLoaded()?n(a):c.addEventListener("ready",a.h))},k=function(a){a.a&&(a.a.removeEventListener("ready",a.h),a.a.removeEventListener("frameactivated",a.g))};e.prototype.l=function(a){a.target==this.a&&n(this)};e.prototype.j=function(a){a.target==this.a&&q(this,a.detail.id)};e.prototype.i=function(a){for(a=a.target;a&&a!=this;a=a.parentNode)if(a.gwdTargetFrameNum){this.a.goToFrame(a.gwdTargetFrameNum);break}};
var n=function(a){var b=a.getAttribute("highlight");a.style.color=b||"";a.f=a.hasAttribute("use-thumbnails");for(a.c=[];a.b.firstChild;)a.b.removeChild(a.b.firstChild);if(a.a){for(b=0;b<a.a.frameCount;b+=a.a.frameSnapInterval){var c=document.createElement("span");c.classList.add("button");for(var f=a.f?a.a.frameSnapInterval:1,d=0;d<f;++d){var g=a.a.getFrame(b+d+1);if(!g)break;var l=void 0;var h=a;var m=g;g=document.createElement("span");h.f?(g.classList.add("frame-thumbnail"),(h="img"==m.tagName.toLowerCase()?
m:m.querySelector("img"))&&(l=h.getAttribute("source")||h.getAttribute("src")),g.style.backgroundImage=l?"url("+JSON.stringify(l)+")":"url(data:image/gif;base64,R0lGODlhAQABAPAAAGZmZgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==)"):g.classList.add("frame-dot");c.appendChild(g)}c.gwdTargetFrameNum=b+1;a.c.push(c);a.b.appendChild(c)}q(a)}},q=function(a,b){b=void 0!=b?b-1:a.a.currentIndex-1;b=Math.floor(b/a.a.frameSnapInterval);for(var c=0;c<a.c.length;c++)a.c[c].classList.remove("active");(a=a.c[b])&&a.classList.add("active")};
e.prototype.attachedCallback=function(){p(this)};e.prototype.detachedCallback=function(){k(this)};e.prototype.attributeChangedCallback=function(a){"for"==a?p(this):n(this)};document.registerElement("gwd-gallerynavigation",{prototype:e.prototype});}).call(this);