2011-11-24 21:29:07 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
2017-05-23 14:30:14 +00:00
|
|
|
* https://www.drupal.org/node/2815083
|
2017-05-19 22:12:53 +00:00
|
|
|
* @preserve
|
|
|
|
**/
|
2011-11-24 21:29:07 +00:00
|
|
|
|
2014-01-22 14:27:17 +00:00
|
|
|
(function ($, Drupal, drupalSettings, _, Backbone, JSON, storage) {
|
2017-05-19 22:12:53 +00:00
|
|
|
var options = $.extend(drupalSettings.contextual, {
|
|
|
|
strings: {
|
|
|
|
open: Drupal.t('Open'),
|
|
|
|
close: Drupal.t('Close')
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2017-05-19 22:12:53 +00:00
|
|
|
});
|
2013-05-02 04:36:21 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
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) {
|
|
|
|
if (key.substring(0, 18) === 'Drupal.contextual.') {
|
|
|
|
storage.removeItem(key);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
storage.setItem('Drupal.contextual.permissionsHash', permissionsHash);
|
|
|
|
}
|
2013-05-03 12:42:39 +00:00
|
|
|
|
2018-03-05 09:14:08 +00:00
|
|
|
function adjustIfNestedAndOverlapping($contextual) {
|
|
|
|
var $contextuals = $contextual.parents('.contextual-region').eq(-1).find('.contextual');
|
|
|
|
|
|
|
|
if ($contextuals.length <= 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-02 18:48:06 +00:00
|
|
|
function initContextual($contextual, html) {
|
2014-01-27 21:41:32 +00:00
|
|
|
var $region = $contextual.closest('.contextual-region');
|
|
|
|
var contextual = Drupal.contextual;
|
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
$contextual.html(html).addClass('contextual').prepend(Drupal.theme('contextualTrigger'));
|
2014-01-27 21:41:32 +00:00
|
|
|
|
2018-10-26 06:33:00 +00:00
|
|
|
var destination = 'destination=' + Drupal.encodePath(Drupal.url(drupalSettings.path.currentPath));
|
2014-01-27 21:41:32 +00:00
|
|
|
$contextual.find('.contextual-links a').each(function () {
|
|
|
|
var url = this.getAttribute('href');
|
2017-05-19 22:12:53 +00:00
|
|
|
var glue = url.indexOf('?') === -1 ? '?' : '&';
|
2014-01-27 21:41:32 +00:00
|
|
|
this.setAttribute('href', url + glue + destination);
|
|
|
|
});
|
2013-02-01 16:24:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
var model = new contextual.StateModel({
|
2015-04-15 07:59:36 +00:00
|
|
|
title: $region.find('h2').eq(0).text().trim()
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
2017-05-19 22:12:53 +00:00
|
|
|
var viewOptions = $.extend({ el: $contextual, model: model }, options);
|
2014-01-27 21:41:32 +00:00
|
|
|
contextual.views.push({
|
|
|
|
visual: new contextual.VisualView(viewOptions),
|
|
|
|
aural: new contextual.AuralView(viewOptions),
|
|
|
|
keyboard: new contextual.KeyboardView(viewOptions)
|
|
|
|
});
|
2017-05-19 22:12:53 +00:00
|
|
|
contextual.regionViews.push(new contextual.RegionView($.extend({ el: $region, model: model }, options)));
|
2014-01-27 21:41:32 +00:00
|
|
|
|
|
|
|
contextual.collection.add(model);
|
|
|
|
|
|
|
|
$(document).trigger('drupalContextualLinkAdded', {
|
|
|
|
$el: $contextual,
|
|
|
|
$region: $region,
|
|
|
|
model: model
|
|
|
|
});
|
2013-05-03 12:42:39 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
adjustIfNestedAndOverlapping($contextual);
|
2013-05-02 04:36:21 +00:00
|
|
|
}
|
2013-02-01 16:24:51 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.contextual = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2014-01-27 21:41:32 +00:00
|
|
|
var $context = $(context);
|
|
|
|
|
|
|
|
var $placeholders = $context.find('[data-contextual-id]').once('contextual-render');
|
|
|
|
if ($placeholders.length === 0) {
|
|
|
|
return;
|
2014-01-22 14:27:17 +00:00
|
|
|
}
|
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
var ids = [];
|
|
|
|
$placeholders.each(function () {
|
SA-CORE-2018-006 by alexpott, attilatilman, bkosborne, catch, bonus, Wim Leers, Sam152, Berdir, Damien Tournoud, Dave Reid, Kova101, David_Rothstein, dawehner, dsnopek, samuel.mortenson, stefan.r, tedbow, xjm, timmillwood, pwolanin, njbooher, dyates, effulgentsia, klausi, mlhess, larowlan
2018-10-17 22:46:04 +00:00
|
|
|
ids.push({
|
|
|
|
id: $(this).attr('data-contextual-id'),
|
|
|
|
token: $(this).attr('data-contextual-token')
|
|
|
|
});
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
|
|
|
|
SA-CORE-2018-006 by alexpott, attilatilman, bkosborne, catch, bonus, Wim Leers, Sam152, Berdir, Damien Tournoud, Dave Reid, Kova101, David_Rothstein, dawehner, dsnopek, samuel.mortenson, stefan.r, tedbow, xjm, timmillwood, pwolanin, njbooher, dyates, effulgentsia, klausi, mlhess, larowlan
2018-10-17 22:46:04 +00:00
|
|
|
var uncachedIDs = [];
|
|
|
|
var uncachedTokens = [];
|
|
|
|
ids.forEach(function (contextualID) {
|
|
|
|
var html = storage.getItem('Drupal.contextual.' + contextualID.id);
|
2017-03-28 14:25:09 +00:00
|
|
|
if (html && html.length) {
|
2014-03-07 20:00:10 +00:00
|
|
|
window.setTimeout(function () {
|
SA-CORE-2018-006 by alexpott, attilatilman, bkosborne, catch, bonus, Wim Leers, Sam152, Berdir, Damien Tournoud, Dave Reid, Kova101, David_Rothstein, dawehner, dsnopek, samuel.mortenson, stefan.r, tedbow, xjm, timmillwood, pwolanin, njbooher, dyates, effulgentsia, klausi, mlhess, larowlan
2018-10-17 22:46:04 +00:00
|
|
|
initContextual($context.find('[data-contextual-id="' + contextualID.id + '"]'), html);
|
2014-03-07 20:00:10 +00:00
|
|
|
});
|
SA-CORE-2018-006 by alexpott, attilatilman, bkosborne, catch, bonus, Wim Leers, Sam152, Berdir, Damien Tournoud, Dave Reid, Kova101, David_Rothstein, dawehner, dsnopek, samuel.mortenson, stefan.r, tedbow, xjm, timmillwood, pwolanin, njbooher, dyates, effulgentsia, klausi, mlhess, larowlan
2018-10-17 22:46:04 +00:00
|
|
|
return;
|
2013-05-20 08:35:41 +00:00
|
|
|
}
|
SA-CORE-2018-006 by alexpott, attilatilman, bkosborne, catch, bonus, Wim Leers, Sam152, Berdir, Damien Tournoud, Dave Reid, Kova101, David_Rothstein, dawehner, dsnopek, samuel.mortenson, stefan.r, tedbow, xjm, timmillwood, pwolanin, njbooher, dyates, effulgentsia, klausi, mlhess, larowlan
2018-10-17 22:46:04 +00:00
|
|
|
uncachedIDs.push(contextualID.id);
|
|
|
|
uncachedTokens.push(contextualID.token);
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (uncachedIDs.length > 0) {
|
|
|
|
$.ajax({
|
|
|
|
url: Drupal.url('contextual/render'),
|
|
|
|
type: 'POST',
|
SA-CORE-2018-006 by alexpott, attilatilman, bkosborne, catch, bonus, Wim Leers, Sam152, Berdir, Damien Tournoud, Dave Reid, Kova101, David_Rothstein, dawehner, dsnopek, samuel.mortenson, stefan.r, tedbow, xjm, timmillwood, pwolanin, njbooher, dyates, effulgentsia, klausi, mlhess, larowlan
2018-10-17 22:46:04 +00:00
|
|
|
data: { 'ids[]': uncachedIDs, 'tokens[]': uncachedTokens },
|
2014-01-27 21:41:32 +00:00
|
|
|
dataType: 'json',
|
2017-05-19 22:12:53 +00:00
|
|
|
success: function success(results) {
|
2014-01-27 21:41:32 +00:00
|
|
|
_.each(results, function (html, contextualID) {
|
|
|
|
storage.setItem('Drupal.contextual.' + contextualID, html);
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (html.length > 0) {
|
2015-01-10 01:36:01 +00:00
|
|
|
$placeholders = $context.find('[data-contextual-id="' + contextualID + '"]');
|
2014-01-27 21:41:32 +00:00
|
|
|
|
|
|
|
for (var i = 0; i < $placeholders.length; i++) {
|
|
|
|
initContextual($placeholders.eq(i), html);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-01-22 14:27:17 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Drupal.contextual = {
|
|
|
|
views: [],
|
|
|
|
|
|
|
|
regionViews: []
|
|
|
|
};
|
|
|
|
|
2018-08-09 15:49:18 +00:00
|
|
|
Drupal.contextual.collection = new Backbone.Collection([], {
|
|
|
|
model: Drupal.contextual.StateModel
|
|
|
|
});
|
2014-01-27 21:41:32 +00:00
|
|
|
|
|
|
|
Drupal.theme.contextualTrigger = function () {
|
|
|
|
return '<button class="trigger visually-hidden focusable" type="button"></button>';
|
|
|
|
};
|
2017-10-16 22:15:27 +00:00
|
|
|
|
|
|
|
$(document).on('drupalContextualLinkAdded', function (event, data) {
|
|
|
|
Drupal.ajax.bindAjaxLinks(data.$el[0]);
|
|
|
|
});
|
2017-05-19 22:12:53 +00:00
|
|
|
})(jQuery, Drupal, drupalSettings, _, Backbone, window.JSON, window.sessionStorage);
|