UNPKG

rxcornor

Version:
8 lines (7 loc) 3.09 kB
/*! * RxCornon * version: 0.0.8 * repo: https://github.com/cheere/rxcornor * build: 2021-09-16 10:09:38 */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).RxCornor=t()}(this,(function(){"use strict";let e=!1;const t="rxcornor";function n(){this instanceof n||console.warn("RxCornor is a constructor and should be called with `new` keyword")}function o(e){setTimeout((()=>{document.body?document.body.appendChild(e):o(e)}),100)}function s(e,t,o){let s;o&&"object"==typeof o&&(s=o[e],s=s||t);const i={value:s,writable:!0,enumerable:!0,configurable:!1};Object.defineProperty(n.prototype,e,i)}function i(e){const t=document.head||document.getElementsByTagName("head")[0];if(e.indexOf(".css")>0){const n=document.createElement("link");n.setAttribute("rel","stylesheet"),n.setAttribute("href",e),t.appendChild(n)}else{const n=document.createElement("script");n.type="text/javascript",n.setAttribute("src",e),t.appendChild(n)}}function r(){const t=function(){const e={},t=["link","target","title","className","style","animal"],o=Object.entries(n.prototype);for(let n=0;n<o.length;n++){const s=o[n],i=s[0]||"",r=s[1]||"";-1!==t.indexOf(i)&&(e[i]=r)}return e}();if(!t)return'<div data-set-tip="getTemplate-fn error"></div>';const o=t.link||"",s=t.target||"",i=t.title||"",r=`\n <a href="${o}" target="${s}" rel="noopener noreferrer" title="Follow me on ${i}" aria-describedat="rxcornor">\n <div class="rxcont ${t.className||""}">\n <div class="text">${i}</div>\n </div>\n </a>\n `;return e?`<div class="rxcornor">${r}</div>`:r}function l(e){s("title","GitHub",e),s("link","",e),s("target","_blank",e),s("className","",e),s("style",null,e),s("animal",null,e)}return function c(){if(!document)return void setTimeout((()=>{c()}),10);const a=document.getElementById(t);if(a)!function(e){const n=e.attributes||{},s=function(e=""){return(n[e]||{}).value||""},c=s("link"),a=s("target")||"_blank",d=s("title")||"GitHub",u=s("className")||"",m=s("style")||null,f=s("animal")||"play";l({link:c,target:a,title:d,className:u,style:m});function p(e,t){const n=e.lastIndexOf(t);return n>0?e.slice(0,n):e}let y=p(s("src")||"","rxcornor.js");y=p(y,"rxcornor.min.js"),y=p(y,"index.js"),y=p(y,"index.min.js");const b=document.createElement("div");b.innerHTML=r(),b.className=t,m&&(b.style=m);const g=parseInt((new Date).getTime()/108e3);i(y+t+".css?"+g),o(b),b.onmouseover=function(){b.classList.add(f)},b.onmouseout=function(){b.classList.remove(f)}}(a);else{e=!0;l({})}s(n.prototype,"isNode",e)}(),n.prototype.version='"0.0.8"',n.prototype.headAppendLabel=i,n.prototype.getTemplate=r,n.prototype.setConfig=l,n.prototype.addNomalAnimal=function e(n){n=n||"play";const o=document;if(!o)return void setTimeout((()=>{e(n)}),10);const s=o.getElementsByClassName(t);for(let e=0;e<s.length;e++){const t=s[e]||{};t&&t.nodeName&&"DIV"===t.nodeName&&(t.onmouseover=function(){t.classList.add(n)},t.onmouseout=function(){t.classList.remove(n)})}},n}));