[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/system/js/fields/ -> joomla-media-select-es5.min.js (source)

   1  !function(){"use strict";function e(e,t,i,n,a,l,o){try{var r=e[l](o),s=r.value}catch(e){return void i(e)}r.done?t(s):Promise.resolve(s).then(n,a)}function t(t){return function(){var i=this,n=arguments;return new Promise((function(a,l){var o=t.apply(i,n);function r(t){e(o,a,l,r,s,"next",t)}function s(t){e(o,a,l,r,s,"throw",t)}r(void 0)}))}}function i(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function o(e,t,i){return(o=l()?Reflect.construct:function(e,t,i){var n=[null];n.push.apply(n,t);var l=new(Function.bind.apply(e,n));return i&&a(l,i.prototype),l}).apply(null,arguments)}function r(e){var t="function"==typeof Map?new Map:void 0;return(r=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,l)}function l(){return o(e,arguments,n(this).constructor)}return l.prototype=Object.create(e.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}),a(l,e)})(e)}if(!Joomla)throw new Error("Joomla API is not properly initiated");Joomla.selectedMediaFile={};var s=Joomla.getOptions("media-picker",{});if(!Object.keys(s).length)throw new Error("No supported extensions provided");document.addEventListener("onMediaFileSelected",function(){var e=t(regeneratorRuntime.mark((function e(t){var i,n,a,l,o,r,c,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Joomla.selectedMediaFile=t.detail,i=Joomla.Modal.getCurrent(),n=i.querySelector(".modal-body")){e.next=5;break}return e.abrupt("return");case 5:if((a=n.querySelector("joomla-field-mediamore"))&&a.parentNode.removeChild(a),!n.closest("joomla-field-media")){e.next=9;break}return e.abrupt("return");case 9:l=s.images,o=s.audios,r=s.videos,c=s.documents,Joomla.selectedMediaFile.path&&(l.includes(Joomla.selectedMediaFile.extension.toLowerCase())?u="images":o.includes(Joomla.selectedMediaFile.extension.toLowerCase())?u="audios":r.includes(Joomla.selectedMediaFile.extension.toLowerCase())?u="videos":c.includes(Joomla.selectedMediaFile.extension.toLowerCase())&&(u="documents"),u&&n.insertAdjacentHTML("afterbegin",'<joomla-field-mediamore\n  parent-id="'+i.id+'"\n  type="'+u+'"\n  summary-label="'+Joomla.Text._("JFIELD_MEDIA_SUMMARY_LABEL")+'"\n  lazy-label="'+Joomla.Text._("JFIELD_MEDIA_LAZY_LABEL")+'"\n  alt-label="'+Joomla.Text._("JFIELD_MEDIA_ALT_LABEL")+'"\n  alt-check-label="'+Joomla.Text._("JFIELD_MEDIA_ALT_CHECK_LABEL")+'"\n  alt-check-desc-label="'+Joomla.Text._("JFIELD_MEDIA_ALT_CHECK_DESC_LABEL")+'"\n  classes-label="'+Joomla.Text._("JFIELD_MEDIA_CLASS_LABEL")+'"\n  figure-classes-label="'+Joomla.Text._("JFIELD_MEDIA_FIGURE_CLASS_LABEL")+'"\n  figure-caption-label="'+Joomla.Text._("JFIELD_MEDIA_FIGURE_CAPTION_LABEL")+'"\n  embed-check-label="'+Joomla.Text._("JFIELD_MEDIA_EMBED_CHECK_LABEL")+'"\n  embed-check-desc-label="'+Joomla.Text._("JFIELD_MEDIA_EMBED_CHECK_DESC_LABEL")+'"\n  download-check-label="'+Joomla.Text._("JFIELD_MEDIA_DOWNLOAD_CHECK_LABEL")+'"\n  download-check-desc-label="'+Joomla.Text._("JFIELD_MEDIA_DOWNLOAD_CHECK_DESC_LABEL")+'"\n  title-label="'+Joomla.Text._("JFIELD_MEDIA_TITLE_LABEL")+'"\n  width-label="'+Joomla.Text._("JFIELD_MEDIA_WIDTH_LABEL")+'"\n  height-label="'+Joomla.Text._("JFIELD_MEDIA_HEIGHT_LABEL")+'"\n></joomla-field-mediamore>\n'));case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());var c=function(e){return"object"==typeof HTMLElement?e instanceof HTMLElement:e&&"object"==typeof e&&1===e.nodeType&&"string"==typeof e.nodeName},u=function(e){return new Promise((function(t,i){var n=new Image;n.src=e,n.onload=function(){Joomla.selectedMediaFile.width=n.width,Joomla.selectedMediaFile.height=n.height,t(!0)},n.onerror=function(){i(!1)}}))},d=function(){var e=t(regeneratorRuntime.mark((function e(t,i,n){var a,l,o,r,s,d,p,h,m,f,b,g;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.url?(a=Joomla.getOptions("system.paths"),l=a.rootFull,(o=t.url.split(l)).length>1?(Joomla.selectedMediaFile.url=o[1],t.thumb_path?Joomla.selectedMediaFile.thumb=t.thumb_path:Joomla.selectedMediaFile.thumb=!1):t.thumb_path&&(Joomla.selectedMediaFile.url=t.url,Joomla.selectedMediaFile.thumb=t.thumb_path)):Joomla.selectedMediaFile.url=!1,!Joomla.selectedMediaFile.url){e.next=47;break}if(s="",d="",p="",h="",m="",f="",b="",c(i)){e.next=35;break}if(g=n.closest(".modal-content"),!(r=g.querySelector("joomla-field-mediamore"))){e.next=30;break}if("true"===r.getAttribute("alt-check")&&(p=' alt=""'),d=r.getAttribute("alt-value")?' alt="'+r.getAttribute("alt-value")+'"':p,h=r.getAttribute("img-classes")?' class="'+r.getAttribute("img-classes")+'"':"",m=r.getAttribute("fig-classes")?' class="image '+r.getAttribute("fig-classes")+'"':' class="image"',f=r.getAttribute("fig-caption")?""+r.getAttribute("fig-caption"):"","true"!==r.getAttribute("is-lazy")){e.next=30;break}if(s=' loading="lazy" width="'+Joomla.selectedMediaFile.width+'" height="'+Joomla.selectedMediaFile.height+'"',0!==Joomla.selectedMediaFile.width&&0!==Joomla.selectedMediaFile.height){e.next=30;break}return e.prev=21,e.next=24,u(Joomla.selectedMediaFile.url);case 24:s=' loading="lazy" width="'+Joomla.selectedMediaFile.width+'" height="'+Joomla.selectedMediaFile.height+'"',e.next=30;break;case 27:e.prev=27,e.t0=e.catch(21),s="";case 30:b=f?"<figure"+m+'><img src="'+Joomla.selectedMediaFile.url+'"'+h+s+d+' data-path="'+Joomla.selectedMediaFile.path+'"/><figcaption>'+f+"</figcaption></figure>":'<img src="'+Joomla.selectedMediaFile.url+'"'+h+s+d+' data-path="'+Joomla.selectedMediaFile.path+'"/>',r&&r.parentNode.removeChild(r),Joomla.editors.instances[i].replaceSelection(b),e.next=47;break;case 35:if(0!==Joomla.selectedMediaFile.width&&0!==Joomla.selectedMediaFile.height){e.next=45;break}return e.prev=36,e.next=39,u(Joomla.selectedMediaFile.url);case 39:e.next=45;break;case 41:e.prev=41,e.t1=e.catch(36),Joomla.selectedMediaFile.height=0,Joomla.selectedMediaFile.width=0;case 45:n.markValid(),n.setValue(Joomla.selectedMediaFile.url+"#joomlaImage://"+t.path.replace(":","")+"?width="+Joomla.selectedMediaFile.width+"&height="+Joomla.selectedMediaFile.height);case 47:case"end":return e.stop()}}),e,null,[[21,27],[36,41]])})));return function(t,i,n){return e.apply(this,arguments)}}(),p=function(e,t,i,n){if(e.url){var a=Joomla.getOptions("system.paths").rootFull,l=e.url.split(a);l.length>1?Joomla.selectedMediaFile.url=l[1]:Joomla.selectedMediaFile.url=e.url}else Joomla.selectedMediaFile.url=!1;var o;if(Joomla.selectedMediaFile.url)if(c(t))i.markValid(),i.givenType=n,i.setValue(Joomla.selectedMediaFile.url);else{var r;if(o=i.closest(".modal-content").querySelector("joomla-field-mediamore")){var s=o.getAttribute("embed-it");if(s&&"true"===s){if("audios"===n&&(r='<audio controls src="'+Joomla.selectedMediaFile.url+'"></audio>'),"documents"===n){var u=o.getAttribute("title");r='<object type="application/'+Joomla.selectedMediaFile.extension+'" data="'+Joomla.selectedMediaFile.url+'" '+(u?'title="'+u+'"':"")+' width="'+o.getAttribute("width")+'" height="'+o.getAttribute("height")+'">\n  '+Joomla.Text._("JFIELD_MEDIA_UNSUPPORTED").replace("{tag}",'<a download href="'+Joomla.selectedMediaFile.url+'">').replace(/{extension}/g,Joomla.selectedMediaFile.extension)+"\n</object>"}"videos"===n&&(r='<video controls width="'+o.getAttribute("width")+'" height="'+o.getAttribute("height")+'">\n  <source src="'+Joomla.selectedMediaFile.url+'" type="'+Joomla.selectedMediaFile.fileType+'">\n</video>')}else if(""!==Joomla.editors.instances[t].getSelection())r='<a download href="'+Joomla.selectedMediaFile.url+'">'+Joomla.editors.instances[t].getSelection()+"</a>";else{var d=/([\w-]+)\./.exec(Joomla.selectedMediaFile.url);r='<a download href="'+Joomla.selectedMediaFile.url+'">'+Joomla.Text._("JFIELD_MEDIA_DOWNLOAD_FILE").replace("{file}",d[1])+"</a>"}}o&&o.parentNode.removeChild(o),Joomla.editors.instances[t].replaceSelection(r)}},h=function(){var e=t(regeneratorRuntime.mark((function e(t,i,n){var a,l,o,r,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!0!==t.success){e.next=12;break}if(a=t.data[0],l=s.images,o=s.audios,r=s.videos,c=s.documents,!Joomla.selectedMediaFile.extension||!l.includes(a.extension.toLowerCase())){e.next=5;break}return e.abrupt("return",d(a,i,n));case 5:if(!Joomla.selectedMediaFile.extension||!o.includes(a.extension.toLowerCase())){e.next=7;break}return e.abrupt("return",p(a,i,n,"audios"));case 7:if(!Joomla.selectedMediaFile.extension||!c.includes(a.extension.toLowerCase())){e.next=9;break}return e.abrupt("return",p(a,i,n,"documents"));case 9:if(!Joomla.selectedMediaFile.extension||!r.includes(a.extension.toLowerCase())){e.next=11;break}return e.abrupt("return",p(a,i,n,"videos"));case 11:case 12:return e.abrupt("return","");case 13:case"end":return e.stop()}}),e)})));return function(t,i,n){return e.apply(this,arguments)}}();Joomla.getMedia=function(e,i,n){return new Promise((function(a,l){if(!e||"object"==typeof e&&(!e.path||""===e.path))return Joomla.selectedMediaFile={},void a({resp:{success:!1}});var o=Joomla.getOptions("system.paths").baseFull+"index.php?option=com_media&task=api.files&url=true&path="+e.path+"&mediatypes=0,1,2,3&"+Joomla.getOptions("csrf.token")+"=1&format=json";fetch(o,{method:"GET",headers:{"Content-Type":"application/json"}}).then((function(e){return e.json()})).then(function(){var e=t(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=a,e.next=3,h(t,i,n);case 3:return e.t1=e.sent,e.abrupt("return",(0,e.t0)(e.t1));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return l(e)}))}))},Joomla.getImage=Joomla.getMedia;var m=function(e){var t,n;function l(){return e.apply(this,arguments)||this}n=e,(t=l).prototype=Object.create(n.prototype),t.prototype.constructor=t,a(t,n);var o,r,s,c=l.prototype;return c.connectedCallback=function(){var e=this;"images"===this.type?(this.innerHTML="<details open>\n<summary>"+this.summarytext+'</summary>\n<div class="">\n  <div class="form-group">\n    <div class="input-group">\n      <label class="input-group-text" for="'+this.parentId+'-alt">'+this.alttext+'</label>\n      <input class="form-control" type="text" id="'+this.parentId+'-alt" data-is="alt-value" />\n    </div>\n  </div>\n  <div class="form-group">\n    <div class="form-check">\n      <input class="form-check-input" type="checkbox" id="'+this.parentId+'-alt-check">\n      <label class="form-check-label" for="'+this.parentId+'-alt-check">'+this.altchecktext+'</label>\n      <div><small class="form-text">'+this.altcheckdesctext+'</small></div>\n    </div>\n  </div>\n  <div class="form-group">\n    <div class="form-check">\n      <input class="form-check-input" type="checkbox" id="'+this.parentId+'-lazy" checked>\n      <label class="form-check-label" for="'+this.parentId+'-lazy">'+this.lazytext+'</label>\n    </div>\n  </div>\n  <div class="form-group">\n    <div class="input-group">\n      <label class="input-group-text" for="'+this.parentId+'-classes">'+this.classestext+'</label>\n      <input class="form-control" type="text" id="'+this.parentId+'-classes" data-is="img-classes"/>\n    </div>\n  </div>\n  <div class="form-group">\n    <div class="input-group">\n      <label class="input-group-text" for="'+this.parentId+'-figclasses">'+this.figclassestext+'</label>\n      <input class="form-control" type="text" id="'+this.parentId+'-figclasses" data-is="fig-classes"/>\n    </div>\n  </div>\n  <div class="form-group">\n    <div class="input-group">\n      <label class="input-group-text" for="'+this.parentId+'-figcaption">'+this.figcaptiontext+'</label>\n      <input class="form-control" type="text" id="'+this.parentId+'-figcaption" data-is="fig-caption"/>\n    </div>\n  </div>\n</div>\n</details>',this.lazyInputFn=this.lazyInputFn.bind(this),this.altCheckFn=this.altCheckFn.bind(this),this.inputFn=this.inputFn.bind(this),this.lazyInput=this.querySelector("#"+this.parentId+"-lazy"),this.lazyInput.addEventListener("change",this.lazyInputFn),this.altCheck=this.querySelector("#"+this.parentId+"-alt-check"),this.altCheck.addEventListener("input",this.altCheckFn),[].slice.call(this.querySelectorAll('input[type="text"]')).map((function(t){t.addEventListener("input",e.inputFn);var i=t.dataset.is;return i&&e.setAttribute(i,t.value.replace(/"/g,"&quot;")),t})),this.setAttribute("is-lazy",!!this.lazyInput.checked),this.setAttribute("alt-check",!1)):["audios","videos","documents"].includes(this.type)&&(this.innerHTML="<details open>\n<summary>"+this.summarytext+'</summary>\n<div class="">\n  <div class="form-group">\n    <div class="form-check">\n      <input class="form-check-input radio" type="radio" name="flexRadioDefault" id="'+this.parentId+'-embed-check-2" value="0" checked>\n      <label class="form-check-label" for="'+this.parentId+'-embed-check-2">\n        '+this.downloadchecktext+'\n        <div><small class="form-text">'+this.downloadcheckdesctext+'</small></div>\n      </label>\n    </div>\n    <div class="form-check">\n      <input class="form-check-input radio" type="radio" name="flexRadioDefault" id="'+this.parentId+'-embed-check-1" value="1">\n      <label class="form-check-label" for="'+this.parentId+'-embed-check-1">\n        '+this.embedchecktext+'\n        <div><small class="form-text">'+this.embedcheckdesctext+'</small></div>\n      </label>\n    </div>\n  </div>\n  <div class="toggable-parts" style="display: none">\n    <div style="display: '+("audios"===this.type?"none":"block")+'">\n      <div class="form-group">\n        <div class="input-group">\n          <label class="input-group-text" for="'+this.parentId+'-width">'+this.widthtext+'</label>\n          <input class="form-control" type="text" id="'+this.parentId+'-width" value="800" data-is="width"/>\n        </div>\n      </div>\n      <div class="form-group">\n        <div class="input-group">\n          <label class="input-group-text" for="'+this.parentId+'-height">'+this.heighttext+'</label>\n          <input class="form-control" type="text" id="'+this.parentId+'-height" value="600" data-is="height"/>\n        </div>\n      </div>\n      <div style="display: '+("document"===this.type?"block":"none")+'">\n        <div class="form-group">\n          <div class="input-group">\n            <label class="input-group-text" for="'+this.parentId+'-title">'+this.titletext+'</label>\n            <input class="form-control" type="text" id="'+this.parentId+'-title" value="" data-is="title"/>\n          </div>\n        </div>\n    </div>\n  </div>\n</div>\n</details>',this.embedInputFn=this.embedInputFn.bind(this),this.inputFn=this.inputFn.bind(this),[].slice.call(this.querySelectorAll(".form-check-input.radio")).map((function(t){return t.addEventListener("input",e.embedInputFn)})),this.setAttribute("embed-it",!1),[].slice.call(this.querySelectorAll('input[type="text"]')).map((function(t){t.addEventListener("input",e.inputFn);var i=t.dataset.is;return i&&e.setAttribute(i,t.value.replace(/"/g,"&quot;")),t})))},c.disconnectedCallback=function(){var e=this;"image"===this.type&&(this.lazyInput.removeEventListener("input",this.lazyInputFn),this.altInput.removeEventListener("input",this.inputFn),this.altCheck.removeEventListener("input",this.altCheckFn)),["audio","video","document"].includes(this.type)&&([].slice.call(this.querySelectorAll(".form-check-input.radio")).map((function(t){return t.removeEventListener("input",e.embedInputFn)})),[].slice.call(this.querySelectorAll('input[type="text"]')).map((function(t){return t.removeEventListener("input",e.embedInputFn)}))),this.innerHTML=""},c.lazyInputFn=function(e){this.setAttribute("is-lazy",!!e.target.checked)},c.altCheckFn=function(e){this.setAttribute("alt-check",!!e.target.checked)},c.inputFn=function(e){var t=e.target.dataset.is;t&&this.setAttribute(t,e.target.value.replace(/"/g,"&quot;"))},c.embedInputFn=function(e){var t=e.target.value;this.setAttribute("embed-it","0"!==t);var i=this.querySelector(".toggable-parts");i&&("block"!==i.style.display?i.style.display="block":i.style.display="none")},o=l,(r=[{key:"type",get:function(){return this.getAttribute("type")}},{key:"parentId",get:function(){return this.getAttribute("parent-id")}},{key:"lazytext",get:function(){return this.getAttribute("lazy-label")}},{key:"alttext",get:function(){return this.getAttribute("alt-label")}},{key:"altchecktext",get:function(){return this.getAttribute("alt-check-label")}},{key:"altcheckdesctext",get:function(){return this.getAttribute("alt-check-desc-label")}},{key:"embedchecktext",get:function(){return this.getAttribute("embed-check-label")}},{key:"embedcheckdesctext",get:function(){return this.getAttribute("embed-check-desc-label")}},{key:"downloadchecktext",get:function(){return this.getAttribute("download-check-label")}},{key:"downloadcheckdesctext",get:function(){return this.getAttribute("download-check-desc-label")}},{key:"classestext",get:function(){return this.getAttribute("classes-label")}},{key:"figclassestext",get:function(){return this.getAttribute("figure-classes-label")}},{key:"figcaptiontext",get:function(){return this.getAttribute("figure-caption-label")}},{key:"summarytext",get:function(){return this.getAttribute("summary-label")}},{key:"widthtext",get:function(){return this.getAttribute("width-label")}},{key:"heighttext",get:function(){return this.getAttribute("height-label")}},{key:"titletext",get:function(){return this.getAttribute("title-label")}}])&&i(o.prototype,r),s&&i(o,s),Object.defineProperty(o,"prototype",{writable:!1}),l}(r(HTMLElement));customElements.define("joomla-field-mediamore",m)}();


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer