Commit 3b61f06b authored by alexpott's avatar alexpott

Issue #2019481 by nod_: JavaScript AJAX commands object is borked: it is...

Issue #2019481 by nod_: JavaScript AJAX commands object is borked: it is shared among all Drupal.ajax instances, preventing scoped overrides.
parent ba810ba1
......@@ -691,7 +691,7 @@ function ajax_pre_render_element($element) {
* The 'alert' command instructs the client to display a JavaScript alert
* dialog box.
*
* This command is implemented by Drupal.ajax.prototype.commands.alert()
* This command is implemented by Drupal.AjaxCommands.prototype.alert()
* defined in misc/ajax.js.
*
* @param $text
......@@ -714,7 +714,7 @@ function ajax_command_alert($text) {
* jQuery DOM manipulation method has been specified in the #ajax['method']
* variable of the element that triggered the request.
*
* This command is implemented by Drupal.ajax.prototype.commands.insert()
* This command is implemented by Drupal.AjaxCommands.prototype.insert()
* defined in misc/ajax.js.
*
* @param $selector
......@@ -745,7 +745,7 @@ function ajax_command_insert($selector, $html, $settings = NULL) {
* method to prepend the given HTML content to the inside each element matched
* by the given selector.
*
* This command is implemented by Drupal.ajax.prototype.commands.insert()
* This command is implemented by Drupal.AjaxCommands.prototype.insert()
* defined in misc/ajax.js.
*
* @param $selector
......@@ -778,7 +778,7 @@ function ajax_command_prepend($selector, $html, $settings = NULL) {
* method to append the given HTML content to the inside of each element matched
* by the given selector.
*
* This command is implemented by Drupal.ajax.prototype.commands.insert()
* This command is implemented by Drupal.AjaxCommands.prototype.insert()
* defined in misc/ajax.js.
*
* @param $selector
......@@ -811,7 +811,7 @@ function ajax_command_append($selector, $html, $settings = NULL) {
* to remove each of elements matched by the given selector, and everything
* within them.
*
* This command is implemented by Drupal.ajax.prototype.commands.remove()
* This command is implemented by Drupal.AjaxCommands.prototype.remove()
* defined in misc/ajax.js.
*
* @param $selector
......@@ -836,7 +836,7 @@ function ajax_command_remove($selector) {
* This command instructs the client to mark each of the elements matched by the
* given selector as 'ajax-changed'.
*
* This command is implemented by Drupal.ajax.prototype.commands.changed()
* This command is implemented by Drupal.AjaxCommands.prototype.changed()
* defined in misc/ajax.js.
*
* @param $selector
......@@ -863,7 +863,7 @@ function ajax_command_changed($selector, $asterisk = '') {
* The 'css' command will instruct the client to use the jQuery css() method
* to apply the CSS arguments to elements matched by the given selector.
*
* This command is implemented by Drupal.ajax.prototype.commands.css()
* This command is implemented by Drupal.AjaxCommands.prototype.css()
* defined in misc/ajax.js.
*
* @param $selector
......@@ -892,7 +892,7 @@ function ajax_command_css($selector, $argument) {
* the settings for ajax-loaded content or to extend Drupal.settings with the
* given array, depending on the value of the $merge parameter.
*
* This command is implemented by Drupal.ajax.prototype.commands.settings()
* This command is implemented by Drupal.AjaxCommands.prototype.settings()
* defined in misc/ajax.js.
*
* @param $argument
......@@ -921,7 +921,7 @@ function ajax_command_settings($argument, $merge = FALSE) {
*
* This method will add css via ajax in a cross-browser compatible way.
*
* This command is implemented by Drupal.ajax.prototype.commands.add_css()
* This command is implemented by Drupal.AjaxCommands.prototype.add_css()
* defined in misc/ajax.js.
*
* @param $styles
......
......@@ -12,7 +12,7 @@
/**
* An AJAX command for adding css to the page via ajax.
*
* This command is implemented by Drupal.ajax.prototype.commands.add_css()
* This command is implemented by Drupal.AjaxCommands.prototype.add_css()
* defined in misc/ajax.js.
*
* @see misc/ajax.js
......
......@@ -16,7 +16,7 @@
* method to insert the given HTML content after each element matched by the
* given selector.
*
* This command is implemented by Drupal.ajax.prototype.commands.insert()
* This command is implemented by Drupal.AjaxCommands.prototype.insert()
* defined in misc/ajax.js.
*
* @see http://docs.jquery.com/Manipulation/after#content
......
......@@ -16,7 +16,7 @@
* method to append the given HTML content to the inside of each element matched
* by the given selector.
*
* This command is implemented by Drupal.ajax.prototype.commands.insert()
* This command is implemented by Drupal.AjaxCommands.prototype.insert()
* defined in misc/ajax.js.
*
* @see http://docs.jquery.com/Manipulation/append#content
......
......@@ -16,7 +16,7 @@
* method to insert the given HTML content before each of elements matched by
* the given selector.
*
* This command is implemented by Drupal.ajax.prototype.commands.insert()
* This command is implemented by Drupal.AjaxCommands.prototype.insert()
* defined in misc/ajax.js.
*
* @see http://docs.jquery.com/Manipulation/before#content
......
......@@ -15,7 +15,7 @@
* This command instructs the client to mark each of the elements matched by the
* given selector as 'ajax-changed'.
*
* This command is implemented by Drupal.ajax.prototype.commands.changed()
* This command is implemented by Drupal.AjaxCommands.prototype.changed()
* defined in misc/ajax.js.
*/
class ChangedCommand implements CommandInterface {
......
......@@ -15,7 +15,7 @@
* The 'css' command will instruct the client to use the jQuery css() method to
* apply the CSS arguments to elements matched by the given selector.
*
* This command is implemented by Drupal.ajax.prototype.commands.css() defined
* This command is implemented by Drupal.AjaxCommands.prototype.css() defined
* in misc/ajax.js.
*
* @see http://docs.jquery.com/CSS/css#properties
......
......@@ -15,7 +15,7 @@
* This instructs the client to attach the name=value pair of data to the
* selector via jQuery's data cache.
*
* This command is implemented by Drupal.ajax.prototype.commands.data() defined
* This command is implemented by Drupal.AjaxCommands.prototype.data() defined
* in misc/ajax.js.
*/
class DataCommand implements CommandInterface {
......
......@@ -16,7 +16,7 @@
* to set the HTML content of each element matched by the given selector while
* leaving the outer tags intact.
*
* This command is implemented by Drupal.ajax.prototype.commands.insert()
* This command is implemented by Drupal.AjaxCommands.prototype.insert()
* defined in misc/ajax.js.
*
* @see http://docs.jquery.com/Attributes/html#val
......
......@@ -16,7 +16,7 @@
* jQuery DOM manipulation method has been specified in the #ajax['method']
* variable of the element that triggered the request.
*
* This command is implemented by Drupal.ajax.prototype.commands.insert()
* This command is implemented by Drupal.AjaxCommands.prototype.insert()
* defined in misc/ajax.js.
*/
class InsertCommand implements CommandInterface {
......
......@@ -17,7 +17,7 @@
* selector. Intended for simple jQuery commands, such as attr(), addClass(),
* removeClass(), toggleClass(), etc.
*
* This command is implemented by Drupal.ajax.prototype.commands.invoke()
* This command is implemented by Drupal.AjaxCommands.prototype.invoke()
* defined in misc/ajax.js.
*/
class InvokeCommand implements CommandInterface {
......
......@@ -16,7 +16,7 @@
* method to prepend the given HTML content to the inside each element matched
* by the given selector.
*
* This command is implemented by Drupal.ajax.prototype.commands.insert()
* This command is implemented by Drupal.AjaxCommands.prototype.insert()
* defined in misc/ajax.js.
*
* @see http://docs.jquery.com/Manipulation/prepend#content
......
......@@ -16,7 +16,7 @@
* to remove each of elements matched by the given selector, and everything
* within them.
*
* This command is implemented by Drupal.ajax.prototype.commands.remove()
* This command is implemented by Drupal.AjaxCommands.prototype.remove()
* defined in misc/ajax.js.
*
* @see http://docs.jquery.com/Manipulation/remove#expr
......
......@@ -16,7 +16,7 @@
* replaceWith() method to replace each element matched matched by the given
* selector with the given HTML.
*
* This command is implemented by Drupal.ajax.prototype.commands.insert()
* This command is implemented by Drupal.AjaxCommands.prototype.insert()
* defined in misc/ajax.js.
*
* See
......
......@@ -15,7 +15,7 @@
* The 'restripe' command instructs the client to restripe a table. This is
* usually used after a table has been modified by a replace or append command.
*
* This command is implemented by Drupal.ajax.prototype.commands.restripe()
* This command is implemented by Drupal.AjaxCommands.prototype.restripe()
* defined in misc/ajax.js.
*/
class RestripeCommand implements CommandInterface {
......
......@@ -16,7 +16,7 @@
* the settings for ajax-loaded content or to extend Drupal.settings with the
* given array, depending on the value of the $merge parameter.
*
* This command is implemented by Drupal.ajax.prototype.commands.settings()
* This command is implemented by Drupal.AjaxCommands.prototype.settings()
* defined in misc/ajax.js.
*/
class SettingsCommand implements CommandInterface {
......
......@@ -164,6 +164,8 @@ Drupal.ajax = function (base, element, element_settings) {
$.extend(this, defaults, element_settings);
this.commands = new Drupal.AjaxCommands();
// @todo Remove this after refactoring the PHP code to:
// - Call this 'selector'.
// - Include the '#' for ID-based selectors.
......@@ -552,7 +554,8 @@ Drupal.ajax.prototype.error = function (response, uri) {
/**
* Provide a series of commands that the server can request the client perform.
*/
Drupal.ajax.prototype.commands = {
Drupal.AjaxCommands = function () {};
Drupal.AjaxCommands.prototype = {
/**
* Command to insert new content into the DOM.
*/
......
......@@ -21,7 +21,7 @@
/**
* Command to open a dialog.
*/
Drupal.ajax.prototype.commands.openDialog = function (ajax, response, status) {
Drupal.AjaxCommands.prototype.openDialog = function (ajax, response, status) {
if (!response.selector) {
return false;
}
......@@ -56,7 +56,7 @@
*
* If no selector is given, it defaults to trying to close the modal.
*/
Drupal.ajax.prototype.commands.closeDialog = function (ajax, response, status) {
Drupal.AjaxCommands.prototype.closeDialog = function (ajax, response, status) {
var $dialog = $(response.selector);
if ($dialog.length) {
Drupal.dialog($dialog).close();
......@@ -68,7 +68,7 @@
*
* jQuery UI specific way of setting dialog options.
*/
Drupal.ajax.prototype.commands.setDialogOption = function (ajax, response, status) {
Drupal.AjaxCommands.prototype.setDialogOption = function (ajax, response, status) {
var $dialog = $(response.selector);
if ($dialog.length) {
$dialog.dialog('option', response.optionName, response.optionValue);
......
......@@ -290,7 +290,7 @@ function loadMissingEditors (callback) {
});
// Implement a scoped insert AJAX command: calls the callback after all AJAX
// command functions have been executed (hence the deferred calling).
var realInsert = Drupal.ajax.prototype.commands.insert;
var realInsert = Drupal.AjaxCommands.prototype.insert;
Drupal.ajax[id].commands.insert = function (ajax, response, status) {
_.defer(function() { callback(); });
realInsert(ajax, response, status);
......
......@@ -85,7 +85,7 @@ Drupal.edit.editors.form = Drupal.edit.EditorView.extend({
nocssjs: false
};
Drupal.edit.util.form.load(formOptions, function (form, ajax) {
Drupal.ajax.prototype.commands.insert(ajax, {
Drupal.AjaxCommands.prototype.insert(ajax, {
data: form,
selector: '#' + id + ' .placeholder'
});
......@@ -160,7 +160,7 @@ Drupal.edit.editors.form = Drupal.edit.EditorView.extend({
Drupal.ajax[base].commands.editFieldForm = function (ajax, response, status) {
Drupal.edit.util.form.unajaxifySaving($(ajax.element));
Drupal.ajax.prototype.commands.insert(ajax, {
Drupal.AjaxCommands.prototype.insert(ajax, {
data: response.data,
selector: '#' + $formContainer.attr('id') + ' form'
});
......
......@@ -116,7 +116,7 @@ Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) {
this.pagerAjax = new Drupal.ajax(false, $link, this.element_settings);
};
Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response) {
Drupal.AjaxCommands.prototype.viewsScrollTop = function (ajax, response) {
// Scroll to the top of the view. This will allow users
// to browse newly loaded content after e.g. clicking a pager
// link.
......
......@@ -12,7 +12,7 @@
/**
* Provides an AJAX command for closing the views form modal.
*
* This command is implemented in Drupal.ajax.prototype.commands.viewsDismissForm.
* This command is implemented in Drupal.AjaxCommands.prototype.viewsDismissForm.
*/
class DismissFormCommand implements CommandInterface {
......
......@@ -12,7 +12,7 @@
/**
* Provides an AJAX command for highlighting a certain new piece of html.
*
* This command is implemented in Drupal.ajax.prototype.commands.viewsHighlight.
* This command is implemented in Drupal.AjaxCommands.prototype.viewsHighlight.
*/
class HighlightCommand implements CommandInterface {
......
......@@ -12,7 +12,7 @@
/**
* Provides an AJAX command for replacing the page title.
*
* This command is implemented in Drupal.ajax.prototype.commands.viewsReplaceTitle.
* This command is implemented in Drupal.AjaxCommands.prototype.viewsReplaceTitle.
*/
class ReplaceTitleCommand implements CommandInterface {
......
......@@ -12,7 +12,7 @@
/**
* Provides an AJAX command for scolling to the top of an element.
*
* This command is implemented in Drupal.ajax.prototype.commands.viewsScrollTop.
* This command is implemented in Drupal.AjaxCommands.prototype.viewsScrollTop.
*/
class ScrollTopCommand implements CommandInterface {
......
......@@ -12,7 +12,7 @@
/**
* Provides an AJAX command for setting a form in the views edit modal.
*
* This command is implemented in Drupal.ajax.prototype.commands.viewsSetForm.
* This command is implemented in Drupal.AjaxCommands.prototype.viewsSetForm.
*/
class SetFormCommand implements CommandInterface {
......
......@@ -12,7 +12,7 @@
/**
* Provides an AJAX command for showing the save and cancel buttons.
*
* This command is implemented in Drupal.ajax.prototype.commands.viewsShowButtons.
* This command is implemented in Drupal.AjaxCommands.prototype.viewsShowButtons.
*/
class ShowButtonsCommand implements CommandInterface {
......
......@@ -12,7 +12,7 @@
/**
* Provides an AJAX command for triggering the views live preview.
*
* This command is implemented in Drupal.ajax.prototype.commands.viewsTriggerPreview.
* This command is implemented in Drupal.AjaxCommands.prototype.viewsTriggerPreview.
*/
class TriggerPreviewCommand implements CommandInterface {
......
......@@ -6,7 +6,7 @@
"use strict";
Drupal.ajax.prototype.commands.viewsSetForm = function (ajax, response, status) {
Drupal.AjaxCommands.prototype.viewsSetForm = function (ajax, response, status) {
var ajax_title = Drupal.settings.views.ajax.title;
var ajax_body = Drupal.settings.views.ajax.id;
var ajax_popup = Drupal.settings.views.ajax.popup;
......@@ -37,28 +37,28 @@
Drupal.viewsUi.resizeModal();
};
Drupal.ajax.prototype.commands.viewsDismissForm = function (ajax, response, status) {
Drupal.ajax.prototype.commands.viewsSetForm({}, {'title': '', 'output': Drupal.settings.views.ajax.defaultForm});
Drupal.AjaxCommands.prototype.viewsDismissForm = function (ajax, response, status) {
Drupal.AjaxCommands.prototype.viewsSetForm({}, {'title': '', 'output': Drupal.settings.views.ajax.defaultForm});
$(Drupal.settings.views.ajax.popup).dialog('close');
};
Drupal.ajax.prototype.commands.viewsHighlight = function (ajax, response, status) {
Drupal.AjaxCommands.prototype.viewsHighlight = function (ajax, response, status) {
$('.hilited').removeClass('hilited');
$(response.selector).addClass('hilited');
};
Drupal.ajax.prototype.commands.viewsShowButtons = function (ajax, response, status) {
Drupal.AjaxCommands.prototype.viewsShowButtons = function (ajax, response, status) {
$('div.views-edit-view div.form-actions').removeClass('js-hide');
$('div.views-edit-view div.view-changed.messages').removeClass('js-hide');
};
Drupal.ajax.prototype.commands.viewsTriggerPreview = function (ajax, response, status) {
Drupal.AjaxCommands.prototype.viewsTriggerPreview = function (ajax, response, status) {
if ($('input#edit-displays-live-preview').is(':checked')) {
$('#preview-submit').trigger('click');
}
};
Drupal.ajax.prototype.commands.viewsReplaceTitle = function (ajax, response, status) {
Drupal.AjaxCommands.prototype.viewsReplaceTitle = function (ajax, response, status) {
// In case we're in the overlay, get a reference to the underlying window.
var doc = parent.document;
// For the <title> element, make a best-effort attempt to replace the page
......
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