From d4dcb5c357b942653b6259be4149e539ea24eedb Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Wed, 4 Dec 2013 14:28:18 +0000 Subject: [PATCH] Issue #1342198 by nod_, droplet, cosmicdreams, RobLoach, aspilicious: Use .on and .off instead of .bind, .unbind and .delegate. --- core/misc/ajax.js | 6 ++--- core/misc/collapse.js | 4 +-- core/misc/form.js | 6 ++--- core/misc/machine-name.js | 10 ++++---- core/misc/states.js | 16 ++++++------ core/misc/tabbingmanager.js | 2 +- core/misc/tabledrag.js | 30 +++++++++++----------- core/misc/tableheader.js | 2 +- core/misc/tableselect.js | 4 +-- core/misc/vertical-tabs.js | 8 +++--- core/modules/block/block.js | 6 ++--- core/modules/ckeditor/js/ckeditor.admin.js | 14 +++++----- core/modules/color/color.js | 12 ++++----- core/modules/editor/js/editor.js | 2 +- core/modules/field_ui/field_ui.js | 4 +-- core/modules/file/file.js | 16 ++++++------ core/modules/filter/filter.admin.js | 2 +- core/modules/filter/filter.js | 4 +-- core/modules/menu/menu.js | 4 +-- core/modules/shortcut/shortcut.admin.js | 2 +- core/modules/simpletest/simpletest.js | 6 ++--- core/modules/text/text.js | 2 +- core/modules/user/user.js | 2 +- core/modules/user/user.permissions.js | 2 +- core/modules/views_ui/js/ajax.js | 16 ++++++------ core/modules/views_ui/js/views-admin.js | 11 ++++---- 26 files changed, 97 insertions(+), 96 deletions(-) diff --git a/core/misc/ajax.js b/core/misc/ajax.js index a586945fdde..ad9dcae566d 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -258,7 +258,7 @@ Drupal.ajax = function (base, element, element_settings) { } // Bind the ajaxSubmit function to the element event. - $(ajax.element).bind(element_settings.event, function (event) { + $(ajax.element).on(element_settings.event, function (event) { return ajax.eventResponse(this, event); }); @@ -266,7 +266,7 @@ Drupal.ajax = function (base, element, element_settings) { // can be triggered through keyboard input as well as e.g. a mousedown // action. if (element_settings.keypress) { - $(ajax.element).keypress(function (event) { + $(ajax.element).on('keypress', function (event) { return ajax.keypressResponse(this, event); }); } @@ -275,7 +275,7 @@ Drupal.ajax = function (base, element, element_settings) { // For example, prevent the browser default action of a click, even if the // AJAX behavior binds to mousedown. if (element_settings.prevent) { - $(ajax.element).bind(element_settings.prevent, false); + $(ajax.element).on(element_settings.prevent, false); } }; diff --git a/core/misc/collapse.js b/core/misc/collapse.js index c26ab55e972..84a803d5272 100644 --- a/core/misc/collapse.js +++ b/core/misc/collapse.js @@ -40,7 +40,7 @@ $.extend(CollapsibleDetails.prototype, { setupSummary: function () { this.$summary = $(''); this.$node - .bind('summaryUpdated', $.proxy(this.onSummaryUpdated, this)) + .on('summaryUpdated', $.proxy(this.onSummaryUpdated, this)) .trigger('summaryUpdated'); }, /** @@ -60,7 +60,7 @@ $.extend(CollapsibleDetails.prototype, { .attr('href', '#' + this.$node.attr('id')) .prepend($legend.contents()) .appendTo($legend) - .click($.proxy(this.onLegendClick, this)); + .on('click', $.proxy(this.onLegendClick, this)); $legend.append(this.$summary); }, /** diff --git a/core/misc/form.js b/core/misc/form.js index d97559d53db..ff134e2c1ef 100644 --- a/core/misc/form.js +++ b/core/misc/form.js @@ -31,8 +31,8 @@ $.fn.drupalSetSummary = function (callback) { .data('summaryCallback', callback) // To prevent duplicate events, the handlers are first removed and then // (re-)added. - .unbind('formUpdated.summary') - .bind('formUpdated.summary', function () { + .off('formUpdated.summary') + .on('formUpdated.summary', function () { self.trigger('summaryUpdated'); }) // The actual summaryUpdated handler doesn't fire when the callback is @@ -53,7 +53,7 @@ Drupal.behaviors.formUpdated = { .find(':input').addBack().filter(':input') // To prevent duplicate events, the handlers are first removed and then // (re-)added. - .unbind(events).bind(events, function () { + .off(events).on(events, function () { $(this).trigger('formUpdated'); }); } diff --git a/core/misc/machine-name.js b/core/misc/machine-name.js index 9369e857223..53ed6687fca 100644 --- a/core/misc/machine-name.js +++ b/core/misc/machine-name.js @@ -35,9 +35,9 @@ Drupal.behaviors.machineName = { var data = e.data; e.preventDefault(); data.$wrapper.show(); - data.$target.focus(); + data.$target.trigger('focus'); data.$suffix.hide(); - data.$source.unbind('.machineName'); + data.$source.off('.machineName'); } function machineNameHandler(e) { @@ -109,16 +109,16 @@ Drupal.behaviors.machineName = { options: options }; // If it is editable, append an edit link. - var $link = $('').bind('click', eventData, clickEditHandler); + var $link = $('').on('click', eventData, clickEditHandler); $suffix.append(' ').append($link); // Preview the machine name in realtime when the human-readable name // changes, but only if there is no machine name yet; i.e., only upon // initial creation, not when editing. if ($target.val() === '') { - $source.bind('keyup.machineName change.machineName input.machineName', eventData, machineNameHandler) + $source.on('keyup.machineName change.machineName input.machineName', eventData, machineNameHandler) // Initialize machine name preview. - .keyup(); + .trigger('keyup'); } } } diff --git a/core/misc/states.js b/core/misc/states.js index 30a49dc5492..206d521c834 100644 --- a/core/misc/states.js +++ b/core/misc/states.js @@ -118,7 +118,7 @@ states.Dependent.prototype = { this.values[selector][state.name] = null; // Monitor state changes of the specified state for this dependee. - $(selector).bind('state:' + state, {selector: selector, state: state}, stateEventHandler); + $(selector).on('state:' + state, {selector: selector, state: state}, stateEventHandler); // Make sure the event we just bound ourselves to is actually fired. new states.Trigger({ selector: selector, state: state }); @@ -348,7 +348,7 @@ states.Trigger.prototype = { var oldValue = valueFn.call(this.element); // Attach the event callback. - this.element.bind(event, $.proxy(function (e) { + this.element.on(event, $.proxy(function (e) { var value = valueFn.call(this.element, e); // Only trigger the event if the value has actually changed. if (oldValue !== value) { @@ -500,7 +500,7 @@ states.State.prototype = { * can override these state change handlers for particular parts of a page. */ -$(document).bind('state:disabled', function(e) { +$(document).on('state:disabled', function (e) { // Only act when this change was triggered by a dependency and not by the // element monitoring itself. if (e.trigger) { @@ -514,7 +514,7 @@ $(document).bind('state:disabled', function(e) { } }); -$(document).bind('state:required', function(e) { +$(document).on('state:required', function (e) { if (e.trigger) { if (e.value) { var $label = $(e.target).attr({ 'required': 'required', 'aria-required': 'aria-required' }).closest('.form-item, .form-wrapper').find('label'); @@ -529,22 +529,22 @@ $(document).bind('state:required', function(e) { } }); -$(document).bind('state:visible', function(e) { +$(document).on('state:visible', function (e) { if (e.trigger) { $(e.target).closest('.form-item, .form-submit, .form-wrapper').toggle(e.value); } }); -$(document).bind('state:checked', function(e) { +$(document).on('state:checked', function (e) { if (e.trigger) { $(e.target).prop('checked', e.value); } }); -$(document).bind('state:collapsed', function(e) { +$(document).on('state:collapsed', function (e) { if (e.trigger) { if ($(e.target).is('[open]') === e.value) { - $(e.target).find('> summary a').click(); + $(e.target).find('> summary a').trigger('click'); } } }); diff --git a/core/misc/tabbingmanager.js b/core/misc/tabbingmanager.js index 9914233219e..05071207652 100644 --- a/core/misc/tabbingmanager.js +++ b/core/misc/tabbingmanager.js @@ -127,7 +127,7 @@ $.extend(TabbingManager.prototype, { if ($hasFocus.length === 0) { $hasFocus = $set.eq(0); } - $hasFocus.focus(); + $hasFocus.trigger('focus'); }, /** diff --git a/core/misc/tabledrag.js b/core/misc/tabledrag.js index 57e48a202e4..f8dc6149ca4 100644 --- a/core/misc/tabledrag.js +++ b/core/misc/tabledrag.js @@ -106,7 +106,7 @@ Drupal.tableDrag = function (table, tableSettings) { // Add a link before the table for users to show or hide weight columns. $table.before($('') .attr('title', Drupal.t('Re-order rows by numerical weight instead of dragging.')) - .click($.proxy(function (e) { + .on('click', $.proxy(function (e) { e.preventDefault(); this.toggleColumns(); }, this)) @@ -123,16 +123,16 @@ Drupal.tableDrag = function (table, tableSettings) { // Add event bindings to the document. The self variable is passed along // as event handlers do not have direct access to the tableDrag object. if (Modernizr.touch) { - $(document).bind('touchmove', function (event) { return self.dragRow(event.originalEvent.touches[0], self); }); - $(document).bind('touchend', function (event) { return self.dropRow(event.originalEvent.touches[0], self); }); + $(document).on('touchmove', function (event) { return self.dragRow(event.originalEvent.touches[0], self); }); + $(document).on('touchend', function (event) { return self.dropRow(event.originalEvent.touches[0], self); }); } else { - $(document).bind('mousemove', function (event) { return self.dragRow(event, self); }); - $(document).bind('mouseup', function (event) { return self.dropRow(event, self); }); + $(document).on('mousemove', function (event) { return self.dragRow(event, self); }); + $(document).on('mouseup', function (event) { return self.dropRow(event, self); }); } // React to localStorage event showing or hiding weight columns. - $(window).bind('storage', $.proxy(function (e) { + $(window).on('storage', $.proxy(function (e) { // Only react to 'Drupal.tableDrag.showWeight' value change. if (e.originalEvent.key === 'Drupal.tableDrag.showWeight') { // This was changed in another window, get the new value for this window. @@ -332,32 +332,32 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) { }); } else { - handle.mousedown(function (event) { + handle.on('mousedown', function (event) { event.preventDefault(); self.dragStart(event, self, item); }); } // Prevent the anchor tag from jumping us to the top of the page. - handle.click(function (e) { + handle.on('click', function (e) { e.preventDefault(); }); // Set blur cleanup when a handle is focused. - handle.focus(function () { + handle.on('focus', function () { self.safeBlur = true; }); // On blur, fire the same function as a touchend/mouseup. This is used to // update values after a row has been moved through the keyboard support. - handle.blur(function (event) { + handle.on('blur', function (event) { if (self.rowObject && self.safeBlur) { self.dropRow(event, self); } }); // Add arrow-key support to the handle. - handle.keydown(function (event) { + handle.on('keydown', function (event) { // If a rowObject doesn't yet exist and this isn't the tab key. if (event.keyCode !== 9 && !self.rowObject) { self.rowObject = new self.row(item, 'keyboard', self.indentEnabled, self.maxDepth, true); @@ -406,7 +406,7 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) { self.rowObject.indent(0); window.scrollBy(0, -parseInt(item.offsetHeight, 10)); } - handle.get(0).focus(); // Regain focus after the DOM manipulation. + handle.trigger('focus'); // Regain focus after the DOM manipulation. } break; case 39: // Right arrow. @@ -448,7 +448,7 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) { self.rowObject.indent(0); window.scrollBy(0, parseInt(item.offsetHeight, 10)); } - handle.get(0).focus(); // Regain focus after the DOM manipulation. + handle.trigger('focus'); // Regain focus after the DOM manipulation. } break; } @@ -472,7 +472,7 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) { // Compatibility addition, return false on keypress to prevent unwanted scrolling. // IE and Safari will suppress scrolling on keydown, but all other browsers // need to return false on keypress. http://www.quirksmode.org/js/keys.html - handle.keypress(function (event) { + handle.on('keypress', function (event) { switch (event.keyCode) { case 37: // Left arrow. case 38: // Up arrow. @@ -504,7 +504,7 @@ Drupal.tableDrag.prototype.dragStart = function (event, self, item) { // If there's a lingering row object from the keyboard, remove its focus. if (self.rowObject) { - $(self.rowObject.element).find('a.tabledrag-handle').blur(); + $(self.rowObject.element).find('a.tabledrag-handle').trigger('blur'); } // Create a new rowObject for manipulation of this row. diff --git a/core/misc/tableheader.js b/core/misc/tableheader.js index d04b624e25c..2519304eb1e 100644 --- a/core/misc/tableheader.js +++ b/core/misc/tableheader.js @@ -93,7 +93,7 @@ function TableHeader(table) { this.tableOffset = this.$originalTable.offset(); // React to columns change to avoid making checks in the scroll callback. - this.$originalTable.bind('columnschange', {tableHeader: this}, function (e, display) { + this.$originalTable.on('columnschange', {tableHeader: this}, function (e, display) { var tableHeader = e.data.tableHeader; if (tableHeader.displayWeight === null || tableHeader.displayWeight !== display) { tableHeader.recalculateSticky(); diff --git a/core/misc/tableselect.js b/core/misc/tableselect.js index b3ab4c42c02..da3a7225d9a 100644 --- a/core/misc/tableselect.js +++ b/core/misc/tableselect.js @@ -28,7 +28,7 @@ Drupal.tableSelect = function () { }; // Find all with class select-all, and insert the check all checkbox. - $table.find('th.select-all').prepend($('').attr('title', strings.selectAll)).click(function (event) { + $table.find('th.select-all').prepend($('').attr('title', strings.selectAll)).on('click', function (event) { if ($(event.target).is('input[type="checkbox"]')) { // Loop through all checkboxes and set their state to the select all checkbox' state. checkboxes.each(function () { @@ -42,7 +42,7 @@ Drupal.tableSelect = function () { }); // For each of the checkboxes within the table that are not disabled. - checkboxes = $table.find('td input[type="checkbox"]:enabled').click(function (e) { + checkboxes = $table.find('td input[type="checkbox"]:enabled').on('click', function (e) { // Either add or remove the selected class based on the state of the check all checkbox. $(this).closest('tr').toggleClass('selected', this.checked); diff --git a/core/misc/vertical-tabs.js b/core/misc/vertical-tabs.js index a02fa2c5d89..d45bcac1603 100644 --- a/core/misc/vertical-tabs.js +++ b/core/misc/vertical-tabs.js @@ -90,24 +90,24 @@ Drupal.verticalTab = function (settings) { this.link.attr('href', '#' + settings.details.attr('id')); - this.link.click(function (e) { + this.link.on('click', function (e) { e.preventDefault(); self.focus(); }); // Keyboard events added: // Pressing the Enter key will open the tab pane. - this.link.keydown(function(event) { + this.link.on('keydown', function (event) { event.preventDefault(); if (event.keyCode === 13) { self.focus(); // Set focus on the first input field of the visible details/tab pane. - $(".vertical-tabs-pane :input:visible:enabled:first").focus(); + $(".vertical-tabs-pane :input:visible:enabled:first").trigger('focus'); } }); this.details - .bind('summaryUpdated', function () { + .on('summaryUpdated', function () { self.updateSummary(); }) .trigger('summaryUpdated'); diff --git a/core/modules/block/block.js b/core/modules/block/block.js index 7025ce172f4..9ff920d448c 100644 --- a/core/modules/block/block.js +++ b/core/modules/block/block.js @@ -78,7 +78,7 @@ Drupal.behaviors.blockDrag = { window.alert(Drupal.t('The block cannot be placed in this region.')); // Simulate that there was a selected element change, so the row is put // back to from where the user tried to drag it. - regionField.change(); + regionField.trigger('change'); } else if ($rowElement.prev('tr').is('.region-message')) { var weightField = $rowElement.find('select.block-weight'); @@ -94,7 +94,7 @@ Drupal.behaviors.blockDrag = { // Add the behavior to each region select list. $(context).find('select.block-region-select').once('block-region-select', function () { - $(this).change(function (event) { + $(this).on('change', function (event) { // Make our new row and select field. var row = $(this).closest('tr'); var select = $(this); @@ -106,7 +106,7 @@ Drupal.behaviors.blockDrag = { // Modify empty regions with added or removed fields. checkEmptyRegions(table, row); // Remove focus from selectbox. - select.get(0).blur(); + select.trigger('blur'); }); }); diff --git a/core/modules/ckeditor/js/ckeditor.admin.js b/core/modules/ckeditor/js/ckeditor.admin.js index 84aa024494c..ccf2f715407 100644 --- a/core/modules/ckeditor/js/ckeditor.admin.js +++ b/core/modules/ckeditor/js/ckeditor.admin.js @@ -536,7 +536,7 @@ Drupal.ckeditor = { if (success) { $group.appendTo($(event.currentTarget).closest('.ckeditor-row').children('.ckeditor-toolbar-groups')); // Focus on the new group. - $group.focus(); + $group.trigger('focus'); } } @@ -574,7 +574,7 @@ Drupal.ckeditor = { * elements involved in the sort action. */ startButtonDrag: function (event, ui) { - this.$el.find('a:focus').blur(); + this.$el.find('a:focus').trigger('blur'); // Show the button group names as soon as the user starts dragging. this.model.set('groupNamesVisible', true); @@ -597,7 +597,7 @@ Drupal.ckeditor = { } // Refocus the target button so that the user can continue from a known // place. - ui.item.find('a').focus(); + ui.item.find('a').trigger('focus'); }); }, @@ -809,7 +809,7 @@ Drupal.ckeditor = { .off() .remove(); // Focus on the first button in the active toolbar. - $activeButtons.find('.ckeditor-toolbar-group-buttons').eq(0).children().eq(0).children().focus(); + $activeButtons.find('.ckeditor-toolbar-group-buttons').eq(0).children().eq(0).children().trigger('focus'); } // Otherwise, move it. else { @@ -852,7 +852,7 @@ Drupal.ckeditor = { } // Refocus the target button so that the user can continue from a known // place. - $target.focus(); + $target.trigger('focus'); }); event.preventDefault(); @@ -933,7 +933,7 @@ Drupal.ckeditor = { } registerGroupMove(this, $group); - $group.focus(); + $group.trigger('focus'); event.preventDefault(); event.stopPropagation(); } @@ -1410,7 +1410,7 @@ function openGroupNameDialog (view, $group, callback) { // When editing, set the "group name" input in the form to the current value. .attr('value', $group.attr('data-drupal-ckeditor-toolbar-group-name')) // Focus on the "group name" input in the form. - .focus(); + .trigger('focus'); } /** diff --git a/core/modules/color/color.js b/core/modules/color/color.js index ca74657c549..704fc1c023d 100644 --- a/core/modules/color/color.js +++ b/core/modules/color/color.js @@ -55,7 +55,7 @@ Drupal.behaviors.color = { } // Set up colorScheme selector. - form.find('#edit-scheme').change(function () { + form.find('#edit-scheme').on('change', function () { var schemes = settings.color.schemes, colorScheme = this.options[this.selectedIndex].value; if (colorScheme !== '' && schemes[colorScheme]) { // Get colors of active scheme. @@ -184,8 +184,8 @@ Drupal.behaviors.color = { var input = e.target; // Remove old bindings. if (focused) { - $(focused).unbind('keyup', farb.updateValue) - .unbind('keyup', preview).unbind('keyup', resetScheme) + $(focused).off('keyup', farb.updateValue) + .off('keyup', preview).off('keyup', resetScheme) .parent().removeClass('item-selected'); } @@ -193,7 +193,7 @@ Drupal.behaviors.color = { focused = input; farb.linkTo(function (color) { callback(input, color, true, false); }); farb.setColor(input.value); - $(focused).keyup(farb.updateValue).keyup(preview).keyup(resetScheme) + $(focused).on('keyup', farb.updateValue).on('keyup', preview).on('keyup', resetScheme) .parent().addClass('item-selected'); } @@ -240,11 +240,11 @@ Drupal.behaviors.color = { $(this).after(hook); hooks.push(hook); - $(this).parent().find('.lock').click(); + $(this).parent().find('.lock').trigger('click'); this.i = i; inputs.push(this); }) - .focus(focus); + .on('focus', focus); form.find('#palette label'); diff --git a/core/modules/editor/js/editor.js b/core/modules/editor/js/editor.js index 18493d6f8bd..c1cdcbccb27 100644 --- a/core/modules/editor/js/editor.js +++ b/core/modules/editor/js/editor.js @@ -55,7 +55,7 @@ Drupal.behaviors.editor = { }); } // Detach any editor when the containing form is submitted. - $this.parents('form').submit(function (event) { + $this.parents('form').on('submit', function (event) { // Do not detach if the event was canceled. if (event.isDefaultPrevented()) { return; diff --git a/core/modules/field_ui/field_ui.js b/core/modules/field_ui/field_ui.js index 2955bf9b11f..9297462d0b9 100644 --- a/core/modules/field_ui/field_ui.js +++ b/core/modules/field_ui/field_ui.js @@ -157,7 +157,7 @@ Drupal.fieldUIOverview = { // Fire the Ajax update. $('input[name=refresh_rows]').val(rowNames.join(' ')); - $('input#edit-refresh').mousedown(); + $('input#edit-refresh').trigger('mousedown'); // Disabled elements do not appear in POST ajax data, so we mark the // elements disabled only after firing the request. @@ -190,7 +190,7 @@ Drupal.fieldUIDisplayOverview.field = function (row, data) { // Attach change listener to the 'plugin type' select. this.$pluginSelect = $(row).find('select.field-plugin-type'); - this.$pluginSelect.change(Drupal.fieldUIOverview.onChange); + this.$pluginSelect.on('change', Drupal.fieldUIOverview.onChange); return this; }; diff --git a/core/modules/file/file.js b/core/modules/file/file.js index df1c3b1a5f7..c7c6362ff6a 100644 --- a/core/modules/file/file.js +++ b/core/modules/file/file.js @@ -23,7 +23,7 @@ Drupal.behaviors.fileValidateAutoAttach = { elements = settings.file.elements; for (selector in elements) { if (elements.hasOwnProperty(selector)) { - $context.find(selector).bind('change', {extensions: elements[selector]}, validateExtension); + $context.find(selector).on('change', {extensions: elements[selector]}, validateExtension); } } } @@ -36,7 +36,7 @@ Drupal.behaviors.fileValidateAutoAttach = { elements = settings.file.elements; for (selector in elements) { if (elements.hasOwnProperty(selector)) { - $context.find(selector).unbind('change', validateExtension); + $context.find(selector).off('change', validateExtension); } } } @@ -63,13 +63,13 @@ Drupal.behaviors.fileAutoUpload = { Drupal.behaviors.fileButtons = { attach: function (context) { var $context = $(context); - $context.find('input.form-submit').bind('mousedown', Drupal.file.disableFields); - $context.find('div.form-managed-file input.form-submit').bind('mousedown', Drupal.file.progressBar); + $context.find('input.form-submit').on('mousedown', Drupal.file.disableFields); + $context.find('div.form-managed-file input.form-submit').on('mousedown', Drupal.file.progressBar); }, detach: function (context) { var $context = $(context); - $context.find('input.form-submit').unbind('mousedown', Drupal.file.disableFields); - $context.find('div.form-managed-file input.form-submit').unbind('mousedown', Drupal.file.progressBar); + $context.find('input.form-submit').off('mousedown', Drupal.file.disableFields); + $context.find('div.form-managed-file input.form-submit').off('mousedown', Drupal.file.progressBar); } }; @@ -78,10 +78,10 @@ Drupal.behaviors.fileButtons = { */ Drupal.behaviors.filePreviewLinks = { attach: function (context) { - $(context).find('div.form-managed-file .file a, .file-widget .file a').bind('click',Drupal.file.openInNewWindow); + $(context).find('div.form-managed-file .file a, .file-widget .file a').on('click',Drupal.file.openInNewWindow); }, detach: function (context){ - $(context).find('div.form-managed-file .file a, .file-widget .file a').unbind('click', Drupal.file.openInNewWindow); + $(context).find('div.form-managed-file .file a, .file-widget .file a').off('click', Drupal.file.openInNewWindow); } }; diff --git a/core/modules/filter/filter.admin.js b/core/modules/filter/filter.admin.js index b440faef872..cde65a5d4cb 100644 --- a/core/modules/filter/filter.admin.js +++ b/core/modules/filter/filter.admin.js @@ -20,7 +20,7 @@ Drupal.behaviors.filterStatus = { // Bind click handler to this checkbox to conditionally show and hide the // filter's tableDrag row and vertical tab pane. - $checkbox.bind('click.filterUpdate', function () { + $checkbox.on('click.filterUpdate', function () { if ($checkbox.is(':checked')) { $row.show(); if (filterSettingsTab) { diff --git a/core/modules/filter/filter.js b/core/modules/filter/filter.js index 4bb10e0bf00..c9e8388809a 100644 --- a/core/modules/filter/filter.js +++ b/core/modules/filter/filter.js @@ -15,12 +15,12 @@ Drupal.behaviors.filterGuidelines = { $(context).find('.filter-guidelines').once('filter-guidelines') .find(':header').hide() .closest('.filter-wrapper').find('select.filter-list') - .bind('change', function () { + .on('change', function () { $(this).closest('.filter-wrapper') .find('.filter-guidelines-item').hide() .filter('.filter-guidelines-' + this.value).show(); }) - .change(); + .trigger('change'); } }; diff --git a/core/modules/menu/menu.js b/core/modules/menu/menu.js index 77baddbb68c..c9e14b5447d 100644 --- a/core/modules/menu/menu.js +++ b/core/modules/menu/menu.js @@ -39,7 +39,7 @@ Drupal.behaviors.menuLinkAutomaticTitle = { $link_title.data('menuLinkAutomaticTitleOveridden', true); } // Whenever the value is changed manually, disable this behavior. - $link_title.keyup(function () { + $link_title.on('keyup', function () { $link_title.data('menuLinkAutomaticTitleOveridden', true); }); // Global trigger on checkbox (do not fill-in a value when disabled). @@ -57,7 +57,7 @@ Drupal.behaviors.menuLinkAutomaticTitle = { $checkbox.trigger('formUpdated'); }); // Take over any title change. - $title.keyup(function () { + $title.on('keyup', function () { if (!$link_title.data('menuLinkAutomaticTitleOveridden') && $checkbox.is(':checked')) { $link_title.val($title.val()); $link_title.val($title.val()).trigger('formUpdated'); diff --git a/core/modules/shortcut/shortcut.admin.js b/core/modules/shortcut/shortcut.admin.js index 7cad31f1fe7..c95e4fdbc97 100644 --- a/core/modules/shortcut/shortcut.admin.js +++ b/core/modules/shortcut/shortcut.admin.js @@ -11,7 +11,7 @@ Drupal.behaviors.newSet = { var selectDefault = function() { $(this).closest('form').find('.form-item-set .form-type-radio:last input').prop('checked', true); }; - $('div.form-item-new input').focus(selectDefault).keyup(selectDefault); + $('div.form-item-new input').on('focus', selectDefault).on('keyup', selectDefault); } }; diff --git a/core/modules/simpletest/simpletest.js b/core/modules/simpletest/simpletest.js index 70493589175..aa422ed597d 100644 --- a/core/modules/simpletest/simpletest.js +++ b/core/modules/simpletest/simpletest.js @@ -15,7 +15,7 @@ Drupal.behaviors.simpleTestMenuCollapse = { $this.html(drupalSettings.simpleTest.images[direction]); // Adds group toggling functionality to arrow images. - $this.click(function () { + $this.on('click', function () { var trs = $this.closest('tbody').children('.' + drupalSettings.simpleTest[this.id].testClass); var direction = drupalSettings.simpleTest[this.id].imageDirection; var row = direction ? trs.length - 1 : 0; @@ -80,7 +80,7 @@ Drupal.behaviors.simpleTestSelectAll = { } // Have the single-test checkboxes follow the group checkbox. - groupCheckbox.change(function () { + groupCheckbox.on('change', function () { var checked = $(this).prop('checked'); for (var i = 0; i < testCheckboxes.length; i++) { $('#' + testCheckboxes[i]).prop('checked', checked); @@ -89,7 +89,7 @@ Drupal.behaviors.simpleTestSelectAll = { // Have the group checkbox follow the single-test checkboxes. for (var i = 0; i < testCheckboxes.length; i++) { - $('#' + testCheckboxes[i]).change(updateGroupCheckbox); + $('#' + testCheckboxes[i]).on('change', updateGroupCheckbox); } // Initialize status for the group checkbox correctly. diff --git a/core/modules/text/text.js b/core/modules/text/text.js index 347b6e8b3a4..78a180a34c3 100644 --- a/core/modules/text/text.js +++ b/core/modules/text/text.js @@ -42,7 +42,7 @@ Drupal.behaviors.textSummary = { // If no summary is set, hide the summary field. if ($widget.find('.text-summary').val() === '') { - $link.click(); + $link.trigger('click'); } }); } diff --git a/core/modules/user/user.js b/core/modules/user/user.js index 564cebdacfd..7b1ccfad943 100644 --- a/core/modules/user/user.js +++ b/core/modules/user/user.js @@ -180,7 +180,7 @@ Drupal.behaviors.fieldUserRegistration = { if ($checkbox.length) { $(context).find('input#edit-instance-required').once('user-register-form-checkbox', function () { - $(this).bind('change', function (e) { + $(this).on('change', function (e) { if ($(this).prop('checked')) { $checkbox.prop('checked', true); } diff --git a/core/modules/user/user.permissions.js b/core/modules/user/user.permissions.js index 15658a9f4ba..850dd8835b9 100644 --- a/core/modules/user/user.permissions.js +++ b/core/modules/user/user.permissions.js @@ -41,7 +41,7 @@ Drupal.behaviors.permissions = { // Initialize the authenticated user checkbox. $table.find('input[type=checkbox].rid-authenticated') - .bind('click.permissions', self.toggle) + .on('click.permissions', self.toggle) // .triggerHandler() cannot be used here, as it only affects the first // element. .each(self.toggle); diff --git a/core/modules/views_ui/js/ajax.js b/core/modules/views_ui/js/ajax.js index 84d65c8d5ce..f9263307018 100644 --- a/core/modules/views_ui/js/ajax.js +++ b/core/modules/views_ui/js/ajax.js @@ -49,9 +49,9 @@ */ Drupal.behaviors.livePreview = { attach: function (context) { - $('input#edit-displays-live-preview', context).once('views-ajax-processed').click(function() { + $('input#edit-displays-live-preview', context).once('views-ajax').on('click', function () { if ($(this).is(':checked')) { - $('#preview-submit').click(); + $('#preview-submit').trigger('click'); } }); } @@ -62,13 +62,13 @@ */ Drupal.behaviors.syncPreviewDisplay = { attach: function (context) { - $("#views-tabset a").once('views-ajax-processed').click(function() { + $("#views-tabset a").once('views-ajax').on('click', function () { var href = $(this).attr('href'); // Cut of #views-tabset. var display_id = href.substr(11); // Set the form element. $("#views-live-preview #preview-display-id").val(display_id); - }).addClass('views-ajax-processed'); + }); } }; @@ -80,7 +80,7 @@ 'progress': { 'type': 'throbber' } }; // Bind AJAX behaviors to all items showing the class. - $('a.views-ajax-link', context).once('views-ajax-processed').each(function () { + $('a.views-ajax-link', context).once('views-ajax').each(function () { var element_settings = base_element_settings; // Set the URL to go to the anchor. if ($(this).attr('href')) { @@ -91,7 +91,7 @@ }); $('div#views-live-preview a') - .once('views-ajax-processed').each(function () { + .once('views-ajax').each(function () { // We don't bind to links without a URL. if (!$(this).attr('href')) { return true; @@ -115,8 +115,8 @@ // @todo Revisit this after fixing Views UI to display a Preview outside // of the main Edit form. $('div#views-live-preview input[type=submit]') - .once('views-ajax-processed').each(function(event) { - $(this).click(function () { + .once('views-ajax').each(function(event) { + $(this).on('click', function () { this.form.clk = this; return true; }); diff --git a/core/modules/views_ui/js/views-admin.js b/core/modules/views_ui/js/views-admin.js index 0311e266c48..b4432273178 100644 --- a/core/modules/views_ui/js/views-admin.js +++ b/core/modules/views_ui/js/views-admin.js @@ -307,7 +307,7 @@ Drupal.viewsUi.OptionsSearch = function ($form) { this.$form = $form; // Add a keyup handler to the search box. this.$searchBox = this.$form.find('#edit-override-controls-options-search'); - this.$searchBox.keyup($.proxy(this.handleKeyup, this)); + this.$searchBox.on('keyup', $.proxy(this.handleKeyup, this)); // Get a list of option labels and their corresponding divs and maintain it // in memory, so we have as little overhead as possible at keyup time. this.options = this.getOptions(this.$form.find('.filterable-option')); @@ -527,7 +527,7 @@ $.extend(Drupal.viewsUi.RearrangeFilterHandler.prototype, { clickAddGroupButton: function () { // Due to conflicts between Drupal core's AJAX system and the Views AJAX // system, the only way to get this to work seems to be to trigger both the - // .mousedown() and .submit() events. + // mousedown and submit events. this.addGroupButton .trigger('mousedown') .trigger('submit'); @@ -856,7 +856,7 @@ Drupal.viewsUi.Checkboxifier = function (button) { this.$button.hide(); this.$parent.find('.exposed-description, .grouped-description').hide(); - this.$input.click($.proxy(this, 'clickHandler')); + this.$input.on('click', $.proxy(this, 'clickHandler')); }; @@ -864,8 +864,9 @@ Drupal.viewsUi.Checkboxifier = function (button) { * When the checkbox is checked or unchecked, simulate a button press. */ Drupal.viewsUi.Checkboxifier.prototype.clickHandler = function (e) { - this.$button.mousedown(); - this.$button.submit(); + this.$button + .trigger('mousedown') + .trigger('submit'); }; /**