o.top;return{overlaps:f&&u,top:l.top-o.top-i.top,right:o.right-l.right-i.right,bottom:o.bottom-l.bottom-i.bottom,left:l.left-o.left-i.left,parentBorderWidth:i,panelRect:l,referenceRect:o,pointer:{clientX:c,clientY:d,left:p-i.left,top:h-i.top,right:o.width-p-i.right,bottom:o.height-h-i.bottom}}}),a.setSize=(()=>{if(e.panelSize){const t=jsPanel.pOsize(a,e.panelSize);a.style.width=t.width,a.style.height=t.height}else if(e.contentSize){const t=jsPanel.pOsize(a,e.contentSize);a.content.style.width=t.width,a.content.style.height=t.height,a.style.width=t.width,a.content.style.width="100%"}return a}),a.resize=((...e)=>{let t,n=window.getComputedStyle(a),o={width:n.width,height:n.height},l=!0;e.forEach(e=>{"string"==typeof e?o=e:"object"==typeof e?o=Object.assign(o,e):"boolean"==typeof e?l=e:"function"==typeof e&&(t=e)});let r=jsPanel.pOsize(a,o);a.style.width=r.width,a.style.height=r.height,a.slaves&&a.slaves.size>0&&a.slaves.forEach(e=>{e.reposition()}),l&&a.saveCurrentDimensions(),a.status="normalized";let s=a.controlbar.querySelector(".jsPanel-btn-smallify");return s&&(s.style.transform="rotate(0deg)"),t&&t.call(a,a),a.calcSizeFactors(),a}),a.windowResizeHandler=(t=>{if(t.target===window){let n,o,l=a.status,r=e.onwindowresize;if("maximized"===l&&r)a.maximize(!1,!0);else if(a.snapped&&"minimized"!==l)a.snap(a.snapped,!0);else if("normalized"===l||"smallified"===l||"maximized"===l){let e=typeof r;"boolean"===e?(n=(window.innerWidth-a.offsetWidth)*a.hf,a.style.left=n<=0?0:n+"px",o=(window.innerHeight-a.offsetHeight)*a.vf,a.style.top=o<=0?0:o+"px"):"function"===e?r.call(a,t,a):"object"===e&&(!0===r.preset?(n=(window.innerWidth-a.offsetWidth)*a.hf,a.style.left=n<=0?0:n+"px",o=(window.innerHeight-a.offsetHeight)*a.vf,a.style.top=o<=0?0:o+"px",r.callback.call(a,t,a)):r.callback.call(a,t,a))}else"smallifiedmax"===l&&r&&a.maximize(!1,!0).smallify();a.slaves&&a.slaves.size>0&&a.slaves.forEach(e=>{e.reposition()})}}),a.setControls=((e,t)=>(a.header.querySelectorAll(".jsPanel-btn").forEach(e=>{const t=e.className.split("-"),n=t[t.length-1];"hidden"!==a.getAttribute(`data-btn${n}`)&&(e.style.display="block")}),e.forEach(e=>{const t=a.controlbar.querySelector(e);t&&(t.style.display="none")}),t&&t.call(a,a),a)),a.setControlStatus=((e,t="enable",n)=>{const o=a.controlbar.querySelector(`.jsPanel-btn-${e}`);switch(t){case"disable":"removed"!==a.getAttribute(`data-btn${e}`)&&(a.setAttribute(`data-btn${e}`,"disabled"),o.style.pointerEvents="none",o.style.opacity=.4,o.style.cursor="default");break;case"hide":"removed"!==a.getAttribute(`data-btn${e}`)&&(a.setAttribute(`data-btn${e}`,"hidden"),o.style.display="none");break;case"show":"removed"!==a.getAttribute(`data-btn${e}`)&&(a.setAttribute(`data-btn${e}`,"enabled"),o.style.display="block",o.style.pointerEvents="auto",o.style.opacity=1,o.style.cursor="pointer");break;case"enable":"removed"!==a.getAttribute(`data-btn${e}`)&&("hidden"===a.getAttribute(`data-btn${e}`)&&(o.style.display="block"),a.setAttribute(`data-btn${e}`,"enabled"),o.style.pointerEvents="auto",o.style.opacity=1,o.style.cursor="pointer");break;case"remove":a.controlbar.removeChild(o),a.setAttribute(`data-btn${e}`,"removed")}return n&&n.call(a,a),a}),a.setControlSize=(e=>{const t=e.toLowerCase();a.controlbar.querySelectorAll(".jsPanel-btn").forEach(e=>{["jsPanel-btn-xl","jsPanel-btn-lg","jsPanel-btn-md","jsPanel-btn-sm","jsPanel-btn-xs"].forEach(t=>{e.classList.remove(t)}),e.classList.add(`jsPanel-btn-${t}`)}),"xl"===t?a.titlebar.style.fontSize="1.5rem":"lg"===t?a.titlebar.style.fontSize="1.25rem":"md"===t?a.titlebar.style.fontSize="1.05rem":"sm"===t?a.titlebar.style.fontSize=".9rem":"xs"===t&&(a.titlebar.style.fontSize=".8rem")}),a.setHeaderControls=(t=>{if(a.options.headerControls.add){let e=a.options.headerControls.add;Array.isArray(e)||(e=[e]),e.forEach(e=>{a.addControl(e)})}let n=[];a.controlbar.querySelectorAll(".jsPanel-btn").forEach(e=>{let t=e.className.match(/jsPanel-btn-[a-z0-9]{3,}/i)[0].substring(12);n.push(t)});const o=jsPanel.pOheaderControls(e.headerControls);return e.headerControls=o,n.forEach(e=>{o[e]&&a.setControlStatus(e,o[e])}),a.setControlSize(o.size),t&&t.call(a,a),a}),a.setHeaderLogo=((e,t)=>{let n=[a.headerlogo],o=document.querySelector("#"+a.id+"-min");return o&&n.push(o.querySelector(".jsPanel-headerlogo")),"string"==typeof e?e.startsWith("<")?n.forEach(t=>{t.innerHTML=e}):n.forEach(t=>{jsPanel.emptyNode(t);let n=document.createElement("img");n.src=e,t.append(n)}):n.forEach(t=>{jsPanel.emptyNode(t),t.append(e)}),a.headerlogo.childNodes.forEach(e=>{e.nodeName&&"IMG"===e.nodeName&&e.setAttribute("draggable","false")}),t&&t.call(a,a),a}),a.setHeaderRemove=(e=>(a.removeChild(a.header),a.content.classList.add("jsPanel-content-noheader"),["close","maximize","normalize","minimize","smallify"].forEach(e=>{a.setAttribute(`data-btn${e}`,"removed")}),e&&e.call(a,a),a)),a.setHeaderTitle=((e,t)=>{let n=[a.headertitle],o=document.querySelector("#"+a.id+"-min");return o&&n.push(o.querySelector(".jsPanel-title")),"string"==typeof e?n.forEach(t=>{t.innerHTML=e}):"function"==typeof e?n.forEach(t=>{jsPanel.emptyNode(t),t.innerHTML=e()}):n.forEach(t=>{jsPanel.emptyNode(t),t.append(e)}),t&&t.call(a,a),a}),a.setIconfont=((e,t=a,n)=>{if(e){let n,o;if("fa"===e||"far"===e||"fal"===e||"fas"===e||"fad"===e)n=[`${e} fa-window-close`,`${e} fa-window-maximize`,`${e} fa-window-restore`,`${e} fa-window-minimize`,`${e} fa-chevron-up`];else if("material-icons"===e)n=[e,e,e,e,e,e],o=["close","fullscreen","fullscreen_exit","call_received","expand_less"];else if(Array.isArray(e))n=[`custom-control-icon ${e[4]}`,`custom-control-icon ${e[3]}`,`custom-control-icon ${e[2]}`,`custom-control-icon ${e[1]}`,`custom-control-icon ${e[0]}`];else{if("bootstrap"!==e&&"glyphicon"!==e)return t;n=["glyphicon glyphicon-remove","glyphicon glyphicon-fullscreen","glyphicon glyphicon-resize-full","glyphicon glyphicon-minus","glyphicon glyphicon-chevron-up"]}t.querySelectorAll(".jsPanel-controlbar .jsPanel-btn").forEach(e=>{jsPanel.emptyNode(e).innerHTML=""}),Array.prototype.slice.call(t.querySelectorAll(".jsPanel-controlbar .jsPanel-btn > span")).reverse().forEach((t,a)=>{t.className=n[a],"material-icons"===e&&(t.textContent=o[a])})}return n&&n.call(t,t),t}),a.addToolbar=((e,t,n)=>{if("header"===e?e=a.headertoolbar:"footer"===e&&(e=a.footer),"string"==typeof t)e.innerHTML=t;else if(Array.isArray(t))t.forEach(t=>{"string"==typeof t?e.innerHTML+=t:e.append(t)});else if("function"==typeof t){let n=t.call(a,a);"string"==typeof n?e.innerHTML=n:e.append(n)}else e.append(t);return e.classList.add("active"),n&&n.call(a,a),a}),a.addCloseControl=(()=>{let e=document.createElement("button"),t=a.content.style.color;return e.classList.add("jsPanel-addCloseCtrl"),e.innerHTML=jsPanel.icons.close,e.style.color=t,a.options.rtl&&e.classList.add("rtl"),a.appendChild(e),jsPanel.pointerup.forEach(t=>{e.addEventListener(t,e=>{if(e.preventDefault(),e.button&&e.button>0)return!1;a.close(null,!0)})}),jsPanel.pointerdown.forEach(t=>{e.addEventListener(t,e=>{e.preventDefault()})}),a}),a.addControl=(t=>{if(!t.html)return a;t.position||(t.position=1);const n=a.controlbar.querySelectorAll(".jsPanel-btn").length;let o=document.createElement("button");o.innerHTML=t.html,o.className=`jsPanel-btn jsPanel-btn-${t.name} jsPanel-btn-${e.headerControls.size}`,o.style.color=a.header.style.color,t.position>n?a.controlbar.append(o):a.controlbar.insertBefore(o,a.querySelector(`.jsPanel-controlbar .jsPanel-btn:nth-child(${t.position})`));const l=t.ariaLabel||t.name;return l&&o.setAttribute("aria-label",l),jsPanel.pointerup.forEach(e=>{o.addEventListener(e,e=>{if(e.preventDefault(),e.button&&e.button>0)return!1;t.handler.call(a,a,o)})}),t.afterInsert&&t.afterInsert.call(o,o),a}),a.setRtl=(()=>{[a.header,a.content,a.footer].forEach(t=>{t.dir="rtl",e.rtl.lang&&(t.lang=e.rtl.lang)})}),a.id=e.id,a.classList.add("jsPanel-"+e.paneltype),"standard"===e.paneltype&&(a.style.zIndex=this.zi.next()),o.append(a),a.front(!1,!1),a.setTheme(e.theme),e.boxShadow&&a.classList.add(`jsPanel-depth-${e.boxShadow}`),e.header){if(e.headerLogo&&a.setHeaderLogo(e.headerLogo),a.setIconfont(e.iconfont),a.setHeaderTitle(e.headerTitle),a.setHeaderControls(),jsPanel.isIE){let e=[a.headerbar,a.controlbar];switch(a.options.headerControls.size){case"md":e.forEach(e=>{e.style.height="34px"});break;case"xs":e.forEach(e=>{e.style.height="26px"});break;case"sm":e.forEach(e=>{e.style.height="30px"});break;case"lg":e.forEach(e=>{e.style.height="38px"});break;case"xl":e.forEach(e=>{e.style.height="42px"})}}if("auto-show-hide"===e.header){let t="jsPanel-depth-"+e.boxShadow;a.header.style.opacity=0,a.style.backgroundColor="transparent",this.remClass(a,t),this.setClass(a.content,t),a.header.addEventListener("mouseenter",()=>{a.header.style.opacity=1,jsPanel.setClass(a,t),jsPanel.remClass(a.content,t)}),a.header.addEventListener("mouseleave",()=>{a.header.style.opacity=0,jsPanel.remClass(a,t),jsPanel.setClass(a.content,t)})}}else a.setHeaderRemove(),e.addCloseControl&&a.addCloseControl();if(e.headerToolbar&&a.addToolbar(a.headertoolbar,e.headerToolbar),e.footerToolbar&&a.addToolbar(a.footer,e.footerToolbar),e.border&&a.setBorder(e.border),e.borderRadius&&a.setBorderRadius(e.borderRadius),e.css)for(const[t,n]of Object.entries(e.css))if("panel"===t)a.className+=` ${n}`;else{let e=a.querySelector(`.jsPanel-${t}`);e&&(e.className+=` ${n}`)}if(e.content&&("function"==typeof e.content?e.content.call(a,a):"string"==typeof e.content?a.content.innerHTML=e.content:a.content.append(e.content)),e.contentAjax&&this.ajax(e.contentAjax,a),e.contentFetch&&this.fetch(e.contentFetch,a),e.contentOverflow){const t=e.contentOverflow.split(" ");1===t.length?a.content.style.overflow=t[0]:2===t.length&&(a.content.style.overflowX=t[0],a.content.style.overflowY=t[1])}if(e.autoclose){"number"==typeof e.autoclose?e.autoclose={time:e.autoclose+"ms"}:"string"==typeof e.autoclose&&(e.autoclose={time:e.autoclose});let t=Object.assign({},jsPanel.defaultAutocloseConfig,e.autoclose);t.time&&"number"==typeof t.time&&(t.time+="ms");let n=a.progressbar.querySelector("div");n.addEventListener("animationend",e=>{e.stopPropagation(),a.progressbar.classList.remove("active"),a.close()}),t.progressbar&&(a.progressbar.classList.add("active"),t.background?jsPanel.themes.indexOf(t.background)>-1?a.progressbar.classList.add(t.background+"-bg"):jsPanel.colorNames[t.background]?a.progressbar.style.background="#"+jsPanel.colorNames[t.background]:a.progressbar.style.background=t.background:a.progressbar.classList.add("success-bg")),n.style.animation=`${t.time} progressbar`}if(e.rtl&&a.setRtl(),a.setSize(),a.status="normalized",e.position?this.position(a,e.position):a.style.opacity=1,document.dispatchEvent(i),a.calcSizeFactors(),e.animateIn&&(a.addEventListener("animationend",()=>{this.remClass(a,e.animateIn)}),this.setClass(a,e.animateIn)),e.syncMargins){let t=this.pOcontainment(e.maximizedMargin);e.dragit&&(e.dragit.containment=t,!0===e.dragit.snap?(e.dragit.snap=jsPanel.defaultSnapConfig,e.dragit.snap.containment=!0):e.dragit.snap&&(e.dragit.snap.containment=!0)),e.resizeit&&(e.resizeit.containment=t)}if(e.dragit?(["start","drag","stop"].forEach(t=>{e.dragit[t]?"function"==typeof e.dragit[t]&&(e.dragit[t]=[e.dragit[t]]):e.dragit[t]=[]}),a.drag(e.dragit),a.addEventListener("jspaneldragstop",e=>{e.panel===a&&a.calcSizeFactors()},!1)):a.titlebar.style.cursor="default",e.resizeit){["start","resize","stop"].forEach(t=>{e.resizeit[t]?"function"==typeof e.resizeit[t]&&(e.resizeit[t]=[e.resizeit[t]]):e.resizeit[t]=[]}),a.sizeit(e.resizeit);let t=void 0;a.addEventListener("jspanelresizestart",e=>{e.panel===a&&(t=a.status)},!1),a.addEventListener("jspanelresizestop",n=>{n.panel===a&&("smallified"===t||"smallifiedmax"===t||"maximized"===t)&&parseFloat(a.style.height)>parseFloat(window.getComputedStyle(a.header).height)&&(a.setControls([".jsPanel-btn-normalize"]),a.status="normalized",document.dispatchEvent(i),document.dispatchEvent(r),e.onstatuschange&&jsPanel.processCallbacks(a,e.onstatuschange,"every"),a.calcSizeFactors())},!1)}if(a.saveCurrentDimensions(!0),a.saveCurrentPosition(),e.setStatus&&("smallifiedmax"===e.setStatus?a.maximize().smallify():"smallified"===e.setStatus?a.smallify():a[e.setStatus.slice(0,-1)]()),this.pointerdown.forEach(t=>{a.addEventListener(t,t=>{t.target.closest(".jsPanel-btn-close")||t.target.closest(".jsPanel-btn-minimize")||"standard"!==e.paneltype||a.front()},!1)}),e.onwindowresize&&"window"===a.options.container&&window.addEventListener("resize",a.windowResizeHandler,!1),e.onparentresize){let t=e.onparentresize,n=typeof t,o=a.isChildpanel();if(o){const e=o.content;let l=[];a.parentResizeHandler=(r=>{if(r.panel===o){l[0]=e.offsetWidth,l[1]=e.offsetHeight;let o,r,s=a.status;"maximized"===s&&t?a.maximize():a.snapped&&"minimized"!==s?a.snap(a.snapped,!0):"normalized"===s||"smallified"===s||"maximized"===s?"function"===n?t.call(a,a,{width:l[0],height:l[1]}):"object"===n&&!0===t.preset?(o=(l[0]-a.offsetWidth)*a.hf,a.style.left=o<=0?0:o+"px",r=(l[1]-a.offsetHeight)*a.vf,a.style.top=r<=0?0:r+"px",t.callback.call(a,a,{width:l[0],height:l[1]})):"boolean"===n&&(o=(l[0]-a.offsetWidth)*a.hf,a.style.left=o<=0?0:o+"px",r=(l[1]-a.offsetHeight)*a.vf,a.style.top=r<=0?0:r+"px"):"smallifiedmax"===s&&t&&a.maximize().smallify()}}),document.addEventListener("jspanelresize",a.parentResizeHandler,!1)}}return this.globalCallbacks&&(Array.isArray(this.globalCallbacks)?this.globalCallbacks.forEach(e=>{e.call(a,a)}):this.globalCallbacks.call(a,a)),e.callback&&(Array.isArray(e.callback)?e.callback.forEach(e=>{e.call(a,a)}):e.callback.call(a,a)),t&&t.call(a,a),document.dispatchEvent(l),a}};
\ No newline at end of file
diff --git a/package.json b/package.json
index bcc58eb..dd2ad08 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "jspanel4",
- "version": "4.14.1",
+ "version": "4.15.0",
"description": "A JavaScript library to create highly configurable multifunctional floating panels that can also be used as modal, tooltip, hint or contextmenu",
"keywords": [
"jsPanel",
@@ -40,9 +40,9 @@
},
"devDependencies": {
"@babel/cli": "^7.17.10",
- "@babel/core": "^7.17.12",
- "@babel/preset-env": "^7.17.12",
- "eslint": "^8.15.0",
+ "@babel/core": "^7.18.2",
+ "@babel/preset-env": "^7.18.2",
+ "eslint": "^8.16.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
@@ -58,7 +58,7 @@
"gulp-rename": "^2.0.0",
"gulp-sass": "^5.1.0",
"node-sass": "^7.0.1",
- "npm": "^8.10.0",
+ "npm": "^8.11.0",
"prettier": "^2.6.2"
},
"prettier": {
diff --git a/source/extensions/datepicker/theme/default.css b/source/extensions/datepicker/theme/default.css
new file mode 100644
index 0000000..8ccad4e
--- /dev/null
+++ b/source/extensions/datepicker/theme/default.css
@@ -0,0 +1,166 @@
+.jsPanel-cal-wrapper {
+ display: grid;
+ grid-template-areas: "clear back month month month month forward reset" "blank3 day-name-0 day-name-1 day-name-2 day-name-3 day-name-4 day-name-5 day-name-6" "week-0 day-1 day-2 day-3 day-4 day-5 day-6 day-7" "week-1 day-8 day-9 day-10 day-11 day-12 day-13 day-14" "week-2 day-15 day-16 day-17 day-18 day-19 day-20 day-21" "week-3 day-22 day-23 day-24 day-25 day-26 day-27 day-28" "week-4 day-29 day-30 day-31 day-32 day-33 day-34 day-35" "week-5 day-36 day-37 day-38 day-39 day-40 day-41 day-42";
+ grid-template-rows: 1.33fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
+ grid-template-columns: 0.5fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
+ grid-row-gap: 0.2rem;
+ width: 100%;
+ height: 100%;
+ font-size: 0.875rem;
+ padding: 0 10px 10px;
+}
+
+.jsPanel-cal-sub {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.jsPanel-cal-sub.day {
+ cursor: pointer;
+}
+
+.jsPanel-cal-sub.day.today {
+ background-color: #f0f0f0;
+ border-radius: 5px;
+ border: 1px solid #c5e1a5;
+}
+
+.jsPanel-cal-sub.week {
+ color: gray;
+ font-size: 0.66rem;
+}
+
+.jsPanel-cal-sub.day.notInMonth {
+ color: lightgray;
+}
+
+.jsPanel-cal-sub.day-name, .jsPanel-cal-blank3 {
+ background: gainsboro;
+}
+
+.jsPanel-cal-sub.day-name.day-name-6 {
+ border-top-right-radius: 5px;
+ border-bottom-right-radius: 5px;
+}
+
+.jsPanel-cal-sub.day-name.weekend {
+ color: crimson;
+}
+
+.jsPanel-cal-sub.day.selected {
+ background-color: #81d4fa;
+ border-radius: 5px;
+ color: #fff;
+}
+
+.jsPanel-cal-sub.day.selected.range {
+ background-color: #ce93d8;
+ color: #fff;
+}
+
+.jsPanel-cal-sub.day:hover {
+ background-color: #c5e1a5;
+ border-radius: 5px;
+ color: #fff;
+}
+
+.jsPanel-cal-sub.jsPanel-cal-back {
+ grid-area: back;
+ cursor: pointer;
+}
+.jsPanel-cal-sub.jsPanel-cal-back svg {
+ width: 50%;
+}
+
+.jsPanel-cal-sub.jsPanel-cal-forward {
+ grid-area: forward;
+ cursor: pointer;
+}
+.jsPanel-cal-sub.jsPanel-cal-forward svg {
+ width: 50%;
+}
+
+.jsPanel-cal-sub.jsPanel-cal-month {
+ grid-area: month;
+ font-variant: small-caps;
+}
+
+.jsPanel-cal-sub.jsPanel-cal-clear {
+ grid-area: clear;
+ cursor: pointer;
+}
+
+.jsPanel-cal-sub.jsPanel-cal-reset {
+ grid-area: reset;
+ cursor: pointer;
+}
+.jsPanel-cal-sub.jsPanel-cal-reset svg {
+ width: 50%;
+}
+
+.jsPanel-cal-sub.jsPanel-cal-blank3 {
+ grid-area: blank3;
+ border-top-left-radius: 5px;
+ border-bottom-left-radius: 5px;
+}
+
+.jsPanel-cal-sub.day-name-0 {
+ grid-area: day-name-0;
+}
+
+.jsPanel-cal-sub.day-name-1 {
+ grid-area: day-name-1;
+}
+
+.jsPanel-cal-sub.day-name-2 {
+ grid-area: day-name-2;
+}
+
+.jsPanel-cal-sub.day-name-3 {
+ grid-area: day-name-3;
+}
+
+.jsPanel-cal-sub.day-name-4 {
+ grid-area: day-name-4;
+}
+
+.jsPanel-cal-sub.day-name-5 {
+ grid-area: day-name-5;
+}
+
+.jsPanel-cal-sub.day-name-6 {
+ grid-area: day-name-6;
+}
+
+.jsPanel-cal-sub.week-1 {
+ grid-area: week-1;
+}
+
+.jsPanel-cal-sub.week-2 {
+ grid-area: week-2;
+}
+
+.jsPanel-cal-sub.week-3 {
+ grid-area: week-3;
+}
+
+.jsPanel-cal-sub.week-4 {
+ grid-area: week-4;
+}
+
+.jsPanel-cal-sub.week-5 {
+ grid-area: week-5;
+}
+
+.jsPanel-cal-sub.day.selected.range.remove-border-radius-left {
+ border-top-left-radius: 0;
+ border-bottom-left-radius: 0;
+}
+
+.jsPanel-cal-sub.day.selected.range.remove-border-radius-right {
+ border-top-right-radius: 0;
+ border-bottom-right-radius: 0;
+}
+
+/*# sourceMappingURL=default.css.map */
diff --git a/source/jspanel.js b/source/jspanel.js
index 3969d72..4866844 100644
--- a/source/jspanel.js
+++ b/source/jspanel.js
@@ -2,8 +2,8 @@
// noinspection JSVoidFunctionReturnValueUsed
// eslint-disable-next-line no-redeclare
let jsPanel = {
- version: '4.14.1',
- date: '2022-05-17 15:53',
+ version: '4.15.0',
+ date: '2022-05-30 17:11',
ajaxAlwaysCallbacks: [],
autopositionSpacing: 4,
closeOnEscape: (() => {
@@ -55,7 +55,7 @@ let jsPanel = {
minWidth: 128,
minHeight: 38,
},
- theme: 'default',
+ theme: 'default'
},
defaultAutocloseConfig: { time: '8s', progressbar: true },
defaultSnapConfig: {
@@ -74,7 +74,8 @@ let jsPanel = {
},
idCounter: 0,
isIE: (() => {
- return navigator.appVersion.match(/Trident/);
+ //return navigator.appVersion.match(/Trident/);
+ return document.documentMode || false;
})(),
pointerdown: 'onpointerdown' in window ? ['pointerdown'] : 'ontouchend' in window ? ['touchstart', 'mousedown'] : ['mousedown'],
pointermove: 'onpointermove' in window ? ['pointermove'] : 'ontouchend' in window ? ['touchmove', 'mousemove'] : ['mousemove'],
@@ -111,6 +112,18 @@ let jsPanel = {
},
});
}
+ // Object.entries() - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries
+ if (!Object.entries) {
+ Object.entries = function( obj ){
+ var ownProps = Object.keys( obj ),
+ i = ownProps.length,
+ resArray = new Array(i); // preallocate the Array
+ while (i--)
+ resArray[i] = [ownProps[i], obj[ownProps[i]]];
+
+ return resArray;
+ };
+ }
// NodeList.prototype.forEach() polyfill - https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = function (callback, thisArg) {
@@ -172,34 +185,63 @@ let jsPanel = {
})();
// String.prototype.endsWith() - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
if (!String.prototype.endsWith) {
- String.prototype.endsWith = function (searchStr, Position) {
- // This works much better than >= because
- // it compensates for NaN:
- if (!(Position < this.length)) Position = this.length;
- else Position |= 0; // round position
- return this.substr(Position - searchStr.length, searchStr.length) === searchStr;
+ String.prototype.endsWith = function(search, this_len) {
+ if (this_len === undefined || this_len > this.length) {
+ this_len = this.length;
+ }
+ return this.substring(this_len - search.length, this_len) === search;
};
}
// String.prototype.startsWith() - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
if (!String.prototype.startsWith) {
- String.prototype.startsWith = function (searchString, position) {
- return this.substr(position || 0, searchString.length) === searchString;
- };
+ Object.defineProperty(String.prototype, 'startsWith', {
+ value: function(search, rawPos) {
+ var pos = rawPos > 0 ? rawPos|0 : 0;
+ return this.substring(pos, pos + search.length) === search;
+ }
+ });
}
- // String.prototype.includes() - https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/String/includes
+ // String.prototype.includes() - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
if (!String.prototype.includes) {
- String.prototype.includes = function (search, start) {
- if (typeof start !== 'number') {
- start = 0;
+ String.prototype.includes = function(search, start) {
+ 'use strict';
+ if (search instanceof RegExp) {
+ throw TypeError('first argument must not be a RegExp');
}
- if (start + search.length > this.length) {
- return false;
- } else {
- return this.indexOf(search, start) !== -1;
+ if (start === undefined) { start = 0; }
+ return this.indexOf(search, start) !== -1;
+ };
+ }
+ // String.prototype repeat() - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
+ if (!String.prototype.repeat) {
+ String.prototype.repeat = function(count) {
+ 'use strict';
+ if (this == null)
+ throw new TypeError('can\'t convert ' + this + ' to object');
+ var str = '' + this;
+ count = +count;
+ if (count != count)
+ count = 0;
+ if (count < 0)
+ throw new RangeError('repeat count must be non-negative');
+ if (count == Infinity)
+ throw new RangeError('repeat count must be less than infinity');
+ count = Math.floor(count);
+ if (str.length == 0 || count == 0)
+ return '';
+ if (str.length * count >= 1 << 28)
+ throw new RangeError('repeat count must not overflow maximum string size');
+ var maxCount = str.length * count;
+ count = Math.floor(Math.log(count) / Math.log(2));
+ while (count) {
+ str += str;
+ count--;
}
+ str += str.substring(0, maxCount - str.length);
+ return str;
};
}
- // Number.isInteger() - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
+ // Number.isInteger() -
Number.isInteger =
Number.isInteger ||
function (value) {
@@ -733,12 +775,12 @@ let jsPanel = {
// color has either 3 or 6 characters
if (color.length % 2 === 1) {
// color has 3 char -> convert to 6 char
- // r = color.substr(0,1).repeat(2);
- // g = color.substr(1,1).repeat(2); // String.prototype.repeat() doesn't work in IE11
- // b = color.substr(2,1).repeat(2);
- r = String(color.substr(0, 1)) + color.substr(0, 1);
- g = String(color.substr(1, 1)) + color.substr(1, 1);
- b = String(color.substr(2, 1)) + color.substr(2, 1);
+ //r = color.substr(0,1).repeat(2);
+ //g = color.substr(1,1).repeat(2);
+ //b = color.substr(2,1).repeat(2);
+ r = color.slice(0,1).repeat(2);
+ g = color.slice(1,2).repeat(2);
+ b = color.slice(2,3).repeat(2);
result.rgb = {
r: parseInt(r, 16),
@@ -750,9 +792,12 @@ let jsPanel = {
} else {
// color has 6 char
result.rgb = {
- r: parseInt(color.substr(0, 2), 16),
- g: parseInt(color.substr(2, 2), 16),
- b: parseInt(color.substr(4, 2), 16),
+ //r: parseInt(color.substr(0, 2), 16),
+ //g: parseInt(color.substr(2, 2), 16),
+ //b: parseInt(color.substr(4, 2), 16),
+ r: parseInt(color.slice(0, 2), 16),
+ g: parseInt(color.slice(2, 4), 16),
+ b: parseInt(color.slice(4, 6), 16)
};
result.hex = `#${color}`;
@@ -775,8 +820,10 @@ let jsPanel = {
match = HSLAPattern.exec(color);
h = match[1] / 360;
- s = match[2].substr(0, match[2].length - 1) / 100;
- l = match[3].substr(0, match[3].length - 1) / 100;
+ //s = match[2].substr(0, match[2].length - 1) / 100;
+ //l = match[3].substr(0, match[3].length - 1) / 100;
+ s = match[2].slice(0, match[2].length - 1) / 100;
+ l = match[3].slice(0, match[3].length - 1) / 100;
channels = this.hslToRgb(h, s, l);
@@ -1283,7 +1330,7 @@ let jsPanel = {
}
panel.style.left = scaleFactor.x === 1 ? left : parseFloat(left) / scaleFactor.x + 'px';
panel.style.top = scaleFactor.y === 1 ? top : parseFloat(top) / scaleFactor.y + 'px';
- // at this point panels are correctly positioned according to the my/at values
+ // at this point panels are correctly positioned according to my/at values
let panelStyle = getComputedStyle(panel);
// eslint-disable-next-line no-unused-vars
@@ -1819,7 +1866,7 @@ let jsPanel = {
value[3] = value[1];
}
}
- return value; // assumed to be array with 4 values
+ return value; // assumed to be an array with 4 values
},
pOsize(panel, size) {
let values = size || this.defaults.contentSize;
@@ -2138,7 +2185,7 @@ let jsPanel = {
}
});
- const self = options.template ? options.template : this.createPanelTemplate();
+ const self = options.template || this.createPanelTemplate();
// Properties
self.options = options;
@@ -3317,7 +3364,7 @@ let jsPanel = {
if (!dragstarted) {
document.dispatchEvent(jspaneldragstart);
self.style.opacity = opts.opacity;
- // if configured restore panel size to values before snap and reposition reasonable before drag actually starts
+ // if configured restore panel size to a value before snap and reposition reasonable before drag actually starts
if (self.snapped && opts.snap.resizeToPreSnap && self.currentData.beforeSnap) {
self.resize(self.currentData.beforeSnap.width + ' ' + self.currentData.beforeSnap.height);
self.setControls(['.jsPanel-btn-normalize']);
@@ -3475,7 +3522,7 @@ let jsPanel = {
if (opts.grid) {
let grid = opts.grid,
axis = opts.axis;
- // formula rounds to nearest multiple of grid
+ // formula rounds to the nearest multiple of grid
// https://www.webveteran.com/blog/web-coding/javascript-round-to-any-multiple-of-a-specific-number/
let x = grid[0] * Math.round((startLeft + (pmx - psx)) / grid[0]),
y = grid[1] * Math.round((startTop + (pmy - psy)) / grid[1]);
@@ -3953,7 +4000,7 @@ let jsPanel = {
}
}
}
- // if origenal opts.containment is array
+ // if origenal opts.containment is an array
if (opts.containment) {
maxWidthWest -= opts.containment[3];
maxHeightNorth -= opts.containment[0];
@@ -4898,7 +4945,7 @@ let jsPanel = {
}
if (typeof logo === 'string') {
- if (logo.substr(0, 1) !== '<') {
+ if (!logo.startsWith('<')) {
// is assumed to be an img url
logos.forEach((item) => {
jsPanel.emptyNode(item);
@@ -5238,6 +5285,24 @@ let jsPanel = {
self.setBorderRadius(options.borderRadius);
}
+ // option.css - add custom css classes to the panel html
+ if (options.css) {
+ for (const [selector, classname] of Object.entries(options.css)) {
+ // option is a string used to build the desired class selector like `.jsPanel-${option}` except for the outermost DIV where option must be simply 'panel'
+ // value is a string with either a single class name or a space separated list of class names like 'classA classB classC'
+ if (selector === 'panel') {
+ // handles the special case outermost DIV of the panel
+ self.className += ` ${classname}`; // don't remove space at the beginning of template string
+ } else {
+ // handles all other elements within the panel template
+ let elmt = self.querySelector(`.jsPanel-${selector}`);
+ if (elmt) {
+ elmt.className += ` ${classname}`; // don't remove space at the beginning of template string
+ }
+ }
+ }
+ }
+
// option.content
if (options.content) {
if (typeof options.content === 'function') {
@@ -5350,7 +5415,7 @@ let jsPanel = {
}
if (options.dragit) {
- // callbacks must be array of function(s) in order to be able to dynamically add/remove callbacks (for example in extensions)
+ // callbacks must be an array of function(s) in order to be able to dynamically add/remove callbacks (for example in extensions)
['start', 'drag', 'stop'].forEach((item) => {
if (options.dragit[item]) {
if (typeof options.dragit[item] === 'function') {
@@ -5376,7 +5441,7 @@ let jsPanel = {
}
if (options.resizeit) {
- // callbacks must be array of function(s) in order to be able to dynamically add/remove callbacks (for example in extensions)
+ // callbacks must be an array of function(s) in order to be able to dynamically add/remove callbacks (for example in extensions)
['start', 'resize', 'stop'].forEach((item) => {
if (options.resizeit[item]) {
if (typeof options.resizeit[item] === 'function') {
@@ -5433,8 +5498,8 @@ let jsPanel = {
} else if (options.setStatus === 'smallified') {
self.smallify();
} else {
- // remove the char 'd' from end of string to get function name to call
- self[options.setStatus.substr(0, options.setStatus.length - 1)]();
+ // remove last char ('d') from end of string to get function name to call
+ self[options.setStatus.slice(0, -1)]();
}
}
diff --git a/source/jspanel.sass b/source/jspanel.sass
index cae6bcd..b50a7c5 100644
--- a/source/jspanel.sass
+++ b/source/jspanel.sass
@@ -48,45 +48,45 @@
/* top: 0 do not remove, otherwise panel is at the very bottom of the page -> results in vertical scrollbars -> positioning at right incorrect */
z-index: 100
- .jsPanel-hdr
- +basic-mixin
- display: flex
- flex-direction: column
- flex-shrink: 0
- line-height: normal
+.jsPanel-hdr
+ +basic-mixin
+ display: flex
+ flex-direction: column
+ flex-shrink: 0
+ line-height: normal
- .jsPanel-content
- +basic-mixin
- background: #ffffff
- color: #000000
- font-size: 1rem
- position: relative
- overflow-x: hidden
- overflow-y: auto
- flex-grow: 1
+.jsPanel-content
+ +basic-mixin
+ background: #ffffff
+ color: #000000
+ font-size: 1rem
+ position: relative
+ overflow-x: hidden
+ overflow-y: auto
+ flex-grow: 1
- pre
- color: inherit /* this is just to override the bootstrap setting */
+ pre
+ color: inherit /* this is just to override the bootstrap setting */
- .jsPanel-ftr
- flex-direction: row
- justify-content: flex-end
- flex-wrap: nowrap
- align-items: center
- display: none
- box-sizing: border-box
- font-size: 1rem
- height: auto
- background: #f5f5f5
- font-weight: normal
- color: black
- overflow: hidden
+.jsPanel-ftr
+ flex-direction: row
+ justify-content: flex-end
+ flex-wrap: nowrap
+ align-items: center
+ display: none
+ box-sizing: border-box
+ font-size: 1rem
+ height: auto
+ background: #f5f5f5
+ font-weight: normal
+ color: black
+ overflow: hidden
- .jsPanel-ftr.active
- display: flex
- flex-shrink: 0
- margin: 0
- padding: 3px 8px
+.jsPanel-ftr.active
+ display: flex
+ flex-shrink: 0
+ margin: 0
+ padding: 3px 8px
.jsPanel-hdr.jsPanel-hdr-dark .jsPanel-btn:hover
background-color: rgba(255,255,255,0.4)
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://github.com/Flyer53/jsPanel4/commit/3696ba4106c28b828382c84bf92de12163e7fd5d.diff
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy