Skip to content

Commit

Permalink
Item10075: put check all/uncheck all functionality in foswiki.Form
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@10313 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed Dec 14, 2010
1 parent 47fb07b commit 620a37b
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 82 deletions.
1 change: 1 addition & 0 deletions PatternSkin/data/System/PatternSkin.txt
Expand Up @@ -168,6 +168,7 @@ For further troubleshooting and feedback, go to http://foswiki.org/Support/%TOPI
| Version: | %$VERSION% |
| Release: | %$RELEASE% |
| History: | <!-- specify latest version first -->&nbsp; |
| 14 Dec 2010: | v.5.4.4: Fix check all / uncheck all checkboxes on rename and delete topic pages. |
| 12 Dec 2010: | v.5.4.3: Fix trimming and stripping spaces in web topic creator javascript. |
| 09 Nov 2010: | v.5.4.2: Remove redundant files from repository. v.5.4.1: Revert usage of =$<nop>percent= back to =$<nop>percnt= |
| 19 Aug 2010: | v.5.4 - Version for Foswiki 1.1. |
Expand Down
2 changes: 1 addition & 1 deletion PatternSkin/lib/Foswiki/Contrib/PatternSkin.pm
Expand Up @@ -4,7 +4,7 @@ use strict;
use warnings;

our $VERSION = '$Rev$';
our $RELEASE = '5.4.3';
our $RELEASE = '5.4.4';
our $SHORTDESCRIPTION =
'Pattern skin provides a CSS based default look and feel - flexible and [[http://www.w3.org/][W3C]] compliant. Its layout and color scheme are designed to provide a nice, clean and productive editing environment';

Expand Down
1 change: 0 additions & 1 deletion PatternSkin/lib/Foswiki/Contrib/PatternSkin/MANIFEST
Expand Up @@ -157,7 +157,6 @@ templates/oops.pattern.tmpl 0444
templates/preview.pattern.tmpl 0444
templates/rdiff.pattern.tmpl 0444
templates/renamebase.pattern.tmpl 0444
templates/renamedelete.pattern.tmpl 0444
templates/renamewebbase.pattern.tmpl 0444
templates/search.pattern.tmpl 0444
templates/searchbase.pattern.tmpl 0444
Expand Down
3 changes: 0 additions & 3 deletions PatternSkin/templates/renamebase.pattern.tmpl
Expand Up @@ -2,9 +2,6 @@
%TMPL:DEF{"logo"}%%TMPL:END%


%TMPL:DEF{"script:skintemplate"}%%TMPL:END%


%TMPL:DEF{"bodyclassname"}%patternNoViewPage patternRenamePage%TMPL:END%


Expand Down
2 changes: 0 additions & 2 deletions PatternSkin/templates/renamedelete.pattern.tmpl

This file was deleted.

