1
0
mirror of https://github.com/S2-/gitlit synced 2025-08-02 20:30:05 +02:00
Files
gitlit/app/node_modules/pnotify/dist/es/PNotifyHistory.js
2018-05-18 16:52:09 +02:00

2 lines
3.4 KiB
JavaScript

import PNotify from"./PNotify.js";function data(){return Object.assign({_notice:null,_options:{}},PNotify.modules.History.defaults)}var methods={initModule(t){if(this.set(t),this.get().history){const{_notice:t}=this.get();t.get().destroy&&t.set({destroy:!1})}},beforeOpen(){const{maxInStack:t,_options:o}=this.get();if(t===1/0)return;const e=o.stack;if(!1!==e&&PNotify.notices&&PNotify.notices.length>t){const o="top"===e.push,i=[];let s=0;for(let n=o?0:PNotify.notices.length-1;o?n<PNotify.notices.length:n>=0;o?n++:n--)-1!==["opening","open"].indexOf(PNotify.notices[n].get()._state)&&PNotify.notices[n].get().stack===e&&(s>=t?i.push(PNotify.notices[n]):s++);for(let t=0;t<i.length;t++)i[t].close(!1)}}};function setup(t){t.key="History",t.defaults={history:!0,maxInStack:1/0},t.init=(o=>new t({target:document.body})),t.showLast=(t=>{if(void 0===t&&(t=PNotify.defaultStack),!1===t)return;const o="top"===t.push;let e,i=o?0:PNotify.notices.length-1;do{if(!(e=PNotify.notices[i]))return;i+=o?1:-1}while(e.get().stack!==t||!e.get()._modules.History.get().history||"opening"===e.get()._state||"open"===e.get()._state);e.open()}),t.showAll=(t=>{if(void 0===t&&(t=PNotify.defaultStack),!1!==t)for(let o=0;o<PNotify.notices.length;o++){const e=PNotify.notices[o];!0!==t&&e.get().stack!==t||!e.get()._modules.History.get().history||e.open()}}),PNotify.modules.History=t}function create_main_fragment(t,o){return{c:noop,m:noop,p:noop,d:noop}}function PNotifyHistory(t){init(this,t),this._state=assign(data(),t.data),this._intro=!0,this._fragment=create_main_fragment(this,this._state),t.target&&(this._fragment.c(),this._mount(t.target,t.anchor))}function noop(){}function init(t,o){t._handlers=blankObject(),t._bind=o._bind,t.options=o,t.root=o.root||t,t.store=t.root.store||o.store}function assign(t,o){for(var e in o)t[e]=o[e];return t}function destroy(t){this.destroy=noop,this.fire("destroy"),this.set=noop,this._fragment.d(!1!==t),this._fragment=null,this._state={}}function get(){return this._state}function fire(t,o){var e=t in this._handlers&&this._handlers[t].slice();if(e)for(var i=0;i<e.length;i+=1){var s=e[i];s.__calling||(s.__calling=!0,s.call(this,o),s.__calling=!1)}}function on(t,o){var e=this._handlers[t]||(this._handlers[t]=[]);return e.push(o),{cancel:function(){var t=e.indexOf(o);~t&&e.splice(t,1)}}}function set(t){this._set(assign({},t)),this.root._lock||(this.root._lock=!0,callAll(this.root._beforecreate),callAll(this.root._oncreate),callAll(this.root._aftercreate),this.root._lock=!1)}function _set(t){var o=this._state,e={},i=!1;for(var s in t)this._differs(t[s],o[s])&&(e[s]=i=!0);i&&(this._state=assign(assign({},o),t),this._recompute(e,this._state),this._bind&&this._bind(e,this._state),this._fragment&&(this.fire("state",{changed:e,current:this._state,previous:o}),this._fragment.p(e,this._state),this.fire("update",{changed:e,current:this._state,previous:o})))}function _mount(t,o){this._fragment[this._fragment.i?"i":"m"](t,o||null)}function _differs(t,o){return t!=t?o==o:t!==o||t&&"object"==typeof t||"function"==typeof t}function blankObject(){return Object.create(null)}function callAll(t){for(;t&&t.length;)t.shift()()}assign(PNotifyHistory.prototype,{destroy:destroy,get:get,fire:fire,on:on,set:set,_set:_set,_mount:_mount,_differs:_differs}),assign(PNotifyHistory.prototype,methods),PNotifyHistory.prototype._recompute=noop,setup(PNotifyHistory);export default PNotifyHistory;
//# sourceMappingURL=PNotifyHistory.js.map