Issue #3101543 by lauriii, bnjmnm, ravi.shankar: Update core JavaScript dependencies listed in package.json
parent
09b78ffb1b
commit
2dadb738bf
|
@ -21,6 +21,11 @@
|
|||
"Sortable": true,
|
||||
"CKEDITOR": true
|
||||
},
|
||||
"settings": {
|
||||
"react": {
|
||||
"version": "latest"
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"prettier/prettier": "error",
|
||||
"consistent-return": ["off"],
|
||||
|
|
|
@ -10,26 +10,25 @@
|
|||
attach: function attach(context) {
|
||||
var path = drupalSettings.path;
|
||||
var queryString = JSON.stringify(path.currentQuery);
|
||||
var querySelector = path.currentQuery ? '[data-drupal-link-query=\'' + queryString + '\']' : ':not([data-drupal-link-query])';
|
||||
var originalSelectors = ['[data-drupal-link-system-path="' + path.currentPath + '"]'];
|
||||
var selectors = void 0;
|
||||
var querySelector = path.currentQuery ? "[data-drupal-link-query='".concat(queryString, "']") : ':not([data-drupal-link-query])';
|
||||
var originalSelectors = ["[data-drupal-link-system-path=\"".concat(path.currentPath, "\"]")];
|
||||
var selectors;
|
||||
|
||||
if (path.isFront) {
|
||||
originalSelectors.push('[data-drupal-link-system-path="<front>"]');
|
||||
}
|
||||
|
||||
selectors = [].concat(originalSelectors.map(function (selector) {
|
||||
return selector + ':not([hreflang])';
|
||||
return "".concat(selector, ":not([hreflang])");
|
||||
}), originalSelectors.map(function (selector) {
|
||||
return selector + '[hreflang="' + path.currentLanguage + '"]';
|
||||
return "".concat(selector, "[hreflang=\"").concat(path.currentLanguage, "\"]");
|
||||
}));
|
||||
|
||||
selectors = selectors.map(function (current) {
|
||||
return current + querySelector;
|
||||
});
|
||||
|
||||
var activeLinks = context.querySelectorAll(selectors.join(','));
|
||||
var il = activeLinks.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
activeLinks[i].classList.add('is-active');
|
||||
}
|
||||
|
@ -38,6 +37,7 @@
|
|||
if (trigger === 'unload') {
|
||||
var activeLinks = context.querySelectorAll('[data-drupal-link-system-path].is-active');
|
||||
var il = activeLinks.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
activeLinks[i].classList.remove('is-active');
|
||||
}
|
||||
|
|
|
@ -102,7 +102,9 @@
|
|||
if (xmlhttp.status) {
|
||||
statusCode = `\n${Drupal.t('An AJAX HTTP error occurred.')}\n${Drupal.t(
|
||||
'HTTP Result Code: !status',
|
||||
{ '!status': xmlhttp.status },
|
||||
{
|
||||
'!status': xmlhttp.status,
|
||||
},
|
||||
)}`;
|
||||
} else {
|
||||
statusCode = `\n${Drupal.t(
|
||||
|
@ -1129,12 +1131,14 @@
|
|||
(response.effect || ajax.effect) !== 'none' &&
|
||||
$newContent.filter(
|
||||
i =>
|
||||
!// We can not consider HTML comments or whitespace text as separate
|
||||
// roots, since they do not cause visual regression with effect.
|
||||
(
|
||||
$newContent[i].nodeName === '#comment' ||
|
||||
($newContent[i].nodeName === '#text' &&
|
||||
/^(\s|\n|\r)*$/.test($newContent[i].textContent))
|
||||
!(
|
||||
// We can not consider HTML comments or whitespace text as separate
|
||||
// roots, since they do not cause visual regression with effect.
|
||||
(
|
||||
$newContent[i].nodeName === '#comment' ||
|
||||
($newContent[i].nodeName === '#text' &&
|
||||
/^(\s|\n|\r)*$/.test($newContent[i].textContent))
|
||||
)
|
||||
),
|
||||
).length > 1
|
||||
? Drupal.theme('ajaxWrapperMultipleRootElements', $newContent)
|
||||
|
|
|
@ -4,16 +4,25 @@
|
|||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||
|
||||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
||||
|
||||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
||||
|
||||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
||||
|
||||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
||||
|
||||
(function ($, window, Drupal, drupalSettings) {
|
||||
Drupal.behaviors.AJAX = {
|
||||
attach: function attach(context, settings) {
|
||||
function loadAjaxBehavior(base) {
|
||||
var elementSettings = settings.ajax[base];
|
||||
|
||||
if (typeof elementSettings.selector === 'undefined') {
|
||||
elementSettings.selector = '#' + base;
|
||||
elementSettings.selector = "#".concat(base);
|
||||
}
|
||||
|
||||
$(elementSettings.selector).once('drupal-ajax').each(function () {
|
||||
elementSettings.element = this;
|
||||
elementSettings.base = base;
|
||||
|
@ -24,22 +33,17 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
Object.keys(settings.ajax || {}).forEach(function (base) {
|
||||
return loadAjaxBehavior(base);
|
||||
});
|
||||
|
||||
Drupal.ajax.bindAjaxLinks(document.body);
|
||||
|
||||
$('.use-ajax-submit').once('ajax').each(function () {
|
||||
var elementSettings = {};
|
||||
|
||||
elementSettings.url = $(this.form).attr('action');
|
||||
|
||||
elementSettings.setClick = true;
|
||||
|
||||
elementSettings.event = 'click';
|
||||
|
||||
elementSettings.progress = { type: 'throbber' };
|
||||
elementSettings.progress = {
|
||||
type: 'throbber'
|
||||
};
|
||||
elementSettings.base = $(this).attr('id');
|
||||
elementSettings.element = this;
|
||||
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
},
|
||||
|
@ -53,45 +57,47 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
};
|
||||
|
||||
Drupal.AjaxError = function (xmlhttp, uri, customMessage) {
|
||||
var statusCode = void 0;
|
||||
var statusText = void 0;
|
||||
var responseText = void 0;
|
||||
var statusCode;
|
||||
var statusText;
|
||||
var responseText;
|
||||
|
||||
if (xmlhttp.status) {
|
||||
statusCode = '\n' + Drupal.t('An AJAX HTTP error occurred.') + '\n' + Drupal.t('HTTP Result Code: !status', { '!status': xmlhttp.status });
|
||||
statusCode = "\n".concat(Drupal.t('An AJAX HTTP error occurred.'), "\n").concat(Drupal.t('HTTP Result Code: !status', {
|
||||
'!status': xmlhttp.status
|
||||
}));
|
||||
} else {
|
||||
statusCode = '\n' + Drupal.t('An AJAX HTTP request terminated abnormally.');
|
||||
statusCode = "\n".concat(Drupal.t('An AJAX HTTP request terminated abnormally.'));
|
||||
}
|
||||
statusCode += '\n' + Drupal.t('Debugging information follows.');
|
||||
var pathText = '\n' + Drupal.t('Path: !uri', { '!uri': uri });
|
||||
|
||||
statusCode += "\n".concat(Drupal.t('Debugging information follows.'));
|
||||
var pathText = "\n".concat(Drupal.t('Path: !uri', {
|
||||
'!uri': uri
|
||||
}));
|
||||
statusText = '';
|
||||
|
||||
try {
|
||||
statusText = '\n' + Drupal.t('StatusText: !statusText', {
|
||||
statusText = "\n".concat(Drupal.t('StatusText: !statusText', {
|
||||
'!statusText': $.trim(xmlhttp.statusText)
|
||||
});
|
||||
}));
|
||||
} catch (e) {}
|
||||
|
||||
responseText = '';
|
||||
|
||||
try {
|
||||
responseText = '\n' + Drupal.t('ResponseText: !responseText', {
|
||||
responseText = "\n".concat(Drupal.t('ResponseText: !responseText', {
|
||||
'!responseText': $.trim(xmlhttp.responseText)
|
||||
});
|
||||
}));
|
||||
} catch (e) {}
|
||||
|
||||
responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, '');
|
||||
responseText = responseText.replace(/[\n]+\s+/g, '\n');
|
||||
|
||||
var readyStateText = xmlhttp.status === 0 ? '\n' + Drupal.t('ReadyState: !readyState', {
|
||||
var readyStateText = xmlhttp.status === 0 ? "\n".concat(Drupal.t('ReadyState: !readyState', {
|
||||
'!readyState': xmlhttp.readyState
|
||||
}) : '';
|
||||
|
||||
customMessage = customMessage ? '\n' + Drupal.t('CustomMessage: !customMessage', {
|
||||
})) : '';
|
||||
customMessage = customMessage ? "\n".concat(Drupal.t('CustomMessage: !customMessage', {
|
||||
'!customMessage': customMessage
|
||||
}) : '';
|
||||
|
||||
})) : '';
|
||||
this.message = statusCode + pathText + statusText + customMessage + responseText + readyStateText;
|
||||
|
||||
this.name = 'AjaxError';
|
||||
};
|
||||
|
||||
|
@ -115,7 +121,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
var ajax = new Drupal.Ajax(base, element, settings);
|
||||
ajax.instanceIndex = Drupal.ajax.instances.length;
|
||||
Drupal.ajax.instances.push(ajax);
|
||||
|
||||
return ajax;
|
||||
};
|
||||
|
||||
|
@ -130,9 +135,10 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
Drupal.ajax.bindAjaxLinks = function (element) {
|
||||
$(element).find('.use-ajax').once('ajax').each(function (i, ajaxLink) {
|
||||
var $linkElement = $(ajaxLink);
|
||||
|
||||
var elementSettings = {
|
||||
progress: { type: 'throbber' },
|
||||
progress: {
|
||||
type: 'throbber'
|
||||
},
|
||||
dialogType: $linkElement.data('dialog-type'),
|
||||
dialog: $linkElement.data('dialog-options'),
|
||||
dialogRenderer: $linkElement.data('dialog-renderer'),
|
||||
|
@ -145,6 +151,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
elementSettings.url = href;
|
||||
elementSettings.event = 'click';
|
||||
}
|
||||
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
};
|
||||
|
@ -153,7 +160,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
var defaults = {
|
||||
event: element ? 'mousedown' : null,
|
||||
keypress: true,
|
||||
selector: base ? '#' + base : null,
|
||||
selector: base ? "#".concat(base) : null,
|
||||
effect: 'none',
|
||||
speed: 'none',
|
||||
method: 'replaceWith',
|
||||
|
@ -165,21 +172,16 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
js: true
|
||||
}
|
||||
};
|
||||
|
||||
$.extend(this, defaults, elementSettings);
|
||||
|
||||
this.commands = new Drupal.AjaxCommands();
|
||||
|
||||
this.instanceIndex = false;
|
||||
|
||||
if (this.wrapper) {
|
||||
this.wrapper = '#' + this.wrapper;
|
||||
this.wrapper = "#".concat(this.wrapper);
|
||||
}
|
||||
|
||||
this.element = element;
|
||||
|
||||
this.element_settings = elementSettings;
|
||||
|
||||
this.elementSettings = elementSettings;
|
||||
|
||||
if (this.element && this.element.form) {
|
||||
|
@ -188,6 +190,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
|
||||
if (!this.url) {
|
||||
var $element = $(this.element);
|
||||
|
||||
if ($element.is('a')) {
|
||||
this.url = $element.attr('href');
|
||||
} else if (this.element && element.form) {
|
||||
|
@ -196,7 +199,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
}
|
||||
|
||||
var originalUrl = this.url;
|
||||
|
||||
this.url = this.url.replace(/\/nojs(\/|$|\?|#)/, '/ajax$1');
|
||||
|
||||
if (drupalSettings.ajaxTrustedUrl[originalUrl]) {
|
||||
|
@ -204,7 +206,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
}
|
||||
|
||||
var ajax = this;
|
||||
|
||||
ajax.options = {
|
||||
url: ajax.url,
|
||||
data: ajax.submit,
|
||||
|
@ -235,11 +236,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
},
|
||||
complete: function complete(xmlhttprequest, status) {
|
||||
ajax.ajaxing = false;
|
||||
|
||||
if (status === 'error' || status === 'parsererror') {
|
||||
return ajax.error(xmlhttprequest, ajax.url);
|
||||
}
|
||||
},
|
||||
|
||||
dataType: 'json',
|
||||
type: 'POST'
|
||||
};
|
||||
|
@ -254,18 +255,20 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
ajax.options.url += '&';
|
||||
}
|
||||
|
||||
var wrapper = 'drupal_' + (elementSettings.dialogType || 'ajax');
|
||||
if (elementSettings.dialogRenderer) {
|
||||
wrapper += '.' + elementSettings.dialogRenderer;
|
||||
}
|
||||
ajax.options.url += Drupal.ajax.WRAPPER_FORMAT + '=' + wrapper;
|
||||
var wrapper = "drupal_".concat(elementSettings.dialogType || 'ajax');
|
||||
|
||||
if (elementSettings.dialogRenderer) {
|
||||
wrapper += ".".concat(elementSettings.dialogRenderer);
|
||||
}
|
||||
|
||||
ajax.options.url += "".concat(Drupal.ajax.WRAPPER_FORMAT, "=").concat(wrapper);
|
||||
$(ajax.element).on(elementSettings.event, function (event) {
|
||||
if (!drupalSettings.ajaxTrustedUrl[ajax.url] && !Drupal.url.isLocal(ajax.url)) {
|
||||
throw new Error(Drupal.t('The callback URL is not local and not trusted: !url', {
|
||||
'!url': ajax.url
|
||||
}));
|
||||
}
|
||||
|
||||
return ajax.eventResponse(this, event);
|
||||
});
|
||||
|
||||
|
@ -281,7 +284,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
};
|
||||
|
||||
Drupal.ajax.WRAPPER_FORMAT = '_wrapper_format';
|
||||
|
||||
Drupal.Ajax.AJAX_REQUEST_PARAMETER = '_drupal_ajax';
|
||||
|
||||
Drupal.Ajax.prototype.execute = function () {
|
||||
|
@ -291,12 +293,10 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
|
||||
try {
|
||||
this.beforeSerialize(this.element, this.options);
|
||||
|
||||
return $.ajax(this.options);
|
||||
} catch (e) {
|
||||
this.ajaxing = false;
|
||||
window.alert('An error occurred while attempting to process ' + this.options.url + ': ' + e.message);
|
||||
|
||||
window.alert("An error occurred while attempting to process ".concat(this.options.url, ": ").concat(e.message));
|
||||
return $.Deferred().reject();
|
||||
}
|
||||
};
|
||||
|
@ -314,7 +314,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
Drupal.Ajax.prototype.eventResponse = function (element, event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
var ajax = this;
|
||||
|
||||
if (ajax.ajaxing) {
|
||||
|
@ -334,7 +333,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
}
|
||||
} catch (e) {
|
||||
ajax.ajaxing = false;
|
||||
window.alert('An error occurred while attempting to process ' + ajax.options.url + ': ' + e.message);
|
||||
window.alert("An error occurred while attempting to process ".concat(ajax.options.url, ": ").concat(e.message));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -345,7 +344,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
}
|
||||
|
||||
options.data[Drupal.Ajax.AJAX_REQUEST_PARAMETER] = 1;
|
||||
|
||||
var pageState = drupalSettings.ajaxPageState;
|
||||
options.data['ajax_page_state[theme]'] = pageState.theme;
|
||||
options.data['ajax_page_state[theme_token]'] = pageState.theme_token;
|
||||
|
@ -357,10 +355,9 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
Drupal.Ajax.prototype.beforeSend = function (xmlhttprequest, options) {
|
||||
if (this.$form) {
|
||||
options.extraData = options.extraData || {};
|
||||
|
||||
options.extraData.ajax_iframe_upload = '1';
|
||||
|
||||
var v = $.fieldValue(this.element);
|
||||
|
||||
if (v !== null) {
|
||||
options.extraData[this.element.name] = v;
|
||||
}
|
||||
|
@ -372,7 +369,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
return;
|
||||
}
|
||||
|
||||
var progressIndicatorMethod = 'setProgressIndicator' + this.progress.type.slice(0, 1).toUpperCase() + this.progress.type.slice(1).toLowerCase();
|
||||
var progressIndicatorMethod = "setProgressIndicator".concat(this.progress.type.slice(0, 1).toUpperCase()).concat(this.progress.type.slice(1).toLowerCase());
|
||||
|
||||
if (progressIndicatorMethod in this && typeof this[progressIndicatorMethod] === 'function') {
|
||||
this[progressIndicatorMethod].call(this);
|
||||
}
|
||||
|
@ -381,8 +379,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
Drupal.theme.ajaxProgressThrobber = function (message) {
|
||||
var messageMarkup = typeof message === 'string' ? Drupal.theme('ajaxProgressMessage', message) : '';
|
||||
var throbber = '<div class="throbber"> </div>';
|
||||
|
||||
return '<div class="ajax-progress ajax-progress-throbber">' + throbber + messageMarkup + '</div>';
|
||||
return "<div class=\"ajax-progress ajax-progress-throbber\">".concat(throbber).concat(messageMarkup, "</div>");
|
||||
};
|
||||
|
||||
Drupal.theme.ajaxProgressIndicatorFullscreen = function () {
|
||||
|
@ -390,7 +387,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
};
|
||||
|
||||
Drupal.theme.ajaxProgressMessage = function (message) {
|
||||
return '<div class="message">' + message + '</div>';
|
||||
return "<div class=\"message\">".concat(message, "</div>");
|
||||
};
|
||||
|
||||
Drupal.theme.ajaxProgressBar = function ($element) {
|
||||
|
@ -398,13 +395,16 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
};
|
||||
|
||||
Drupal.Ajax.prototype.setProgressIndicatorBar = function () {
|
||||
var progressBar = new Drupal.ProgressBar('ajax-progress-' + this.element.id, $.noop, this.progress.method, $.noop);
|
||||
var progressBar = new Drupal.ProgressBar("ajax-progress-".concat(this.element.id), $.noop, this.progress.method, $.noop);
|
||||
|
||||
if (this.progress.message) {
|
||||
progressBar.setProgress(-1, this.progress.message);
|
||||
}
|
||||
|
||||
if (this.progress.url) {
|
||||
progressBar.startMonitoring(this.progress.url, this.progress.interval || 1500);
|
||||
}
|
||||
|
||||
this.progress.element = $(Drupal.theme('ajaxProgressBar', progressBar.element));
|
||||
this.progress.object = progressBar;
|
||||
$(this.element).after(this.progress.element);
|
||||
|
@ -426,17 +426,18 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
if (this.progress.element) {
|
||||
$(this.progress.element).remove();
|
||||
}
|
||||
|
||||
if (this.progress.object) {
|
||||
this.progress.object.stopMonitoring();
|
||||
}
|
||||
|
||||
$(this.element).prop('disabled', false);
|
||||
|
||||
var elementParents = $(this.element).parents('[data-drupal-selector]').addBack().toArray();
|
||||
|
||||
var focusChanged = false;
|
||||
Object.keys(response || {}).forEach(function (i) {
|
||||
if (response[i].command && _this.commands[response[i].command]) {
|
||||
_this.commands[response[i].command](_this, response[i], status);
|
||||
|
||||
if (response[i].command === 'invoke' && response[i].method === 'focus') {
|
||||
focusChanged = true;
|
||||
}
|
||||
|
@ -447,7 +448,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
var target = false;
|
||||
|
||||
for (var n = elementParents.length - 1; !target && n >= 0; n--) {
|
||||
target = document.querySelector('[data-drupal-selector="' + elementParents[n].getAttribute('data-drupal-selector') + '"]');
|
||||
target = document.querySelector("[data-drupal-selector=\"".concat(elementParents[n].getAttribute('data-drupal-selector'), "\"]"));
|
||||
}
|
||||
|
||||
if (target) {
|
||||
|
@ -466,8 +467,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
Drupal.Ajax.prototype.getEffect = function (response) {
|
||||
var type = response.effect || this.effect;
|
||||
var speed = response.speed || this.speed;
|
||||
|
||||
var effect = {};
|
||||
|
||||
if (type === 'none') {
|
||||
effect.showEffect = 'show';
|
||||
effect.hideEffect = 'hide';
|
||||
|
@ -477,8 +478,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
effect.hideEffect = 'fadeOut';
|
||||
effect.showSpeed = speed;
|
||||
} else {
|
||||
effect.showEffect = type + 'Toggle';
|
||||
effect.hideEffect = type + 'Toggle';
|
||||
effect.showEffect = "".concat(type, "Toggle");
|
||||
effect.hideEffect = "".concat(type, "Toggle");
|
||||
effect.showSpeed = speed;
|
||||
}
|
||||
|
||||
|
@ -489,18 +490,19 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
if (this.progress.element) {
|
||||
$(this.progress.element).remove();
|
||||
}
|
||||
|
||||
if (this.progress.object) {
|
||||
this.progress.object.stopMonitoring();
|
||||
}
|
||||
|
||||
$(this.wrapper).show();
|
||||
|
||||
$(this.element).prop('disabled', false);
|
||||
|
||||
if (this.$form && document.body.contains(this.$form.get(0))) {
|
||||
var settings = this.settings || drupalSettings;
|
||||
Drupal.attachBehaviors(this.$form.get(0), settings);
|
||||
}
|
||||
|
||||
throw new Drupal.AjaxError(xmlhttprequest, uri, customMessage);
|
||||
};
|
||||
|
||||
|
@ -515,16 +517,14 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
};
|
||||
|
||||
Drupal.AjaxCommands = function () {};
|
||||
|
||||
Drupal.AjaxCommands.prototype = {
|
||||
insert: function insert(ajax, response) {
|
||||
var $wrapper = response.selector ? $(response.selector) : $(ajax.wrapper);
|
||||
var method = response.method || ajax.method;
|
||||
var effect = ajax.getEffect(response);
|
||||
|
||||
var settings = response.settings || ajax.settings || drupalSettings;
|
||||
|
||||
var $newContent = $($.parseHTML(response.data, document, true));
|
||||
|
||||
$newContent = Drupal.theme('ajaxWrapperNewContent', $newContent, ajax, response);
|
||||
|
||||
switch (method) {
|
||||
|
@ -535,6 +535,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
case 'remove':
|
||||
Drupal.detachBehaviors($wrapper.get(0), settings);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -546,6 +547,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
}
|
||||
|
||||
var $ajaxNewContent = $newContent.find('.ajax-new-content');
|
||||
|
||||
if ($ajaxNewContent.length) {
|
||||
$ajaxNewContent.hide();
|
||||
$newContent.show();
|
||||
|
@ -570,10 +572,12 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
},
|
||||
changed: function changed(ajax, response, status) {
|
||||
var $element = $(response.selector);
|
||||
|
||||
if (!$element.hasClass('ajax-changed')) {
|
||||
$element.addClass('ajax-changed');
|
||||
|
||||
if (response.asterisk) {
|
||||
$element.find(response.asterisk).append(' <abbr class="ajax-changed" title="' + Drupal.t('Changed') + '">*</abbr> ');
|
||||
$element.find(response.asterisk).append(" <abbr class=\"ajax-changed\" title=\"".concat(Drupal.t('Changed'), "\">*</abbr> "));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -598,9 +602,9 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
|
||||
if (ajaxSettings) {
|
||||
Drupal.ajax.expired().forEach(function (instance) {
|
||||
|
||||
if (instance.selector) {
|
||||
var selector = instance.selector.replace('#', '');
|
||||
|
||||
if (selector in ajaxSettings) {
|
||||
delete ajaxSettings[selector];
|
||||
}
|
||||
|
@ -625,16 +629,18 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
|
|||
$(response.selector).find('> tbody > tr:visible, > tr:visible').removeClass('odd even').filter(':even').addClass('odd').end().filter(':odd').addClass('even');
|
||||
},
|
||||
update_build_id: function update_build_id(ajax, response, status) {
|
||||
$('input[name="form_build_id"][value="' + response.old + '"]').val(response.new);
|
||||
$("input[name=\"form_build_id\"][value=\"".concat(response.old, "\"]")).val(response["new"]);
|
||||
},
|
||||
add_css: function add_css(ajax, response, status) {
|
||||
$('head').prepend(response.data);
|
||||
},
|
||||
message: function message(ajax, response) {
|
||||
var messages = new Drupal.Message(document.querySelector(response.messageWrapperQuerySelector));
|
||||
|
||||
if (response.clearPrevious) {
|
||||
messages.clear();
|
||||
}
|
||||
|
||||
messages.add(response.message, response.messageOptions);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
**/
|
||||
|
||||
(function (Drupal, debounce) {
|
||||
var liveElement = void 0;
|
||||
var liveElement;
|
||||
var announcements = [];
|
||||
|
||||
Drupal.behaviors.drupalAnnounce = {
|
||||
attach: function attach(context) {
|
||||
if (!liveElement) {
|
||||
|
@ -25,9 +24,9 @@
|
|||
function announce() {
|
||||
var text = [];
|
||||
var priority = 'polite';
|
||||
var announcement = void 0;
|
||||
|
||||
var announcement;
|
||||
var il = announcements.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
announcement = announcements.pop();
|
||||
text.unshift(announcement.text);
|
||||
|
@ -39,13 +38,9 @@
|
|||
|
||||
if (text.length) {
|
||||
liveElement.innerHTML = '';
|
||||
|
||||
liveElement.setAttribute('aria-busy', 'true');
|
||||
|
||||
liveElement.setAttribute('aria-live', priority);
|
||||
|
||||
liveElement.innerHTML = text.join('\n');
|
||||
|
||||
liveElement.setAttribute('aria-busy', 'false');
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +50,6 @@
|
|||
text: text,
|
||||
priority: priority
|
||||
});
|
||||
|
||||
return debounce(announce, 200)();
|
||||
};
|
||||
})(Drupal, Drupal.debounce);
|
|
@ -6,17 +6,18 @@
|
|||
**/
|
||||
|
||||
(function ($, Drupal) {
|
||||
var autocomplete = void 0;
|
||||
var autocomplete;
|
||||
|
||||
function autocompleteSplitValues(value) {
|
||||
var result = [];
|
||||
var quote = false;
|
||||
var current = '';
|
||||
var valueLength = value.length;
|
||||
var character = void 0;
|
||||
var character;
|
||||
|
||||
for (var i = 0; i < valueLength; i++) {
|
||||
character = value.charAt(i);
|
||||
|
||||
if (character === '"') {
|
||||
current += character;
|
||||
quote = !quote;
|
||||
|
@ -27,6 +28,7 @@
|
|||
current += character;
|
||||
}
|
||||
}
|
||||
|
||||
if (value.length > 0) {
|
||||
result.push($.trim(current));
|
||||
}
|
||||
|
@ -64,12 +66,15 @@
|
|||
function showSuggestions(suggestions) {
|
||||
var tagged = autocomplete.splitValues(request.term);
|
||||
var il = tagged.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
var index = suggestions.indexOf(tagged[i]);
|
||||
|
||||
if (index >= 0) {
|
||||
suggestions.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
response(suggestions);
|
||||
}
|
||||
|
||||
|
@ -77,14 +82,18 @@
|
|||
|
||||
function sourceCallbackHandler(data) {
|
||||
autocomplete.cache[elementId][term] = data;
|
||||
|
||||
showSuggestions(data);
|
||||
}
|
||||
|
||||
if (autocomplete.cache[elementId].hasOwnProperty(term)) {
|
||||
showSuggestions(autocomplete.cache[elementId][term]);
|
||||
} else {
|
||||
var options = $.extend({ success: sourceCallbackHandler, data: { q: term } }, autocomplete.ajax);
|
||||
var options = $.extend({
|
||||
success: sourceCallbackHandler,
|
||||
data: {
|
||||
q: term
|
||||
}
|
||||
}, autocomplete.ajax);
|
||||
$.ajax(this.element.attr('data-autocomplete-path'), options);
|
||||
}
|
||||
}
|
||||
|
@ -95,13 +104,9 @@
|
|||
|
||||
function selectHandler(event, ui) {
|
||||
var terms = autocomplete.splitValues(event.target.value);
|
||||
|
||||
terms.pop();
|
||||
|
||||
terms.push(ui.item.value);
|
||||
|
||||
event.target.value = terms.join(', ');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -112,16 +117,15 @@
|
|||
Drupal.behaviors.autocomplete = {
|
||||
attach: function attach(context) {
|
||||
var $autocomplete = $(context).find('input.form-autocomplete').once('autocomplete');
|
||||
|
||||
if ($autocomplete.length) {
|
||||
var blacklist = $autocomplete.attr('data-autocomplete-first-character-blacklist');
|
||||
$.extend(autocomplete.options, {
|
||||
firstCharacterBlacklist: blacklist || ''
|
||||
});
|
||||
|
||||
$autocomplete.autocomplete(autocomplete.options).each(function () {
|
||||
$(this).data('ui-autocomplete')._renderItem = autocomplete.options.renderItem;
|
||||
});
|
||||
|
||||
$autocomplete.on('compositionstart.autocomplete', function () {
|
||||
autocomplete.options.isComposing = true;
|
||||
});
|
||||
|
@ -136,13 +140,10 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
autocomplete = {
|
||||
cache: {},
|
||||
|
||||
splitValues: autocompleteSplitValues,
|
||||
extractLastTerm: extractLastTerm,
|
||||
|
||||
options: {
|
||||
source: sourceData,
|
||||
focus: focusHandler,
|
||||
|
@ -150,15 +151,12 @@
|
|||
select: selectHandler,
|
||||
renderItem: renderItem,
|
||||
minLength: 1,
|
||||
|
||||
firstCharacterBlacklist: '',
|
||||
|
||||
isComposing: false
|
||||
},
|
||||
ajax: {
|
||||
dataType: 'json'
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.autocomplete = autocomplete;
|
||||
})(jQuery, Drupal);
|
|
@ -10,12 +10,12 @@
|
|||
attach: function attach(context, settings) {
|
||||
var batch = settings.batch;
|
||||
var $progress = $('[data-drupal-progress]').once('batch');
|
||||
var progressBar = void 0;
|
||||
var progressBar;
|
||||
|
||||
function updateCallback(progress, status, pb) {
|
||||
if (progress === '100') {
|
||||
pb.stopMonitoring();
|
||||
window.location = batch.uri + '&op=finished';
|
||||
window.location = "".concat(batch.uri, "&op=finished");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,10 +27,8 @@
|
|||
if ($progress.length) {
|
||||
progressBar = new Drupal.ProgressBar('updateprogress', updateCallback, 'POST', errorCallback);
|
||||
progressBar.setProgress(-1, batch.initMessage);
|
||||
progressBar.startMonitoring(batch.uri + '&op=do', 10);
|
||||
|
||||
progressBar.startMonitoring("".concat(batch.uri, "&op=do"), 10);
|
||||
$progress.empty();
|
||||
|
||||
$progress.append(progressBar.element);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,21 +9,19 @@
|
|||
function CollapsibleDetails(node) {
|
||||
this.$node = $(node);
|
||||
this.$node.data('details', this);
|
||||
var anchor = window.location.hash && window.location.hash !== '#' ? ", ".concat(window.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".concat(anchor)).length) {
|
||||
this.$node.attr('open', true);
|
||||
}
|
||||
|
||||
this.setupSummary();
|
||||
|
||||
this.setupLegend();
|
||||
}
|
||||
|
||||
$.extend(CollapsibleDetails, {
|
||||
instances: []
|
||||
});
|
||||
|
||||
$.extend(CollapsibleDetails.prototype, {
|
||||
setupSummary: function setupSummary() {
|
||||
this.$summary = $('<span class="summary"></span>');
|
||||
|
@ -31,11 +29,8 @@
|
|||
},
|
||||
setupLegend: function setupLegend() {
|
||||
var $legend = this.$node.find('> summary');
|
||||
|
||||
$('<span class="details-summary-prefix visually-hidden"></span>').append(this.$node.attr('open') ? Drupal.t('Hide') : Drupal.t('Show')).prependTo($legend).after(document.createTextNode(' '));
|
||||
|
||||
$('<a class="details-title"></a>').attr('href', '#' + this.$node.attr('id')).prepend($legend.contents()).appendTo($legend);
|
||||
|
||||
$('<a class="details-title"></a>').attr('href', "#".concat(this.$node.attr('id'))).prepend($legend.contents()).appendTo($legend);
|
||||
$legend.append(this.$summary).on('click', $.proxy(this.onLegendClick, this));
|
||||
},
|
||||
onLegendClick: function onLegendClick(e) {
|
||||
|
@ -44,13 +39,14 @@
|
|||
},
|
||||
onSummaryUpdated: function onSummaryUpdated() {
|
||||
var text = $.trim(this.$node.drupalGetSummary());
|
||||
this.$summary.html(text ? ' (' + text + ')' : '');
|
||||
this.$summary.html(text ? " (".concat(text, ")") : '');
|
||||
},
|
||||
toggle: function toggle() {
|
||||
var _this = this;
|
||||
|
||||
var isOpen = !!this.$node.attr('open');
|
||||
var $summaryPrefix = this.$node.find('> summary span.details-summary-prefix');
|
||||
|
||||
if (isOpen) {
|
||||
$summaryPrefix.html(Drupal.t('Show'));
|
||||
} else {
|
||||
|
@ -62,13 +58,14 @@
|
|||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
Drupal.behaviors.collapse = {
|
||||
attach: function attach(context) {
|
||||
if (Modernizr.details) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $collapsibleDetails = $(context).find('details').once('collapse').addClass('collapse-processed');
|
||||
|
||||
if ($collapsibleDetails.length) {
|
||||
for (var i = 0; i < $collapsibleDetails.length; i++) {
|
||||
CollapsibleDetails.instances.push(new CollapsibleDetails($collapsibleDetails[i]));
|
||||
|
@ -82,6 +79,5 @@
|
|||
};
|
||||
|
||||
$('body').on('formFragmentLinkClickOrHashChange.details', handleFragmentLinkClickOrHashChange);
|
||||
|
||||
Drupal.CollapsibleDetails = CollapsibleDetails;
|
||||
})(jQuery, Modernizr, Drupal);
|
|
@ -4,10 +4,13 @@
|
|||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
(function ($, Modernizr, Drupal) {
|
||||
Drupal.behaviors.date = {
|
||||
attach: function attach(context, settings) {
|
||||
|
@ -15,7 +18,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
var dataDatepickerProcessed = 'data-datepicker-is-processed';
|
||||
|
||||
var getDateSelector = function getDateSelector(elements) {
|
||||
return ['[' + dataFieldElements + '="' + elements + '"]', ':not([' + dataDatepickerProcessed + '="' + elements + '"])'].join('');
|
||||
return ["[".concat(dataFieldElements, "=\"").concat(elements, "\"]"), ":not([".concat(dataDatepickerProcessed, "=\"").concat(elements, "\"])")].join('');
|
||||
};
|
||||
|
||||
if (Modernizr.inputtypes.date === false) {
|
||||
|
@ -23,35 +26,27 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
var dateInput = dateTime.querySelector('input[type="date"]');
|
||||
var timeInput = dateTime.querySelector('input[type="time"]');
|
||||
var help = Drupal.theme.dateTimeHelp({
|
||||
dateId: dateInput.id + '--description',
|
||||
dateId: "".concat(dateInput.id, "--description"),
|
||||
dateDesc: dateInput.dataset.help,
|
||||
timeId: timeInput.id + '--description',
|
||||
timeId: "".concat(timeInput.id, "--description"),
|
||||
timeDesc: timeInput.dataset.help
|
||||
});
|
||||
|
||||
[dateInput, timeInput].forEach(function (input) {
|
||||
input.setAttribute('aria-describedby', input.id + '--description');
|
||||
|
||||
input.setAttribute('aria-describedby', "".concat(input.id, "--description"));
|
||||
input.setAttribute('type', 'text');
|
||||
});
|
||||
|
||||
Drupal.DatepickerPolyfill.attachDescription(dateTime, help);
|
||||
|
||||
dateTime.setAttribute(dataDatepickerProcessed, 'date-time');
|
||||
});
|
||||
|
||||
Array.prototype.forEach.call(document.querySelectorAll(getDateSelector('date')), function (date) {
|
||||
var dateInput = date.querySelector('input[type="date"]');
|
||||
var help = Drupal.theme.dateHelp({
|
||||
dateDesc: dateInput.dataset.help
|
||||
});
|
||||
|
||||
var id = date.id + '--description';
|
||||
var id = "".concat(date.id, "--description");
|
||||
dateInput.setAttribute('aria-describedby', id);
|
||||
|
||||
dateInput.setAttribute('type', 'text');
|
||||
Drupal.DatepickerPolyfill.attachDescription(date, help, id);
|
||||
|
||||
date.setAttribute(dataDatepickerProcessed, 'date');
|
||||
});
|
||||
}
|
||||
|
@ -64,7 +59,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
}
|
||||
|
||||
_createClass(_class, null, [{
|
||||
key: 'attachDescription',
|
||||
key: "attachDescription",
|
||||
value: function attachDescription(element, help, id) {
|
||||
var description = element.nextElementSibling;
|
||||
|
||||
|
@ -72,17 +67,20 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
description = Drupal.DatepickerPolyfill.descriptionWrapperElement(id);
|
||||
element.parentNode.insertBefore(description, element.nextSibling);
|
||||
}
|
||||
|
||||
description.insertAdjacentHTML('beforeend', help);
|
||||
}
|
||||
}, {
|
||||
key: 'descriptionWrapperElement',
|
||||
key: "descriptionWrapperElement",
|
||||
value: function descriptionWrapperElement(id) {
|
||||
var description = document.createElement('div');
|
||||
description.classList.add('description');
|
||||
description.setAttribute('data-drupal-field-elements', 'description');
|
||||
|
||||
if (id) {
|
||||
description.setAttribute('id', id);
|
||||
}
|
||||
|
||||
return description;
|
||||
}
|
||||
}]);
|
||||
|
@ -92,7 +90,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
|
||||
Drupal.theme.dateHelp = function (_ref) {
|
||||
var dateDesc = _ref.dateDesc;
|
||||
return '<div class="no-native-datepicker-help">' + dateDesc + '</div>';
|
||||
return "<div class=\"no-native-datepicker-help\">".concat(dateDesc, "</div>");
|
||||
};
|
||||
|
||||
Drupal.theme.dateTimeHelp = function (_ref2) {
|
||||
|
@ -100,6 +98,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
timeId = _ref2.timeId,
|
||||
dateDesc = _ref2.dateDesc,
|
||||
timeDesc = _ref2.timeDesc;
|
||||
return '<div class="no-native-datepicker-help">\n <span id="' + dateId + '">' + dateDesc + '</span> <span id="' + timeId + '">' + timeDesc + '</span>\n </div>';
|
||||
return "<div class=\"no-native-datepicker-help\">\n <span id=\"".concat(dateId, "\">").concat(dateDesc, "</span> <span id=\"").concat(timeId, "\">").concat(timeDesc, "</span>\n </div>");
|
||||
};
|
||||
})(jQuery, Modernizr, Drupal);
|
|
@ -6,26 +6,31 @@
|
|||
**/
|
||||
|
||||
Drupal.debounce = function (func, wait, immediate) {
|
||||
var timeout = void 0;
|
||||
var result = void 0;
|
||||
var timeout;
|
||||
var result;
|
||||
return function () {
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var context = this;
|
||||
|
||||
var later = function later() {
|
||||
timeout = null;
|
||||
|
||||
if (!immediate) {
|
||||
result = func.apply(context, args);
|
||||
}
|
||||
};
|
||||
|
||||
var callNow = immediate && !timeout;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
|
||||
if (callNow) {
|
||||
result = func.apply(context, args);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
};
|
|
@ -11,7 +11,6 @@
|
|||
$('body').once('detailsAria').on('click.detailsAria', 'summary', function (event) {
|
||||
var $summary = $(event.currentTarget);
|
||||
var open = $(event.currentTarget.parentNode).attr('open') === 'open' ? 'false' : 'true';
|
||||
|
||||
$summary.attr({
|
||||
'aria-expanded': open,
|
||||
'aria-pressed': open
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
}
|
||||
|
||||
var $dialog = $context.closest('.ui-dialog-content');
|
||||
|
||||
if ($dialog.length) {
|
||||
if ($dialog.dialog('option', 'drupalAutoButtons')) {
|
||||
$dialog.trigger('dialogButtonsChange');
|
||||
|
@ -26,7 +27,7 @@
|
|||
var originalClose = settings.dialog.close;
|
||||
|
||||
settings.dialog.close = function (event) {
|
||||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
|
@ -38,10 +39,12 @@
|
|||
var buttons = [];
|
||||
var $buttons = $dialog.find('.form-actions input[type=submit], .form-actions a.button');
|
||||
$buttons.each(function () {
|
||||
var $originalButton = $(this).css({ display: 'none' });
|
||||
var $originalButton = $(this).css({
|
||||
display: 'none'
|
||||
});
|
||||
buttons.push({
|
||||
text: $originalButton.html() || $originalButton.attr('value'),
|
||||
class: $originalButton.attr('class'),
|
||||
"class": $originalButton.attr('class'),
|
||||
click: function click(e) {
|
||||
if ($originalButton.is('a')) {
|
||||
$originalButton[0].click();
|
||||
|
@ -60,9 +63,11 @@
|
|||
if (!response.selector) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var $dialog = $(response.selector);
|
||||
|
||||
if (!$dialog.length) {
|
||||
$dialog = $('<div id="' + response.selector.replace(/^#/, '') + '" class="ui-front"/>').appendTo('body');
|
||||
$dialog = $("<div id=\"".concat(response.selector.replace(/^#/, ''), "\" class=\"ui-front\"/>")).appendTo('body');
|
||||
}
|
||||
|
||||
if (!ajax.wrapper) {
|
||||
|
@ -82,9 +87,9 @@
|
|||
var buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog);
|
||||
$dialog.dialog('option', 'buttons', buttons);
|
||||
});
|
||||
|
||||
response.dialogOptions = response.dialogOptions || {};
|
||||
var dialog = Drupal.dialog($dialog.get(0), response.dialogOptions);
|
||||
|
||||
if (response.dialogOptions.modal) {
|
||||
dialog.showModal();
|
||||
} else {
|
||||
|
@ -96,8 +101,10 @@
|
|||
|
||||
Drupal.AjaxCommands.prototype.closeDialog = function (ajax, response, status) {
|
||||
var $dialog = $(response.selector);
|
||||
|
||||
if ($dialog.length) {
|
||||
Drupal.dialog($dialog.get(0)).close();
|
||||
|
||||
if (!response.persist) {
|
||||
$dialog.remove();
|
||||
}
|
||||
|
@ -108,6 +115,7 @@
|
|||
|
||||
Drupal.AjaxCommands.prototype.setDialogOption = function (ajax, response, status) {
|
||||
var $dialog = $(response.selector);
|
||||
|
||||
if ($dialog.length) {
|
||||
$dialog.dialog('option', response.optionName, response.optionValue);
|
||||
}
|
||||
|
@ -120,7 +128,6 @@
|
|||
e.stopPropagation();
|
||||
});
|
||||
});
|
||||
|
||||
$(window).on('dialog:beforeclose', function (e, dialog, $element) {
|
||||
$element.off('.dialog');
|
||||
});
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
},
|
||||
_createButtons: function _createButtons() {
|
||||
var opts = this.options;
|
||||
var primaryIndex = void 0;
|
||||
var index = void 0;
|
||||
var primaryIndex;
|
||||
var index;
|
||||
var il = opts.buttons.length;
|
||||
|
||||
for (index = 0; index < il; index++) {
|
||||
if (opts.buttons[index].primary && opts.buttons[index].primary === true) {
|
||||
primaryIndex = index;
|
||||
|
@ -23,8 +24,11 @@
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this._super();
|
||||
|
||||
var $buttons = this.uiButtonSet.children().addClass(opts.buttonClass);
|
||||
|
||||
if (typeof primaryIndex !== 'undefined') {
|
||||
$buttons.eq(index).addClass(opts.buttonPrimaryClass);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
drupalSettings.dialog = {
|
||||
autoOpen: true,
|
||||
dialogClass: '',
|
||||
|
||||
buttonClass: 'button',
|
||||
buttonPrimaryClass: 'button--primary',
|
||||
close: function close(event) {
|
||||
|
@ -19,7 +18,7 @@
|
|||
};
|
||||
|
||||
Drupal.dialog = function (element, options) {
|
||||
var undef = void 0;
|
||||
var undef;
|
||||
var $element = $(element);
|
||||
var dialog = {
|
||||
open: false,
|
||||
|
@ -28,7 +27,6 @@
|
|||
|
||||
function openDialog(settings) {
|
||||
settings = $.extend({}, drupalSettings.dialog, options, settings);
|
||||
|
||||
$(window).trigger('dialog:beforecreate', [dialog, $element, settings]);
|
||||
$element.dialog(settings);
|
||||
dialog.open = true;
|
||||
|
@ -44,13 +42,18 @@
|
|||
}
|
||||
|
||||
dialog.show = function () {
|
||||
openDialog({ modal: false });
|
||||
openDialog({
|
||||
modal: false
|
||||
});
|
||||
};
|
||||
dialog.showModal = function () {
|
||||
openDialog({ modal: true });
|
||||
};
|
||||
dialog.close = closeDialog;
|
||||
|
||||
dialog.showModal = function () {
|
||||
openDialog({
|
||||
modal: true
|
||||
});
|
||||
};
|
||||
|
||||
dialog.close = closeDialog;
|
||||
return dialog;
|
||||
};
|
||||
})(jQuery, Drupal, drupalSettings);
|
|
@ -6,17 +6,19 @@
|
|||
**/
|
||||
|
||||
(function ($, Drupal, drupalSettings, debounce, displace) {
|
||||
drupalSettings.dialog = $.extend({ autoResize: true, maxHeight: '95%' }, drupalSettings.dialog);
|
||||
drupalSettings.dialog = $.extend({
|
||||
autoResize: true,
|
||||
maxHeight: '95%'
|
||||
}, drupalSettings.dialog);
|
||||
|
||||
function resetPosition(options) {
|
||||
var offsets = displace.offsets;
|
||||
var left = offsets.left - offsets.right;
|
||||
var top = offsets.top - offsets.bottom;
|
||||
|
||||
var leftString = (left > 0 ? '+' : '-') + Math.abs(Math.round(left / 2)) + 'px';
|
||||
var topString = (top > 0 ? '+' : '-') + Math.abs(Math.round(top / 2)) + 'px';
|
||||
var leftString = "".concat((left > 0 ? '+' : '-') + Math.abs(Math.round(left / 2)), "px");
|
||||
var topString = "".concat((top > 0 ? '+' : '-') + Math.abs(Math.round(top / 2)), "px");
|
||||
options.position = {
|
||||
my: 'center' + (left !== 0 ? leftString : '') + ' center' + (top !== 0 ? topString : ''),
|
||||
my: "center".concat(left !== 0 ? leftString : '', " center").concat(top !== 0 ? topString : ''),
|
||||
of: window
|
||||
};
|
||||
return options;
|
||||
|
@ -26,12 +28,14 @@
|
|||
var positionOptions = ['width', 'height', 'minWidth', 'minHeight', 'maxHeight', 'maxWidth', 'position'];
|
||||
var adjustedOptions = {};
|
||||
var windowHeight = $(window).height();
|
||||
var option = void 0;
|
||||
var optionValue = void 0;
|
||||
var adjustedValue = void 0;
|
||||
var option;
|
||||
var optionValue;
|
||||
var adjustedValue;
|
||||
|
||||
for (var n = 0; n < positionOptions.length; n++) {
|
||||
option = positionOptions[n];
|
||||
optionValue = event.data.settings[option];
|
||||
|
||||
if (optionValue) {
|
||||
if (typeof optionValue === 'string' && /%$/.test(optionValue) && /height/i.test(option)) {
|
||||
windowHeight -= displace.offsets.top + displace.offsets.bottom;
|
||||
|
@ -40,6 +44,7 @@
|
|||
if (option === 'height' && event.data.$element.parent().outerHeight() < adjustedValue) {
|
||||
adjustedValue = 'auto';
|
||||
}
|
||||
|
||||
adjustedOptions[option] = adjustedValue;
|
||||
}
|
||||
}
|
||||
|
@ -48,15 +53,23 @@
|
|||
if (!event.data.settings.modal) {
|
||||
adjustedOptions = resetPosition(adjustedOptions);
|
||||
}
|
||||
|
||||
event.data.$element.dialog('option', adjustedOptions).trigger('dialogContentResize');
|
||||
}
|
||||
|
||||
$(window).on({
|
||||
'dialog:aftercreate': function dialogAftercreate(event, dialog, $element, settings) {
|
||||
var autoResize = debounce(resetSize, 20);
|
||||
var eventData = { settings: settings, $element: $element };
|
||||
var eventData = {
|
||||
settings: settings,
|
||||
$element: $element
|
||||
};
|
||||
|
||||
if (settings.autoResize === true || settings.autoResize === 'true') {
|
||||
$element.dialog('option', { resizable: false, draggable: false }).dialog('widget').css('position', 'fixed');
|
||||
$element.dialog('option', {
|
||||
resizable: false,
|
||||
draggable: false
|
||||
}).dialog('widget').css('position', 'fixed');
|
||||
$(window).on('resize.dialogResize scroll.dialogResize', eventData, autoResize).trigger('resize.dialogResize');
|
||||
$(document).on('drupalViewportOffsetChange.dialogResize', eventData, autoResize);
|
||||
}
|
||||
|
|
|
@ -8,13 +8,9 @@
|
|||
(function ($, Drupal, debounce, displace) {
|
||||
Drupal.offCanvas = {
|
||||
position: null,
|
||||
|
||||
minimumHeight: 30,
|
||||
|
||||
minDisplaceWidth: 768,
|
||||
|
||||
$mainCanvasWrapper: $('[data-off-canvas-main-canvas]'),
|
||||
|
||||
isOffCanvas: function isOffCanvas($element) {
|
||||
return $element.is('#drupal-off-canvas');
|
||||
},
|
||||
|
@ -26,17 +22,13 @@
|
|||
beforeCreate: function beforeCreate(_ref) {
|
||||
var settings = _ref.settings,
|
||||
$element = _ref.$element;
|
||||
|
||||
Drupal.offCanvas.removeOffCanvasEvents($element);
|
||||
|
||||
$('body').addClass('js-off-canvas-dialog-open');
|
||||
|
||||
settings.position = {
|
||||
my: 'left top',
|
||||
at: Drupal.offCanvas.getEdge() + ' top',
|
||||
at: "".concat(Drupal.offCanvas.getEdge(), " top"),
|
||||
of: window
|
||||
};
|
||||
|
||||
var position = settings.drupalOffCanvasPosition;
|
||||
var height = position === 'side' ? $(window).height() : settings.height;
|
||||
var width = position === 'side' ? settings.width : '100%';
|
||||
|
@ -45,43 +37,38 @@
|
|||
},
|
||||
beforeClose: function beforeClose(_ref2) {
|
||||
var $element = _ref2.$element;
|
||||
|
||||
$('body').removeClass('js-off-canvas-dialog-open');
|
||||
|
||||
Drupal.offCanvas.removeOffCanvasEvents($element);
|
||||
Drupal.offCanvas.resetPadding();
|
||||
},
|
||||
afterCreate: function afterCreate(_ref3) {
|
||||
var $element = _ref3.$element,
|
||||
settings = _ref3.settings;
|
||||
|
||||
var eventData = { settings: settings, $element: $element, offCanvasDialog: this };
|
||||
|
||||
var eventData = {
|
||||
settings: settings,
|
||||
$element: $element,
|
||||
offCanvasDialog: this
|
||||
};
|
||||
$element.on('dialogContentResize.off-canvas', eventData, Drupal.offCanvas.handleDialogResize).on('dialogContentResize.off-canvas', eventData, Drupal.offCanvas.bodyPadding);
|
||||
|
||||
Drupal.offCanvas.getContainer($element).attr('data-offset-' + Drupal.offCanvas.getEdge(), '');
|
||||
|
||||
Drupal.offCanvas.getContainer($element).attr("data-offset-".concat(Drupal.offCanvas.getEdge()), '');
|
||||
$(window).on('resize.off-canvas', eventData, debounce(Drupal.offCanvas.resetSize, 100)).trigger('resize.off-canvas');
|
||||
},
|
||||
render: function render(_ref4) {
|
||||
var settings = _ref4.settings;
|
||||
|
||||
$('.ui-dialog-off-canvas, .ui-dialog-off-canvas .ui-dialog-titlebar').toggleClass('ui-dialog-empty-title', !settings.title);
|
||||
},
|
||||
handleDialogResize: function handleDialogResize(event) {
|
||||
var $element = event.data.$element;
|
||||
var $container = Drupal.offCanvas.getContainer($element);
|
||||
|
||||
var $offsets = $container.find('> :not(#drupal-off-canvas, .ui-resizable-handle)');
|
||||
var offset = 0;
|
||||
|
||||
$element.css({ height: 'auto' });
|
||||
$element.css({
|
||||
height: 'auto'
|
||||
});
|
||||
var modalHeight = $container.height();
|
||||
|
||||
$offsets.each(function (i, e) {
|
||||
offset += $(e).outerHeight();
|
||||
});
|
||||
|
||||
var scrollOffset = $element.outerHeight() - $element.height();
|
||||
$element.height(modalHeight - offset - scrollOffset);
|
||||
},
|
||||
|
@ -91,57 +78,55 @@
|
|||
var position = event.data.settings.drupalOffCanvasPosition;
|
||||
|
||||
if (Drupal.offCanvas.position && Drupal.offCanvas.position !== position) {
|
||||
container.removeAttr('data-offset-' + Drupal.offCanvas.position);
|
||||
container.removeAttr("data-offset-".concat(Drupal.offCanvas.position));
|
||||
}
|
||||
|
||||
if (position === 'top') {
|
||||
$element.css('min-height', Drupal.offCanvas.minimumHeight + 'px');
|
||||
$element.css('min-height', "".concat(Drupal.offCanvas.minimumHeight, "px"));
|
||||
}
|
||||
|
||||
displace();
|
||||
|
||||
var offsets = displace.offsets;
|
||||
|
||||
var topPosition = position === 'side' && offsets.top !== 0 ? '+' + offsets.top : '';
|
||||
var topPosition = position === 'side' && offsets.top !== 0 ? "+".concat(offsets.top) : '';
|
||||
var adjustedOptions = {
|
||||
position: {
|
||||
my: Drupal.offCanvas.getEdge() + ' top',
|
||||
at: Drupal.offCanvas.getEdge() + ' top' + topPosition,
|
||||
my: "".concat(Drupal.offCanvas.getEdge(), " top"),
|
||||
at: "".concat(Drupal.offCanvas.getEdge(), " top").concat(topPosition),
|
||||
of: window
|
||||
}
|
||||
};
|
||||
|
||||
var height = position === 'side' ? $(window).height() - (offsets.top + offsets.bottom) + 'px' : event.data.settings.height;
|
||||
var height = position === 'side' ? "".concat($(window).height() - (offsets.top + offsets.bottom), "px") : event.data.settings.height;
|
||||
container.css({
|
||||
position: 'fixed',
|
||||
height: height
|
||||
});
|
||||
|
||||
$element.dialog('option', adjustedOptions).trigger('dialogContentResize.off-canvas');
|
||||
|
||||
Drupal.offCanvas.position = position;
|
||||
},
|
||||
bodyPadding: function bodyPadding(event) {
|
||||
var position = event.data.settings.drupalOffCanvasPosition;
|
||||
|
||||
if (position === 'side' && $('body').outerWidth() < Drupal.offCanvas.minDisplaceWidth) {
|
||||
return;
|
||||
}
|
||||
|
||||
Drupal.offCanvas.resetPadding();
|
||||
var $element = event.data.$element;
|
||||
var $container = Drupal.offCanvas.getContainer($element);
|
||||
var $mainCanvasWrapper = Drupal.offCanvas.$mainCanvasWrapper;
|
||||
|
||||
var width = $container.outerWidth();
|
||||
var mainCanvasPadding = $mainCanvasWrapper.css('padding-' + Drupal.offCanvas.getEdge());
|
||||
var mainCanvasPadding = $mainCanvasWrapper.css("padding-".concat(Drupal.offCanvas.getEdge()));
|
||||
|
||||
if (position === 'side' && width !== mainCanvasPadding) {
|
||||
$mainCanvasWrapper.css('padding-' + Drupal.offCanvas.getEdge(), width + 'px');
|
||||
$container.attr('data-offset-' + Drupal.offCanvas.getEdge(), width);
|
||||
$mainCanvasWrapper.css("padding-".concat(Drupal.offCanvas.getEdge()), "".concat(width, "px"));
|
||||
$container.attr("data-offset-".concat(Drupal.offCanvas.getEdge()), width);
|
||||
displace();
|
||||
}
|
||||
|
||||
var height = $container.outerHeight();
|
||||
|
||||
if (position === 'top') {
|
||||
$mainCanvasWrapper.css('padding-top', height + 'px');
|
||||
$mainCanvasWrapper.css('padding-top', "".concat(height, "px"));
|
||||
$container.attr('data-offset-top', height);
|
||||
displace();
|
||||
}
|
||||
|
@ -153,29 +138,42 @@
|
|||
return document.documentElement.dir === 'rtl' ? 'left' : 'right';
|
||||
},
|
||||
resetPadding: function resetPadding() {
|
||||
Drupal.offCanvas.$mainCanvasWrapper.css('padding-' + Drupal.offCanvas.getEdge(), 0);
|
||||
Drupal.offCanvas.$mainCanvasWrapper.css("padding-".concat(Drupal.offCanvas.getEdge()), 0);
|
||||
Drupal.offCanvas.$mainCanvasWrapper.css('padding-top', 0);
|
||||
displace();
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.offCanvasEvents = {
|
||||
attach: function attach() {
|
||||
$(window).once('off-canvas').on({
|
||||
'dialog:beforecreate': function dialogBeforecreate(event, dialog, $element, settings) {
|
||||
if (Drupal.offCanvas.isOffCanvas($element)) {
|
||||
Drupal.offCanvas.beforeCreate({ dialog: dialog, $element: $element, settings: settings });
|
||||
Drupal.offCanvas.beforeCreate({
|
||||
dialog: dialog,
|
||||
$element: $element,
|
||||
settings: settings
|
||||
});
|
||||
}
|
||||
},
|
||||
'dialog:aftercreate': function dialogAftercreate(event, dialog, $element, settings) {
|
||||
if (Drupal.offCanvas.isOffCanvas($element)) {
|
||||
Drupal.offCanvas.render({ dialog: dialog, $element: $element, settings: settings });
|
||||
Drupal.offCanvas.afterCreate({ $element: $element, settings: settings });
|
||||
Drupal.offCanvas.render({
|
||||
dialog: dialog,
|
||||
$element: $element,
|
||||
settings: settings
|
||||
});
|
||||
Drupal.offCanvas.afterCreate({
|
||||
$element: $element,
|
||||
settings: settings
|
||||
});
|
||||
}
|
||||
},
|
||||
'dialog:beforeclose': function dialogBeforeclose(event, dialog, $element) {
|
||||
if (Drupal.offCanvas.isOffCanvas($element)) {
|
||||
Drupal.offCanvas.beforeClose({ dialog: dialog, $element: $element });
|
||||
Drupal.offCanvas.beforeClose({
|
||||
dialog: dialog,
|
||||
$element: $element
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -18,10 +18,8 @@
|
|||
var documentElement = document.documentElement;
|
||||
var displacement = 0;
|
||||
var horizontal = edge === 'left' || edge === 'right';
|
||||
|
||||
var placement = $el.offset()[horizontal ? 'left' : 'top'];
|
||||
|
||||
placement -= window['scroll' + (horizontal ? 'X' : 'Y')] || document.documentElement['scroll' + (horizontal ? 'Left' : 'Top')] || 0;
|
||||
placement -= window["scroll".concat(horizontal ? 'X' : 'Y')] || document.documentElement["scroll".concat(horizontal ? 'Left' : 'Top')] || 0;
|
||||
|
||||
switch (edge) {
|
||||
case 'top':
|
||||
|
@ -43,13 +41,15 @@
|
|||
default:
|
||||
displacement = 0;
|
||||
}
|
||||
|
||||
return displacement;
|
||||
}
|
||||
|
||||
function calculateOffset(edge) {
|
||||
var edgeOffset = 0;
|
||||
var displacingElements = document.querySelectorAll('[data-offset-' + edge + ']');
|
||||
var displacingElements = document.querySelectorAll("[data-offset-".concat(edge, "]"));
|
||||
var n = displacingElements.length;
|
||||
|
||||
for (var i = 0; i < n; i++) {
|
||||
var el = displacingElements[i];
|
||||
|
||||
|
@ -57,7 +57,7 @@
|
|||
continue;
|
||||
}
|
||||
|
||||
var displacement = parseInt(el.getAttribute('data-offset-' + edge), 10);
|
||||
var displacement = parseInt(el.getAttribute("data-offset-".concat(edge)), 10);
|
||||
|
||||
if (isNaN(displacement)) {
|
||||
displacement = getRawOffset(el, edge);
|
||||
|
@ -81,9 +81,11 @@
|
|||
function displace(broadcast) {
|
||||
offsets = calculateOffsets();
|
||||
Drupal.displace.offsets = offsets;
|
||||
|
||||
if (typeof broadcast === 'undefined' || broadcast) {
|
||||
$(document).trigger('drupalViewportOffsetChange', offsets);
|
||||
}
|
||||
|
||||
return offsets;
|
||||
}
|
||||
|
||||
|
@ -92,16 +94,14 @@
|
|||
if (this.displaceProcessed) {
|
||||
return;
|
||||
}
|
||||
this.displaceProcessed = true;
|
||||
|
||||
this.displaceProcessed = true;
|
||||
$(window).on('resize.drupalDisplace', debounce(displace, 200));
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.displace = displace;
|
||||
$.extend(Drupal.displace, {
|
||||
offsets: offsets,
|
||||
|
||||
calculateOffset: calculateOffset
|
||||
});
|
||||
})(jQuery, Drupal, Drupal.debounce);
|
|
@ -7,30 +7,23 @@
|
|||
|
||||
(function ($, Drupal) {
|
||||
function DropButton(dropbutton, settings) {
|
||||
var options = $.extend({ title: Drupal.t('List additional actions') }, settings);
|
||||
var options = $.extend({
|
||||
title: Drupal.t('List additional actions')
|
||||
}, settings);
|
||||
var $dropbutton = $(dropbutton);
|
||||
|
||||
this.$dropbutton = $dropbutton;
|
||||
|
||||
this.$list = $dropbutton.find('.dropbutton');
|
||||
|
||||
this.$actions = this.$list.find('li').addClass('dropbutton-action');
|
||||
|
||||
if (this.$actions.length > 1) {
|
||||
var $primary = this.$actions.slice(0, 1);
|
||||
|
||||
var $secondary = this.$actions.slice(1);
|
||||
$secondary.addClass('secondary-action');
|
||||
|
||||
$primary.after(Drupal.theme('dropbuttonToggle', options));
|
||||
|
||||
this.$dropbutton.addClass('dropbutton-multiple').on({
|
||||
'mouseleave.dropbutton': $.proxy(this.hoverOut, this),
|
||||
|
||||
'mouseenter.dropbutton': $.proxy(this.hoverIn, this),
|
||||
|
||||
'focusout.dropbutton': $.proxy(this.focusOut, this),
|
||||
|
||||
'focusin.dropbutton': $.proxy(this.focusIn, this)
|
||||
});
|
||||
} else {
|
||||
|
@ -46,24 +39,25 @@
|
|||
Drupal.behaviors.dropButton = {
|
||||
attach: function attach(context, settings) {
|
||||
var $dropbuttons = $(context).find('.dropbutton-wrapper').once('dropbutton');
|
||||
|
||||
if ($dropbuttons.length) {
|
||||
var $body = $('body').once('dropbutton-click');
|
||||
|
||||
if ($body.length) {
|
||||
$body.on('click', '.dropbutton-toggle', dropbuttonClickHandler);
|
||||
}
|
||||
|
||||
var il = $dropbuttons.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
DropButton.dropbuttons.push(new DropButton($dropbuttons[i], settings.dropbutton));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.extend(DropButton, {
|
||||
dropbuttons: []
|
||||
});
|
||||
|
||||
$.extend(DropButton.prototype, {
|
||||
toggle: function toggle(show) {
|
||||
var isBool = typeof show === 'boolean';
|
||||
|
@ -91,12 +85,10 @@
|
|||
this.hoverIn.call(this, e);
|
||||
}
|
||||
});
|
||||
|
||||
$.extend(Drupal.theme, {
|
||||
dropbuttonToggle: function dropbuttonToggle(options) {
|
||||
return '<li class="dropbutton-toggle"><button type="button"><span class="dropbutton-arrow"><span class="visually-hidden">' + options.title + '</span></span></button></li>';
|
||||
return "<li class=\"dropbutton-toggle\"><button type=\"button\"><span class=\"dropbutton-arrow\"><span class=\"visually-hidden\">".concat(options.title, "</span></span></button></li>");
|
||||
}
|
||||
});
|
||||
|
||||
Drupal.DropButton = DropButton;
|
||||
})(jQuery, Drupal);
|
|
@ -20,6 +20,7 @@ document.documentElement.className += ' js';
|
|||
callback();
|
||||
document.removeEventListener('DOMContentLoaded', listener);
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', listener);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
* @preserve
|
||||
**/
|
||||
|
||||
window.Drupal = { behaviors: {}, locale: {} };
|
||||
window.Drupal = {
|
||||
behaviors: {},
|
||||
locale: {}
|
||||
};
|
||||
|
||||
(function (Drupal, drupalSettings, drupalTranslations, console, Proxy, Reflect) {
|
||||
Drupal.throwError = function (error) {
|
||||
|
@ -18,7 +21,6 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
context = context || document;
|
||||
settings = settings || drupalSettings;
|
||||
var behaviors = Drupal.behaviors;
|
||||
|
||||
Object.keys(behaviors || {}).forEach(function (i) {
|
||||
if (typeof behaviors[i].attach === 'function') {
|
||||
try {
|
||||
|
@ -35,7 +37,6 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
settings = settings || drupalSettings;
|
||||
trigger = trigger || 'unload';
|
||||
var behaviors = Drupal.behaviors;
|
||||
|
||||
Object.keys(behaviors || {}).forEach(function (i) {
|
||||
if (typeof behaviors[i].detach === 'function') {
|
||||
try {
|
||||
|
@ -54,7 +55,6 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
|
||||
Drupal.formatString = function (str, args) {
|
||||
var processedArgs = {};
|
||||
|
||||
Object.keys(args || {}).forEach(function (key) {
|
||||
switch (key.charAt(0)) {
|
||||
case '@':
|
||||
|
@ -70,7 +70,6 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
break;
|
||||
}
|
||||
});
|
||||
|
||||
return Drupal.stringReplace(str, processedArgs, null);
|
||||
};
|
||||
|
||||
|
@ -81,7 +80,6 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
|
||||
if (!Array.isArray(keys)) {
|
||||
keys = Object.keys(args || {});
|
||||
|
||||
keys.sort(function (a, b) {
|
||||
return a.length - b.length;
|
||||
});
|
||||
|
@ -114,6 +112,7 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
if (args) {
|
||||
str = Drupal.formatString(str, args);
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
|
@ -129,7 +128,6 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
} catch (e) {}
|
||||
|
||||
urlParsingNode.setAttribute('href', url);
|
||||
|
||||
return urlParsingNode.cloneNode(false).href;
|
||||
};
|
||||
|
||||
|
@ -140,28 +138,29 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
if (protocol === 'http:' && absoluteUrl.indexOf('https:') === 0) {
|
||||
protocol = 'https:';
|
||||
}
|
||||
var baseUrl = protocol + '//' + window.location.host + drupalSettings.path.baseUrl.slice(0, -1);
|
||||
|
||||
var baseUrl = "".concat(protocol, "//").concat(window.location.host).concat(drupalSettings.path.baseUrl.slice(0, -1));
|
||||
|
||||
try {
|
||||
absoluteUrl = decodeURIComponent(absoluteUrl);
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
baseUrl = decodeURIComponent(baseUrl);
|
||||
} catch (e) {}
|
||||
|
||||
return absoluteUrl === baseUrl || absoluteUrl.indexOf(baseUrl + '/') === 0;
|
||||
return absoluteUrl === baseUrl || absoluteUrl.indexOf("".concat(baseUrl, "/")) === 0;
|
||||
};
|
||||
|
||||
Drupal.formatPlural = function (count, singular, plural, args, options) {
|
||||
args = args || {};
|
||||
args['@count'] = count;
|
||||
|
||||
var pluralDelimiter = drupalSettings.pluralDelimiter;
|
||||
var translations = Drupal.t(singular + pluralDelimiter + plural, args, options).split(pluralDelimiter);
|
||||
var index = 0;
|
||||
|
||||
if (typeof drupalTranslations !== 'undefined' && drupalTranslations.pluralFormula) {
|
||||
index = count in drupalTranslations.pluralFormula ? drupalTranslations.pluralFormula[count] : drupalTranslations.pluralFormula.default;
|
||||
index = count in drupalTranslations.pluralFormula ? drupalTranslations.pluralFormula[count] : drupalTranslations.pluralFormula["default"];
|
||||
} else if (args['@count'] !== 1) {
|
||||
index = 1;
|
||||
}
|
||||
|
@ -177,7 +176,7 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
var message = _ref.message;
|
||||
|
||||
if (drupalSettings.suppressDeprecationErrors === false && typeof console !== 'undefined' && console.warn) {
|
||||
console.warn('[Deprecation] ' + message);
|
||||
console.warn("[Deprecation] ".concat(message));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -192,13 +191,16 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
|
||||
return new Proxy(target, {
|
||||
get: function get(target, key) {
|
||||
for (var _len = arguments.length, rest = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
||||
if (key === deprecatedProperty) {
|
||||
Drupal.deprecationError({
|
||||
message: message
|
||||
});
|
||||
}
|
||||
|
||||
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
||||
rest[_key - 2] = arguments[_key];
|
||||
}
|
||||
|
||||
if (key === deprecatedProperty) {
|
||||
Drupal.deprecationError({ message: message });
|
||||
}
|
||||
return Reflect.get.apply(Reflect, [target, key].concat(rest));
|
||||
}
|
||||
});
|
||||
|
@ -208,7 +210,7 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
if (func in Drupal.theme) {
|
||||
var _Drupal$theme;
|
||||
|
||||
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
|
@ -217,6 +219,6 @@ window.Drupal = { behaviors: {}, locale: {} };
|
|||
};
|
||||
|
||||
Drupal.theme.placeholder = function (str) {
|
||||
return '<em class="placeholder">' + Drupal.checkPlain(str) + '</em>';
|
||||
return "<em class=\"placeholder\">".concat(Drupal.checkPlain(str), "</em>");
|
||||
};
|
||||
})(Drupal, window.drupalSettings, window.drupalTranslations, window.console, window.Proxy, window.Reflect);
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
(function () {
|
||||
var settingsElement = document.querySelector('head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"]');
|
||||
|
||||
window.drupalSettings = {};
|
||||
|
||||
if (settingsElement !== null) {
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
|
||||
return Drupal.t('No revision');
|
||||
});
|
||||
|
||||
$context.find('details.entity-translation-options').drupalSetSummary(function (context) {
|
||||
var $translationContext = $(context);
|
||||
var translate = void 0;
|
||||
var translate;
|
||||
var $checkbox = $translationContext.find('.js-form-item-translation-translate input');
|
||||
|
||||
if ($checkbox.length) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
if (typeof callback !== 'function') {
|
||||
var val = callback;
|
||||
|
||||
callback = function callback() {
|
||||
return val;
|
||||
};
|
||||
|
@ -32,6 +33,7 @@
|
|||
var $form = $(e.currentTarget);
|
||||
var formValues = $form.serialize();
|
||||
var previousValues = $form.attr('data-drupal-form-submit-last');
|
||||
|
||||
if (previousValues === formValues) {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
|
@ -51,7 +53,6 @@
|
|||
var $fieldList = $(form).find('[name]').map(function (index, element) {
|
||||
return element.getAttribute('id');
|
||||
});
|
||||
|
||||
return $.makeArray($fieldList);
|
||||
}
|
||||
|
||||
|
@ -60,7 +61,7 @@
|
|||
var $context = $(context);
|
||||
var contextIsForm = $context.is('form');
|
||||
var $forms = (contextIsForm ? $context : $context.find('form')).once('form-updated');
|
||||
var formFields = void 0;
|
||||
var formFields;
|
||||
|
||||
if ($forms.length) {
|
||||
$.makeArray($forms).forEach(function (form) {
|
||||
|
@ -69,7 +70,6 @@
|
|||
triggerFormUpdated(event.target);
|
||||
}, 300);
|
||||
formFields = fieldsList(form).join(',');
|
||||
|
||||
form.setAttribute('data-drupal-form-fields', formFields);
|
||||
$(form).on(events, eventHandler);
|
||||
});
|
||||
|
@ -77,7 +77,6 @@
|
|||
|
||||
if (contextIsForm) {
|
||||
formFields = fieldsList(context).join(',');
|
||||
|
||||
var currentFields = $(context).attr('data-drupal-form-fields');
|
||||
|
||||
if (formFields !== currentFields) {
|
||||
|
@ -88,8 +87,10 @@
|
|||
detach: function detach(context, settings, trigger) {
|
||||
var $context = $(context);
|
||||
var contextIsForm = $context.is('form');
|
||||
|
||||
if (trigger === 'unload') {
|
||||
var $forms = (contextIsForm ? $context : $context.find('form')).removeOnce('form-updated');
|
||||
|
||||
if ($forms.length) {
|
||||
$.makeArray($forms).forEach(function (form) {
|
||||
form.removeAttribute('data-drupal-form-fields');
|
||||
|
@ -99,26 +100,29 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.fillUserInfoFromBrowser = {
|
||||
attach: function attach(context, settings) {
|
||||
var userInfo = ['name', 'mail', 'homepage'];
|
||||
var $forms = $('[data-user-info-from-browser]').once('user-info-from-browser');
|
||||
|
||||
if ($forms.length) {
|
||||
userInfo.forEach(function (info) {
|
||||
var $element = $forms.find('[name=' + info + ']');
|
||||
var browserData = localStorage.getItem('Drupal.visitor.' + info);
|
||||
var $element = $forms.find("[name=".concat(info, "]"));
|
||||
var browserData = localStorage.getItem("Drupal.visitor.".concat(info));
|
||||
var emptyOrDefault = $element.val() === '' || $element.attr('data-drupal-default-value') === $element.val();
|
||||
|
||||
if ($element.length && emptyOrDefault && browserData) {
|
||||
$element.val(browserData);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$forms.on('submit', function () {
|
||||
userInfo.forEach(function (info) {
|
||||
var $element = $forms.find('[name=' + info + ']');
|
||||
var $element = $forms.find("[name=".concat(info, "]"));
|
||||
|
||||
if ($element.length) {
|
||||
localStorage.setItem('Drupal.visitor.' + info, $element.val());
|
||||
localStorage.setItem("Drupal.visitor.".concat(info), $element.val());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -126,17 +130,19 @@
|
|||
};
|
||||
|
||||
var handleFragmentLinkClickOrHashChange = function handleFragmentLinkClickOrHashChange(e) {
|
||||
var url = void 0;
|
||||
var url;
|
||||
|
||||
if (e.type === 'click') {
|
||||
url = e.currentTarget.location ? e.currentTarget.location : e.currentTarget;
|
||||
} else {
|
||||
url = window.location;
|
||||
}
|
||||
var hash = url.hash.substr(1);
|
||||
if (hash) {
|
||||
var $target = $('#' + hash);
|
||||
$('body').trigger('formFragmentLinkClickOrHashChange', [$target]);
|
||||
|
||||
var hash = url.hash.substr(1);
|
||||
|
||||
if (hash) {
|
||||
var $target = $("#".concat(hash));
|
||||
$('body').trigger('formFragmentLinkClickOrHashChange', [$target]);
|
||||
setTimeout(function () {
|
||||
return $target.trigger('focus');
|
||||
}, 300);
|
||||
|
@ -144,8 +150,6 @@
|
|||
};
|
||||
|
||||
var debouncedHandleFragmentLinkClickOrHashChange = debounce(handleFragmentLinkClickOrHashChange, 300, true);
|
||||
|
||||
$(window).on('hashchange.form-fragment', debouncedHandleFragmentLinkClickOrHashChange);
|
||||
|
||||
$(document).on('click.form-fragment', 'a[href*="#"]', debouncedHandleFragmentLinkClickOrHashChange);
|
||||
})(jQuery, Drupal, Drupal.debounce);
|
|
@ -25,7 +25,6 @@
|
|||
var data = e.data;
|
||||
var options = data.options;
|
||||
var baseValue = $(e.target).val();
|
||||
|
||||
var rx = new RegExp(options.replace_pattern, 'g');
|
||||
var expected = baseValue.toLowerCase().replace(rx, options.replace).substr(0, options.maxlength);
|
||||
|
||||
|
@ -38,6 +37,7 @@
|
|||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
|
||||
if (baseValue.toLowerCase() !== expected) {
|
||||
timeout = setTimeout(function () {
|
||||
xhr = self.transliterate(baseValue, options).done(function (machine) {
|
||||
|
@ -52,7 +52,6 @@
|
|||
Object.keys(settings.machineName).forEach(function (sourceId) {
|
||||
var machine = '';
|
||||
var options = settings.machineName[sourceId];
|
||||
|
||||
var $source = $context.find(sourceId).addClass('machine-name-source').once('machine-name');
|
||||
var $target = $context.find(options.target).addClass('machine-name-target');
|
||||
var $suffix = $context.find(options.suffix);
|
||||
|
@ -67,7 +66,6 @@
|
|||
}
|
||||
|
||||
options.maxlength = $target.attr('maxlength');
|
||||
|
||||
$wrapper.addClass('visually-hidden');
|
||||
|
||||
if ($target.is(':disabled') || $target.val() !== '') {
|
||||
|
@ -76,11 +74,13 @@
|
|||
machine = self.transliterate($source.val(), options);
|
||||
}
|
||||
|
||||
var $preview = $('<span class="machine-name-value">' + options.field_prefix + Drupal.checkPlain(machine) + options.field_suffix + '</span>');
|
||||
var $preview = $("<span class=\"machine-name-value\">".concat(options.field_prefix).concat(Drupal.checkPlain(machine)).concat(options.field_suffix, "</span>"));
|
||||
$suffix.empty();
|
||||
|
||||
if (options.label) {
|
||||
$suffix.append('<span class="machine-name-label">' + options.label + ': </span>');
|
||||
$suffix.append("<span class=\"machine-name-label\">".concat(options.label, ": </span>"));
|
||||
}
|
||||
|
||||
$suffix.append($preview);
|
||||
|
||||
if ($target.is(':disabled')) {
|
||||
|
@ -95,8 +95,7 @@
|
|||
$preview: $preview,
|
||||
options: options
|
||||
};
|
||||
|
||||
var $link = $('<span class="admin-link"><button type="button" class="link">' + Drupal.t('Edit') + '</button></span>').on('click', eventData, clickEditHandler);
|
||||
var $link = $("<span class=\"admin-link\"><button type=\"button\" class=\"link\">".concat(Drupal.t('Edit'), "</button></span>")).on('click', eventData, clickEditHandler);
|
||||
$suffix.append($link);
|
||||
|
||||
if ($target.val() === '') {
|
||||
|
@ -114,6 +113,7 @@
|
|||
data.$target.val(machine);
|
||||
data.$preview.html(settings.field_prefix + Drupal.checkPlain(machine) + settings.field_suffix);
|
||||
}
|
||||
|
||||
data.$suffix.show();
|
||||
} else {
|
||||
data.$suffix.hide();
|
||||
|
|
|
@ -4,10 +4,13 @@
|
|||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
(function (Drupal) {
|
||||
Drupal.Message = function () {
|
||||
function _class() {
|
||||
|
@ -23,7 +26,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
}
|
||||
|
||||
_createClass(_class, [{
|
||||
key: 'add',
|
||||
key: "add",
|
||||
value: function add(message) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
|
@ -36,31 +39,30 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
}
|
||||
|
||||
Drupal.Message.announce(message, options);
|
||||
|
||||
options.id = options.id ? String(options.id) : options.type + '-' + Math.random().toFixed(15).replace('0.', '');
|
||||
options.id = options.id ? String(options.id) : "".concat(options.type, "-").concat(Math.random().toFixed(15).replace('0.', ''));
|
||||
|
||||
if (!Drupal.Message.getMessageTypeLabels().hasOwnProperty(options.type)) {
|
||||
var type = options.type;
|
||||
|
||||
throw new Error('The message type, ' + type + ', is not present in Drupal.Message.getMessageTypeLabels().');
|
||||
throw new Error("The message type, ".concat(type, ", is not present in Drupal.Message.getMessageTypeLabels()."));
|
||||
}
|
||||
|
||||
this.messageWrapper.appendChild(Drupal.theme('message', { text: message }, options));
|
||||
|
||||
this.messageWrapper.appendChild(Drupal.theme('message', {
|
||||
text: message
|
||||
}, options));
|
||||
return options.id;
|
||||
}
|
||||
}, {
|
||||
key: 'select',
|
||||
key: "select",
|
||||
value: function select(id) {
|
||||
return this.messageWrapper.querySelector('[data-drupal-message-id^="' + id + '"]');
|
||||
return this.messageWrapper.querySelector("[data-drupal-message-id^=\"".concat(id, "\"]"));
|
||||
}
|
||||
}, {
|
||||
key: 'remove',
|
||||
key: "remove",
|
||||
value: function remove(id) {
|
||||
return this.messageWrapper.removeChild(this.select(id));
|
||||
}
|
||||
}, {
|
||||
key: 'clear',
|
||||
key: "clear",
|
||||
value: function clear() {
|
||||
var _this = this;
|
||||
|
||||
|
@ -69,19 +71,21 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
});
|
||||
}
|
||||
}], [{
|
||||
key: 'defaultWrapper',
|
||||
key: "defaultWrapper",
|
||||
value: function defaultWrapper() {
|
||||
var wrapper = document.querySelector('[data-drupal-messages]');
|
||||
|
||||
if (!wrapper) {
|
||||
wrapper = document.querySelector('[data-drupal-messages-fallback]');
|
||||
wrapper.removeAttribute('data-drupal-messages-fallback');
|
||||
wrapper.setAttribute('data-drupal-messages', '');
|
||||
wrapper.classList.remove('hidden');
|
||||
}
|
||||
|
||||
return wrapper.innerHTML === '' ? Drupal.Message.messageInternalWrapper(wrapper) : wrapper.firstElementChild;
|
||||
}
|
||||
}, {
|
||||
key: 'getMessageTypeLabels',
|
||||
key: "getMessageTypeLabels",
|
||||
value: function getMessageTypeLabels() {
|
||||
return {
|
||||
status: Drupal.t('Status message'),
|
||||
|
@ -90,7 +94,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
};
|
||||
}
|
||||
}, {
|
||||
key: 'announce',
|
||||
key: "announce",
|
||||
value: function announce(message, options) {
|
||||
if (!options.priority && (options.type === 'warning' || options.type === 'error')) {
|
||||
options.priority = 'assertive';
|
||||
|
@ -101,7 +105,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
}
|
||||
}
|
||||
}, {
|
||||
key: 'messageInternalWrapper',
|
||||
key: "messageInternalWrapper",
|
||||
value: function messageInternalWrapper(messageWrapper) {
|
||||
var innerWrapper = document.createElement('div');
|
||||
innerWrapper.setAttribute('class', 'messages__wrapper');
|
||||
|
@ -117,19 +121,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|||
var text = _ref.text;
|
||||
var type = _ref2.type,
|
||||
id = _ref2.id;
|
||||
|
||||
var messagesTypes = Drupal.Message.getMessageTypeLabels();
|
||||
var messageWrapper = document.createElement('div');
|
||||
|
||||
messageWrapper.setAttribute('class', 'messages messages--' + type);
|
||||
messageWrapper.setAttribute('class', "messages messages--".concat(type));
|
||||
messageWrapper.setAttribute('role', type === 'error' || type === 'warning' ? 'alert' : 'status');
|
||||
messageWrapper.setAttribute('data-drupal-message-id', id);
|
||||
messageWrapper.setAttribute('data-drupal-message-type', type);
|
||||
|
||||
messageWrapper.setAttribute('aria-label', messagesTypes[type]);
|
||||
|
||||
messageWrapper.innerHTML = '' + text;
|
||||
|
||||
messageWrapper.innerHTML = "".concat(text);
|
||||
return messageWrapper;
|
||||
};
|
||||
})(Drupal);
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
(function (Modernizr) {
|
||||
Modernizr.addTest('touchevents', function () {
|
||||
var bool = void 0;
|
||||
var bool;
|
||||
|
||||
if ('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch) {
|
||||
bool = true;
|
||||
|
@ -17,6 +17,7 @@
|
|||
bool = node.offsetTop === 9;
|
||||
});
|
||||
}
|
||||
|
||||
return bool;
|
||||
});
|
||||
})(Modernizr);
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
(function ($, Drupal) {
|
||||
Drupal.theme.progressBar = function (id) {
|
||||
return '<div id="' + id + '" class="progress" aria-live="polite">' + '<div class="progress__label"> </div>' + '<div class="progress__track"><div class="progress__bar"></div></div>' + '<div class="progress__percentage"></div>' + '<div class="progress__description"> </div>' + '</div>';
|
||||
return "<div id=\"".concat(id, "\" class=\"progress\" aria-live=\"polite\">") + '<div class="progress__label"> </div>' + '<div class="progress__track"><div class="progress__bar"></div></div>' + '<div class="progress__percentage"></div>' + '<div class="progress__description"> </div>' + '</div>';
|
||||
};
|
||||
|
||||
Drupal.ProgressBar = function (id, updateCallback, method, errorCallback) {
|
||||
|
@ -15,18 +15,19 @@
|
|||
this.method = method || 'GET';
|
||||
this.updateCallback = updateCallback;
|
||||
this.errorCallback = errorCallback;
|
||||
|
||||
this.element = $(Drupal.theme('progressBar', id));
|
||||
};
|
||||
|
||||
$.extend(Drupal.ProgressBar.prototype, {
|
||||
setProgress: function setProgress(percentage, message, label) {
|
||||
if (percentage >= 0 && percentage <= 100) {
|
||||
$(this.element).find('div.progress__bar').css('width', percentage + '%');
|
||||
$(this.element).find('div.progress__percentage').html(percentage + '%');
|
||||
$(this.element).find('div.progress__bar').css('width', "".concat(percentage, "%"));
|
||||
$(this.element).find('div.progress__percentage').html("".concat(percentage, "%"));
|
||||
}
|
||||
|
||||
$('div.progress__description', this.element).html(message);
|
||||
$('div.progress__label', this.element).html(label);
|
||||
|
||||
if (this.updateCallback) {
|
||||
this.updateCallback(percentage, message, this);
|
||||
}
|
||||
|
@ -38,22 +39,23 @@
|
|||
},
|
||||
stopMonitoring: function stopMonitoring() {
|
||||
clearTimeout(this.timer);
|
||||
|
||||
this.uri = null;
|
||||
},
|
||||
sendPing: function sendPing() {
|
||||
if (this.timer) {
|
||||
clearTimeout(this.timer);
|
||||
}
|
||||
|
||||
if (this.uri) {
|
||||
var pb = this;
|
||||
|
||||
var uri = this.uri;
|
||||
|
||||
if (uri.indexOf('?') === -1) {
|
||||
uri += '?';
|
||||
} else {
|
||||
uri += '&';
|
||||
}
|
||||
|
||||
uri += '_format=json';
|
||||
$.ajax({
|
||||
type: this.method,
|
||||
|
@ -67,14 +69,13 @@
|
|||
}
|
||||
|
||||
pb.setProgress(progress.percentage, progress.message, progress.label);
|
||||
|
||||
pb.timer = setTimeout(function () {
|
||||
pb.sendPing();
|
||||
}, pb.delay);
|
||||
},
|
||||
error: function error(xmlhttp) {
|
||||
var e = new Drupal.AjaxError(xmlhttp, pb.uri);
|
||||
pb.displayError('<pre>' + e.message + '</pre>');
|
||||
pb.displayError("<pre>".concat(e.message, "</pre>"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
var states = {
|
||||
postponed: []
|
||||
};
|
||||
|
||||
Drupal.states = states;
|
||||
|
||||
function invert(a, invertState) {
|
||||
|
@ -28,6 +27,7 @@
|
|||
if (typeof a === 'undefined') {
|
||||
return b;
|
||||
}
|
||||
|
||||
if (typeof b === 'undefined') {
|
||||
return a;
|
||||
}
|
||||
|
@ -64,8 +64,10 @@
|
|||
states.Dependent = function (args) {
|
||||
var _this = this;
|
||||
|
||||
$.extend(this, { values: {}, oldValue: null }, args);
|
||||
|
||||
$.extend(this, {
|
||||
values: {},
|
||||
oldValue: null
|
||||
}, args);
|
||||
this.dependees = this.getDependees();
|
||||
Object.keys(this.dependees || {}).forEach(function (selector) {
|
||||
_this.initializeDependee(selector, _this.dependees[selector]);
|
||||
|
@ -83,13 +85,11 @@
|
|||
return typeof value === 'string' ? _compare2(reference.toString(), value) : _compare2(reference, value);
|
||||
}
|
||||
};
|
||||
|
||||
states.Dependent.prototype = {
|
||||
initializeDependee: function initializeDependee(selector, dependeeStates) {
|
||||
var _this2 = this;
|
||||
|
||||
this.values[selector] = {};
|
||||
|
||||
Object.keys(dependeeStates).forEach(function (i) {
|
||||
var state = dependeeStates[i];
|
||||
|
||||
|
@ -98,18 +98,22 @@
|
|||
}
|
||||
|
||||
state = states.State.sanitize(state);
|
||||
|
||||
_this2.values[selector][state.name] = null;
|
||||
|
||||
$(selector).on('state:' + state, { selector: selector, state: state }, function (e) {
|
||||
$(selector).on("state:".concat(state), {
|
||||
selector: selector,
|
||||
state: state
|
||||
}, function (e) {
|
||||
_this2.update(e.data.selector, e.data.state, e.value);
|
||||
});
|
||||
|
||||
new states.Trigger({ selector: selector, state: state });
|
||||
new states.Trigger({
|
||||
selector: selector,
|
||||
state: state
|
||||
});
|
||||
});
|
||||
},
|
||||
compare: function compare(reference, selector, state) {
|
||||
var value = this.values[selector][state.name];
|
||||
|
||||
if (reference.constructor.name in states.Dependent.comparisons) {
|
||||
return states.Dependent.comparisons[reference.constructor.name](reference, value);
|
||||
}
|
||||
|
@ -127,21 +131,21 @@
|
|||
|
||||
if (value !== this.oldValue) {
|
||||
this.oldValue = value;
|
||||
|
||||
value = invert(value, this.state.invert);
|
||||
|
||||
this.element.trigger({
|
||||
type: 'state:' + this.state,
|
||||
type: "state:".concat(this.state),
|
||||
value: value,
|
||||
trigger: true
|
||||
});
|
||||
}
|
||||
},
|
||||
verifyConstraints: function verifyConstraints(constraints, selector) {
|
||||
var result = void 0;
|
||||
var result;
|
||||
|
||||
if ($.isArray(constraints)) {
|
||||
var hasXor = $.inArray('xor', constraints) === -1;
|
||||
var len = constraints.length;
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (constraints[i] !== 'xor') {
|
||||
var constraint = this.checkConstraints(constraints[i], selector, i);
|
||||
|
@ -149,6 +153,7 @@
|
|||
if (constraint && (hasXor || result)) {
|
||||
return hasXor;
|
||||
}
|
||||
|
||||
result = result || constraint;
|
||||
}
|
||||
}
|
||||
|
@ -163,6 +168,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
checkConstraints: function checkConstraints(value, selector, state) {
|
||||
|
@ -182,16 +188,14 @@
|
|||
},
|
||||
getDependees: function getDependees() {
|
||||
var cache = {};
|
||||
|
||||
var _compare = this.compare;
|
||||
|
||||
this.compare = function (reference, selector, state) {
|
||||
(cache[selector] || (cache[selector] = [])).push(state.name);
|
||||
};
|
||||
|
||||
this.verifyConstraints(this.constraints);
|
||||
|
||||
this.compare = _compare;
|
||||
|
||||
return cache;
|
||||
}
|
||||
};
|
||||
|
@ -202,7 +206,7 @@
|
|||
if (this.state in states.Trigger.states) {
|
||||
this.element = $(this.selector);
|
||||
|
||||
if (!this.element.data('trigger:' + this.state)) {
|
||||
if (!this.element.data("trigger:".concat(this.state))) {
|
||||
this.initialize();
|
||||
}
|
||||
}
|
||||
|
@ -222,68 +226,63 @@
|
|||
});
|
||||
}
|
||||
|
||||
this.element.data('trigger:' + this.state, true);
|
||||
this.element.data("trigger:".concat(this.state), true);
|
||||
},
|
||||
defaultTrigger: function defaultTrigger(event, valueFn) {
|
||||
var oldValue = valueFn.call(this.element);
|
||||
|
||||
this.element.on(event, $.proxy(function (e) {
|
||||
var value = valueFn.call(this.element, e);
|
||||
|
||||
if (oldValue !== value) {
|
||||
this.element.trigger({
|
||||
type: 'state:' + this.state,
|
||||
type: "state:".concat(this.state),
|
||||
value: value,
|
||||
oldValue: oldValue
|
||||
});
|
||||
oldValue = value;
|
||||
}
|
||||
}, this));
|
||||
|
||||
states.postponed.push($.proxy(function () {
|
||||
this.element.trigger({
|
||||
type: 'state:' + this.state,
|
||||
type: "state:".concat(this.state),
|
||||
value: oldValue,
|
||||
oldValue: null
|
||||
});
|
||||
}, this));
|
||||
}
|
||||
};
|
||||
|
||||
states.Trigger.states = {
|
||||
empty: {
|
||||
keyup: function keyup() {
|
||||
return this.val() === '';
|
||||
}
|
||||
},
|
||||
|
||||
checked: {
|
||||
change: function change() {
|
||||
var checked = false;
|
||||
this.each(function () {
|
||||
checked = $(this).prop('checked');
|
||||
|
||||
return !checked;
|
||||
});
|
||||
return checked;
|
||||
}
|
||||
},
|
||||
|
||||
value: {
|
||||
keyup: function keyup() {
|
||||
if (this.length > 1) {
|
||||
return this.filter(':checked').val() || false;
|
||||
}
|
||||
|
||||
return this.val();
|
||||
},
|
||||
change: function change() {
|
||||
if (this.length > 1) {
|
||||
return this.filter(':checked').val() || false;
|
||||
}
|
||||
|
||||
return this.val();
|
||||
}
|
||||
},
|
||||
|
||||
collapsed: {
|
||||
collapsed: function collapsed(e) {
|
||||
return typeof e !== 'undefined' && 'value' in e ? e.value : !this.is('[open]');
|
||||
|
@ -294,8 +293,8 @@
|
|||
states.State = function (state) {
|
||||
this.pristine = state;
|
||||
this.name = state;
|
||||
|
||||
var process = true;
|
||||
|
||||
do {
|
||||
while (this.name.charAt(0) === '!') {
|
||||
this.name = this.name.substring(1);
|
||||
|
@ -332,27 +331,26 @@
|
|||
closed: 'collapsed',
|
||||
readwrite: '!readonly'
|
||||
};
|
||||
|
||||
states.State.prototype = {
|
||||
invert: false,
|
||||
|
||||
toString: function toString() {
|
||||
return this.name;
|
||||
}
|
||||
};
|
||||
|
||||
var $document = $(document);
|
||||
$document.on('state:disabled', function (e) {
|
||||
if (e.trigger) {
|
||||
$(e.target).prop('disabled', e.value).closest('.js-form-item, .js-form-submit, .js-form-wrapper').toggleClass('form-disabled', e.value).find('select, input, textarea').prop('disabled', e.value);
|
||||
}
|
||||
});
|
||||
|
||||
$document.on('state:required', function (e) {
|
||||
if (e.trigger) {
|
||||
if (e.value) {
|
||||
var label = 'label' + (e.target.id ? '[for=' + e.target.id + ']' : '');
|
||||
var $label = $(e.target).attr({ required: 'required', 'aria-required': 'true' }).closest('.js-form-item, .js-form-wrapper').find(label);
|
||||
var label = "label".concat(e.target.id ? "[for=".concat(e.target.id, "]") : '');
|
||||
var $label = $(e.target).attr({
|
||||
required: 'required',
|
||||
'aria-required': 'true'
|
||||
}).closest('.js-form-item, .js-form-wrapper').find(label);
|
||||
|
||||
if (!$label.hasClass('js-form-required').length) {
|
||||
$label.addClass('js-form-required form-required');
|
||||
|
@ -362,19 +360,16 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
$document.on('state:visible', function (e) {
|
||||
if (e.trigger) {
|
||||
$(e.target).closest('.js-form-item, .js-form-submit, .js-form-wrapper').toggle(e.value);
|
||||
}
|
||||
});
|
||||
|
||||
$document.on('state:checked', function (e) {
|
||||
if (e.trigger) {
|
||||
$(e.target).prop('checked', e.value);
|
||||
}
|
||||
});
|
||||
|
||||
$document.on('state:collapsed', function (e) {
|
||||
if (e.trigger) {
|
||||
if ($(e.target).is('[open]') === e.value) {
|
||||
|
|
|
@ -13,13 +13,9 @@
|
|||
function TabbingContext(options) {
|
||||
$.extend(this, {
|
||||
level: null,
|
||||
|
||||
$tabbableElements: $(),
|
||||
|
||||
$disabledElements: $(),
|
||||
|
||||
released: false,
|
||||
|
||||
active: false
|
||||
}, options);
|
||||
}
|
||||
|
@ -27,27 +23,24 @@
|
|||
$.extend(TabbingManager.prototype, {
|
||||
constrain: function constrain(elements) {
|
||||
var il = this.stack.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
this.stack[i].deactivate();
|
||||
}
|
||||
|
||||
var $elements = $(elements).find(':tabbable').addBack(':tabbable');
|
||||
|
||||
var tabbingContext = new TabbingContext({
|
||||
level: this.stack.length,
|
||||
$tabbableElements: $elements
|
||||
});
|
||||
|
||||
this.stack.push(tabbingContext);
|
||||
|
||||
tabbingContext.activate();
|
||||
|
||||
$(document).trigger('drupalTabbingConstrained', tabbingContext);
|
||||
|
||||
return tabbingContext;
|
||||
},
|
||||
release: function release() {
|
||||
var toActivate = this.stack.length - 1;
|
||||
|
||||
while (toActivate >= 0 && this.stack[toActivate].released) {
|
||||
toActivate--;
|
||||
}
|
||||
|
@ -61,29 +54,28 @@
|
|||
activate: function activate(tabbingContext) {
|
||||
var $set = tabbingContext.$tabbableElements;
|
||||
var level = tabbingContext.level;
|
||||
|
||||
var $disabledSet = $(':tabbable').not($set);
|
||||
|
||||
tabbingContext.$disabledElements = $disabledSet;
|
||||
|
||||
var il = $disabledSet.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
this.recordTabindex($disabledSet.eq(i), level);
|
||||
}
|
||||
|
||||
$disabledSet.prop('tabindex', -1).prop('autofocus', false);
|
||||
|
||||
var $hasFocus = $set.filter('[autofocus]').eq(-1);
|
||||
|
||||
if ($hasFocus.length === 0) {
|
||||
$hasFocus = $set.eq(0);
|
||||
}
|
||||
|
||||
$hasFocus.trigger('focus');
|
||||
},
|
||||
deactivate: function deactivate(tabbingContext) {
|
||||
var $set = tabbingContext.$disabledElements;
|
||||
var level = tabbingContext.level;
|
||||
var il = $set.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
this.restoreTabindex($set.eq(i), level);
|
||||
}
|
||||
|
@ -98,13 +90,16 @@
|
|||
},
|
||||
restoreTabindex: function restoreTabindex($el, level) {
|
||||
var tabInfo = $el.data('drupalOriginalTabIndices');
|
||||
|
||||
if (tabInfo && tabInfo[level]) {
|
||||
var data = tabInfo[level];
|
||||
|
||||
if (data.tabindex) {
|
||||
$el[0].setAttribute('tabindex', data.tabindex);
|
||||
} else {
|
||||
$el[0].removeAttribute('tabindex');
|
||||
}
|
||||
|
||||
if (data.autofocus) {
|
||||
$el[0].setAttribute('autofocus', 'autofocus');
|
||||
}
|
||||
|
@ -113,23 +108,23 @@
|
|||
$el.removeData('drupalOriginalTabIndices');
|
||||
} else {
|
||||
var levelToDelete = level;
|
||||
|
||||
while (tabInfo.hasOwnProperty(levelToDelete)) {
|
||||
delete tabInfo[levelToDelete];
|
||||
levelToDelete++;
|
||||
}
|
||||
|
||||
$el.data('drupalOriginalTabIndices', tabInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.extend(TabbingContext.prototype, {
|
||||
release: function release() {
|
||||
if (!this.released) {
|
||||
this.deactivate();
|
||||
this.released = true;
|
||||
Drupal.tabbingManager.release(this);
|
||||
|
||||
$(document).trigger('drupalTabbingContextReleased', this);
|
||||
}
|
||||
},
|
||||
|
@ -137,7 +132,6 @@
|
|||
if (!this.active && !this.released) {
|
||||
this.active = true;
|
||||
Drupal.tabbingManager.activate(this);
|
||||
|
||||
$(document).trigger('drupalTabbingContextActivated', this);
|
||||
}
|
||||
},
|
||||
|
@ -145,7 +139,6 @@
|
|||
if (this.active) {
|
||||
this.active = false;
|
||||
Drupal.tabbingManager.deactivate(this);
|
||||
|
||||
$(document).trigger('drupalTabbingContextDeactivated', this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -405,7 +405,7 @@
|
|||
$tables.find('.tabledrag-handle').css('display', '');
|
||||
// Reduce the colspan of any effected multi-span columns.
|
||||
$tables.find('.tabledrag-has-colspan').each(function() {
|
||||
this.colSpan = this.colSpan - 1;
|
||||
this.colSpan -= 1;
|
||||
});
|
||||
// Change link text.
|
||||
$('.tabledrag-toggle-weight').text(Drupal.t('Show row weights'));
|
||||
|
@ -424,7 +424,7 @@
|
|||
$tables.find('.tabledrag-handle').css('display', 'none');
|
||||
// Increase the colspan for any columns where it was previously reduced.
|
||||
$tables.find('.tabledrag-has-colspan').each(function() {
|
||||
this.colSpan = this.colSpan + 1;
|
||||
this.colSpan += 1;
|
||||
});
|
||||
// Change link text.
|
||||
$('.tabledrag-toggle-weight').text(Drupal.t('Hide row weights'));
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
var showWeight = JSON.parse(localStorage.getItem('Drupal.tableDrag.showWeight'));
|
||||
|
||||
Drupal.behaviors.tableDrag = {
|
||||
attach: function attach(context, settings) {
|
||||
function initTableDrag(table, base) {
|
||||
|
@ -18,7 +18,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
}
|
||||
|
||||
Object.keys(settings.tableDrag || {}).forEach(function (base) {
|
||||
initTableDrag($(context).find('#' + base).once('tabledrag'), base);
|
||||
initTableDrag($(context).find("#".concat(base)).once('tabledrag'), base);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -28,56 +28,44 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
var self = this;
|
||||
var $table = $(table);
|
||||
|
||||
this.$table = $(table);
|
||||
|
||||
this.table = table;
|
||||
|
||||
this.tableSettings = tableSettings;
|
||||
|
||||
this.dragObject = null;
|
||||
|
||||
this.rowObject = null;
|
||||
|
||||
this.oldRowElement = null;
|
||||
|
||||
this.oldY = null;
|
||||
|
||||
this.changed = false;
|
||||
|
||||
this.maxDepth = 0;
|
||||
|
||||
this.rtl = $(this.table).css('direction') === 'rtl' ? -1 : 1;
|
||||
|
||||
this.striping = $(this.table).data('striping') === 1;
|
||||
|
||||
this.scrollSettings = { amount: 4, interval: 50, trigger: 70 };
|
||||
|
||||
this.scrollSettings = {
|
||||
amount: 4,
|
||||
interval: 50,
|
||||
trigger: 70
|
||||
};
|
||||
this.scrollInterval = null;
|
||||
|
||||
this.scrollY = 0;
|
||||
|
||||
this.windowHeight = 0;
|
||||
|
||||
this.indentEnabled = false;
|
||||
Object.keys(tableSettings || {}).forEach(function (group) {
|
||||
Object.keys(tableSettings[group] || {}).forEach(function (n) {
|
||||
if (tableSettings[group][n].relationship === 'parent') {
|
||||
_this.indentEnabled = true;
|
||||
}
|
||||
|
||||
if (tableSettings[group][n].limit > 0) {
|
||||
_this.maxDepth = tableSettings[group][n].limit;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (this.indentEnabled) {
|
||||
this.indentCount = 1;
|
||||
|
||||
var indent = Drupal.theme('tableDragIndentation');
|
||||
var testRow = $('<tr/>').addClass('draggable').appendTo(table);
|
||||
var testCell = $('<td/>').appendTo(testRow).prepend(indent).prepend(indent);
|
||||
var $indentation = testCell.find('.js-indentation');
|
||||
|
||||
this.indentAmount = $indentation.get(1).offsetLeft - $indentation.get(0).offsetLeft;
|
||||
testRow.remove();
|
||||
}
|
||||
|
@ -85,14 +73,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
$table.find('> tr.draggable, > tbody > tr.draggable').each(function () {
|
||||
self.makeDraggable(this);
|
||||
});
|
||||
|
||||
$table.before($('<button type="button" class="link tabledrag-toggle-weight"></button>').on('click', $.proxy(function (e) {
|
||||
e.preventDefault();
|
||||
this.toggleColumns();
|
||||
}, this)).wrap('<div class="tabledrag-toggle-weight-wrapper"></div>').parent());
|
||||
|
||||
self.initColumns();
|
||||
|
||||
$(document).on('touchmove', function (event) {
|
||||
return self.dragRow(event.originalEvent.touches[0], self);
|
||||
});
|
||||
|
@ -105,7 +90,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
$(document).on('mouseup pointerup', function (event) {
|
||||
return self.dropRow(event, self);
|
||||
});
|
||||
|
||||
$(window).on('storage', $.proxy(function (e) {
|
||||
if (e.originalEvent.key === 'Drupal.tableDrag.showWeight') {
|
||||
showWeight = JSON.parse(e.originalEvent.newValue);
|
||||
|
@ -118,17 +102,19 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
var _this2 = this;
|
||||
|
||||
var $table = this.$table;
|
||||
var hidden = void 0;
|
||||
var cell = void 0;
|
||||
var columnIndex = void 0;
|
||||
var hidden;
|
||||
var cell;
|
||||
var columnIndex;
|
||||
Object.keys(this.tableSettings || {}).forEach(function (group) {
|
||||
Object.keys(_this2.tableSettings[group]).some(function (tableSetting) {
|
||||
var field = $table.find('.' + _this2.tableSettings[group][tableSetting].target).eq(0);
|
||||
var field = $table.find(".".concat(_this2.tableSettings[group][tableSetting].target)).eq(0);
|
||||
|
||||
if (field.length && _this2.tableSettings[group][tableSetting].hidden) {
|
||||
hidden = _this2.tableSettings[group][tableSetting].hidden;
|
||||
cell = field.closest('td');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
@ -145,14 +131,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
var $row = $(this);
|
||||
var index = columnIndex;
|
||||
var cells = $row.children();
|
||||
var cell = void 0;
|
||||
var cell;
|
||||
cells.each(function (n) {
|
||||
if (n < index && this.colSpan && this.colSpan > 1) {
|
||||
index -= this.colSpan - 1;
|
||||
}
|
||||
});
|
||||
|
||||
if (index > 0) {
|
||||
cell = cells.filter(':nth-child(' + index + ')');
|
||||
cell = cells.filter(":nth-child(".concat(index, ")"));
|
||||
|
||||
if (cell[0].colSpan && cell[0].colSpan > 1) {
|
||||
cell.addClass('tabledrag-has-colspan');
|
||||
} else {
|
||||
|
@ -175,6 +163,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
Drupal.tableDrag.prototype.toggleColumns = function () {
|
||||
showWeight = !showWeight;
|
||||
this.displayColumns(showWeight);
|
||||
|
||||
if (showWeight) {
|
||||
localStorage.setItem('Drupal.tableDrag.showWeight', showWeight);
|
||||
} else {
|
||||
|
@ -184,44 +173,38 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
Drupal.tableDrag.prototype.hideColumns = function () {
|
||||
var $tables = $('table').findOnce('tabledrag');
|
||||
|
||||
$tables.find('.tabledrag-hide').css('display', 'none');
|
||||
|
||||
$tables.find('.tabledrag-handle').css('display', '');
|
||||
|
||||
$tables.find('.tabledrag-has-colspan').each(function () {
|
||||
this.colSpan = this.colSpan - 1;
|
||||
this.colSpan -= 1;
|
||||
});
|
||||
|
||||
$('.tabledrag-toggle-weight').text(Drupal.t('Show row weights'));
|
||||
};
|
||||
|
||||
Drupal.tableDrag.prototype.showColumns = function () {
|
||||
var $tables = $('table').findOnce('tabledrag');
|
||||
|
||||
$tables.find('.tabledrag-hide').css('display', '');
|
||||
|
||||
$tables.find('.tabledrag-handle').css('display', 'none');
|
||||
|
||||
$tables.find('.tabledrag-has-colspan').each(function () {
|
||||
this.colSpan = this.colSpan + 1;
|
||||
this.colSpan += 1;
|
||||
});
|
||||
|
||||
$('.tabledrag-toggle-weight').text(Drupal.t('Hide row weights'));
|
||||
};
|
||||
|
||||
Drupal.tableDrag.prototype.rowSettings = function (group, row) {
|
||||
var field = $(row).find('.' + group);
|
||||
var field = $(row).find(".".concat(group));
|
||||
var tableSettingsGroup = this.tableSettings[group];
|
||||
return Object.keys(tableSettingsGroup).map(function (delta) {
|
||||
var targetClass = tableSettingsGroup[delta].target;
|
||||
var rowSettings = void 0;
|
||||
if (field.is('.' + targetClass)) {
|
||||
var rowSettings;
|
||||
|
||||
if (field.is(".".concat(targetClass))) {
|
||||
rowSettings = {};
|
||||
Object.keys(tableSettingsGroup[delta]).forEach(function (n) {
|
||||
rowSettings[n] = tableSettingsGroup[delta][n];
|
||||
});
|
||||
}
|
||||
|
||||
return rowSettings;
|
||||
}).filter(function (rowSetting) {
|
||||
return rowSetting;
|
||||
|
@ -231,15 +214,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
Drupal.tableDrag.prototype.makeDraggable = function (item) {
|
||||
var self = this;
|
||||
var $item = $(item);
|
||||
|
||||
$item.find('td:first-of-type').find('a').addClass('menu-item__link');
|
||||
|
||||
var handle = $('<a href="#" class="tabledrag-handle"><div class="handle"> </div></a>').attr('title', Drupal.t('Drag to re-order'));
|
||||
|
||||
var $indentationLast = $item.find('td:first-of-type').find('.js-indentation').eq(-1);
|
||||
|
||||
if ($indentationLast.length) {
|
||||
$indentationLast.after(handle);
|
||||
|
||||
self.indentCount = Math.max($item.find('.js-indentation').length, self.indentCount);
|
||||
} else {
|
||||
$item.find('td').eq(0).prepend(handle);
|
||||
|
@ -247,33 +227,31 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
handle.on('mousedown touchstart pointerdown', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
if (event.originalEvent.type === 'touchstart') {
|
||||
event = event.originalEvent.touches[0];
|
||||
}
|
||||
|
||||
self.dragStart(event, self, item);
|
||||
});
|
||||
|
||||
handle.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
handle.on('focus', function () {
|
||||
self.safeBlur = true;
|
||||
});
|
||||
|
||||
handle.on('blur', function (event) {
|
||||
if (self.rowObject && self.safeBlur) {
|
||||
self.dropRow(event, self);
|
||||
}
|
||||
});
|
||||
|
||||
handle.on('keydown', function (event) {
|
||||
if (event.keyCode !== 9 && !self.rowObject) {
|
||||
self.rowObject = new self.row(item, 'keyboard', self.indentEnabled, self.maxDepth, true);
|
||||
}
|
||||
|
||||
var keyChange = false;
|
||||
var groupHeight = void 0;
|
||||
var groupHeight;
|
||||
|
||||
switch (event.keyCode) {
|
||||
case 37:
|
||||
|
@ -287,10 +265,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
{
|
||||
var $previousRow = $(self.rowObject.element).prev('tr').eq(0);
|
||||
var previousRow = $previousRow.get(0);
|
||||
|
||||
while (previousRow && $previousRow.is(':hidden')) {
|
||||
$previousRow = $(previousRow).prev('tr').eq(0);
|
||||
previousRow = $previousRow.get(0);
|
||||
}
|
||||
|
||||
if (previousRow) {
|
||||
self.safeBlur = false;
|
||||
self.rowObject.direction = 'up';
|
||||
|
@ -298,14 +278,15 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
if ($(item).is('.tabledrag-root')) {
|
||||
groupHeight = 0;
|
||||
|
||||
while (previousRow && $previousRow.find('.js-indentation').length) {
|
||||
$previousRow = $(previousRow).prev('tr').eq(0);
|
||||
previousRow = $previousRow.get(0);
|
||||
groupHeight += $previousRow.is(':hidden') ? 0 : previousRow.offsetHeight;
|
||||
}
|
||||
|
||||
if (previousRow) {
|
||||
self.rowObject.swap('before', previousRow);
|
||||
|
||||
window.scrollBy(0, -groupHeight);
|
||||
}
|
||||
} else if (self.table.tBodies[0].rows[0] !== previousRow || $previousRow.is('.draggable')) {
|
||||
|
@ -317,6 +298,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
handle.trigger('focus');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -331,10 +313,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
{
|
||||
var $nextRow = $(self.rowObject.group).eq(-1).next('tr').eq(0);
|
||||
var nextRow = $nextRow.get(0);
|
||||
|
||||
while (nextRow && $nextRow.is(':hidden')) {
|
||||
$nextRow = $(nextRow).next('tr').eq(0);
|
||||
nextRow = $nextRow.get(0);
|
||||
}
|
||||
|
||||
if (nextRow) {
|
||||
self.safeBlur = false;
|
||||
self.rowObject.direction = 'down';
|
||||
|
@ -343,13 +327,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
if ($(item).is('.tabledrag-root')) {
|
||||
groupHeight = 0;
|
||||
var nextGroup = new self.row(nextRow, 'keyboard', self.indentEnabled, self.maxDepth, false);
|
||||
|
||||
if (nextGroup) {
|
||||
$(nextGroup.group).each(function () {
|
||||
groupHeight += $(this).is(':hidden') ? 0 : this.offsetHeight;
|
||||
});
|
||||
var nextGroupRow = $(nextGroup.group).eq(-1).get(0);
|
||||
self.rowObject.swap('after', nextGroupRow);
|
||||
|
||||
window.scrollBy(0, parseInt(groupHeight, 10));
|
||||
}
|
||||
} else {
|
||||
|
@ -361,19 +345,24 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
handle.trigger('focus');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (self.rowObject && self.rowObject.changed === true) {
|
||||
$(item).addClass('drag');
|
||||
|
||||
if (self.oldRowElement) {
|
||||
$(self.oldRowElement).removeClass('drag-previous');
|
||||
}
|
||||
|
||||
self.oldRowElement = item;
|
||||
|
||||
if (self.striping === true) {
|
||||
self.restripeTable();
|
||||
}
|
||||
|
||||
self.onDrag();
|
||||
}
|
||||
|
||||
|
@ -381,9 +370,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
handle.on('keypress', function (event) {
|
||||
|
||||
switch (event.keyCode) {
|
||||
case 37:
|
||||
case 38:
|
||||
|
@ -398,6 +385,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
self.dragObject = {};
|
||||
self.dragObject.initOffset = self.getPointerOffset(item, event);
|
||||
self.dragObject.initPointerCoords = self.pointerCoords(event);
|
||||
|
||||
if (self.indentEnabled) {
|
||||
self.dragObject.indentPointerPos = self.dragObject.initPointerCoords;
|
||||
}
|
||||
|
@ -407,13 +395,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
}
|
||||
|
||||
self.rowObject = new self.row(item, 'pointer', self.indentEnabled, self.maxDepth, true);
|
||||
|
||||
self.table.topY = $(self.table).offset().top;
|
||||
self.table.bottomY = self.table.topY + self.table.offsetHeight;
|
||||
|
||||
$(item).addClass('drag');
|
||||
|
||||
$('body').addClass('drag');
|
||||
|
||||
if (self.oldRowElement) {
|
||||
$(self.oldRowElement).removeClass('drag-previous');
|
||||
}
|
||||
|
@ -429,11 +415,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
if (y !== self.oldY) {
|
||||
self.rowObject.direction = y > self.oldY ? 'down' : 'up';
|
||||
|
||||
self.oldY = y;
|
||||
|
||||
var scrollAmount = self.checkScroll(self.currentPointerCoords.y);
|
||||
|
||||
clearInterval(self.scrollInterval);
|
||||
|
||||
if (scrollAmount > 0 && self.rowObject.direction === 'down' || scrollAmount < 0 && self.rowObject.direction === 'up') {
|
||||
|
@ -441,12 +424,14 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
}
|
||||
|
||||
var currentRow = self.findDropTargetRow(x, y);
|
||||
|
||||
if (currentRow) {
|
||||
if (self.rowObject.direction === 'down') {
|
||||
self.rowObject.swap('after', currentRow, self);
|
||||
} else {
|
||||
self.rowObject.swap('before', currentRow, self);
|
||||
}
|
||||
|
||||
if (self.striping === true) {
|
||||
self.restripeTable();
|
||||
}
|
||||
|
@ -455,11 +440,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
if (self.indentEnabled) {
|
||||
var xDiff = self.currentPointerCoords.x - self.dragObject.indentPointerPos.x;
|
||||
|
||||
var indentDiff = Math.round(xDiff / self.indentAmount);
|
||||
|
||||
var indentChange = self.rowObject.indent(indentDiff);
|
||||
|
||||
self.dragObject.indentPointerPos.x += self.indentAmount * indentChange * self.rtl;
|
||||
self.indentCount = Math.max(self.indentCount, self.rowObject.indents);
|
||||
}
|
||||
|
@ -469,8 +451,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
};
|
||||
|
||||
Drupal.tableDrag.prototype.dropRow = function (event, self) {
|
||||
var droppedRow = void 0;
|
||||
var $droppedRow = void 0;
|
||||
var droppedRow;
|
||||
var $droppedRow;
|
||||
|
||||
if (self.rowObject !== null) {
|
||||
droppedRow = self.rowObject.element;
|
||||
|
@ -478,17 +460,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
if (self.rowObject.changed === true) {
|
||||
self.updateFields(droppedRow);
|
||||
|
||||
Object.keys(self.tableSettings || {}).forEach(function (group) {
|
||||
var rowSettings = self.rowSettings(group, droppedRow);
|
||||
|
||||
if (rowSettings.relationship === 'group') {
|
||||
Object.keys(self.rowObject.children || {}).forEach(function (n) {
|
||||
self.updateField(self.rowObject.children[n], group);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
self.rowObject.markChanged();
|
||||
|
||||
if (self.changed === false) {
|
||||
$(Drupal.theme('tableDragChangedWarning')).insertBefore(self.table).hide().fadeIn('slow');
|
||||
self.changed = true;
|
||||
|
@ -498,9 +480,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
if (self.indentEnabled) {
|
||||
self.rowObject.removeIndentClasses();
|
||||
}
|
||||
|
||||
if (self.oldRowElement) {
|
||||
$(self.oldRowElement).removeClass('drag-previous');
|
||||
}
|
||||
|
||||
$droppedRow.removeClass('drag').addClass('drag-previous');
|
||||
self.oldRowElement = droppedRow;
|
||||
self.onDrop();
|
||||
|
@ -516,8 +500,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
Drupal.tableDrag.prototype.pointerCoords = function (event) {
|
||||
if (event.pageX || event.pageY) {
|
||||
return { x: event.pageX, y: event.pageY };
|
||||
return {
|
||||
x: event.pageX,
|
||||
y: event.pageY
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
x: event.clientX + document.body.scrollLeft - document.body.clientLeft,
|
||||
y: event.clientY + document.body.scrollTop - document.body.clientTop
|
||||
|
@ -527,7 +515,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
Drupal.tableDrag.prototype.getPointerOffset = function (target, event) {
|
||||
var docPos = $(target).offset();
|
||||
var pointerPos = this.pointerCoords(event);
|
||||
return { x: pointerPos.x - docPos.left, y: pointerPos.y - docPos.top };
|
||||
return {
|
||||
x: pointerPos.x - docPos.left,
|
||||
y: pointerPos.y - docPos.top
|
||||
};
|
||||
};
|
||||
|
||||
Drupal.tableDrag.prototype.findDropTargetRow = function (x, y) {
|
||||
|
@ -572,6 +563,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
$row = $row.prev('tr:first-of-type');
|
||||
row = $row.get(0);
|
||||
}
|
||||
|
||||
return {
|
||||
v: row
|
||||
};
|
||||
|
@ -581,8 +573,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
for (var n = 0; n < rows.length; n++) {
|
||||
var _ret = _loop(n);
|
||||
|
||||
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
|
||||
if (_typeof(_ret) === "object") return _ret.v;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
|
@ -597,10 +590,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
|
||||
var rowSettings = this.rowSettings(group, changedRow);
|
||||
var $changedRow = $(changedRow);
|
||||
var sourceRow = void 0;
|
||||
var $previousRow = void 0;
|
||||
var previousRow = void 0;
|
||||
var useSibling = void 0;
|
||||
var sourceRow;
|
||||
var $previousRow;
|
||||
var previousRow;
|
||||
var useSibling;
|
||||
|
||||
if (rowSettings.relationship === 'self' || rowSettings.relationship === 'group') {
|
||||
sourceRow = changedRow;
|
||||
|
@ -610,7 +603,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
var $nextRow = $changedRow.next('tr:first-of-type');
|
||||
var nextRow = $nextRow.get(0);
|
||||
sourceRow = changedRow;
|
||||
if ($previousRow.is('.draggable') && $previousRow.find('.' + group).length) {
|
||||
|
||||
if ($previousRow.is('.draggable') && $previousRow.find(".".concat(group)).length) {
|
||||
if (this.indentEnabled) {
|
||||
if ($previousRow.find('.js-indentations').length === $changedRow.find('.js-indentations').length) {
|
||||
sourceRow = previousRow;
|
||||
|
@ -618,7 +612,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
} else {
|
||||
sourceRow = previousRow;
|
||||
}
|
||||
} else if ($nextRow.is('.draggable') && $nextRow.find('.' + group).length) {
|
||||
} else if ($nextRow.is('.draggable') && $nextRow.find(".".concat(group)).length) {
|
||||
if (this.indentEnabled) {
|
||||
if ($nextRow.find('.js-indentations').length === $changedRow.find('.js-indentations').length) {
|
||||
sourceRow = nextRow;
|
||||
|
@ -630,6 +624,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
} else if (rowSettings.relationship === 'parent') {
|
||||
$previousRow = $changedRow.prev('tr');
|
||||
previousRow = $previousRow;
|
||||
|
||||
while ($previousRow.length && $previousRow.find('.js-indentation').length >= this.rowObject.indents) {
|
||||
$previousRow = $previousRow.prev('tr');
|
||||
previousRow = $previousRow;
|
||||
|
@ -639,9 +634,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
sourceRow = $previousRow.get(0);
|
||||
} else {
|
||||
sourceRow = $(this.table).find('tr.draggable:first-of-type').get(0);
|
||||
|
||||
if (sourceRow === this.rowObject.element) {
|
||||
sourceRow = $(this.rowObject.group[this.rowObject.group.length - 1]).next('tr.draggable').get(0);
|
||||
}
|
||||
|
||||
useSibling = true;
|
||||
}
|
||||
}
|
||||
|
@ -654,12 +651,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
rowSettings.source = rowSettings.target;
|
||||
}
|
||||
|
||||
var targetClass = '.' + rowSettings.target;
|
||||
var targetClass = ".".concat(rowSettings.target);
|
||||
var targetElement = $changedRow.find(targetClass).get(0);
|
||||
|
||||
if (targetElement) {
|
||||
var sourceClass = '.' + rowSettings.source;
|
||||
var sourceClass = ".".concat(rowSettings.source);
|
||||
var sourceElement = $(sourceClass, sourceRow).get(0);
|
||||
|
||||
switch (rowSettings.action) {
|
||||
case 'depth':
|
||||
targetElement.value = $(sourceElement).closest('tr').find('.js-indentation').length;
|
||||
|
@ -672,13 +670,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
case 'order':
|
||||
{
|
||||
var siblings = this.rowObject.findSiblings(rowSettings);
|
||||
|
||||
if ($(targetElement).is('select')) {
|
||||
var values = [];
|
||||
$(targetElement).find('option').each(function () {
|
||||
values.push(this.value);
|
||||
});
|
||||
var maxVal = values[values.length - 1];
|
||||
|
||||
$(siblings).find(targetClass).each(function () {
|
||||
if (values.length > 0) {
|
||||
this.value = values.shift();
|
||||
|
@ -693,6 +691,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
weight++;
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -700,8 +699,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
};
|
||||
|
||||
Drupal.tableDrag.prototype.copyDragClasses = function (sourceRow, targetRow, group) {
|
||||
var sourceElement = $(sourceRow).find('.' + group);
|
||||
var targetElement = $(targetRow).find('.' + group);
|
||||
var sourceElement = $(sourceRow).find(".".concat(group));
|
||||
var targetElement = $(targetRow).find(".".concat(group));
|
||||
|
||||
if (sourceElement.length && targetElement.length) {
|
||||
targetElement[0].className = sourceElement[0].className;
|
||||
}
|
||||
|
@ -710,15 +710,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
Drupal.tableDrag.prototype.checkScroll = function (cursorY) {
|
||||
var de = document.documentElement;
|
||||
var b = document.body;
|
||||
|
||||
var windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
|
||||
this.windowHeight = windowHeight;
|
||||
var scrollY = void 0;
|
||||
var scrollY;
|
||||
|
||||
if (document.all) {
|
||||
scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
|
||||
} else {
|
||||
scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
|
||||
}
|
||||
|
||||
this.scrollY = scrollY;
|
||||
var trigger = this.scrollSettings.trigger;
|
||||
var delta = 0;
|
||||
|
@ -728,6 +729,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
delta = delta > 0 && delta < trigger ? delta : trigger;
|
||||
return delta * this.scrollSettings.amount;
|
||||
}
|
||||
|
||||
if (cursorY - scrollY < trigger) {
|
||||
delta = trigger / (cursorY - scrollY);
|
||||
delta = delta > 0 && delta < trigger ? delta : trigger;
|
||||
|
@ -737,11 +739,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
Drupal.tableDrag.prototype.setScroll = function (scrollAmount) {
|
||||
var self = this;
|
||||
|
||||
this.scrollInterval = setInterval(function () {
|
||||
self.checkScroll(self.currentPointerCoords.y);
|
||||
var aboveTable = self.scrollY > self.table.topY;
|
||||
var belowTable = self.scrollY + self.windowHeight < self.table.bottomY;
|
||||
|
||||
if (scrollAmount > 0 && belowTable || scrollAmount < 0 && aboveTable) {
|
||||
window.scrollBy(0, scrollAmount);
|
||||
}
|
||||
|
@ -762,7 +764,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
Drupal.tableDrag.prototype.row = function (tableRow, method, indentEnabled, maxDepth, addClasses) {
|
||||
var $tableRow = $(tableRow);
|
||||
|
||||
this.element = tableRow;
|
||||
this.method = method;
|
||||
this.group = [tableRow];
|
||||
|
@ -771,8 +772,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
this.table = $tableRow.closest('table')[0];
|
||||
this.indentEnabled = indentEnabled;
|
||||
this.maxDepth = maxDepth;
|
||||
|
||||
this.direction = '';
|
||||
|
||||
if (this.indentEnabled) {
|
||||
this.indents = $tableRow.find('.js-indentation').length;
|
||||
this.children = this.findChildren(addClasses);
|
||||
|
@ -792,9 +793,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
function rowIndentation(indentNum, el) {
|
||||
var self = $(el);
|
||||
|
||||
if (child === 1 && indentNum === parentIndentation) {
|
||||
self.addClass('tree-child-first');
|
||||
}
|
||||
|
||||
if (indentNum === parentIndentation) {
|
||||
self.addClass('tree-child');
|
||||
} else if (indentNum > parentIndentation) {
|
||||
|
@ -806,25 +809,31 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
if (currentRow.find('.js-indentation').length > parentIndentation) {
|
||||
child++;
|
||||
rows.push(currentRow[0]);
|
||||
|
||||
if (addClasses) {
|
||||
currentRow.find('.js-indentation').each(rowIndentation);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
currentRow = currentRow.next('tr.draggable');
|
||||
}
|
||||
|
||||
if (addClasses && rows.length) {
|
||||
$(rows[rows.length - 1]).find('.js-indentation:nth-child(' + (parentIndentation + 1) + ')').addClass('tree-child-last');
|
||||
$(rows[rows.length - 1]).find(".js-indentation:nth-child(".concat(parentIndentation + 1, ")")).addClass('tree-child-last');
|
||||
}
|
||||
|
||||
return rows;
|
||||
};
|
||||
|
||||
Drupal.tableDrag.prototype.row.prototype.isValidSwap = function (row) {
|
||||
var $row = $(row);
|
||||
|
||||
if (this.indentEnabled) {
|
||||
var prevRow = void 0;
|
||||
var nextRow = void 0;
|
||||
var prevRow;
|
||||
var nextRow;
|
||||
|
||||
if (this.direction === 'down') {
|
||||
prevRow = row;
|
||||
nextRow = $row.next('tr').get(0);
|
||||
|
@ -832,6 +841,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
prevRow = $row.prev('tr').get(0);
|
||||
nextRow = row;
|
||||
}
|
||||
|
||||
this.interval = this.validIndentInterval(prevRow, nextRow);
|
||||
|
||||
if (this.interval.min > this.interval.max) {
|
||||
|
@ -851,7 +861,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
Drupal.detachBehaviors(row, drupalSettings, 'move');
|
||||
});
|
||||
$(row)[position](this.group);
|
||||
|
||||
this.group.forEach(function (row) {
|
||||
Drupal.attachBehaviors(row, drupalSettings);
|
||||
});
|
||||
|
@ -861,8 +870,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow, nextRow) {
|
||||
var $prevRow = $(prevRow);
|
||||
var maxIndent = void 0;
|
||||
|
||||
var maxIndent;
|
||||
var minIndent = nextRow ? $(nextRow).find('.js-indentation').length : 0;
|
||||
|
||||
if (!prevRow || $prevRow.is(':not(.draggable)') || $(this.element).is('.tabledrag-root')) {
|
||||
|
@ -875,7 +883,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
}
|
||||
}
|
||||
|
||||
return { min: minIndent, max: maxIndent };
|
||||
return {
|
||||
min: minIndent,
|
||||
max: maxIndent
|
||||
};
|
||||
};
|
||||
|
||||
Drupal.tableDrag.prototype.row.prototype.indent = function (indentDiff) {
|
||||
|
@ -901,6 +912,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
this.indents++;
|
||||
}
|
||||
}
|
||||
|
||||
if (indentDiff) {
|
||||
this.changed = true;
|
||||
this.groupDepth += indentDiff;
|
||||
|
@ -914,11 +926,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
var siblings = [];
|
||||
var directions = ['prev', 'next'];
|
||||
var rowIndentation = this.indents;
|
||||
var checkRowIndentation = void 0;
|
||||
var checkRowIndentation;
|
||||
|
||||
for (var d = 0; d < directions.length; d++) {
|
||||
var checkRow = $(this.element)[directions[d]]();
|
||||
|
||||
while (checkRow.length) {
|
||||
if (checkRow.find('.' + rowSettings.target)) {
|
||||
if (checkRow.find(".".concat(rowSettings.target))) {
|
||||
if (this.indentEnabled) {
|
||||
checkRowIndentation = checkRow.find('.js-indentation').length;
|
||||
}
|
||||
|
@ -931,6 +945,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
checkRow = checkRow[directions[d]]();
|
||||
}
|
||||
|
||||
|
@ -939,6 +954,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
siblings.push(this.element);
|
||||
}
|
||||
}
|
||||
|
||||
return siblings;
|
||||
};
|
||||
|
||||
|
@ -953,6 +969,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
Drupal.tableDrag.prototype.row.prototype.markChanged = function () {
|
||||
var marker = Drupal.theme('tableDragChangedMarker');
|
||||
var cell = $(this.element).find('td:first-of-type');
|
||||
|
||||
if (cell.find('abbr.tabledrag-changed').length === 0) {
|
||||
cell.append(marker);
|
||||
}
|
||||
|
@ -968,13 +985,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
|
||||
$.extend(Drupal.theme, {
|
||||
tableDragChangedMarker: function tableDragChangedMarker() {
|
||||
return '<abbr class="warning tabledrag-changed" title="' + Drupal.t('Changed') + '">*</abbr>';
|
||||
return "<abbr class=\"warning tabledrag-changed\" title=\"".concat(Drupal.t('Changed'), "\">*</abbr>");
|
||||
},
|
||||
tableDragIndentation: function tableDragIndentation() {
|
||||
return '<div class="js-indentation indentation"> </div>';
|
||||
},
|
||||
tableDragChangedWarning: function tableDragChangedWarning() {
|
||||
return '<div class="tabledrag-changed-warning messages messages--warning" role="alert">' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t('You have unsaved changes.') + '</div>';
|
||||
return "<div class=\"tabledrag-changed-warning messages messages--warning\" role=\"alert\">".concat(Drupal.theme('tableDragChangedMarker'), " ").concat(Drupal.t('You have unsaved changes.'), "</div>");
|
||||
}
|
||||
});
|
||||
})(jQuery, Drupal, drupalSettings);
|
|
@ -8,32 +8,31 @@
|
|||
(function ($, Drupal, displace) {
|
||||
function TableHeader(table) {
|
||||
var $table = $(table);
|
||||
|
||||
this.$originalTable = $table;
|
||||
|
||||
this.$originalHeader = $table.children('thead');
|
||||
|
||||
this.$originalHeaderCells = this.$originalHeader.find('> tr > th');
|
||||
|
||||
this.displayWeight = null;
|
||||
this.$originalTable.addClass('sticky-table');
|
||||
this.tableHeight = $table[0].clientHeight;
|
||||
this.tableOffset = this.$originalTable.offset();
|
||||
|
||||
this.$originalTable.on('columnschange', { tableHeader: this }, function (e, display) {
|
||||
this.$originalTable.on('columnschange', {
|
||||
tableHeader: this
|
||||
}, function (e, display) {
|
||||
var tableHeader = e.data.tableHeader;
|
||||
|
||||
if (tableHeader.displayWeight === null || tableHeader.displayWeight !== display) {
|
||||
tableHeader.recalculateSticky();
|
||||
}
|
||||
|
||||
tableHeader.displayWeight = display;
|
||||
});
|
||||
|
||||
this.createSticky();
|
||||
}
|
||||
|
||||
function forTables(method, arg) {
|
||||
var tables = TableHeader.tables;
|
||||
var il = tables.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
tables[i][method](arg);
|
||||
}
|
||||
|
@ -42,15 +41,19 @@
|
|||
function tableHeaderInitHandler(e) {
|
||||
var $tables = $(e.data.context).find('table.sticky-enabled').once('tableheader');
|
||||
var il = $tables.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
TableHeader.tables.push(new TableHeader($tables[i]));
|
||||
}
|
||||
|
||||
forTables('onScroll');
|
||||
}
|
||||
|
||||
Drupal.behaviors.tableHeader = {
|
||||
attach: function attach(context) {
|
||||
$(window).one('scroll.TableHeaderInit', { context: context }, tableHeaderInitHandler);
|
||||
$(window).one('scroll.TableHeaderInit', {
|
||||
context: context
|
||||
}, tableHeaderInitHandler);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -72,50 +75,41 @@
|
|||
|
||||
$(window).on({
|
||||
'resize.TableHeader': tableHeaderResizeHandler,
|
||||
|
||||
'scroll.TableHeader': tableHeaderOnScrollHandler
|
||||
});
|
||||
|
||||
$(document).on({
|
||||
'columnschange.TableHeader': tableHeaderResizeHandler,
|
||||
|
||||
'drupalViewportOffsetChange.TableHeader': tableHeaderOffsetChangeHandler
|
||||
});
|
||||
|
||||
$.extend(TableHeader, {
|
||||
tables: []
|
||||
});
|
||||
|
||||
$.extend(TableHeader.prototype, {
|
||||
minHeight: 100,
|
||||
|
||||
tableOffset: null,
|
||||
|
||||
tableHeight: null,
|
||||
|
||||
stickyVisible: false,
|
||||
|
||||
createSticky: function createSticky() {
|
||||
var $stickyHeader = this.$originalHeader.clone(true);
|
||||
|
||||
this.$stickyTable = $('<table class="sticky-header"/>').css({
|
||||
visibility: 'hidden',
|
||||
position: 'fixed',
|
||||
top: '0px'
|
||||
}).append($stickyHeader).insertBefore(this.$originalTable);
|
||||
|
||||
this.$stickyHeaderCells = $stickyHeader.find('> tr > th');
|
||||
|
||||
this.recalculateSticky();
|
||||
},
|
||||
stickyPosition: function stickyPosition(offsetTop, offsetLeft) {
|
||||
var css = {};
|
||||
|
||||
if (typeof offsetTop === 'number') {
|
||||
css.top = offsetTop + 'px';
|
||||
css.top = "".concat(offsetTop, "px");
|
||||
}
|
||||
|
||||
if (typeof offsetLeft === 'number') {
|
||||
css.left = this.tableOffset.left - offsetLeft + 'px';
|
||||
css.left = "".concat(this.tableOffset.left - offsetLeft, "px");
|
||||
}
|
||||
|
||||
return this.$stickyTable.css(css);
|
||||
},
|
||||
checkStickyVisible: function checkStickyVisible() {
|
||||
|
@ -133,35 +127,36 @@
|
|||
},
|
||||
onScroll: function onScroll(e) {
|
||||
this.checkStickyVisible();
|
||||
|
||||
this.stickyPosition(null, scrollValue('scrollLeft'));
|
||||
this.$stickyTable.css('visibility', this.stickyVisible ? 'visible' : 'hidden');
|
||||
},
|
||||
recalculateSticky: function recalculateSticky(event) {
|
||||
this.tableHeight = this.$originalTable[0].clientHeight;
|
||||
|
||||
displace.offsets.top = displace.calculateOffset('top');
|
||||
this.tableOffset = this.$originalTable.offset();
|
||||
this.stickyPosition(displace.offsets.top, scrollValue('scrollLeft'));
|
||||
|
||||
var $that = null;
|
||||
var $stickyCell = null;
|
||||
var display = null;
|
||||
|
||||
var il = this.$originalHeaderCells.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
$that = $(this.$originalHeaderCells[i]);
|
||||
$stickyCell = this.$stickyHeaderCells.eq($that.index());
|
||||
display = $that.css('display');
|
||||
|
||||
if (display !== 'none') {
|
||||
$stickyCell.css({ width: $that.css('width'), display: display });
|
||||
$stickyCell.css({
|
||||
width: $that.css('width'),
|
||||
display: display
|
||||
});
|
||||
} else {
|
||||
$stickyCell.css('display', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
this.$stickyTable.css('width', this.$originalTable.outerWidth());
|
||||
}
|
||||
});
|
||||
|
||||
Drupal.TableHeader = TableHeader;
|
||||
})(jQuery, Drupal, window.Drupal.displace);
|
|
@ -11,32 +11,28 @@
|
|||
this.$table = $(table);
|
||||
this.showText = Drupal.t('Show all columns');
|
||||
this.hideText = Drupal.t('Hide lower priority columns');
|
||||
|
||||
this.$headers = this.$table.find('th');
|
||||
|
||||
this.$link = $('<button type="button" class="link tableresponsive-toggle"></button>').attr('title', Drupal.t('Show table cells that were hidden to make the table fit within a small screen.')).on('click', $.proxy(this, 'eventhandlerToggleColumns'));
|
||||
|
||||
this.$table.before($('<div class="tableresponsive-toggle-columns"></div>').append(this.$link));
|
||||
|
||||
$(window).on('resize.tableresponsive', $.proxy(this, 'eventhandlerEvaluateColumnVisibility')).trigger('resize.tableresponsive');
|
||||
}
|
||||
|
||||
Drupal.behaviors.tableResponsive = {
|
||||
attach: function attach(context, settings) {
|
||||
var $tables = $(context).find('table.responsive-enabled').once('tableresponsive');
|
||||
|
||||
if ($tables.length) {
|
||||
var il = $tables.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
TableResponsive.tables.push(new TableResponsive($tables[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.extend(TableResponsive, {
|
||||
tables: []
|
||||
});
|
||||
|
||||
$.extend(TableResponsive.prototype, {
|
||||
eventhandlerEvaluateColumnVisibility: function eventhandlerEvaluateColumnVisibility(e) {
|
||||
var pegged = parseInt(this.$link.data('pegged'), 10);
|
||||
|
@ -63,42 +59,38 @@
|
|||
self.$table.find('tbody tr').each(function () {
|
||||
var $cells = $(this).find('td').eq(position);
|
||||
$cells.show();
|
||||
|
||||
self.$revealedCells = $().add(self.$revealedCells).add($cells);
|
||||
});
|
||||
$header.show();
|
||||
|
||||
self.$revealedCells = $().add(self.$revealedCells).add($header);
|
||||
});
|
||||
this.$link.text(this.hideText).data('pegged', 1);
|
||||
} else {
|
||||
this.$revealedCells.hide();
|
||||
|
||||
this.$revealedCells.each(function (index, element) {
|
||||
var $cell = $(this);
|
||||
var properties = $cell.attr('style').split(';');
|
||||
var newProps = [];
|
||||
|
||||
var match = /^display\s*:\s*none$/;
|
||||
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
var prop = properties[i];
|
||||
prop.trim();
|
||||
|
||||
var isDisplayNone = match.exec(prop);
|
||||
|
||||
if (isDisplayNone) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newProps.push(prop);
|
||||
}
|
||||
|
||||
$cell.attr('style', newProps.join(';'));
|
||||
});
|
||||
this.$link.text(this.showText).data('pegged', 0);
|
||||
|
||||
$(window).trigger('resize.tableresponsive');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Drupal.TableResponsive = TableResponsive;
|
||||
})(jQuery, Drupal, window);
|
|
@ -18,18 +18,18 @@
|
|||
}
|
||||
|
||||
var table = this;
|
||||
var checkboxes = void 0;
|
||||
var lastChecked = void 0;
|
||||
var checkboxes;
|
||||
var lastChecked;
|
||||
var $table = $(table);
|
||||
var strings = {
|
||||
selectAll: Drupal.t('Select all rows in this table'),
|
||||
selectNone: Drupal.t('Deselect all rows in this table')
|
||||
};
|
||||
|
||||
var updateSelectAll = function updateSelectAll(state) {
|
||||
$table.prev('table.sticky-header').addBack().find('th.select-all input[type="checkbox"]').each(function () {
|
||||
var $checkbox = $(this);
|
||||
var stateChanged = $checkbox.prop('checked') !== state;
|
||||
|
||||
$checkbox.attr('title', state ? strings.selectNone : strings.selectAll);
|
||||
|
||||
if (stateChanged) {
|
||||
|
@ -50,11 +50,9 @@
|
|||
|
||||
$checkbox.closest('tr').toggleClass('selected', this.checked);
|
||||
});
|
||||
|
||||
updateSelectAll(event.target.checked);
|
||||
}
|
||||
});
|
||||
|
||||
checkboxes = $table.find('td input[type="checkbox"]:enabled').on('click', function (e) {
|
||||
$(this).closest('tr').toggleClass('selected', this.checked);
|
||||
|
||||
|
@ -63,10 +61,8 @@
|
|||
}
|
||||
|
||||
updateSelectAll(checkboxes.length === checkboxes.filter(':checked').length);
|
||||
|
||||
lastChecked = e.target;
|
||||
});
|
||||
|
||||
updateSelectAll(checkboxes.length === checkboxes.filter(':checked').length);
|
||||
};
|
||||
|
||||
|
|
|
@ -9,21 +9,18 @@
|
|||
Drupal.behaviors.setTimezone = {
|
||||
attach: function attach(context, settings) {
|
||||
var $timezone = $(context).find('.timezone-detect').once('timezone');
|
||||
|
||||
if ($timezone.length) {
|
||||
var dateString = Date();
|
||||
|
||||
var matches = dateString.match(/\(([A-Z]{3,5})\)/);
|
||||
var abbreviation = matches ? matches[1] : 0;
|
||||
|
||||
var dateNow = new Date();
|
||||
var offsetNow = dateNow.getTimezoneOffset() * -60;
|
||||
|
||||
var dateJan = new Date(dateNow.getFullYear(), 0, 1, 12, 0, 0, 0);
|
||||
var dateJul = new Date(dateNow.getFullYear(), 6, 1, 12, 0, 0, 0);
|
||||
var offsetJan = dateJan.getTimezoneOffset() * -60;
|
||||
var offsetJul = dateJul.getTimezoneOffset() * -60;
|
||||
|
||||
var isDaylightSavingTime = void 0;
|
||||
var isDaylightSavingTime;
|
||||
|
||||
if (offsetJan === offsetJul) {
|
||||
isDaylightSavingTime = '';
|
||||
|
@ -33,11 +30,13 @@
|
|||
isDaylightSavingTime = 0;
|
||||
}
|
||||
|
||||
var path = 'system/timezone/' + abbreviation + '/' + offsetNow + '/' + isDaylightSavingTime;
|
||||
var path = "system/timezone/".concat(abbreviation, "/").concat(offsetNow, "/").concat(isDaylightSavingTime);
|
||||
$.ajax({
|
||||
async: false,
|
||||
url: Drupal.url(path),
|
||||
data: { date: dateString },
|
||||
data: {
|
||||
date: dateString
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function success(data) {
|
||||
if (data) {
|
||||
|
|
|
@ -15,27 +15,25 @@
|
|||
Drupal.behaviors.verticalTabs = {
|
||||
attach: function attach(context) {
|
||||
var width = drupalSettings.widthBreakpoint || 640;
|
||||
var mq = '(max-width: ' + width + 'px)';
|
||||
var mq = "(max-width: ".concat(width, "px)");
|
||||
|
||||
if (window.matchMedia(mq).matches) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('body').once('vertical-tabs-fragments').on('formFragmentLinkClickOrHashChange.verticalTabs', handleFragmentLinkClickOrHashChange);
|
||||
|
||||
$(context).find('[data-vertical-tabs-panes]').once('vertical-tabs').each(function () {
|
||||
var $this = $(this).addClass('vertical-tabs__panes');
|
||||
var focusID = $this.find(':hidden.vertical-tabs__active-tab').val();
|
||||
var tabFocus = void 0;
|
||||
|
||||
var tabFocus;
|
||||
var $details = $this.find('> details');
|
||||
|
||||
if ($details.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var tabList = $('<ul class="vertical-tabs__menu"></ul>');
|
||||
$this.wrap('<div class="vertical-tabs clearfix"></div>').before(tabList);
|
||||
|
||||
$details.each(function () {
|
||||
var $that = $(this);
|
||||
var verticalTab = new Drupal.verticalTab({
|
||||
|
@ -44,22 +42,24 @@
|
|||
});
|
||||
tabList.append(verticalTab.item);
|
||||
$that.removeClass('collapsed').attr('open', true).addClass('vertical-tabs__pane').data('verticalTab', verticalTab);
|
||||
|
||||
if (this.id === focusID) {
|
||||
tabFocus = $that;
|
||||
}
|
||||
});
|
||||
|
||||
$(tabList).find('> li').eq(0).addClass('first');
|
||||
$(tabList).find('> li').eq(-1).addClass('last');
|
||||
|
||||
if (!tabFocus) {
|
||||
var $locationHash = $this.find(window.location.hash);
|
||||
|
||||
if (window.location.hash && $locationHash.length) {
|
||||
tabFocus = $locationHash.closest('.vertical-tabs__pane');
|
||||
} else {
|
||||
tabFocus = $this.find('> .vertical-tabs__pane').eq(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (tabFocus.length) {
|
||||
tabFocus.data('verticalTab').focus();
|
||||
}
|
||||
|
@ -70,23 +70,18 @@
|
|||
Drupal.verticalTab = function (settings) {
|
||||
var self = this;
|
||||
$.extend(this, settings, Drupal.theme('verticalTab', settings));
|
||||
|
||||
this.link.attr('href', '#' + settings.details.attr('id'));
|
||||
|
||||
this.link.attr('href', "#".concat(settings.details.attr('id')));
|
||||
this.link.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
self.focus();
|
||||
});
|
||||
|
||||
this.link.on('keydown', function (event) {
|
||||
if (event.keyCode === 13) {
|
||||
event.preventDefault();
|
||||
self.focus();
|
||||
|
||||
$('.vertical-tabs__pane :input:visible:enabled').eq(0).trigger('focus');
|
||||
}
|
||||
});
|
||||
|
||||
this.details.on('summaryUpdated', function () {
|
||||
self.updateSummary();
|
||||
}).trigger('summaryUpdated');
|
||||
|
@ -100,38 +95,32 @@
|
|||
tab.item.removeClass('is-selected');
|
||||
}).end().show().siblings(':hidden.vertical-tabs__active-tab').val(this.details.attr('id'));
|
||||
this.item.addClass('is-selected');
|
||||
|
||||
$('#active-vertical-tab').remove();
|
||||
this.link.append('<span id="active-vertical-tab" class="visually-hidden">' + Drupal.t('(active tab)') + '</span>');
|
||||
this.link.append("<span id=\"active-vertical-tab\" class=\"visually-hidden\">".concat(Drupal.t('(active tab)'), "</span>"));
|
||||
},
|
||||
updateSummary: function updateSummary() {
|
||||
this.summary.html(this.details.drupalGetSummary());
|
||||
},
|
||||
tabShow: function tabShow() {
|
||||
this.item.show();
|
||||
|
||||
this.item.closest('.js-form-type-vertical-tabs').show();
|
||||
|
||||
this.item.parent().children('.vertical-tabs__menu-item').removeClass('first').filter(':visible').eq(0).addClass('first');
|
||||
|
||||
this.details.removeClass('vertical-tab--hidden').show();
|
||||
|
||||
this.focus();
|
||||
return this;
|
||||
},
|
||||
tabHide: function tabHide() {
|
||||
this.item.hide();
|
||||
|
||||
this.item.parent().children('.vertical-tabs__menu-item').removeClass('first').filter(':visible').eq(0).addClass('first');
|
||||
|
||||
this.details.addClass('vertical-tab--hidden').hide();
|
||||
|
||||
var $firstTab = this.details.siblings('.vertical-tabs__pane:not(.vertical-tab--hidden)').eq(0);
|
||||
|
||||
if ($firstTab.length) {
|
||||
$firstTab.data('verticalTab').focus();
|
||||
} else {
|
||||
this.item.closest('.js-form-type-vertical-tabs').hide();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -34,15 +34,13 @@
|
|||
element: false,
|
||||
progress: false
|
||||
});
|
||||
|
||||
ajaxObject.success(response, 'success');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var interval = drupalSettings.bigPipeInterval || 50;
|
||||
|
||||
var timeoutID = void 0;
|
||||
var timeoutID;
|
||||
|
||||
function bigPipeProcessDocument(context) {
|
||||
if (!context.querySelector('script[data-big-pipe-event="start"]')) {
|
||||
|
@ -55,6 +53,7 @@
|
|||
if (timeoutID) {
|
||||
clearTimeout(timeoutID);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -70,11 +69,11 @@
|
|||
}
|
||||
|
||||
bigPipeProcess();
|
||||
|
||||
$(window).on('load', function () {
|
||||
if (timeoutID) {
|
||||
clearTimeout(timeoutID);
|
||||
}
|
||||
|
||||
bigPipeProcessDocument(document);
|
||||
});
|
||||
})(jQuery, Drupal, drupalSettings);
|
|
@ -10,7 +10,7 @@
|
|||
attach: function attach(context, settings) {
|
||||
var $input = $('input.block-filter-text').once('block-filter-text');
|
||||
var $table = $($input.attr('data-element'));
|
||||
var $filterRows = void 0;
|
||||
var $filterRows;
|
||||
|
||||
function filterBlockList(e) {
|
||||
var query = $(e.target).val().toLowerCase();
|
||||
|
@ -38,13 +38,11 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.blockHighlightPlacement = {
|
||||
attach: function attach(context, settings) {
|
||||
if (settings.blockPlacement && $('.js-block-placed').length) {
|
||||
$(context).find('[data-drupal-selector="edit-blocks"]').once('block-highlight').each(function () {
|
||||
var $container = $(this);
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: $('.js-block-placed').offset().top - $container.offset().top + $container.scrollTop()
|
||||
}, 500);
|
||||
|
|
|
@ -16,19 +16,22 @@
|
|||
var vals = [];
|
||||
var $checkboxes = $(context).find('input[type="checkbox"]:checked + label');
|
||||
var il = $checkboxes.length;
|
||||
|
||||
for (var i = 0; i < il; i++) {
|
||||
vals.push($($checkboxes[i]).html());
|
||||
}
|
||||
|
||||
if (!vals.length) {
|
||||
vals.push(Drupal.t('Not restricted'));
|
||||
}
|
||||
|
||||
return vals.join(', ');
|
||||
}
|
||||
|
||||
$('[data-drupal-selector="edit-visibility-node-type"], [data-drupal-selector="edit-visibility-language"], [data-drupal-selector="edit-visibility-user-role"]').drupalSetSummary(checkboxesSummary);
|
||||
|
||||
$('[data-drupal-selector="edit-visibility-request-path"]').drupalSetSummary(function (context) {
|
||||
var $pages = $(context).find('textarea[name="visibility[request_path][pages]"]');
|
||||
|
||||
if (!$pages.val()) {
|
||||
return Drupal.t('Not restricted');
|
||||
}
|
||||
|
@ -37,7 +40,6 @@
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.blockDrag = {
|
||||
attach: function attach(context, settings) {
|
||||
if (typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag.blocks === 'undefined') {
|
||||
|
@ -64,8 +66,8 @@
|
|||
|
||||
function updateLastPlaced(table, rowObject) {
|
||||
table.find('.color-success').removeClass('color-success');
|
||||
|
||||
var $rowObject = $(rowObject);
|
||||
|
||||
if (!$rowObject.is('.drag-previous')) {
|
||||
table.find('.drag-previous').removeClass('drag-previous');
|
||||
$rowObject.addClass('drag-previous');
|
||||
|
@ -74,14 +76,12 @@
|
|||
|
||||
function updateBlockWeights(table, region) {
|
||||
var weight = -Math.round(table.find('.draggable').length / 2);
|
||||
|
||||
table.find('.region-' + region + '-message').nextUntil('.region-title').find('select.block-weight').val(function () {
|
||||
table.find(".region-".concat(region, "-message")).nextUntil('.region-title').find('select.block-weight').val(function () {
|
||||
return ++weight;
|
||||
});
|
||||
}
|
||||
|
||||
var table = $('#blocks');
|
||||
|
||||
var tableDrag = Drupal.tableDrag.blocks;
|
||||
|
||||
tableDrag.row.prototype.onSwap = function (swappedRow) {
|
||||
|
@ -92,22 +92,20 @@
|
|||
tableDrag.onDrop = function () {
|
||||
var dragObject = this;
|
||||
var $rowElement = $(dragObject.rowObject.element);
|
||||
|
||||
var regionRow = $rowElement.prevAll('tr.region-message').get(0);
|
||||
var regionName = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
|
||||
var regionField = $rowElement.find('select.block-region-select');
|
||||
|
||||
if (regionField.find('option[value=' + regionName + ']').length === 0) {
|
||||
if (regionField.find("option[value=".concat(regionName, "]")).length === 0) {
|
||||
window.alert(Drupal.t('The block cannot be placed in this region.'));
|
||||
|
||||
regionField.trigger('change');
|
||||
}
|
||||
|
||||
if (!regionField.is('.block-region-' + regionName)) {
|
||||
if (!regionField.is(".block-region-".concat(regionName))) {
|
||||
var weightField = $rowElement.find('select.block-weight');
|
||||
var oldRegionName = weightField[0].className.replace(/([^ ]+[ ]+)*block-weight-([^ ]+)([ ]+[^ ]+)*/, '$2');
|
||||
regionField.removeClass('block-region-' + oldRegionName).addClass('block-region-' + regionName);
|
||||
weightField.removeClass('block-weight-' + oldRegionName).addClass('block-weight-' + regionName);
|
||||
regionField.removeClass("block-region-".concat(oldRegionName)).addClass("block-region-".concat(regionName));
|
||||
weightField.removeClass("block-weight-".concat(oldRegionName)).addClass("block-weight-".concat(regionName));
|
||||
regionField.val(regionName);
|
||||
}
|
||||
|
||||
|
@ -117,19 +115,18 @@
|
|||
$(context).find('select.block-region-select').once('block-region-select').on('change', function (event) {
|
||||
var row = $(this).closest('tr');
|
||||
var select = $(this);
|
||||
|
||||
tableDrag.rowObject = new tableDrag.row(row[0]);
|
||||
var regionMessage = table.find('.region-' + select[0].value + '-message');
|
||||
var regionMessage = table.find(".region-".concat(select[0].value, "-message"));
|
||||
var regionItems = regionMessage.nextUntil('.region-message, .region-title');
|
||||
|
||||
if (regionItems.length) {
|
||||
regionItems.last().after(row);
|
||||
} else {
|
||||
regionMessage.after(row);
|
||||
}
|
||||
|
||||
updateBlockWeights(table, select[0].value);
|
||||
|
||||
checkEmptyRegions(table, tableDrag.rowObject);
|
||||
|
||||
updateLastPlaced(table, row);
|
||||
|
||||
if (!tableDrag.changed) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
if (val === '0') {
|
||||
return Drupal.t('Not in book');
|
||||
}
|
||||
|
||||
if (val === 'new') {
|
||||
return Drupal.t('New book');
|
||||
}
|
||||
|
|
|
@ -7,21 +7,18 @@
|
|||
|
||||
(function ($, Drupal, drupalSettings, _) {
|
||||
Drupal.ckeditor = Drupal.ckeditor || {};
|
||||
|
||||
Drupal.behaviors.ckeditorAdmin = {
|
||||
attach: function attach(context) {
|
||||
var $configurationForm = $(context).find('.ckeditor-toolbar-configuration').once('ckeditor-configuration');
|
||||
|
||||
if ($configurationForm.length) {
|
||||
var $textarea = $configurationForm.find('.js-form-item-editor-settings-toolbar-button-groups').hide().find('textarea');
|
||||
|
||||
$configurationForm.append(drupalSettings.ckeditor.toolbarAdmin);
|
||||
|
||||
Drupal.ckeditor.models.Model = new Drupal.ckeditor.Model({
|
||||
$textarea: $textarea,
|
||||
activeEditorConfig: JSON.parse($textarea.val()),
|
||||
hiddenEditorConfig: drupalSettings.ckeditor.hiddenCKEditorConfig
|
||||
});
|
||||
|
||||
var viewDefaults = {
|
||||
model: Drupal.ckeditor.models.Model,
|
||||
el: $('.ckeditor-toolbar-configuration')
|
||||
|
@ -40,22 +37,21 @@
|
|||
}
|
||||
|
||||
var $configurationForm = $(context).find('.ckeditor-toolbar-configuration').findOnce('ckeditor-configuration');
|
||||
|
||||
if ($configurationForm.length && Drupal.ckeditor.models && Drupal.ckeditor.models.Model) {
|
||||
var config = Drupal.ckeditor.models.Model.toJSON().activeEditorConfig;
|
||||
var buttons = Drupal.ckeditor.views.controller.getButtonList(config);
|
||||
var $activeToolbar = $('.ckeditor-toolbar-configuration').find('.ckeditor-toolbar-active');
|
||||
|
||||
for (var i = 0; i < buttons.length; i++) {
|
||||
$activeToolbar.trigger('CKEditorToolbarChanged', ['removed', buttons[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.ckeditor = {
|
||||
views: {},
|
||||
|
||||
models: {},
|
||||
|
||||
registerButtonMove: function registerButtonMove(view, $button, callback) {
|
||||
var $group = $button.closest('.ckeditor-toolbar-group');
|
||||
|
||||
|
@ -63,8 +59,8 @@
|
|||
if (view.isProcessing) {
|
||||
return;
|
||||
}
|
||||
view.isProcessing = true;
|
||||
|
||||
view.isProcessing = true;
|
||||
Drupal.ckeditor.openGroupNameDialog(view, $group, callback);
|
||||
} else {
|
||||
view.model.set('isDirty', true);
|
||||
|
@ -73,12 +69,14 @@
|
|||
},
|
||||
registerGroupMove: function registerGroupMove(view, $group) {
|
||||
var $row = $group.closest('.ckeditor-row');
|
||||
|
||||
if ($row.hasClass('placeholder')) {
|
||||
$row.removeClass('placeholder');
|
||||
}
|
||||
|
||||
$row.parent().children().each(function () {
|
||||
$row = $(this);
|
||||
|
||||
if ($row.find('.ckeditor-toolbar-group').not('.placeholder').length === 0) {
|
||||
$row.addClass('placeholder');
|
||||
}
|
||||
|
@ -91,25 +89,27 @@
|
|||
function validateForm(form) {
|
||||
if (form.elements[0].value.length === 0) {
|
||||
var $form = $(form);
|
||||
|
||||
if (!$form.hasClass('errors')) {
|
||||
$form.addClass('errors').find('input').addClass('error').attr('aria-invalid', 'true');
|
||||
$('<div class="description" >' + Drupal.t('Please provide a name for the button group.') + '</div>').insertAfter(form.elements[0]);
|
||||
$("<div class=\"description\" >".concat(Drupal.t('Please provide a name for the button group.'), "</div>")).insertAfter(form.elements[0]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function closeDialog(action, form) {
|
||||
function shutdown() {
|
||||
dialog.close(action);
|
||||
|
||||
delete view.isProcessing;
|
||||
}
|
||||
|
||||
function namePlaceholderGroup($group, name) {
|
||||
if ($group.hasClass('placeholder')) {
|
||||
var groupID = 'ckeditor-toolbar-group-aria-label-for-' + Drupal.checkPlain(name.toLowerCase().replace(/\s/g, '-'));
|
||||
var groupID = "ckeditor-toolbar-group-aria-label-for-".concat(Drupal.checkPlain(name.toLowerCase().replace(/\s/g, '-')));
|
||||
$group.removeAttr('aria-label').attr('data-drupal-ckeditor-type', 'group').attr('tabindex', 0).children('.ckeditor-toolbar-group-name').attr('id', groupID).end().children('.ckeditor-toolbar-group-buttons').attr('aria-labelledby', groupID);
|
||||
}
|
||||
|
||||
|
@ -128,13 +128,9 @@
|
|||
|
||||
if (action === 'apply') {
|
||||
shutdown();
|
||||
|
||||
namePlaceholderGroup($group, Drupal.checkPlain(form.elements[0].value));
|
||||
|
||||
$group.closest('.ckeditor-row.placeholder').addBack().removeClass('placeholder');
|
||||
|
||||
callback(true, $group);
|
||||
|
||||
view.model.set('isDirty', true);
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +145,6 @@
|
|||
click: function click() {
|
||||
closeDialog('apply', this);
|
||||
},
|
||||
|
||||
primary: true
|
||||
}, {
|
||||
text: Drupal.t('Cancel'),
|
||||
|
@ -162,7 +157,6 @@
|
|||
var $form = $(this);
|
||||
var $widget = $form.parent();
|
||||
$widget.find('.ui-dialog-titlebar-close').remove();
|
||||
|
||||
$widget.on('keypress.ckeditor', 'input, button', function (event) {
|
||||
if (event.keyCode === 13) {
|
||||
var $target = $(event.currentTarget);
|
||||
|
@ -172,49 +166,50 @@
|
|||
if (data && data.options && data.options.label) {
|
||||
action = data.options.label.toLowerCase();
|
||||
}
|
||||
|
||||
closeDialog(action, form);
|
||||
event.stopPropagation();
|
||||
event.stopImmediatePropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
var text = Drupal.t('Editing the name of the new button group in a dialog.');
|
||||
|
||||
if (typeof $group.attr('data-drupal-ckeditor-toolbar-group-name') !== 'undefined') {
|
||||
text = Drupal.t('Editing the name of the "@groupName" button group in a dialog.', {
|
||||
'@groupName': $group.attr('data-drupal-ckeditor-toolbar-group-name')
|
||||
});
|
||||
}
|
||||
|
||||
Drupal.announce(text);
|
||||
},
|
||||
close: function close(event) {
|
||||
$(event.target).remove();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.showModal();
|
||||
|
||||
$(document.querySelector('.ckeditor-name-toolbar-group').querySelector('input')).attr('value', $group.attr('data-drupal-ckeditor-toolbar-group-name')).trigger('focus');
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.ckeditorAdminButtonPluginSettings = {
|
||||
attach: function attach(context) {
|
||||
var $context = $(context);
|
||||
var $ckeditorPluginSettings = $context.find('#ckeditor-plugin-settings').once('ckeditor-plugin-settings');
|
||||
|
||||
if ($ckeditorPluginSettings.length) {
|
||||
$ckeditorPluginSettings.find('[data-ckeditor-buttons]').each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if ($this.data('verticalTab')) {
|
||||
$this.data('verticalTab').tabHide();
|
||||
} else {
|
||||
$this.hide();
|
||||
}
|
||||
|
||||
$this.data('ckeditorButtonPluginSettingsActiveButtons', []);
|
||||
});
|
||||
|
||||
$context.find('.ckeditor-toolbar-active').off('CKEditorToolbarChanged.ckeditorAdminPluginSettings').on('CKEditorToolbarChanged.ckeditorAdminPluginSettings', function (event, action, button) {
|
||||
var $pluginSettings = $ckeditorPluginSettings.find('[data-ckeditor-buttons~=' + button + ']');
|
||||
var $pluginSettings = $ckeditorPluginSettings.find("[data-ckeditor-buttons~=".concat(button, "]"));
|
||||
|
||||
if ($pluginSettings.length === 0) {
|
||||
return;
|
||||
|
@ -222,6 +217,7 @@
|
|||
|
||||
var verticalTab = $pluginSettings.data('verticalTab');
|
||||
var activeButtons = $pluginSettings.data('ckeditorButtonPluginSettingsActiveButtons');
|
||||
|
||||
if (action === 'added') {
|
||||
activeButtons.push(button);
|
||||
|
||||
|
@ -241,6 +237,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pluginSettings.data('ckeditorButtonPluginSettingsActiveButtons', activeButtons);
|
||||
});
|
||||
}
|
||||
|
@ -253,8 +250,8 @@
|
|||
|
||||
Drupal.theme.ckeditorToolbarGroup = function () {
|
||||
var group = '';
|
||||
group += '<li class="ckeditor-toolbar-group placeholder" role="presentation" aria-label="' + Drupal.t('Place a button to create a new button group.') + '">';
|
||||
group += '<h3 class="ckeditor-toolbar-group-name">' + Drupal.t('New group') + '</h3>';
|
||||
group += "<li class=\"ckeditor-toolbar-group placeholder\" role=\"presentation\" aria-label=\"".concat(Drupal.t('Place a button to create a new button group.'), "\">");
|
||||
group += "<h3 class=\"ckeditor-toolbar-group-name\">".concat(Drupal.t('New group'), "</h3>");
|
||||
group += '<ul class="ckeditor-buttons ckeditor-toolbar-group-buttons" role="toolbar" data-drupal-ckeditor-button-sorting="target"></ul>';
|
||||
group += '</li>';
|
||||
return group;
|
||||
|
@ -269,6 +266,6 @@
|
|||
};
|
||||
|
||||
Drupal.theme.ckeditorNewButtonGroup = function () {
|
||||
return '<li class="ckeditor-add-new-group"><button aria-label="' + Drupal.t('Add a CKEditor button group to the end of this row.') + '">' + Drupal.t('Add group') + '</button></li>';
|
||||
return "<li class=\"ckeditor-add-new-group\"><button aria-label=\"".concat(Drupal.t('Add a CKEditor button group to the end of this row.'), "\">").concat(Drupal.t('Add group'), "</button></li>");
|
||||
};
|
||||
})(jQuery, Drupal, drupalSettings, _);
|
|
@ -10,14 +10,13 @@
|
|||
attach: function attach() {
|
||||
$('[data-ckeditor-plugin-id="drupalimage"]').drupalSetSummary(function (context) {
|
||||
var root = 'input[name="editor[settings][plugins][drupalimage][image_upload]';
|
||||
var $status = $(root + '[status]"]');
|
||||
var $maxFileSize = $(root + '[max_size]"]');
|
||||
var $maxWidth = $(root + '[max_dimensions][width]"]');
|
||||
var $maxHeight = $(root + '[max_dimensions][height]"]');
|
||||
var $scheme = $(root + '[scheme]"]:checked');
|
||||
|
||||
var $status = $("".concat(root, "[status]\"]"));
|
||||
var $maxFileSize = $("".concat(root, "[max_size]\"]"));
|
||||
var $maxWidth = $("".concat(root, "[max_dimensions][width]\"]"));
|
||||
var $maxHeight = $("".concat(root, "[max_dimensions][height]\"]"));
|
||||
var $scheme = $("".concat(root, "[scheme]\"]:checked"));
|
||||
var maxFileSize = $maxFileSize.val() ? $maxFileSize.val() : $maxFileSize.attr('placeholder');
|
||||
var maxDimensions = $maxWidth.val() && $maxHeight.val() ? '(' + $maxWidth.val() + 'x' + $maxHeight.val() + ')' : '';
|
||||
var maxDimensions = $maxWidth.val() && $maxHeight.val() ? "(".concat($maxWidth.val(), "x").concat($maxHeight.val(), ")") : '';
|
||||
|
||||
if (!$status.is(':checked')) {
|
||||
return Drupal.t('Uploads disabled');
|
||||
|
@ -28,9 +27,11 @@
|
|||
'@size': maxFileSize,
|
||||
'@dimensions': maxDimensions
|
||||
});
|
||||
|
||||
if ($scheme.length) {
|
||||
output += '<br />' + $scheme.attr('data-label');
|
||||
output += "<br />".concat($scheme.attr('data-label'));
|
||||
}
|
||||
|
||||
return output;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,16 +13,15 @@
|
|||
format.editorSettings.drupal = {
|
||||
format: format.format
|
||||
};
|
||||
|
||||
var label = $('label[for=' + element.getAttribute('id') + ']').html();
|
||||
var label = $("label[for=".concat(element.getAttribute('id'), "]")).html();
|
||||
format.editorSettings.title = Drupal.t('Rich Text Editor, !label field', {
|
||||
'!label': label
|
||||
});
|
||||
|
||||
return !!CKEDITOR.replace(element, format.editorSettings);
|
||||
},
|
||||
detach: function detach(element, format, trigger) {
|
||||
var editor = CKEDITOR.dom.element.get(element).getEditor();
|
||||
|
||||
if (editor) {
|
||||
if (trigger === 'serialize') {
|
||||
editor.updateElement();
|
||||
|
@ -31,17 +30,19 @@
|
|||
element.removeAttribute('contentEditable');
|
||||
}
|
||||
}
|
||||
|
||||
return !!editor;
|
||||
},
|
||||
onChange: function onChange(element, callback) {
|
||||
var editor = CKEDITOR.dom.element.get(element).getEditor();
|
||||
|
||||
if (editor) {
|
||||
editor.on('change', debounce(function () {
|
||||
callback(editor.getData());
|
||||
}, 400));
|
||||
|
||||
editor.on('mode', function () {
|
||||
var editable = editor.editable();
|
||||
|
||||
if (!editable.isInline()) {
|
||||
editor.on('autoGrow', function (evt) {
|
||||
var doc = evt.editor.document;
|
||||
|
@ -56,6 +57,7 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
return !!editor;
|
||||
},
|
||||
attachInlineEditor: function attachInlineEditor(element, format, mainToolbarId, floatedToolbarId) {
|
||||
|
@ -64,7 +66,6 @@
|
|||
format.editorSettings.drupal = {
|
||||
format: format.format
|
||||
};
|
||||
|
||||
var settings = $.extend(true, {}, format.editorSettings);
|
||||
|
||||
if (mainToolbarId) {
|
||||
|
@ -75,14 +76,13 @@
|
|||
top: mainToolbarId
|
||||
}
|
||||
};
|
||||
|
||||
var sourceButtonFound = false;
|
||||
|
||||
for (var i = 0; !sourceButtonFound && i < settings.toolbar.length; i++) {
|
||||
if (settings.toolbar[i] !== '/') {
|
||||
for (var j = 0; !sourceButtonFound && j < settings.toolbar[i].items.length; j++) {
|
||||
if (settings.toolbar[i].items[j] === 'Source') {
|
||||
sourceButtonFound = true;
|
||||
|
||||
settings.toolbar[i].items[j] = 'Sourcedialog';
|
||||
settingsOverride.extraPlugins += ',sourcedialog';
|
||||
settingsOverride.removePlugins += ',sourcearea';
|
||||
|
@ -91,13 +91,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
settings.extraPlugins += ',' + settingsOverride.extraPlugins;
|
||||
settings.removePlugins += ',' + settingsOverride.removePlugins;
|
||||
settings.extraPlugins += ",".concat(settingsOverride.extraPlugins);
|
||||
settings.removePlugins += ",".concat(settingsOverride.removePlugins);
|
||||
settings.sharedSpaces = settingsOverride.sharedSpaces;
|
||||
}
|
||||
|
||||
element.setAttribute('contentEditable', 'true');
|
||||
|
||||
return !!CKEDITOR.inline(element, settings);
|
||||
},
|
||||
_loadExternalPlugins: function _loadExternalPlugins(format) {
|
||||
|
@ -111,69 +110,64 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.ckeditor = {
|
||||
saveCallback: null,
|
||||
|
||||
openDialog: function openDialog(editor, url, existingValues, saveCallback, dialogSettings) {
|
||||
var $target = $(editor.container.$);
|
||||
|
||||
if (editor.elementMode === CKEDITOR.ELEMENT_MODE_REPLACE) {
|
||||
$target = $target.find('.cke_contents');
|
||||
}
|
||||
|
||||
$target.css('position', 'relative').find('.ckeditor-dialog-loading').remove();
|
||||
|
||||
var classes = dialogSettings.dialogClass ? dialogSettings.dialogClass.split(' ') : [];
|
||||
classes.push('ui-dialog--narrow');
|
||||
dialogSettings.dialogClass = classes.join(' ');
|
||||
dialogSettings.autoResize = window.matchMedia('(min-width: 600px)').matches;
|
||||
dialogSettings.width = 'auto';
|
||||
|
||||
var $content = $('<div class="ckeditor-dialog-loading"><span style="top: -40px;" class="ckeditor-dialog-loading-link">' + Drupal.t('Loading...') + '</span></div>');
|
||||
var $content = $("<div class=\"ckeditor-dialog-loading\"><span style=\"top: -40px;\" class=\"ckeditor-dialog-loading-link\">".concat(Drupal.t('Loading...'), "</span></div>"));
|
||||
$content.appendTo($target);
|
||||
|
||||
var ckeditorAjaxDialog = Drupal.ajax({
|
||||
dialog: dialogSettings,
|
||||
dialogType: 'modal',
|
||||
selector: '.ckeditor-dialog-loading-link',
|
||||
url: url,
|
||||
progress: { type: 'throbber' },
|
||||
progress: {
|
||||
type: 'throbber'
|
||||
},
|
||||
submit: {
|
||||
editor_object: existingValues
|
||||
}
|
||||
});
|
||||
ckeditorAjaxDialog.execute();
|
||||
|
||||
window.setTimeout(function () {
|
||||
$content.find('span').animate({ top: '0px' });
|
||||
$content.find('span').animate({
|
||||
top: '0px'
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
Drupal.ckeditor.saveCallback = saveCallback;
|
||||
}
|
||||
};
|
||||
|
||||
$(window).on('dialogcreate', function (e, dialog, $element, settings) {
|
||||
$('.ui-dialog--narrow').css('zIndex', CKEDITOR.config.baseFloatZIndex + 1);
|
||||
});
|
||||
|
||||
$(window).on('dialog:beforecreate', function (e, dialog, $element, settings) {
|
||||
$('.ckeditor-dialog-loading').animate({ top: '-40px' }, function () {
|
||||
$('.ckeditor-dialog-loading').animate({
|
||||
top: '-40px'
|
||||
}, function () {
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
|
||||
$(window).on('editor:dialogsave', function (e, values) {
|
||||
if (Drupal.ckeditor.saveCallback) {
|
||||
Drupal.ckeditor.saveCallback(values);
|
||||
}
|
||||
});
|
||||
|
||||
$(window).on('dialog:afterclose', function (e, dialog, $element) {
|
||||
if (Drupal.ckeditor.saveCallback) {
|
||||
Drupal.ckeditor.saveCallback = null;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('drupalViewportOffsetChange', function () {
|
||||
CKEDITOR.config.autoGrow_maxHeight = 0.7 * (window.innerHeight - displace.offsets.top - displace.offsets.bottom);
|
||||
});
|
||||
|
@ -181,20 +175,20 @@
|
|||
function redirectTextareaFragmentToCKEditorInstance() {
|
||||
var hash = window.location.hash.substr(1);
|
||||
var element = document.getElementById(hash);
|
||||
|
||||
if (element) {
|
||||
var editor = CKEDITOR.dom.element.get(element).getEditor();
|
||||
|
||||
if (editor) {
|
||||
var id = editor.container.getAttribute('id');
|
||||
window.location.replace('#' + id);
|
||||
window.location.replace("#".concat(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(window).on('hashchange.ckeditor', redirectTextareaFragmentToCKEditorInstance);
|
||||
|
||||
CKEDITOR.config.autoGrow_onStartup = true;
|
||||
|
||||
CKEDITOR.config.autoGrow_maxHeight = 0.7 * window.innerHeight;
|
||||
|
||||
CKEDITOR.timestamp = drupalSettings.ckeditor.timestamp;
|
||||
|
||||
if (AjaxCommands) {
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
(function ($, CKEDITOR) {
|
||||
var convertToOffCanvasCss = function convertToOffCanvasCss(originalCss) {
|
||||
var selectorPrefix = '#drupal-off-canvas ';
|
||||
var skinPath = '' + CKEDITOR.basePath + CKEDITOR.skinName + '/';
|
||||
var css = originalCss.substring(originalCss.indexOf('*/') + 2).trim().replace(/}/g, '}' + selectorPrefix).replace(/,/g, ',' + selectorPrefix).replace(/url\(/g, skinPath);
|
||||
return '' + selectorPrefix + css;
|
||||
var skinPath = "".concat(CKEDITOR.basePath).concat(CKEDITOR.skinName, "/");
|
||||
var css = originalCss.substring(originalCss.indexOf('*/') + 2).trim().replace(/}/g, "}".concat(selectorPrefix)).replace(/,/g, ",".concat(selectorPrefix)).replace(/url\(/g, skinPath);
|
||||
return "".concat(selectorPrefix).concat(css);
|
||||
};
|
||||
|
||||
var insertCss = function insertCss(cssToInsert) {
|
||||
|
@ -26,11 +26,9 @@
|
|||
}
|
||||
|
||||
CKEDITOR.skinName = CKEDITOR.skin.name;
|
||||
|
||||
var editorCssPath = CKEDITOR.skin.getPath('editor');
|
||||
var dialogCssPath = CKEDITOR.skin.getPath('dialog');
|
||||
|
||||
var storedOffCanvasCss = window.localStorage.getItem('Drupal.off-canvas.css.' + editorCssPath + dialogCssPath);
|
||||
var storedOffCanvasCss = window.localStorage.getItem("Drupal.off-canvas.css.".concat(editorCssPath).concat(dialogCssPath));
|
||||
|
||||
if (storedOffCanvasCss) {
|
||||
insertCss(storedOffCanvasCss);
|
||||
|
@ -40,11 +38,11 @@
|
|||
$.when($.get(editorCssPath), $.get(dialogCssPath)).done(function (editorCss, dialogCss) {
|
||||
var offCanvasEditorCss = convertToOffCanvasCss(editorCss[0]);
|
||||
var offCanvasDialogCss = convertToOffCanvasCss(dialogCss[0]);
|
||||
var cssToInsert = '#drupal-off-canvas .cke_inner * {background: transparent;}\n ' + offCanvasEditorCss + '\n ' + offCanvasDialogCss;
|
||||
var cssToInsert = "#drupal-off-canvas .cke_inner * {background: transparent;}\n ".concat(offCanvasEditorCss, "\n ").concat(offCanvasDialogCss);
|
||||
insertCss(cssToInsert);
|
||||
|
||||
if (CKEDITOR.timestamp && editorCssPath.indexOf(CKEDITOR.timestamp) !== -1 && dialogCssPath.indexOf(CKEDITOR.timestamp) !== -1) {
|
||||
window.localStorage.setItem('Drupal.off-canvas.css.' + editorCssPath + dialogCssPath, cssToInsert);
|
||||
window.localStorage.setItem("Drupal.off-canvas.css.".concat(editorCssPath).concat(dialogCssPath), cssToInsert);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -9,24 +9,27 @@
|
|||
Drupal.behaviors.ckeditorStylesComboSettings = {
|
||||
attach: function attach(context) {
|
||||
var $context = $(context);
|
||||
|
||||
var $ckeditorActiveToolbar = $context.find('.ckeditor-toolbar-configuration').find('.ckeditor-toolbar-active');
|
||||
var previousStylesSet = drupalSettings.ckeditor.hiddenCKEditorConfig.stylesSet;
|
||||
var that = this;
|
||||
$context.find('[name="editor[settings][plugins][stylescombo][styles]"]').on('blur.ckeditorStylesComboSettings', function () {
|
||||
var styles = $.trim($(this).val());
|
||||
|
||||
var stylesSet = that._generateStylesSetSetting(styles);
|
||||
|
||||
if (!_.isEqual(previousStylesSet, stylesSet)) {
|
||||
previousStylesSet = stylesSet;
|
||||
$ckeditorActiveToolbar.trigger('CKEditorPluginSettingsChanged', [{ stylesSet: stylesSet }]);
|
||||
$ckeditorActiveToolbar.trigger('CKEditorPluginSettingsChanged', [{
|
||||
stylesSet: stylesSet
|
||||
}]);
|
||||
}
|
||||
});
|
||||
},
|
||||
_generateStylesSetSetting: function _generateStylesSetSetting(styles) {
|
||||
var stylesSet = [];
|
||||
|
||||
styles = styles.replace(/\r/g, '\n');
|
||||
var lines = styles.split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var style = $.trim(lines[i]);
|
||||
|
||||
|
@ -43,9 +46,10 @@
|
|||
var label = parts[1];
|
||||
var classes = selector.split('.');
|
||||
var element = classes.shift();
|
||||
|
||||
stylesSet.push({
|
||||
attributes: { class: classes.join(' ') },
|
||||
attributes: {
|
||||
"class": classes.join(' ')
|
||||
},
|
||||
element: element,
|
||||
name: label
|
||||
});
|
||||
|
@ -54,17 +58,19 @@
|
|||
return stylesSet;
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.ckeditorStylesComboSettingsSummary = {
|
||||
attach: function attach() {
|
||||
$('[data-ckeditor-plugin-id="stylescombo"]').drupalSetSummary(function (context) {
|
||||
var styles = $.trim($('[data-drupal-selector="edit-editor-settings-plugins-stylescombo-styles"]').val());
|
||||
|
||||
if (styles.length === 0) {
|
||||
return Drupal.t('No styles configured');
|
||||
}
|
||||
|
||||
var count = $.trim(styles).split('\n').length;
|
||||
return Drupal.t('@count styles configured', { '@count': count });
|
||||
return Drupal.t('@count styles configured', {
|
||||
'@count': count
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -9,20 +9,13 @@
|
|||
Drupal.ckeditor.Model = Backbone.Model.extend({
|
||||
defaults: {
|
||||
activeEditorConfig: null,
|
||||
|
||||
$textarea: null,
|
||||
|
||||
isDirty: false,
|
||||
|
||||
hiddenEditorConfig: null,
|
||||
|
||||
buttonsToFeatures: null,
|
||||
|
||||
featuresMetadata: null,
|
||||
|
||||
groupNamesVisible: false
|
||||
},
|
||||
|
||||
sync: function sync() {
|
||||
this.get('$textarea').val(JSON.stringify(this.get('activeEditorConfig')));
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
}
|
||||
|
||||
CKEDITOR.plugins.drupallink.registerLinkableWidget('image');
|
||||
|
||||
editor.getCommand('drupalunlink').on('exec', function (evt) {
|
||||
var widget = getFocusedWidget(editor);
|
||||
|
||||
|
@ -31,12 +30,9 @@
|
|||
}
|
||||
|
||||
widget.setData('link', null);
|
||||
|
||||
this.refresh(editor, editor.elementPath());
|
||||
|
||||
evt.cancel();
|
||||
});
|
||||
|
||||
editor.getCommand('drupalunlink').on('refresh', function (evt) {
|
||||
var widget = getFocusedWidget(editor);
|
||||
|
||||
|
@ -45,7 +41,6 @@
|
|||
}
|
||||
|
||||
this.setState(widget.data.link || widget.wrapper.getAscendant('a') ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED);
|
||||
|
||||
evt.cancel();
|
||||
});
|
||||
}
|
||||
|
@ -54,10 +49,10 @@
|
|||
requires: 'image2',
|
||||
icons: 'drupalimage',
|
||||
hidpi: true,
|
||||
|
||||
beforeInit: function beforeInit(editor) {
|
||||
editor.on('widgetDefinition', function (event) {
|
||||
var widgetDefinition = event.data;
|
||||
|
||||
if (widgetDefinition.name !== 'image') {
|
||||
return;
|
||||
}
|
||||
|
@ -73,7 +68,6 @@
|
|||
classes: {}
|
||||
}
|
||||
};
|
||||
|
||||
widgetDefinition.requiredContent = new CKEDITOR.style({
|
||||
element: 'img',
|
||||
attributes: {
|
||||
|
@ -81,7 +75,6 @@
|
|||
alt: ''
|
||||
}
|
||||
});
|
||||
|
||||
var requiredContent = widgetDefinition.requiredContent.getDefinition();
|
||||
requiredContent.attributes['data-entity-type'] = '';
|
||||
requiredContent.attributes['data-entity-uuid'] = '';
|
||||
|
@ -104,13 +97,12 @@
|
|||
}
|
||||
|
||||
data['data-entity-type'] = element.attributes['data-entity-type'];
|
||||
|
||||
data['data-entity-uuid'] = element.attributes['data-entity-uuid'];
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
var originalGetClasses = widgetDefinition.getClasses;
|
||||
|
||||
widgetDefinition.getClasses = function () {
|
||||
var classes = originalGetClasses.call(this);
|
||||
var captionedClasses = (this.editor.config.image2_captionedClass || '').split(/\s+/);
|
||||
|
@ -164,13 +156,12 @@
|
|||
}
|
||||
|
||||
editor.fire('saveSnapshot');
|
||||
|
||||
var container = widget.wrapper.getParent(true);
|
||||
var image = widget.parts.image;
|
||||
|
||||
var data = widgetDefinition._dialogValuesToData(dialogReturnValues.attributes);
|
||||
widget.setData(data);
|
||||
|
||||
widget.setData(data);
|
||||
widget = editor.widgets.getByElement(image);
|
||||
|
||||
if (firstEdit) {
|
||||
|
@ -179,15 +170,14 @@
|
|||
|
||||
setTimeout(function () {
|
||||
widget.focus();
|
||||
|
||||
editor.fire('saveSnapshot');
|
||||
});
|
||||
|
||||
return widget;
|
||||
};
|
||||
};
|
||||
|
||||
var originalInit = widgetDefinition.init;
|
||||
|
||||
widgetDefinition.init = function () {
|
||||
originalInit.call(this);
|
||||
|
||||
|
@ -196,7 +186,6 @@
|
|||
}
|
||||
};
|
||||
});
|
||||
|
||||
editor.widgets.on('instanceCreated', function (event) {
|
||||
var widget = event.data;
|
||||
|
||||
|
@ -206,34 +195,32 @@
|
|||
|
||||
widget.on('edit', function (event) {
|
||||
event.cancel();
|
||||
|
||||
editor.execCommand('editdrupalimage', {
|
||||
existingValues: widget.definition._dataToDialogValues(widget.data),
|
||||
saveCallback: widget.definition._createDialogSaveCallback(editor, widget),
|
||||
|
||||
dialogTitle: widget.data.src ? editor.config.drupalImage_dialogTitleEdit : editor.config.drupalImage_dialogTitleAdd
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
editor.addCommand('editdrupalimage', {
|
||||
allowedContent: 'img[alt,!src,width,height,!data-entity-type,!data-entity-uuid]',
|
||||
requiredContent: 'img[alt,src,data-entity-type,data-entity-uuid]',
|
||||
modes: { wysiwyg: 1 },
|
||||
modes: {
|
||||
wysiwyg: 1
|
||||
},
|
||||
canUndo: true,
|
||||
exec: function exec(editor, data) {
|
||||
var dialogSettings = {
|
||||
title: data.dialogTitle,
|
||||
dialogClass: 'editor-image-dialog'
|
||||
};
|
||||
Drupal.ckeditor.openDialog(editor, Drupal.url('editor/dialog/image/' + editor.config.drupal.format), data.existingValues, data.saveCallback, dialogSettings);
|
||||
Drupal.ckeditor.openDialog(editor, Drupal.url("editor/dialog/image/".concat(editor.config.drupal.format)), data.existingValues, data.saveCallback, dialogSettings);
|
||||
}
|
||||
});
|
||||
|
||||
if (editor.ui.addButton) {
|
||||
editor.ui.addButton('DrupalImage', {
|
||||
label: Drupal.t('Image'),
|
||||
|
||||
command: 'image'
|
||||
});
|
||||
}
|
||||
|
@ -246,6 +233,7 @@
|
|||
CKEDITOR.plugins.image2.getLinkAttributesParser = function () {
|
||||
return CKEDITOR.plugins.drupallink.parseLinkAttributes;
|
||||
};
|
||||
|
||||
CKEDITOR.plugins.image2.getLinkAttributesGetter = function () {
|
||||
return CKEDITOR.plugins.drupallink.getLinkAttributes;
|
||||
};
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
element.forEach(function (el) {
|
||||
if (el.name === name) {
|
||||
found = el;
|
||||
|
||||
return false;
|
||||
}
|
||||
}, CKEDITOR.NODE_ELEMENT);
|
||||
|
@ -24,21 +23,18 @@
|
|||
|
||||
CKEDITOR.plugins.add('drupalimagecaption', {
|
||||
requires: 'drupalimage',
|
||||
|
||||
beforeInit: function beforeInit(editor) {
|
||||
editor.lang.image2.captionPlaceholder = '';
|
||||
|
||||
var placeholderText = editor.config.drupalImageCaption_captionPlaceholderText;
|
||||
|
||||
editor.on('widgetDefinition', function (event) {
|
||||
var widgetDefinition = event.data;
|
||||
|
||||
if (widgetDefinition.name !== 'image') {
|
||||
return;
|
||||
}
|
||||
|
||||
var captionFilterEnabled = editor.config.drupalImageCaption_captionFilterEnabled;
|
||||
var alignFilterEnabled = editor.config.drupalImageCaption_alignFilterEnabled;
|
||||
|
||||
CKEDITOR.tools.extend(widgetDefinition.features, {
|
||||
caption: {
|
||||
requiredContent: 'img[data-caption]'
|
||||
|
@ -47,21 +43,18 @@
|
|||
requiredContent: 'img[data-align]'
|
||||
}
|
||||
}, true);
|
||||
|
||||
var requiredContent = widgetDefinition.requiredContent.getDefinition();
|
||||
requiredContent.attributes['data-align'] = '';
|
||||
requiredContent.attributes['data-caption'] = '';
|
||||
widgetDefinition.requiredContent = new CKEDITOR.style(requiredContent);
|
||||
widgetDefinition.allowedContent.img.attributes['!data-align'] = true;
|
||||
widgetDefinition.allowedContent.img.attributes['!data-caption'] = true;
|
||||
|
||||
widgetDefinition.editables.caption.allowedContent = 'a[!href]; em strong cite code br';
|
||||
|
||||
var originalDowncast = widgetDefinition.downcast;
|
||||
|
||||
widgetDefinition.downcast = function (element) {
|
||||
var img = findElementByName(element, 'img');
|
||||
originalDowncast.call(this, img);
|
||||
|
||||
var caption = this.editables.caption;
|
||||
var captionHtml = caption && caption.getData();
|
||||
var attrs = img.attributes;
|
||||
|
@ -71,6 +64,7 @@
|
|||
attrs['data-caption'] = captionHtml;
|
||||
}
|
||||
}
|
||||
|
||||
if (alignFilterEnabled) {
|
||||
if (this.data.align !== 'none') {
|
||||
attrs['data-align'] = this.data.align;
|
||||
|
@ -85,6 +79,7 @@
|
|||
};
|
||||
|
||||
var originalUpcast = widgetDefinition.upcast;
|
||||
|
||||
widgetDefinition.upcast = function (element, data) {
|
||||
if (element.name !== 'img' || !element.attributes['data-entity-type'] || !element.attributes['data-entity-uuid']) {
|
||||
return;
|
||||
|
@ -102,16 +97,18 @@
|
|||
}
|
||||
|
||||
var retElement = element;
|
||||
var caption = void 0;
|
||||
var caption;
|
||||
|
||||
if (captionFilterEnabled) {
|
||||
caption = attrs['data-caption'];
|
||||
delete attrs['data-caption'];
|
||||
}
|
||||
|
||||
if (alignFilterEnabled) {
|
||||
data.align = attrs['data-align'];
|
||||
delete attrs['data-align'];
|
||||
}
|
||||
|
||||
data['data-entity-type'] = attrs['data-entity-type'];
|
||||
delete attrs['data-entity-type'];
|
||||
data['data-entity-uuid'] = attrs['data-entity-uuid'];
|
||||
|
@ -126,7 +123,9 @@
|
|||
if (splitBefore) {
|
||||
element.parent.split(index);
|
||||
}
|
||||
|
||||
index = element.getIndex();
|
||||
|
||||
if (splitAfter) {
|
||||
element.parent.split(index + 1);
|
||||
}
|
||||
|
@ -138,13 +137,11 @@
|
|||
if (caption) {
|
||||
var figure = new CKEDITOR.htmlParser.element('figure');
|
||||
caption = new CKEDITOR.htmlParser.fragment.fromHtml(caption, 'figcaption');
|
||||
|
||||
caption.attributes['data-placeholder'] = placeholderText;
|
||||
|
||||
element.replaceWith(figure);
|
||||
figure.add(element);
|
||||
figure.add(caption);
|
||||
figure.attributes.class = editor.config.image2_captionedClass;
|
||||
figure.attributes["class"] = editor.config.image2_captionedClass;
|
||||
retElement = figure;
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +151,6 @@
|
|||
var p = new CKEDITOR.htmlParser.element('p');
|
||||
element.replaceWith(p);
|
||||
p.add(element);
|
||||
|
||||
p.addClass(editor.config.image2_alignClasses[1]);
|
||||
retElement = p;
|
||||
}
|
||||
|
@ -168,20 +164,18 @@
|
|||
'data-caption': 'data-caption',
|
||||
hasCaption: 'hasCaption'
|
||||
});
|
||||
|
||||
var originalCreateDialogSaveCallback = widgetDefinition._createDialogSaveCallback;
|
||||
|
||||
widgetDefinition._createDialogSaveCallback = function (editor, widget) {
|
||||
var saveCallback = originalCreateDialogSaveCallback.call(this, editor, widget);
|
||||
|
||||
return function (dialogReturnValues) {
|
||||
dialogReturnValues.attributes.hasCaption = !!dialogReturnValues.attributes.hasCaption;
|
||||
|
||||
var actualWidget = saveCallback(dialogReturnValues);
|
||||
|
||||
if (dialogReturnValues.attributes.hasCaption) {
|
||||
actualWidget.editables.caption.setAttribute('data-placeholder', placeholderText);
|
||||
|
||||
var captionElement = actualWidget.editables.caption.$;
|
||||
|
||||
if (captionElement.childNodes.length === 1 && captionElement.childNodes.item(0).nodeName === 'BR') {
|
||||
captionElement.removeChild(captionElement.childNodes.item(0));
|
||||
}
|
||||
|
@ -193,6 +187,7 @@
|
|||
afterInit: function afterInit(editor) {
|
||||
var disableButtonIfOnWidget = function disableButtonIfOnWidget(evt) {
|
||||
var widget = editor.widgets.focused;
|
||||
|
||||
if (widget && widget.name === 'image') {
|
||||
this.setState(CKEDITOR.TRISTATE_DISABLED);
|
||||
evt.cancel();
|
||||
|
@ -200,8 +195,9 @@
|
|||
};
|
||||
|
||||
if (editor.plugins.justify && !editor.config.drupalImageCaption_alignFilterEnabled) {
|
||||
var cmd = void 0;
|
||||
var cmd;
|
||||
var commands = ['justifyleft', 'justifycenter', 'justifyright', 'justifyblock'];
|
||||
|
||||
for (var n = 0; n < commands.length; n++) {
|
||||
cmd = editor.getCommand(commands[n]);
|
||||
cmd.contextSensitive = 1;
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
(function ($, Drupal, drupalSettings, CKEDITOR) {
|
||||
function parseAttributes(editor, element) {
|
||||
var parsedAttributes = {};
|
||||
|
||||
var domElement = element.$;
|
||||
var attribute = void 0;
|
||||
var attributeName = void 0;
|
||||
var attribute;
|
||||
var attributeName;
|
||||
|
||||
for (var attrIndex = 0; attrIndex < domElement.attributes.length; attrIndex++) {
|
||||
attribute = domElement.attributes.item(attrIndex);
|
||||
attributeName = attribute.nodeName.toLowerCase();
|
||||
|
@ -20,11 +20,11 @@
|
|||
continue;
|
||||
}
|
||||
|
||||
parsedAttributes[attributeName] = element.data('cke-saved-' + attributeName) || attribute.nodeValue;
|
||||
parsedAttributes[attributeName] = element.data("cke-saved-".concat(attributeName)) || attribute.nodeValue;
|
||||
}
|
||||
|
||||
if (parsedAttributes.class) {
|
||||
parsedAttributes.class = CKEDITOR.tools.trim(parsedAttributes.class.replace(/cke_\S+/, ''));
|
||||
if (parsedAttributes["class"]) {
|
||||
parsedAttributes["class"] = CKEDITOR.tools.trim(parsedAttributes["class"].replace(/cke_\S+/, ''));
|
||||
}
|
||||
|
||||
return parsedAttributes;
|
||||
|
@ -35,14 +35,11 @@
|
|||
Object.keys(data || {}).forEach(function (attributeName) {
|
||||
set[attributeName] = data[attributeName];
|
||||
});
|
||||
|
||||
set['data-cke-saved-href'] = set.href;
|
||||
|
||||
var removed = {};
|
||||
Object.keys(set).forEach(function (s) {
|
||||
delete removed[s];
|
||||
});
|
||||
|
||||
return {
|
||||
set: set,
|
||||
removed: CKEDITOR.tools.objectKeys(removed)
|
||||
|
@ -57,15 +54,18 @@
|
|||
|
||||
function getFocusedLinkableWidget(editor) {
|
||||
var widget = editor.widgets.focused;
|
||||
|
||||
if (widget && registeredLinkableWidgets.indexOf(widget.name) !== -1) {
|
||||
return widget;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getSelectedLink(editor) {
|
||||
var selection = editor.getSelection();
|
||||
var selectedElement = selection.getSelectedElement();
|
||||
|
||||
if (selectedElement && selectedElement.is('a')) {
|
||||
return selectedElement;
|
||||
}
|
||||
|
@ -76,13 +76,13 @@
|
|||
range.shrink(CKEDITOR.SHRINK_TEXT);
|
||||
return editor.elementPath(range.getCommonAncestor()).contains('a', 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
CKEDITOR.plugins.add('drupallink', {
|
||||
icons: 'drupallink,drupalunlink',
|
||||
hidpi: true,
|
||||
|
||||
init: function init(editor) {
|
||||
editor.addCommand('drupallink', {
|
||||
allowedContent: {
|
||||
|
@ -99,13 +99,15 @@
|
|||
href: ''
|
||||
}
|
||||
}),
|
||||
modes: { wysiwyg: 1 },
|
||||
modes: {
|
||||
wysiwyg: 1
|
||||
},
|
||||
canUndo: true,
|
||||
exec: function exec(editor) {
|
||||
var focusedLinkableWidget = getFocusedLinkableWidget(editor);
|
||||
var linkElement = getSelectedLink(editor);
|
||||
|
||||
var existingValues = {};
|
||||
|
||||
if (linkElement && linkElement.$) {
|
||||
existingValues = parseAttributes(editor, linkElement);
|
||||
} else if (focusedLinkableWidget && focusedLinkableWidget.data.link) {
|
||||
|
@ -138,13 +140,12 @@
|
|||
style.type = CKEDITOR.STYLE_INLINE;
|
||||
style.applyToRange(range);
|
||||
range.select();
|
||||
|
||||
linkElement = getSelectedLink(editor);
|
||||
} else if (linkElement) {
|
||||
Object.keys(returnValues.attributes || {}).forEach(function (attrName) {
|
||||
if (returnValues.attributes[attrName].length > 0) {
|
||||
var value = returnValues.attributes[attrName];
|
||||
linkElement.data('cke-saved-' + attrName, value);
|
||||
linkElement.data("cke-saved-".concat(attrName), value);
|
||||
linkElement.setAttribute(attrName, value);
|
||||
} else {
|
||||
linkElement.removeAttribute(attrName);
|
||||
|
@ -159,8 +160,7 @@
|
|||
title: linkElement ? editor.config.drupalLink_dialogTitleEdit : editor.config.drupalLink_dialogTitleAdd,
|
||||
dialogClass: 'editor-link-dialog'
|
||||
};
|
||||
|
||||
Drupal.ckeditor.openDialog(editor, Drupal.url('editor/dialog/link/' + editor.config.drupal.format), existingValues, saveCallback, dialogSettings);
|
||||
Drupal.ckeditor.openDialog(editor, Drupal.url("editor/dialog/link/".concat(editor.config.drupal.format)), existingValues, saveCallback, dialogSettings);
|
||||
}
|
||||
});
|
||||
editor.addCommand('drupalunlink', {
|
||||
|
@ -182,6 +182,7 @@
|
|||
},
|
||||
refresh: function refresh(editor, path) {
|
||||
var element = path.lastElement && path.lastElement.getAscendant('a', true);
|
||||
|
||||
if (element && element.getName() === 'a' && element.getAttribute('href') && element.getChildCount()) {
|
||||
this.setState(CKEDITOR.TRISTATE_OFF);
|
||||
} else {
|
||||
|
@ -189,7 +190,6 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.setKeystroke(CKEDITOR.CTRL + 75, 'drupallink');
|
||||
|
||||
if (editor.ui.addButton) {
|
||||
|
@ -222,7 +222,6 @@
|
|||
group: 'link',
|
||||
order: 1
|
||||
},
|
||||
|
||||
unlink: {
|
||||
label: Drupal.t('Unlink'),
|
||||
command: 'drupalunlink',
|
||||
|
@ -237,24 +236,27 @@
|
|||
if (!element || element.isReadOnly()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var anchor = getSelectedLink(editor);
|
||||
|
||||
if (!anchor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var menu = {};
|
||||
|
||||
if (anchor.getAttribute('href') && anchor.getChildCount()) {
|
||||
menu = {
|
||||
link: CKEDITOR.TRISTATE_OFF,
|
||||
unlink: CKEDITOR.TRISTATE_OFF
|
||||
};
|
||||
}
|
||||
|
||||
return menu;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CKEDITOR.plugins.drupallink = {
|
||||
parseLinkAttributes: parseAttributes,
|
||||
getLinkAttributes: getAttributes,
|
||||
|
|
|
@ -14,15 +14,16 @@
|
|||
'focus .ckeditor-button-separator a': 'onFocus',
|
||||
'focus .ckeditor-toolbar-group': 'onFocus'
|
||||
},
|
||||
|
||||
initialize: function initialize() {
|
||||
this.listenTo(this.model, 'change:isDirty', this.announceMove);
|
||||
},
|
||||
announceMove: function announceMove(model, isDirty) {
|
||||
if (!isDirty) {
|
||||
var item = document.activeElement || null;
|
||||
|
||||
if (item) {
|
||||
var $item = $(item);
|
||||
|
||||
if ($item.hasClass('ckeditor-toolbar-group')) {
|
||||
this.announceButtonGroupPosition($item);
|
||||
} else if ($item.parent().hasClass('ckeditor-button')) {
|
||||
|
@ -33,10 +34,10 @@
|
|||
},
|
||||
onFocus: function onFocus(event) {
|
||||
event.stopPropagation();
|
||||
|
||||
var $originalTarget = $(event.target);
|
||||
var $currentTarget = $(event.currentTarget);
|
||||
var $parent = $currentTarget.parent();
|
||||
|
||||
if ($parent.hasClass('ckeditor-button') || $parent.hasClass('ckeditor-button-separator')) {
|
||||
this.announceButtonPosition($currentTarget.parent());
|
||||
} else if ($originalTarget.attr('role') !== 'button' && $currentTarget.hasClass('ckeditor-toolbar-group')) {
|
||||
|
@ -63,6 +64,7 @@
|
|||
text += '\n';
|
||||
text += Drupal.t('Press the down arrow key to create a new row.');
|
||||
}
|
||||
|
||||
Drupal.announce(text, 'assertive');
|
||||
},
|
||||
announceButtonPosition: function announceButtonPosition($button) {
|
||||
|
@ -77,17 +79,15 @@
|
|||
var positionCount = $buttons.length;
|
||||
var row = $rows.index($row) + 1;
|
||||
var rowCount = $rows.not('.placeholder').length;
|
||||
|
||||
var type = $button.attr('data-drupal-ckeditor-type') === 'separator' ? '' : Drupal.t('button');
|
||||
var text = void 0;
|
||||
var text;
|
||||
|
||||
if ($button.closest('.ckeditor-toolbar-disabled').length > 0) {
|
||||
text = Drupal.t('@name @type.', {
|
||||
'@name': $button.children().attr('aria-label'),
|
||||
'@type': type
|
||||
});
|
||||
text += '\n' + Drupal.t('Press the down arrow key to activate.');
|
||||
|
||||
text += "\n".concat(Drupal.t('Press the down arrow key to activate.'));
|
||||
Drupal.announce(text, 'assertive');
|
||||
} else if ($group.not('.placeholder').length === 1) {
|
||||
text = Drupal.t('@name @type in position @position of @positionCount in @groupName button group in row @row of @rowCount.', {
|
||||
|
@ -109,6 +109,7 @@
|
|||
text += '\n';
|
||||
text += Drupal.t('This is the last group. Move the button forward to create a new group.');
|
||||
}
|
||||
|
||||
Drupal.announce(text, 'assertive');
|
||||
}
|
||||
},
|
||||
|
@ -116,20 +117,21 @@
|
|||
var $link = $(event.currentTarget);
|
||||
var $button = $link.parent();
|
||||
var enabled = $button.closest('.ckeditor-toolbar-active').length > 0;
|
||||
var message = void 0;
|
||||
var message;
|
||||
|
||||
if (enabled) {
|
||||
message = Drupal.t('The "@name" button is currently enabled.', {
|
||||
'@name': $link.attr('aria-label')
|
||||
});
|
||||
message += '\n' + Drupal.t('Use the keyboard arrow keys to change the position of this button.');
|
||||
message += '\n' + Drupal.t('Press the up arrow key on the top row to disable the button.');
|
||||
message += "\n".concat(Drupal.t('Use the keyboard arrow keys to change the position of this button.'));
|
||||
message += "\n".concat(Drupal.t('Press the up arrow key on the top row to disable the button.'));
|
||||
} else {
|
||||
message = Drupal.t('The "@name" button is currently disabled.', {
|
||||
'@name': $link.attr('aria-label')
|
||||
});
|
||||
message += '\n' + Drupal.t('Use the down arrow key to move this button into the active toolbar.');
|
||||
message += "\n".concat(Drupal.t('Use the down arrow key to move this button into the active toolbar.'));
|
||||
}
|
||||
|
||||
Drupal.announce(message);
|
||||
event.preventDefault();
|
||||
},
|
||||
|
@ -137,21 +139,22 @@
|
|||
var $link = $(event.currentTarget);
|
||||
var $button = $link.parent();
|
||||
var enabled = $button.closest('.ckeditor-toolbar-active').length > 0;
|
||||
var message = void 0;
|
||||
var message;
|
||||
|
||||
if (enabled) {
|
||||
message = Drupal.t('This @name is currently enabled.', {
|
||||
'@name': $link.attr('aria-label')
|
||||
});
|
||||
message += '\n' + Drupal.t('Use the keyboard arrow keys to change the position of this separator.');
|
||||
message += "\n".concat(Drupal.t('Use the keyboard arrow keys to change the position of this separator.'));
|
||||
} else {
|
||||
message = Drupal.t('Separators are used to visually split individual buttons.');
|
||||
message += '\n' + Drupal.t('This @name is currently disabled.', {
|
||||
message += "\n".concat(Drupal.t('This @name is currently disabled.', {
|
||||
'@name': $link.attr('aria-label')
|
||||
});
|
||||
message += '\n' + Drupal.t('Use the down arrow key to move this separator into the active toolbar.');
|
||||
message += '\n' + Drupal.t('You may add multiple separators to each button group.');
|
||||
}));
|
||||
message += "\n".concat(Drupal.t('Use the down arrow key to move this separator into the active toolbar.'));
|
||||
message += "\n".concat(Drupal.t('You may add multiple separators to each button group.'));
|
||||
}
|
||||
|
||||
Drupal.announce(message);
|
||||
event.preventDefault();
|
||||
}
|
||||
|
|
|
@ -8,24 +8,21 @@
|
|||
(function ($, Drupal, Backbone, CKEDITOR, _) {
|
||||
Drupal.ckeditor.ControllerView = Backbone.View.extend({
|
||||
events: {},
|
||||
|
||||
initialize: function initialize() {
|
||||
this.getCKEditorFeatures(this.model.get('hiddenEditorConfig'), this.disableFeaturesDisallowedByFilters.bind(this));
|
||||
|
||||
this.model.listenTo(this.model, 'change:activeEditorConfig', this.model.sync);
|
||||
this.listenTo(this.model, 'change:isDirty', this.parseEditorDOM);
|
||||
},
|
||||
parseEditorDOM: function parseEditorDOM(model, isDirty, options) {
|
||||
if (isDirty) {
|
||||
var currentConfig = this.model.get('activeEditorConfig');
|
||||
|
||||
var rows = [];
|
||||
this.$el.find('.ckeditor-active-toolbar-configuration').children('.ckeditor-row').each(function () {
|
||||
var groups = [];
|
||||
|
||||
$(this).find('.ckeditor-toolbar-group').each(function () {
|
||||
var $group = $(this);
|
||||
var $buttons = $group.find('.ckeditor-button');
|
||||
|
||||
if ($buttons.length) {
|
||||
var group = {
|
||||
name: $group.attr('data-drupal-ckeditor-toolbar-group-name'),
|
||||
|
@ -37,17 +34,18 @@
|
|||
groups.push(group);
|
||||
}
|
||||
});
|
||||
|
||||
if (groups.length) {
|
||||
rows.push(groups);
|
||||
}
|
||||
});
|
||||
this.model.set('activeEditorConfig', rows);
|
||||
|
||||
this.model.set('isDirty', false);
|
||||
|
||||
if (options.broadcast !== false) {
|
||||
var prev = this.getButtonList(currentConfig);
|
||||
var next = this.getButtonList(rows);
|
||||
|
||||
if (prev.length !== next.length) {
|
||||
this.$el.find('.ckeditor-toolbar-active').trigger('CKEditorToolbarChanged', [prev.length < next.length ? 'added' : 'removed', _.difference(_.union(prev, next), _.intersection(prev, next))[0]]);
|
||||
}
|
||||
|
@ -63,52 +61,51 @@
|
|||
for (var i = 0; i < CKEFeatureRules.length; i++) {
|
||||
var CKERule = CKEFeatureRules[i];
|
||||
var rule = new Drupal.EditorFeatureHTMLRule();
|
||||
|
||||
var tags = getProperties(CKERule.elements);
|
||||
rule.required.tags = CKERule.propertiesOnly ? [] : tags;
|
||||
rule.allowed.tags = tags;
|
||||
|
||||
rule.required.attributes = getProperties(CKERule.requiredAttributes);
|
||||
rule.allowed.attributes = getProperties(CKERule.attributes);
|
||||
|
||||
rule.required.styles = getProperties(CKERule.requiredStyles);
|
||||
rule.allowed.styles = getProperties(CKERule.styles);
|
||||
|
||||
rule.required.classes = getProperties(CKERule.requiredClasses);
|
||||
rule.allowed.classes = getProperties(CKERule.classes);
|
||||
|
||||
rule.raw = CKERule;
|
||||
|
||||
feature.addHTMLRule(rule);
|
||||
}
|
||||
};
|
||||
|
||||
var hiddenCKEditorID = 'ckeditor-hidden';
|
||||
|
||||
if (CKEDITOR.instances[hiddenCKEditorID]) {
|
||||
CKEDITOR.instances[hiddenCKEditorID].destroy(true);
|
||||
}
|
||||
|
||||
var hiddenEditorConfig = this.model.get('hiddenEditorConfig');
|
||||
|
||||
if (hiddenEditorConfig.drupalExternalPlugins) {
|
||||
var externalPlugins = hiddenEditorConfig.drupalExternalPlugins;
|
||||
Object.keys(externalPlugins || {}).forEach(function (pluginName) {
|
||||
CKEDITOR.plugins.addExternal(pluginName, externalPlugins[pluginName], '');
|
||||
});
|
||||
}
|
||||
CKEDITOR.inline($('#' + hiddenCKEditorID).get(0), CKEditorConfig);
|
||||
|
||||
CKEDITOR.inline($("#".concat(hiddenCKEditorID)).get(0), CKEditorConfig);
|
||||
CKEDITOR.once('instanceReady', function (e) {
|
||||
if (e.editor.name === hiddenCKEditorID) {
|
||||
var CKEFeatureRulesMap = {};
|
||||
var rules = e.editor.filter.allowedContent;
|
||||
var rule = void 0;
|
||||
var name = void 0;
|
||||
var rule;
|
||||
var name;
|
||||
|
||||
for (var i = 0; i < rules.length; i++) {
|
||||
rule = rules[i];
|
||||
name = rule.featureName || ':(';
|
||||
|
||||
if (!CKEFeatureRulesMap[name]) {
|
||||
CKEFeatureRulesMap[name] = [];
|
||||
}
|
||||
|
||||
CKEFeatureRulesMap[name].push(rule);
|
||||
}
|
||||
|
||||
|
@ -119,11 +116,11 @@
|
|||
convertCKERulesToEditorFeature(feature, CKEFeatureRulesMap[featureName]);
|
||||
features[featureName] = feature;
|
||||
var command = e.editor.getCommand(featureName);
|
||||
|
||||
if (command) {
|
||||
buttonsToFeatures[command.uiItems[0].name] = featureName;
|
||||
}
|
||||
});
|
||||
|
||||
callback(features, buttonsToFeatures);
|
||||
}
|
||||
});
|
||||
|
@ -138,25 +135,27 @@
|
|||
if (!featureName) {
|
||||
featureName = button.toLowerCase();
|
||||
}
|
||||
|
||||
var featuresMetadata = this.model.get('featuresMetadata');
|
||||
|
||||
if (!featuresMetadata[featureName]) {
|
||||
featuresMetadata[featureName] = new Drupal.EditorFeature(featureName);
|
||||
this.model.set('featuresMetadata', featuresMetadata);
|
||||
}
|
||||
|
||||
return featuresMetadata[featureName];
|
||||
},
|
||||
disableFeaturesDisallowedByFilters: function disableFeaturesDisallowedByFilters(features, buttonsToFeatures) {
|
||||
this.model.set('featuresMetadata', features);
|
||||
|
||||
this.model.set('buttonsToFeatures', buttonsToFeatures);
|
||||
|
||||
this.broadcastConfigurationChanges(this.$el);
|
||||
|
||||
var existingButtons = [];
|
||||
|
||||
var buttonGroups = _.flatten(this.model.get('activeEditorConfig'));
|
||||
|
||||
for (var i = 0; i < buttonGroups.length; i++) {
|
||||
var buttons = buttonGroups[i].items;
|
||||
|
||||
for (var k = 0; k < buttons.length; k++) {
|
||||
existingButtons.push(buttons[k]);
|
||||
}
|
||||
|
@ -175,9 +174,12 @@
|
|||
if (Drupal.editorConfiguration.featureIsAllowedByFilters(feature)) {
|
||||
this.$el.find('.ckeditor-toolbar-active').trigger('CKEditorToolbarChanged', ['added', existingButtons[n]]);
|
||||
} else {
|
||||
$('.ckeditor-toolbar-active li[data-drupal-ckeditor-button-name="' + button + '"]').detach().appendTo('.ckeditor-toolbar-disabled > .ckeditor-toolbar-available > ul');
|
||||
|
||||
this.model.set({ isDirty: true }, { broadcast: false });
|
||||
$(".ckeditor-toolbar-active li[data-drupal-ckeditor-button-name=\"".concat(button, "\"]")).detach().appendTo('.ckeditor-toolbar-disabled > .ckeditor-toolbar-available > ul');
|
||||
this.model.set({
|
||||
isDirty: true
|
||||
}, {
|
||||
broadcast: false
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -199,31 +201,27 @@
|
|||
Object.keys(settingsChanges || {}).forEach(function (key) {
|
||||
hiddenEditorConfig[key] = settingsChanges[key];
|
||||
});
|
||||
|
||||
getCKEditorFeatures(hiddenEditorConfig, function (features) {
|
||||
var featuresMetadata = view.model.get('featuresMetadata');
|
||||
Object.keys(features || {}).forEach(function (name) {
|
||||
var feature = features[name];
|
||||
|
||||
if (featuresMetadata.hasOwnProperty(name) && !_.isEqual(featuresMetadata[name], feature)) {
|
||||
Drupal.editorConfiguration.modifiedFeature(feature);
|
||||
}
|
||||
});
|
||||
|
||||
view.model.set('featuresMetadata', features);
|
||||
});
|
||||
});
|
||||
},
|
||||
getButtonList: function getButtonList(config) {
|
||||
var buttons = [];
|
||||
|
||||
config = _.flatten(config);
|
||||
|
||||
config.forEach(function (group) {
|
||||
group.items.forEach(function (button) {
|
||||
buttons.push(button);
|
||||
});
|
||||
});
|
||||
|
||||
return _.without(buttons, '-');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -26,13 +26,12 @@
|
|||
var $button = $target.parent();
|
||||
var $container = $button.parent();
|
||||
var $group = $button.closest('.ckeditor-toolbar-group');
|
||||
var $row = void 0;
|
||||
var $row;
|
||||
var containerType = $container.data('drupal-ckeditor-button-sorting');
|
||||
var $availableButtons = this.$el.find('[data-drupal-ckeditor-button-sorting="source"]');
|
||||
var $activeButtons = this.$el.find('.ckeditor-toolbar-active');
|
||||
|
||||
var $originalGroup = $group;
|
||||
var dir = void 0;
|
||||
var dir;
|
||||
|
||||
if (containerType === 'source') {
|
||||
if (_.indexOf([40, 63233], event.keyCode) > -1) {
|
||||
|
@ -42,11 +41,13 @@
|
|||
if (_.indexOf(leftRightKeys, event.keyCode) > -1) {
|
||||
var $siblings = $container.children();
|
||||
var index = $siblings.index($button);
|
||||
|
||||
if (_.indexOf([37, 63234], event.keyCode) > -1) {
|
||||
if (index > 0) {
|
||||
$button.insertBefore($container.children().eq(index - 1));
|
||||
} else {
|
||||
$group = $container.parent().prev();
|
||||
|
||||
if ($group.length > 0) {
|
||||
$group.find('.ckeditor-toolbar-group-buttons').append($button);
|
||||
} else {
|
||||
|
@ -67,7 +68,6 @@
|
|||
if (dir === 'prev' && $row.length === 0) {
|
||||
if ($button.data('drupal-ckeditor-type') === 'separator') {
|
||||
$button.off().remove();
|
||||
|
||||
$activeButtons.find('.ckeditor-toolbar-group-buttons').eq(0).children().eq(0).children().trigger('focus');
|
||||
} else {
|
||||
$availableButtons.prepend($button);
|
||||
|
@ -85,7 +85,6 @@
|
|||
}
|
||||
|
||||
view = this;
|
||||
|
||||
Drupal.ckeditor.registerButtonMove(this, $button, function (result) {
|
||||
if (!result && $originalGroup) {
|
||||
$originalGroup.find('.ckeditor-buttons').append($button);
|
||||
|
@ -93,7 +92,6 @@
|
|||
|
||||
$target.trigger('focus');
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
@ -104,7 +102,6 @@
|
|||
|
||||
if (event.keyCode === 13) {
|
||||
var view = this;
|
||||
|
||||
window.setTimeout(function () {
|
||||
Drupal.ckeditor.openGroupNameDialog(view, $(event.currentTarget));
|
||||
}, 0);
|
||||
|
@ -116,8 +113,8 @@
|
|||
var $group = $(event.currentTarget);
|
||||
var $container = $group.parent();
|
||||
var $siblings = $container.children();
|
||||
var index = void 0;
|
||||
var dir = void 0;
|
||||
var index;
|
||||
var dir;
|
||||
|
||||
if (_.indexOf(leftRightKeys, event.keyCode) > -1) {
|
||||
index = $siblings.index($group);
|
||||
|
|
|
@ -12,33 +12,32 @@
|
|||
'click .ckeditor-groupnames-toggle': 'onGroupNamesToggleClick',
|
||||
'click .ckeditor-add-new-group button': 'onAddGroupButtonClick'
|
||||
},
|
||||
|
||||
initialize: function initialize() {
|
||||
this.listenTo(this.model, 'change:isDirty change:groupNamesVisible', this.render);
|
||||
|
||||
$(Drupal.theme('ckeditorButtonGroupNamesToggle')).prependTo(this.$el.find('#ckeditor-active-toolbar').parent());
|
||||
|
||||
this.render();
|
||||
},
|
||||
render: function render(model, value, changedAttributes) {
|
||||
this.insertPlaceholders();
|
||||
this.applySorting();
|
||||
|
||||
var groupNamesVisible = this.model.get('groupNamesVisible');
|
||||
|
||||
if (changedAttributes && changedAttributes.changes && changedAttributes.changes.isDirty) {
|
||||
this.model.set({ groupNamesVisible: true }, { silent: true });
|
||||
this.model.set({
|
||||
groupNamesVisible: true
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
groupNamesVisible = true;
|
||||
}
|
||||
|
||||
this.$el.find('[data-toolbar="active"]').toggleClass('ckeditor-group-names-are-visible', groupNamesVisible);
|
||||
this.$el.find('.ckeditor-groupnames-toggle').text(groupNamesVisible ? Drupal.t('Hide group names') : Drupal.t('Show group names')).attr('aria-pressed', groupNamesVisible);
|
||||
|
||||
return this;
|
||||
},
|
||||
onGroupNameClick: function onGroupNameClick(event) {
|
||||
var $group = $(event.currentTarget).closest('.ckeditor-toolbar-group');
|
||||
Drupal.ckeditor.openGroupNameDialog(this, $group);
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
},
|
||||
|
@ -50,13 +49,11 @@
|
|||
function insertNewGroup(success, $group) {
|
||||
if (success) {
|
||||
$group.appendTo($(event.currentTarget).closest('.ckeditor-row').children('.ckeditor-toolbar-groups'));
|
||||
|
||||
$group.trigger('focus');
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.ckeditor.openGroupNameDialog(this, $(Drupal.theme('ckeditorToolbarGroup')), insertNewGroup);
|
||||
|
||||
event.preventDefault();
|
||||
},
|
||||
endGroupDrag: function endGroupDrag(event) {
|
||||
|
@ -65,12 +62,10 @@
|
|||
},
|
||||
startButtonDrag: function startButtonDrag(event) {
|
||||
this.$el.find('a:focus').trigger('blur');
|
||||
|
||||
this.model.set('groupNamesVisible', true);
|
||||
},
|
||||
endButtonDrag: function endButtonDrag(event) {
|
||||
var $item = $(event.item);
|
||||
|
||||
Drupal.ckeditor.registerButtonMove(this, $item, function (success) {
|
||||
$item.find('a').trigger('focus');
|
||||
});
|
||||
|
@ -87,7 +82,6 @@
|
|||
onEnd: _this.endButtonDrag.bind(_this)
|
||||
});
|
||||
});
|
||||
|
||||
Array.prototype.forEach.call(this.el.querySelectorAll('.ckeditor-toolbar-groups:not(.js-sortable)'), function (buttons) {
|
||||
buttons.classList.add('js-sortable');
|
||||
Sortable.create(buttons, {
|
||||
|
@ -95,7 +89,6 @@
|
|||
onEnd: _this.endGroupDrag.bind(_this)
|
||||
});
|
||||
});
|
||||
|
||||
Array.prototype.forEach.call(this.el.querySelectorAll('.ckeditor-multiple-buttons:not(.js-sortable)'), function (buttons) {
|
||||
buttons.classList.add('js-sortable');
|
||||
Sortable.create(buttons, {
|
||||
|
@ -119,12 +112,12 @@
|
|||
}
|
||||
|
||||
$rows = this.$el.find('.ckeditor-row');
|
||||
|
||||
var len = $rows.length;
|
||||
$rows.filter(function (index, row) {
|
||||
if (index + 1 === len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $(row).find('.ckeditor-toolbar-group').not('.placeholder').length === 0;
|
||||
}).remove();
|
||||
},
|
||||
|
@ -133,6 +126,7 @@
|
|||
var $row = $(this);
|
||||
var $groups = $row.find('.ckeditor-toolbar-group');
|
||||
var $button = $row.find('.ckeditor-add-new-group');
|
||||
|
||||
if ($button.length === 0) {
|
||||
$row.children('.ckeditor-toolbar-groups').append(Drupal.theme('ckeditorNewButtonGroup'));
|
||||
} else if (!$groups.eq(-1).hasClass('ckeditor-add-new-group')) {
|
||||
|
|
|
@ -8,27 +8,25 @@
|
|||
(function ($, Drupal) {
|
||||
Drupal.behaviors.color = {
|
||||
attach: function attach(context, settings) {
|
||||
var i = void 0;
|
||||
var j = void 0;
|
||||
var colors = void 0;
|
||||
|
||||
var i;
|
||||
var j;
|
||||
var colors;
|
||||
var form = $(context).find('#system-theme-settings .color-form').once('color');
|
||||
|
||||
if (form.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var inputs = [];
|
||||
var hooks = [];
|
||||
var locks = [];
|
||||
var focused = null;
|
||||
|
||||
$('<div class="color-placeholder"></div>').once('color').prependTo(form);
|
||||
var farb = $.farbtastic('.color-placeholder');
|
||||
|
||||
var reference = settings.color.reference;
|
||||
Object.keys(reference || {}).forEach(function (color) {
|
||||
reference[color] = farb.RGBToHSL(farb.unpack(reference[color]));
|
||||
});
|
||||
|
||||
var height = [];
|
||||
var width = [];
|
||||
|
||||
|
@ -43,16 +41,15 @@
|
|||
}
|
||||
|
||||
function shiftColor(given, ref1, ref2) {
|
||||
var d = void 0;
|
||||
|
||||
var d;
|
||||
given = farb.RGBToHSL(farb.unpack(given));
|
||||
|
||||
given[0] += ref2[0] - ref1[0];
|
||||
|
||||
if (ref1[1] === 0 || ref2[1] === 0) {
|
||||
given[1] = ref2[1];
|
||||
} else {
|
||||
d = ref1[1] / ref2[1];
|
||||
|
||||
if (d > 1) {
|
||||
given[1] /= d;
|
||||
} else {
|
||||
|
@ -64,6 +61,7 @@
|
|||
given[2] = ref2[2];
|
||||
} else {
|
||||
d = ref1[2] / ref2[2];
|
||||
|
||||
if (d > 1) {
|
||||
given[2] /= d;
|
||||
} else {
|
||||
|
@ -75,8 +73,7 @@
|
|||
}
|
||||
|
||||
function callback(input, color, propagate, colorScheme) {
|
||||
var matched = void 0;
|
||||
|
||||
var matched;
|
||||
$(input).css({
|
||||
backgroundColor: color,
|
||||
color: farb.RGBToHSL(farb.unpack(color))[2] > 0.5 ? '#000' : '#fff'
|
||||
|
@ -87,17 +84,21 @@
|
|||
|
||||
if (propagate) {
|
||||
i = input.i;
|
||||
|
||||
for (j = i + 1;; ++j) {
|
||||
if (!locks[j - 1] || $(locks[j - 1]).is('.is-unlocked')) {
|
||||
break;
|
||||
}
|
||||
|
||||
matched = shiftColor(color, reference[input.key], reference[inputs[j].key]);
|
||||
callback(inputs[j], matched, false);
|
||||
}
|
||||
|
||||
for (j = i - 1;; --j) {
|
||||
if (!locks[j] || $(locks[j]).is('.is-unlocked')) {
|
||||
break;
|
||||
}
|
||||
|
||||
matched = shiftColor(color, reference[input.key], reference[inputs[j].key]);
|
||||
callback(inputs[j], matched, false);
|
||||
}
|
||||
|
@ -112,25 +113,23 @@
|
|||
}
|
||||
|
||||
Object.keys(settings.gradients || {}).forEach(function (i) {
|
||||
$('.color-preview').once('color').append('<div id="gradient-' + i + '"></div>');
|
||||
var gradient = $('.color-preview #gradient-' + i);
|
||||
|
||||
$('.color-preview').once('color').append("<div id=\"gradient-".concat(i, "\"></div>"));
|
||||
var gradient = $(".color-preview #gradient-".concat(i));
|
||||
height.push(parseInt(gradient.css('height'), 10) / 10);
|
||||
|
||||
width.push(parseInt(gradient.css('width'), 10) / 10);
|
||||
|
||||
for (j = 0; j < (settings.gradients[i].direction === 'vertical' ? height[i] : width[i]); ++j) {
|
||||
gradient.append('<div class="gradient-line"></div>');
|
||||
}
|
||||
});
|
||||
|
||||
form.find('#edit-scheme').on('change', function () {
|
||||
var schemes = settings.color.schemes;
|
||||
var colorScheme = this.options[this.selectedIndex].value;
|
||||
|
||||
if (colorScheme !== '' && schemes[colorScheme]) {
|
||||
colors = schemes[colorScheme];
|
||||
Object.keys(colors || {}).forEach(function (fieldName) {
|
||||
callback($('#edit-palette-' + fieldName), colors[fieldName], false, true);
|
||||
callback($("#edit-palette-".concat(fieldName)), colors[fieldName], false, true);
|
||||
});
|
||||
preview();
|
||||
}
|
||||
|
@ -153,14 +152,14 @@
|
|||
|
||||
form.find('.js-color-palette input.form-text').each(function () {
|
||||
this.key = this.id.substring(13);
|
||||
|
||||
farb.linkTo(function () {}).setColor('#000').linkTo(this);
|
||||
|
||||
var i = inputs.length;
|
||||
|
||||
if (inputs.length) {
|
||||
var toggleClick = true;
|
||||
var lock = $('<button class="color-palette__lock">' + Drupal.t('Unlock') + '</button>').on('click', function (e) {
|
||||
var lock = $("<button class=\"color-palette__lock\">".concat(Drupal.t('Unlock'), "</button>")).on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (toggleClick) {
|
||||
$(this).addClass('is-unlocked').html(Drupal.t('Lock'));
|
||||
$(hooks[i - 1]).attr('class', locks[i - 2] && $(locks[i - 2]).is(':not(.is-unlocked)') ? 'color-palette__hook is-up' : 'color-palette__hook');
|
||||
|
@ -170,6 +169,7 @@
|
|||
$(hooks[i - 1]).attr('class', locks[i - 2] && $(locks[i - 2]).is(':not(.is-unlocked)') ? 'color-palette__hook is-both' : 'color-palette__hook is-down');
|
||||
$(hooks[i]).attr('class', locks[i] && $(locks[i]).is(':not(.is-unlocked)') ? 'color-palette__hook is-both' : 'color-palette__hook is-up');
|
||||
}
|
||||
|
||||
toggleClick = !toggleClick;
|
||||
});
|
||||
$(this).after(lock);
|
||||
|
@ -179,16 +179,12 @@
|
|||
var hook = $('<div class="color-palette__hook"></div>');
|
||||
$(this).after(hook);
|
||||
hooks.push(hook);
|
||||
|
||||
$(this).parent().find('.color-palette__lock').trigger('click');
|
||||
this.i = i;
|
||||
inputs.push(this);
|
||||
}).on('focus', focus);
|
||||
|
||||
form.find('.js-color-palette label');
|
||||
|
||||
inputs[0].focus();
|
||||
|
||||
preview();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -65,18 +65,14 @@
|
|||
colorStart = farb.unpack(
|
||||
form
|
||||
.find(
|
||||
`.color-palette input[name="palette[${
|
||||
settings.gradients[i].colors[0]
|
||||
}]"]`,
|
||||
`.color-palette input[name="palette[${settings.gradients[i].colors[0]}]"]`,
|
||||
)
|
||||
.val(),
|
||||
);
|
||||
colorEnd = farb.unpack(
|
||||
form
|
||||
.find(
|
||||
`.color-palette input[name="palette[${
|
||||
settings.gradients[i].colors[1]
|
||||
}]"]`,
|
||||
`.color-palette input[name="palette[${settings.gradients[i].colors[1]}]"]`,
|
||||
)
|
||||
.val(),
|
||||
);
|
||||
|
|
|
@ -8,11 +8,9 @@
|
|||
(function ($, Drupal) {
|
||||
Drupal.color = {
|
||||
callback: function callback(context, settings, form, farb, height, width) {
|
||||
var accum = void 0;
|
||||
var delta = void 0;
|
||||
|
||||
var accum;
|
||||
var delta;
|
||||
form.find('.color-preview').css('backgroundColor', form.find('.color-palette input[name="palette[base]"]').val());
|
||||
|
||||
form.find('#text').css('color', form.find('.color-palette input[name="palette[text]"]').val());
|
||||
form.find('#text a, #text h2').css('color', form.find('.color-palette input[name="palette[link]"]').val());
|
||||
|
||||
|
@ -23,19 +21,19 @@
|
|||
element.style.backgroundColor = farb.pack(accum);
|
||||
}
|
||||
|
||||
var colorStart = void 0;
|
||||
var colorEnd = void 0;
|
||||
var colorStart;
|
||||
var colorEnd;
|
||||
Object.keys(settings.gradients || {}).forEach(function (i) {
|
||||
colorStart = farb.unpack(form.find('.color-palette input[name="palette[' + settings.gradients[i].colors[0] + ']"]').val());
|
||||
colorEnd = farb.unpack(form.find('.color-palette input[name="palette[' + settings.gradients[i].colors[1] + ']"]').val());
|
||||
colorStart = farb.unpack(form.find(".color-palette input[name=\"palette[".concat(settings.gradients[i].colors[0], "]\"]")).val());
|
||||
colorEnd = farb.unpack(form.find(".color-palette input[name=\"palette[".concat(settings.gradients[i].colors[1], "]\"]")).val());
|
||||
|
||||
if (colorStart && colorEnd) {
|
||||
delta = [];
|
||||
Object.keys(colorStart || {}).forEach(function (colorStartKey) {
|
||||
delta[colorStartKey] = (colorEnd[colorStartKey] - colorStart[colorStartKey]) / (settings.gradients[i].vertical ? height[i] : width[i]);
|
||||
});
|
||||
accum = colorStart;
|
||||
|
||||
form.find('#gradient-' + i + ' > div').each(gradientLineColor);
|
||||
form.find("#gradient-".concat(i, " > div")).each(gradientLineColor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
function processCommentNewIndicators($placeholders) {
|
||||
var isFirstNewComment = true;
|
||||
var newCommentString = Drupal.t('new');
|
||||
var $placeholder = void 0;
|
||||
|
||||
var $placeholder;
|
||||
$placeholders.each(function (index, placeholder) {
|
||||
$placeholder = $(placeholder);
|
||||
var timestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10);
|
||||
|
@ -40,6 +39,7 @@
|
|||
var $placeholder = $(this);
|
||||
var commentTimestamp = parseInt($placeholder.attr('data-comment-timestamp'), 10);
|
||||
var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id');
|
||||
|
||||
if (Drupal.history.needsServerCheck(nodeID, commentTimestamp)) {
|
||||
nodeIDs.push(nodeID);
|
||||
return true;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
function processNodeNewCommentLinks($placeholders) {
|
||||
var $placeholdersToUpdate = {};
|
||||
var fieldName = 'comment';
|
||||
var $placeholder = void 0;
|
||||
var $placeholder;
|
||||
$placeholders.each(function (index, placeholder) {
|
||||
$placeholder = $(placeholder);
|
||||
var timestamp = parseInt($placeholder.attr('data-history-node-last-comment-timestamp'), 10);
|
||||
|
@ -35,8 +35,8 @@
|
|||
remove($placeholder);
|
||||
}
|
||||
});
|
||||
|
||||
var nodeIDs = Object.keys($placeholdersToUpdate);
|
||||
|
||||
if (nodeIDs.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -56,7 +56,10 @@
|
|||
$.ajax({
|
||||
url: Drupal.url('comments/render_new_comments_node_links'),
|
||||
type: 'POST',
|
||||
data: { 'node_ids[]': nodeIDs, field_name: fieldName },
|
||||
data: {
|
||||
'node_ids[]': nodeIDs,
|
||||
field_name: fieldName
|
||||
},
|
||||
dataType: 'json',
|
||||
success: render
|
||||
});
|
||||
|
@ -70,9 +73,9 @@
|
|||
var $placeholder = $(this);
|
||||
var lastCommentTimestamp = parseInt($placeholder.attr('data-history-node-last-comment-timestamp'), 10);
|
||||
var nodeID = $placeholder.closest('[data-history-node-id]').attr('data-history-node-id');
|
||||
|
||||
if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) {
|
||||
nodeIDs.push(nodeID);
|
||||
|
||||
hide($placeholder);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
attach: function attach(context) {
|
||||
var $context = $(context);
|
||||
var options = drupalSettings.contentTranslationDependentOptions;
|
||||
var $fields = void 0;
|
||||
var $fields;
|
||||
|
||||
function fieldsChangeHandler($fields, dependentColumns) {
|
||||
return function (e) {
|
||||
|
@ -20,9 +20,8 @@
|
|||
|
||||
if (options && options.dependent_selectors) {
|
||||
Object.keys(options.dependent_selectors).forEach(function (field) {
|
||||
$fields = $context.find('input[name^="' + field + '"]');
|
||||
$fields = $context.find("input[name^=\"".concat(field, "\"]"));
|
||||
var dependentColumns = options.dependent_selectors[field];
|
||||
|
||||
$fields.on('change', fieldsChangeHandler($fields, dependentColumns));
|
||||
Drupal.behaviors.contentTranslationDependentOptions.check($fields, dependentColumns);
|
||||
});
|
||||
|
@ -30,7 +29,7 @@
|
|||
},
|
||||
check: function check($fields, dependentColumns, $changed) {
|
||||
var $element = $changed;
|
||||
var column = void 0;
|
||||
var column;
|
||||
|
||||
function filterFieldsList(index, field) {
|
||||
return $(field).val() === column;
|
||||
|
@ -43,7 +42,7 @@
|
|||
$element = $fields.filter(filterFieldsList);
|
||||
}
|
||||
|
||||
if ($element.is('input[value="' + column + '"]:checked')) {
|
||||
if ($element.is("input[value=\"".concat(column, "\"]:checked"))) {
|
||||
$fields.prop('checked', true).not($element).prop('disabled', true);
|
||||
} else {
|
||||
$fields.prop('disabled', false);
|
||||
|
@ -51,24 +50,24 @@
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.contentTranslation = {
|
||||
attach: function attach(context) {
|
||||
$(context).find('table .bundle-settings .translatable :input').once('translation-entity-admin-hide').each(function () {
|
||||
var $input = $(this);
|
||||
var $bundleSettings = $input.closest('.bundle-settings');
|
||||
|
||||
if (!$input.is(':checked')) {
|
||||
$bundleSettings.nextUntil('.bundle-settings').hide();
|
||||
} else {
|
||||
$bundleSettings.nextUntil('.bundle-settings', '.field-settings').find('.translatable :input:not(:checked)').closest('.field-settings').nextUntil(':not(.column-settings)').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('body').once('translation-entity-admin-bind').on('click', 'table .bundle-settings .translatable :input', function (e) {
|
||||
var $target = $(e.target);
|
||||
var $bundleSettings = $target.closest('.bundle-settings');
|
||||
var $settings = $bundleSettings.nextUntil('.bundle-settings');
|
||||
var $fieldSettings = $settings.filter('.field-settings');
|
||||
|
||||
if ($target.is(':checked')) {
|
||||
$bundleSettings.find('.operations :input[name$="[language_alterable]"]').prop('checked', true);
|
||||
$fieldSettings.find('.translatable :input').prop('checked', true);
|
||||
|
@ -80,6 +79,7 @@
|
|||
var $target = $(e.target);
|
||||
var $fieldSettings = $target.closest('.field-settings');
|
||||
var $columnSettings = $fieldSettings.nextUntil('.field-settings, .bundle-settings');
|
||||
|
||||
if ($target.is(':checked')) {
|
||||
$columnSettings.show();
|
||||
} else {
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
close: Drupal.t('Close')
|
||||
}
|
||||
});
|
||||
|
||||
var cachedPermissionsHash = storage.getItem('Drupal.contextual.permissionsHash');
|
||||
var permissionsHash = drupalSettings.user.permissionsHash;
|
||||
|
||||
if (cachedPermissionsHash !== permissionsHash) {
|
||||
if (typeof permissionsHash === 'string') {
|
||||
_.chain(storage).keys().each(function (key) {
|
||||
|
@ -23,6 +23,7 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
storage.setItem('Drupal.contextual.permissionsHash', permissionsHash);
|
||||
}
|
||||
|
||||
|
@ -35,60 +36,60 @@
|
|||
|
||||
var firstTop = $contextuals.eq(0).offset().top;
|
||||
var secondTop = $contextuals.eq(1).offset().top;
|
||||
|
||||
if (firstTop === secondTop) {
|
||||
var $nestedContextual = $contextuals.eq(1);
|
||||
|
||||
var height = 0;
|
||||
var $trigger = $nestedContextual.find('.trigger');
|
||||
|
||||
$trigger.removeClass('visually-hidden');
|
||||
height = $nestedContextual.height();
|
||||
$trigger.addClass('visually-hidden');
|
||||
|
||||
$nestedContextual.css({ top: $nestedContextual.position().top + height });
|
||||
$nestedContextual.css({
|
||||
top: $nestedContextual.position().top + height
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initContextual($contextual, html) {
|
||||
var $region = $contextual.closest('.contextual-region');
|
||||
var contextual = Drupal.contextual;
|
||||
|
||||
$contextual.html(html).addClass('contextual').prepend(Drupal.theme('contextualTrigger'));
|
||||
|
||||
var destination = 'destination=' + Drupal.encodePath(Drupal.url(drupalSettings.path.currentPath));
|
||||
var destination = "destination=".concat(Drupal.encodePath(Drupal.url(drupalSettings.path.currentPath)));
|
||||
$contextual.find('.contextual-links a').each(function () {
|
||||
var url = this.getAttribute('href');
|
||||
var glue = url.indexOf('?') === -1 ? '?' : '&';
|
||||
this.setAttribute('href', url + glue + destination);
|
||||
});
|
||||
|
||||
var model = new contextual.StateModel({
|
||||
title: $region.find('h2').eq(0).text().trim()
|
||||
});
|
||||
var viewOptions = $.extend({ el: $contextual, model: model }, options);
|
||||
var viewOptions = $.extend({
|
||||
el: $contextual,
|
||||
model: model
|
||||
}, options);
|
||||
contextual.views.push({
|
||||
visual: new contextual.VisualView(viewOptions),
|
||||
aural: new contextual.AuralView(viewOptions),
|
||||
keyboard: new contextual.KeyboardView(viewOptions)
|
||||
});
|
||||
contextual.regionViews.push(new contextual.RegionView($.extend({ el: $region, model: model }, options)));
|
||||
|
||||
contextual.regionViews.push(new contextual.RegionView($.extend({
|
||||
el: $region,
|
||||
model: model
|
||||
}, options)));
|
||||
contextual.collection.add(model);
|
||||
|
||||
$(document).trigger('drupalContextualLinkAdded', {
|
||||
$el: $contextual,
|
||||
$region: $region,
|
||||
model: model
|
||||
});
|
||||
|
||||
adjustIfNestedAndOverlapping($contextual);
|
||||
}
|
||||
|
||||
Drupal.behaviors.contextual = {
|
||||
attach: function attach(context) {
|
||||
var $context = $(context);
|
||||
|
||||
var $placeholders = $context.find('[data-contextual-id]').once('contextual-render');
|
||||
|
||||
if ($placeholders.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -100,17 +101,18 @@
|
|||
token: $(this).attr('data-contextual-token')
|
||||
});
|
||||
});
|
||||
|
||||
var uncachedIDs = [];
|
||||
var uncachedTokens = [];
|
||||
ids.forEach(function (contextualID) {
|
||||
var html = storage.getItem('Drupal.contextual.' + contextualID.id);
|
||||
var html = storage.getItem("Drupal.contextual.".concat(contextualID.id));
|
||||
|
||||
if (html && html.length) {
|
||||
window.setTimeout(function () {
|
||||
initContextual($context.find('[data-contextual-id="' + contextualID.id + '"]'), html);
|
||||
initContextual($context.find("[data-contextual-id=\"".concat(contextualID.id, "\"]")), html);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
uncachedIDs.push(contextualID.id);
|
||||
uncachedTokens.push(contextualID.token);
|
||||
});
|
||||
|
@ -119,14 +121,17 @@
|
|||
$.ajax({
|
||||
url: Drupal.url('contextual/render'),
|
||||
type: 'POST',
|
||||
data: { 'ids[]': uncachedIDs, 'tokens[]': uncachedTokens },
|
||||
data: {
|
||||
'ids[]': uncachedIDs,
|
||||
'tokens[]': uncachedTokens
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function success(results) {
|
||||
_.each(results, function (html, contextualID) {
|
||||
storage.setItem('Drupal.contextual.' + contextualID, html);
|
||||
storage.setItem("Drupal.contextual.".concat(contextualID), html);
|
||||
|
||||
if (html.length > 0) {
|
||||
$placeholders = $context.find('[data-contextual-id="' + contextualID + '"]');
|
||||
$placeholders = $context.find("[data-contextual-id=\"".concat(contextualID, "\"]"));
|
||||
|
||||
for (var i = 0; i < $placeholders.length; i++) {
|
||||
initContextual($placeholders.eq(i), html);
|
||||
|
@ -138,13 +143,10 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.contextual = {
|
||||
views: [],
|
||||
|
||||
regionViews: []
|
||||
};
|
||||
|
||||
Drupal.contextual.collection = new Backbone.Collection([], {
|
||||
model: Drupal.contextual.StateModel
|
||||
});
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
}, {
|
||||
contextualCollection: Drupal.contextual.collection
|
||||
});
|
||||
|
||||
var viewOptions = {
|
||||
el: $('.toolbar .toolbar-bar .contextual-toolbar-tab'),
|
||||
model: contextualToolbar.model,
|
||||
|
@ -40,7 +39,6 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.contextualToolbar = {
|
||||
model: null
|
||||
};
|
||||
|
|
|
@ -9,22 +9,19 @@
|
|||
Drupal.contextual.StateModel = Backbone.Model.extend({
|
||||
defaults: {
|
||||
title: '',
|
||||
|
||||
regionIsHovered: false,
|
||||
|
||||
hasFocus: false,
|
||||
|
||||
isOpen: false,
|
||||
|
||||
isLocked: false
|
||||
},
|
||||
|
||||
toggleOpen: function toggleOpen() {
|
||||
var newIsOpen = !this.get('isOpen');
|
||||
this.set('isOpen', newIsOpen);
|
||||
|
||||
if (newIsOpen) {
|
||||
this.focus();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
close: function close() {
|
||||
|
@ -45,6 +42,7 @@
|
|||
if (!this.get('isOpen')) {
|
||||
this.set('hasFocus', false);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -9,20 +9,14 @@
|
|||
Drupal.contextualToolbar.StateModel = Backbone.Model.extend({
|
||||
defaults: {
|
||||
isViewing: true,
|
||||
|
||||
isVisible: false,
|
||||
|
||||
contextualCount: 0,
|
||||
|
||||
tabbingContext: null
|
||||
},
|
||||
|
||||
initialize: function initialize(attrs, options) {
|
||||
this.listenTo(options.contextualCollection, 'reset remove add', this.countContextualLinks);
|
||||
this.listenTo(options.contextualCollection, 'add', this.lockNewContextualLinks);
|
||||
|
||||
this.listenTo(this, 'change:contextualCount', this.updateVisibility);
|
||||
|
||||
this.listenTo(this, 'change:isViewing', function (model, isViewing) {
|
||||
options.contextualCollection.each(function (contextualModel) {
|
||||
contextualModel.set('isLocked', !isViewing);
|
||||
|
|
|
@ -8,19 +8,15 @@
|
|||
(function ($, Drupal, Backbone, _) {
|
||||
Drupal.contextualToolbar.AuralView = Backbone.View.extend({
|
||||
announcedOnce: false,
|
||||
|
||||
initialize: function initialize(options) {
|
||||
this.options = options;
|
||||
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
this.listenTo(this.model, 'change:isViewing', this.manageTabbing);
|
||||
|
||||
$(document).on('keyup', _.bind(this.onKeypress, this));
|
||||
this.manageTabbing();
|
||||
},
|
||||
render: function render() {
|
||||
this.$el.find('button').attr('aria-pressed', !this.model.get('isViewing'));
|
||||
|
||||
return this;
|
||||
},
|
||||
manageTabbing: function manageTabbing() {
|
||||
|
@ -30,6 +26,7 @@
|
|||
if (tabbingContext.active) {
|
||||
Drupal.announce(this.options.strings.tabbingReleased);
|
||||
}
|
||||
|
||||
tabbingContext.release();
|
||||
}
|
||||
|
||||
|
@ -50,7 +47,6 @@
|
|||
onKeypress: function onKeypress(event) {
|
||||
if (!this.announcedOnce && event.keyCode === 9 && !this.model.get('isViewing')) {
|
||||
this.announceTabbingConstraint();
|
||||
|
||||
this.announcedOnce = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
click: function click() {
|
||||
this.model.set('isViewing', !this.model.get('isViewing'));
|
||||
},
|
||||
|
||||
touchend: touchEndToClick
|
||||
};
|
||||
},
|
||||
|
@ -27,9 +26,7 @@
|
|||
},
|
||||
render: function render() {
|
||||
this.$el.toggleClass('hidden', !this.model.get('isVisible'));
|
||||
|
||||
this.$el.find('button').toggleClass('is-active', !this.model.get('isViewing'));
|
||||
|
||||
return this;
|
||||
},
|
||||
persist: function persist(model, isViewing) {
|
||||
|
|
|
@ -9,16 +9,12 @@
|
|||
Drupal.contextual.AuralView = Backbone.View.extend({
|
||||
initialize: function initialize(options) {
|
||||
this.options = options;
|
||||
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
|
||||
this.render();
|
||||
},
|
||||
render: function render() {
|
||||
var isOpen = this.model.get('isOpen');
|
||||
|
||||
this.$el.find('.contextual-links').prop('hidden', !isOpen);
|
||||
|
||||
this.$el.find('.trigger').text(Drupal.t('@action @title configuration options', {
|
||||
'@action': !isOpen ? this.options.strings.open : this.options.strings.close,
|
||||
'@title': this.model.get('title')
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
}, 150);
|
||||
}
|
||||
},
|
||||
|
||||
initialize: function initialize() {
|
||||
this.timer = NaN;
|
||||
},
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
if (Modernizr.touchevents) {
|
||||
mapping = {};
|
||||
}
|
||||
|
||||
return mapping;
|
||||
},
|
||||
initialize: function initialize() {
|
||||
|
@ -27,7 +28,6 @@
|
|||
},
|
||||
render: function render() {
|
||||
this.$el.toggleClass('focus', this.model.get('hasFocus'));
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
event.preventDefault();
|
||||
event.target.click();
|
||||
};
|
||||
|
||||
var mapping = {
|
||||
'click .trigger': function clickTrigger() {
|
||||
this.model.toggleOpen();
|
||||
|
@ -28,6 +29,7 @@
|
|||
this.model.focus();
|
||||
};
|
||||
}
|
||||
|
||||
return mapping;
|
||||
},
|
||||
initialize: function initialize() {
|
||||
|
@ -35,9 +37,7 @@
|
|||
},
|
||||
render: function render() {
|
||||
var isOpen = this.model.get('isOpen');
|
||||
|
||||
var isVisible = this.model.get('isLocked') || this.model.get('regionIsHovered') || isOpen;
|
||||
|
||||
this.$el.toggleClass('open', isOpen).find('.trigger').toggleClass('visually-hidden', !isVisible);
|
||||
|
||||
if ('isOpen' in this.model.changed) {
|
||||
|
|
|
@ -27,14 +27,12 @@
|
|||
|
||||
for (var r = 0; r < feature.rules.length; r++) {
|
||||
var featureRule = feature.rules[r];
|
||||
|
||||
var requiredTags = featureRule.required.tags;
|
||||
|
||||
for (var t = 0; t < requiredTags.length; t++) {
|
||||
universe[requiredTags[t]] = {
|
||||
tag: false,
|
||||
|
||||
touchedByAllowedPropertyRule: false,
|
||||
|
||||
touchedBytouchedByForbiddenPropertyRule: false
|
||||
};
|
||||
}
|
||||
|
@ -45,9 +43,10 @@
|
|||
|
||||
for (var p = 0; p < properties.length; p++) {
|
||||
var property = properties[p];
|
||||
|
||||
for (var pv = 0; pv < featureRule.required[property].length; pv++) {
|
||||
var propertyValue = featureRule.required[property];
|
||||
universe[requiredTags][property + ':' + propertyValue] = false;
|
||||
universe[requiredTags]["".concat(property, ":").concat(propertyValue)] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +59,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
var key = property + ':' + propertyValue;
|
||||
var key = "".concat(property, ":").concat(propertyValue);
|
||||
|
||||
if (allowing) {
|
||||
universe[tag].touchedByAllowedPropertyRule = true;
|
||||
|
@ -71,32 +70,38 @@
|
|||
if (allowing) {
|
||||
universe[tag][key] = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var atLeastOneFound = false;
|
||||
var regex = key.replace(/\*/g, '[^ ]*');
|
||||
|
||||
_.each(_.keys(universe[tag]), function (key) {
|
||||
if (key.match(regex)) {
|
||||
atLeastOneFound = true;
|
||||
|
||||
if (allowing) {
|
||||
universe[tag][key] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return atLeastOneFound;
|
||||
}
|
||||
|
||||
function findPropertyValuesOnAllTags(universe, property, propertyValues, allowing) {
|
||||
var atLeastOneFound = false;
|
||||
|
||||
_.each(_.keys(universe), function (tag) {
|
||||
if (findPropertyValuesOnTag(universe, tag, property, propertyValues, allowing)) {
|
||||
atLeastOneFound = true;
|
||||
}
|
||||
});
|
||||
|
||||
return atLeastOneFound;
|
||||
}
|
||||
|
||||
|
@ -106,21 +111,25 @@
|
|||
}
|
||||
|
||||
var atLeastOneFound = false;
|
||||
|
||||
_.each(propertyValues, function (propertyValue) {
|
||||
if (findPropertyValueOnTag(universe, tag, property, propertyValue, allowing)) {
|
||||
atLeastOneFound = true;
|
||||
}
|
||||
});
|
||||
|
||||
return atLeastOneFound;
|
||||
}
|
||||
|
||||
function deleteAllTagsFromUniverseIfAllowed(universe) {
|
||||
var atLeastOneDeleted = false;
|
||||
|
||||
_.each(_.keys(universe), function (tag) {
|
||||
if (deleteFromUniverseIfAllowed(universe, tag)) {
|
||||
atLeastOneDeleted = true;
|
||||
}
|
||||
});
|
||||
|
||||
return atLeastOneDeleted;
|
||||
}
|
||||
|
||||
|
@ -128,10 +137,12 @@
|
|||
if (tag === '*') {
|
||||
return deleteAllTagsFromUniverseIfAllowed(universe);
|
||||
}
|
||||
|
||||
if (_.has(universe, tag) && _.every(_.omit(universe[tag], 'touchedByAllowedPropertyRule'))) {
|
||||
delete universe[tag];
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -139,9 +150,12 @@
|
|||
var properties = ['attributes', 'styles', 'classes'];
|
||||
|
||||
var allRequiredTags = _.keys(universe);
|
||||
var filterRule = void 0;
|
||||
|
||||
var filterRule;
|
||||
|
||||
for (var i = 0; i < filterStatus.rules.length; i++) {
|
||||
filterRule = filterStatus.rules[i];
|
||||
|
||||
if (filterRule.allow === false) {
|
||||
if (_.intersection(allRequiredTags, filterRule.tags).length > 0) {
|
||||
return true;
|
||||
|
@ -172,14 +186,16 @@
|
|||
|
||||
function markAllowedTagsAndPropertyValues(universe, filterStatus) {
|
||||
var properties = ['attributes', 'styles', 'classes'];
|
||||
var filterRule;
|
||||
var tag;
|
||||
|
||||
var filterRule = void 0;
|
||||
var tag = void 0;
|
||||
for (var l = 0; !_.isEmpty(universe) && l < filterStatus.rules.length; l++) {
|
||||
filterRule = filterStatus.rules[l];
|
||||
|
||||
if (filterRule.allow === true) {
|
||||
for (var m = 0; !_.isEmpty(universe) && m < filterRule.tags.length; m++) {
|
||||
tag = filterRule.tags[m];
|
||||
|
||||
if (_.has(universe, tag)) {
|
||||
universe[tag].tag = true;
|
||||
deleteFromUniverseIfAllowed(universe, tag);
|
||||
|
@ -237,21 +253,21 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
var tags = _.keys(universe);
|
||||
|
||||
for (var i = 0; i < tags.length; i++) {
|
||||
var tag = tags[i];
|
||||
|
||||
if (_.has(universe, tag)) {
|
||||
if (universe[tag].touchedByAllowedPropertyRule === false) {
|
||||
delete universe[tag];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _.isEmpty(universe);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -269,14 +285,12 @@
|
|||
styles: [],
|
||||
classes: []
|
||||
};
|
||||
|
||||
this.allowed = {
|
||||
tags: [],
|
||||
attributes: [],
|
||||
styles: [],
|
||||
classes: []
|
||||
};
|
||||
|
||||
this.raw = null;
|
||||
};
|
||||
|
||||
|
@ -291,9 +305,7 @@
|
|||
|
||||
Drupal.FilterStatus = function (name) {
|
||||
this.name = name;
|
||||
|
||||
this.active = false;
|
||||
|
||||
this.rules = [];
|
||||
};
|
||||
|
||||
|
@ -304,13 +316,19 @@
|
|||
Drupal.FilterHTMLRule = function () {
|
||||
this.tags = [];
|
||||
this.allow = null;
|
||||
|
||||
this.restrictedTags = {
|
||||
tags: [],
|
||||
allowed: { attributes: [], styles: [], classes: [] },
|
||||
forbidden: { attributes: [], styles: [], classes: [] }
|
||||
allowed: {
|
||||
attributes: [],
|
||||
styles: [],
|
||||
classes: []
|
||||
},
|
||||
forbidden: {
|
||||
attributes: [],
|
||||
styles: [],
|
||||
classes: []
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
@ -330,12 +348,10 @@
|
|||
|
||||
Drupal.filterConfiguration = {
|
||||
statuses: {},
|
||||
|
||||
liveSettingParsers: {},
|
||||
|
||||
update: function update() {
|
||||
Object.keys(Drupal.filterConfiguration.statuses || {}).forEach(function (filterID) {
|
||||
Drupal.filterConfiguration.statuses[filterID].active = $('[name="filters[' + filterID + '][status]"]').is(':checked');
|
||||
Drupal.filterConfiguration.statuses[filterID].active = $("[name=\"filters[".concat(filterID, "][status]\"]")).is(':checked');
|
||||
|
||||
if (Drupal.filterConfiguration.liveSettingParsers[filterID]) {
|
||||
Drupal.filterConfiguration.statuses[filterID].rules = Drupal.filterConfiguration.liveSettingParsers[filterID].getRules();
|
||||
|
@ -343,17 +359,13 @@
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.initializeFilterConfiguration = {
|
||||
attach: function attach(context, settings) {
|
||||
var $context = $(context);
|
||||
|
||||
$context.find('#filters-status-wrapper input.form-checkbox').once('filter-editor-status').each(function () {
|
||||
var $checkbox = $(this);
|
||||
var nameAttribute = $checkbox.attr('name');
|
||||
|
||||
var filterID = nameAttribute.substring(8, nameAttribute.indexOf(']'));
|
||||
|
||||
Drupal.filterConfiguration.statuses[filterID] = new Drupal.FilterStatus(filterID);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,27 +8,23 @@
|
|||
(function ($, Drupal, drupalSettings, _) {
|
||||
Drupal.quickedit.editors.editor = Drupal.quickedit.EditorView.extend({
|
||||
textFormat: null,
|
||||
|
||||
textFormatHasTransformations: null,
|
||||
|
||||
textEditor: null,
|
||||
|
||||
$textElement: null,
|
||||
|
||||
initialize: function initialize(options) {
|
||||
Drupal.quickedit.EditorView.prototype.initialize.call(this, options);
|
||||
|
||||
var metadata = Drupal.quickedit.metadata.get(this.fieldModel.get('fieldID'), 'custom');
|
||||
this.textFormat = drupalSettings.editor.formats[metadata.format];
|
||||
this.textFormatHasTransformations = metadata.formatHasTransformations;
|
||||
this.textEditor = Drupal.editors[this.textFormat.editor];
|
||||
|
||||
var $fieldItems = this.$el.find('.quickedit-field');
|
||||
|
||||
if ($fieldItems.length) {
|
||||
this.$textElement = $fieldItems.eq(0);
|
||||
} else {
|
||||
this.$textElement = this.$el;
|
||||
}
|
||||
|
||||
this.model.set('originalValue', this.$textElement.html());
|
||||
},
|
||||
getEditedElement: function getEditedElement() {
|
||||
|
@ -38,6 +34,7 @@
|
|||
var editorModel = this.model;
|
||||
var from = fieldModel.previous('state');
|
||||
var to = state;
|
||||
|
||||
switch (to) {
|
||||
case 'inactive':
|
||||
break;
|
||||
|
@ -50,9 +47,11 @@
|
|||
if (from === 'active' && this.textFormatHasTransformations) {
|
||||
this.revert();
|
||||
}
|
||||
|
||||
if (from === 'invalid') {
|
||||
this.removeValidationErrors();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'highlighted':
|
||||
|
@ -61,6 +60,7 @@
|
|||
case 'activating':
|
||||
if (this.textFormatHasTransformations) {
|
||||
var $textElement = this.$textElement;
|
||||
|
||||
this._getUntransformedText(function (untransformedText) {
|
||||
$textElement.html(untransformedText);
|
||||
fieldModel.set('state', 'active');
|
||||
|
@ -70,6 +70,7 @@
|
|||
fieldModel.set('state', 'active');
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'active':
|
||||
|
@ -77,7 +78,6 @@
|
|||
var textElement = this.$textElement.get(0);
|
||||
var toolbarView = fieldModel.toolbarView;
|
||||
this.textEditor.attachInlineEditor(textElement, this.textFormat, toolbarView.getMainWysiwygToolgroupId(), toolbarView.getFloatedWysiwygToolgroupId());
|
||||
|
||||
this.textEditor.onChange(textElement, function (htmlText) {
|
||||
editorModel.set('currentValue', htmlText);
|
||||
fieldModel.set('state', 'changed');
|
||||
|
@ -92,6 +92,7 @@
|
|||
if (from === 'invalid') {
|
||||
this.removeValidationErrors();
|
||||
}
|
||||
|
||||
this.save();
|
||||
break;
|
||||
|
||||
|
@ -116,10 +117,11 @@
|
|||
},
|
||||
_getUntransformedText: function _getUntransformedText(callback) {
|
||||
var fieldID = this.fieldModel.get('fieldID');
|
||||
|
||||
var textLoaderAjax = Drupal.ajax({
|
||||
url: Drupal.quickedit.util.buildUrl(fieldID, Drupal.url('editor/!entity_type/!id/!field_name/!langcode/!view_mode')),
|
||||
submit: { nocssjs: true }
|
||||
submit: {
|
||||
nocssjs: true
|
||||
}
|
||||
});
|
||||
|
||||
textLoaderAjax.commands.editorGetUntransformedText = function (ajax, response, status) {
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
(function ($, Drupal, drupalSettings) {
|
||||
function findFieldForFormatSelector($formatSelector) {
|
||||
var fieldId = $formatSelector.attr('data-editor-for');
|
||||
|
||||
return $('#' + fieldId).get(0);
|
||||
return $("#".concat(fieldId)).get(0);
|
||||
}
|
||||
|
||||
function filterXssWhenSwitching(field, format, originalFormatID, callback) {
|
||||
|
@ -17,7 +16,7 @@
|
|||
callback(field, format);
|
||||
} else {
|
||||
$.ajax({
|
||||
url: Drupal.url('editor/filter_xss/' + format.format),
|
||||
url: Drupal.url("editor/filter_xss/".concat(format.format)),
|
||||
type: 'POST',
|
||||
data: {
|
||||
value: field.value,
|
||||
|
@ -28,6 +27,7 @@
|
|||
if (xssFilteredValue !== false) {
|
||||
field.value = xssFilteredValue;
|
||||
}
|
||||
|
||||
callback(field, format);
|
||||
}
|
||||
});
|
||||
|
@ -62,43 +62,40 @@
|
|||
}
|
||||
|
||||
var supportContentFiltering = drupalSettings.editor.formats[newFormatID] && drupalSettings.editor.formats[newFormatID].editorSupportsContentFiltering;
|
||||
|
||||
var hasContent = field.value !== '';
|
||||
|
||||
if (hasContent && supportContentFiltering) {
|
||||
var message = Drupal.t('Changing the text format to %text_format will permanently remove content that is not allowed in that text format.<br><br>Save your changes before switching the text format to avoid losing data.', {
|
||||
'%text_format': $select.find('option:selected').text()
|
||||
});
|
||||
var confirmationDialog = Drupal.dialog('<div>' + message + '</div>', {
|
||||
var confirmationDialog = Drupal.dialog("<div>".concat(message, "</div>"), {
|
||||
title: Drupal.t('Change text format?'),
|
||||
dialogClass: 'editor-change-text-format-modal',
|
||||
resizable: false,
|
||||
buttons: [{
|
||||
text: Drupal.t('Continue'),
|
||||
class: 'button button--primary',
|
||||
"class": 'button button--primary',
|
||||
click: function click() {
|
||||
changeTextEditor(field, newFormatID);
|
||||
confirmationDialog.close();
|
||||
}
|
||||
}, {
|
||||
text: Drupal.t('Cancel'),
|
||||
class: 'button',
|
||||
"class": 'button',
|
||||
click: function click() {
|
||||
$select.val(activeFormatID);
|
||||
confirmationDialog.close();
|
||||
}
|
||||
}],
|
||||
|
||||
closeOnEscape: false,
|
||||
create: function create() {
|
||||
$(this).parent().find('.ui-dialog-titlebar-close').remove();
|
||||
},
|
||||
|
||||
beforeClose: false,
|
||||
close: function close(event) {
|
||||
$(event.target).remove();
|
||||
}
|
||||
});
|
||||
|
||||
confirmationDialog.showModal();
|
||||
} else {
|
||||
changeTextEditor(field, newFormatID);
|
||||
|
@ -106,7 +103,6 @@
|
|||
}
|
||||
|
||||
Drupal.editors = {};
|
||||
|
||||
Drupal.behaviors.editor = {
|
||||
attach: function attach(context, settings) {
|
||||
if (!settings.editor) {
|
||||
|
@ -130,12 +126,13 @@
|
|||
|
||||
$(field).on('change.editor keypress.editor', function () {
|
||||
field.setAttribute('data-editor-value-is-changed', 'true');
|
||||
|
||||
$(field).off('.editor');
|
||||
});
|
||||
|
||||
if ($this.is('select')) {
|
||||
$this.on('change.editorAttach', { field: field }, onTextFormatChange);
|
||||
$this.on('change.editorAttach', {
|
||||
field: field
|
||||
}, onTextFormatChange);
|
||||
}
|
||||
|
||||
$this.parents('form').on('submit', function (event) {
|
||||
|
@ -150,7 +147,7 @@
|
|||
});
|
||||
},
|
||||
detach: function detach(context, settings, trigger) {
|
||||
var editors = void 0;
|
||||
var editors;
|
||||
|
||||
if (trigger === 'serialize') {
|
||||
editors = $(context).find('[data-editor-for]').findOnce('editor');
|
||||
|
@ -162,6 +159,7 @@
|
|||
var $this = $(this);
|
||||
var activeFormatID = $this.val();
|
||||
var field = findFieldForFormatSelector($this);
|
||||
|
||||
if (field && activeFormatID in settings.editor.formats) {
|
||||
Drupal.editorDetach(field, settings.editor.formats[activeFormatID], trigger);
|
||||
}
|
||||
|
@ -172,10 +170,8 @@
|
|||
Drupal.editorAttach = function (field, format) {
|
||||
if (format.editor) {
|
||||
Drupal.editors[format.editor].attach(field, format);
|
||||
|
||||
Drupal.editors[format.editor].onChange(field, function () {
|
||||
$(field).trigger('formUpdated');
|
||||
|
||||
field.setAttribute('data-editor-value-is-changed', 'true');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,21 +9,20 @@
|
|||
Drupal.behaviors.fieldUIFieldStorageAddForm = {
|
||||
attach: function attach(context) {
|
||||
var $form = $(context).find('[data-drupal-selector="field-ui-field-storage-add-form"]').once('field_ui_add');
|
||||
|
||||
if ($form.length) {
|
||||
$form.find('.js-form-item-label label,' + '.js-form-item-field-name label,' + '.js-form-item-existing-storage-label label').addClass('js-form-required form-required');
|
||||
|
||||
var $newFieldType = $form.find('select[name="new_storage_type"]');
|
||||
var $existingStorageName = $form.find('select[name="existing_storage_name"]');
|
||||
var $existingStorageLabel = $form.find('input[name="existing_storage_label"]');
|
||||
|
||||
$newFieldType.on('change', function () {
|
||||
if ($(this).val() !== '') {
|
||||
$existingStorageName.val('').trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
$existingStorageName.on('change', function () {
|
||||
var value = $(this).val();
|
||||
|
||||
if (value !== '') {
|
||||
$newFieldType.val('').trigger('change');
|
||||
|
||||
|
@ -35,7 +34,6 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.fieldUIDisplayOverview = {
|
||||
attach: function attach(context, settings) {
|
||||
$(context).find('table#field-display-overview').once('field-display-overview').each(function () {
|
||||
|
@ -43,20 +41,17 @@
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.fieldUIOverview = {
|
||||
attach: function attach(table, rowsData, rowHandlers) {
|
||||
var tableDrag = Drupal.tableDrag[table.id];
|
||||
|
||||
tableDrag.onDrop = this.onDrop;
|
||||
tableDrag.row.prototype.onSwap = this.onSwap;
|
||||
|
||||
$(table).find('tr.draggable').each(function () {
|
||||
var row = this;
|
||||
|
||||
if (row.id in rowsData) {
|
||||
var data = rowsData[row.id];
|
||||
data.tableDrag = tableDrag;
|
||||
|
||||
var rowHandler = new rowHandlers[data.rowHandler](row, data);
|
||||
$(row).data('fieldUIRowHandler', rowHandler);
|
||||
}
|
||||
|
@ -66,16 +61,13 @@
|
|||
var $trigger = $(this);
|
||||
var $row = $trigger.closest('tr');
|
||||
var rowHandler = $row.data('fieldUIRowHandler');
|
||||
|
||||
var refreshRows = {};
|
||||
refreshRows[rowHandler.name] = $trigger.get(0);
|
||||
|
||||
var region = rowHandler.getRegion();
|
||||
|
||||
if (region !== rowHandler.region) {
|
||||
$row.find('select.js-field-parent').val('');
|
||||
|
||||
$.extend(refreshRows, rowHandler.regionChange(region));
|
||||
|
||||
rowHandler.region = region;
|
||||
}
|
||||
|
||||
|
@ -86,15 +78,14 @@
|
|||
var row = dragObject.rowObject.element;
|
||||
var $row = $(row);
|
||||
var rowHandler = $row.data('fieldUIRowHandler');
|
||||
|
||||
if (typeof rowHandler !== 'undefined') {
|
||||
var regionRow = $row.prevAll('tr.region-message').get(0);
|
||||
var region = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
|
||||
|
||||
if (region !== rowHandler.region) {
|
||||
var refreshRows = rowHandler.regionChange(region);
|
||||
|
||||
rowHandler.region = region;
|
||||
|
||||
Drupal.fieldUIOverview.AJAXRefreshRows(refreshRows);
|
||||
}
|
||||
}
|
||||
|
@ -127,15 +118,12 @@
|
|||
|
||||
if (rowNames.length) {
|
||||
$(ajaxElements).after(Drupal.theme.ajaxProgressThrobber());
|
||||
|
||||
$('input[name=refresh_rows]').val(rowNames.join(' '));
|
||||
$('input[data-drupal-selector="edit-refresh"]').trigger('mousedown');
|
||||
|
||||
$(ajaxElements).prop('disabled', true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.fieldUIDisplayOverview = {};
|
||||
|
||||
Drupal.fieldUIDisplayOverview.field = function (row, data) {
|
||||
|
@ -144,13 +132,10 @@
|
|||
this.region = data.region;
|
||||
this.tableDrag = data.tableDrag;
|
||||
this.defaultPlugin = data.defaultPlugin;
|
||||
|
||||
this.$pluginSelect = $(row).find('.field-plugin-type');
|
||||
this.$pluginSelect.on('change', Drupal.fieldUIOverview.onChange);
|
||||
|
||||
this.$regionSelect = $(row).find('select.field-region');
|
||||
this.$regionSelect.on('change', Drupal.fieldUIOverview.onChange);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
@ -160,7 +145,6 @@
|
|||
},
|
||||
regionChange: function regionChange(region) {
|
||||
region = region.replace(/-/g, '_');
|
||||
|
||||
this.$regionSelect.val(region);
|
||||
|
||||
if (this.region === 'hidden') {
|
||||
|
@ -173,7 +157,6 @@
|
|||
|
||||
var refreshRows = {};
|
||||
refreshRows[this.name] = this.$pluginSelect.get(0);
|
||||
|
||||
return refreshRows;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -9,10 +9,12 @@
|
|||
Drupal.behaviors.fileValidateAutoAttach = {
|
||||
attach: function attach(context, settings) {
|
||||
var $context = $(context);
|
||||
var elements = void 0;
|
||||
var elements;
|
||||
|
||||
function initFileValidation(selector) {
|
||||
$context.find(selector).once('fileValidate').on('change.fileValidate', { extensions: elements[selector] }, Drupal.file.validateExtension);
|
||||
$context.find(selector).once('fileValidate').on('change.fileValidate', {
|
||||
extensions: elements[selector]
|
||||
}, Drupal.file.validateExtension);
|
||||
}
|
||||
|
||||
if (settings.file && settings.file.elements) {
|
||||
|
@ -22,7 +24,7 @@
|
|||
},
|
||||
detach: function detach(context, settings, trigger) {
|
||||
var $context = $(context);
|
||||
var elements = void 0;
|
||||
var elements;
|
||||
|
||||
function removeFileValidation(selector) {
|
||||
$context.find(selector).removeOnce('fileValidate').off('change.fileValidate', Drupal.file.validateExtension);
|
||||
|
@ -34,7 +36,6 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.fileAutoUpload = {
|
||||
attach: function attach(context) {
|
||||
$(context).find('input[type="file"]').once('auto-file-upload').on('change.autoFileUpload', Drupal.file.triggerUploadButton);
|
||||
|
@ -45,7 +46,6 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.fileButtons = {
|
||||
attach: function attach(context) {
|
||||
var $context = $(context);
|
||||
|
@ -60,7 +60,6 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.filePreviewLinks = {
|
||||
attach: function attach(context) {
|
||||
$(context).find('div.js-form-managed-file .file a').on('click', Drupal.file.openInNewWindow);
|
||||
|
@ -69,24 +68,22 @@
|
|||
$(context).find('div.js-form-managed-file .file a').off('click', Drupal.file.openInNewWindow);
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.file = Drupal.file || {
|
||||
validateExtension: function validateExtension(event) {
|
||||
event.preventDefault();
|
||||
|
||||
$('.file-upload-js-error').remove();
|
||||
|
||||
var extensionPattern = event.data.extensions.replace(/,\s*/g, '|');
|
||||
|
||||
if (extensionPattern.length > 1 && this.value.length > 0) {
|
||||
var acceptableMatch = new RegExp('\\.(' + extensionPattern + ')$', 'gi');
|
||||
var acceptableMatch = new RegExp("\\.(".concat(extensionPattern, ")$"), 'gi');
|
||||
|
||||
if (!acceptableMatch.test(this.value)) {
|
||||
var error = Drupal.t('The selected file %filename cannot be uploaded. Only files with the following extensions are allowed: %extensions.', {
|
||||
'%filename': this.value.replace('C:\\fakepath\\', ''),
|
||||
'%extensions': extensionPattern.replace(/\|/g, ', ')
|
||||
});
|
||||
$(this).closest('div.js-form-managed-file').prepend('<div class="messages messages--error file-upload-js-error" aria-live="polite">' + error + '</div>');
|
||||
$(this).closest('div.js-form-managed-file').prepend("<div class=\"messages messages--error file-upload-js-error\" aria-live=\"polite\">".concat(error, "</div>"));
|
||||
this.value = '';
|
||||
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
|
@ -97,8 +94,8 @@
|
|||
disableFields: function disableFields(event) {
|
||||
var $clickedButton = $(this);
|
||||
$clickedButton.trigger('formUpdated');
|
||||
|
||||
var $enabledFields = [];
|
||||
|
||||
if ($clickedButton.closest('div.js-form-managed-file').length > 0) {
|
||||
$enabledFields = $clickedButton.closest('div.js-form-managed-file').find('input.js-form-file');
|
||||
}
|
||||
|
@ -112,11 +109,10 @@
|
|||
progressBar: function progressBar(event) {
|
||||
var $clickedButton = $(this);
|
||||
var $progressId = $clickedButton.closest('div.js-form-managed-file').find('input.file-progress');
|
||||
|
||||
if ($progressId.length) {
|
||||
var originalName = $progressId.attr('name');
|
||||
|
||||
$progressId.attr('name', originalName.match(/APC_UPLOAD_PROGRESS|UPLOAD_IDENTIFIER/)[0]);
|
||||
|
||||
setTimeout(function () {
|
||||
$progressId.attr('name', originalName);
|
||||
}, 1000);
|
||||
|
|
|
@ -11,15 +11,13 @@
|
|||
var $context = $(context);
|
||||
$context.find('#filters-status-wrapper input.form-checkbox').once('filter-status').each(function () {
|
||||
var $checkbox = $(this);
|
||||
|
||||
var $row = $context.find('#' + $checkbox.attr('id').replace(/-status$/, '-weight')).closest('tr');
|
||||
|
||||
var $filterSettings = $context.find('#' + $checkbox.attr('id').replace(/-status$/, '-settings'));
|
||||
var $row = $context.find("#".concat($checkbox.attr('id').replace(/-status$/, '-weight'))).closest('tr');
|
||||
var $filterSettings = $context.find("#".concat($checkbox.attr('id').replace(/-status$/, '-settings')));
|
||||
var filterSettingsTab = $filterSettings.data('verticalTab');
|
||||
|
||||
$checkbox.on('click.filterUpdate', function () {
|
||||
if ($checkbox.is(':checked')) {
|
||||
$row.show();
|
||||
|
||||
if (filterSettingsTab) {
|
||||
filterSettingsTab.tabShow().updateSummary();
|
||||
} else {
|
||||
|
@ -27,6 +25,7 @@
|
|||
}
|
||||
} else {
|
||||
$row.hide();
|
||||
|
||||
if (filterSettingsTab) {
|
||||
filterSettingsTab.tabHide().updateSummary();
|
||||
} else {
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
Drupal.filterConfiguration.liveSettingParsers.filter_html = {
|
||||
getRules: function getRules() {
|
||||
var currentValue = $('#edit-filters-filter-html-settings-allowed-html').val();
|
||||
|
||||
var rules = Drupal.behaviors.filterFilterHtmlUpdating._parseSetting(currentValue);
|
||||
|
||||
var rule = new Drupal.FilterHTMLRule();
|
||||
rule.restrictedTags.tags = ['*'];
|
||||
rule.restrictedTags.forbidden.attributes = ['style', 'on*'];
|
||||
rules.push(rule);
|
||||
|
||||
return rules;
|
||||
}
|
||||
};
|
||||
|
@ -24,37 +24,33 @@
|
|||
|
||||
Drupal.behaviors.filterFilterHtmlUpdating = {
|
||||
$allowedHTMLFormItem: null,
|
||||
|
||||
$allowedHTMLDescription: null,
|
||||
|
||||
userTags: {},
|
||||
|
||||
autoTags: null,
|
||||
|
||||
newFeatures: {},
|
||||
|
||||
attach: function attach(context, settings) {
|
||||
var that = this;
|
||||
$(context).find('[name="filters[filter_html][settings][allowed_html]"]').once('filter-filter_html-updating').each(function () {
|
||||
that.$allowedHTMLFormItem = $(this);
|
||||
that.$allowedHTMLDescription = that.$allowedHTMLFormItem.closest('.js-form-item').find('.description');
|
||||
that.userTags = that._parseSetting(this.value);
|
||||
|
||||
$(document).on('drupalEditorFeatureAdded', function (e, feature) {
|
||||
that.newFeatures[feature.name] = feature.rules;
|
||||
|
||||
that._updateAllowedTags();
|
||||
}).on('drupalEditorFeatureModified', function (e, feature) {
|
||||
if (that.newFeatures.hasOwnProperty(feature.name)) {
|
||||
that.newFeatures[feature.name] = feature.rules;
|
||||
|
||||
that._updateAllowedTags();
|
||||
}
|
||||
}).on('drupalEditorFeatureRemoved', function (e, feature) {
|
||||
if (that.newFeatures.hasOwnProperty(feature.name)) {
|
||||
delete that.newFeatures[feature.name];
|
||||
|
||||
that._updateAllowedTags();
|
||||
}
|
||||
});
|
||||
|
||||
that.$allowedHTMLFormItem.on('change.updateUserTags', function () {
|
||||
that.userTags = _.difference(that._parseSetting(this.value), that.autoTags);
|
||||
});
|
||||
|
@ -62,34 +58,35 @@
|
|||
},
|
||||
_updateAllowedTags: function _updateAllowedTags() {
|
||||
this.autoTags = this._calculateAutoAllowedTags(this.userTags, this.newFeatures);
|
||||
|
||||
this.$allowedHTMLDescription.find('.editor-update-message').remove();
|
||||
|
||||
if (!_.isEmpty(this.autoTags)) {
|
||||
this.$allowedHTMLDescription.append(Drupal.theme('filterFilterHTMLUpdateMessage', this.autoTags));
|
||||
|
||||
var userTagsWithoutOverrides = _.omit(this.userTags, _.keys(this.autoTags));
|
||||
this.$allowedHTMLFormItem.val(this._generateSetting(userTagsWithoutOverrides) + ' ' + this._generateSetting(this.autoTags));
|
||||
|
||||
this.$allowedHTMLFormItem.val("".concat(this._generateSetting(userTagsWithoutOverrides), " ").concat(this._generateSetting(this.autoTags)));
|
||||
} else {
|
||||
this.$allowedHTMLFormItem.val(this._generateSetting(this.userTags));
|
||||
}
|
||||
},
|
||||
_calculateAutoAllowedTags: function _calculateAutoAllowedTags(userAllowedTags, newFeatures) {
|
||||
var editorRequiredTags = {};
|
||||
|
||||
Object.keys(newFeatures || {}).forEach(function (featureName) {
|
||||
var feature = newFeatures[featureName];
|
||||
var featureRule = void 0;
|
||||
var filterRule = void 0;
|
||||
var tag = void 0;
|
||||
var featureRule;
|
||||
var filterRule;
|
||||
var tag;
|
||||
|
||||
for (var f = 0; f < feature.length; f++) {
|
||||
featureRule = feature[f];
|
||||
|
||||
for (var t = 0; t < featureRule.required.tags.length; t++) {
|
||||
tag = featureRule.required.tags[t];
|
||||
|
||||
if (!_.has(editorRequiredTags, tag)) {
|
||||
filterRule = new Drupal.FilterHTMLRule();
|
||||
filterRule.restrictedTags.tags = [tag];
|
||||
|
||||
filterRule.restrictedTags.allowed.attributes = featureRule.required.attributes.slice(0);
|
||||
filterRule.restrictedTags.allowed.classes = featureRule.required.classes.slice(0);
|
||||
editorRequiredTags[tag] = filterRule;
|
||||
|
@ -101,7 +98,6 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
var autoAllowedTags = {};
|
||||
Object.keys(editorRequiredTags).forEach(function (tag) {
|
||||
if (!_.has(userAllowedTags, tag)) {
|
||||
|
@ -109,43 +105,47 @@
|
|||
} else {
|
||||
var requiredAttributes = editorRequiredTags[tag].restrictedTags.allowed.attributes;
|
||||
var allowedAttributes = userAllowedTags[tag].restrictedTags.allowed.attributes;
|
||||
|
||||
var needsAdditionalAttributes = requiredAttributes.length && _.difference(requiredAttributes, allowedAttributes).length;
|
||||
|
||||
var requiredClasses = editorRequiredTags[tag].restrictedTags.allowed.classes;
|
||||
var allowedClasses = userAllowedTags[tag].restrictedTags.allowed.classes;
|
||||
|
||||
var needsAdditionalClasses = requiredClasses.length && _.difference(requiredClasses, allowedClasses).length;
|
||||
|
||||
if (needsAdditionalAttributes || needsAdditionalClasses) {
|
||||
autoAllowedTags[tag] = userAllowedTags[tag].clone();
|
||||
}
|
||||
|
||||
if (needsAdditionalAttributes) {
|
||||
autoAllowedTags[tag].restrictedTags.allowed.attributes = _.union(allowedAttributes, requiredAttributes);
|
||||
}
|
||||
|
||||
if (needsAdditionalClasses) {
|
||||
autoAllowedTags[tag].restrictedTags.allowed.classes = _.union(allowedClasses, requiredClasses);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return autoAllowedTags;
|
||||
},
|
||||
_parseSetting: function _parseSetting(setting) {
|
||||
var node = void 0;
|
||||
var tag = void 0;
|
||||
var rule = void 0;
|
||||
var attributes = void 0;
|
||||
var attribute = void 0;
|
||||
var node;
|
||||
var tag;
|
||||
var rule;
|
||||
var attributes;
|
||||
var attribute;
|
||||
var allowedTags = setting.match(/(<[^>]+>)/g);
|
||||
var sandbox = document.createElement('div');
|
||||
var rules = {};
|
||||
|
||||
for (var t = 0; t < allowedTags.length; t++) {
|
||||
sandbox.innerHTML = allowedTags[t];
|
||||
node = sandbox.firstChild;
|
||||
tag = node.tagName.toLowerCase();
|
||||
|
||||
rule = new Drupal.FilterHTMLRule();
|
||||
|
||||
rule.restrictedTags.tags = [tag];
|
||||
|
||||
attributes = node.attributes;
|
||||
|
||||
for (var i = 0; i < attributes.length; i++) {
|
||||
attribute = attributes.item(i);
|
||||
var attributeName = attribute.nodeName;
|
||||
|
@ -160,6 +160,7 @@
|
|||
|
||||
rules[tag] = rule;
|
||||
}
|
||||
|
||||
return rules;
|
||||
},
|
||||
_generateSetting: function _generateSetting(tags) {
|
||||
|
@ -168,13 +169,14 @@
|
|||
setting += ' ';
|
||||
}
|
||||
|
||||
setting += '<' + tag;
|
||||
setting += "<".concat(tag);
|
||||
|
||||
if (rule.restrictedTags.allowed.attributes.length) {
|
||||
setting += ' ' + rule.restrictedTags.allowed.attributes.join(' ');
|
||||
setting += " ".concat(rule.restrictedTags.allowed.attributes.join(' '));
|
||||
}
|
||||
|
||||
if (rule.restrictedTags.allowed.classes.length) {
|
||||
setting += ' class="' + rule.restrictedTags.allowed.classes.join(' ') + '"';
|
||||
setting += " class=\"".concat(rule.restrictedTags.allowed.classes.join(' '), "\"");
|
||||
}
|
||||
|
||||
setting += '>';
|
||||
|
@ -185,9 +187,13 @@
|
|||
|
||||
Drupal.theme.filterFilterHTMLUpdateMessage = function (tags) {
|
||||
var html = '';
|
||||
|
||||
var tagList = Drupal.behaviors.filterFilterHtmlUpdating._generateSetting(tags);
|
||||
|
||||
html += '<p class="editor-update-message">';
|
||||
html += Drupal.t('Based on the text editor configuration, these tags have automatically been added: <strong>@tag-list</strong>.', { '@tag-list': tagList });
|
||||
html += Drupal.t('Based on the text editor configuration, these tags have automatically been added: <strong>@tag-list</strong>.', {
|
||||
'@tag-list': tagList
|
||||
});
|
||||
html += '</p>';
|
||||
return html;
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
function updateFilterGuidelines(event) {
|
||||
var $this = $(event.target);
|
||||
var value = $this.val();
|
||||
$this.closest('.js-filter-wrapper').find('[data-drupal-format-id]').hide().filter('[data-drupal-format-id="' + value + '"]').show();
|
||||
$this.closest('.js-filter-wrapper').find('[data-drupal-format-id]').hide().filter("[data-drupal-format-id=\"".concat(value, "\"]")).show();
|
||||
}
|
||||
|
||||
$(context).find('.js-filter-guidelines').once('filter-guidelines').find(':header').hide().closest('.js-filter-wrapper').find('select.js-filter-list').on('change.filterGuidelines', updateFilterGuidelines).trigger('change.filterGuidelines');
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
(function ($, Drupal, drupalSettings, storage) {
|
||||
var currentUserID = parseInt(drupalSettings.user.uid, 10);
|
||||
|
||||
var secondsIn30Days = 2592000;
|
||||
var thirtyDaysAgo = Math.round(new Date().getTime() / 1000) - secondsIn30Days;
|
||||
|
||||
var embeddedLastReadTimestamps = false;
|
||||
|
||||
if (drupalSettings.history && drupalSettings.history.lastReadTimestamps) {
|
||||
embeddedLastReadTimestamps = drupalSettings.history.lastReadTimestamps;
|
||||
}
|
||||
|
@ -26,11 +25,13 @@
|
|||
$.ajax({
|
||||
url: Drupal.url('history/get_node_read_timestamps'),
|
||||
type: 'POST',
|
||||
data: { 'node_ids[]': nodeIDs },
|
||||
data: {
|
||||
'node_ids[]': nodeIDs
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function success(results) {
|
||||
Object.keys(results || {}).forEach(function (nodeID) {
|
||||
storage.setItem('Drupal.history.' + currentUserID + '.' + nodeID, results[nodeID]);
|
||||
storage.setItem("Drupal.history.".concat(currentUserID, ".").concat(nodeID), results[nodeID]);
|
||||
});
|
||||
callback();
|
||||
}
|
||||
|
@ -40,11 +41,12 @@
|
|||
if (embeddedLastReadTimestamps && embeddedLastReadTimestamps[nodeID]) {
|
||||
return parseInt(embeddedLastReadTimestamps[nodeID], 10);
|
||||
}
|
||||
return parseInt(storage.getItem('Drupal.history.' + currentUserID + '.' + nodeID) || 0, 10);
|
||||
|
||||
return parseInt(storage.getItem("Drupal.history.".concat(currentUserID, ".").concat(nodeID)) || 0, 10);
|
||||
},
|
||||
markAsRead: function markAsRead(nodeID) {
|
||||
$.ajax({
|
||||
url: Drupal.url('history/' + nodeID + '/read'),
|
||||
url: Drupal.url("history/".concat(nodeID, "/read")),
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: function success(timestamp) {
|
||||
|
@ -52,7 +54,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
storage.setItem('Drupal.history.' + currentUserID + '.' + nodeID, timestamp);
|
||||
storage.setItem("Drupal.history.".concat(currentUserID, ".").concat(nodeID), timestamp);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -65,7 +67,7 @@
|
|||
return contentTimestamp > parseInt(embeddedLastReadTimestamps[nodeID], 10);
|
||||
}
|
||||
|
||||
var minLastReadTimestamp = parseInt(storage.getItem('Drupal.history.' + currentUserID + '.' + nodeID) || 0, 10);
|
||||
var minLastReadTimestamp = parseInt(storage.getItem("Drupal.history.".concat(currentUserID, ".").concat(nodeID)) || 0, 10);
|
||||
return contentTimestamp > minLastReadTimestamp;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -9,15 +9,15 @@
|
|||
Drupal.quickedit.editors.image = Drupal.quickedit.EditorView.extend({
|
||||
initialize: function initialize(options) {
|
||||
Drupal.quickedit.EditorView.prototype.initialize.call(this, options);
|
||||
|
||||
this.model.set('originalValue', this.$el.html().trim());
|
||||
|
||||
this.model.set('currentValue', function (index, value) {
|
||||
var matches = $(this).attr('name').match(/(alt|title)]$/);
|
||||
|
||||
if (matches) {
|
||||
var name = matches[1];
|
||||
var $toolgroup = $('#' + options.fieldModel.toolbarView.getMainWysiwygToolgroupId());
|
||||
var $input = $toolgroup.find('.quickedit-image-field-info input[name="' + name + '"]');
|
||||
var $toolgroup = $("#".concat(options.fieldModel.toolbarView.getMainWysiwygToolgroupId()));
|
||||
var $input = $toolgroup.find(".quickedit-image-field-info input[name=\"".concat(name, "\"]"));
|
||||
|
||||
if ($input.length) {
|
||||
return $input.val();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
|||
},
|
||||
stateChange: function stateChange(fieldModel, state, options) {
|
||||
var from = fieldModel.previous('state');
|
||||
|
||||
switch (state) {
|
||||
case 'inactive':
|
||||
break;
|
||||
|
@ -35,9 +36,11 @@
|
|||
this.$el.find('.quickedit-image-dropzone').remove();
|
||||
this.$el.removeClass('quickedit-image-element');
|
||||
}
|
||||
|
||||
if (from === 'invalid') {
|
||||
this.removeValidationErrors();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'highlighted':
|
||||
|
@ -47,30 +50,26 @@
|
|||
_.defer(function () {
|
||||
fieldModel.set('state', 'active');
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case 'active':
|
||||
{
|
||||
var self = this;
|
||||
|
||||
this.$el.addClass('quickedit-image-element');
|
||||
|
||||
var $dropzone = this.renderDropzone('upload', Drupal.t('Drop file here or click to upload'));
|
||||
|
||||
$dropzone.on('dragenter', function (e) {
|
||||
$(this).addClass('hover');
|
||||
});
|
||||
$dropzone.on('dragleave', function (e) {
|
||||
$(this).removeClass('hover');
|
||||
});
|
||||
|
||||
$dropzone.on('drop', function (e) {
|
||||
if (e.originalEvent.dataTransfer && e.originalEvent.dataTransfer.files.length) {
|
||||
$(this).removeClass('hover');
|
||||
self.uploadImage(e.originalEvent.dataTransfer.files[0]);
|
||||
}
|
||||
});
|
||||
|
||||
$dropzone.on('click', function (e) {
|
||||
$('<input type="file">').trigger('click').on('change', function () {
|
||||
if (this.files.length) {
|
||||
|
@ -78,12 +77,10 @@
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
$dropzone.on('dragover dragenter dragleave drop click', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
this.renderToolbar(fieldModel);
|
||||
break;
|
||||
}
|
||||
|
@ -108,14 +105,13 @@
|
|||
}
|
||||
},
|
||||
uploadImage: function uploadImage(file) {
|
||||
this.renderDropzone('upload loading', Drupal.t('Uploading <i>@file</i>…', { '@file': file.name }));
|
||||
|
||||
this.renderDropzone('upload loading', Drupal.t('Uploading <i>@file</i>…', {
|
||||
'@file': file.name
|
||||
}));
|
||||
var fieldID = this.fieldModel.get('fieldID');
|
||||
var url = Drupal.quickedit.util.buildUrl(fieldID, Drupal.url('quickedit/image/upload/!entity_type/!id/!field_name/!langcode/!view_mode'));
|
||||
|
||||
var data = new FormData();
|
||||
data.append('files[image]', file);
|
||||
|
||||
var self = this;
|
||||
this.ajax({
|
||||
type: 'POST',
|
||||
|
@ -123,11 +119,9 @@
|
|||
data: data,
|
||||
success: function success(response) {
|
||||
var $el = $(self.fieldModel.get('el'));
|
||||
|
||||
self.fieldModel.set('state', 'changed');
|
||||
self.fieldModel.get('entity').set('inTempStore', true);
|
||||
self.removeValidationErrors();
|
||||
|
||||
var $content = $(response.html).closest('[data-quickedit-field-id]').children();
|
||||
$el.empty().append($content);
|
||||
}
|
||||
|
@ -144,16 +138,17 @@
|
|||
this.renderDropzone('error', Drupal.t('A server error has occurred.'));
|
||||
}
|
||||
};
|
||||
|
||||
var ajaxOptions = $.extend(defaultOptions, options);
|
||||
var successCallback = ajaxOptions.success;
|
||||
|
||||
ajaxOptions.success = function (response) {
|
||||
if (response.main_error) {
|
||||
this.renderDropzone('error', response.main_error);
|
||||
|
||||
if (response.errors.length) {
|
||||
this.model.set('validationErrors', response.errors);
|
||||
}
|
||||
|
||||
this.showValidationErrors();
|
||||
} else {
|
||||
successCallback(response);
|
||||
|
@ -163,8 +158,9 @@
|
|||
$.ajax(ajaxOptions);
|
||||
},
|
||||
renderToolbar: function renderToolbar(fieldModel) {
|
||||
var $toolgroup = $('#' + fieldModel.toolbarView.getMainWysiwygToolgroupId());
|
||||
var $toolgroup = $("#".concat(fieldModel.toolbarView.getMainWysiwygToolgroupId()));
|
||||
var $toolbar = $toolgroup.find('.quickedit-image-field-info');
|
||||
|
||||
if ($toolbar.length === 0) {
|
||||
var fieldID = fieldModel.get('fieldID');
|
||||
var url = Drupal.quickedit.util.buildUrl(fieldID, Drupal.url('quickedit/image/info/!entity_type/!id/!field_name/!langcode/!view_mode'));
|
||||
|
@ -178,7 +174,6 @@
|
|||
$toolbar.on('keyup paste', function () {
|
||||
fieldModel.set('state', 'changed');
|
||||
});
|
||||
|
||||
fieldModel.get('entity').toolbarView.position();
|
||||
}
|
||||
});
|
||||
|
@ -188,7 +183,7 @@
|
|||
var $dropzone = this.$el.find('.quickedit-image-dropzone');
|
||||
|
||||
if ($dropzone.length) {
|
||||
$dropzone.removeClass('upload error hover loading').addClass('.quickedit-image-dropzone ' + state).children('.quickedit-image-text').html(text);
|
||||
$dropzone.removeClass('upload error hover loading').addClass(".quickedit-image-dropzone ".concat(state)).children('.quickedit-image-text').html(text);
|
||||
} else {
|
||||
$dropzone = $(Drupal.theme('quickeditImageDropzone', {
|
||||
state: state,
|
||||
|
@ -214,13 +209,12 @@
|
|||
var errors = Drupal.theme('quickeditImageErrors', {
|
||||
errors: this.model.get('validationErrors')
|
||||
});
|
||||
$('#' + this.fieldModel.toolbarView.getMainWysiwygToolgroupId()).append(errors);
|
||||
$("#".concat(this.fieldModel.toolbarView.getMainWysiwygToolgroupId())).append(errors);
|
||||
this.getEditedElement().addClass('quickedit-validation-error');
|
||||
|
||||
this.fieldModel.get('entity').toolbarView.position();
|
||||
},
|
||||
removeValidationErrors: function removeValidationErrors() {
|
||||
$('#' + this.fieldModel.toolbarView.getMainWysiwygToolgroupId()).find('.quickedit-image-errors').remove();
|
||||
$("#".concat(this.fieldModel.toolbarView.getMainWysiwygToolgroupId())).find('.quickedit-image-errors').remove();
|
||||
this.getEditedElement().removeClass('quickedit-validation-error');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,23 +7,25 @@
|
|||
|
||||
(function (Drupal) {
|
||||
Drupal.theme.quickeditImageErrors = function (settings) {
|
||||
return '<div class="quickedit-image-errors">' + settings.errors + '</div>';
|
||||
return "<div class=\"quickedit-image-errors\">".concat(settings.errors, "</div>");
|
||||
};
|
||||
|
||||
Drupal.theme.quickeditImageDropzone = function (settings) {
|
||||
return '<div class="quickedit-image-dropzone ' + settings.state + '">' + ' <i class="quickedit-image-icon"></i>' + (' <span class="quickedit-image-text">' + settings.text + '</span>') + '</div>';
|
||||
return "<div class=\"quickedit-image-dropzone ".concat(settings.state, "\">") + ' <i class="quickedit-image-icon"></i>' + " <span class=\"quickedit-image-text\">".concat(settings.text, "</span>") + '</div>';
|
||||
};
|
||||
|
||||
Drupal.theme.quickeditImageToolbar = function (settings) {
|
||||
var html = '<form class="quickedit-image-field-info">';
|
||||
if (settings.alt_field) {
|
||||
html += '<div><label for="alt" class="' + (settings.alt_field_required ? 'required' : '') + '">' + Drupal.t('Alternative text') + '</label>' + ('<input type="text" placeholder="' + settings.alt + '" value="' + settings.alt + '" name="alt" ' + (settings.alt_field_required ? 'required' : '') + '/>') + ' </div>';
|
||||
}
|
||||
if (settings.title_field) {
|
||||
html += '<div><label for="title" class="' + (settings.title_field_required ? 'form-required' : '') + '">' + Drupal.t('Title') + '</label>' + ('<input type="text" placeholder="' + settings.title + '" value="' + settings.title + '" name="title" ' + (settings.title_field_required ? 'required' : '') + '/>') + '</div>';
|
||||
}
|
||||
html += '</form>';
|
||||
|
||||
if (settings.alt_field) {
|
||||
html += "<div><label for=\"alt\" class=\"".concat(settings.alt_field_required ? 'required' : '', "\">").concat(Drupal.t('Alternative text'), "</label>") + "<input type=\"text\" placeholder=\"".concat(settings.alt, "\" value=\"").concat(settings.alt, "\" name=\"alt\" ").concat(settings.alt_field_required ? 'required' : '', "/>") + ' </div>';
|
||||
}
|
||||
|
||||
if (settings.title_field) {
|
||||
html += "<div><label for=\"title\" class=\"".concat(settings.title_field_required ? 'form-required' : '', "\">").concat(Drupal.t('Title'), "</label>") + "<input type=\"text\" placeholder=\"".concat(settings.title, "\" value=\"").concat(settings.title, "\" name=\"title\" ").concat(settings.title_field_required ? 'required' : '', "/>") + '</div>';
|
||||
}
|
||||
|
||||
html += '</form>';
|
||||
return html;
|
||||
};
|
||||
})(Drupal);
|
|
@ -13,15 +13,13 @@
|
|||
|
||||
function toggleTable(checkbox) {
|
||||
var $checkbox = $(checkbox);
|
||||
|
||||
$checkbox.closest('.table-language-group').find('table, .tabledrag-toggle-weight').toggle($checkbox.prop('checked'));
|
||||
}
|
||||
|
||||
$configForm.once('negotiation-language-admin-bind').on('change', inputSelector, function (event) {
|
||||
toggleTable(event.target);
|
||||
});
|
||||
|
||||
$configForm.find(inputSelector + ':not(:checked)').each(function (index, element) {
|
||||
$configForm.find("".concat(inputSelector, ":not(:checked)")).each(function (index, element) {
|
||||
toggleTable(element);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,9 +11,7 @@
|
|||
debounce = Drupal.debounce,
|
||||
announce = Drupal.announce,
|
||||
formatPlural = Drupal.formatPlural;
|
||||
|
||||
var layoutBuilderBlocksFiltered = false;
|
||||
|
||||
behaviors.layoutBuilderBlockFilter = {
|
||||
attach: function attach(context) {
|
||||
var $categories = $('.js-layout-builder-categories', context);
|
||||
|
@ -30,18 +28,13 @@
|
|||
|
||||
if (query.length >= 2) {
|
||||
$categories.find('.js-layout-builder-category:not([open])').attr('remember-closed', '');
|
||||
|
||||
$categories.find('.js-layout-builder-category').attr('open', '');
|
||||
|
||||
$filterLinks.each(toggleBlockEntry);
|
||||
|
||||
$categories.find('.js-layout-builder-category:not(:has(.js-layout-builder-block-link:visible))').hide();
|
||||
|
||||
announce(formatPlural($categories.find('.js-layout-builder-block-link:visible').length, '1 block is available in the modified list.', '@count blocks are available in the modified list.'));
|
||||
layoutBuilderBlocksFiltered = true;
|
||||
} else if (layoutBuilderBlocksFiltered) {
|
||||
layoutBuilderBlocksFiltered = false;
|
||||
|
||||
$categories.find('.js-layout-builder-category[remember-closed]').removeAttr('open').removeAttr('remember-closed');
|
||||
$categories.find('.js-layout-builder-category').show();
|
||||
$filterLinks.show();
|
||||
|
@ -56,11 +49,10 @@
|
|||
Drupal.layoutBuilderBlockUpdate = function (item, from, to) {
|
||||
var $item = $(item);
|
||||
var $from = $(from);
|
||||
|
||||
var itemRegion = $item.closest('.js-layout-builder-region');
|
||||
|
||||
if (to === itemRegion[0]) {
|
||||
var deltaTo = $item.closest('[data-layout-delta]').data('layout-delta');
|
||||
|
||||
var deltaFrom = $from ? $from.closest('[data-layout-delta]').data('layout-delta') : deltaTo;
|
||||
ajax({
|
||||
url: [$item.closest('[data-layout-update-url]').data('layout-update-url'), deltaFrom, deltaTo, itemRegion.data('region'), $item.data('layout-block-uuid'), $item.prev('[data-layout-block-uuid]').data('layout-block-uuid')].filter(function (element) {
|
||||
|
@ -85,7 +77,6 @@
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
behaviors.layoutBuilderDisableInteractiveElements = {
|
||||
attach: function attach() {
|
||||
var $blocks = $('#layout-builder [data-layout-block-uuid]');
|
||||
|
@ -96,25 +87,23 @@
|
|||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$blocks.find('button, [href], input, select, textarea, iframe, [tabindex]:not([tabindex="-1"]):not(.tabbable)').not(function (index, element) {
|
||||
return $(element).closest('[data-contextual-id]').length > 0;
|
||||
}).attr('tabindex', -1);
|
||||
}
|
||||
};
|
||||
|
||||
$(window).on('dialog:aftercreate', function (event, dialog, $element) {
|
||||
if (Drupal.offCanvas.isOffCanvas($element)) {
|
||||
$('.is-layout-builder-highlighted').removeClass('is-layout-builder-highlighted');
|
||||
|
||||
var id = $element.find('[data-layout-builder-target-highlight-id]').attr('data-layout-builder-target-highlight-id');
|
||||
|
||||
if (id) {
|
||||
$('[data-layout-builder-highlight-id="' + id + '"]').addClass('is-layout-builder-highlighted');
|
||||
$("[data-layout-builder-highlight-id=\"".concat(id, "\"]")).addClass('is-layout-builder-highlighted');
|
||||
}
|
||||
|
||||
$('#layout-builder').removeClass('layout-builder--move-blocks-active');
|
||||
|
||||
var layoutBuilderWrapperValue = $element.find('[data-add-layout-builder-wrapper]').attr('data-add-layout-builder-wrapper');
|
||||
|
||||
if (layoutBuilderWrapperValue) {
|
||||
$('#layout-builder').addClass(layoutBuilderWrapperValue);
|
||||
}
|
||||
|
@ -123,7 +112,6 @@
|
|||
|
||||
if (document.querySelector('[data-off-canvas-main-canvas]')) {
|
||||
var mainCanvas = document.querySelector('[data-off-canvas-main-canvas]');
|
||||
|
||||
mainCanvas.addEventListener('transitionend', function () {
|
||||
var $target = $('.is-layout-builder-highlighted');
|
||||
|
||||
|
@ -154,31 +142,22 @@
|
|||
$(window).on('dialog:afterclose', function (event, dialog, $element) {
|
||||
if (Drupal.offCanvas.isOffCanvas($element)) {
|
||||
$('.is-layout-builder-highlighted').removeClass('is-layout-builder-highlighted');
|
||||
|
||||
$('#layout-builder').removeClass('layout-builder--move-blocks-active');
|
||||
}
|
||||
});
|
||||
|
||||
behaviors.layoutBuilderToggleContentPreview = {
|
||||
attach: function attach(context) {
|
||||
var $layoutBuilder = $('#layout-builder');
|
||||
|
||||
var $layoutBuilderContentPreview = $('#layout-builder-content-preview');
|
||||
|
||||
var contentPreviewId = $layoutBuilderContentPreview.data('content-preview-id');
|
||||
|
||||
var isContentPreview = JSON.parse(localStorage.getItem(contentPreviewId)) !== false;
|
||||
|
||||
var disableContentPreview = function disableContentPreview() {
|
||||
$layoutBuilder.addClass('layout-builder--content-preview-disabled');
|
||||
|
||||
$('[data-layout-content-preview-placeholder-label]', context).each(function (i, element) {
|
||||
var $element = $(element);
|
||||
|
||||
$element.children(':not([data-contextual-id])').hide(0);
|
||||
|
||||
var contentPreviewPlaceholderText = $element.attr('data-layout-content-preview-placeholder-label');
|
||||
|
||||
var contentPreviewPlaceholderLabel = Drupal.theme('layoutBuilderPrependContentPreviewPlaceholderLabel', contentPreviewPlaceholderText);
|
||||
$element.prepend(contentPreviewPlaceholderLabel);
|
||||
});
|
||||
|
@ -186,9 +165,7 @@
|
|||
|
||||
var enableContentPreview = function enableContentPreview() {
|
||||
$layoutBuilder.removeClass('layout-builder--content-preview-disabled');
|
||||
|
||||
$('.js-layout-builder-content-preview-placeholder-label').remove();
|
||||
|
||||
$('[data-layout-content-preview-placeholder-label]').each(function (i, element) {
|
||||
$(element).children().show();
|
||||
});
|
||||
|
@ -196,7 +173,6 @@
|
|||
|
||||
$('#layout-builder-content-preview', context).on('change', function (event) {
|
||||
var isChecked = $(event.currentTarget).is(':checked');
|
||||
|
||||
localStorage.setItem(contentPreviewId, JSON.stringify(isChecked));
|
||||
|
||||
if (isChecked) {
|
||||
|
@ -219,7 +195,6 @@
|
|||
var contentPreviewPlaceholderLabel = document.createElement('div');
|
||||
contentPreviewPlaceholderLabel.className = 'layout-builder-block__content-preview-placeholder-label js-layout-builder-content-preview-placeholder-label';
|
||||
contentPreviewPlaceholderLabel.innerHTML = contentPreviewPlaceholderText;
|
||||
|
||||
return '<div class="layout-builder-block__content-preview-placeholder-label js-layout-builder-content-preview-placeholder-label">' + contentPreviewPlaceholderText + '</div>';
|
||||
return "<div class=\"layout-builder-block__content-preview-placeholder-label js-layout-builder-content-preview-placeholder-label\">".concat(contentPreviewPlaceholderText, "</div>");
|
||||
};
|
||||
})(jQuery, Drupal, Sortable);
|
|
@ -74,7 +74,7 @@
|
|||
|
||||
// Open/close the description details by toggling a tr class.
|
||||
$tbodies.on('click keydown', '.description', function(e) {
|
||||
if (e.keyCode && (e.keyCode !== 13 && e.keyCode !== 32)) {
|
||||
if (e.keyCode && e.keyCode !== 13 && e.keyCode !== 32) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
|
|
|
@ -9,18 +9,17 @@
|
|||
Drupal.behaviors.localeTranslateDirty = {
|
||||
attach: function attach() {
|
||||
var $form = $('#locale-translate-edit-form').once('localetranslatedirty');
|
||||
|
||||
if ($form.length) {
|
||||
$form.one('formUpdated.localeTranslateDirty', 'table', function () {
|
||||
var $marker = $(Drupal.theme('localeTranslateChangedWarning')).hide();
|
||||
$(this).addClass('changed').before($marker);
|
||||
$marker.fadeIn('slow');
|
||||
});
|
||||
|
||||
$form.on('formUpdated.localeTranslateDirty', 'tr', function () {
|
||||
var $row = $(this);
|
||||
var $rowToMark = $row.once('localemark');
|
||||
var marker = Drupal.theme('localeTranslateChangedMarker');
|
||||
|
||||
$row.addClass('changed');
|
||||
|
||||
if ($rowToMark.length) {
|
||||
|
@ -32,28 +31,27 @@
|
|||
detach: function detach(context, settings, trigger) {
|
||||
if (trigger === 'unload') {
|
||||
var $form = $('#locale-translate-edit-form').removeOnce('localetranslatedirty');
|
||||
|
||||
if ($form.length) {
|
||||
$form.off('formUpdated.localeTranslateDirty');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.hideUpdateInformation = {
|
||||
attach: function attach(context, settings) {
|
||||
var $table = $('#locale-translation-status-form').once('expand-updates');
|
||||
|
||||
if ($table.length) {
|
||||
var $tbodies = $table.find('tbody');
|
||||
|
||||
$tbodies.on('click keydown', '.description', function (e) {
|
||||
if (e.keyCode && e.keyCode !== 13 && e.keyCode !== 32) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
var $tr = $(this).closest('tr');
|
||||
|
||||
$tr.toggleClass('expanded');
|
||||
|
||||
$tr.find('.locale-translation-update__prefix').text(function () {
|
||||
if ($tr.hasClass('expanded')) {
|
||||
return Drupal.t('Hide description');
|
||||
|
@ -66,13 +64,12 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.extend(Drupal.theme, {
|
||||
localeTranslateChangedMarker: function localeTranslateChangedMarker() {
|
||||
return '<abbr class="warning ajax-changed" title="' + Drupal.t('Changed') + '">*</abbr>';
|
||||
return "<abbr class=\"warning ajax-changed\" title=\"".concat(Drupal.t('Changed'), "\">*</abbr>");
|
||||
},
|
||||
localeTranslateChangedWarning: function localeTranslateChangedWarning() {
|
||||
return '<div class="clearfix messages messages--warning">' + Drupal.theme('localeTranslateChangedMarker') + ' ' + Drupal.t('Changes made in this table will not be saved until the form is submitted.') + '</div>';
|
||||
return "<div class=\"clearfix messages messages--warning\">".concat(Drupal.theme('localeTranslateChangedMarker'), " ").concat(Drupal.t('Changes made in this table will not be saved until the form is submitted.'), "</div>");
|
||||
}
|
||||
});
|
||||
})(jQuery, Drupal);
|
|
@ -9,11 +9,13 @@
|
|||
Drupal.behaviors.importLanguageCodeSelector = {
|
||||
attach: function attach(context, settings) {
|
||||
var $form = $('#locale-translate-import-form').once('autodetect-lang');
|
||||
|
||||
if ($form.length) {
|
||||
var $langcode = $form.find('.langcode-input');
|
||||
$form.find('.file-import-input').on('change', function () {
|
||||
var matches = $(this).val().match(/([^.][.]*)([\w-]+)\.po$/);
|
||||
if (matches && $langcode.find('option[value="' + matches[2] + '"]').length) {
|
||||
|
||||
if (matches && $langcode.find("option[value=\"".concat(matches[2], "\"]")).length) {
|
||||
$langcode.val(matches[2]);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,34 +7,44 @@
|
|||
|
||||
Drupal.t("Standard Call t");
|
||||
Drupal.t("Whitespace Call t");
|
||||
|
||||
Drupal.t('Single Quote t');
|
||||
Drupal.t('Single Quote \'Escaped\' t');
|
||||
Drupal.t('Single Quote ' + 'Concat ' + 'strings ' + 't');
|
||||
|
||||
Drupal.t("Double Quote t");
|
||||
Drupal.t("Double Quote \"Escaped\" t");
|
||||
Drupal.t("Double Quote " + "Concat " + "strings " + "t");
|
||||
|
||||
Drupal.t("Context Unquoted t", {}, { context: "Context string unquoted" });
|
||||
Drupal.t("Context Single Quoted t", {}, { 'context': "Context string single quoted" });
|
||||
Drupal.t("Context Double Quoted t", {}, { "context": "Context string double quoted" });
|
||||
|
||||
Drupal.t("Context !key Args t", { '!key': 'value' }, { context: "Context string" });
|
||||
|
||||
Drupal.t("Context Unquoted t", {}, {
|
||||
context: "Context string unquoted"
|
||||
});
|
||||
Drupal.t("Context Single Quoted t", {}, {
|
||||
'context': "Context string single quoted"
|
||||
});
|
||||
Drupal.t("Context Double Quoted t", {}, {
|
||||
"context": "Context string double quoted"
|
||||
});
|
||||
Drupal.t("Context !key Args t", {
|
||||
'!key': 'value'
|
||||
}, {
|
||||
context: "Context string"
|
||||
});
|
||||
Drupal.formatPlural(1, "Standard Call plural", "Standard Call @count plural");
|
||||
Drupal.formatPlural(1, "Whitespace Call plural", "Whitespace Call @count plural");
|
||||
|
||||
Drupal.formatPlural(1, 'Single Quote plural', 'Single Quote @count plural');
|
||||
Drupal.formatPlural(1, 'Single Quote \'Escaped\' plural', 'Single Quote \'Escaped\' @count plural');
|
||||
|
||||
Drupal.formatPlural(1, "Double Quote plural", "Double Quote @count plural");
|
||||
Drupal.formatPlural(1, "Double Quote \"Escaped\" plural", "Double Quote \"Escaped\" @count plural");
|
||||
|
||||
Drupal.formatPlural(1, "Context Unquoted plural", "Context Unquoted @count plural", {}, { context: "Context string unquoted" });
|
||||
Drupal.formatPlural(1, "Context Single Quoted plural", "Context Single Quoted @count plural", {}, { 'context': "Context string single quoted" });
|
||||
Drupal.formatPlural(1, "Context Double Quoted plural", "Context Double Quoted @count plural", {}, { "context": "Context string double quoted" });
|
||||
|
||||
Drupal.formatPlural(1, "Context !key Args plural", "Context !key Args @count plural", { '!key': 'value' }, { context: "Context string" });
|
||||
|
||||
Drupal.formatPlural(1, "Context Unquoted plural", "Context Unquoted @count plural", {}, {
|
||||
context: "Context string unquoted"
|
||||
});
|
||||
Drupal.formatPlural(1, "Context Single Quoted plural", "Context Single Quoted @count plural", {}, {
|
||||
'context': "Context string single quoted"
|
||||
});
|
||||
Drupal.formatPlural(1, "Context Double Quoted plural", "Context Double Quoted @count plural", {}, {
|
||||
"context": "Context string double quoted"
|
||||
});
|
||||
Drupal.formatPlural(1, "Context !key Args plural", "Context !key Args @count plural", {
|
||||
'!key': 'value'
|
||||
}, {
|
||||
context: "Context string"
|
||||
});
|
||||
Drupal.formatPlural(1, "No count argument plural - singular", "No count argument plural - plural");
|
|
@ -9,7 +9,6 @@
|
|||
Drupal.behaviors.mediaFormSummaries = {
|
||||
attach: function attach(context) {
|
||||
var $context = $(context);
|
||||
|
||||
$context.find('.media-form-author').drupalSetSummary(function (context) {
|
||||
var $authorContext = $(context);
|
||||
var name = $authorContext.find('.field--name-uid input').val();
|
||||
|
@ -21,11 +20,17 @@
|
|||
'@date': date
|
||||
});
|
||||
}
|
||||
|
||||
if (name) {
|
||||
return Drupal.t('By @name', { '@name': name });
|
||||
return Drupal.t('By @name', {
|
||||
'@name': name
|
||||
});
|
||||
}
|
||||
|
||||
if (date) {
|
||||
return Drupal.t('Authored on @date', { '@date': date });
|
||||
return Drupal.t('Authored on @date', {
|
||||
'@date': date
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
(function (Drupal) {
|
||||
Drupal.theme.mediaEmbedPreviewError = function () {
|
||||
return '<div>' + Drupal.t('An error occurred while trying to preview the media. Please save your work and reload this page.') + '</div>';
|
||||
return "<div>".concat(Drupal.t('An error occurred while trying to preview the media. Please save your work and reload this page.'), "</div>");
|
||||
};
|
||||
|
||||
Drupal.theme.mediaEmbedEditButton = function () {
|
||||
return '<button class="media-library-item__edit">' + Drupal.t('Edit media') + '</button>';
|
||||
return "<button class=\"media-library-item__edit\">".concat(Drupal.t('Edit media'), "</button>");
|
||||
};
|
||||
})(Drupal);
|
|
@ -12,6 +12,7 @@
|
|||
if (widget && widget.name === 'drupalmedia') {
|
||||
return widget;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -21,7 +22,6 @@
|
|||
}
|
||||
|
||||
CKEDITOR.plugins.drupallink.registerLinkableWidget('drupalmedia');
|
||||
|
||||
editor.getCommand('drupalunlink').on('exec', function (evt) {
|
||||
var widget = getFocusedWidget(editor);
|
||||
|
||||
|
@ -30,12 +30,9 @@
|
|||
}
|
||||
|
||||
widget.setData('link', null);
|
||||
|
||||
this.refresh(editor, editor.elementPath());
|
||||
|
||||
evt.cancel();
|
||||
});
|
||||
|
||||
editor.getCommand('drupalunlink').on('refresh', function (evt) {
|
||||
var widget = getFocusedWidget(editor);
|
||||
|
||||
|
@ -44,7 +41,6 @@
|
|||
}
|
||||
|
||||
this.setState(widget.data.link ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED);
|
||||
|
||||
evt.cancel();
|
||||
});
|
||||
|
||||
|
@ -62,6 +58,7 @@
|
|||
unlink: CKEDITOR.TRISTATE_OFF
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
@ -69,19 +66,17 @@
|
|||
|
||||
CKEDITOR.plugins.add('drupalmedia', {
|
||||
requires: 'widget',
|
||||
|
||||
beforeInit: function beforeInit(editor) {
|
||||
var dtd = CKEDITOR.dtd;
|
||||
|
||||
dtd['drupal-media'] = { '#': 1 };
|
||||
|
||||
dtd['drupal-media'] = {
|
||||
'#': 1
|
||||
};
|
||||
Object.keys(dtd).forEach(function (tagName) {
|
||||
if (dtd[tagName].div) {
|
||||
dtd[tagName]['drupal-media'] = 1;
|
||||
}
|
||||
});
|
||||
dtd.a['drupal-media'] = 1;
|
||||
|
||||
editor.widgets.add('drupalmedia', {
|
||||
allowedContent: {
|
||||
'drupal-media': {
|
||||
|
@ -96,7 +91,6 @@
|
|||
classes: {}
|
||||
}
|
||||
},
|
||||
|
||||
requiredContent: new CKEDITOR.style({
|
||||
element: 'drupal-media',
|
||||
attributes: {
|
||||
|
@ -104,9 +98,7 @@
|
|||
'data-entity-uuid': ''
|
||||
}
|
||||
}),
|
||||
|
||||
pathName: Drupal.t('Embedded media'),
|
||||
|
||||
editables: {
|
||||
caption: {
|
||||
selector: 'figcaption',
|
||||
|
@ -114,11 +106,11 @@
|
|||
pathName: Drupal.t('Caption')
|
||||
}
|
||||
},
|
||||
|
||||
getLabel: function getLabel() {
|
||||
if (this.data.label) {
|
||||
return this.data.label;
|
||||
}
|
||||
|
||||
return Drupal.t('Embedded media');
|
||||
},
|
||||
upcast: function upcast(element, data) {
|
||||
|
@ -127,17 +119,19 @@
|
|||
if (element.name !== 'drupal-media' || attributes['data-entity-type'] !== 'media' || attributes['data-entity-uuid'] === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
data.attributes = CKEDITOR.tools.copy(attributes);
|
||||
data.hasCaption = data.attributes.hasOwnProperty('data-caption');
|
||||
|
||||
if (data.hasCaption && data.attributes['data-caption'] === '') {
|
||||
data.attributes['data-caption'] = ' ';
|
||||
}
|
||||
|
||||
data.label = null;
|
||||
data.link = null;
|
||||
|
||||
if (element.parent.name === 'a') {
|
||||
data.link = CKEDITOR.tools.copy(element.parent.attributes);
|
||||
|
||||
Object.keys(element.parent.attributes).forEach(function (attrName) {
|
||||
if (attrName.indexOf('data-cke-') !== -1) {
|
||||
delete data.link[attrName];
|
||||
|
@ -146,9 +140,11 @@
|
|||
}
|
||||
|
||||
var hostEntityLangcode = document.getElementById(editor.name).getAttribute('data-media-embed-host-entity-langcode');
|
||||
|
||||
if (hostEntityLangcode) {
|
||||
data.hostEntityLangcode = hostEntityLangcode;
|
||||
}
|
||||
|
||||
return element;
|
||||
},
|
||||
destroy: function destroy() {
|
||||
|
@ -167,11 +163,14 @@
|
|||
|
||||
if (this._previewNeedsServerSideUpdate()) {
|
||||
editor.fire('lockSnapshot');
|
||||
|
||||
this._tearDownDynamicEditables();
|
||||
|
||||
this._loadPreview(function (widget) {
|
||||
widget._setUpDynamicEditables();
|
||||
|
||||
widget._setUpEditButton();
|
||||
|
||||
editor.fire('unlockSnapshot');
|
||||
});
|
||||
}
|
||||
|
@ -183,16 +182,17 @@
|
|||
}
|
||||
|
||||
this.element.setAttributes(this.data.attributes);
|
||||
|
||||
this.oldData = CKEDITOR.tools.clone(this.data);
|
||||
},
|
||||
downcast: function downcast() {
|
||||
var downcastElement = new CKEDITOR.htmlParser.element('drupal-media', this.data.attributes);
|
||||
|
||||
if (this.data.link) {
|
||||
var link = new CKEDITOR.htmlParser.element('a', this.data.link);
|
||||
link.add(downcastElement);
|
||||
return link;
|
||||
}
|
||||
|
||||
return downcastElement;
|
||||
},
|
||||
_setUpDynamicEditables: function _setUpDynamicEditables() {
|
||||
|
@ -200,12 +200,11 @@
|
|||
|
||||
if (this.initEditable('caption', this.definition.editables.caption)) {
|
||||
var captionEditable = this.editables.caption;
|
||||
|
||||
captionEditable.setAttribute('data-placeholder', Drupal.t('Enter caption here'));
|
||||
|
||||
this.captionObserver = new MutationObserver(function () {
|
||||
var mediaAttributes = CKEDITOR.tools.clone(_this2.data.attributes);
|
||||
mediaAttributes['data-caption'] = captionEditable.getData();
|
||||
|
||||
_this2.setData('attributes', mediaAttributes);
|
||||
});
|
||||
this.captionObserver.observe(captionEditable.$, {
|
||||
|
@ -237,24 +236,23 @@
|
|||
}
|
||||
|
||||
embeddedMedia.setStyle('position', 'relative');
|
||||
|
||||
var editButton = CKEDITOR.dom.element.createFromHtml(Drupal.theme('mediaEmbedEditButton'));
|
||||
embeddedMedia.getFirst().insertBeforeMe(editButton);
|
||||
|
||||
var widget = this;
|
||||
this.element.findOne('.media-library-item__edit').on('click', function (event) {
|
||||
var saveCallback = function saveCallback(values) {
|
||||
event.cancel();
|
||||
editor.fire('saveSnapshot');
|
||||
|
||||
if (values.hasOwnProperty('attributes')) {
|
||||
CKEDITOR.tools.extend(values.attributes, widget.data.attributes);
|
||||
|
||||
Object.keys(values.attributes).forEach(function (prop) {
|
||||
if (values.attributes[prop] === false || prop === 'data-align' && values.attributes[prop] === 'none') {
|
||||
delete values.attributes[prop];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
widget.setData({
|
||||
attributes: values.attributes,
|
||||
hasCaption: !!values.hasCaption
|
||||
|
@ -262,15 +260,15 @@
|
|||
editor.fire('saveSnapshot');
|
||||
};
|
||||
|
||||
Drupal.ckeditor.openDialog(editor, Drupal.url('editor/dialog/media/' + editor.config.drupal.format), widget.data, saveCallback, {});
|
||||
Drupal.ckeditor.openDialog(editor, Drupal.url("editor/dialog/media/".concat(editor.config.drupal.format)), widget.data, saveCallback, {});
|
||||
});
|
||||
|
||||
this.element.findOne('.media-library-item__edit').on('keydown', function (event) {
|
||||
var returnKey = 13;
|
||||
|
||||
var spaceBar = 32;
|
||||
|
||||
if (typeof event.data !== 'undefined') {
|
||||
var keypress = event.data.getKey();
|
||||
|
||||
if (keypress === returnKey || keypress === spaceBar) {
|
||||
event.sender.$.click();
|
||||
}
|
||||
|
@ -294,21 +292,20 @@
|
|||
},
|
||||
_hashData: function _hashData(data) {
|
||||
var dataToHash = CKEDITOR.tools.clone(data);
|
||||
|
||||
delete dataToHash.attributes['data-caption'];
|
||||
|
||||
delete dataToHash.label;
|
||||
|
||||
if (dataToHash.link) {
|
||||
delete dataToHash.link.href;
|
||||
}
|
||||
|
||||
return JSON.stringify(dataToHash);
|
||||
},
|
||||
_loadPreview: function _loadPreview(callback) {
|
||||
var _this3 = this;
|
||||
|
||||
jQuery.get({
|
||||
url: Drupal.url('media/' + editor.config.drupal.format + '/preview'),
|
||||
url: Drupal.url("media/".concat(editor.config.drupal.format, "/preview")),
|
||||
data: {
|
||||
text: this.downcast().getOuterHtml(),
|
||||
uuid: this.data.attributes['data-entity-uuid']
|
||||
|
@ -316,7 +313,9 @@
|
|||
dataType: 'html',
|
||||
success: function success(previewHtml, textStatus, jqXhr) {
|
||||
_this3.element.setHtml(previewHtml);
|
||||
|
||||
_this3.setData('label', jqXhr.getResponseHeader('Drupal-Media-Label'));
|
||||
|
||||
callback(_this3);
|
||||
},
|
||||
error: function error() {
|
||||
|
|
|
@ -9,26 +9,24 @@
|
|||
Drupal.behaviors.mediaTypeFormSummaries = {
|
||||
attach: function attach(context) {
|
||||
var $context = $(context);
|
||||
|
||||
$context.find('#edit-workflow').drupalSetSummary(function (context) {
|
||||
var vals = [];
|
||||
$(context).find('input[name^="options"]:checked').parent().each(function () {
|
||||
vals.push(Drupal.checkPlain($(this).find('label').text()));
|
||||
});
|
||||
|
||||
if (!$(context).find('#edit-options-status').is(':checked')) {
|
||||
vals.unshift(Drupal.t('Not published'));
|
||||
}
|
||||
|
||||
return vals.join(', ');
|
||||
});
|
||||
$(context).find('#edit-language').drupalSetSummary(function (context) {
|
||||
var vals = [];
|
||||
|
||||
vals.push($(context).find('.js-form-item-language-configuration-langcode select option:selected').text());
|
||||
|
||||
$(context).find('input:checked').next('label').each(function () {
|
||||
vals.push(Drupal.checkPlain($(this).text()));
|
||||
});
|
||||
|
||||
return vals.join(', ');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,26 +10,20 @@
|
|||
attach: function attach(context) {
|
||||
$('.js-click-to-select-trigger', context).once('media-library-click-to-select').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $input = $(event.currentTarget).closest('.js-click-to-select').find('.js-click-to-select-checkbox input');
|
||||
$input.prop('checked', !$input.prop('checked')).trigger('change');
|
||||
});
|
||||
|
||||
$('.js-click-to-select-checkbox input', context).once('media-library-click-to-select').on('change', function (_ref) {
|
||||
var currentTarget = _ref.currentTarget;
|
||||
|
||||
$(currentTarget).closest('.js-click-to-select').toggleClass('checked', $(currentTarget).prop('checked'));
|
||||
}).on('focus blur', function (_ref2) {
|
||||
var currentTarget = _ref2.currentTarget,
|
||||
type = _ref2.type;
|
||||
|
||||
$(currentTarget).closest('.js-click-to-select').toggleClass('is-focus', type === 'focus');
|
||||
});
|
||||
|
||||
$('.js-click-to-select-trigger, .js-click-to-select-checkbox', context).once('media-library-click-to-select-hover').on('mouseover mouseout', function (_ref3) {
|
||||
var currentTarget = _ref3.currentTarget,
|
||||
type = _ref3.type;
|
||||
|
||||
$(currentTarget).closest('.js-click-to-select').toggleClass('is-hover', type === 'mouseover');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
}).on('click', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var ajaxObject = Drupal.ajax({
|
||||
wrapper: 'media-library-content',
|
||||
url: e.currentTarget.href,
|
||||
|
@ -45,49 +44,45 @@
|
|||
if (this.progress.element) {
|
||||
$(this.progress.element).remove();
|
||||
}
|
||||
|
||||
if (this.progress.object) {
|
||||
this.progress.object.stopMonitoring();
|
||||
}
|
||||
$(this.element).prop('disabled', false);
|
||||
|
||||
$(this.element).prop('disabled', false);
|
||||
Object.keys(response || {}).forEach(function (i) {
|
||||
if (response[i].command && _this.commands[response[i].command]) {
|
||||
_this.commands[response[i].command](_this, response[i], status);
|
||||
}
|
||||
});
|
||||
|
||||
$('#media-library-content :tabbable:first').focus();
|
||||
|
||||
this.settings = null;
|
||||
};
|
||||
ajaxObject.execute();
|
||||
|
||||
ajaxObject.execute();
|
||||
$menu.find('.active-tab').remove();
|
||||
$menu.find('a').removeClass('active');
|
||||
$(e.currentTarget).addClass('active').html(Drupal.t('<span class="visually-hidden">Show </span>@title<span class="visually-hidden"> media</span><span class="active-tab visually-hidden"> (selected)</span>', { '@title': $(e.currentTarget).data('title') }));
|
||||
|
||||
$(e.currentTarget).addClass('active').html(Drupal.t('<span class="visually-hidden">Show </span>@title<span class="visually-hidden"> media</span><span class="active-tab visually-hidden"> (selected)</span>', {
|
||||
'@title': $(e.currentTarget).data('title')
|
||||
}));
|
||||
Drupal.announce(Drupal.t('Showing @title media.', {
|
||||
'@title': $(e.currentTarget).data('title')
|
||||
}));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.MediaLibraryViewsDisplay = {
|
||||
attach: function attach(context) {
|
||||
var $view = $(context).hasClass('.js-media-library-view') ? $(context) : $('.js-media-library-view', context);
|
||||
|
||||
$view.closest('.views-element-container').attr('id', 'media-library-view');
|
||||
|
||||
$('.views-display-link-widget, .views-display-link-widget_table', context).once('media-library-views-display-link').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var $link = $(e.currentTarget);
|
||||
|
||||
var loadingAnnouncement = '';
|
||||
var displayAnnouncement = '';
|
||||
var focusSelector = '';
|
||||
|
||||
if ($link.hasClass('views-display-link-widget')) {
|
||||
loadingAnnouncement = Drupal.t('Loading grid view.');
|
||||
displayAnnouncement = Drupal.t('Changed to grid view.');
|
||||
|
@ -110,6 +105,7 @@
|
|||
|
||||
if (displayAnnouncement || focusSelector) {
|
||||
var success = ajaxObject.success;
|
||||
|
||||
ajaxObject.success = function (response, status) {
|
||||
success.bind(this)(response, status);
|
||||
|
||||
|
@ -131,7 +127,6 @@
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.MediaLibraryItemSelection = {
|
||||
attach: function attach(context, settings) {
|
||||
var $form = $('.js-media-library-views-form, .js-media-library-add-form', context);
|
||||
|
@ -155,14 +150,13 @@
|
|||
var selectItemsText = remaining < 0 ? Drupal.formatPlural(currentSelection.length, '1 item selected', '@count items selected') : Drupal.formatPlural(remaining, '@selected of @count item selected', '@selected of @count items selected', {
|
||||
'@selected': currentSelection.length
|
||||
});
|
||||
|
||||
$('.js-media-library-selected-count').html(selectItemsText);
|
||||
}
|
||||
|
||||
$mediaItems.once('media-item-change').on('change', function (e) {
|
||||
var id = e.currentTarget.value;
|
||||
|
||||
var position = currentSelection.indexOf(id);
|
||||
|
||||
if (e.currentTarget.checked) {
|
||||
if (position === -1) {
|
||||
currentSelection.push(id);
|
||||
|
@ -172,10 +166,8 @@
|
|||
}
|
||||
|
||||
$form.find('#media-library-modal-selection').val(currentSelection.join()).trigger('change');
|
||||
|
||||
$('.js-media-library-add-form-current-selection').val(currentSelection.join());
|
||||
});
|
||||
|
||||
$('#media-library-modal-selection', $form).once('media-library-selection-change').on('change', function (e) {
|
||||
updateSelectionCount(settings.media_library.selection_remaining);
|
||||
|
||||
|
@ -186,22 +178,21 @@
|
|||
enableItems($mediaItems);
|
||||
}
|
||||
});
|
||||
|
||||
currentSelection.forEach(function (value) {
|
||||
$form.find('input[type="checkbox"][value="' + value + '"]').prop('checked', true).trigger('change');
|
||||
$form.find("input[type=\"checkbox\"][value=\"".concat(value, "\"]")).prop('checked', true).trigger('change');
|
||||
});
|
||||
|
||||
$(window).once('media-library-selection-info').on('dialog:aftercreate', function () {
|
||||
var $buttonPane = $('.media-library-widget-modal .ui-dialog-buttonpane');
|
||||
|
||||
if (!$buttonPane.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
$buttonPane.append(Drupal.theme('mediaLibrarySelectionCount'));
|
||||
updateSelectionCount(settings.media_library.selection_remaining);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.MediaLibraryModalClearSelection = {
|
||||
attach: function attach() {
|
||||
$(window).once('media-library-clear-selection').on('dialog:afterclose', function () {
|
||||
|
@ -211,6 +202,6 @@
|
|||
};
|
||||
|
||||
Drupal.theme.mediaLibrarySelectionCount = function () {
|
||||
return '<div class="media-library-selected-count js-media-library-selected-count" role="status" aria-live="polite" aria-atomic="true"></div>';
|
||||
return "<div class=\"media-library-selected-count js-media-library-selected-count\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"></div>";
|
||||
};
|
||||
})(jQuery, Drupal, window);
|
|
@ -9,13 +9,12 @@
|
|||
Drupal.behaviors.MediaLibrarySelectAll = {
|
||||
attach: function attach(context) {
|
||||
var $view = $('.js-media-library-view[data-view-display-id="page"]', context).once('media-library-select-all');
|
||||
|
||||
if ($view.length && $view.find('.js-media-library-item').length) {
|
||||
var $checkbox = $(Drupal.theme('checkbox')).on('click', function (_ref) {
|
||||
var currentTarget = _ref.currentTarget;
|
||||
|
||||
var $checkboxes = $(currentTarget).closest('.js-media-library-view').find('.js-media-library-item input[type="checkbox"]');
|
||||
$checkboxes.prop('checked', $(currentTarget).prop('checked')).trigger('change');
|
||||
|
||||
var announcement = $(currentTarget).prop('checked') ? Drupal.t('All @count items selected', {
|
||||
'@count': $checkboxes.length
|
||||
}) : Drupal.t('Zero items selected');
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.MediaLibraryWidgetToggleWeight = {
|
||||
attach: function attach(context) {
|
||||
var strings = {
|
||||
|
@ -36,14 +35,12 @@
|
|||
$('.js-media-library-item-weight', context).once('media-library-toggle').parent().hide();
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.MediaLibraryWidgetDisableButton = {
|
||||
attach: function attach(context) {
|
||||
$('.js-media-library-open-button[data-disabled-focus="true"]', context).once('media-library-disable').each(function () {
|
||||
var _this = this;
|
||||
|
||||
$(this).focus();
|
||||
|
||||
setTimeout(function () {
|
||||
$(_this).attr('disabled', 'disabled');
|
||||
}, 50);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
classes: {}
|
||||
}
|
||||
},
|
||||
|
||||
requiredContent: new CKEDITOR.style({
|
||||
element: 'drupal-media',
|
||||
attributes: {
|
||||
|
@ -34,14 +33,14 @@
|
|||
'data-entity-uuid': ''
|
||||
}
|
||||
}),
|
||||
modes: { wysiwyg: 1 },
|
||||
|
||||
modes: {
|
||||
wysiwyg: 1
|
||||
},
|
||||
canUndo: true,
|
||||
exec: function exec(editor) {
|
||||
var saveCallback = function saveCallback(values) {
|
||||
editor.fire('saveSnapshot');
|
||||
var mediaElement = editor.document.createElement('drupal-media');
|
||||
|
||||
var attributes = values.attributes;
|
||||
Object.keys(attributes).forEach(function (key) {
|
||||
mediaElement.setAttribute(key, attributes[key]);
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
Drupal.behaviors.menuUiChangeParentItems = {
|
||||
attach: function attach(context, settings) {
|
||||
var $menu = $('#edit-menu').once('menu-parent');
|
||||
|
||||
if ($menu.length) {
|
||||
Drupal.menuUiUpdateParentList();
|
||||
|
||||
$menu.on('change', 'input', Drupal.menuUiUpdateParentList);
|
||||
}
|
||||
}
|
||||
|
@ -20,29 +20,25 @@
|
|||
Drupal.menuUiUpdateParentList = function () {
|
||||
var $menu = $('#edit-menu');
|
||||
var values = [];
|
||||
|
||||
$menu.find('input:checked').each(function () {
|
||||
values.push(Drupal.checkPlain($.trim($(this).val())));
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: window.location.protocol + '//' + window.location.host + Drupal.url('admin/structure/menu/parents'),
|
||||
url: "".concat(window.location.protocol, "//").concat(window.location.host).concat(Drupal.url('admin/structure/menu/parents')),
|
||||
type: 'POST',
|
||||
data: { 'menus[]': values },
|
||||
data: {
|
||||
'menus[]': values
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function success(options) {
|
||||
var $select = $('#edit-menu-parent');
|
||||
|
||||
var selected = $select.val();
|
||||
|
||||
$select.children().remove();
|
||||
|
||||
var totalOptions = 0;
|
||||
Object.keys(options || {}).forEach(function (machineName) {
|
||||
$select.append($('<option ' + (machineName === selected ? ' selected="selected"' : '') + '></option>').val(machineName).text(options[machineName]));
|
||||
$select.append($("<option ".concat(machineName === selected ? ' selected="selected"' : '', "></option>")).val(machineName).text(options[machineName]));
|
||||
totalOptions++;
|
||||
});
|
||||
|
||||
$select.closest('div').toggle(totalOptions > 0).attr('hidden', totalOptions === 0);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
attach: function attach(context) {
|
||||
$(context).find('.menu-link-form').drupalSetSummary(function (context) {
|
||||
var $context = $(context);
|
||||
|
||||
if ($context.find('.js-form-item-menu-enabled input').is(':checked')) {
|
||||
return Drupal.checkPlain($context.find('.js-form-item-menu-title input').val());
|
||||
}
|
||||
|
@ -18,13 +19,11 @@
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.menuUiLinkAutomaticTitle = {
|
||||
attach: function attach(context) {
|
||||
var $context = $(context);
|
||||
$context.find('.menu-link-form').each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
var $checkbox = $this.find('.js-form-item-menu-enabled input');
|
||||
var $linkTitle = $context.find('.js-form-item-menu-title input');
|
||||
var $title = $this.closest('form').find('.js-form-item-title-0-value input');
|
||||
|
@ -40,7 +39,6 @@
|
|||
$linkTitle.on('keyup', function () {
|
||||
$linkTitle.data('menuLinkAutomaticTitleOverridden', true);
|
||||
});
|
||||
|
||||
$checkbox.on('change', function () {
|
||||
if ($checkbox.is(':checked')) {
|
||||
if (!$linkTitle.data('menuLinkAutomaticTitleOverridden')) {
|
||||
|
@ -50,10 +48,10 @@
|
|||
$linkTitle.val('');
|
||||
$linkTitle.removeData('menuLinkAutomaticTitleOverridden');
|
||||
}
|
||||
|
||||
$checkbox.closest('.vertical-tabs-pane').trigger('summaryUpdated');
|
||||
$checkbox.trigger('formUpdated');
|
||||
});
|
||||
|
||||
$title.on('keyup', function () {
|
||||
if (!$linkTitle.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked')) {
|
||||
$linkTitle.val($title.val());
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
Drupal.behaviors.contentTypes = {
|
||||
attach: function attach(context) {
|
||||
var $context = $(context);
|
||||
|
||||
$context.find('#edit-submission').drupalSetSummary(function (context) {
|
||||
var vals = [];
|
||||
vals.push(Drupal.checkPlain($(context).find('#edit-title-label').val()) || Drupal.t('Requires a title'));
|
||||
|
@ -20,20 +19,19 @@
|
|||
$(context).find('input[name^="options"]:checked').next('label').each(function () {
|
||||
vals.push(Drupal.checkPlain($(this).text()));
|
||||
});
|
||||
|
||||
if (!$(context).find('#edit-options-status').is(':checked')) {
|
||||
vals.unshift(Drupal.t('Not published'));
|
||||
}
|
||||
|
||||
return vals.join(', ');
|
||||
});
|
||||
$('#edit-language', context).drupalSetSummary(function (context) {
|
||||
var vals = [];
|
||||
|
||||
vals.push($('.js-form-item-language-configuration-langcode select option:selected', context).text());
|
||||
|
||||
$('input:checked', context).next('label').each(function () {
|
||||
vals.push(Drupal.checkPlain($(this).text()));
|
||||
});
|
||||
|
||||
return vals.join(', ');
|
||||
});
|
||||
$context.find('#edit-display').drupalSetSummary(function (context) {
|
||||
|
@ -42,9 +40,11 @@
|
|||
$editContext.find('input:checked').next('label').each(function () {
|
||||
vals.push(Drupal.checkPlain($(this).text()));
|
||||
});
|
||||
|
||||
if (!$editContext.find('#edit-display-submitted').is(':checked')) {
|
||||
vals.unshift(Drupal.t("Don't display post information"));
|
||||
}
|
||||
|
||||
return vals.join(', ');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
Drupal.behaviors.nodeDetailsSummaries = {
|
||||
attach: function attach(context) {
|
||||
var $context = $(context);
|
||||
|
||||
$context.find('.node-form-author').drupalSetSummary(function (context) {
|
||||
var $authorContext = $(context);
|
||||
var name = $authorContext.find('.field--name-uid input').val();
|
||||
|
@ -21,14 +20,19 @@
|
|||
'@date': date
|
||||
});
|
||||
}
|
||||
|
||||
if (name) {
|
||||
return Drupal.t('By @name', { '@name': name });
|
||||
return Drupal.t('By @name', {
|
||||
'@name': name
|
||||
});
|
||||
}
|
||||
|
||||
if (date) {
|
||||
return Drupal.t('Authored on @date', { '@date': date });
|
||||
return Drupal.t('Authored on @date', {
|
||||
'@date': date
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$context.find('.node-form-options').drupalSetSummary(function (context) {
|
||||
var $optionsContext = $(context);
|
||||
var vals = [];
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
function clickPreviewModal(event) {
|
||||
if (event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
|
||||
event.preventDefault();
|
||||
var $previewDialog = $('<div>' + Drupal.theme('nodePreviewModal') + '</div>').appendTo('body');
|
||||
var $previewDialog = $("<div>".concat(Drupal.theme('nodePreviewModal'), "</div>")).appendTo('body');
|
||||
Drupal.dialog($previewDialog, {
|
||||
title: Drupal.t('Leave preview?'),
|
||||
buttons: [{
|
||||
|
@ -30,6 +30,7 @@
|
|||
}
|
||||
|
||||
var $preview = $(context).once('node-preview');
|
||||
|
||||
if ($(context).find('.node-preview-container').length) {
|
||||
$preview.on('click.preview', 'a:not([href^="#"], .node-preview-container a)', clickPreviewModal);
|
||||
}
|
||||
|
@ -37,16 +38,17 @@
|
|||
detach: function detach(context, settings, trigger) {
|
||||
if (trigger === 'unload') {
|
||||
var $preview = $(context).find('.content').removeOnce('node-preview');
|
||||
|
||||
if ($preview.length) {
|
||||
$preview.off('click.preview');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.nodePreviewSwitchViewMode = {
|
||||
attach: function attach(context) {
|
||||
var $autosubmit = $(context).find('[data-drupal-autosubmit]').once('autosubmit');
|
||||
|
||||
if ($autosubmit.length) {
|
||||
$autosubmit.on('formUpdated.preview', function () {
|
||||
$(this.form).trigger('submit');
|
||||
|
@ -56,6 +58,6 @@
|
|||
};
|
||||
|
||||
Drupal.theme.nodePreviewModal = function () {
|
||||
return '<p>' + Drupal.t('Leaving the preview will cause unsaved changes to be lost. Are you sure you want to leave the preview?') + '</p><small class="description">' + Drupal.t('CTRL+Left click will prevent this dialog from showing and proceed to the clicked link.') + '</small>';
|
||||
return "<p>".concat(Drupal.t('Leaving the preview will cause unsaved changes to be lost. Are you sure you want to leave the preview?'), "</p><small class=\"description\">").concat(Drupal.t('CTRL+Left click will prevent this dialog from showing and proceed to the clicked link.'), "</small>");
|
||||
};
|
||||
})(jQuery, Drupal);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue