r89945 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89944‎ | r89945 | r89946 >
Date:03:43, 13 June 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added warning Javascript alert if form contains a div ID with a space for "show on select" - that's invalid HTML, and won't work
Modified paths:
  • /trunk/extensions/SemanticForms/libs/SemanticForms.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/libs/SemanticForms.js
@@ -321,6 +321,13 @@
322322 // Hide a div due to "show on select". The CSS class is there so that SF can
323323 // ignore the div's contents when the form is submitted.
324324 function hideDiv(div_id, instanceWrapperDiv) {
 325+ // IDs can't contain spaces, and jQuery won't work with such IDs - if
 326+ // this one has a space, display an alert.
 327+ if ( div_id.indexOf( ' ' ) > -1 ) {
 328+ // TODO - this should probably be a language value, instead of
 329+ // hardcoded in English.
 330+ alert( "Warning: this form has \"show on select\" pointing to an invalid element ID (\"" + div_id + "\") - IDs in HTML cannot contain spaces." );
 331+ }
325332 if (instanceWrapperDiv != null) {
326333 instanceWrapperDiv.find('[origID=' + div_id + ']').find("span, div").addClass('hiddenBySF');
327334 instanceWrapperDiv.find('[origID=' + div_id + ']').hide();