Commit 7a228368 authored by webchick's avatar webchick

Issue #2181527 by nod_, Wim Leers, sqndr: Contextual's toolbar toggle doesn't...

Issue #2181527 by nod_, Wim Leers, sqndr: Contextual's toolbar toggle doesn't appear once the client-side cache is filled.
parent 7eda0ecb
......@@ -41,7 +41,7 @@
* @param string html
* The server-side rendered HTML for this contextual link.
*/
function initContextual($contextual, html) {
function initContextual ($contextual, html) {
var $region = $contextual.closest('.contextual-region');
var contextual = Drupal.contextual;
......@@ -101,7 +101,7 @@
* A contextual links placeholder DOM element, containing the actual
* contextual links as rendered by the server.
*/
function adjustIfNestedAndOverlapping($contextual) {
function adjustIfNestedAndOverlapping ($contextual) {
var $contextuals = $contextual
// @todo confirm that .closest() is not sufficient
.parents('.contextual-region').eq(-1)
......@@ -156,10 +156,17 @@
});
// Update all contextual links placeholders whose HTML is cached.
var uncachedIDs = _.filter(ids, function initIfCached(contextualID) {
var uncachedIDs = _.filter(ids, function initIfCached (contextualID) {
var html = storage.getItem('Drupal.contextual.' + contextualID);
if (html !== null) {
initContextual($context.find('[data-contextual-id="' + contextualID + '"]'), html);
// Initialize after the current executation cycle, to make the AJAX
// request for retrieving the uncached contextual links as soon as
// possible, but also to ensure that other Drupal behaviors have had the
// chance to set up an event listener on the Backbone collection
// Drupal.contextual.collection.
window.setTimeout(function () {
initContextual($context.find('[data-contextual-id="' + contextualID + '"]'), html);
});
return false;
}
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment