diff --git a/media/system/js/core-uncompressed.js b/media/system/js/core-uncompressed.js index e21a2decc623d..3e3b7c4a34171 100644 --- a/media/system/js/core-uncompressed.js +++ b/media/system/js/core-uncompressed.js @@ -960,7 +960,7 @@ Joomla.editors.instances = Joomla.editors.instances || { xhr.setRequestHeader('X-CSRF-Token', token); } - if (!options.headers || !options.headers['Content-Type']) { + if (typeof(options.data) === 'string' && (!options.headers || !options.headers['Content-Type'])) { xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } } diff --git a/media/system/js/core.js b/media/system/js/core.js index 0109c6d6fb17a..cb0e5a0051ca8 100644 --- a/media/system/js/core.js +++ b/media/system/js/core.js @@ -1 +1 @@ -Joomla=window.Joomla||{},Joomla.editors=Joomla.editors||{},Joomla.editors.instances=Joomla.editors.instances||{},function(e,t){"use strict";e.submitform=function(e,o,n){o||(o=t.getElementById("adminForm")),e&&(o.task.value=e),o.noValidate=!n,n?o.hasAttribute("novalidate")&&o.removeAttribute("novalidate"):o.setAttribute("novalidate","");var r=t.createElement("input");r.style.display="none",r.type="submit",o.appendChild(r).click(),o.removeChild(r)},e.submitbutton=function(t){e.submitform(t)},e.Text={strings:{},_:function(t,o){var n=e.getOptions("joomla.jtext");return n&&(this.load(n),e.loadOptions({"joomla.jtext":null})),o=void 0===o?"":o,t=t.toUpperCase(),void 0!==this.strings[t]?this.strings[t]:o},load:function(e){for(var t in e)e.hasOwnProperty(t)&&(this.strings[t.toUpperCase()]=e[t]);return this}},e.JText=e.Text,e.optionsStorage=e.optionsStorage||null,e.getOptions=function(t,o){return e.optionsStorage||e.loadOptions(),void 0!==e.optionsStorage[t]?e.optionsStorage[t]:o},e.loadOptions=function(o){if(!o){for(var n,r,a,i=t.querySelectorAll(".joomla-script-options.new"),s=0,l=0,d=i.length;l=0;s--)(l=t.createElement("div")).innerHTML=r[s],a.appendChild(l);c.appendChild(a)}},e.removeMessages=function(){for(var e=t.getElementById("system-message-container");e.firstChild;)e.removeChild(e.firstChild);e.style.display="none",e.offsetHeight,e.style.display=""},e.ajaxErrorsMessages=function(t,o,n){var r={};if("parsererror"===o){for(var a=t.responseText.trim(),i=[],s=a.length-1;s>=0;s--)i.unshift(["&#",a[s].charCodeAt(),";"].join(""));a=i.join(""),r.error=[e.JText._("JLIB_JS_AJAX_ERROR_PARSE").replace("%s",a)]}else"nocontent"===o?r.error=[e.JText._("JLIB_JS_AJAX_ERROR_NO_CONTENT")]:"timeout"===o?r.error=[e.JText._("JLIB_JS_AJAX_ERROR_TIMEOUT")]:"abort"===o?r.error=[e.JText._("JLIB_JS_AJAX_ERROR_CONNECTION_ABORT")]:t.responseJSON&&t.responseJSON.message?r.error=[e.JText._("JLIB_JS_AJAX_ERROR_OTHER").replace("%s",t.status)+" "+t.responseJSON.message+""]:t.statusText?r.error=[e.JText._("JLIB_JS_AJAX_ERROR_OTHER").replace("%s",t.status)+" "+t.statusText+""]:r.error=[e.JText._("JLIB_JS_AJAX_ERROR_OTHER").replace("%s",t.status)];return r},e.isChecked=function(e,o){if(void 0===o&&(o=t.getElementById("adminForm")),o.boxchecked.value=e?parseInt(o.boxchecked.value)+1:parseInt(o.boxchecked.value)-1,o.elements["checkall-toggle"]){var n,r,a,i=!0;for(n=0,a=o.elements.length;n-1?n.options[r].value:null},window.listItemTask=function(t,o){return console.warn("window.listItemTask() is deprecated use Joomla.listItemTask() instead"),e.listItemTask(t,o)},e.listItemTask=function(e,o){var n,r=t.adminForm,a=0,i=r[e];if(!i)return!1;for(;n=r["cb"+a];)n.checked=!1,a++;return i.checked=!0,r.boxchecked.value=1,window.submitform(o),!1},window.submitbutton=function(t){console.warn("window.submitbutton() is deprecated use Joomla.submitbutton() instead"),e.submitbutton(t)},window.submitform=function(t){console.warn("window.submitform() is deprecated use Joomla.submitform() instead"),e.submitform(t)},window.saveorder=function(e,t){console.warn("window.saveorder() is deprecated without a replacement!"),window.checkAll_button(e,t)},window.checkAll_button=function(o,n){var r,a;for(console.warn("window.checkAll_button() is deprecated without a replacement!"),n=n||"saveorder",r=0;r<=o;r++){if(!(a=t.adminForm["cb"+r]))return void alert("You cannot change the order of items, as an item in the list is `Checked Out`");a.checked=!0}e.submitform(n)},e.loadingLayer=function(o,n){if(o=o||"show",n=n||t.body,"load"===o){var r=(e.getOptions("system.paths")||{}).root||"",a=t.createElement("div");a.id="loading-logo",a.style.position="fixed",a.style.top="0",a.style.left="0",a.style.width="100%",a.style.height="100%",a.style.opacity="0.8",a.style.filter="alpha(opacity=80)",a.style.overflow="hidden",a.style["z-index"]="10000",a.style.display="none",a.style["background-color"]="#fff",a.style["background-image"]='url("'+r+'/media/jui/images/ajax-loader.gif")',a.style["background-position"]="center",a.style["background-repeat"]="no-repeat",a.style["background-attachment"]="fixed",n.appendChild(a)}else t.getElementById("loading-logo")||e.loadingLayer("load",n),t.getElementById("loading-logo").style.display="show"==o?"block":"none";return t.getElementById("loading-logo")},e.extend=function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o]);return e},e.request=function(t){(t=e.extend({url:"",method:"GET",data:null,perform:!0},t)).method=t.data?"POST":t.method.toUpperCase();try{var o=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");if(o.open(t.method,t.url,!0),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("X-Ajax-Engine","Joomla!"),"POST"===t.method){var n=e.getOptions("csrf.token","");n&&o.setRequestHeader("X-CSRF-Token",n),t.headers&&t.headers["Content-Type"]||o.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}if(t.headers)for(var r in t.headers)t.headers.hasOwnProperty(r)&&o.setRequestHeader(r,t.headers[r]);if(o.onreadystatechange=function(){4===o.readyState&&(200===o.status?t.onSuccess&&t.onSuccess.call(window,o.responseText,o):t.onError&&t.onError.call(window,o))},t.perform){if(t.onBefore&&!1===t.onBefore.call(window,o))return o;o.send(t.data)}}catch(e){return window.console&&console.log(e),!1}return o}}(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;if(!validate){form.setAttribute("novalidate","")}else if(form.hasAttribute("novalidate")){form.removeAttribute("novalidate")}var button=document.createElement("input");button.style.display="none";button.type="submit";form.appendChild(button).click();form.removeChild(button)};Joomla.submitbutton=function(pressbutton){Joomla.submitform(pressbutton)};Joomla.Text={strings:{},_:function(key,def){var newStrings=Joomla.getOptions("joomla.jtext");if(newStrings){this.load(newStrings);Joomla.loadOptions({"joomla.jtext":null})}def=def===undefined?"":def;key=key.toUpperCase();return this.strings[key]!==undefined?this.strings[key]:def},load:function(object){for(var key in object){if(!object.hasOwnProperty(key))continue;this.strings[key.toUpperCase()]=object[key]}return this}};Joomla.JText=Joomla.Text;Joomla.optionsStorage=Joomla.optionsStorage||null;Joomla.getOptions=function(key,def){if(!Joomla.optionsStorage){Joomla.loadOptions()}return Joomla.optionsStorage[key]!==undefined?Joomla.optionsStorage[key]:def};Joomla.loadOptions=function(options){if(!options){var elements=document.querySelectorAll(".joomla-script-options.new"),str,element,option,counter=0;for(var i=0,l=elements.length;i=0;i--){messageWrapper=document.createElement("div");messageWrapper.innerHTML=typeMessages[i];messagesBox.appendChild(messageWrapper)}messageContainer.appendChild(messagesBox)}};Joomla.removeMessages=function(){var messageContainer=document.getElementById("system-message-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-1){return srcList.options[i].value}else{return null}};window.listItemTask=function(id,task){console.warn("window.listItemTask() is deprecated use Joomla.listItemTask() instead");return Joomla.listItemTask(id,task)};Joomla.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){console.warn("window.submitbutton() is deprecated use Joomla.submitbutton() instead");Joomla.submitbutton(pressbutton)};window.submitform=function(pressbutton){console.warn("window.submitform() is deprecated use Joomla.submitform() instead");Joomla.submitform(pressbutton)};window.saveorder=function(n,task){console.warn("window.saveorder() is deprecated without a replacement!");window.checkAll_button(n,task)};window.checkAll_button=function(n,task){console.warn("window.checkAll_button() is deprecated without a replacement!");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 systemPaths=Joomla.getOptions("system.paths")||{},basePath=systemPaths.root||"";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/jui/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.toUpperCase();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"){var token=Joomla.getOptions("csrf.token","");if(token){xhr.setRequestHeader("X-CSRF-Token",token)}if(typeof options.data==="string"&&(!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);