Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Namespace the checkAll() function

  • Loading branch information...
commit d9ec6d3e15344727dc7453c4cce9137b634e8b2c 1 parent f5c536e
@realityking realityking authored
Showing with 41 additions and 1 deletion.
  1. +40 −1 media/system/js/core-uncompressed.js
  2. +1 −0  media/system/js/core.js
View
41 media/system/js/core-uncompressed.js
@@ -1,5 +1,5 @@
/**
- * @version $Id: core-uncompressed.js 20196 2011-01-09 02:40:25Z ian $
+ * @version $Id: core-uncompressed.js 21463 2011-06-06 15:28:10Z dextercowley $
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
@@ -92,6 +92,39 @@ Joomla.isEmail = function(text) {
};
/**
+ * USED IN: all list forms.
+ *
+ * Toggles the check state of a group of boxes
+ *
+ * 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
+ */
+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;
+}
+
+/**
* Render messages send via JSON
*
* @param object
@@ -270,6 +303,8 @@ function getSelectedValue(frmName, srcListName) {
*
* @param mixed The number of box to 'check', for a checkbox element
* @param string An alternative field name
+ *
+ * @deprecated 11.1 This function will be removed in a future version. Use Joomla.checkAll() instead.
*/
function checkAll(checkbox, stub) {
if (!stub) {
@@ -369,6 +404,8 @@ function isChecked(isitchecked) {
/**
* Default function. Usually would be overriden by the component
+ *
+ * @deprecated 11.1 This function will be removed in a future version. Use Joomla.submitbutton() instead.
*/
function submitbutton(pressbutton) {
submitform(pressbutton);
@@ -376,6 +413,8 @@ function submitbutton(pressbutton) {
/**
* Submit the admin form
+ *
+ * @deprecated 11.1 This function will be removed in a future version. Use Joomla.submitform() instead.
*/
function submitform(pressbutton) {
if (pressbutton) {
View
1  media/system/js/core.js
@@ -3,6 +3,7 @@
*/
if(typeof Joomla==="undefined")var Joomla={};Joomla.editors={};Joomla.editors.instances={};Joomla.submitform=function(a,b){if(typeof b==="undefined"&&(b=document.getElementById("adminForm"),!b))b=document.adminForm;if(typeof a!=="undefined")b.task.value=a;if(typeof b.onsubmit=="function")b.onsubmit();typeof b.fireEvent=="function"&&b.fireEvent("submit");b.submit()};Joomla.submitbutton=function(a){Joomla.submitform(a)};
Joomla.JText={strings:{},_:function(a,b){return typeof this.strings[a.toUpperCase()]!=="undefined"?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<b.length;c++)if(b[c].type=="hidden"&&b[c].name.length==32&&b[c].value=="1")b[c].name=a};Joomla.isEmail=function(a){return/^[\w-_.]*[\w-_.]@[\w].+[\w]+[\w]$/.test(a)};
+Joomla.checkAll=function(a,b){b||(b="cb");if(a.form){for(var c=0,d=0,f=a.form.elements.length;d<f;d++){var e=a.form.elements[d];if(e.type==a.type&&(b&&e.id.indexOf(b)==0||!b))e.checked=a.checked,c+=e.checked==!0?1:0}if(a.form.boxchecked)a.form.boxchecked.value=c;return!0}return!1};
Joomla.renderMessages=function(a){var b=document.id("system-message-container");$$("#system-message-container > *").destroy();var c=new Element("dl",{id:"system-message"});Object.each(a,function(a,b){(new Element("dt",{"class":b,html:b})).inject(c);var e=new Element("dd",{"class":b});e.addClass("message");var g=new Element("ul");Array.each(a,function(a){(new Element("li",{html:a})).inject(g)},this);g.inject(e);e.inject(c)},this);c.inject(b)};
function writeDynaList(a,b,c,d,f){var a="\n\t<select "+a+">",e=0;for(x in b){if(b[x][0]==c){var g="";if(d==c&&f==b[x][1]||e==0&&d!=c)g='selected="selected"';a+='\n\t\t<option value="'+b[x][1]+'" '+g+">"+b[x][2]+"</option>"}e++}a+="\n\t</select>";document.writeln(a)}
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||i==0)opt.selected=!0;a.options[i++]=opt}a.length=i}function radioGetCheckedValue(a){if(!a)return"";var b=a.length;if(b==void 0)return a.checked?a.value:"";for(var c=0;c<b;c++)if(a[c].checked)return a[c].value;return""}
Please sign in to comment.
Something went wrong with that request. Please try again.