Issue #2983373 by ApacheEx, drpal, m1r1k: JS codestyle: no-restricted-globals
parent
eb5d499d31
commit
258a27b635
|
@ -9,7 +9,6 @@
|
||||||
"default-case": "off",
|
"default-case": "off",
|
||||||
"prefer-destructuring": "off",
|
"prefer-destructuring": "off",
|
||||||
"operator-linebreak": "off",
|
"operator-linebreak": "off",
|
||||||
"no-restricted-globals": "off",
|
|
||||||
"react/no-this-in-sfc": "off",
|
"react/no-this-in-sfc": "off",
|
||||||
"react/destructuring-assignment": "off",
|
"react/destructuring-assignment": "off",
|
||||||
"implicit-arrow-linebreak": "off",
|
"implicit-arrow-linebreak": "off",
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
this.$node.data('details', this);
|
this.$node.data('details', this);
|
||||||
// Expand details if there are errors inside, or if it contains an
|
// Expand details if there are errors inside, or if it contains an
|
||||||
// element that is targeted by the URI fragment identifier.
|
// element that is targeted by the URI fragment identifier.
|
||||||
const anchor = location.hash && location.hash !== '#' ? `, ${location.hash}` : '';
|
const anchor = window.location.hash && window.location.hash !== '#' ? `, ${window.location.hash}` : '';
|
||||||
if (this.$node.find(`.error${anchor}`).length) {
|
if (this.$node.find(`.error${anchor}`).length) {
|
||||||
this.$node.attr('open', true);
|
this.$node.attr('open', true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
this.$node = $(node);
|
this.$node = $(node);
|
||||||
this.$node.data('details', this);
|
this.$node.data('details', this);
|
||||||
|
|
||||||
var anchor = location.hash && location.hash !== '#' ? ', ' + location.hash : '';
|
var anchor = window.location.hash && window.location.hash !== '#' ? ', ' + window.location.hash : '';
|
||||||
if (this.$node.find('.error' + anchor).length) {
|
if (this.$node.find('.error' + anchor).length) {
|
||||||
this.$node.attr('open', true);
|
this.$node.attr('open', true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,7 @@
|
||||||
// If the element's offset data attribute exits
|
// If the element's offset data attribute exits
|
||||||
// but is not a valid number then get the displacement
|
// but is not a valid number then get the displacement
|
||||||
// dimensions directly from the element.
|
// dimensions directly from the element.
|
||||||
|
// eslint-disable-next-line no-restricted-globals
|
||||||
if (isNaN(displacement)) {
|
if (isNaN(displacement)) {
|
||||||
displacement = getRawOffset(el, edge);
|
displacement = getRawOffset(el, edge);
|
||||||
}
|
}
|
||||||
|
|
|
@ -434,14 +434,14 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||||
// Always use browser-derived absolute URLs in the comparison, to avoid
|
// Always use browser-derived absolute URLs in the comparison, to avoid
|
||||||
// attempts to break out of the base path using directory traversal.
|
// attempts to break out of the base path using directory traversal.
|
||||||
let absoluteUrl = Drupal.url.toAbsolute(url);
|
let absoluteUrl = Drupal.url.toAbsolute(url);
|
||||||
let protocol = location.protocol;
|
let { protocol } = window.location;
|
||||||
|
|
||||||
// Consider URLs that match this site's base URL but use HTTPS instead of HTTP
|
// Consider URLs that match this site's base URL but use HTTPS instead of HTTP
|
||||||
// as local as well.
|
// as local as well.
|
||||||
if (protocol === 'http:' && absoluteUrl.indexOf('https:') === 0) {
|
if (protocol === 'http:' && absoluteUrl.indexOf('https:') === 0) {
|
||||||
protocol = 'https:';
|
protocol = 'https:';
|
||||||
}
|
}
|
||||||
let baseUrl = `${protocol}//${location.host}${drupalSettings.path.baseUrl.slice(0, -1)}`;
|
let baseUrl = `${protocol}//${window.location.host}${drupalSettings.path.baseUrl.slice(0, -1)}`;
|
||||||
|
|
||||||
// Decoding non-UTF-8 strings may throw an exception.
|
// Decoding non-UTF-8 strings may throw an exception.
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -135,12 +135,12 @@ window.Drupal = { behaviors: {}, locale: {} };
|
||||||
|
|
||||||
Drupal.url.isLocal = function (url) {
|
Drupal.url.isLocal = function (url) {
|
||||||
var absoluteUrl = Drupal.url.toAbsolute(url);
|
var absoluteUrl = Drupal.url.toAbsolute(url);
|
||||||
var protocol = location.protocol;
|
var protocol = window.location.protocol;
|
||||||
|
|
||||||
if (protocol === 'http:' && absoluteUrl.indexOf('https:') === 0) {
|
if (protocol === 'http:' && absoluteUrl.indexOf('https:') === 0) {
|
||||||
protocol = 'https:';
|
protocol = 'https:';
|
||||||
}
|
}
|
||||||
var baseUrl = protocol + '//' + location.host + drupalSettings.path.baseUrl.slice(0, -1);
|
var baseUrl = protocol + '//' + window.location.host + drupalSettings.path.baseUrl.slice(0, -1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
absoluteUrl = decodeURIComponent(absoluteUrl);
|
absoluteUrl = decodeURIComponent(absoluteUrl);
|
||||||
|
|
|
@ -270,7 +270,7 @@
|
||||||
url = e.currentTarget.location ? e.currentTarget.location : e.currentTarget;
|
url = e.currentTarget.location ? e.currentTarget.location : e.currentTarget;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
url = location;
|
url = window.location;
|
||||||
}
|
}
|
||||||
const hash = url.hash.substr(1);
|
const hash = url.hash.substr(1);
|
||||||
if (hash) {
|
if (hash) {
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
if (e.type === 'click') {
|
if (e.type === 'click') {
|
||||||
url = e.currentTarget.location ? e.currentTarget.location : e.currentTarget;
|
url = e.currentTarget.location ? e.currentTarget.location : e.currentTarget;
|
||||||
} else {
|
} else {
|
||||||
url = location;
|
url = window.location;
|
||||||
}
|
}
|
||||||
var hash = url.hash.substr(1);
|
var hash = url.hash.substr(1);
|
||||||
if (hash) {
|
if (hash) {
|
||||||
|
|
|
@ -295,13 +295,13 @@
|
||||||
|
|
||||||
// Redirect on hash change when the original hash has an associated CKEditor.
|
// Redirect on hash change when the original hash has an associated CKEditor.
|
||||||
function redirectTextareaFragmentToCKEditorInstance() {
|
function redirectTextareaFragmentToCKEditorInstance() {
|
||||||
const hash = location.hash.substr(1);
|
const hash = window.location.hash.substr(1);
|
||||||
const element = document.getElementById(hash);
|
const element = document.getElementById(hash);
|
||||||
if (element) {
|
if (element) {
|
||||||
const editor = CKEDITOR.dom.element.get(element).getEditor();
|
const editor = CKEDITOR.dom.element.get(element).getEditor();
|
||||||
if (editor) {
|
if (editor) {
|
||||||
const id = editor.container.getAttribute('id');
|
const id = editor.container.getAttribute('id');
|
||||||
location.replace(`#${id}`);
|
window.location.replace(`#${id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,13 +177,13 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
function redirectTextareaFragmentToCKEditorInstance() {
|
function redirectTextareaFragmentToCKEditorInstance() {
|
||||||
var hash = location.hash.substr(1);
|
var hash = window.location.hash.substr(1);
|
||||||
var element = document.getElementById(hash);
|
var element = document.getElementById(hash);
|
||||||
if (element) {
|
if (element) {
|
||||||
var editor = CKEDITOR.dom.element.get(element).getEditor();
|
var editor = CKEDITOR.dom.element.get(element).getEditor();
|
||||||
if (editor) {
|
if (editor) {
|
||||||
var id = editor.container.getAttribute('id');
|
var id = editor.container.getAttribute('id');
|
||||||
location.replace('#' + id);
|
window.location.replace('#' + id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: `${location.protocol}//${location.host}${Drupal.url('admin/structure/menu/parents')}`,
|
url: `${window.location.protocol}//${window.location.host}${Drupal.url('admin/structure/menu/parents')}`,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: { 'menus[]': values },
|
data: { 'menus[]': values },
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: location.protocol + '//' + location.host + Drupal.url('admin/structure/menu/parents'),
|
url: window.location.protocol + '//' + window.location.host + Drupal.url('admin/structure/menu/parents'),
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: { 'menus[]': values },
|
data: { 'menus[]': values },
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
|
|
@ -103,7 +103,7 @@
|
||||||
// the edited fields.
|
// the edited fields.
|
||||||
if (reload) {
|
if (reload) {
|
||||||
reload = false;
|
reload = false;
|
||||||
location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
if (reload) {
|
if (reload) {
|
||||||
reload = false;
|
reload = false;
|
||||||
location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,9 +142,9 @@
|
||||||
* The root of the menu.
|
* The root of the menu.
|
||||||
*/
|
*/
|
||||||
function openActiveItem($menu) {
|
function openActiveItem($menu) {
|
||||||
const pathItem = $menu.find(`a[href="${location.pathname}"]`);
|
const pathItem = $menu.find(`a[href="${window.location.pathname}"]`);
|
||||||
if (pathItem.length && !activeItem) {
|
if (pathItem.length && !activeItem) {
|
||||||
activeItem = location.pathname;
|
activeItem = window.location.pathname;
|
||||||
}
|
}
|
||||||
if (activeItem) {
|
if (activeItem) {
|
||||||
const $activeItem = $menu.find(`a[href="${activeItem}"]`).addClass('menu-item--active');
|
const $activeItem = $menu.find(`a[href="${activeItem}"]`).addClass('menu-item--active');
|
||||||
|
|
|
@ -72,9 +72,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function openActiveItem($menu) {
|
function openActiveItem($menu) {
|
||||||
var pathItem = $menu.find('a[href="' + location.pathname + '"]');
|
var pathItem = $menu.find('a[href="' + window.location.pathname + '"]');
|
||||||
if (pathItem.length && !activeItem) {
|
if (pathItem.length && !activeItem) {
|
||||||
activeItem = location.pathname;
|
activeItem = window.location.pathname;
|
||||||
}
|
}
|
||||||
if (activeItem) {
|
if (activeItem) {
|
||||||
var $activeItem = $menu.find('a[href="' + activeItem + '"]').addClass('menu-item--active');
|
var $activeItem = $menu.find('a[href="' + activeItem + '"]').addClass('menu-item--active');
|
||||||
|
|
Loading…
Reference in New Issue