1 Star 0 Fork 1

梁旭光 / Dungeons-and-Dragons

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
gwdimage_min.js 4.08 KB
一键复制 编辑 原始数据 按行查看 历史
梁旭光 提交于 2021-08-04 01:32 . Add files via upload
(function(){'use strict';var d=function(a){return"gwd-page"==a.tagName.toLowerCase()||"gwd-page"==a.getAttribute("is")},l=function(a){if(d(a))return a;for(;a&&9!=a.nodeType;)if((a=a.parentElement)&&d(a))return a;return null},m=function(a,b,c){var e=e||b;a.hasAttribute(b)?(a=a.getAttribute(b),c.setAttribute(e,a)):c.removeAttribute(e)};var n=["height","width","alt"];var p=/^\d*\.?\d+\s\d*\.?\d+$/;var q=function(){};goog.inherits(q,HTMLElement);
q.prototype.createdCallback=function(){for(var a;a=this.firstChild;)this.removeChild(a);this.a=document.createElement("img");this.g=this.h.bind(this);this.b=0;this.c=this.f=-1;Object.defineProperty(this,"nativeElement",{enumerable:!0,get:function(){return this.a}});Object.defineProperty(this,"assetWidth",{enumerable:!0,get:function(){return this.f}});Object.defineProperty(this,"assetHeight",{enumerable:!0,get:function(){return this.c}});Object.defineProperty(this,"naturalWidth",{enumerable:!0,get:function(){return this.a.naturalWidth}});
Object.defineProperty(this,"naturalHeight",{enumerable:!0,get:function(){return this.a.naturalHeight}});Object.defineProperty(this,"height",{enumerable:!0,get:function(){return this.a.height},set:function(b){this.a.height=b}});Object.defineProperty(this,"width",{enumerable:!0,get:function(){return this.a.width},set:function(b){this.a.width=b}});Object.defineProperty(this,"alt",{enumerable:!0,get:function(){return this.a.alt},set:function(b){this.a.alt=b}});Object.defineProperty(this,"src",{enumerable:!0,
get:function(){return this.a.src}});a=document.createElement("div");a.classList.add("intermediate-element");a.appendChild(this.a);this.appendChild(a);if(a=this.getAttribute("src"))this.setAttribute("source",a),this.removeAttribute("src");this.a.addEventListener("load",this.g,!1);this.a.addEventListener("error",this.g,!1);for(a=0;a<n.length;a++)m(this,n[a],this.a)};
q.prototype.attachedCallback=function(){if("function"==typeof this.gwdLoad&&"function"==typeof this.gwdIsLoaded&&!this.gwdIsLoaded()){var a=l(this),b=a&&"function"==typeof a.gwdIsLoaded;(!a||b&&a.gwdIsLoaded())&&this.gwdLoad()}};q.prototype.gwdIsLoaded=function(){return 2==this.b||3==this.b};q.prototype.gwdLoad=function(){this.b=1;this.c=this.f=-1;var a=this.getAttribute("source")||"data:image/gif;base64,R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";this.a.setAttribute("src",a)};
q.prototype.h=function(a){if(2!=this.b){a&&"error"==a.type?(this.b=3,this.c=this.f=-1,this.a.style.backgroundImage=""):(-1!=this.f&&-1!=this.c||!this.getAttribute("source")||(this.f=this.naturalWidth,this.c=this.naturalHeight),this.b=2);r(this);a=!1;var b=this.getAttribute("focalpoint");b&&p.test(b)&&(a=!0);a?t(this):u(this);a=document.createEvent("Event");a.initEvent("ready",!0,!0);this.dispatchEvent(a)}};
var r=function(a){if(2==a.b){var b=a.getAttribute("source"),c=a.getAttribute("scaling")||"stretch";"stretch"==c?(a.classList.remove("scaled-proportionally"),a.a.style.backgroundImage="",a=a.a,b=b||"data:image/gif;base64,R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",b!=a.getAttribute("src")&&a.setAttribute("src",b)):(a.classList.add("scaled-proportionally"),a.a.style.backgroundImage=b?"url("+JSON.stringify(b)+")":"",a.a.style.backgroundSize="none"!=c?c:"auto",b=a.a,"data:image/gif;base64,R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="!=
b.getAttribute("src")&&b.setAttribute("src","data:image/gif;base64,R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="))}},u=function(a){var b=a.getAttribute("alignment")||"center";a.a.style.backgroundPosition=b},t=function(a){var b=a.width,c=a.height,e=a.f,k=a.c,g=1;"cover"==a.getAttribute("scaling")&&(g=c/b>k/e?c/k:b/e);var f=a.getAttribute("focalpoint").split(" "),h=parseFloat(f[0])*g-b/2;f=parseFloat(f[1])*g-c/2;h=0<h?Math.min(h,e*g-b):0;f=0<f?Math.min(f,k*g-c):0;a.a.style.backgroundPositionX=
-h+"px";a.a.style.backgroundPositionY=-f+"px"};q.prototype.attributeChangedCallback=function(a){"source"==a?0!==this.b&&this.gwdLoad():"scaling"==a?r(this):"alignment"==a?u(this):"focalpoint"==a?t(this):"alt"==a&&m(this,a,this.a)};document.registerElement("gwd-image",{prototype:q.prototype});}).call(this);
HTML
1
https://gitee.com/liang-xuguang/Dungeons-and-Dragons.git
git@gitee.com:liang-xuguang/Dungeons-and-Dragons.git
liang-xuguang
Dungeons-and-Dragons
Dungeons-and-Dragons
main

搜索帮助