1 Star 0 Fork 34

皮皮虾耶/outline.js

forked from Yaohaixiao/outline.js 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
drawer.min.js 12.84 KB
一键复制 编辑 原始数据 按行查看 历史
!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).Drawer=t()}(this,(function(){"use strict";const e=e=>"string"==typeof e,t=(e,t)=>{const s=Object.prototype.hasOwnProperty;return e&&s.call(e,t)},s=Object.prototype.toString;class l{constructor(e){this.attrs={},e&&this.initialize(e)}initialize(e){return this.attr(e).render().addListeners(),this}attr(l,i){const r=this.attrs;return e(l)?i&&t(r,l)?(r[l]=i,this):r[l]:(a=l,"[object Object]"===s.apply(a)&&null!==a?(n=r,o=l,Object.keys(o).forEach((e=>{t(o,e)&&(n[e]=o[e])})),this):0===arguments.length?r:this);var n,o,a}render(){return this}destroy(){return this.removeListeners(),this}reload(e){return this.destroy().initialize(this.attr(e)),this}addListeners(){return this}removeListeners(){return this}}const i=e=>"function"==typeof e||"[object Function]"===s.apply(e),r=(e,t=300)=>!!i(e)&&setTimeout((()=>{e()}),t),n=(e,t)=>{let s=e.className;return!!s&&s.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},o=(e,t)=>{let s=e.className;if(n(e,t))return!1;s+=s.length>0?" "+t:t,e.className=s},a=(t,s)=>{let l=t.className;if(!l||!n(t,s))return!1;var i;i=l.replace(s,""),l=!!e(i)&&i.replace(/^\s+|\s+$/g,""),t.className=l},c=e=>Array.isArray?Array.isArray(e):"[object Array]"===s.apply(e),h=e=>e&&e.nodeName&&e.tagName&&1===e.nodeType,d=(e,s,l)=>{const i=Object.keys(s);let r=document.createElement(e);return i.forEach((e=>{t(s,e)&&((e,t,s)=>{let l=e.tagName.toLowerCase();switch(t){case"style":e.style.cssText=s;break;case"value":"input"===l||"textarea"===l?e.value=s:e.setAttribute(t,s);break;case"className":e.className=s;break;default:e.setAttribute(t,s)}})(r,e,s[e])})),c(l)&&l.forEach((e=>{let t=h(e)?e:document.createTextNode(e);r.appendChild(t)})),r},u=(e,t="")=>{const s=t.replace(/^>/i,"");return!!(t&&s&&e)&&(e.matches?e.matches(s):!!e.msMatchesSelector&&e.msMatchesSelector(s))},m=e=>e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode,p=["focusout","blur","focusin","focus","load","unload","mouseenter","mouseleave"],f=(e,t,s)=>{const l=p.indexOf(t)>-1;s._delegateListener&&delete(s=s._delegateListener)._delegateListener,function(e,t,s){const l=e._listeners;let i=-1;if(l.length<1)return!1;l.forEach(((e,l)=>{const r=e.fn;t===e.type&&(i=l,r===s&&(i=l))})),i>-1&&l.splice(i,1)}(e,t,s),e.removeEventListener(t,s,l)},y=function(t,s,l=!1){const i=e(t)?document.querySelector(t):t,r=i.childNodes,n=((t,s)=>{let l=t._listeners||[];return e(s)&&s&&(l=l.filter((e=>e.type===s))),l})(i,s);n.forEach((e=>{f(i,e.type,e.fn)})),(l||!0===s||1===arguments.length)&&i&&r&&r.forEach((e=>{h(e)&&y(e,s,l)}))},v=(e,t,s)=>{if(!i(s))return y(e,t);f(e,t,s)},$=(e,t,s,l,i,r,n=!1)=>{const o=p.indexOf(s)>-1,a=function(o){const c=function(e){const t=e.target;return(s=t)&&3===s.nodeType?s.parentNode:s;var s}(o),h=((e,t,s,l)=>{const i=s||document;if(!e)return null;do{if(null!=t&&(">"===t[0]?e.parentNode===i&&u(e,t):u(e,t))||l&&e===i)return e;if(e===i)break}while(e=m(e))})(c,t,e);let d=r||e;o.delegateTarget=h,!0===r&&(d=i),h&&(!0===n&&v(e,s,a),l.call(d,o,i))};e._listeners||(e._listeners=[]),e._listeners.push({el:e,selector:t,type:s,fn:a,data:i,context:r,capture:o}),l._delegateListener=a,e.addEventListener(s,a,o)},_=(e,t=0,s="",l="outline")=>{const i=l?`xlink:href="#${l}-icon-${e}"`:`xlink:href="#icon-${e}"`,r=c(t)?t[0]:t,n=c(t)?t[1]:t,o=t?`width:${r}px;height:${n}px;`:"",a=`<svg aria-hidden="true" class="outline-icon__svg" style="${s?o+`color:${s}`:o}"><use ${i}></use></svg>`,h=document.createElement("i");return h.className="outline-icon",h.innerHTML=a,h};class b extends l{constructor(e){super(),this.attrs=b.DEFAULTS,this.title="",this.closed=!0,this.$el=null,this.$modal=null,this.$header=null,this.$title=null,this.$close=null,this.$main=null,this.$footer=null,this.$overlay=null,e&&this.initialize(e)}initialize(e){let t;return this.attr(e),this.title=this.attr("title"),t=this.attr("created"),i(t)&&t.call(this),this.render().addListeners(),this}setTitle(e){return this.attr("title",e),this.title=e,this.$title.innerHTML=e,this}isClosed(){return this.closed}render(){const e=this.attr("mounted"),t=this.attr("size"),s=this.attr("placement"),l=this.attr("hasClose"),r=this.attr("hasOverlay"),n=this.attr("hasOffset"),a=this.attr("hasPadding");let h,u,m,p,f,y,v,$;return((e=[])=>{const t=['<symbol id="outline-icon-up" viewBox="0 0 1024 1024"><path d="M494.784 261.696c0.832-0.448 1.536-1.216 2.368-1.536a38.72 38.72 0 0 1 46.08 8.256l277.824 302.272a41.92 41.92 0 0 1-1.536 58.048 39.104 39.104 0 0 1-56.448-1.6L513.728 355.904 260.736 626.048a39.104 39.104 0 0 1-56.448 1.088 41.6 41.6 0 0 1-1.088-57.984L483.84 269.696c0.512-0.512 1.344-0.768 1.92-1.408l1.088-1.344c2.368-2.496 5.312-3.648 8-5.248z"></path></symbol>','<symbol id="outline-icon-down" viewBox="0 0 1024 1024"><path d="M494.784 762.304c0.832 0.448 1.536 1.216 2.368 1.536 15.232 7.488 33.92 4.992 46.08-8.256l277.824-302.272a41.92 41.92 0 0 0-1.536-58.048 39.104 39.104 0 0 0-56.448 1.6l-249.344 271.232-252.992-270.144a39.104 39.104 0 0 0-56.448-1.088 41.6 41.6 0 0 0-1.088 57.984l280.576 299.456c0.512 0.512 1.344 0.768 1.92 1.408l1.088 1.344c2.368 2.496 5.312 3.648 8 5.248z"></path></symbol>','<symbol id="outline-icon-menu" viewBox="0 0 1024 1024"><path d="M320 256h640V128H320zM320 576h640V448H320zM320 896h640v-128H320zM64 256h128V128H64zM64 576h128V448H64zM64 896h128v-128H64z"></path></symbol>','<symbol id="outline-icon-hash" viewBox="0 0 24 24"><path d="M14.216 10l-0.444 4h-3.988l0.444-4zM15.006 2.89l-0.568 5.11h-3.988l0.543-4.89c0.061-0.549-0.335-1.043-0.883-1.104s-1.043 0.335-1.104 0.884l-0.568 5.11h-4.438c-0.552 0-1 0.448-1 1s0.448 1 1 1h4.216l-0.444 4h-3.772c-0.552 0-1 0.448-1 1s0.448 1 1 1h3.549l-0.543 4.89c-0.061 0.549 0.335 1.043 0.883 1.104s1.043-0.335 1.104-0.883l0.569-5.111h3.988l-0.543 4.89c-0.061 0.549 0.335 1.043 0.883 1.104s1.043-0.335 1.104-0.883l0.568-5.111h4.438c0.552 0 1-0.448 1-1s-0.448-1-1-1h-4.216l0.444-4h3.772c0.552 0 1-0.448 1-1s-0.448-1-1-1h-3.549l0.543-4.89c0.061-0.549-0.335-1.043-0.883-1.104s-1.043 0.335-1.104 0.883z"></path></symbol>','<symbol id="outline-icon-close" viewBox="0 0 1024 1024"><path d="M536.96 491.648L310.592 265.344a32 32 0 1 0-45.248 45.248L491.584 536.96l-226.304 226.304a32 32 0 0 0 45.312 45.248l226.24-226.304 226.304 226.304a32 32 0 0 0 45.248-45.248L582.144 536.896l226.304-226.24a32 32 0 0 0-45.248-45.248L536.896 491.584z"></path></symbol>','<symbol id="outline-icon-homepage" viewBox="0 0 26 28"><path d="M22 15.5v7.5c0 0.547-0.453 1-1 1h-6v-6h-4v6h-6c-0.547 0-1-0.453-1-1v-7.5c0-0.031 0.016-0.063 0.016-0.094l8.984-7.406 8.984 7.406c0.016 0.031 0.016 0.063 0.016 0.094zM25.484 14.422l-0.969 1.156c-0.078 0.094-0.203 0.156-0.328 0.172h-0.047c-0.125 0-0.234-0.031-0.328-0.109l-10.813-9.016-10.813 9.016c-0.109 0.078-0.234 0.125-0.375 0.109-0.125-0.016-0.25-0.078-0.328-0.172l-0.969-1.156c-0.172-0.203-0.141-0.531 0.063-0.703l11.234-9.359c0.656-0.547 1.719-0.547 2.375 0l3.813 3.187v-3.047c0-0.281 0.219-0.5 0.5-0.5h3c0.281 0 0.5 0.219 0.5 0.5v6.375l3.422 2.844c0.203 0.172 0.234 0.5 0.063 0.703z"></path></symbol>','<symbol id="outline-icon-tags" viewBox="0 0 24 28"><path d="M7 7c0-1.109-0.891-2-2-2s-2 0.891-2 2 0.891 2 2 2 2-0.891 2-2zM23.672 16c0 0.531-0.219 1.047-0.578 1.406l-7.672 7.688c-0.375 0.359-0.891 0.578-1.422 0.578s-1.047-0.219-1.406-0.578l-11.172-11.188c-0.797-0.781-1.422-2.297-1.422-3.406v-6.5c0-1.094 0.906-2 2-2h6.5c1.109 0 2.625 0.625 3.422 1.422l11.172 11.156c0.359 0.375 0.578 0.891 0.578 1.422zM29.672 16c0 0.531-0.219 1.047-0.578 1.406l-7.672 7.688c-0.375 0.359-0.891 0.578-1.422 0.578-0.812 0-1.219-0.375-1.75-0.922l7.344-7.344c0.359-0.359 0.578-0.875 0.578-1.406s-0.219-1.047-0.578-1.422l-11.172-11.156c-0.797-0.797-2.312-1.422-3.422-1.422h3.5c1.109 0 2.625 0.625 3.422 1.422l11.172 11.156c0.359 0.375 0.578 0.891 0.578 1.422z"></path><path d="M12 2c6.625 0 12 5.375 12 12 0 5.297-3.437 9.797-8.203 11.391-0.609 0.109-0.828-0.266-0.828-0.578 0-0.391 0.016-1.687 0.016-3.297 0-1.125-0.375-1.844-0.812-2.219 2.672-0.297 5.484-1.313 5.484-5.922 0-1.313-0.469-2.375-1.234-3.219 0.125-0.313 0.531-1.531-0.125-3.187-1-0.313-3.297 1.234-3.297 1.234-0.953-0.266-1.984-0.406-3-0.406s-2.047 0.141-3 0.406c0 0-2.297-1.547-3.297-1.234-0.656 1.656-0.25 2.875-0.125 3.187-0.766 0.844-1.234 1.906-1.234 3.219 0 4.594 2.797 5.625 5.469 5.922-0.344 0.313-0.656 0.844-0.766 1.609-0.688 0.313-2.438 0.844-3.484-1-0.656-1.141-1.844-1.234-1.844-1.234-1.172-0.016-0.078 0.734-0.078 0.734 0.781 0.359 1.328 1.75 1.328 1.75 0.703 2.141 4.047 1.422 4.047 1.422 0 1 0.016 1.937 0.016 2.234 0 0.313-0.219 0.688-0.828 0.578-4.766-1.594-8.203-6.094-8.203-11.391 0-6.625 5.375-12 12-12zM4.547 19.234c0.031-0.063-0.016-0.141-0.109-0.187-0.094-0.031-0.172-0.016-0.203 0.031-0.031 0.063 0.016 0.141 0.109 0.187 0.078 0.047 0.172 0.031 0.203-0.031zM5.031 19.766c0.063-0.047 0.047-0.156-0.031-0.25-0.078-0.078-0.187-0.109-0.25-0.047-0.063 0.047-0.047 0.156 0.031 0.25 0.078 0.078 0.187 0.109 0.25 0.047zM5.5 20.469c0.078-0.063 0.078-0.187 0-0.297-0.063-0.109-0.187-0.156-0.266-0.094-0.078 0.047-0.078 0.172 0 0.281s0.203 0.156 0.266 0.109zM6.156 21.125c0.063-0.063 0.031-0.203-0.063-0.297-0.109-0.109-0.25-0.125-0.313-0.047-0.078 0.063-0.047 0.203 0.063 0.297 0.109 0.109 0.25 0.125 0.313 0.047zM7.047 21.516c0.031-0.094-0.063-0.203-0.203-0.25-0.125-0.031-0.266 0.016-0.297 0.109s0.063 0.203 0.203 0.234c0.125 0.047 0.266 0 0.297-0.094zM8.031 21.594c0-0.109-0.125-0.187-0.266-0.172-0.141 0-0.25 0.078-0.25 0.172 0 0.109 0.109 0.187 0.266 0.172 0.141 0 0.25-0.078 0.25-0.172zM8.937 21.438c-0.016-0.094-0.141-0.156-0.281-0.141-0.141 0.031-0.234 0.125-0.219 0.234 0.016 0.094 0.141 0.156 0.281 0.125s0.234-0.125 0.219-0.219z"></path></symbol>','<symbol id="outline-icon-issues" viewBox="0 0 26 28"><path d="M25.5 15c0 0.547-0.453 1-1 1h-3.5c0 1.953-0.422 3.422-1.047 4.531l3.25 3.266c0.391 0.391 0.391 1.016 0 1.406-0.187 0.203-0.453 0.297-0.703 0.297s-0.516-0.094-0.703-0.297l-3.094-3.078s-2.047 1.875-4.703 1.875v-14h-2v14c-2.828 0-4.891-2.063-4.891-2.063l-2.859 3.234c-0.203 0.219-0.469 0.328-0.75 0.328-0.234 0-0.469-0.078-0.672-0.25-0.406-0.375-0.438-1-0.078-1.422l3.156-3.547c-0.547-1.078-0.906-2.469-0.906-4.281h-3.5c-0.547 0-1-0.453-1-1s0.453-1 1-1h3.5v-4.594l-2.703-2.703c-0.391-0.391-0.391-1.016 0-1.406s1.016-0.391 1.406 0l2.703 2.703h13.188l2.703-2.703c0.391-0.391 1.016-0.391 1.406 0s0.391 1.016 0 1.406l-2.703 2.703v4.594h3.5c0.547 0 1 0.453 1 1zM18 6h-10c0-2.766 2.234-5 5-5s5 2.234 5 5z"></path></symbol>'],s=c(e)&&e.length>0?t.concat(e):t,l=document.body;let i=document.querySelector("#svg-sprites");i?i.innerHTML=s.join(""):(i=document.createElement("div"),i.innerHTML=`<svg id="svg-sprites" aria-hidden="true" style="position:absolute;display:none;width:0;height:0;overflow:hidden;">${s.join("")}</svg>`,l.insertBefore(i.firstChild,l.firstChild))})(),b.zIndex+=1,p=d("h2",{className:"outline-drawer__title"},[this.title]),this.$title=p,l&&(f=d("div",{className:"outline-drawer__close"},[_("close",20)]),this.$close=f),m=d("header",{className:"outline-drawer__header"},[p,f]),this.$header=m,y=d("div",{className:"outline-drawer__main"},[""]),this.$main=y,a||o(y," outline-drawer_full"),v=d("footer",{className:"outline-drawer__footer"},[""]),this.$footer=v,u=d("div",{className:`outline-drawer__modal outline-drawer_${s} outline-drawer_${t} outline-drawer_closed`},[m,y,v]),this.$modal=u,n&&o(u," outline-drawer_offset"),r&&($=d("div",{className:"outline-drawer__overlay"},[""]),this.$overlay=$),h=d("div",{className:"outline-drawer"},[u,$]),this.$el=h,document.body.appendChild(h),i(e)&&e.call(this),this}open(){const e=this.attr("afterOpened"),t=this.$modal;return o(this.$el,"outline-drawer_opened"),a(t,"outline-drawer_closed"),o(t,"outline-drawer_opened"),r((()=>{this.closed=!1,i(e)&&e.call(this)})),this}close(){const e=this.attr("afterClosed"),t=this.$modal;return a(t,"outline-drawer_opened"),o(t,"outline-drawer_closed"),r((()=>{a(this.$el,"outline-drawer_opened"),this.closed=!0,i(e)&&e.call(this)})),this}toggle(){return this.isClosed()?this.open():this.close(),this}destroy(){const e=this.attr("afterDestroy"),t=this.attr("beforeDestroy");return i(t)&&t.call(this),this.removeListeners(),this.attrs=b.DEFAULTS,this.title="",this.closed=!1,this.$el=null,this.$modal=null,this.$header=null,this.$title=null,this.$close=null,this.$main=null,this.$footer=null,this.$overlay=null,b.zIndex-=1,i(e)&&e.call(this),this}addListeners(){const e=this.attr("hasClose"),t=this.attr("hasOverlay"),s=this.$el;return e&&$(s,".outline-drawer__close","click",this.onClose,this,!0),t&&$(s,".outline-drawer__overlay","click",this.onClose,this,!0),this}removeListeners(){const e=this.attr("hasClose"),t=this.attr("hasOverlay"),s=this.$el;return e||t?(v(s,"click",this.onClose),this):this}onClose(){return this.close(),this}}return b.DEFAULTS={placement:"rtl",title:"标题",size:"regular",hasClose:!0,hasOverlay:!0,hasOffset:!1,hasPadding:!0,created:null,mounted:null,afterClosed:null,afterOpened:null,afterScroll:null,beforeDestroy:null,afterDestroy:null},b.zIndex=2e3,b}));
//# sourceMappingURL=drawer.min.js.map
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/pipixiaye/outline.js.git
git@gitee.com:pipixiaye/outline.js.git
pipixiaye
outline.js
outline.js
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385