diff --git a/libraries/cms/html/behavior.php b/libraries/cms/html/behavior.php index f8453e03fdf0c..cabe16a7f61e1 100644 --- a/libraries/cms/html/behavior.php +++ b/libraries/cms/html/behavior.php @@ -61,6 +61,8 @@ public static function framework($extras = false, $debug = null) } JHtml::_('script', 'system/mootools-' . $type . '.js', false, true, false, false, $debug); + // Include jQuery + JHtml::_('jquery.framework'); JHtml::_('script', 'system/core.js', false, true); static::$loaded[__METHOD__][$type] = true; diff --git a/media/system/js/core-uncompressed.js b/media/system/js/core-uncompressed.js index f7840d3affbc5..5db2334a285b2 100644 --- a/media/system/js/core-uncompressed.js +++ b/media/system/js/core-uncompressed.js @@ -1,12 +1,10 @@ /** - * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt */ // Only define the Joomla namespace if not defined. -if (typeof(Joomla) === 'undefined') { - var Joomla = {}; -} +Joomla = window.Joomla || {}; Joomla.editors = {}; // An object to hold each editor instance on page @@ -16,29 +14,29 @@ Joomla.editors.instances = {}; * Generic submit form */ Joomla.submitform = function(task, form) { - if (typeof(form) === 'undefined') { - form = document.getElementById('adminForm'); - } - - if (typeof(task) !== 'undefined') { - form.task.value = task; - } - - // Submit the form. - if (typeof form.onsubmit == 'function') { - form.onsubmit(); - } - if (typeof form.fireEvent == "function") { - form.fireEvent('submit'); - } - form.submit(); + if (typeof(form) === 'undefined') { + form = document.getElementById('adminForm'); + } + + if (typeof(task) !== 'undefined') { + form.task.value = task; + } + + // Submit the form. + if (typeof form.onsubmit == 'function') { + form.onsubmit(); + } + if (typeof form.fireEvent == "function") { + form.fireEvent('submit'); + } + form.submit(); }; /** * Default function. Usually would be overriden by the component */ Joomla.submitbutton = function(pressbutton) { - Joomla.submitform(pressbutton); + Joomla.submitform(pressbutton); } /** @@ -47,28 +45,28 @@ Joomla.submitbutton = function(pressbutton) { * Allows you to call Joomla.JText._() to get a translated JavaScript string pushed in with JText::script() in Joomla. */ Joomla.JText = { - strings: {}, - '_': function(key, def) { - return typeof this.strings[key.toUpperCase()] !== 'undefined' ? this.strings[key.toUpperCase()] : def; - }, - load: function(object) { - for (var key in object) { - this.strings[key.toUpperCase()] = object[key]; - } - return this; - } + strings: {}, + '_': function(key, def) { + return typeof this.strings[key.toUpperCase()] !== 'undefined' ? this.strings[key.toUpperCase()] : def; + }, + load: function(object) { + for (var key in object) { + this.strings[key.toUpperCase()] = object[key]; + } + return this; + } }; /** * Method to replace all request tokens on the page with a new one. */ Joomla.replaceTokens = function(n) { - var els = document.getElementsByTagName('input'); - for (var i = 0; i < els.length; i++) { - if ((els[i].type == 'hidden') && (els[i].name.length == 32) && els[i].value == '1') { - els[i].name = n; - } - } + var els = document.getElementsByTagName('input'), i; + for (i = 0; i < els.length; i++) { + if ((els[i].type == 'hidden') && (els[i].name.length == 32) && els[i].value == '1') { + els[i].name = n; + } + } }; /** @@ -80,8 +78,8 @@ Joomla.replaceTokens = function(n) { * @return boolean */ Joomla.isEmail = function(text) { - var regex = new RegExp("^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$"); - return regex.test(text); + var regex = new RegExp("^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$"); + return regex.test(text); }; /** @@ -91,73 +89,75 @@ Joomla.isEmail = function(text) { * * Checkboxes must have an id attribute in the form cb0, cb1... * - * @param mixed The number of box to 'check', for a checkbox element - * @param string An alternative field name + * @param mixed The number of box to 'check', for a checkbox element + * @param string An alternative field name */ Joomla.checkAll = function(checkbox, stub) { - if (!stub) { - stub = 'cb'; - } - if (checkbox.form) { - var c = 0; - for (var i = 0, n = checkbox.form.elements.length; i < n; i++) { - var e = checkbox.form.elements[i]; - if (e.type == checkbox.type) { - if ((stub && e.id.indexOf(stub) == 0) || !stub) { - e.checked = checkbox.checked; - c += (e.checked == true ? 1 : 0); - } - } - } - if (checkbox.form.boxchecked) { - checkbox.form.boxchecked.value = c; - } - return true; - } - return false; + if (!stub) { + stub = 'cb'; + } + if (checkbox.form) { + var c = 0, i, e; + for (i = 0, n = checkbox.form.elements.length; i < n; i++) { + e = checkbox.form.elements[i]; + if (e.type == checkbox.type) { + if ((stub && e.id.indexOf(stub) == 0) || !stub) { + e.checked = checkbox.checked; + c += (e.checked == true ? 1 : 0); + } + } + } + if (checkbox.form.boxchecked) { + checkbox.form.boxchecked.value = c; + } + return true; + } + return false; } /** * Render messages send via JSON * - * @param object messages JavaScript object containing the messages to render - * @return void + * @param object messages JavaScript object containing the messages to render + * @return void */ Joomla.renderMessages = function(messages) { - Joomla.removeMessages(); - var container = document.id('system-message-container'); - - Object.each(messages, function (item, type) { - var div = new Element('div', { - id: 'system-message', - 'class': 'alert alert-' + type - }); - div.inject(container); - var h4 = new Element('h4', { - 'class' : 'alert-heading', - html: Joomla.JText._(type) - }); - h4.inject(div); - var divList = new Element('div'); - Array.each(item, function (item, index, object) { - var p = new Element('p', { - html: item - }); - p.inject(divList); - }, this); - divList.inject(div); - }, this); + var $ = jQuery.noConflict(), $container, $div, $h4, $divList, $p; + Joomla.removeMessages(); + $container = $('#system-message-container'); + + $.each(messages, function(type, item) { + $div = $('
', { + 'id' : 'system-message', + 'class' : 'alert alert-' + type + }); + $container.append($div) + + $h4 = $('

