Issue #2422017 by penyaskito, MobliMic, nod_: Split drupal.js

8.3.x
Nathaniel Catchpole 2016-12-13 17:15:23 +00:00
parent f4a242f154
commit 765c10b69f
3 changed files with 22 additions and 13 deletions

View File

@ -46,6 +46,7 @@ drupal:
version: VERSION
js:
misc/drupal.js: { weight: -18 }
misc/drupal.init.js: { weight: -17 }
dependencies:
- core/domready
- core/drupalSettings

19
core/misc/drupal.init.js Normal file
View File

@ -0,0 +1,19 @@
// Allow other JavaScript libraries to use $.
if (window.jQuery) {
jQuery.noConflict();
}
// Class indicating that JS is enabled; used for styling purpose.
document.documentElement.className += ' js';
// JavaScript should be made compatible with libraries other than jQuery by
// wrapping it in an anonymous closure.
(function (domready, Drupal, drupalSettings) {
'use strict';
// Attach all behaviors.
domready(function () { Drupal.attachBehaviors(document, drupalSettings); });
})(domready, Drupal, window.drupalSettings);

View File

@ -40,17 +40,9 @@
*/
window.Drupal = {behaviors: {}, locale: {}};
// Class indicating that JavaScript is enabled; used for styling purpose.
document.documentElement.className += ' js';
// Allow other JavaScript libraries to use $.
if (window.jQuery) {
jQuery.noConflict();
}
// JavaScript should be made compatible with libraries other than jQuery by
// wrapping it in an anonymous closure.
(function (domready, Drupal, drupalSettings, drupalTranslations) {
(function (Drupal, drupalSettings, drupalTranslations) {
'use strict';
@ -174,9 +166,6 @@ if (window.jQuery) {
}
};
// Attach all behaviors.
domready(function () { Drupal.attachBehaviors(document, drupalSettings); });
/**
* Detaches registered behaviors from a page element.
*
@ -591,4 +580,4 @@ if (window.jQuery) {
return '<em class="placeholder">' + Drupal.checkPlain(str) + '</em>';
};
})(domready, Drupal, window.drupalSettings, window.drupalTranslations);
})(Drupal, window.drupalSettings, window.drupalTranslations);