149 changes: 74 additions & 75 deletions core/pub/System/JavascriptFiles/foswikiForm_src.js
Expand Up @@ -53,13 +53,15 @@ As per the GPL, removal of this notice is prohibited.
* @example
* <code>
* var queryString = foswiki.Form.formData2QueryString(
* document.getElementById('myForm'),
* {collapseMulti:true}
* document.getElementById('myForm'),
* {collapseMulti:true}
* );
* </code>
*/
formData2QueryString:function (inForm, inFormatOptions) {
if (!inForm) return null;
if (!inForm) {
return null;
}
var opts = inFormatOptions || {};
var str = '';
var formElem;
Expand All @@ -70,82 +72,66 @@ As per the GPL, removal of this notice is prohibited.

switch (formElem.type) {
// Text fields, hidden form elements
case 'text':
case 'hidden':
case 'password':
case 'textarea':
case 'select-one':
str += formElem.name
+ '='
+ encodeURI(formElem.value)
+ foswiki.Form.KEYVALUEPAIR_DELIMITER;
break;
case 'text':
case 'hidden':
case 'password':
case 'textarea':
case 'select-one':
str += (formElem.name + '=' + encodeURI(formElem.value) + foswiki.Form.KEYVALUEPAIR_DELIMITER);
break;

// Multi-option select
case 'select-multiple':
var isSet = false;
for(var j = 0; j < formElem.options.length; j++) {
var currOpt = formElem.options[j];
if(currOpt.selected) {
if (opts.collapseMulti) {
if (isSet) {
str += ','
+ encodeURI(currOpt.text);
} else {
str += formElem.name
+ '='
+ encodeURI(currOpt.text);
isSet = true;
}
} else {
str += formElem.name
+ '='
+ encodeURI(currOpt.text)
+ foswiki.Form.KEYVALUEPAIR_DELIMITER;
}
}
}
if (opts.collapseMulti) {
str += foswiki.Form.KEYVALUEPAIR_DELIMITER;
}
break;
case 'select-multiple':
var isSet = false;
for(var j = 0; j < formElem.options.length; j++) {
var currOpt = formElem.options[j];
if(currOpt.selected) {
if (opts.collapseMulti) {
if (isSet) {
str += (',' + encodeURI(currOpt.text));
} else {
str += (formElem.name + '=' + encodeURI(currOpt.text));
isSet = true;
}
} else {
str += (formElem.name + '=' + encodeURI(currOpt.text) + foswiki.Form.KEYVALUEPAIR_DELIMITER);
}
}
}
if (opts.collapseMulti) {
str += foswiki.Form.KEYVALUEPAIR_DELIMITER;
}
break;

// Radio buttons
case 'radio':
if (formElem.checked) {
str += formElem.name
+ '='
+ encodeURI(formElem.value)
+ foswiki.Form.KEYVALUEPAIR_DELIMITER;
}
break;
case 'radio':
if (formElem.checked) {
str += (formElem.name + '=' + encodeURI(formElem.value) + foswiki.Form.KEYVALUEPAIR_DELIMITER);
}
break;

// Checkboxes
case 'checkbox':
if (formElem.checked) {
// Collapse multi-select into comma-separated list
if (opts.collapseMulti
&& (formElem.name == lastElemName)) {
case 'checkbox':
if (formElem.checked) {
// Collapse multi-select into comma-separated list
if (opts.collapseMulti && (formElem.name === lastElemName)) {
// Strip of end ampersand if there is one
if (str.lastIndexOf('&') == str.length-1) {
str = str.substr(0, str.length - 1);
}
// Append value as comma-delimited string
str += ','
+ encodeURI(formElem.value);
}
else {
str += formElem.name
+ '='
+ encodeURI(formElem.value);
}
str += foswiki.Form.KEYVALUEPAIR_DELIMITER;
lastElemName = formElem.name;
}
break;
str += (',' + encodeURI(formElem.value));
}
else {
str += (formElem.name + '=' + encodeURI(formElem.value));
}
str += foswiki.Form.KEYVALUEPAIR_DELIMITER;
lastElemName = formElem.name;
}
break;

} // switch
} // for
} // switch
} // for
// Remove trailing separator
str = str.substr(0, str.length - 1);
return str;
Expand All @@ -158,20 +144,21 @@ As per the GPL, removal of this notice is prohibited.
* @param inForm: (String) the form to make safe
*/
makeSafeForTableEntry:function(inForm) {
if (!inForm)
if (!inForm) {
return null;
}
var formElem;

for (i = 0; i < inForm.elements.length; i++) {
formElem = inForm.elements[i];
switch (formElem.type) {
// Text fields, hidden form elements
case 'text':
case 'password':
case 'textarea':
formElem.value = foswiki.String.makeTextSafeForTableEntry(
case 'text':
case 'password':
case 'textarea':
formElem.value = foswiki.String.makeTextSafeForTableEntry(
formElem.value);
break;
break;
}
}
},
Expand Down Expand Up @@ -258,9 +245,9 @@ As per the GPL, removal of this notice is prohibited.

jQuery(document).ready(
function ($) {
$('input[type="text"].foswikiDefaultText')
$('input[type="text"].foswikiDefaultText')
.each(
function(index, el) {
function(index, el) {
foswiki.Form.initBeforeFocusText(this, this.title);
})
.focus(
Expand All @@ -271,5 +258,17 @@ jQuery(document).ready(
function() {
foswiki.Form.restoreBeforeFocusText(this);
});
$('.foswikiCheckAllOn').click(
function(e) {
var form = $(this).parents('form:first');
$('.foswikiCheckBox', form).attr('checked', true);
}
);
$('.foswikiCheckAllOff').click(
function(e) {
var form = $(this).parents('form:first');
$('.foswikiCheckBox', form).attr('checked', false);
}
);
}
);

0 comments on commit 620a37b

Please sign in to comment.