jizy-dom 2.1.9 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/jizy-dom.min.js +2 -2
- package/lib/index.js +2 -0
- package/lib/js/jdom.js +44 -0
- package/lib/js/plugins/accordion.js +72 -0
- package/lib/js/plugins/blockFitWidth.js +27 -0
- package/lib/js/plugins/checkboxMaxSelection.js +43 -0
- package/lib/js/plugins/confirm.js +26 -0
- package/lib/js/plugins/hasher.js +30 -0
- package/lib/js/plugins/hrefData.js +23 -0
- package/lib/js/plugins/limitLinkText.js +30 -0
- package/lib/js/plugins/linker.js +22 -0
- package/lib/js/plugins/newWindowLink.js +35 -0
- package/lib/js/plugins/picviewer.js +55 -0
- package/lib/js/plugins/tableResponsive.js +19 -0
- package/lib/js/plugins/toggler.js +21 -0
- package/lib/js/plugins/userDropzone.js +48 -0
- package/package.json +5 -5
package/dist/js/jizy-dom.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! DOM v2.1
|
|
2
|
-
!function(e){"use strict";if("object"!=typeof e||!e||!e.document)throw new Error("DOM requires a window with a document");if(void 0!==e.DOM)throw new Error("DOM is already defined");var t=function(){const e="compareDocumentPosition"in document.documentElement?function(e,t){return!(16&~t.compareDocumentPosition(e))}:function(e,t){return(t=t==document||t==window?document.documentElement:t)!==e&&t.contains(e)};function t(e){return[].slice.call(e,0)}function s(e){let t;return e&&"object"==typeof e&&(t=e.nodeType)&&(1==t||9==t)}function n(e){return"object"==typeof e&&isFinite(e.length)}function i(r,l){const a=function(e){return e?"string"==typeof e?i(e)[0]:!e.nodeType&&n(e)?e[0]:e:document}(l);let o;return a&&r?r===window||s(r)?!l||r!==window&&s(a)&&e(r,a)?[r]:[]:r&&n(r)?function(e){for(var t=[],s=0,i=e.length;s<i;++s)n(e[s])?t=t.concat(e[s]):t[t.length]=e[s];return t}(r):document.getElementsByClassName&&"string"==r&&(o=r.match(/^\.([\w\-]+)$/))?t(a.getElementsByClassName(o[1])):r&&(r.document||r.nodeType&&9==r.nodeType)?l?[]:[r]:t(a.querySelectorAll(r)):[]}function r(...e){let t=!1,s=0,n={};"boolean"==typeof e[0]&&(t=e[0],s=1);const i=e=>e&&"[object Object]"===Object.prototype.toString.call(e),l=e=>{for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t&&i(e[s])?n[s]=r(!0,n[s]||{},e[s]):void 0!==e[s]&&(n[s]=e[s]))};for(;s<e.length;s++)e[s]&&l(e[s]);return n}const l=/^(?:(width|height|top|right|bottom|left|margin|padding)|((min|max)(Width|Height))|((margin|padding)(Top|Right|Bottom|Left)))$/,a={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},o={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},c=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch(e){}return e})();function h(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function u(e){return e.replace(/-([a-z])/g,e=>e[1].toUpperCase())}function d(e,t){return!!(t&&e&&1===e.nodeType&&e.matches(t))}function m(e,t){return null==t?new E(e):new E(e).filter(t)}function p(e,t,s){null==s?e.removeAttribute(t):e.setAttribute(t,s)}function f(e){if(e.data("cssInitialDisplay"))return e.data("cssInitialDisplay");if(e.css("display")&&"none"!==e.css("display"))return e.css("display");switch(e.tagName.toLowerCase()){case"table":return"table";case"thead":return"table-header-group";case"tfoot":return"table-footer-group";case"tr":return"table-row";case"th":case"td":return"table-cell";case"span":return"inline";case"li":return"list-item"}return"block"}function g(e,t){for(var s in t)if(!0===e.classList.contains(t[s]))return!0;return!1}function y(e,t){for(var s in t)if(!1===e.classList.contains(t[s]))return!1;return!0}function w(e,t,s,n){return 2 in arguments?null===s?void e.style.removeProperty(h(t)):("number"==typeof s&&!a[h(t)]&&l.test(u(t))&&(s+="px"),void(n?e.style.setProperty(h(t),s,"important"):e.style[u(t)]=s)):e.style[u(t)]||getComputedStyle(e,null).getPropertyValue(h(t))}function b(e,t,s){if(1===arguments.length){const t={};for(let s in e.dataset)t[s]=b(e,s);return t}const n="data-"+h(t);if(!(2 in arguments))return null!==(s=e.getAttribute(n))?function(e){try{return e?"true"==e||"false"!=e&&("null"==e?null:+e+""==e?+e:/^[\[\{]/.test(e)?JSON.parse(e):e):e}catch(t){return e}}(s):void 0;if("object"!=typeof s||null===s||Array.isArray(s))p(e,n,s);else for(let n in s)b(e,t+"-"+n,s[n])}function v(e,t,s){const n=s.split(" ");return e.classList[t].apply(e.classList,n)}async function C(e,t){const s=t.slideSpeed,n=t.direction,i=t.easing,r=t.delay,l=void 0===r?0:r,a=t.visibleDisplayValue,o=void 0===a?"block":a,c=e.dataset.domSliderId||(Date.now()*Math.random()).toFixed(0);e.dataset.domSliderId||(e.dataset.domSliderId=c);const h=window.getComputedStyle(e),u="none"===h.getPropertyValue("display"),d=n||(u||e.classList.contains("slider-hidden")?"down":"up"),m=s||(0===s?0:300),p=h.getPropertyValue("box-sizing"),f=parseInt(h.getPropertyValue("padding-top").split("px")[0]),g=parseInt(h.getPropertyValue("padding-bottom").split("px")[0]);let y=Math.max(e.scrollHeight-f-g,0);return"border-box"===p&&(y=Math.max(e.scrollHeight,0)),e.dataset.sliding?Promise.resolve(e):"down"!==d||u||e.classList.contains("slider-hidden")?"up"===d&&e.classList.contains("slider-hidden")?Promise.resolve(e):(e.dataset.sliding=!0,e.setAttribute("aria-hidden","down"===d?"false":"true"),"down"===d&&u&&(e.classList.add("slider-hidden"),e.style.display=o,y=e.scrollHeight),e.style.height="".concat(y,"px"),e.style.transition="all ".concat(m,"ms ").concat(i||""),e.style.overflow="hidden",await new Promise(t=>{setTimeout(()=>{e.classList.contains("slider-hidden")||setTimeout(()=>{e.style.display="none"},300),e.classList.toggle("slider-hidden"),t()},+l>20?+l:20)}),await new Promise(t=>{setTimeout(()=>{e.style.removeProperty("height"),e.style.removeProperty("transition"),e.style.removeProperty("overflow"),e.removeAttribute("data-sliding"),t(e)},m)})):Promise.resolve(e)}class E{constructor(e,t){if(t=t||document,e instanceof E)return e;if(t instanceof E)return t.find(e);this.elems=i(e,t);for(let e=0;e<this.elems.length;e++){const t=this.elems[e];t.data=function(e,s){return 0===arguments.length?b(t):1===arguments.length?b(t,e):(b(t,e,s),t)},t.css=function(e,s,n){return arguments.length>=2?w(t,e,s,n||!1):w(t,e)},t.addClass=e=>v(t,"add",e),t.removeClass=e=>v(t,"remove",e),t.hasClass=e=>v(t,"contains",e),t.hasClasses=e=>g(t,e),t.hasAllClasses=e=>y(t,e)}return this}toArray(){return this.elems}exists(){return this.elems.length>0}size(){return this.elems.length}each(e){for(let t=0,s=this.elems.length;t<s;t++)e.call(this,this.elems[t],t);return this}map(e){const t=[];for(let s=0,n=this.elems.length;s<n;s++){const n=e.call(this,this.elems[s],s);!1!==n&&t.push(n)}return t}filter(e){if("function"!=typeof e){const t=e;e=e=>!!d(e,t)&&e}const t=[];for(let s=0,n=this.elems.length;s<n;s++){const n=e.call(this,this.elems[s],s);!1!==n&&t.push(n)}return new E(t)}not(e){const t=[];if("function"==typeof e&&void 0!==e.call)this.each(function(s,n){!1===e.call(s,n)&&t.push(s)});else{let s=[];s="string"==typeof e?this.filter(e):new E(e),s instanceof E&&(s=s.elems),this.each(function(e,n){s.indexOf(e)<0&&t.push(e)})}return new E(t)}get(e){const t=(e=e||0)>=0?e:this.elems.length+e;return void 0!==this.elems[t]?new E(this.elems[t]):this}getElement(e){return 0 in this.elems?this.elems[0]:document.createElement(e||"div")}is(e){return e instanceof HTMLElement?e===this.getElement():e instanceof E?e.getElement()===this.getElement():0 in this.elems&&"string"==typeof e&&(":visible"===e?"none"!==this.elems[0].css("display"):":hidden"===e?"none"===this.elems[0].css("display"):d(this.elems[0],e))}find(e){const t=e.trim().split(/,\s*/);let s=[];return this.each(function(e){for(let n=0,r=t.length;n<r;n++){const r=t[n].match(/^>\s*(.+)$/);if(t[n].match(/^\:(first|last)/),r){if(i(r[1],e))for(const t in e.childNodes)d(e.childNodes[t],r[1])&&(s=s.concat(e.childNodes[t]))}else{const r=i(t[n],e);r&&(s=s.concat(r))}}}),new E(s)}insert(e,t){return"before"===t&&(t="beforebegin"),"after"===t&&(t="afterend"),"prepend"===t&&(t="afterbegin"),"append"===t&&(t="beforeend"),this.each(s=>{e instanceof E?e.each(e=>{s.insertAdjacentElement(t,e)}):e instanceof Element?s.insertAdjacentElement(t,e):s.insertAdjacentHTML(t,e)})}before(e){return this.insert(e,"before")}after(e){return this.insert(e,"after")}append(e){return this.insert(e,"append")}prepend(e){return this.insert(e,"prepend")}replaceWith(e){return this.insert(e,"before"),this.remove(),this}remove(){return this.each(e=>e.parentNode.removeChild(e))}parent(e){let t=[];return this.each(e=>{const s=e.parentNode;s&&(t=t.concat(s))}),m(t,e||null)}children(e){let t=[];return this.each(e=>{const s=e.childNodes;s&&(t=t.concat(Array.from(s)))}),m(t,e||null)}closest(e){let t=[];return this.each(s=>{const n=s.closest(e);n&&(t=t.concat(n))}),new E(t)}prev(e){let t=[];return this.each(e=>{const s=e.previousElementSibling;s&&(t=t.concat(s))}),m(t,e||null)}next(e){let t=[];return this.each(e=>{const s=e.nextElementSibling;s&&(t=t.concat(s))}),m(t,e||null)}first(e){let t=[];return this.each(e=>{const s=e.firstElementChild;s&&(t=t.concat(s))}),m(t,e||null)}last(e){let t=[];return this.each(e=>{const s=e.lastElementChild;s&&(t=t.concat(s))}),m(t,e||null)}wrap(e){return this.each(t=>{t.parentNode.insertBefore(e,t),e.appendChild(t)}),this}on(e,t,s){return s=s||!1,e.split(" ").forEach(e=>{this.each(n=>{n.addEventListener(e,t,s)})}),this}delegate(e,t,s,n){return n=n||!1,this.on(e,e=>{new E(e.target).is(t)&&s(...arguments)},n)}off(e,t){return e.split(" ").forEach(e=>{this.each(s=>{s.removeEventListener(e,t)})}),this}submit(){return 0 in this.elems&&this.elems[0]instanceof HTMLFormElement&&this.elems[0].submit(),this}focus(){return 0 in this.elems&&this.elems[0].focus(),this}trigger(e,t,s,n){let i;return arguments.length<4&&(n=!0),arguments.length<3&&(s=!1),arguments.length<2&&(t=null),i=t?new CustomEvent(e,{bubbles:s,cancellable:n,detail:t}):new Event(e,{bubbles:s,cancellable:n}),this.each(e=>{e.dispatchEvent(i)})}swipe(e,t,s){return this.each(n=>{let i,l,a,o,h,u,d,m=e||function(e,t){},p=t||function(e){return!1},f=r({scrolling:!1,threshold:10,restraint:100,allowedTime:300},s||{});return n.addEventListener("touchstart",e=>{if(!1===p(e)){const t=e.changedTouches[0];i="none",l=t.pageX,a=t.pageY,d=(new Date).getTime(),!c&&e.preventDefault()}},c?{passive:!0}:void 0),n.addEventListener("touchmove",e=>{!1===p(e)&&!1===f.scrolling&&!c&&e.preventDefault()},c?{passive:!0}:void 0),n.addEventListener("touchend",e=>{if(!1===p(e)){const t=e.changedTouches[0];o=t.pageX-l,h=t.pageY-a,u=(new Date).getTime()-d,u<=f.allowedTime&&(Math.abs(o)>=f.threshold&&Math.abs(h)<=f.restraint?i=o<0?"left":"right":Math.abs(h)>=f.threshold&&Math.abs(o)<=f.restraint&&(i=h<0?"up":"down")),!c&&e.preventDefault(),m(e,i)}},c?{passive:!0}:void 0),this})}text(e){return 0 in arguments?this.each(t=>{t.innerText=e}):0 in this.elems?this.elems[0].innerText:null}html(e){return 0 in arguments?this.each(t=>{t.innerHTML=e}):0 in this.elems?this.elems[0].innerHTML:null}content(e){return 0 in arguments?this.each(t=>{t.innerContent=e}):0 in this.elems?this.elems[0].innerContent:null}addClass(e){return this.each(t=>{t.addClass(e)})}removeClass(e){return this.each(t=>{t.removeClass(e)})}toggleClass(e){return this.each(t=>{t.classList.toggle(e)})}replaceClass(e,t){return this.each(s=>{s.classList.replace(e,t)})}hasClass(e){return 0 in this.elems&&this.elems[0].classList.contains(e)}hasClasses(e){return 0 in this.elems&&this.elems[0].hasClasses(e)}hasAllClasses(e){return 0 in this.elems&&this.elems[0].hasAllClasses(e)}containsClass(e){if(0 in this.elems)for(var t=this.elems[0].classList,s=0;s<t.length;s++)if(t[s].indexOf(e)>-1)return!0;return!1}toggle(){return this.each(e=>{const t=f(e);e.data("cssInitialDisplay")||e.data("cssInitialDisplay",t),"none"===e.css("display")?e.style.display="block":e.style.display="none"})}show(){return this.each(e=>{const t=f(e);e.data("cssInitialDisplay")||e.data("cssInitialDisplay",t),e.style.display=t})}hide(){return this.each(e=>{e.data("cssInitialDisplay")||e.data("cssInitialDisplay",f(e)),e.style.display="none"})}offset(){if(0===this.elems.length)return{top:0,left:0};const e=this.elems[0].getBoundingClientRect();return{top:e.top+window.pageYOffset,left:e.left+window.pageXOffset}}serialize(){if(!(0 in this.elems))return"";const e=new FormData(this.elems[0]);return new URLSearchParams(e).toString()}css(e,t,s){if(1 in arguments)return this.each(n=>{w(n,e,t,s||!1)});if(0 in this.elems){if("string"==typeof e)return w(this.elems[0],e);const t={};if(Array.isArray(e)){const s=this.elems[0];e.forEach(e=>{t[e]=w(s,e)})}return t}return null}data(e,t){return 0 in arguments&&e?1 in arguments?this.each(s=>{b(s,e,t)}):0 in this.elems?b(this.elems[0],e):void 0:0 in this.elems?b(this.elems[0]):{}}attr(e,t){if(1 in arguments)return this.each(s=>{1===s.nodeType&&p(s,e,t)});let s=null;return 0 in this.elems&&1==this.elems[0].nodeType&&(s=this.elems[0].getAttribute(e)),s}prop(e,t){if(e=o[e]||e,1 in arguments)return this.each(s=>{s[e]=t});let s=null;return 0 in this.elems&&(s=this.elems[0][e]),s}tagName(e){let t=0 in this.elems?this.elems[0].tagName:null;return t&&(t=t.toLowerCase(),e&&(t=t.toUpperCase())),t}val(e){return 0 in arguments?(null==e&&(e=""),this.each(t=>{t.value=e})):0 in this.elems?this.elems[0].value:null}outerHeight(){let e=0;return 0 in this.elems&&(e+=parseInt(this.elems[0].css("height")),e+=parseInt(this.elems[0].css("padding-top")),e+=parseInt(this.elems[0].css("padding-bottom")),e+=parseInt(this.elems[0].css("margin-top")),e+=parseInt(this.elems[0].css("margin-bottom"))),e}outerWidth(){let e=0;return 0 in this.elems&&(e+=parseInt(this.elems[0].css("width")),e+=parseInt(this.elems[0].css("padding-left")),e+=parseInt(this.elems[0].css("padding-right")),e+=parseInt(this.elems[0].css("margin-left")),e+=parseInt(this.elems[0].css("margin-right"))),e}slideDown(e,t,s,n){return window.Promise?(e=e||500,t=t||"cubic-bezier(0.25, 0.1, 0.44, 1.4)",s=s||200,this.each(i=>C(i,{direction:"down",slideSpeed:e,easing:t,delay:s,visibleDisplayValue:n||f(i)}))):this.show()}slideUp(e,t,s){return window.Promise?(e=e||500,t=t||"cubic-bezier(0.25, 0.1, 0.44, 1.4)",s=s||200,this.each(n=>C(n,{direction:"up",slideSpeed:e,easing:t,delay:s}))):this.hide()}slideToggle(e,t,s,n){return window.Promise?(e=e||500,t=t||"cubic-bezier(0.25, 0.1, 0.44, 1.4)",s=s||200,this.each(i=>C(i,{slideSpeed:e,easing:t,delay:s,visibleDisplayValue:n||f(i)}))):this.toggle()}scrollTop(e){return 0 in arguments?this.each(t=>{t.style.scrollBehavior="smooth",t.scrollTop=e||0}):0 in this.elems?this.elems[0].scrollTop:0}}return E}();e.DOM=t}("undefined"!=typeof window?window:this);
|
|
1
|
+
/*! DOM v2.5.1 | MIT | 2026-06-09T18:35Z | [default] */
|
|
2
|
+
!function(e){"use strict";if("object"!=typeof e||!e||!e.document)throw new Error("DOM requires a window with a document");if(void 0!==e.DOM)throw new Error("DOM is already defined");var t=function(){const e="compareDocumentPosition"in document.documentElement?function(e,t){return!(16&~t.compareDocumentPosition(e))}:function(e,t){return(t=t==document||t==window?document.documentElement:t)!==e&&t.contains(e)};function t(e){return[].slice.call(e,0)}function s(e){let t;return e&&"object"==typeof e&&(t=e.nodeType)&&(1==t||9==t)}function n(e){return"object"==typeof e&&isFinite(e.length)}function i(r,l){const a=function(e){return e?"string"==typeof e?i(e)[0]:!e.nodeType&&n(e)?e[0]:e:document}(l);let o;return a&&r?r===window||s(r)?!l||r!==window&&s(a)&&e(r,a)?[r]:[]:r&&n(r)?function(e){for(var t=[],s=0,i=e.length;s<i;++s)n(e[s])?t=t.concat(e[s]):t[t.length]=e[s];return t}(r):document.getElementsByClassName&&"string"==r&&(o=r.match(/^\.([\w\-]+)$/))?t(a.getElementsByClassName(o[1])):r&&(r.document||r.nodeType&&9==r.nodeType)?l?[]:[r]:t(a.querySelectorAll(r)):[]}function r(...e){let t=!1,s=0,n={};"boolean"==typeof e[0]&&(t=e[0],s=1);const i=e=>e&&"[object Object]"===Object.prototype.toString.call(e),l=e=>{for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t&&i(e[s])?n[s]=r(!0,n[s]||{},e[s]):void 0!==e[s]&&(n[s]=e[s]))};for(;s<e.length;s++)e[s]&&l(e[s]);return n}const l=/^(?:(width|height|top|right|bottom|left|margin|padding)|((min|max)(Width|Height))|((margin|padding)(Top|Right|Bottom|Left)))$/,a={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},o={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},c=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch(e){}return e})();function h(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function d(e){return e.replace(/-([a-z])/g,e=>e[1].toUpperCase())}function u(e,t){return!!(t&&e&&1===e.nodeType&&e.matches(t))}function m(e,t){return null==t?new E(e):new E(e).filter(t)}function p(e,t,s){null==s?e.removeAttribute(t):e.setAttribute(t,s)}function f(e){if(e.data("cssInitialDisplay"))return e.data("cssInitialDisplay");if(e.css("display")&&"none"!==e.css("display"))return e.css("display");switch(e.tagName.toLowerCase()){case"table":return"table";case"thead":return"table-header-group";case"tfoot":return"table-footer-group";case"tr":return"table-row";case"th":case"td":return"table-cell";case"span":return"inline";case"li":return"list-item"}return"block"}function g(e,t){for(var s in t)if(!0===e.classList.contains(t[s]))return!0;return!1}function y(e,t){for(var s in t)if(!1===e.classList.contains(t[s]))return!1;return!0}function w(e,t,s,n){return 2 in arguments?null===s?void e.style.removeProperty(h(t)):("number"==typeof s&&!a[h(t)]&&l.test(d(t))&&(s+="px"),void(n?e.style.setProperty(h(t),s,"important"):e.style[d(t)]=s)):e.style[d(t)]||getComputedStyle(e,null).getPropertyValue(h(t))}function b(e,t,s){if(1===arguments.length){const t={};for(let s in e.dataset)t[s]=b(e,s);return t}const n="data-"+h(t);if(!(2 in arguments))return null!==(s=e.getAttribute(n))?function(e){try{return e?"true"==e||"false"!=e&&("null"==e?null:+e+""==e?+e:/^[\[\{]/.test(e)?JSON.parse(e):e):e}catch(t){return e}}(s):void 0;if("object"!=typeof s||null===s||Array.isArray(s))p(e,n,s);else for(let n in s)b(e,t+"-"+n,s[n])}function v(e,t,s){const n=s.split(" ");return e.classList[t].apply(e.classList,n)}async function C(e,t){const s=t.slideSpeed,n=t.direction,i=t.easing,r=t.delay,l=void 0===r?0:r,a=t.visibleDisplayValue,o=void 0===a?"block":a,c=e.dataset.domSliderId||(Date.now()*Math.random()).toFixed(0);e.dataset.domSliderId||(e.dataset.domSliderId=c);const h=window.getComputedStyle(e),d="none"===h.getPropertyValue("display"),u=n||(d||e.classList.contains("slider-hidden")?"down":"up"),m=s||(0===s?0:300),p=h.getPropertyValue("box-sizing"),f=parseInt(h.getPropertyValue("padding-top").split("px")[0]),g=parseInt(h.getPropertyValue("padding-bottom").split("px")[0]);let y=Math.max(e.scrollHeight-f-g,0);return"border-box"===p&&(y=Math.max(e.scrollHeight,0)),e.dataset.sliding?Promise.resolve(e):"down"!==u||d||e.classList.contains("slider-hidden")?"up"===u&&e.classList.contains("slider-hidden")?Promise.resolve(e):(e.dataset.sliding=!0,e.setAttribute("aria-hidden","down"===u?"false":"true"),"down"===u&&d&&(e.classList.add("slider-hidden"),e.style.display=o,y=e.scrollHeight),e.style.height="".concat(y,"px"),e.style.transition="all ".concat(m,"ms ").concat(i||""),e.style.overflow="hidden",await new Promise(t=>{setTimeout(()=>{e.classList.contains("slider-hidden")||setTimeout(()=>{e.style.display="none"},300),e.classList.toggle("slider-hidden"),t()},+l>20?+l:20)}),await new Promise(t=>{setTimeout(()=>{e.style.removeProperty("height"),e.style.removeProperty("transition"),e.style.removeProperty("overflow"),e.removeAttribute("data-sliding"),t(e)},m)})):Promise.resolve(e)}class E{constructor(e,t){if(t=t||document,e instanceof E)return e;if(t instanceof E)return t.find(e);this.elems=i(e,t);for(let e=0;e<this.elems.length;e++){const t=this.elems[e];t.data=function(e,s){return 0===arguments.length?b(t):1===arguments.length?b(t,e):(b(t,e,s),t)},t.css=function(e,s,n){return arguments.length>=2?w(t,e,s,n||!1):w(t,e)},t.addClass=e=>v(t,"add",e),t.removeClass=e=>v(t,"remove",e),t.hasClass=e=>v(t,"contains",e),t.hasClasses=e=>g(t,e),t.hasAllClasses=e=>y(t,e)}return this}toArray(){return this.elems}exists(){return this.elems.length>0}size(){return this.elems.length}each(e){for(let t=0,s=this.elems.length;t<s;t++)e.call(this,this.elems[t],t);return this}map(e){const t=[];for(let s=0,n=this.elems.length;s<n;s++){const n=e.call(this,this.elems[s],s);!1!==n&&t.push(n)}return t}filter(e){if("function"!=typeof e){const t=e;e=e=>!!u(e,t)&&e}const t=[];for(let s=0,n=this.elems.length;s<n;s++){const n=e.call(this,this.elems[s],s);!1!==n&&t.push(n)}return new E(t)}not(e){const t=[];if("function"==typeof e&&void 0!==e.call)this.each(function(s,n){!1===e.call(s,n)&&t.push(s)});else{let s=[];s="string"==typeof e?this.filter(e):new E(e),s instanceof E&&(s=s.elems),this.each(function(e,n){s.indexOf(e)<0&&t.push(e)})}return new E(t)}get(e){const t=(e=e||0)>=0?e:this.elems.length+e;return void 0!==this.elems[t]?new E(this.elems[t]):this}getElement(e){return 0 in this.elems?this.elems[0]:document.createElement(e||"div")}is(e){return e instanceof HTMLElement?e===this.getElement():e instanceof E?e.getElement()===this.getElement():0 in this.elems&&"string"==typeof e&&(":visible"===e?"none"!==this.elems[0].css("display"):":hidden"===e?"none"===this.elems[0].css("display"):u(this.elems[0],e))}find(e){const t=e.trim().split(/,\s*/);let s=[];return this.each(function(e){for(let n=0,r=t.length;n<r;n++){const r=t[n].match(/^>\s*(.+)$/);if(t[n].match(/^\:(first|last)/),r){if(i(r[1],e))for(const t in e.childNodes)u(e.childNodes[t],r[1])&&(s=s.concat(e.childNodes[t]))}else{const r=i(t[n],e);r&&(s=s.concat(r))}}}),new E(s)}insert(e,t){return"before"===t&&(t="beforebegin"),"after"===t&&(t="afterend"),"prepend"===t&&(t="afterbegin"),"append"===t&&(t="beforeend"),this.each(s=>{e instanceof E?e.each(e=>{s.insertAdjacentElement(t,e)}):e instanceof Element?s.insertAdjacentElement(t,e):s.insertAdjacentHTML(t,e)})}before(e){return this.insert(e,"before")}after(e){return this.insert(e,"after")}append(e){return this.insert(e,"append")}prepend(e){return this.insert(e,"prepend")}replaceWith(e){return this.insert(e,"before"),this.remove(),this}remove(){return this.each(e=>e.parentNode.removeChild(e))}parent(e){let t=[];return this.each(e=>{const s=e.parentNode;s&&(t=t.concat(s))}),m(t,e||null)}children(e){let t=[];return this.each(e=>{const s=e.childNodes;s&&(t=t.concat(Array.from(s)))}),m(t,e||null)}closest(e){let t=[];return this.each(s=>{const n=s.closest(e);n&&(t=t.concat(n))}),new E(t)}prev(e){let t=[];return this.each(e=>{const s=e.previousElementSibling;s&&(t=t.concat(s))}),m(t,e||null)}next(e){let t=[];return this.each(e=>{const s=e.nextElementSibling;s&&(t=t.concat(s))}),m(t,e||null)}first(e){let t=[];return this.each(e=>{const s=e.firstElementChild;s&&(t=t.concat(s))}),m(t,e||null)}last(e){let t=[];return this.each(e=>{const s=e.lastElementChild;s&&(t=t.concat(s))}),m(t,e||null)}wrap(e){return this.each(t=>{t.parentNode.insertBefore(e,t),e.appendChild(t)}),this}on(e,t,s){return s=s||!1,e.split(" ").forEach(e=>{this.each(n=>{n.addEventListener(e,t,s)})}),this}delegate(e,t,s,n){return n=n||!1,this.on(e,e=>{new E(e.target).is(t)&&s(...arguments)},n)}off(e,t){return e.split(" ").forEach(e=>{this.each(s=>{s.removeEventListener(e,t)})}),this}submit(){return 0 in this.elems&&this.elems[0]instanceof HTMLFormElement&&this.elems[0].submit(),this}focus(){return 0 in this.elems&&this.elems[0].focus(),this}trigger(e,t,s,n){let i;return arguments.length<4&&(n=!0),arguments.length<3&&(s=!1),arguments.length<2&&(t=null),i=t?new CustomEvent(e,{bubbles:s,cancellable:n,detail:t}):new Event(e,{bubbles:s,cancellable:n}),this.each(e=>{e.dispatchEvent(i)})}swipe(e,t,s){return this.each(n=>{let i,l,a,o,h,d,u,m=e||function(e,t){},p=t||function(e){return!1},f=r({scrolling:!1,threshold:10,restraint:100,allowedTime:300},s||{});return n.addEventListener("touchstart",e=>{if(!1===p(e)){const t=e.changedTouches[0];i="none",l=t.pageX,a=t.pageY,u=(new Date).getTime(),!c&&e.preventDefault()}},c?{passive:!0}:void 0),n.addEventListener("touchmove",e=>{!1===p(e)&&!1===f.scrolling&&!c&&e.preventDefault()},c?{passive:!0}:void 0),n.addEventListener("touchend",e=>{if(!1===p(e)){const t=e.changedTouches[0];o=t.pageX-l,h=t.pageY-a,d=(new Date).getTime()-u,d<=f.allowedTime&&(Math.abs(o)>=f.threshold&&Math.abs(h)<=f.restraint?i=o<0?"left":"right":Math.abs(h)>=f.threshold&&Math.abs(o)<=f.restraint&&(i=h<0?"up":"down")),!c&&e.preventDefault(),m(e,i)}},c?{passive:!0}:void 0),this})}text(e){return 0 in arguments?this.each(t=>{t.innerText=e}):0 in this.elems?this.elems[0].innerText:null}html(e){return 0 in arguments?this.each(t=>{t.innerHTML=e}):0 in this.elems?this.elems[0].innerHTML:null}content(e){return 0 in arguments?this.each(t=>{t.innerContent=e}):0 in this.elems?this.elems[0].innerContent:null}addClass(e){return this.each(t=>{t.addClass(e)})}removeClass(e){return this.each(t=>{t.removeClass(e)})}toggleClass(e){return this.each(t=>{t.classList.toggle(e)})}replaceClass(e,t){return this.each(s=>{s.classList.replace(e,t)})}hasClass(e){return 0 in this.elems&&this.elems[0].classList.contains(e)}hasClasses(e){return 0 in this.elems&&this.elems[0].hasClasses(e)}hasAllClasses(e){return 0 in this.elems&&this.elems[0].hasAllClasses(e)}containsClass(e){if(0 in this.elems)for(var t=this.elems[0].classList,s=0;s<t.length;s++)if(t[s].indexOf(e)>-1)return!0;return!1}toggle(){return this.each(e=>{const t=f(e);e.data("cssInitialDisplay")||e.data("cssInitialDisplay",t),"none"===e.css("display")?e.style.display="block":e.style.display="none"})}show(){return this.each(e=>{const t=f(e);e.data("cssInitialDisplay")||e.data("cssInitialDisplay",t),e.style.display=t})}hide(){return this.each(e=>{e.data("cssInitialDisplay")||e.data("cssInitialDisplay",f(e)),e.style.display="none"})}offset(){if(0===this.elems.length)return{top:0,left:0};const e=this.elems[0].getBoundingClientRect();return{top:e.top+window.pageYOffset,left:e.left+window.pageXOffset}}serialize(){if(!(0 in this.elems))return"";const e=new FormData(this.elems[0]);return new URLSearchParams(e).toString()}css(e,t,s){if(1 in arguments)return this.each(n=>{w(n,e,t,s||!1)});if(0 in this.elems){if("string"==typeof e)return w(this.elems[0],e);const t={};if(Array.isArray(e)){const s=this.elems[0];e.forEach(e=>{t[e]=w(s,e)})}return t}return null}data(e,t){return 0 in arguments&&e?1 in arguments?this.each(s=>{b(s,e,t)}):0 in this.elems?b(this.elems[0],e):void 0:0 in this.elems?b(this.elems[0]):{}}attr(e,t){if(1 in arguments)return this.each(s=>{1===s.nodeType&&p(s,e,t)});let s=null;return 0 in this.elems&&1==this.elems[0].nodeType&&(s=this.elems[0].getAttribute(e)),s}prop(e,t){if(e=o[e]||e,1 in arguments)return this.each(s=>{s[e]=t});let s=null;return 0 in this.elems&&(s=this.elems[0][e]),s}tagName(e){let t=0 in this.elems?this.elems[0].tagName:null;return t&&(t=t.toLowerCase(),e&&(t=t.toUpperCase())),t}val(e){return 0 in arguments?(null==e&&(e=""),this.each(t=>{t.value=e})):0 in this.elems?this.elems[0].value:null}outerHeight(){let e=0;return 0 in this.elems&&(e+=parseInt(this.elems[0].css("height")),e+=parseInt(this.elems[0].css("padding-top")),e+=parseInt(this.elems[0].css("padding-bottom")),e+=parseInt(this.elems[0].css("margin-top")),e+=parseInt(this.elems[0].css("margin-bottom"))),e}outerWidth(){let e=0;return 0 in this.elems&&(e+=parseInt(this.elems[0].css("width")),e+=parseInt(this.elems[0].css("padding-left")),e+=parseInt(this.elems[0].css("padding-right")),e+=parseInt(this.elems[0].css("margin-left")),e+=parseInt(this.elems[0].css("margin-right"))),e}slideDown(e,t,s,n){return window.Promise?(e=e||500,t=t||"cubic-bezier(0.25, 0.1, 0.44, 1.4)",s=s||200,this.each(i=>C(i,{direction:"down",slideSpeed:e,easing:t,delay:s,visibleDisplayValue:n||f(i)}))):this.show()}slideUp(e,t,s){return window.Promise?(e=e||500,t=t||"cubic-bezier(0.25, 0.1, 0.44, 1.4)",s=s||200,this.each(n=>C(n,{direction:"up",slideSpeed:e,easing:t,delay:s}))):this.hide()}slideToggle(e,t,s,n){return window.Promise?(e=e||500,t=t||"cubic-bezier(0.25, 0.1, 0.44, 1.4)",s=s||200,this.each(i=>C(i,{slideSpeed:e,easing:t,delay:s,visibleDisplayValue:n||f(i)}))):this.toggle()}scrollTop(e){return 0 in arguments?this.each(t=>{t.style.scrollBehavior="smooth",t.scrollTop=e||0}):0 in this.elems?this.elems[0].scrollTop:0}}return"undefined"!=typeof window&&(window.jDOM=function(e,t){return new E(e,t)},window.jDOMplugin=function(e,t){E.prototype[e]=t},window.jDOMcreate=function(e,t){const s=new E([document.createElement(e)]);if(t)for(var n in t.className&&(s.addClass(t.className),delete t.className),t.text&&(s.text(t.text),delete t.text),t.html&&(s.html(t.html),delete t.html),t)t.hasOwnProperty(n)&&s.attr(n,t[n]);return s}),E}();e.DOM=t}("undefined"!=typeof window?window:this);
|
package/lib/index.js
CHANGED
package/lib/js/jdom.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import DOM from './dom.js';
|
|
2
|
+
|
|
3
|
+
// jDOM machinery, decoupled from any JiZy global.
|
|
4
|
+
// (The old JiZy.dom / JiZy.qsa / JiZy.qs namespace is dropped — use jDOM(selector) instead.)
|
|
5
|
+
|
|
6
|
+
export function jDOM(selector, parent) {
|
|
7
|
+
return new DOM(selector, parent);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function jDOMplugin(name, fn) {
|
|
11
|
+
DOM.prototype[name] = fn;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function jDOMcreate(tagName, attrs) {
|
|
15
|
+
const el = new DOM([document.createElement(tagName)]);
|
|
16
|
+
|
|
17
|
+
if (attrs) {
|
|
18
|
+
if (attrs.className) {
|
|
19
|
+
el.addClass(attrs.className);
|
|
20
|
+
delete attrs.className;
|
|
21
|
+
}
|
|
22
|
+
if (attrs.text) {
|
|
23
|
+
el.text(attrs.text);
|
|
24
|
+
delete attrs.text;
|
|
25
|
+
}
|
|
26
|
+
if (attrs.html) {
|
|
27
|
+
el.html(attrs.html);
|
|
28
|
+
delete attrs.html;
|
|
29
|
+
}
|
|
30
|
+
for (var key in attrs) {
|
|
31
|
+
if (attrs.hasOwnProperty(key)) {
|
|
32
|
+
el.attr(key, attrs[key]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return el;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (typeof window !== 'undefined') {
|
|
41
|
+
window.jDOM = jDOM;
|
|
42
|
+
window.jDOMplugin = jDOMplugin;
|
|
43
|
+
window.jDOMcreate = jDOMcreate;
|
|
44
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
jDOMplugin('accordion', function (params) {
|
|
2
|
+
params = Object.assign({
|
|
3
|
+
offset: 0,
|
|
4
|
+
tag: 'h2'
|
|
5
|
+
}, params || {});
|
|
6
|
+
|
|
7
|
+
function getScrollOffset(offset) {
|
|
8
|
+
if (jDOM("body > main .page-contents").offset().top) {
|
|
9
|
+
offset += parseInt(jDOM(".page-contents").css("padding-top"));
|
|
10
|
+
}
|
|
11
|
+
if (jDOM("body > header").exists()) {
|
|
12
|
+
offset += jDOM("body > header").outerHeight();
|
|
13
|
+
}
|
|
14
|
+
else if (jDOM("body > nav").exists()) {
|
|
15
|
+
offset += jDOM("body > nav").outerHeight();
|
|
16
|
+
}
|
|
17
|
+
return offset;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return this.each(function (el) {
|
|
21
|
+
var $el = jDOM(el);
|
|
22
|
+
|
|
23
|
+
if (el.data("accordion")) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
el.data("accordion", true);
|
|
27
|
+
|
|
28
|
+
var $triggers = $el.find("> " + params.tag);
|
|
29
|
+
var $boxes = $el.find("> div");
|
|
30
|
+
|
|
31
|
+
$triggers.each(function (el) {
|
|
32
|
+
var $trigger = jDOM(el);
|
|
33
|
+
var $box = $trigger.next("div");
|
|
34
|
+
|
|
35
|
+
$trigger.find("a").on("click", function (e) {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
|
|
38
|
+
if ($trigger.hasClass("active")) {
|
|
39
|
+
$trigger.removeClass("active");
|
|
40
|
+
$box.slideUp();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
$triggers.removeClass("active");
|
|
45
|
+
|
|
46
|
+
$boxes.map(function (el) {
|
|
47
|
+
if ('none' !== el.css("display")) {
|
|
48
|
+
jDOM(el).slideUp();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
$trigger.addClass("active");
|
|
53
|
+
|
|
54
|
+
$box.slideDown();
|
|
55
|
+
|
|
56
|
+
if (document.body.classList.contains("modalizer-open")) {
|
|
57
|
+
jDOM(".modalizer").scrollTop(0);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
jDOM("body").scrollTop($el.offset().top - getScrollOffset(params.offset));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (el.data("open")) {
|
|
66
|
+
$el.find("> " + params.tag + ":first-of-type")
|
|
67
|
+
.addClass("active")
|
|
68
|
+
.next("div")
|
|
69
|
+
.slideDown();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function blockFitWidth(el, params) {
|
|
2
|
+
let margin = params.offset;
|
|
3
|
+
const container = el.closest(".container");
|
|
4
|
+
if (container) {
|
|
5
|
+
margin += parseInt(container.style.paddingLeft) || 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
let padding = params.offset;
|
|
9
|
+
if (el.getAttribute('data-nopadding')) {
|
|
10
|
+
padding = null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
el.style.marginLeft = '-' + margin + 'px';
|
|
14
|
+
el.style.marginRight = '-' + margin + 'px';
|
|
15
|
+
el.style.paddingLeft = padding ? padding + 'px' : null;
|
|
16
|
+
el.style.paddingRight = padding ? padding + 'px' : null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
jDOMplugin('blockFitWidth', function (params) {
|
|
20
|
+
params = Object.assign({
|
|
21
|
+
offset: 0
|
|
22
|
+
}, params || {});
|
|
23
|
+
|
|
24
|
+
return this.each(function (el) {
|
|
25
|
+
blockFitWidth(el, params);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function checkboxMaxSelection(el) {
|
|
2
|
+
const max = parseInt(el.getAttribute("data-max-selection"));
|
|
3
|
+
|
|
4
|
+
if (!max) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const $checkboxes = Array.from(el.querySelectorAll("input[type='checkbox']"));
|
|
9
|
+
|
|
10
|
+
if ($checkboxes.length === 0) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function checkCount($checkboxes) {
|
|
15
|
+
const counter = $checkboxes.filter(checkbox => checkbox.checked).length;
|
|
16
|
+
if (counter >= max) {
|
|
17
|
+
$checkboxes.forEach(checkbox => {
|
|
18
|
+
if (!checkbox.checked) {
|
|
19
|
+
checkbox.disabled = true;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
$checkboxes.forEach(checkbox => {
|
|
25
|
+
checkbox.disabled = false;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
checkCount($checkboxes);
|
|
31
|
+
|
|
32
|
+
$checkboxes.forEach(checkbox => {
|
|
33
|
+
checkbox.addEventListener("click", () => {
|
|
34
|
+
checkCount($checkboxes);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
jDOMplugin('checkboxMaxSelection', function () {
|
|
40
|
+
return this.each(function (el) {
|
|
41
|
+
checkboxMaxSelection(el);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// confirm — wires `[data-confirm]` elements to the global `Modalizer.confirm()`
|
|
2
|
+
// (the jizy-modalizer extension). On click it opens a confirmation layer; the OK
|
|
3
|
+
// action (a callback, or navigating to the element's href) is handled by
|
|
4
|
+
// Modalizer.confirm, which also reads the element's data-confirm* attributes.
|
|
5
|
+
//
|
|
6
|
+
// jDOM("[data-confirm]").confirm({ okText: JiZy.translate('CONFIRM'), koText: JiZy.translate('CANCEL') });
|
|
7
|
+
function confirm(el, params) {
|
|
8
|
+
if (el.getAttribute("data-jizy-confirm-done")) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
el.setAttribute("data-jizy-confirm-done", true);
|
|
13
|
+
|
|
14
|
+
el.addEventListener("click", (e) => {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
if (typeof Modalizer !== 'undefined' && typeof Modalizer.confirm === 'function') {
|
|
17
|
+
Modalizer.confirm(el, params || {});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
jDOMplugin('confirm', function (params) {
|
|
23
|
+
return this.each(function (el) {
|
|
24
|
+
confirm(el, params);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function hasher(el) {
|
|
2
|
+
if (el.getAttr("data-jhasher-done")) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
el.setAttr("data-jhasher-done", true);
|
|
7
|
+
|
|
8
|
+
const hash = JiZy.Hasher.DomData(el);
|
|
9
|
+
let layer = JiZy.Modalizer.LayerDomData(el);
|
|
10
|
+
|
|
11
|
+
if (typeof hash.parser === "function") {
|
|
12
|
+
layer = hash.parser(el, layer);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
el.addEventListener("click", function (e) {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
this.blur();
|
|
18
|
+
JiZy.Modalizer.loadHash(hash.url, hash, layer);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
el.addEventListener("jizy.hasher.reload", function (e) {
|
|
22
|
+
JiZy.Modalizer.loadHash(hash.url, hash, layer);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
jDOMplugin('hasher', function (config) {
|
|
27
|
+
return this.each(function (el) {
|
|
28
|
+
hasher(el, config);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function hrefData(el) {
|
|
2
|
+
if (el.getAttribute("data-jizy-href-done")) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
el.setAttribute("data-jizy-href-done", true);
|
|
7
|
+
|
|
8
|
+
const href = el.getAttribute('data-href');
|
|
9
|
+
if (!href) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
el.addEventListener("click", (e) => {
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
window.location.href = href;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
jDOMplugin('hrefData', function () {
|
|
20
|
+
return this.each(function (el) {
|
|
21
|
+
hrefData(el);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function limitLinkText(el, params) {
|
|
2
|
+
if (el.getAttribute("data-limit-link-text")) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
el.setAttribute("data-limit-link-text", true);
|
|
7
|
+
|
|
8
|
+
if (el.innerText === el.getAttribute("href")) {
|
|
9
|
+
let limit = parseInt(el.getAttribute("data-maxlength"));
|
|
10
|
+
if (!limit) {
|
|
11
|
+
limit = params.maxLength;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let text = el.innerText;
|
|
15
|
+
if (text.length > limit) {
|
|
16
|
+
text = text.substr(0, limit) + '...';
|
|
17
|
+
}
|
|
18
|
+
el.innerText = text;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
jDOMplugin('limitLinkText', function (params) {
|
|
23
|
+
params = Object.assign({
|
|
24
|
+
maxLength: 47
|
|
25
|
+
}, params || {});
|
|
26
|
+
|
|
27
|
+
return this.each(function (el) {
|
|
28
|
+
limitLinkText(el, params);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function linker(el) {
|
|
2
|
+
if (el.getAttribute("data-jizy-linker-done")) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
el.setAttribute("data-jizy-linker-done", true);
|
|
6
|
+
|
|
7
|
+
const link = el.getAttribute('data-linker');
|
|
8
|
+
if (!link) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
el.addEventListener("click", (e) => {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
document.querySelector("[data-slug='" + link + "']").click();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
jDOMplugin('linker', function () {
|
|
19
|
+
return this.each(function (el) {
|
|
20
|
+
linker(el);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function newWindowLink(el, params) {
|
|
2
|
+
if (el.getAttribute("data-newwindow-done")) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
el.setAttribute("data-newwindow-done", true);
|
|
6
|
+
|
|
7
|
+
if (el.classList.contains("notip") || el.classList.contains("no-icon")) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const tip = el.getAttribute("data-tip") || el.title || JiZy.translate('NEW_WINDOW');
|
|
12
|
+
|
|
13
|
+
// Mark as a tooltip trigger via `data-tip` (the shared front layer's delegated
|
|
14
|
+
// jizy-tooltip handler reads it on hover). Do NOT add a `.jtip` class — in
|
|
15
|
+
// jizy-tooltip v2 `.jtip` is the hidden tooltip CONTAINER (opacity:0;
|
|
16
|
+
// position:absolute), which would hide the link. Drop the native title too.
|
|
17
|
+
el.setAttribute("data-tip", tip);
|
|
18
|
+
el.removeAttribute("title");
|
|
19
|
+
el.setAttribute("data-tip-position", el.getAttribute("data-placement") || params.placement);
|
|
20
|
+
// The link is a real external link (selector is a[target='_blank']); let the
|
|
21
|
+
// browser open it natively. Just drop focus so the outline doesn't linger.
|
|
22
|
+
el.addEventListener("click", () => {
|
|
23
|
+
el.blur();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
jDOMplugin('newWindowLink', function (params) {
|
|
28
|
+
params = Object.assign({
|
|
29
|
+
placement: 'top',
|
|
30
|
+
}, params || {});
|
|
31
|
+
|
|
32
|
+
return this.each(function (el) {
|
|
33
|
+
newWindowLink(el, params);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// picviewer — wires [data-zoom] thumbnails (and [data-gallery] containers) to the
|
|
2
|
+
// global Modalizer.picviewer() lightbox (the optional jizy-modalizer plugin). Thin
|
|
3
|
+
// proxy: it gathers the image(s) — the whole gallery when the thumb sits inside a
|
|
4
|
+
// [data-gallery], otherwise just the one — and hands them to Modalizer.picviewer,
|
|
5
|
+
// which builds the layer, the pure-CSS arrows and the prev/next + keyboard + swipe
|
|
6
|
+
// navigation. All styling and behaviour live in the modalizer plugin (js + css);
|
|
7
|
+
// this file is the optional DOM glue (native DOM + the Modalizer global, no JiZy.*).
|
|
8
|
+
//
|
|
9
|
+
// jDOM("img[data-zoom]").picViewer();
|
|
10
|
+
// jDOM("[data-gallery]").picSlider();
|
|
11
|
+
function pvGalleryImages(el) {
|
|
12
|
+
var gallery = el.closest ? el.closest('[data-gallery]') : null;
|
|
13
|
+
if (gallery) {
|
|
14
|
+
return Array.prototype.slice.call(gallery.querySelectorAll('img[data-zoom]'));
|
|
15
|
+
}
|
|
16
|
+
return [el];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function pvBind(el) {
|
|
20
|
+
if (!el || el.getAttribute('data-jizy-viewer-done')) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
el.setAttribute('data-jizy-viewer-done', true);
|
|
24
|
+
if (el.classList) {
|
|
25
|
+
el.classList.add('pic-thumb');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
el.addEventListener('click', function (e) {
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
if (typeof Modalizer === 'undefined' || typeof Modalizer.picviewer !== 'function') {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
var imgs = pvGalleryImages(el);
|
|
34
|
+
var index = imgs.indexOf(el);
|
|
35
|
+
Modalizer.picviewer(imgs, index < 0 ? 0 : index);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
jDOMplugin('picViewer', function () {
|
|
40
|
+
return this.each(function (el) {
|
|
41
|
+
pvBind(el);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
jDOMplugin('picSlider', function () {
|
|
46
|
+
// Gallery container: wire each of its [data-zoom] thumbs. The prev/next slider
|
|
47
|
+
// itself is provided by Modalizer.picviewer (it detects the gallery from the
|
|
48
|
+
// clicked thumb), so there is nothing else to set up here.
|
|
49
|
+
return this.each(function (el) {
|
|
50
|
+
var thumbs = el.querySelectorAll ? el.querySelectorAll('img[data-zoom]') : [];
|
|
51
|
+
for (var i = 0; i < thumbs.length; i++) {
|
|
52
|
+
pvBind(thumbs[i]);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function tableResponsive(el) {
|
|
2
|
+
if (el.getAttribute("data-tblresp-done")) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
el.setAttribute("data-tblresp-done", true);
|
|
7
|
+
|
|
8
|
+
const wrapper = document.createElement('div');
|
|
9
|
+
wrapper.classList.add('table-responsive');
|
|
10
|
+
|
|
11
|
+
el.parentNode.insertBefore(wrapper, el);
|
|
12
|
+
wrapper.appendChild(el);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
jDOMplugin('tableResponsive', function () {
|
|
16
|
+
return this.each(function (el) {
|
|
17
|
+
tableResponsive(el);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function toggler(el) {
|
|
2
|
+
if (el.getAttribute("data-toggler-done")) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
el.setAttribute("data-toggler-done", true);
|
|
6
|
+
if (!el.getAttribute("data-toggler")) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
el.addEventListener("click", (e) => {
|
|
11
|
+
e.preventDefault();
|
|
12
|
+
document.querySelector(el.getAttribute("data-toggler"))?.classList.toggle("active");
|
|
13
|
+
el.blur();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
jDOMplugin('toggler', function () {
|
|
18
|
+
return this.each(function (el) {
|
|
19
|
+
toggler(el);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// userDropzone — wraps the third-party Dropzone library, which the site must load itself
|
|
2
|
+
// (assumed present as the global `Dropzone`; no-ops if absent).
|
|
3
|
+
jDOMplugin('userDropzone', function(config){
|
|
4
|
+
return this.each(function(el){
|
|
5
|
+
if ( typeof Dropzone === 'undefined' ){
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if ( el.data("dropzone-done") ){
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
el.data("dropzone-done", true);
|
|
14
|
+
|
|
15
|
+
var dropzone = new Dropzone("#"+el.id, config);
|
|
16
|
+
|
|
17
|
+
dropzone.on("error", function(file, errorMessage, xhr){
|
|
18
|
+
JiZy.log.debug('DZ xhr', xhr);
|
|
19
|
+
JiZy.log.debug('DZ file', file);
|
|
20
|
+
JiZy.log.debug('DZ errorMessage', errorMessage);
|
|
21
|
+
|
|
22
|
+
dropzone.removeFile(file);
|
|
23
|
+
|
|
24
|
+
config.onError(errorMessage.error, file);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
dropzone.on("success", function(file, response){
|
|
28
|
+
JiZy.log.debug('DZ response', response);
|
|
29
|
+
JiZy.log.debug('DZ file', file);
|
|
30
|
+
|
|
31
|
+
dropzone.removeFile(file);
|
|
32
|
+
|
|
33
|
+
if ( response.exception ){
|
|
34
|
+
config.onError('Une erreur est survenue.', file);
|
|
35
|
+
}
|
|
36
|
+
else if ( response.error ){
|
|
37
|
+
config.onError(response.error, file);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
config.onSuccess(file, response);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
jDOM(el).on("dropzone.destroy", function(){
|
|
45
|
+
dropzone.destroy();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jizy-dom",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"browser": "dist/js/jizy-dom.min.js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"description": "A lightweight DOM manipulation library",
|
|
10
10
|
"homepage": "https://jizy.joffreydemetz.com/dom",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"JiZy",
|
|
13
|
+
"DOM"
|
|
14
|
+
],
|
|
11
15
|
"files": [
|
|
12
16
|
"dist/*",
|
|
13
17
|
"lib/*"
|
|
@@ -23,10 +27,6 @@
|
|
|
23
27
|
"type": "git",
|
|
24
28
|
"url": "https://github.com/joffreydemetz/jizy-dom"
|
|
25
29
|
},
|
|
26
|
-
"keywords": [
|
|
27
|
-
"JiZy",
|
|
28
|
-
"DOM"
|
|
29
|
-
],
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"happy-dom": "^20.9.0",
|
|
32
32
|
"jizy-packer": "^2.1.44",
|