', { + 'class' : 'alert-heading', + 'text' : Joomla.JText._(type) + }); + $div.append($h4); + + $divList = $('
'); + $.each(item, function(index, item) { + $p = $('

', { + html : item + }); + $divList.append($p); + }); + $div.append($divList); + }); }; /** * Remove messages * - * @return void + * @return void */ Joomla.removeMessages = function() { - var children = $$('#system-message-container > *'); - children.destroy(); + jQuery('#system-message-container').empty(); } /** @@ -172,15 +172,15 @@ Joomla.removeMessages = function() { * @return */ Joomla.isChecked = function(isitchecked, form) { - if (typeof(form) === 'undefined') { - form = document.getElementById('adminForm'); - } - - if (isitchecked == true) { - form.boxchecked.value++; - } else { - form.boxchecked.value--; - } + if (typeof(form) === 'undefined') { + form = document.getElementById('adminForm'); + } + + if (isitchecked == true) { + form.boxchecked.value++; + } else { + form.boxchecked.value--; + } } /** @@ -189,25 +189,25 @@ Joomla.isChecked = function(isitchecked, form) { * Pops up a new window in the middle of the screen */ Joomla.popupWindow = function(mypage, myname, w, h, scroll) { - var winl = (screen.width - w) / 2; - var wint = (screen.height - h) / 2; - var winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl - + ',scrollbars=' + scroll + ',resizable' - var win = window.open(mypage, myname, winprops) - win.window.focus(); + var winl = (screen.width - w) / 2, wint, winprops, win; + wint = (screen.height - h) / 2; + winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + + ',scrollbars=' + scroll + ',resizable' + win = window.open(mypage, myname, winprops) + win.window.focus(); } /** * USED IN: libraries/joomla/html/html/grid.php */ Joomla.tableOrdering = function(order, dir, task, form) { - if (typeof(form) === 'undefined') { - form = document.getElementById('adminForm'); - } + if (typeof(form) === 'undefined') { + form = document.getElementById('adminForm'); + } - form.filter_order.value = order; - form.filter_order_Dir.value = dir; - Joomla.submitform(task, form); + form.filter_order.value = order; + form.filter_order_Dir.value = dir; + Joomla.submitform(task, form); } /** @@ -216,34 +216,34 @@ Joomla.tableOrdering = function(order, dir, task, form) { * Writes a dynamically generated list * * @param string - * The parameters to insert into the tag * @param array - * A javascript array of list options in the form [key,value,text] + * A javascript array of list options in the form [key,value,text] * @param string - * The key to display for the initial state of the list + * The key to display for the initial state of the list * @param string - * The original key that was selected + * The original key that was selected * @param string - * The original item value that was selected + * The original item value that was selected */ function writeDynaList(selectParams, source, key, orig_key, orig_val) { - var html = '\n '; - - document.writeln(html); + var html = '\n '; + + document.writeln(html); } /** @@ -252,37 +252,37 @@ function writeDynaList(selectParams, source, key, orig_key, orig_val) { * Changes a dynamically generated list * * @param string - * The name of the list to change + * The name of the list to change * @param array - * A javascript array of list options in the form [key,value,text] + * A javascript array of list options in the form [key,value,text] * @param string - * The key to display + * The key to display * @param string - * The original key that was selected + * The original key that was selected * @param string - * The original item value that was selected + * The original item value that was selected */ function changeDynaList(listname, source, key, orig_key, orig_val) { - var list = document.adminForm[listname]; - - // empty the list - for (i in list.options.length) { - list.options[i] = null; - } - i = 0; - for (x in source) { - if (source[x][0] == key) { - opt = new Option(); - opt.value = source[x][1]; - opt.text = source[x][2]; - - if ((orig_key == key && orig_val == opt.value) || i == 0) { - opt.selected = true; - } - list.options[i++] = opt; - } - } - list.length = i; + var list = document.adminForm[listname]; + + // empty the list + for (i in list.options.length) { + list.options[i] = null; + } + i = 0; + for (x in source) { + if (source[x][0] == key) { + opt = new Option(); + opt.value = source[x][1]; + opt.text = source[x][2]; + + if ((orig_key == key && orig_val == opt.value) || i == 0) { + opt.selected = true; + } + list.options[i++] = opt; + } + } + list.length = i; } /** @@ -295,23 +295,23 @@ function changeDynaList(listname, source, key, orig_key, orig_val) { // return an empty string if none are checked, or // there are no radio buttons function radioGetCheckedValue(radioObj) { - if (!radioObj) { - return ''; - } - var n = radioObj.length; - if (n == undefined) { - if (radioObj.checked) { - return radioObj.value; - } else { - return ''; - } - } - for ( var i = 0; i < n; i++) { - if (radioObj[i].checked) { - return radioObj[i].value; - } - } - return ''; + if (!radioObj) { + return ''; + } + var n = radioObj.length, i; + if (n == undefined) { + if (radioObj.checked) { + return radioObj.value; + } else { + return ''; + } + } + for (i = 0; i < n; i++) { + if (radioObj[i].checked) { + return radioObj[i].value; + } + } + return ''; } /** @@ -332,15 +332,15 @@ function radioGetCheckedValue(radioObj) { * @return */ function getSelectedValue(frmName, srcListName) { - var form = document[frmName]; - var srcList = form[srcListName]; - - i = srcList.selectedIndex; - if (i != null && i > -1) { - return srcList.options[i].value; - } else { - return null; - } + var form = document[frmName], + srcList = form[srcListName]; + + i = srcList.selectedIndex; + if (i != null && i > -1) { + return srcList.options[i].value; + } else { + return null; + } } /** @@ -351,47 +351,47 @@ function getSelectedValue(frmName, srcListName) { * @return */ function listItemTask(id, task) { - var f = document.adminForm; - var cb = f[id]; - if (cb) { - for (var i = 0; true; i++) { - var cbx = f['cb'+i]; - if (!cbx) - break; - cbx.checked = false; - } // for - cb.checked = true; - f.boxchecked.value = 1; - submitbutton(task); - } - return false; + var f = document.adminForm, i, cbx, + cb = f[id]; + if (cb) { + for (i = 0; true; i++) { + cbx = f['cb'+i]; + if (!cbx) + break; + cbx.checked = false; + } // for + cb.checked = true; + f.boxchecked.value = 1; + submitbutton(task); + } + return false; } /** * Default function. Usually would be overriden by the component * - * @deprecated 12.1 This function will be removed in a future version. Use Joomla.submitbutton() instead. + * @deprecated 12.1 This function will be removed in a future version. Use Joomla.submitbutton() instead. */ function submitbutton(pressbutton) { - submitform(pressbutton); + submitform(pressbutton); } /** * Submit the admin form * - * @deprecated 12.1 This function will be removed in a future version. Use Joomla.submitform() instead. + * @deprecated 12.1 This function will be removed in a future version. Use Joomla.submitform() instead. */ function submitform(pressbutton) { - if (pressbutton) { - document.adminForm.task.value = pressbutton; - } - if (typeof document.adminForm.onsubmit == "function") { - document.adminForm.onsubmit(); - } - if (typeof document.adminForm.fireEvent == "function") { - document.adminForm.fireEvent('submit'); - } - document.adminForm.submit(); + if (pressbutton) { + document.adminForm.task.value = pressbutton; + } + if (typeof document.adminForm.onsubmit == "function") { + document.adminForm.onsubmit(); + } + if (typeof document.adminForm.fireEvent == "function") { + document.adminForm.fireEvent('submit'); + } + document.adminForm.submit(); } // needed for Table Column ordering @@ -399,24 +399,24 @@ function submitform(pressbutton) { * USED IN: libraries/joomla/html/html/grid.php */ function saveorder(n, task) { - checkAll_button(n, task); + checkAll_button(n, task); } function checkAll_button(n, task) { - if (!task) { - task = 'saveorder'; - } - - for (var j = 0; j <= n; j++) { - var box = document.adminForm['cb'+j]; - if (box) { - if (box.checked == false) { - box.checked = true; - } - } else { - alert("You cannot change the order of items, as an item in the list is `Checked Out`"); - return; - } - } - submitform(task); + if (!task) { + task = 'saveorder'; + } + var j, box; + for (j = 0; j <= n; j++) { + box = document.adminForm['cb'+j]; + if (box) { + if (box.checked == false) { + box.checked = true; + } + } else { + alert("You cannot change the order of items, as an item in the list is `Checked Out`"); + return; + } + } + submitform(task); } diff --git a/media/system/js/core.js b/media/system/js/core.js index 11ad35b13a809..c708a00e586aa 100644 --- a/media/system/js/core.js +++ b/media/system/js/core.js @@ -1,13 +1,4 @@ /* GNU General Public License version 2 or later; see LICENSE.txt */ -if("undefined"===typeof Joomla)var Joomla={};Joomla.editors={};Joomla.editors.instances={};Joomla.submitform=function(a,b){"undefined"===typeof b&&(b=document.getElementById("adminForm"));"undefined"!==typeof a&&(b.task.value=a);if("function"==typeof b.onsubmit)b.onsubmit();"function"==typeof b.fireEvent&&b.fireEvent("submit");b.submit()};Joomla.submitbutton=function(a){Joomla.submitform(a)}; -Joomla.JText={strings:{},_:function(a,b){return"undefined"!==typeof this.strings[a.toUpperCase()]?this.strings[a.toUpperCase()]:b},load:function(a){for(var b in a)this.strings[b.toUpperCase()]=a[b];return this}};Joomla.replaceTokens=function(a){for(var b=document.getElementsByTagName("input"),c=0;c *").destroy()}; -Joomla.isChecked=function(a,b){"undefined"===typeof b&&(b=document.getElementById("adminForm"));!0==a?b.boxchecked.value++:b.boxchecked.value--};Joomla.popupWindow=function(a,b,c,d,f){window.open(a,b,"height="+d+",width="+c+",top="+(screen.height-d)/2+",left="+(screen.width-c)/2+",scrollbars="+f+",resizable").window.focus()}; -Joomla.tableOrdering=function(a,b,c,d){"undefined"===typeof d&&(d=document.getElementById("adminForm"));d.filter_order.value=a;d.filter_order_Dir.value=b;Joomla.submitform(c,d)};function writeDynaList(a,b,c,d,f){var a="\n\t")} -function changeDynaList(a,b,c,d,f){a=document.adminForm[a];for(i in a.options.length)a.options[i]=null;i=0;for(x in b)if(b[x][0]==c){opt=new Option;opt.value=b[x][1];opt.text=b[x][2];if(d==c&&f==opt.value||0==i)opt.selected=!0;a.options[i++]=opt}a.length=i}function radioGetCheckedValue(a){if(!a)return"";var b=a.length;if(void 0==b)return a.checked?a.value:"";for(var c=0;c",{id:"system-message","class":"alert alert-"+h});g.append(b);a=e("

