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) {
// spacebar activation causes inappropriate activation if #ajax['keypress'] is
// 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')) {
event.preventDefault();
$(ajax.element_settings.element).trigger(ajax.element_settings.event);
return false;
}
};
......@@ -228,12 +228,14 @@ Drupal.ajax.prototype.keypressResponse = function (element, event) {
* ajax object.
*/
Drupal.ajax.prototype.eventResponse = function (element, event) {
event.preventDefault();
// Create a synonym for this to reduce code confusion.
var ajax = this;
// Do not perform another ajax command if one is already in progress.
if (ajax.ajaxing) {
return false;
return;
}
try {
......@@ -261,16 +263,6 @@ Drupal.ajax.prototype.eventResponse = function (element, event) {
ajax.ajaxing = false;
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) {
}
switch (e.keyCode) {
case 40: // down arrow.
e.preventDefault();
this.selectDown();
return false;
break;
case 38: // up arrow.
e.preventDefault();
this.selectUp();
return false;
break;
default: // All other keys.
return true;
}
......
......@@ -87,14 +87,14 @@ Drupal.behaviors.collapse = {
var $link = $('<a class="fieldset-title" href="#"></a>')
.prepend($legend.contents())
.appendTo($legend)
.click(function () {
.click(function (e) {
e.preventDefault();
var fieldset = $fieldset.get(0);
// Don't animate multiple times.
if (!fieldset.animating) {
fieldset.animating = true;
Drupal.toggleFieldset(fieldset);
}
return false;
});
$legend.append(summary);
......
......@@ -295,6 +295,7 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) {
// Add the mousedown action for the handle.
handle.mousedown(function (event) {
event.preventDefault();
// Create a new dragObject recording the event information.
self.dragObject = {};
self.dragObject.initMouseOffset = self.getMouseOffset(item, event);
......@@ -331,12 +332,11 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) {
// Call optional placeholder function.
self.onDrag();
return false;
});
// Prevent the anchor tag from jumping us to the top of the page.
handle.click(function () {
return false;
handle.click(function (e) {
e.preventDefault();
});
// Similar to the hover event, add a class when the handle is focused.
......
......@@ -80,19 +80,19 @@ Drupal.verticalTab = function (settings) {
var self = this;
$.extend(this, settings, Drupal.theme('verticalTab', settings));
this.link.click(function () {
this.link.click(function (e) {
e.preventDefault();
self.focus();
return false;
});
// Keyboard events added:
// Pressing the Enter key will open the tab pane.
this.link.keydown(function(event) {
event.preventDefault();
if (event.keyCode === 13) {
self.focus();
// Set focus on the first input field of the visible fieldset/tab pane.
$("fieldset.vertical-tabs-pane :input:visible:enabled:first").focus();
return false;
}
});
......
......@@ -19,10 +19,10 @@ Drupal.behaviors.contextualLinks = {
var $region = $wrapper.closest('.contextual-region');
var $links = $wrapper.find('ul');
var $trigger = $('<a class="trigger" href="#" />').text(Drupal.t('Configure')).click(
function () {
function (e) {
e.preventDefault();
$links.stop(true, true).slideToggle(100);
$wrapper.toggleClass('contextual-active');
return false;
}
);
// Attach hover behavior to trigger and ul.contextual-links.
......
......@@ -79,6 +79,7 @@ Drupal.file = Drupal.file || {
* Client-side file input validation of file extensions.
*/
validateExtension: function (event) {
event.preventDefault();
// Remove any previous errors.
$('.file-upload-js-error').remove();
......@@ -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.value = '';
return false;
}
}
},
......@@ -161,9 +161,9 @@ Drupal.file = Drupal.file || {
* Open links to files within forms in a new window.
*/
openInNewWindow: function (event) {
event.preventDefault();
$(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');
return false;
}
};
......
......@@ -25,7 +25,8 @@ Drupal.behaviors.openid = {
$context.find('li.openid-link')
.once('openid')
.click(function () {
.click(function (e) {
e.preventDefault();
loginElements.hide();
openidElements.css('display', 'block');
// Remove possible error message.
......@@ -33,11 +34,11 @@ Drupal.behaviors.openid = {
$('div.messages.error').hide();
// Set focus on OpenID Identifier field.
$('#edit-openid-identifier')[0].focus();
return false;
});
$context.find('li.user-link')
.once('openid')
.click(function () {
.click(function (e) {
e.preventDefault();
openidElements.hide();
loginElements.css('display', 'block');
// Clear OpenID Identifier field and remove possible error message.
......@@ -45,7 +46,6 @@ Drupal.behaviors.openid = {
$('div.messages.error').css('display', 'block');
// Set focus on username field.
$('#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