UNPKG

jspanel4

Version:

A JavaScript library to create highly configurable multifunctional floating panels that can also be used as modal, tooltip, hint or contextmenu

1 lines 2.77 kB
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}jsPanel.layout||(jsPanel.layout={version:"1.4.1",date:"2021-01-19 10:50",storage:localStorage,save:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.selector?e.selector:".jsPanel-standard",n=e.storagename?e.storagename:"jspanels",o=document.querySelectorAll(t),i=[];o.forEach(function(e){var t=e.currentData;t.status=e.status,t.zIndex=e.style.zIndex,t.id=e.id,t.data=e.options.data||void 0,i.push(t)}),i.sort(function(e,t){return e.zIndex-t.zIndex}),this.storage.removeItem(n);var s=JSON.stringify(i);return this.storage.setItem(n,s),s},getAll:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"jspanels";return!!this.storage[e]&&JSON.parse(this.storage[e])},getDataset:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"id",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"jspanels",o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(this.storage[n]){var i,s=this.getAll(n);return o&&(i=[]),s.forEach(function(n){var o=_typeof(n[t]);if("string"===o||"number"===o)n[t]===e&&(i?i.push(n):i=n);else if(Array.isArray(n[t]))n[t].includes(e)&&(i?i.push(n):i=n);else if("object"===_typeof(n[t]))for(var s in n[t])if(n[t][s]===e){if(!i){i=n;break}i.push(n)}}),i||!1}return!1},restoreId:function(){var e,t,n,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!o.id||!o.config)return console.error("Id or predefined panel configuration is missing!"),!1;e=o.id,t=o.config,n=o.storagename?o.storagename:"jspanels";var i=this.getDataset(e,"id",n);if(i){var s={id:i.id,panelSize:{width:i.width,height:i.height},position:"left-top ".concat(i.left," ").concat(i.top),zIndex:i.zIndex},r=Object.assign({},t,s);return jsPanel.create(r,function(e){e.style.zIndex=s.zIndex,e.saveCurrentDimensions(),e.saveCurrentPosition(),e.calcSizeFactors(),"normalized"!==i.status&&("minimized"===i.status?e.minimize():"maximized"===i.status?e.maximize():"smallified"===i.status?e.smallify():"smallifiedmax"===i.status&&e.maximize().smallify())})}},restore:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n.configs?(e=n.configs,t=n.storagename?n.storagename:"jspanels",!!this.storage[t]&&void this.getAll(t).forEach(function(n){var o=n.id;for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&e[i].id===o&&jsPanel.layout.restoreId({id:o,config:e[i],storagename:t})})):(console.error("Object with predefined panel configurations is missing!"),!1)}}),"undefined"!=typeof module&&(module.exports=jsPanel);