",{"class":"alert-heading",text:Joomla.JText._(h)});b.append(a);f=e("
");e.each(j,function(k,l){c=e("

",{html:l});f.append(c)});b.append(f)})};Joomla.removeMessages=function(){jQuery("#system-message-container").empty()};Joomla.isChecked=function(a,b){if(typeof(b)==="undefined"){b=document.getElementById("adminForm")}if(a==true){b.boxchecked.value++}else{b.boxchecked.value--}};Joomla.popupWindow=function(e,k,j,c,f){var g=(screen.width-j)/2,b,a,d;b=(screen.height-c)/2;a="height="+c+",width="+j+",top="+b+",left="+g+",scrollbars="+f+",resizable";d=window.open(e,k,a);d.window.focus()};Joomla.tableOrdering=function(a,c,b,d){if(typeof(d)==="undefined"){d=document.getElementById("adminForm")}d.filter_order.value=a;d.filter_order_Dir.value=c;Joomla.submitform(b,d)};function writeDynaList(e,g,d,h,a){var c="\n ";document.writeln(c)}function changeDynaList(c,e,b,f,a){var d=document.adminForm[c];for(i in d.options.length){d.options[i]=null}i=0;for(x in e){if(e[x][0]==b){opt=new Option();opt.value=e[x][1];opt.text=e[x][2];if((f==b&&a==opt.value)||i==0){opt.selected=true}d.options[i++]=opt}}d.length=i}function radioGetCheckedValue(b){if(!b){return""}var c=b.length,a;if(c==undefined){if(b.checked){return b.value}else{return""}}for(a=0;a-1){return d.options[i].value}else{return null}}function listItemTask(g,b){var d=document.adminForm,c,e,a=d[g];if(a){for(c=0;true;c++){e=d["cb"+c];if(!e){break}e.checked=false}a.checked=true;d.boxchecked.value=1;submitbutton(b)}return false}function submitbutton(a){submitform(a)}function submitform(a){if(a){document.adminForm.task.value=a}if(typeof document.adminForm.onsubmit=="function"){document.adminForm.onsubmit()}if(typeof document.adminForm.fireEvent=="function"){document.adminForm.fireEvent("submit")}document.adminForm.submit()}function saveorder(b,a){checkAll_button(b,a)}function checkAll_button(d,a){if(!a){a="saveorder"}var b,c;for(b=0;b<=d;b++){c=document.adminForm["cb"+b];if(c){if(c.checked==false){c.checked=true}}else{alert("You cannot change the order of items, as an item in the list is `Checked Out`");return}}submitform(a)};