PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5
3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / assets / build / frontend / media.field.js
jetformbuilder / assets / build / frontend Last commit date
advanced.reporting.asset.php 1 month ago advanced.reporting.js 1 month ago calculated.field.asset.php 1 month ago calculated.field.js 1 month ago conditional.block.asset.php 1 month ago conditional.block.js 1 month ago dynamic.value.asset.php 1 month ago dynamic.value.js 1 month ago main.asset.php 2 weeks ago main.css 1 month ago main.js 2 weeks ago media.field.asset.php 1 month ago media.field.js 1 month ago media.field.restrictions.asset.php 2 weeks ago media.field.restrictions.js 2 weeks ago multi.step.asset.php 1 month ago multi.step.js 1 month ago
media.field.js
1 lines
1 (()=>{"use strict";function t(t){const e=new DataTransfer;for(const n of t)e.items.add(n);return e.files}function e(t){return!!t.classList.contains("jet-form-builder-file-upload__input")&&"file"===t.type}const{InputData:n}=window.JetFormBuilderAbstract;function i(){n.call(this),this.isMultiple=!1,this.prevFiles=null,this.template=null,this.previewsContainer=null,this.wrapper=null,this.isSupported=function(t){return e(t)},this.addListeners=function(){const[e]=this.nodes;e.addEventListener("change",e=>{var n;this.value.current=t(this.isMultiple?[...null!==(n=this.prevFiles)&&void 0!==n?n:[],...e.target.files]:[...e.target.files])})},this.setNode=function(t){n.prototype.setNode.call(this,t),this.isMultiple=t.multiple,this.wrapper=t.closest(".jet-form-builder-file-upload"),this.previewsContainer=this.wrapper.querySelector(".jet-form-builder-file-upload__files"),this.template=this.wrapper.closest(".field-type-media-field").querySelector(".jet-form-builder__preview-template")},this.setValue=function(){this.callable.loadFiles()},this.initNotifyValue=()=>{},this.reQueryValue=()=>{}}i.prototype=Object.create(n.prototype),i.prototype.wrapper=null,i.prototype.previewsContainer=null,i.prototype.template=null;const r=i,{BaseSignal:l}=window.JetFormBuilderAbstract;function o(){l.call(this),this.lock.current=!0,this.isSupported=function(t){return e(t)},this.runSignal=function(){const[e]=this.input.nodes,n=[],{current:i}=this.input.value,r=a(null!=i?i:[]);for(const t of r)n.push(this.getPreview(t));!function(t,e){const n=t.querySelectorAll(".jet-form-builder-file-upload__file");for(const t of n)e.some(e=>e.isEqualNode(t))||t.remove();for(const n in e){if(!e.hasOwnProperty(n))continue;const i=e[n];i.isConnected||t.appendChild(i)}}(this.input.previewsContainer,n),e.files=t(r),this.input.prevFiles=r,this.sortable()}}o.prototype=Object.create(l.prototype),o.prototype.loadFiles=function(){const e=this.input.previewsContainer.querySelectorAll(".jet-form-builder-file-upload__file"),n=[];for(const t of e){this.addRemoveHandler(t);const e=t.dataset.file,i=t.querySelector(".jet-form-builder-file-upload__file-remove"),{fileName:r}=i.dataset;n.push([e,r])}n.length?Promise.allSettled(n.map(([t,e])=>new Promise((n,i)=>{fetch(t).then(t=>t.blob()).then(t=>n(function(t,e){return new File([t],e,t)}(t,e))).catch(i)}))).then(e=>{const n=a(e.map(({value:t})=>t));this.lock.current=!1,this.input.silenceSet(t(n))}).catch(()=>{this.lock.current=!1}):this.lock.current=!1},o.prototype.sortable=function(){jQuery(this.input.previewsContainer).unbind(),jQuery(this.input.previewsContainer).sortable({items:".jet-form-builder-file-upload__file",forcePlaceholderSize:!0}).bind("sortupdate",()=>this.onSortCallback())},o.prototype.onSortCallback=function(){const t=new DataTransfer,[e]=this.input.nodes,n=this.input.previewsContainer.querySelectorAll(".jet-form-builder-file-upload__file-remove");for(const i of n){const{fileName:n}=i.dataset;for(const i of e.files)i.name===n&&t.items.add(i)}this.input.value.current=t.files},o.prototype.addRemoveHandler=function(t){t.querySelector(".jet-form-builder-file-upload__file-remove").addEventListener("click",this.removeFile.bind(this))},o.prototype.getPreview=function(t){const e=this.input.previewsContainer.querySelector(`[data-file-name="${t.name}"]`);if(!e){const e=this.createPreview(t);return this.addRemoveHandler(e),e}return e.closest(".jet-form-builder-file-upload__file")},o.prototype.createPreview=function(t){const e=URL.createObjectURL(t);let{innerHTML:n}=this.input.template;n=n.replace("%file_url%",e),n=n.replace("%file_name%",t.name);const i=document.createElement("template");i.innerHTML=n;const r=i.content.firstChild;if(/^image\//.test(t.type)){const n=document.createElement("img");n.src=e,n.alt=t.name,r.prepend(n)}return r},o.prototype.removeFile=function({target:t}){const e=".jet-form-builder-file-upload__file-remove",{value:n}=this.input;t.matches(e)||(t=t.closest(e));const{fileName:i}=t.dataset,r=new DataTransfer;for(const t of n.current)i!==t.name&&r.items.add(t);n.current=r.files},o.prototype.getFileNode=function(t){const e=`data-file-name="${t}"`;return this.input.previewsContainer.querySelector(`.jet-form-builder-file-upload__file-remove[${e}]`).closest(".jet-form-builder-file-upload__file")};const s=o;function a(t){const e=new Set,n=[];for(const i of function(t){return t?Array.isArray(t)?t:"function"==typeof t[Symbol.iterator]?Array.from(t):"object"==typeof t?Object.values(t):[]:[]}(t))i?.name&&(e.has(i.name)||(e.add(i.name),n.push(i)));return n}function u(t){return String(null!=t?t:"").replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function c(t){const e=t.closest(".field-type-media-field");if(!e)return"";const n=e.querySelectorAll(".jet-form-builder-file-upload__file");if(!n.length)return"";const i=[];return n.forEach(t=>{var e,n;const r=String(null!==(e=t.dataset?.file)&&void 0!==e?e:"").trim(),l=t.querySelector(".jet-form-builder-file-upload__file-remove"),o=String(null!==(n=l?.dataset?.fileName)&&void 0!==n?n:"").trim();t.querySelector("img")&&r?i.push(function(t,e=""){const n=e||"Image";return`\n\t\t<li style="list-style:none; margin:0 0 12px 0;">\n\t\t\t<div style="display:inline-block; max-width:150px;">\n\t\t\t\t<img\n\t\t\t\t\tsrc="${u(t)}"\n\t\t\t\t\talt="${u(n)}"\n\t\t\t\t\tstyle="\n\t\t\t\t\t\tdisplay:block;\n\t\t\t\t\t\twidth:150px;\n\t\t\t\t\t\theight:150px;\n\t\t\t\t\t\tobject-fit:cover;\n\t\t\t\t\t\tborder:1px solid #dcdcdc;\n\t\t\t\t\t\tborder-radius:8px;\n\t\t\t\t\t\tbackground:#fff;\n\t\t\t\t\t"\n\t\t\t\t/>\n\t\t\t\t<div style="\n\t\t\t\t\tmargin-top:6px;\n\t\t\t\t\tfont-size:13px;\n\t\t\t\t\tline-height:1.4;\n\t\t\t\t\tcolor:#444;\n\t\t\t\t\tword-break:break-word;\n\t\t\t\t">\n\t\t\t\t\t${u(n)}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</li>\n\t`}(r,o)):(o||r)&&i.push(function(t,e=""){const n=e||t||"File";return t?`\n\t\t\t<li style="list-style:none; margin:0 0 10px 0;">\n\t\t\t\t<a\n\t\t\t\t\thref="${u(t)}"\n\t\t\t\t\ttarget="_blank"\n\t\t\t\t\trel="noopener noreferrer"\n\t\t\t\t\tstyle="\n\t\t\t\t\t\tcolor:#d63384;\n\t\t\t\t\t\ttext-decoration:underline;\n\t\t\t\t\t\tword-break:break-word;\n\t\t\t\t\t\tfont-size:14px;\n\t\t\t\t\t\tline-height:1.4;\n\t\t\t\t\t"\n\t\t\t\t>\n\t\t\t\t\t📄 ${u(n)}\n\t\t\t\t</a>\n\t\t\t</li>\n\t\t`:`\n\t\t<li style="\n\t\t\tlist-style:none;\n\t\t\tmargin:0 0 10px 0;\n\t\t\tfont-size:14px;\n\t\t\tline-height:1.4;\n\t\t\tword-break:break-word;\n\t\t\tcolor:#444;\n\t\t">\n\t\t\t📄 ${u(n)}\n\t\t</li>\n\t`}(r,o))}),function(t){return t.length?`\n\t\t<div style="\n\t\t\tdisplay:block;\n\t\t\tpadding:0;\n\t\t\tmargin:0;\n\t\t">\n\t\t\t<ul style="\n\t\t\t\tmargin:0;\n\t\t\t\tpadding:0;\n\t\t\t\tlist-style:none;\n\t\t\t">\n\t\t\t\t${t.join("")}\n\t\t\t</ul>\n\t\t</div>\n\t`:""}(i)}function f(t){t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}function d(t,e){const n=e?.[0]||e;return function(t){return!!t&&!!t.closest(".field-type-media-field")}(n)?(function(t){if(!t||t.__jfbMediaRemoveBound)return;const e=t.closest(".field-type-media-field");e&&(t.__jfbMediaRemoveBound=!0,e.addEventListener("click",e=>{e.target.closest(".jet-form-builder-file-upload__file-remove")&&setTimeout(()=>{f(t)},0)}))}(n),function(t){if(!t)return;const e=function(t){const e=t.closest(".field-type-media-field");return e?e.querySelector(".jet-form-builder-file-upload__files")||e.querySelector(".jet-form-builder-file-upload")||e:null}(t);if(!e)return;t.__jfbMediaMacrosObserver&&(t.__jfbMediaMacrosObserver.disconnect(),t.__jfbMediaMacrosObserver=null);const n=c(t),i=new MutationObserver(()=>{c(t)!==n&&(i.disconnect(),t.__jfbMediaMacrosObserver=null,f(t))});t.__jfbMediaMacrosObserver=i,i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-file","src"]}),setTimeout(()=>{t.__jfbMediaMacrosObserver===i&&(i.disconnect(),t.__jfbMediaMacrosObserver=null,c(t)!==n&&f(t))},300)}(n),c(n)):t}const{addFilter:p}=JetPlugins.hooks;p("jet.fb.inputs","jet-form-builder/media-field",function(t){return[r,...t]}),p("jet.fb.signals","jet-form-builder/media-field",function(t){return[s,...t]}),p("jet.fb.macro.field.value","jet-form-builder/media-field",d),p("jet.fb.macro.inside.repeater.field.value","jet-form-builder/media-field",d)})();