Commit 54496aeb authored by webchick's avatar webchick

Issue #1749782 by pascalduez: Use event.preventDefault(); and...

Issue #1749782 by pascalduez: Use event.preventDefault(); and event.stopPropagation(); instead of return false;.
parent ebaab15c
...@@ -214,8 +214,8 @@ Drupal.ajax.prototype.keypressResponse = function (element, event) { ...@@ -214,8 +214,8 @@ Drupal.ajax.prototype.keypressResponse = function (element, event) {
// spacebar activation causes inappropriate activation if #ajax['keypress'] is // spacebar activation causes inappropriate activation if #ajax['keypress'] is
// TRUE. On a text-type widget a space should always be a space. // TRUE. On a text-type widget a space should always be a space.
if (event.which === 13 || (event.which === 32 && element.type !== 'text' && element.type !== 'textarea')) { if (event.which === 13 || (event.which === 32 && element.type !== 'text' && element.type !== 'textarea')) {
event.preventDefault();
$(ajax.element_settings.element).trigger(ajax.element_settings.event); $(ajax.element_settings.element).trigger(ajax.element_settings.event);
return false;
} }
}; };
...@@ -228,12 +228,14 @@ Drupal.ajax.prototype.keypressResponse = function (element, event) { ...@@ -228,12 +228,14 @@ Drupal.ajax.prototype.keypressResponse = function (element, event) {
* ajax object. * ajax object.
*/ */
Drupal.ajax.prototype.eventResponse = function (element, event) { Drupal.ajax.prototype.eventResponse = function (element, event) {
event.preventDefault();
// Create a synonym for this to reduce code confusion. // Create a synonym for this to reduce code confusion.
var ajax = this; var ajax = this;
// Do not perform another ajax command if one is already in progress. // Do not perform another ajax command if one is already in progress.
if (ajax.ajaxing) { if (ajax.ajaxing) {
return false; return;
} }
try { try {
...@@ -261,16 +263,6 @@ Drupal.ajax.prototype.eventResponse = function (element, event) { ...@@ -261,16 +263,6 @@ Drupal.ajax.prototype.eventResponse = function (element, event) {
ajax.ajaxing = false; ajax.ajaxing = false;
window.alert("An error occurred while attempting to process " + ajax.options.url + ": " + e.message); window.alert("An error occurred while attempting to process " + ajax.options.url + ": " + e.message);
} }
// For radio/checkbox, allow the default event. On IE, this means letting
// it actually check the box.
if (typeof element.type !== 'undefined' && (element.type === 'checkbox' || element.type === 'radio')) {
return true;
}
else {
return false;
}
}; };
/** /**
......
...@@ -63,11 +63,13 @@ Drupal.jsAC.prototype.onkeydown = function (input, e) { ...@@ -63,11 +63,13 @@ Drupal.jsAC.prototype.onkeydown = function (input, e) {
} }
switch (e.keyCode) { switch (e.keyCode) {
case 40: // down arrow. case 40: // down arrow.
e.preventDefault();
this.selectDown(); this.selectDown();
return false; break;
case 38: // up arrow. case 38: // up arrow.
e.preventDefault();
this.selectUp(); this.selectUp();
return false; break;
default: // All other keys. default: // All other keys.
return true; return true;
} }
......
...@@ -87,14 +87,14 @@ Drupal.behaviors.collapse = { ...@@ -87,14 +87,14 @@ Drupal.behaviors.collapse = {
var $link = $('<a class="fieldset-title" href="#"></a>') var $link = $('<a class="fieldset-title" href="#"></a>')
.prepend($legend.contents()) .prepend($legend.contents())
.appendTo($legend) .appendTo($legend)
.click(function () { .click(function (e) {
e.preventDefault();
var fieldset = $fieldset.get(0); var fieldset = $fieldset.get(0);
// Don't animate multiple times. // Don't animate multiple times.
if (!fieldset.animating) { if (!fieldset.animating) {
fieldset.animating = true; fieldset.animating = true;
Drupal.toggleFieldset(fieldset); Drupal.toggleFieldset(fieldset);
} }
return false;
}); });
$legend.append(summary); $legend.append(summary);
......
...@@ -295,6 +295,7 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) { ...@@ -295,6 +295,7 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) {
// Add the mousedown action for the handle. // Add the mousedown action for the handle.
handle.mousedown(function (event) { handle.mousedown(function (event) {
event.preventDefault();
// Create a new dragObject recording the event information. // Create a new dragObject recording the event information.
self.dragObject = {}; self.dragObject = {};
self.dragObject.initMouseOffset = self.getMouseOffset(item, event); self.dragObject.initMouseOffset = self.getMouseOffset(item, event);
...@@ -331,12 +332,11 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) { ...@@ -331,12 +332,11 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) {
// Call optional placeholder function. // Call optional placeholder function.
self.onDrag(); self.onDrag();
return false;
}); });
// Prevent the anchor tag from jumping us to the top of the page. // Prevent the anchor tag from jumping us to the top of the page.
handle.click(function () { handle.click(function (e) {
return false; e.preventDefault();
}); });
// Similar to the hover event, add a class when the handle is focused. // Similar to the hover event, add a class when the handle is focused.
......
...@@ -80,19 +80,19 @@ Drupal.verticalTab = function (settings) { ...@@ -80,19 +80,19 @@ Drupal.verticalTab = function (settings) {
var self = this; var self = this;
$.extend(this, settings, Drupal.theme('verticalTab', settings)); $.extend(this, settings, Drupal.theme('verticalTab', settings));
this.link.click(function () { this.link.click(function (e) {
e.preventDefault();
self.focus(); self.focus();
return false;
}); });
// Keyboard events added: // Keyboard events added:
// Pressing the Enter key will open the tab pane. // Pressing the Enter key will open the tab pane.
this.link.keydown(function(event) { this.link.keydown(function(event) {
event.preventDefault();
if (event.keyCode === 13) { if (event.keyCode === 13) {
self.focus(); self.focus();
// Set focus on the first input field of the visible fieldset/tab pane. // Set focus on the first input field of the visible fieldset/tab pane.
$("fieldset.vertical-tabs-pane :input:visible:enabled:first").focus(); $("fieldset.vertical-tabs-pane :input:visible:enabled:first").focus();
return false;
} }
}); });
......
...@@ -19,10 +19,10 @@ Drupal.behaviors.contextualLinks = { ...@@ -19,10 +19,10 @@ Drupal.behaviors.contextualLinks = {
var $region = $wrapper.closest('.contextual-region'); var $region = $wrapper.closest('.contextual-region');
var $links = $wrapper.find('ul'); var $links = $wrapper.find('ul');
var $trigger = $('<a class="trigger" href="#" />').text(Drupal.t('Configure')).click( var $trigger = $('<a class="trigger" href="#" />').text(Drupal.t('Configure')).click(
function () { function (e) {
e.preventDefault();
$links.stop(true, true).slideToggle(100); $links.stop(true, true).slideToggle(100);
$wrapper.toggleClass('contextual-active'); $wrapper.toggleClass('contextual-active');
return false;
} }
); );
// Attach hover behavior to trigger and ul.contextual-links. // Attach hover behavior to trigger and ul.contextual-links.
......
...@@ -79,6 +79,7 @@ Drupal.file = Drupal.file || { ...@@ -79,6 +79,7 @@ Drupal.file = Drupal.file || {
* Client-side file input validation of file extensions. * Client-side file input validation of file extensions.
*/ */
validateExtension: function (event) { validateExtension: function (event) {
event.preventDefault();
// Remove any previous errors. // Remove any previous errors.
$('.file-upload-js-error').remove(); $('.file-upload-js-error').remove();
...@@ -100,7 +101,6 @@ Drupal.file = Drupal.file || { ...@@ -100,7 +101,6 @@ Drupal.file = Drupal.file || {
}); });
$(this).closest('div.form-managed-file').prepend('<div class="messages error file-upload-js-error">' + error + '</div>'); $(this).closest('div.form-managed-file').prepend('<div class="messages error file-upload-js-error">' + error + '</div>');
this.value = ''; this.value = '';
return false;
} }
} }
}, },
...@@ -161,9 +161,9 @@ Drupal.file = Drupal.file || { ...@@ -161,9 +161,9 @@ Drupal.file = Drupal.file || {
* Open links to files within forms in a new window. * Open links to files within forms in a new window.
*/ */
openInNewWindow: function (event) { openInNewWindow: function (event) {
event.preventDefault();
$(this).attr('target', '_blank'); $(this).attr('target', '_blank');
window.open(this.href, 'filePreview', 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,width=500,height=550'); window.open(this.href, 'filePreview', 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,width=500,height=550');
return false;
} }
}; };
......
...@@ -25,7 +25,8 @@ Drupal.behaviors.openid = { ...@@ -25,7 +25,8 @@ Drupal.behaviors.openid = {
$context.find('li.openid-link') $context.find('li.openid-link')
.once('openid') .once('openid')
.click(function () { .click(function (e) {
e.preventDefault();
loginElements.hide(); loginElements.hide();
openidElements.css('display', 'block'); openidElements.css('display', 'block');
// Remove possible error message. // Remove possible error message.
...@@ -33,11 +34,11 @@ Drupal.behaviors.openid = { ...@@ -33,11 +34,11 @@ Drupal.behaviors.openid = {
$('div.messages.error').hide(); $('div.messages.error').hide();
// Set focus on OpenID Identifier field. // Set focus on OpenID Identifier field.
$('#edit-openid-identifier')[0].focus(); $('#edit-openid-identifier')[0].focus();
return false;
}); });
$context.find('li.user-link') $context.find('li.user-link')
.once('openid') .once('openid')
.click(function () { .click(function (e) {
e.preventDefault();
openidElements.hide(); openidElements.hide();
loginElements.css('display', 'block'); loginElements.css('display', 'block');
// Clear OpenID Identifier field and remove possible error message. // Clear OpenID Identifier field and remove possible error message.
...@@ -45,7 +46,6 @@ Drupal.behaviors.openid = { ...@@ -45,7 +46,6 @@ Drupal.behaviors.openid = {
$('div.messages.error').css('display', 'block'); $('div.messages.error').css('display', 'block');
// Set focus on username field. // Set focus on username field.
$('#edit-name')[0].focus(); $('#edit-name')[0].focus();
return false;
}); });
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment