|
|
|
|
var Watermark=function(){function t(e={}){var n=t.prototype;this.options=e,s(this),d(this,this.options),h(this),p(this),n.upload=function(t){if(t){o.disconnect(),i.disconnect(),this.options.content=t;for(const e of this._container.querySelectorAll(".cell-watermark"))e.innerHTML=t;o.observe(this._container.parentNode,{childList:!0,subtree:!0}),i.observe(this._container,{attributes:!0,childList:!0,characterData:!0,subtree:!0})}},n.render=function(t={}){l(this,Object.assign(this.options,t))},n.destroy=function(){i.disconnect(),o.disconnect(),window.removeEventListener("resize",r),this._container.parentNode.removeChild(this._container)}}var e,n,i,o,r,c=window.outerWidth,a=window.outerHeight,s=function(t){t._container=document.createElement("div"),t._container.classList.add("cell-watermark-container"),t._container.style.cssText="display: block; pointer-events: none;",t._container.setAttribute("aria-hidden",!0),e=document.querySelector(t.options.appendTo)||document.body,e.appendChild(t._container)},d=function(t,e){e.rowSpacing=e.rowSpacing||60,e.colSpacing=e.colSpacing||30,e.width=e.width||150,e.height=e.height||20;let i=parseInt(a/(e.height+e.rowSpacing)),o=parseInt(c/(e.width+e.colSpacing)),r=(c-e.width*o-e.colSpacing*(o-1))/2,s=(a-e.height*i-e.rowSpacing*(i-1))/2,d=document.createElement("div");d.classList.add("cell-watermark"),d.style.cssText="transform: rotate(15deg); opacity: 0.1; font-size: 0.85rem; text-align: center;position: fixed; user-select: none; word-break: break-all; overflow: hidden; z-index: 999999;";for(let n=0;n<i;n++){let i=s+(e.rowSpacing+e.height)*n,c=o;n%2!=0&&c++;for(let n=0;n<c;n++){let a=r+(e.colSpacing+e.width)*n;c!==o&&(a-=(e.colSpacing+e.width)/2);let s=d.cloneNode();s.style.cssText+=`left: ${a}px; top: ${i}px; width: ${e.width}px; height: ${e.height}px`,s.style.transform=`rotate(${e.rotate}deg)`,s.style.opacity=e.opacity,s.style.fontSize=`${e.fontSize}rem`,s.innerHTML=e.content,t._container.appendChild(s)}}n=t._container},l=function(t,e){i.disconnect(),t._container.innerHTML="",d(t,e),i.observe(t._container,{attributes:!0,childList:!0,characterData:!0,subtree:!0})},h=function(t){i=new MutationObserver(function(e,n){l(t,t.options)}),i.observe(t._container,{attributes:!0,childList:!0,characterData:!0,subtree:!0}),o=new MutationObserver(function(t){for(let i of t)"childList"===i.type&&i.removedNodes.length>0&&0===document.querySelectorAll(".cell-watermark-container").length&&e.appendChild(n)}),o.observe(t._container.parentNode,{childList:!0,subtree:!0})},p=function(t){r=function(){window.outerHeight===a&&window.outerWidth===c||(a=window.outerHeight,c=window.outerWidth,l(t,t.options))},window.addEventListener("resize",r)};return t}();
|
|
|
|
|
var Watermark=function(){function t(e={}){var n=t.prototype;this.options=e,s(this),d(this,this.options),h(this),p(this),n.upload=function(t){if(t){o.disconnect(),i.disconnect(),this.options.content=t;for(const e of this._container.querySelectorAll(".cell-watermark"))e.innerHTML=t;o.observe(this._container.parentNode,{childList:!0,subtree:!0}),i.observe(this._container,{attributes:!0,childList:!0,characterData:!0,subtree:!0})}},n.render=function(t={}){l(this,Object.assign(this.options,t))},n.destroy=function(){i.disconnect(),o.disconnect(),window.removeEventListener("resize",r),this._container.parentNode.removeChild(this._container)}}var e,n,i,o,r,c=window.outerWidth,a=window.outerHeight,s=function(t){t._container=document.createElement("div"),t._container.classList.add("cell-watermark-container"),t._container.style.cssText="display: block; pointer-events: none;",t._container.setAttribute("aria-hidden",!0),e=document.querySelector(t.options.appendTo)||document.body,e.appendChild(t._container)},d=function(t,e){e.rowSpacing=e.rowSpacing||60,e.colSpacing=e.colSpacing||30,e.width=e.width||150,e.height=e.height||20;let i=parseInt(a/(e.height+e.rowSpacing)),o=parseInt(c/(e.width+e.colSpacing)),r=(c-e.width*o-e.colSpacing*(o-1))/2,s=(a-e.height*i-e.rowSpacing*(i-1))/2,d=document.createElement("div");d.classList.add("cell-watermark"),d.style.cssText="transform: rotate(15deg); opacity: 0.1; font-size: 0.85rem; text-align: center;position: fixed; user-select: none; word-break: break-all; overflow: hidden; z-index: 999999;";for(let n=0;n<i;n++){let i=s+(e.rowSpacing+e.height)*n,c=o;n%2!=0&&c++;for(let n=0;n<c;n++){let a=r+(e.colSpacing+e.width)*n;c!==o&&(a-=(e.colSpacing+e.width)/2);let s=d.cloneNode();s.style.cssText+=`left: ${a}px; top: ${i}px; width: ${e.width}px; height: ${e.height}px`,s.style.transform=`rotate(${e.rotate}deg)`,s.style.opacity=e.opacity,s.style.fontSize=`${e.fontSize}rem`,s.style.fontFamily=e.fontFamily,s.innerHTML=e.content,t._container.appendChild(s)}}n=t._container},l=function(t,e){i.disconnect(),t._container.innerHTML="",d(t,e),i.observe(t._container,{attributes:!0,childList:!0,characterData:!0,subtree:!0})},h=function(t){i=new MutationObserver(function(e,n){l(t,t.options)}),i.observe(t._container,{attributes:!0,childList:!0,characterData:!0,subtree:!0}),o=new MutationObserver(function(t){for(let i of t)"childList"===i.type&&i.removedNodes.length>0&&0===document.querySelectorAll(".cell-watermark-container").length&&e.appendChild(n)}),o.observe(t._container.parentNode,{childList:!0,subtree:!0})},p=function(t){r=function(){window.outerHeight===a&&window.outerWidth===c||(a=window.outerHeight,c=window.outerWidth,l(t,t.options))},window.addEventListener("resize",r)};return t}();
|