Skip to content

Commit

Permalink
Item10714: IE8 thinks that clicking a div is submitting the form; and…
Browse files Browse the repository at this point in the history
… instead of the div we should target the form

git-svn-id: http://svn.foswiki.org/trunk@11635 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed May 5, 2011
1 parent 25ccea9 commit d0a1382
Showing 1 changed file with 74 additions and 71 deletions.
145 changes: 74 additions & 71 deletions core/pub/System/JavascriptFiles/foswiki_edit_src.js
Expand Up @@ -51,14 +51,16 @@ var EDITBOX_FONTSTYLE_PROPORTIONAL_STYLE = "foswikiEditboxStyleProportional";
* EDITBOX_FONTSTYLE_PROPORTIONAL
*/
foswiki.Edit.getFontStyle = function() {
if (foswiki.Edit.fontStyle)
if (foswiki.Edit.fontStyle) {
return foswiki.Edit.fontStyle;
}

var pref = foswiki.Pref.getPref(EDITBOX_PREF_FONTSTYLE_ID);

if (!pref || (pref != EDITBOX_FONTSTYLE_PROPORTIONAL
&& pref != EDITBOX_FONTSTYLE_MONO))
if (!pref || (pref !== EDITBOX_FONTSTYLE_PROPORTIONAL
&& pref !== EDITBOX_FONTSTYLE_MONO)) {
pref = EDITBOX_FONTSTYLE_PROPORTIONAL;
}

return pref;
};
Expand All @@ -70,12 +72,12 @@ var EDITBOX_FONTSTYLE_PROPORTIONAL_STYLE = "foswikiEditboxStyleProportional";
* EDITBOX_FONTSTYLE_PROPORTIONAL
*/
foswiki.Edit.setFontStyle = function(inFontStyle) {
if (inFontStyle == EDITBOX_FONTSTYLE_MONO) {
if (inFontStyle === EDITBOX_FONTSTYLE_MONO) {
$('#' + EDITBOX_ID).removeClass(
EDITBOX_FONTSTYLE_PROPORTIONAL_STYLE).addClass(
EDITBOX_FONTSTYLE_MONO_STYLE);
}
if (inFontStyle == EDITBOX_FONTSTYLE_PROPORTIONAL) {
if (inFontStyle === EDITBOX_FONTSTYLE_PROPORTIONAL) {
$('#' + EDITBOX_ID).removeClass(
EDITBOX_FONTSTYLE_MONO_STYLE).addClass(
EDITBOX_FONTSTYLE_PROPORTIONAL_STYLE);
Expand Down Expand Up @@ -104,78 +106,79 @@ var EDITBOX_FONTSTYLE_PROPORTIONAL_STYLE = "foswikiEditboxStyleProportional";
foswiki.Edit.validateMandatoryFields = function() {
// Provided for use by editors that need to
// validate form elements before navigating away
if (foswiki.Edit.validateSuppressed)
if (foswiki.Edit.validateSuppressed) {
return true;
}

var alerts = [];
$('select.foswikiMandatory').each(
function(index, el) {
var one = false;
for (var k = 0; k < el.options.length; k++) {
if (el.options[k].selected) {
one = true;
break;
}
}
if (!one)
alerts.push("The required form field '"
+ el.name +
"' has no value.");
});

$('textarea.foswikiMandatory, input.foswikiMandatory').each(
function(index, el) {
if (el.value == null || el.value.length == 0) {
alerts.push("The required form field '"
+ el.name +
"' has no value.");
}
});
$('select.foswikiMandatory').each(function(index, el) {
var one = false;
var k;
for (k = 0; k < el.options.length; k=k+1) {
if (el.options[k].selected) {
one = true;
break;
}
}
if (!one) {
alerts.push("The required form field '"
+ el.name +
"' has no value.");
}
});

$('textarea.foswikiMandatory, input.foswikiMandatory').each(function(index, el) {
if (el.value === null || el.value.length === 0) {
alerts.push("The required form field '"
+ el.name +
"' has no value.");
}
});

if (alerts.length > 0) {
alert(alerts.join("\n"));
return false;
} else
} else {
return true;
}
}
};

$(document).ready(
function($) {

try {
document.main.text.focus();
} catch (er) {
};

var pref = foswiki.Pref.getPref(EDITBOX_PREF_ROWS_ID);
if (pref)
$('#' + EDITBOX_ID).attr('rows', parseInt(pref) );

// Set the font style (monospace or proportional space) of the edit
// box to the style read from cookie.
var pref = foswiki.Edit.getFontStyle();
foswiki.Edit.setFontStyle(pref);

$('.foswikiEditForm').submit(
function() {
return foswiki.Edit.validateMandatoryFields();
});

$('.foswikiTextarea').keydown(
function(e) {
// Disables the use of ESCAPE in the edit box, because some
// browsers will interpret this as cancel and will remove
// all changes.
var code;
if (e.keyCode)
code = e.keyCode;
return (code != 27); // ESC
});

$('.foswikiButtonCancel').click(
function(e) {
// Used to dynamically set validation suppression
foswiki.Edit.validateSuppressed = true;
});
});
})(jQuery);
$(function() {

try {
document.main.text.focus();
} catch (er) {
//
}

var prefRowsId = foswiki.Pref.getPref(EDITBOX_PREF_ROWS_ID);
if (prefRowsId) {
$('#' + EDITBOX_ID).attr('rows', parseInt(prefRowsId, 10) );
}

// Set the font style (monospace or proportional space) of the edit
// box to the style read from cookie.
var prefStyle = foswiki.Edit.getFontStyle();
foswiki.Edit.setFontStyle(prefStyle);

$(document.forms[name='main']).submit(function(e) {
return foswiki.Edit.validateMandatoryFields();
});

$('.foswikiTextarea').keydown(function(e) {
// Disables the use of ESCAPE in the edit box, because some
// browsers will interpret this as cancel and will remove
// all changes.
var code;
if (e.keyCode) {
code = e.keyCode;
}
return (code !== 27); // ESC
});

$('.foswikiButtonCancel').click(function(e) {
// Used to dynamically set validation suppression
foswiki.Edit.validateSuppressed = true;
});
});
}(jQuery));

0 comments on commit d0a1382

Please sign in to comment.