Issue #1793648 by nod_, kmox83, droplet, rteijeiro: Follow-up: replace all occurence of Drupal.settings with drupalSettings.
parent
ee74914b50
commit
bb29548d19
|
@ -289,7 +289,7 @@ function ajax_render($commands = array()) {
|
|||
$commands = array_merge($extra_commands, $commands);
|
||||
}
|
||||
|
||||
// Now add a command to merge changes and additions to Drupal.settings.
|
||||
// Now add a command to merge changes and additions to drupalSettings.
|
||||
$scripts = drupal_add_js();
|
||||
if (!empty($scripts['settings'])) {
|
||||
$settings = drupal_merge_js_settings($scripts['settings']['data']);
|
||||
|
@ -808,7 +808,7 @@ function ajax_command_css($selector, $argument) {
|
|||
* Creates a Drupal Ajax 'settings' command.
|
||||
*
|
||||
* The 'settings' command instructs the client either to use the given array as
|
||||
* the settings for ajax-loaded content or to extend Drupal.settings with the
|
||||
* the settings for ajax-loaded content or to extend drupalSettings with the
|
||||
* given array, depending on the value of the $merge parameter.
|
||||
*
|
||||
* This command is implemented by Drupal.AjaxCommands.prototype.settings()
|
||||
|
@ -820,9 +820,9 @@ function ajax_command_css($selector, $argument) {
|
|||
* array.
|
||||
* @param $merge
|
||||
* Whether or not the passed settings in $argument should be merged into the
|
||||
* global Drupal.settings on the page. By default (FALSE), the settings that
|
||||
* global drupalSettings on the page. By default (FALSE), the settings that
|
||||
* are passed to Drupal.attachBehaviors will not include the global
|
||||
* Drupal.settings.
|
||||
* drupalSettings.
|
||||
*
|
||||
* @return
|
||||
* An array suitable for use with the ajax_render() function.
|
||||
|
|
|
@ -2063,7 +2063,7 @@ function drupal_html_id($id) {
|
|||
* on.
|
||||
* - Add settings ('setting'): Adds settings to Drupal's global storage of
|
||||
* JavaScript settings. Per-page settings are required by some modules to
|
||||
* function properly. All settings will be accessible at Drupal.settings.
|
||||
* function properly. All settings will be accessible at drupalSettings.
|
||||
*
|
||||
* Examples:
|
||||
* @code
|
||||
|
@ -2108,9 +2108,9 @@ function drupal_html_id($id) {
|
|||
* hosted on the local server. These files will not be aggregated if
|
||||
* JavaScript aggregation is enabled.
|
||||
* - 'setting': An associative array with configuration options. The array is
|
||||
* merged directly into Drupal.settings. All modules should wrap their
|
||||
* merged directly into drupalSettings. All modules should wrap their
|
||||
* actual configuration settings in another variable to prevent conflicts in
|
||||
* the Drupal.settings namespace. Items added with a string key will replace
|
||||
* the drupalSettings namespace. Items added with a string key will replace
|
||||
* existing settings with that key; items with numeric array keys will be
|
||||
* added to the existing settings array.
|
||||
* @param $options
|
||||
|
@ -2371,7 +2371,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
|
|||
// considered "used" and prevented from being added in a later AJAX
|
||||
// request.
|
||||
// Skip if no files were added to the page otherwise jQuery.extend() will
|
||||
// overwrite the Drupal.settings.ajaxPageState.css object with an empty
|
||||
// overwrite the drupalSettings.ajaxPageState.css object with an empty
|
||||
// array.
|
||||
$css = drupal_add_css();
|
||||
if (!empty($css)) {
|
||||
|
|
|
@ -4118,7 +4118,7 @@ function form_process_autocomplete($element, &$form_state) {
|
|||
$element['#attached']['library'][] = array('system', 'drupal.autocomplete');
|
||||
// Provide a hidden element for the JavaScript behavior to bind to. Since
|
||||
// this element is for client-side functionality only, do not process input.
|
||||
// @todo Refactor autocomplete.js to accept Drupal.settings instead of
|
||||
// @todo Refactor autocomplete.js to accept drupalSettings instead of
|
||||
// requiring extraneous markup.
|
||||
$element['autocomplete'] = array(
|
||||
'#type' => 'hidden',
|
||||
|
|
|
@ -129,7 +129,7 @@ class AjaxResponse extends JsonResponse {
|
|||
$this->addCommand($resource_command, TRUE);
|
||||
}
|
||||
|
||||
// Prepend a command to merge changes and additions to Drupal.settings.
|
||||
// Prepend a command to merge changes and additions to drupalSettings.
|
||||
$scripts = drupal_add_js();
|
||||
if (!empty($scripts['settings'])) {
|
||||
$settings = drupal_merge_js_settings($scripts['settings']['data']);
|
||||
|
|
|
@ -13,7 +13,7 @@ use Drupal\Core\Ajax\CommandInterface;
|
|||
* AJAX command for adjusting Drupal's JavaScript settings.
|
||||
*
|
||||
* The 'settings' command instructs the client either to use the given array as
|
||||
* the settings for ajax-loaded content or to extend Drupal.settings with the
|
||||
* the settings for ajax-loaded content or to extend drupalSettings with the
|
||||
* given array, depending on the value of the $merge parameter.
|
||||
*
|
||||
* This command is implemented by Drupal.AjaxCommands.prototype.settings()
|
||||
|
@ -32,10 +32,10 @@ class SettingsCommand implements CommandInterface {
|
|||
protected $settings;
|
||||
|
||||
/**
|
||||
* Whether the settings should be merged into the global Drupal.settings.
|
||||
* Whether the settings should be merged into the global drupalSettings.
|
||||
*
|
||||
* By default (FALSE), the settings that are passed to Drupal.attachBehaviors
|
||||
* will not include the global Drupal.settings.
|
||||
* will not include the global drupalSettings.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@ class SettingsCommand implements CommandInterface {
|
|||
* @param array $settings
|
||||
* An array of key/value pairs of JavaScript settings.
|
||||
* @param boolean $merge
|
||||
* Whether the settings should be merged into the global Drupal.settings.
|
||||
* Whether the settings should be merged into the global drupalSettings.
|
||||
*/
|
||||
public function __construct(array $settings, $merge = FALSE) {
|
||||
$this->settings = $settings;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(function ($, window) {
|
||||
(function ($, window, Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -366,7 +366,7 @@ Drupal.ajax.prototype.beforeSerialize = function (element, options) {
|
|||
// $.ajax(). When there is no form and $.ajax() is used, beforeSerialize()
|
||||
// isn't called, but don't rely on that: explicitly check this.form.
|
||||
if (this.form) {
|
||||
var settings = this.settings || Drupal.settings;
|
||||
var settings = this.settings || drupalSettings;
|
||||
Drupal.detachBehaviors(this.form, settings, 'serialize');
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,7 @@ Drupal.ajax.prototype.beforeSerialize = function (element, options) {
|
|||
// @see ajax_base_page_theme()
|
||||
// @see drupal_get_css()
|
||||
// @see drupal_get_js()
|
||||
var pageState = Drupal.settings.ajaxPageState;
|
||||
var pageState = drupalSettings.ajaxPageState;
|
||||
options.data['ajax_page_state[theme]'] = pageState.theme;
|
||||
options.data['ajax_page_state[theme_token]'] = pageState.theme_token;
|
||||
for (var cssFile in pageState.css) {
|
||||
|
@ -492,7 +492,7 @@ Drupal.ajax.prototype.success = function (response, status) {
|
|||
// commands is not sufficient, because behaviors from the entire form need
|
||||
// to be reattached.
|
||||
if (this.form) {
|
||||
var settings = this.settings || Drupal.settings;
|
||||
var settings = this.settings || drupalSettings;
|
||||
Drupal.attachBehaviors(this.form, settings);
|
||||
}
|
||||
|
||||
|
@ -545,7 +545,7 @@ Drupal.ajax.prototype.error = function (response, uri) {
|
|||
$(this.element).removeClass('progress-disabled').prop('disabled', false);
|
||||
// Reattach behaviors, if they were detached in beforeSerialize().
|
||||
if (this.form) {
|
||||
var settings = response.settings || this.settings || Drupal.settings;
|
||||
var settings = response.settings || this.settings || drupalSettings;
|
||||
Drupal.attachBehaviors(this.form, settings);
|
||||
}
|
||||
throw new Drupal.AjaxError(response, uri);
|
||||
|
@ -596,7 +596,7 @@ Drupal.AjaxCommands.prototype = {
|
|||
case 'replaceAll':
|
||||
case 'empty':
|
||||
case 'remove':
|
||||
settings = response.settings || ajax.settings || Drupal.settings;
|
||||
settings = response.settings || ajax.settings || drupalSettings;
|
||||
Drupal.detachBehaviors(wrapper, settings);
|
||||
}
|
||||
|
||||
|
@ -624,7 +624,7 @@ Drupal.AjaxCommands.prototype = {
|
|||
// optional.
|
||||
if (new_content.parents('html').length > 0) {
|
||||
// Apply any settings from the returned JSON if available.
|
||||
settings = response.settings || ajax.settings || Drupal.settings;
|
||||
settings = response.settings || ajax.settings || drupalSettings;
|
||||
Drupal.attachBehaviors(new_content, settings);
|
||||
}
|
||||
},
|
||||
|
@ -633,7 +633,7 @@ Drupal.AjaxCommands.prototype = {
|
|||
* Command to remove a chunk from the page.
|
||||
*/
|
||||
remove: function (ajax, response, status) {
|
||||
var settings = response.settings || ajax.settings || Drupal.settings;
|
||||
var settings = response.settings || ajax.settings || drupalSettings;
|
||||
Drupal.detachBehaviors($(response.selector), settings);
|
||||
$(response.selector).remove();
|
||||
},
|
||||
|
@ -676,7 +676,7 @@ Drupal.AjaxCommands.prototype = {
|
|||
*/
|
||||
settings: function (ajax, response, status) {
|
||||
if (response.merge) {
|
||||
$.extend(true, Drupal.settings, response.settings);
|
||||
$.extend(true, drupalSettings, response.settings);
|
||||
}
|
||||
else {
|
||||
ajax.settings = response.settings;
|
||||
|
@ -733,4 +733,4 @@ Drupal.AjaxCommands.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
})(jQuery, this);
|
||||
})(jQuery, this, Drupal, drupalSettings);
|
||||
|
|
|
@ -14,9 +14,6 @@ if (window.jQuery) {
|
|||
|
||||
"use strict";
|
||||
|
||||
// Populate Drupal.settings with the drupalSettings variable.
|
||||
Drupal.settings = drupalSettings;
|
||||
|
||||
/**
|
||||
* Custom error type thrown after attach/detach if one or more behaviors failed.
|
||||
*
|
||||
|
@ -75,7 +72,7 @@ DrupalBehaviorError.prototype = new Error();
|
|||
* is used.
|
||||
* @param settings
|
||||
* An object containing settings for the current context. If none is given,
|
||||
* the global Drupal.settings object is used.
|
||||
* the global drupalSettings object is used.
|
||||
*/
|
||||
Drupal.attachBehaviors = function (context, settings) {
|
||||
context = context || document;
|
||||
|
@ -120,7 +117,7 @@ domready(function () { Drupal.attachBehaviors(document, drupalSettings); });
|
|||
* is used.
|
||||
* @param settings
|
||||
* An object containing settings for the current context. If none given, the
|
||||
* global Drupal.settings object is used.
|
||||
* global drupalSettings object is used.
|
||||
* @param trigger
|
||||
* A string containing what's causing the behaviors to be detached. The
|
||||
* possible triggers are:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(function ($) {
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -1069,9 +1069,9 @@ Drupal.tableDrag.prototype.row.prototype.isValidSwap = function (row) {
|
|||
* DOM element what will be swapped with the row group.
|
||||
*/
|
||||
Drupal.tableDrag.prototype.row.prototype.swap = function (position, row) {
|
||||
Drupal.detachBehaviors(this.group, Drupal.settings, 'move');
|
||||
Drupal.detachBehaviors(this.group, drupalSettings, 'move');
|
||||
$(row)[position](this.group);
|
||||
Drupal.attachBehaviors(this.group, Drupal.settings);
|
||||
Drupal.attachBehaviors(this.group, drupalSettings);
|
||||
this.changed = true;
|
||||
this.onSwap(row);
|
||||
};
|
||||
|
@ -1257,4 +1257,4 @@ $.extend(Drupal.theme, {
|
|||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Datepicker JavaScript for the Locale module.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
|||
*/
|
||||
Drupal.behaviors.localeDatepicker = {
|
||||
attach: function(context, settings) {
|
||||
// This code accesses Drupal.settings and localized strings via Drupal.t().
|
||||
// This code accesses drupalSettings and localized strings via Drupal.t().
|
||||
// So this code should run after these are initialized. By placing it in an
|
||||
// attach behavior this is assured.
|
||||
$.datepicker.regional['drupal-locale'] = $.extend({
|
||||
|
@ -78,9 +78,9 @@ Drupal.behaviors.localeDatepicker = {
|
|||
dateFormat: Drupal.t('mm/dd/yy'),
|
||||
firstDay: 0,
|
||||
isRTL: 0
|
||||
}, Drupal.settings.jquery.ui.datepicker);
|
||||
}, drupalSettings.jquery.ui.datepicker);
|
||||
$.datepicker.setDefaults($.datepicker.regional['drupal-locale']);
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Defines Javascript behaviors for the node module.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -27,7 +27,7 @@ Drupal.behaviors.nodeDetailsSummaries = {
|
|||
|
||||
$context.find('.node-form-author').drupalSetSummary(function (context) {
|
||||
var $context = $(context);
|
||||
var name = $context.find('.form-item-name input').val() || Drupal.settings.anonymous,
|
||||
var name = $context.find('.form-item-name input').val() || drupalSettings.anonymous,
|
||||
date = $context.find('.form-item-date input').val();
|
||||
return date ?
|
||||
Drupal.t('By @name on @date', { '@name': name, '@date': date }) :
|
||||
|
@ -67,4 +67,4 @@ Drupal.behaviors.nodeDetailsSummaries = {
|
|||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Attaches the behaviors for the Overlay parent pages.
|
||||
*/
|
||||
|
||||
(function ($, Drupal, displace) {
|
||||
(function ($, Drupal, displace, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -372,13 +372,13 @@ Drupal.overlay.isAdminLink = function (url) {
|
|||
// Turn the list of administrative paths into a regular expression.
|
||||
if (!this.adminPathRegExp) {
|
||||
var prefix = '';
|
||||
if (Drupal.settings.overlay.pathPrefixes.length) {
|
||||
if (drupalSettings.overlay.pathPrefixes.length) {
|
||||
// Allow path prefixes used for language negatiation followed by slash,
|
||||
// and the empty string.
|
||||
prefix = '(' + Drupal.settings.overlay.pathPrefixes.join('/|') + '/|)';
|
||||
prefix = '(' + drupalSettings.overlay.pathPrefixes.join('/|') + '/|)';
|
||||
}
|
||||
var adminPaths = '^' + prefix + '(' + Drupal.settings.overlay.paths.admin.replace(/\s+/g, '|') + ')$';
|
||||
var nonAdminPaths = '^' + prefix + '(' + Drupal.settings.overlay.paths.non_admin.replace(/\s+/g, '|') + ')$';
|
||||
var adminPaths = '^' + prefix + '(' + drupalSettings.overlay.paths.admin.replace(/\s+/g, '|') + ')$';
|
||||
var nonAdminPaths = '^' + prefix + '(' + drupalSettings.overlay.paths.non_admin.replace(/\s+/g, '|') + ')$';
|
||||
adminPaths = adminPaths.replace(/\*/g, '.*');
|
||||
nonAdminPaths = nonAdminPaths.replace(/\*/g, '.*');
|
||||
this.adminPathRegExp = new RegExp(adminPaths);
|
||||
|
@ -750,9 +750,9 @@ Drupal.overlay.fragmentizeLink = function (link, parentLocation) {
|
|||
function refreshRegion(regionName, regionSelector) {
|
||||
var $region = $(regionSelector);
|
||||
Drupal.detachBehaviors($region);
|
||||
$.get(Drupal.url(Drupal.settings.overlay.ajaxCallback + '/' + regionName), function (newElement) {
|
||||
$.get(Drupal.url(drupalSettings.overlay.ajaxCallback + '/' + regionName), function (newElement) {
|
||||
$region.replaceWith($(newElement));
|
||||
Drupal.attachBehaviors($region, Drupal.settings);
|
||||
Drupal.attachBehaviors($region, drupalSettings);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -827,7 +827,7 @@ Drupal.overlay.getPath = function (link) {
|
|||
if (path.charAt(0) !== '/') {
|
||||
path = '/' + path;
|
||||
}
|
||||
path = path.replace(new RegExp(Drupal.settings.basePath + Drupal.settings.scriptPath), '');
|
||||
path = path.replace(new RegExp(drupalSettings.basePath + drupalSettings.scriptPath), '');
|
||||
|
||||
return path;
|
||||
};
|
||||
|
@ -875,4 +875,4 @@ $.extend(Drupal.theme, {
|
|||
}
|
||||
});
|
||||
|
||||
})(jQuery, Drupal, Drupal.displace);
|
||||
})(jQuery, Drupal, Drupal.displace, drupalSettings);
|
||||
|
|
|
@ -78,9 +78,9 @@ abstract class WebTestBase extends TestBase {
|
|||
protected $plainTextContent;
|
||||
|
||||
/**
|
||||
* The value of Drupal.settings for the currently-loaded page.
|
||||
* The value of drupalSettings for the currently-loaded page.
|
||||
*
|
||||
* Drupal.settings refers to the Drupal.settings JavaScript variable.
|
||||
* drupalSettings refers to the drupalSettings JavaScript variable.
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
|
@ -2348,9 +2348,9 @@ abstract class WebTestBase extends TestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the value of Drupal.settings for the currently-loaded page.
|
||||
* Gets the value of drupalSettings for the currently-loaded page.
|
||||
*
|
||||
* Drupal.settings refers to the Drupal.settings JavaScript variable.
|
||||
* drupalSettings refers to the drupalSettings JavaScript variable.
|
||||
*/
|
||||
protected function drupalGetSettings() {
|
||||
return $this->drupalSettings;
|
||||
|
@ -2404,9 +2404,9 @@ abstract class WebTestBase extends TestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the value of Drupal.settings for the currently-loaded page.
|
||||
* Sets the value of drupalSettings for the currently-loaded page.
|
||||
*
|
||||
* Drupal.settings refers to the Drupal.settings JavaScript variable.
|
||||
* drupalSettings refers to the drupalSettings JavaScript variable.
|
||||
*/
|
||||
protected function drupalSetSettings($settings) {
|
||||
$this->drupalSettings = $settings;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(function ($) {
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
|||
$.ajax({
|
||||
type: "POST",
|
||||
cache: false,
|
||||
url: Drupal.settings.statistics.url,
|
||||
data: Drupal.settings.statistics.data
|
||||
url: drupalSettings.statistics.url,
|
||||
data: drupalSettings.statistics.data
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
|
|
@ -210,7 +210,7 @@ class FrameworkTest extends AjaxTestBase {
|
|||
$this->drupalPostAjaxForm('ajax_forms_test_lazy_load_form', array('add_files' => TRUE), array('op' => t('Submit')));
|
||||
|
||||
// Verify that the resulting HTML does not load the overridden CSS file.
|
||||
// We add a "?" to the assertion, because Drupal.settings may include
|
||||
// We add a "?" to the assertion, because drupalSettings may include
|
||||
// information about the file; we only really care about whether it appears
|
||||
// in a LINK or STYLE tag, for which Drupal always adds a query string for
|
||||
// cache control.
|
||||
|
|
|
@ -148,13 +148,13 @@ class JavaScriptTest extends DrupalUnitTestBase {
|
|||
$this->assertTrue(strpos($javascript, 'pathPrefix') > 0, 'Rendered JavaScript header returns pathPrefix setting.');
|
||||
$this->assertTrue(strpos($javascript, 'currentPath') > 0, 'Rendered JavaScript header returns currentPath setting.');
|
||||
|
||||
// Only the second of these two entries should appear in Drupal.settings.
|
||||
// Only the second of these two entries should appear in drupalSettings.
|
||||
drupal_add_js(array('commonTest' => 'commonTestShouldNotAppear'), 'setting');
|
||||
drupal_add_js(array('commonTest' => 'commonTestShouldAppear'), 'setting');
|
||||
// Only the second of these entries should appear in Drupal.settings.
|
||||
// Only the second of these entries should appear in drupalSettings.
|
||||
drupal_add_js(array('commonTestJsArrayLiteral' => array('commonTestJsArrayLiteralOldValue')), 'setting');
|
||||
drupal_add_js(array('commonTestJsArrayLiteral' => array('commonTestJsArrayLiteralNewValue')), 'setting');
|
||||
// Only the second of these two entries should appear in Drupal.settings.
|
||||
// Only the second of these two entries should appear in drupalSettings.
|
||||
drupal_add_js(array('commonTestJsObjectLiteral' => array('key' => 'commonTestJsObjectLiteralOldValue')), 'setting');
|
||||
drupal_add_js(array('commonTestJsObjectLiteral' => array('key' => 'commonTestJsObjectLiteralNewValue')), 'setting');
|
||||
// Real world test case: multiple elements in a render array are adding the
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @file
|
||||
* Handles AJAX fetching of views, including filter submission and response.
|
||||
*/
|
||||
(function ($) {
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
|||
*/
|
||||
Drupal.behaviors.ViewsAjaxView = {};
|
||||
Drupal.behaviors.ViewsAjaxView.attach = function() {
|
||||
if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) {
|
||||
$.each(Drupal.settings.views.ajaxViews, function(i, settings) {
|
||||
if (drupalSettings && drupalSettings.views && drupalSettings.views.ajaxViews) {
|
||||
$.each(drupalSettings.views.ajaxViews, function(i, settings) {
|
||||
Drupal.views.instances[i] = new Drupal.views.ajaxView(settings);
|
||||
});
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ Drupal.views.ajaxView = function(settings) {
|
|||
this.$view = $(selector);
|
||||
|
||||
// Retrieve the path to use for views' ajax.
|
||||
var ajax_path = Drupal.settings.views.ajax_path;
|
||||
var ajax_path = drupalSettings.views.ajax_path;
|
||||
|
||||
// If there are multiple views this might've ended up showing up multiple times.
|
||||
if (ajax_path.constructor.toString().indexOf("Array") !== -1) {
|
||||
|
@ -145,4 +145,4 @@ Drupal.AjaxCommands.prototype.viewsScrollTop = function (ajax, response) {
|
|||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @file
|
||||
* Some basic behaviors and utility functions for Views.
|
||||
*/
|
||||
(function ($) {
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
|||
*/
|
||||
Drupal.Views.getPath = function (href) {
|
||||
href = Drupal.Views.pathPortion(href);
|
||||
href = href.substring(Drupal.settings.basePath.length, href.length);
|
||||
href = href.substring(drupalSettings.basePath.length, href.length);
|
||||
// 3 is the length of the '?q=' added to the url without clean urls.
|
||||
if (href.substring(0, 3) === '?q=') {
|
||||
href = href.substring(3, href.length);
|
||||
|
@ -77,4 +77,4 @@
|
|||
return href;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
|
|
@ -127,7 +127,7 @@ class ViewAjaxController implements ContainerInjectionInterface {
|
|||
$response->addCommand(new ScrollTopCommand(".view-dom-id-$dom_id"));
|
||||
$view->displayHandlers->get($display_id)->setOption('pager_element', $pager_element);
|
||||
}
|
||||
// Reuse the same DOM id so it matches that in Drupal.settings.
|
||||
// Reuse the same DOM id so it matches that in drupalSettings.
|
||||
$view->dom_id = $dom_id;
|
||||
|
||||
$preview = $view->preview($display_id, $args);
|
||||
|
|
|
@ -99,7 +99,7 @@ function template_preprocess_views_view(&$variables) {
|
|||
// with its HTML, because one view may appear several times on the page. So
|
||||
// we set up a hash with the current time, $dom_id, to issue a "unique"
|
||||
// identifier for each view. This identifier is written to both
|
||||
// Drupal.settings and the DIV wrapper.
|
||||
// drupalSettings and the DIV wrapper.
|
||||
$variables['dom_id'] = $view->dom_id;
|
||||
$variables['attributes']['class'][] = 'view-dom-id-' . $variables['dom_id'];
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
* @file
|
||||
* Handles AJAX submission and response in Views UI.
|
||||
*/
|
||||
(function ($) {
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
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;
|
||||
var ajax_title = drupalSettings.views.ajax.title;
|
||||
var ajax_body = drupalSettings.views.ajax.id;
|
||||
var ajax_popup = drupalSettings.views.ajax.popup;
|
||||
$(ajax_title).html('<h2>' + response.title + '</h2>');
|
||||
$(ajax_body).html(response.output);
|
||||
$(ajax_popup).dialog('open');
|
||||
|
@ -38,8 +38,8 @@
|
|||
};
|
||||
|
||||
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.AjaxCommands.prototype.viewsSetForm({}, {'title': '', 'output': drupalSettings.views.ajax.defaultForm});
|
||||
$(drupalSettings.views.ajax.popup).dialog('close');
|
||||
};
|
||||
|
||||
Drupal.AjaxCommands.prototype.viewsHighlight = function (ajax, response, status) {
|
||||
|
@ -220,4 +220,4 @@
|
|||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
|
|
@ -978,7 +978,7 @@ Drupal.viewsUi.resizeModal = function (e, no_shrink) {
|
|||
});
|
||||
|
||||
// Ensure inner popup height matches.
|
||||
$(Drupal.settings.views.ajax.popup).css('height', height + 'px');
|
||||
$(drupalSettings.views.ajax.popup).css('height', height + 'px');
|
||||
|
||||
$scroll.css({
|
||||
'height': scrollHeight + 'px',
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @file
|
||||
* Preview for the Bartik theme.
|
||||
*/
|
||||
(function ($) {
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -11,11 +11,11 @@
|
|||
callback: function(context, settings, form, farb, height, width) {
|
||||
// Change the logo to be the real one.
|
||||
if (!this.logoChanged) {
|
||||
$('#preview #preview-logo img').attr('src', Drupal.settings.color.logo);
|
||||
$('#preview #preview-logo img').attr('src', drupalSettings.color.logo);
|
||||
this.logoChanged = true;
|
||||
}
|
||||
// Remove the logo if the setting is toggled off.
|
||||
if (Drupal.settings.color.logo === null) {
|
||||
if (drupalSettings.color.logo === null) {
|
||||
$('div').remove('#preview-logo');
|
||||
}
|
||||
|
||||
|
@ -42,4 +42,4 @@
|
|||
form.find('#preview #preview-site-name').css('color', form.find('#palette input[name="palette[titleslogan]"]').val());
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
|
Loading…
Reference in New Issue