diff --git a/core/misc/ajax.js b/core/misc/ajax.js index d599799..520901e 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -167,7 +167,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); }); @@ -184,7 +184,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/form.js b/core/misc/form.js index 0e7cf7b..d7c816c 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').andSelf().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 3cb7351..835413f 100644 --- a/core/misc/machine-name.js +++ b/core/misc/machine-name.js @@ -76,7 +76,7 @@ Drupal.behaviors.machineName = { $wrapper.show(); $target.focus(); $suffix.hide(); - $source.unbind('.machineName'); + $source.off('.machineName'); return false; }); $suffix.append(' ').append($link); @@ -85,7 +85,7 @@ Drupal.behaviors.machineName = { // 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', function () { + $source.on('keyup.machineName change.machineName', function () { machine = self.transliterate($(this).val(), options); // Set the machine name to the transliterated value. if (machine != '') { diff --git a/core/misc/states.js b/core/misc/states.js index 8883bca..7d20674 100644 --- a/core/misc/states.js +++ b/core/misc/states.js @@ -108,7 +108,7 @@ states.Dependent.prototype = { this.values[selector][state.name] = null; // Monitor state changes of the specified state for this dependee. - $(selector).bind('state:' + state, $.proxy(function (e) { + $(selector).on('state:' + state, $.proxy(function (e) { this.update(selector, state, e.value); }, this)); @@ -340,7 +340,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) { @@ -490,7 +490,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) { diff --git a/core/misc/tableheader.js b/core/misc/tableheader.js index 225cb73..fc4d89f 100644 --- a/core/misc/tableheader.js +++ b/core/misc/tableheader.js @@ -33,7 +33,7 @@ Drupal.tableHeader = function (table) { this.displayWeight = null; // React to columns change to avoid making checks in the scroll callback. - this.originalTable.bind('columnschange', function (e, display) { + this.originalTable.on('columnschange', function (e, display) { // This will force header size to be calculated on scroll. self.widthCalculated = (self.displayWeight !== null && self.displayWeight === display); self.displayWeight = display; @@ -51,16 +51,16 @@ Drupal.tableHeader = function (table) { this.originalTable.addClass('sticky-table'); $(window) - .bind('scroll.drupal-tableheader', $.proxy(this, 'eventhandlerRecalculateStickyHeader')) - .bind('resize.drupal-tableheader', { calculateWidth: true }, $.proxy(this, 'eventhandlerRecalculateStickyHeader')) + .on('scroll.drupal-tableheader', $.proxy(this, 'eventhandlerRecalculateStickyHeader')) + .on('resize.drupal-tableheader', { calculateWidth: true }, $.proxy(this, 'eventhandlerRecalculateStickyHeader')) // Make sure the anchor being scrolled into view is not hidden beneath the // sticky table header. Adjust the scrollTop if it does. - .bind('drupalDisplaceAnchor.drupal-tableheader', function () { + .on('drupalDisplaceAnchor.drupal-tableheader', function () { window.scrollBy(0, -self.stickyTable.outerHeight()); }) // Make sure the element being focused is not hidden beneath the sticky // table header. Adjust the scrollTop if it does. - .bind('drupalDisplaceFocus.drupal-tableheader', function (event) { + .on('drupalDisplaceFocus.drupal-tableheader', function (event) { if (self.stickyVisible && event.clientY < (self.stickyOffsetTop + self.stickyTable.outerHeight()) && event.$target.closest('sticky-header').length === 0) { window.scrollBy(0, -self.stickyTable.outerHeight()); } diff --git a/core/misc/vertical-tabs.js b/core/misc/vertical-tabs.js index baae1d1..0bcc7df 100644 --- a/core/misc/vertical-tabs.js +++ b/core/misc/vertical-tabs.js @@ -97,7 +97,7 @@ Drupal.verticalTab = function (settings) { }); this.fieldset - .bind('summaryUpdated', function () { + .on('summaryUpdated', function () { self.updateSummary(); }) .trigger('summaryUpdated'); diff --git a/core/modules/color/color.js b/core/modules/color/color.js index 31c526e..59eb19a 100644 --- a/core/modules/color/color.js +++ b/core/modules/color/color.js @@ -172,8 +172,8 @@ Drupal.behaviors.color = { function focus() { var input = this; // Remove old bindings. - focused && $(focused).unbind('keyup', farb.updateValue) - .unbind('keyup', preview).unbind('keyup', resetScheme) + focused && $(focused).off('keyup', farb.updateValue) + .off('keyup', preview).off('keyup', resetScheme) .parent().removeClass('item-selected'); // Add new bindings. diff --git a/core/modules/contextual/contextual.js b/core/modules/contextual/contextual.js index 3b7aeeb..bf81caf 100644 --- a/core/modules/contextual/contextual.js +++ b/core/modules/contextual/contextual.js @@ -31,7 +31,7 @@ Drupal.behaviors.contextualLinks = { function () { $region.removeClass('contextual-region-active'); } ); // Hide the contextual links when user clicks a link or rolls out of the .contextual-region. - $region.bind('mouseleave click', Drupal.contextualLinks.mouseleave); + $region.on('mouseleave click', Drupal.contextualLinks.mouseleave); $region.hover( function() { $trigger.addClass('contextual-links-trigger-active'); }, function() { $trigger.removeClass('contextual-links-trigger-active'); } diff --git a/core/modules/field_ui/field_ui.js b/core/modules/field_ui/field_ui.js index 87c1091..a2f0db6 100644 --- a/core/modules/field_ui/field_ui.js +++ b/core/modules/field_ui/field_ui.js @@ -34,7 +34,7 @@ Drupal.fieldUIFieldOverview = { var $this = $(this); this.targetSelect = $this.closest('tr').find('.widget-type-select'); - $this.bind('change keyup', function () { + $this.on('change keyup', function () { var selectedFieldType = this.options[this.selectedIndex].value; var options = (selectedFieldType in widgetTypes ? widgetTypes[selectedFieldType] : []); this.targetSelect.fieldUIPopulateOptions(options); @@ -53,11 +53,11 @@ Drupal.fieldUIFieldOverview = { this.targetTextfield = $tr.find('.label-textfield'); this.targetTextfield .data('field_ui_edited', false) - .bind('keyup', function (e) { + .on('keyup', function (e) { $(this).data('field_ui_edited', $(this).val() != ''); }); - $this.bind('change keyup', function (e, updateText) { + $this.on('change keyup', function (e, updateText) { var updateText = (typeof updateText == 'undefined' ? true : updateText); var selectedField = this.options[this.selectedIndex].value; var selectedFieldType = (selectedField in fields ? fields[selectedField].type : null); diff --git a/core/modules/file/file.js b/core/modules/file/file.js index 28237ea..a1f012d 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); } } } @@ -49,13 +49,13 @@ Drupal.behaviors.fileValidateAutoAttach = { 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); } }; @@ -64,10 +64,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 b002041..63c108c 100644 --- a/core/modules/filter/filter.admin.js +++ b/core/modules/filter/filter.admin.js @@ -14,7 +14,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 (tab) { diff --git a/core/modules/filter/filter.js b/core/modules/filter/filter.js index 9482737..02cb0cb 100644 --- a/core/modules/filter/filter.js +++ b/core/modules/filter/filter.js @@ -10,7 +10,7 @@ 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() .siblings('.filter-guidelines-' + this.value).show(); diff --git a/core/modules/overlay/overlay-child.js b/core/modules/overlay/overlay-child.js index 29a9790..ad70179 100644 --- a/core/modules/overlay/overlay-child.js +++ b/core/modules/overlay/overlay-child.js @@ -102,7 +102,7 @@ Drupal.overlayChild.attachBehaviors = function (context, settings) { * to bind their own handlers to links and also to prevent overlay's handling. */ Drupal.overlayChild.behaviors.addClickHandler = function (context, settings) { - $(document).bind('click.drupal-overlay mouseup.drupal-overlay', $.proxy(parent.Drupal.overlay, 'eventhandlerOverrideLink')); + $(document).on('click.drupal-overlay mouseup.drupal-overlay', $.proxy(parent.Drupal.overlay, 'eventhandlerOverrideLink')); }; /** @@ -135,7 +135,7 @@ Drupal.overlayChild.behaviors.loading = function (context, settings) { var text = Drupal.t('Loading'); var dots = ''; - $(document).bind('drupalOverlayBeforeLoad.drupal-overlay.drupal-overlay-child-loading', function () { + $(document).on('drupalOverlayBeforeLoad.drupal-overlay.drupal-overlay-child-loading', function () { $title = $('#overlay-title').text(text); var id = setInterval(function () { dots = (dots.length > 10) ? '' : dots + '.'; @@ -150,7 +150,7 @@ Drupal.overlayChild.behaviors.loading = function (context, settings) { Drupal.overlayChild.behaviors.tabs = function (context, settings) { var $tabsLinks = $('#overlay-tabs > li > a'); - $('#overlay-tabs > li > a').bind('click.drupal-overlay', function () { + $('#overlay-tabs > li > a').on('click.drupal-overlay', function () { var active_tab = Drupal.t('(active tab)'); $tabsLinks.parent().siblings().removeClass('active').find('element-invisible:contains(' + active_tab + ')').appendTo(this); $(this).parent().addClass('active'); @@ -169,7 +169,7 @@ Drupal.overlayChild.behaviors.shortcutAddLink = function (context, settings) { $addToShortcuts.insertAfter('#overlay-title'); } - $(document).bind('drupalOverlayBeforeLoad.drupal-overlay.drupal-overlay-child-loading', function () { + $(document).on('drupalOverlayBeforeLoad.drupal-overlay.drupal-overlay-child-loading', function () { $('#overlay-titlebar').find('.add-or-remove-shortcuts').remove(); }); }; diff --git a/core/modules/overlay/overlay-parent.js b/core/modules/overlay/overlay-parent.js index 6537cb6..8a33f6e 100644 --- a/core/modules/overlay/overlay-parent.js +++ b/core/modules/overlay/overlay-parent.js @@ -18,7 +18,7 @@ Drupal.behaviors.overlayParent = { $(window) // When the hash (URL fragment) changes, open the overlay if needed. - .bind('hashchange.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOperateByURLFragment')) + .on('hashchange.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOperateByURLFragment')) // Trigger the hashchange handler once, after the page is loaded, so that // permalinks open the overlay. .triggerHandler('hashchange.drupal-overlay'); @@ -28,7 +28,7 @@ Drupal.behaviors.overlayParent = { // the document and only handle events that bubble up. This allows other // scripts to bind their own handlers to links and also to prevent // overlay's handling. - .bind('click.drupal-overlay mouseup.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOverrideLink')); + .on('click.drupal-overlay mouseup.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOverrideLink')); } }; @@ -111,27 +111,27 @@ Drupal.overlay.create = function () { this.inactiveFrame = this.$iframeB = $(Drupal.theme('overlayElement')) .appendTo(this.$container); - this.$iframeA.bind('load.drupal-overlay', { self: this.$iframeA[0], sibling: this.$iframeB }, $.proxy(this, 'loadChild')); - this.$iframeB.bind('load.drupal-overlay', { self: this.$iframeB[0], sibling: this.$iframeA }, $.proxy(this, 'loadChild')); + this.$iframeA.on('load.drupal-overlay', { self: this.$iframeA[0], sibling: this.$iframeB }, $.proxy(this, 'loadChild')); + this.$iframeB.on('load.drupal-overlay', { self: this.$iframeB[0], sibling: this.$iframeA }, $.proxy(this, 'loadChild')); // Add a second class "drupal-overlay-open" to indicate these event handlers // should only be bound when the overlay is open. var eventClass = '.drupal-overlay.drupal-overlay-open'; $(window) - .bind('resize' + eventClass, $.proxy(this, 'eventhandlerOuterResize')); + .on('resize' + eventClass, $.proxy(this, 'eventhandlerOuterResize')); $(document) - .bind('drupalOverlayLoad' + eventClass, $.proxy(this, 'eventhandlerOuterResize')) - .bind('drupalOverlayReady' + eventClass + + .on('drupalOverlayLoad' + eventClass, $.proxy(this, 'eventhandlerOuterResize')) + .on('drupalOverlayReady' + eventClass + ' drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerSyncURLFragment')) - .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRefreshPage')) - .bind('drupalOverlayBeforeClose' + eventClass + + .on('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRefreshPage')) + .on('drupalOverlayBeforeClose' + eventClass + ' drupalOverlayBeforeLoad' + eventClass + ' drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerDispatchEvent')); if ($('.overlay-displace-top, .overlay-displace-bottom').length) { $(document) - .bind('drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerAlterDisplacedElements')) - .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRestoreDisplacedElements')); + .on('drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerAlterDisplacedElements')) + .on('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRestoreDisplacedElements')); } }; @@ -208,7 +208,7 @@ Drupal.overlay.close = function () { * Destroy the overlay. */ Drupal.overlay.destroy = function () { - $([document, window]).unbind('.drupal-overlay-open'); + $([document, window]).off('.drupal-overlay-open'); this.$container.remove(); this.$container = null; diff --git a/core/modules/system/system.js b/core/modules/system/system.js index 03bee22..a283279 100644 --- a/core/modules/system/system.js +++ b/core/modules/system/system.js @@ -29,7 +29,7 @@ Drupal.hideEmailAdministratorCheckbox = function () { Drupal.behaviors.copyFieldValue = { attach: function (context, settings) { for (var sourceId in settings.copyFieldValue) { - $('#' + sourceId, context).once('copy-field-values').bind('blur', function () { + $('#' + sourceId, context).once('copy-field-values').on('blur', function () { // Get the list of target fields. var targetIds = settings.copyFieldValue[sourceId]; // Add the behavior to update target fields on blur of the primary field. diff --git a/core/modules/user/user.js b/core/modules/user/user.js index 147c4c2..18f576c 100644 --- a/core/modules/user/user.js +++ b/core/modules/user/user.js @@ -191,7 +191,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).attr('checked')) { $checkbox.attr('checked', true); } diff --git a/core/modules/user/user.permissions.js b/core/modules/user/user.permissions.js index 2707512..5356e73 100644 --- a/core/modules/user/user.permissions.js +++ b/core/modules/user/user.permissions.js @@ -38,7 +38,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);