diff --git a/media/system/js/core.js b/media/system/js/core.js
index fd4d5d0e39fba..8afc165e93c75 100644
--- a/media/system/js/core.js
+++ b/media/system/js/core.js
@@ -235,7 +235,7 @@ Joomla.editors.instances = Joomla.editors.instances || {
}
}
};
-
+
/**
* USED IN: administrator/components/com_banners/views/client/tmpl/default.php
* Actually, probably not used anywhere. Can we deprecate in favor of ?
@@ -928,3 +928,78 @@ Joomla.editors.instances = Joomla.editors.instances || {
};
}( Joomla, document ));
+
+/**
+ * Joomla! Custom events
+ *
+ * @since __DEPLOY_VERSION__
+ */
+(function( window, Joomla ) {
+ "use strict";
+
+ if (Joomla.Event) {
+ return;
+ }
+
+ Joomla.Event = {};
+
+ /**
+ * Dispatch custom event.
+ *
+ * An event name convention:
+ * The event name has at least two part, separated ":", eg `foo:bar`. Where the first part is an "event supporter",
+ * and second part is the event name which happened.
+ * Which is allow us to avoid possible collisions with another scripts and native DOM events.
+ * Joomla! CMS standard events should start from `joomla:`.
+ *
+ * Joomla! events:
+ * `joomla:updated` Dispatch it over the changed container, example after the content was updated via ajax
+ * `joomla:removed` The container was removed
+ *
+ * @param {HTMLElement|string} element DOM element, the event target. Or the event name, then the target will be a Window
+ * @param {String|Object} name The event name, or an optional parameters in case when "element" is an event name
+ * @param {Object} params An optional parameters. Allow to send a custom data through the event.
+ *
+ * @example
+ *
+ * Joomla.Event.dispatch(myElement, 'joomla:updated', {for: 'bar', foo2: 'bar2'}); // Will dispatch event to myElement
+ * or:
+ * Joomla.Event.dispatch('joomla:updated', {for: 'bar', foo2: 'bar2'}); // Will dispatch event to Window
+ *
+ * @since __DEPLOY_VERSION__
+ */
+ Joomla.Event.dispatch = function(element, name, params) {
+ if (typeof element === 'string') {
+ params = name;
+ name = element;
+ element = window;
+ }
+ params = params || {};
+
+ var event = new CustomEvent(name, {
+ detail: params,
+ bubbles: true,
+ cancelable: true
+ });
+ element.dispatchEvent(event);
+ };
+
+ /**
+ * Once listener. Add EventListener to the Element and auto-remove it after the event was dispatched.
+ *
+ * @param {HTMLElement} element DOM element
+ * @param {String} name The event name
+ * @param {Function} callback The event callback
+ *
+ * @since __DEPLOY_VERSION__
+ */
+ Joomla.Event.listenOnce = function (element, name, callback) {
+ var onceCallback = function(event){
+ element.removeEventListener(name, onceCallback);
+ return callback.call(element, event)
+ };
+
+ element.addEventListener(name, onceCallback);
+ };
+
+})( window, Joomla );
diff --git a/media/system/js/core.min.js b/media/system/js/core.min.js
index 2ef95a5004f91..8be879ff55301 100644
--- a/media/system/js/core.min.js
+++ b/media/system/js/core.min.js
@@ -1 +1 @@
-Joomla=window.Joomla||{},Joomla.editors=Joomla.editors||{},Joomla.editors.instances=Joomla.editors.instances||{},function(a,b){"use strict";a.submitform=function(a,c,d){c||(c=b.getElementById("adminForm")),a&&(c.task.value=a),c.noValidate=!d,c.setAttribute("novalidate",!d);var e=b.createElement("input");e.style.display="none",e.type="submit",c.appendChild(e).click(),c.removeChild(e)},a.submitbutton=function(c){var d=b.querySelectorAll("form.form-validate");if(d.length>0)for(var e=0,f=d.length;e=0;m--)n=b.createElement("div"),n.innerHTML=i[m],j.appendChild(n);g.appendChild(j),f&&parseInt(f)>0&&setTimeout(function(){a.removeMessages(g)},f)}},a.removeMessages=function(a){var c;for(c=void 0===a?b.getElementById("system-message-container"):a;c.firstChild;)c.removeChild(c.firstChild);c.style.display="none",c.offsetHeight,c.style.display=""},a.ajaxErrorsMessages=function(b,c,d){var e={};if("parsererror"===c){for(var f=b.responseText.trim(),g=[],h=f.length-1;h>=0;h--)g.unshift(["",f[h].charCodeAt(),";"].join(""));f=g.join(""),e.error=[a.JText._("JLIB_JS_AJAX_ERROR_PARSE").replace("%s",f)]}else"nocontent"===c?e.error=[a.JText._("JLIB_JS_AJAX_ERROR_NO_CONTENT")]:"timeout"===c?e.error=[a.JText._("JLIB_JS_AJAX_ERROR_TIMEOUT")]:"abort"===c?e.error=[a.JText._("JLIB_JS_AJAX_ERROR_CONNECTION_ABORT")]:b.responseJSON&&b.responseJSON.message?e.error=[a.JText._("JLIB_JS_AJAX_ERROR_OTHER").replace("%s",b.status)+" "+b.responseJSON.message+""]:b.statusText?e.error=[a.JText._("JLIB_JS_AJAX_ERROR_OTHER").replace("%s",b.status)+" "+b.statusText+""]:e.error=[a.JText._("JLIB_JS_AJAX_ERROR_OTHER").replace("%s",b.status)];return e},a.isChecked=function(a,c){if(void 0===c&&(c=b.getElementById("adminForm")),c.boxchecked.value=a?parseInt(c.boxchecked.value)+1:parseInt(c.boxchecked.value)-1,c.elements["checkall-toggle"]){var d,e,f,g=!0;for(d=0,f=c.elements.length;d",l=d==e,m=0;for(i in c)c.hasOwnProperty(i)&&(j=c[i],j[0]==d&&(h="",(l&&f==j[1]||!l&&0===m)&&(h='selected="selected"'),k+='",m++));k+="",g?g.innerHTML=k:b.writeln(k)},window.changeDynaList=function(a,c,d,e,f){for(var g,h,i,j,k=b.adminForm[a],l=d==e;k.firstChild;)k.removeChild(k.firstChild);g=0;for(h in c)c.hasOwnProperty(h)&&(i=c[h],i[0]==d&&(j=new Option,j.value=i[1],j.text=i[2],(l&&f==j.value||!l&&0===g)&&(j.selected=!0),k.options[g++]=j));k.length=g},window.radioGetCheckedValue=function(a){if(!a)return"";var b,c=a.length;if(void 0===c)return a.checked?a.value:"";for(b=0;b-1?d.options[e].value:null},window.listItemTask=function(a,c){var d,e=b.adminForm,f=0,g=e[a];if(!g)return!1;for(;;){if(!(d=e["cb"+f]))break;d.checked=!1,f++}return g.checked=!0,e.boxchecked.value=1,window.submitform(c),!1},window.submitbutton=function(b){a.submitbutton(b)},window.submitform=function(b){a.submitform(b)},window.saveorder=function(a,b){window.checkAll_button(a,b)},window.checkAll_button=function(c,d){d=d||"saveorder";var e,f;for(e=0;e<=c;e++){if(!(f=b.adminForm["cb"+e]))return void alert("You cannot change the order of items, as an item in the list is `Checked Out`");f.checked=!0}a.submitform(d)},a.loadingLayer=function(c,d){if(c=c||"show",d=d||b.body,"load"==c){var e=b.getElementsByTagName("body")[0].getAttribute("data-basepath")||"",f=b.createElement("div");f.id="loading-logo",f.style.position="fixed",f.style.top="0",f.style.left="0",f.style.width="100%",f.style.height="100%",f.style.opacity="0.8",f.style.filter="alpha(opacity=80)",f.style.overflow="hidden",f.style["z-index"]="10000",f.style.display="none",f.style["background-color"]="#fff",f.style["background-image"]='url("'+e+'/media/system/images/ajax-loader.gif")',f.style["background-position"]="center",f.style["background-repeat"]="no-repeat",f.style["background-attachment"]="fixed",d.appendChild(f)}else b.getElementById("loading-logo")||a.loadingLayer("load",d),b.getElementById("loading-logo").style.display="show"==c?"block":"none";return b.getElementById("loading-logo")},a.extend=function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},a.request=function(b){b=a.extend({url:"",method:"GET",data:null,perform:!0},b),b.method=b.data?"POST":b.method;try{var c=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");if(c.open(b.method,b.url,!0),c.setRequestHeader("X-Requested-With","XMLHttpRequest"),c.setRequestHeader("X-Ajax-Engine","Joomla!"),"POST"!==b.method||b.headers&&b.headers["Content-Type"]||c.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),b.headers)for(var d in b.headers)b.headers.hasOwnProperty(d)&&c.setRequestHeader(d,b.headers[d]);if(c.onreadystatechange=function(){4===c.readyState&&(200===c.status?b.onSuccess&&b.onSuccess.call(window,c.responseText,c):b.onError&&b.onError.call(window,c))},b.perform){if(b.onBefore&&!1===b.onBefore.call(window,c))return c;c.send(b.data)}}catch(a){return window.console&&console.log(a),!1}return c}}(Joomla,document);
\ No newline at end of file
+Joomla=window.Joomla||{};Joomla.editors=Joomla.editors||{};Joomla.editors.instances=Joomla.editors.instances||{};(function(Joomla,document){"use strict";Joomla.submitform=function(task,form,validate){if(!form){form=document.getElementById("adminForm")}if(task){form.task.value=task}form.noValidate=!validate;form.setAttribute("novalidate",!validate);var button=document.createElement("input");button.style.display="none";button.type="submit";form.appendChild(button).click();form.removeChild(button)};Joomla.submitbutton=function(task){var form=document.querySelectorAll("form.form-validate");if(form.length>0){for(var i=0,j=form.length;i=0;i--){messageWrapper=document.createElement("div");messageWrapper.innerHTML=typeMessages[i];messagesBox.appendChild(messageWrapper)}messageContainer.appendChild(messagesBox);if(timeout&&parseInt(timeout)>0){setTimeout(function(){Joomla.removeMessages(messageContainer)},timeout)}}};Joomla.removeMessages=function(container){var messageContainer;if(typeof container==="undefined"){messageContainer=document.getElementById("system-message-container")}else{messageContainer=container}while(messageContainer.firstChild)messageContainer.removeChild(messageContainer.firstChild);messageContainer.style.display="none";messageContainer.offsetHeight;messageContainer.style.display=""};Joomla.ajaxErrorsMessages=function(xhr,textStatus,error){var msg={};if(textStatus==="parsererror"){var encodedJson=xhr.responseText.trim();var buf=[];for(var i=encodedJson.length-1;i>=0;i--){buf.unshift(["",encodedJson[i].charCodeAt(),";"].join(""))}encodedJson=buf.join("");msg.error=[Joomla.JText._("JLIB_JS_AJAX_ERROR_PARSE").replace("%s",encodedJson)]}else if(textStatus==="nocontent"){msg.error=[Joomla.JText._("JLIB_JS_AJAX_ERROR_NO_CONTENT")]}else if(textStatus==="timeout"){msg.error=[Joomla.JText._("JLIB_JS_AJAX_ERROR_TIMEOUT")]}else if(textStatus==="abort"){msg.error=[Joomla.JText._("JLIB_JS_AJAX_ERROR_CONNECTION_ABORT")]}else if(xhr.responseJSON&&xhr.responseJSON.message){msg.error=[Joomla.JText._("JLIB_JS_AJAX_ERROR_OTHER").replace("%s",xhr.status)+" "+xhr.responseJSON.message+""]}else if(xhr.statusText){msg.error=[Joomla.JText._("JLIB_JS_AJAX_ERROR_OTHER").replace("%s",xhr.status)+" "+xhr.statusText+""]}else{msg.error=[Joomla.JText._("JLIB_JS_AJAX_ERROR_OTHER").replace("%s",xhr.status)]}return msg};Joomla.isChecked=function(isitchecked,form){if(typeof form==="undefined"){form=document.getElementById("adminForm")}form.boxchecked.value=isitchecked?parseInt(form.boxchecked.value)+1:parseInt(form.boxchecked.value)-1;if(!form.elements["checkall-toggle"])return;var c=true,i,e,n;for(i=0,n=form.elements.length;i",hasSelection=key==orig_key,i=0,selected,x,item;for(x in source){if(!source.hasOwnProperty(x)){continue}item=source[x];if(item[0]!=key){continue}selected="";if(hasSelection&&orig_val==item[1]||!hasSelection&&i===0){selected='selected="selected"'}html+='";i++}html+="";if(element){element.innerHTML=html}else{document.writeln(html)}};window.changeDynaList=function(listname,source,key,orig_key,orig_val){var list=document.adminForm[listname],hasSelection=key==orig_key,i,x,item,opt;while(list.firstChild)list.removeChild(list.firstChild);i=0;for(x in source){if(!source.hasOwnProperty(x)){continue}item=source[x];if(item[0]!=key){continue}opt=new Option;opt.value=item[1];opt.text=item[2];if(hasSelection&&orig_val==opt.value||!hasSelection&&i===0){opt.selected=true}list.options[i++]=opt}list.length=i};window.radioGetCheckedValue=function(radioObj){if(!radioObj){return""}var n=radioObj.length,i;if(n===undefined){return radioObj.checked?radioObj.value:""}for(i=0;i-1){return srcList.options[i].value}else{return null}};window.listItemTask=function(id,task){var f=document.adminForm,i=0,cbx,cb=f[id];if(!cb)return false;while(true){cbx=f["cb"+i];if(!cbx)break;cbx.checked=false;i++}cb.checked=true;f.boxchecked.value=1;window.submitform(task);return false};window.submitbutton=function(pressbutton){Joomla.submitbutton(pressbutton)};window.submitform=function(pressbutton){Joomla.submitform(pressbutton)};window.saveorder=function(n,task){window.checkAll_button(n,task)};window.checkAll_button=function(n,task){task=task?task:"saveorder";var j,box;for(j=0;j<=n;j++){box=document.adminForm["cb"+j];if(box){box.checked=true}else{alert("You cannot change the order of items, as an item in the list is `Checked Out`");return}}Joomla.submitform(task)};Joomla.loadingLayer=function(task,parentElement){task=task||"show";parentElement=parentElement||document.body;if(task=="load"){var basePath=document.getElementsByTagName("body")[0].getAttribute("data-basepath")||"";var loadingDiv=document.createElement("div");loadingDiv.id="loading-logo";loadingDiv.style["position"]="fixed";loadingDiv.style["top"]="0";loadingDiv.style["left"]="0";loadingDiv.style["width"]="100%";loadingDiv.style["height"]="100%";loadingDiv.style["opacity"]="0.8";loadingDiv.style["filter"]="alpha(opacity=80)";loadingDiv.style["overflow"]="hidden";loadingDiv.style["z-index"]="10000";loadingDiv.style["display"]="none";loadingDiv.style["background-color"]="#fff";loadingDiv.style["background-image"]='url("'+basePath+'/media/system/images/ajax-loader.gif")';loadingDiv.style["background-position"]="center";loadingDiv.style["background-repeat"]="no-repeat";loadingDiv.style["background-attachment"]="fixed";parentElement.appendChild(loadingDiv)}else{if(!document.getElementById("loading-logo")){Joomla.loadingLayer("load",parentElement)}document.getElementById("loading-logo").style["display"]=task=="show"?"block":"none"}return document.getElementById("loading-logo")};Joomla.extend=function(destination,source){for(var p in source){if(source.hasOwnProperty(p)){destination[p]=source[p]}}return destination};Joomla.request=function(options){options=Joomla.extend({url:"",method:"GET",data:null,perform:true},options);options.method=options.data?"POST":options.method;try{var xhr=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");xhr.open(options.method,options.url,true);xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("X-Ajax-Engine","Joomla!");if(options.method==="POST"&&(!options.headers||!options.headers["Content-Type"])){xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}if(options.headers){for(var p in options.headers){if(options.headers.hasOwnProperty(p)){xhr.setRequestHeader(p,options.headers[p])}}}xhr.onreadystatechange=function(){if(xhr.readyState!==4)return;if(xhr.status===200){if(options.onSuccess){options.onSuccess.call(window,xhr.responseText,xhr)}}else if(options.onError){options.onError.call(window,xhr)}};if(options.perform){if(options.onBefore&&options.onBefore.call(window,xhr)===false){return xhr}xhr.send(options.data)}}catch(error){window.console?console.log(error):null;return false}return xhr}})(Joomla,document);(function(Joomla,document,window){"use strict";if(Joomla.Event){return}Joomla.Event={};Joomla.Event.dispatch=function(element,name,params){if(typeof element==="string"){params=name;name=element;element=window}params=params||{};var event=new CustomEvent(name,{detail:params,bubbles:true,cancelable:true});element.dispatchEvent(event)};Joomla.Event.listenOnce=function(element,name,callback){var onceCallback=function(event){element.removeEventListener(name,onceCallback);return callback.call(element,event)};element.addEventListener(name,onceCallback)}})(Joomla,document,window);
\ No newline at end of file
diff --git a/media/system/js/fields/calendar.js b/media/system/js/fields/calendar.js
index 9247c05273a09..dc99b02988bfd 100644
--- a/media/system/js/fields/calendar.js
+++ b/media/system/js/fields/calendar.js
@@ -1124,19 +1124,20 @@
window.JoomlaCalendar = JoomlaCalendar;
- /** Instantiate all the calendar fields when the document is ready */
- document.addEventListener("DOMContentLoaded", function() {
- var elements, i;
-
- elements = document.querySelectorAll(".field-calendar");
+ /**
+ * Instantiate all the calendar fields when the document is ready/updated
+ * @param {Event} event
+ * @private
+ */
+ function _initCalendars(event) {
+ var elements = event.target.querySelectorAll(".field-calendar");
- for (i = 0; i < elements.length; i++) {
+ for (var i = 0, l = elements.length; i < l; i++) {
JoomlaCalendar.init(elements[i]);
}
-
- window.jQuery && jQuery(document).on("subform-row-add", function (event, row) {
- JoomlaCalendar.init(".field-calendar", row);
- });
+ }
+ document.addEventListener("DOMContentLoaded", _initCalendars);
+ document.addEventListener("joomla:updated", _initCalendars);
/** B/C related code
* @deprecated 4.0
@@ -1211,5 +1212,5 @@
}
return null;
};
- });
+
})(window, document);
diff --git a/media/system/js/fields/calendar.min.js b/media/system/js/fields/calendar.min.js
index 50cf551911f61..111d1d0c1736c 100644
--- a/media/system/js/fields/calendar.min.js
+++ b/media/system/js/fields/calendar.min.js
@@ -1 +1 @@
-!function(a,b){"use strict";Date.convertNumbers=function(a){var a=a.toString();if("[object Array]"===Object.prototype.toString.call(JoomlaCalLocale.localLangNumbers))for(var b=0;b0;)for(var f=e[--d],g=f.getElementsByTagName("td"),h=g.length;h>0;){g[--h]}this.dropdownElement.style.display="block",this.hidden=!1,b.addEventListener("keydown",this._calKeyEvent,!0),b.addEventListener("keypress",this._calKeyEvent,!0),b.addEventListener("mousedown",this._documentClick,!0);var i=this.element.querySelector(".js-calendar");a.innerHeight+a.scrollYc.params.minYear&&f.setOtherFullYear(c.params.dateType,h-1);break;case-1:var j=f.getLocalDate(c.params.dateType);if(i>0){var k=f.getLocalMonthDays(c.params.dateType,i-1);j>k&&f.setLocalDate(c.params.dateType,k),f.setLocalMonth(c.params.dateType,i-1)}else if(h-- >c.params.minYear){f.setOtherFullYear(c.params.dateType,h);var k=f.getLocalMonthDays(c.params.dateType,11);j>k&&f.setLocalDate(c.params.dateType,k),f.setLocalMonth(c.params.dateType,11)}break;case 1:var j=f.getLocalDate(c.params.dateType);if(i<11){var k=f.getLocalMonthDays(c.params.dateType,i+1);j>k&&f.setLocalDate(c.params.dateType,k),f.setLocalMonth(c.params.dateType,i+1)}else if(hk&&f.setLocalDate(c.params.dateType,k),f.setLocalMonth(c.params.dateType,0)}break;case 2:c.params.compressedHeader||h48||c<57||186===c||189===c||190===c||32===c))return d(a)},c.prototype._create=function(){var a=this,b=this.element,c=e("table"),d=e("div");this.table=c,c.className="table",c.cellSpacing=0,c.cellPadding=0,c.style.marginBottom=0,this.dropdownElement=d,b.appendChild(d),this.params.direction&&(d.style.direction=this.params.direction),d.className="js-calendar",d.style.position="absolute",d.style.boxShadow="0px 0px 70px 0px rgba(0,0,0,0.67)",d.style.minWidth=this.inputField.width,d.style.padding="0",d.style.display="none",d.style.left="auto",d.style.top="auto",d.style.zIndex=1060,d.style.borderRadius="20px",this.wrapper=e("div"),this.wrapper.className="calendar-container",d.appendChild(this.wrapper),this.wrapper.appendChild(c);var f=e("thead",c);f.className="calendar-header";var g=null,h=null,i=this,j=function(b,c,d,f,j,k,l){f=f||"td",j=j||{},g=e(f,h),c&&(k=k?'class="'+k+'"':"",g.colSpan=c);for(var m in j)g.style[m]=j[m];for(var m in l)g.setAttribute(m,l[m]);return 0!=d&&Math.abs(d)<=2&&(g.className+=" nav"),c&&g.addEventListener("mousedown",a._dayMouseDown,!0),g.calendar=i,g.navtype=d,0!=d&&Math.abs(d)<=2?g.innerHTML=""+b+"":(g.innerHTML=c?"