summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2014-03-07 12:00:10 -0800
committerwebchick2014-03-07 12:05:54 -0800
commit7a228368c93cb35f1c708b7adab6ef3f9506176c (patch)
treefae3fb8a9d65554341a65a3b5730134c334b8f2d
parent7eda0ecba5e9be2f2ab5e12769c250e29cb815ad (diff)
Issue #2181527 by nod_, Wim Leers, sqndr: Contextual's toolbar toggle doesn't appear once the client-side cache is filled.
-rw-r--r--core/modules/contextual/js/contextual.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/modules/contextual/js/contextual.js b/core/modules/contextual/js/contextual.js
index a843a9a..b01b07f 100644
--- a/core/modules/contextual/js/contextual.js
+++ b/core/modules/contextual/js/contextual.js
@@ -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;