CoreFiles by mySites.guru
joomla-field-media-es5.min.js1 lines, 17,963 bytes, from Joomla_4.3.0-Stable-Full_Package.zip
Raw History Compare with 4.2.9
md5
06caadc4baf5135ee047ba87a02fa7d7
sha1
f159c258ca7f2efc24fa25b54f37f8728c2c9eb7
sha256
255fb2ed94440e863ce2d4ad403843333c366d94bb4c66d37b5b9681b707616d
!function(){"use strict";function t(){t=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function c(t,e,n,r){var o=e&&e.prototype instanceof p?e:p,a=Object.create(o.prototype),u=new x(r||[]);return i(a,"_invoke",{value:k(t,n,u)}),a}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=c;var d={};function p(){}function f(){}function v(){}var m={};l(m,a,(function(){return this}));var y=Object.getPrototypeOf,b=y&&y(y(j([])));b&&b!==n&&r.call(b,a)&&(m=b);var g=v.prototype=p.prototype=Object.create(m);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){function n(i,o,a,u){var s=h(t[i],t,o);if("throw"!==s.type){var l=s.arg,c=l.value;return c&&"object"==typeof c&&r.call(c,"__await")?e.resolve(c.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(c).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,r){function i(){return new e((function(e,i){n(t,r,e,i)}))}return o=o?o.then(i,i):i()}})}function k(t,e,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return S()}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var u=A(a,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=h(t,e,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===d)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}function A(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,A(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=h(r,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,d;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function j(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:S}}function S(){return{value:void 0,done:!0}}return f.prototype=v,i(g,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:f,configurable:!0}),f.displayName=l(v,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,l(t,s,"GeneratorFunction")),t.prototype=Object.create(g),t},e.awrap=function(t){return{__await:t}},w(E.prototype),l(E.prototype,u,(function(){return this})),e.AsyncIterator=E,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new E(c(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(g),l(g,s,"Generator"),l(g,a,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=j,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),s=r.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;O(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:j(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),d}},e}function e(t,e,n,r,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void n(t)}u.done?e(s):Promise.resolve(s).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise((function(i,o){var a=t.apply(n,r);function u(t){e(a,i,o,u,s,"next",t)}function s(t){e(a,i,o,u,s,"throw",t)}u(void 0)}))}}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(i=r.key,o=void 0,"symbol"==typeof(o=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(i,"string"))?o:String(o)),r)}var i,o}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function a(t,e,n){return a=function(){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(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&o(i,n.prototype),i},a.apply(null,arguments)}function u(t){var e="function"==typeof Map?new Map:void 0;return u=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return a(t,arguments,i(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),o(r,t)},u(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}if(!Joomla)throw new Error("Joomla API is not properly initiated");var l=function(e){var i,a;function u(){var t;return(t=e.call(this)||this).onSelected=t.onSelected.bind(s(t)),t.show=t.show.bind(s(t)),t.clearValue=t.clearValue.bind(s(t)),t.modalClose=t.modalClose.bind(s(t)),t.setValue=t.setValue.bind(s(t)),t.updatePreview=t.updatePreview.bind(s(t)),t.validateValue=t.validateValue.bind(s(t)),t.markValid=t.markValid.bind(s(t)),t.markInvalid=t.markInvalid.bind(s(t)),t.mimeType="",t}a=e,(i=u).prototype=Object.create(a.prototype),i.prototype.constructor=i,o(i,a);var l,c,h,d=u.prototype;return d.connectedCallback=function(){if(this.button=this.querySelector(this.buttonSelect),this.inputElement=this.querySelector(this.input),this.buttonClearEl=this.querySelector(this.buttonClear),this.modalElement=this.querySelector(".joomla-modal"),this.buttonSaveSelectedElement=this.querySelector(this.buttonSaveSelected),this.previewElement=this.querySelector(".field-media-preview"),!(this.button&&this.inputElement&&this.buttonClearEl&&this.modalElement&&this.buttonSaveSelectedElement))throw new Error("Misconfiguaration...");if(this.button.addEventListener("click",this.show),this.modalElement&&window.bootstrap&&window.bootstrap.Modal&&!window.bootstrap.Modal.getInstance(this.modalElement)&&Joomla.initialiseModal(this.modalElement,{isJoomla:!0}),this.buttonClearEl&&this.buttonClearEl.addEventListener("click",this.clearValue),this.supportedExtensions=Joomla.getOptions("media-picker",{}),!Object.keys(this.supportedExtensions).length)throw new Error("Joomla API is not properly initiated");this.inputElement.removeAttribute("readonly"),this.inputElement.addEventListener("change",this.validateValue),this.updatePreview()},d.disconnectedCallback=function(){this.button&&this.button.removeEventListener("click",this.show),this.buttonClearEl&&this.buttonClearEl.removeEventListener("click",this.clearValue),this.inputElement&&this.inputElement.removeEventListener("change",this.validateValue)},d.onSelected=function(t){return t.preventDefault(),t.stopPropagation(),this.modalClose(),!1},d.show=function(){this.modalElement.open(),Joomla.selectedMediaFile={},this.buttonSaveSelectedElement.addEventListener("click",this.onSelected)},d.modalClose=function(){var e=n(t().mark((function e(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Joomla.getMedia(Joomla.selectedMediaFile,this.inputElement,this);case 3:t.next=8;break;case 5:t.prev=5,t.t0=t.catch(0),Joomla.renderMessages({error:[Joomla.Text._("JLIB_APPLICATION_ERROR_SERVER")]});case 8:Joomla.selectedMediaFile={},Joomla.Modal.getCurrent().close();case 10:case"end":return t.stop()}}),e,this,[[0,5]])})));return function(){return e.apply(this,arguments)}}(),d.setValue=function(t){this.inputElement.value=t,this.validatedUrl=t,this.mimeType=Joomla.selectedMediaFile.fileType,this.updatePreview(),this.inputElement.dispatchEvent(new Event("change")),this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0}))},d.validateValue=function(){var e=n(t().mark((function e(n){var r,i,o,a,u=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.target.value,this.validatedUrl!==r&&""!==r){t.next=3;break}return t.abrupt("return");case 3:if(/^(http(s)?:\/\/).+$/.test(r))try{fetch(r).then((function(t){200===t.status?(u.validatedUrl=r,u.markValid()):(u.validatedUrl=r,u.markInvalid())}))}catch(t){this.validatedUrl=r,this.markInvalid()}else/^\//.test(r)&&(r=r.substring(1)),i=r.split("#"),o=i[0].split("/"),a=o.slice(1),fetch(Joomla.getOptions("system.paths").rootFull+"/"+r).then((function(t){return t.blob()})).then((function(t){if(t.type.includes("image")){var e=new Image;e.src=URL.createObjectURL(t),e.onload=function(){u.inputElement.value=o[0]+"/"+a.join("/")+"#joomlaImage://local-"+o[0]+"/"+a.join("/")+"?width="+e.width+"&height="+e.height,u.validatedUrl=o[0]+"/"+a.join("/")+"#joomlaImage://local-"+o[0]+"/"+a.join("/")+"?width="+e.width+"&height="+e.height,u.markValid()}}else t.type.includes("audio")||t.type.includes("video")||t.type.includes("application/pdf")?(u.mimeType=t.type,u.inputElement.value=r,u.validatedUrl=r,u.markValid()):(u.validatedUrl=r,u.markInvalid())})).catch((function(){u.setValue(r),u.validatedUrl=r,u.markInvalid()}));case 4:case"end":return t.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),d.markValid=function(){this.inputElement.removeAttribute("required"),this.inputElement.removeAttribute("pattern"),document.formvalidator&&document.formvalidator.validate(this.inputElement)},d.markInvalid=function(){this.inputElement.setAttribute("required",""),this.inputElement.setAttribute("pattern","/^(http://INVALID/).+$/"),document.formvalidator&&document.formvalidator.validate(this.inputElement)},d.clearValue=function(){this.setValue(""),this.validatedUrl="",this.inputElement.removeAttribute("required"),this.inputElement.removeAttribute("pattern"),document.formvalidator&&document.formvalidator.validate(this.inputElement)},d.updatePreview=function(){var t,e,n=this;if(-1!==["true","static"].indexOf(this.preview)&&"false"!==this.preview&&this.previewElement&&this.preview){var r=this.inputElement.value,i=this.supportedExtensions;if(r){var o;this.buttonClearEl.style.display="",this.previewElement.innerHTML="";var a,u=(e=(t=r).split(/[#]/)).length>1?e[1].split(/[?]/)[0].split(".").pop().trim():t.split(/[#?]/)[0].split(".").pop().trim();i.images.includes(u)&&(o="images"),i.audios.includes(u)&&(o="audios"),i.videos.includes(u)&&(o="videos"),i.documents.includes(u)&&(o="documents");var s={images:function(){i.images.includes(u)&&((a=new Image).src=/http/.test(r)?r:Joomla.getOptions("system.paths").rootFull+r,a.setAttribute("alt",""))},audios:function(){i.audios.includes(u)&&((a=document.createElement("audio")).src=/http/.test(r)?r:Joomla.getOptions("system.paths").rootFull+r,a.setAttribute("controls",""))},videos:function(){if(i.videos.includes(u)){a=document.createElement("video");var t=document.createElement("source");t.src=/http/.test(r)?r:Joomla.getOptions("system.paths").rootFull+r,t.type=n.mimeType,a.setAttribute("controls",""),a.setAttribute("width",n.previewWidth),a.setAttribute("height",n.previewHeight),a.appendChild(t)}},documents:function(){i.documents.includes(u)&&((a=document.createElement("object")).data=/http/.test(r)?r:Joomla.getOptions("system.paths").rootFull+r,a.type=n.mimeType,a.setAttribute("width",n.previewWidth),a.setAttribute("height",n.previewHeight))}};if(this.givenType&&["images","audios","videos","documents"].includes(this.givenType))s[this.givenType]();else{if(!o||!["images","audios","videos","documents"].includes(o))return;s[o]()}this.previewElement.style.width=this.previewWidth,this.previewElement.appendChild(a)}else this.buttonClearEl.style.display="none",this.previewElement.innerHTML=Joomla.sanitizeHtml('<span class="field-media-preview-icon"></span>')}},l=u,h=[{key:"observedAttributes",get:function(){return["type","base-path","root-folder","url","modal-container","modal-width","modal-height","input","button-select","button-clear","button-save-selected","preview","preview-width","preview-height"]}}],(c=[{key:"type",get:function(){return this.getAttribute("type")},set:function(t){this.setAttribute("type",t)}},{key:"basePath",get:function(){return this.getAttribute("base-path")},set:function(t){this.setAttribute("base-path",t)}},{key:"rootFolder",get:function(){return this.getAttribute("root-folder")},set:function(t){this.setAttribute("root-folder",t)}},{key:"url",get:function(){return this.getAttribute("url")},set:function(t){this.setAttribute("url",t)}},{key:"modalContainer",get:function(){return this.getAttribute("modal-container")},set:function(t){this.setAttribute("modal-container",t)}},{key:"input",get:function(){return this.getAttribute("input")},set:function(t){this.setAttribute("input",t)}},{key:"buttonSelect",get:function(){return this.getAttribute("button-select")},set:function(t){this.setAttribute("button-select",t)}},{key:"buttonClear",get:function(){return this.getAttribute("button-clear")},set:function(t){this.setAttribute("button-clear",t)}},{key:"buttonSaveSelected",get:function(){return this.getAttribute("button-save-selected")},set:function(t){this.setAttribute("button-save-selected",t)}},{key:"modalWidth",get:function(){return parseInt(this.getAttribute("modal-width"),10)},set:function(t){this.setAttribute("modal-width",t)}},{key:"modalHeight",get:function(){return parseInt(this.getAttribute("modal-height"),10)},set:function(t){this.setAttribute("modal-height",t)}},{key:"previewWidth",get:function(){return parseInt(this.getAttribute("preview-width"),10)},set:function(t){this.setAttribute("preview-width",t)}},{key:"previewHeight",get:function(){return parseInt(this.getAttribute("preview-height"),10)},set:function(t){this.setAttribute("preview-height",t)}},{key:"preview",get:function(){return this.getAttribute("preview")},set:function(t){this.setAttribute("preview",t)}},{key:"previewContainer",get:function(){return this.getAttribute("preview-container")}}])&&r(l.prototype,c),h&&r(l,h),Object.defineProperty(l,"prototype",{writable:!1}),u}(u(HTMLElement));customElements.define("joomla-field-media",l)}();

The same content is in 17 releases, Joomla 4.3.0-beta4 to 5.0.0-alpha1. See them all, or every version of this file.