Skip to content

Commit

Permalink
Allow to skip usage of localstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Neumann committed Mar 24, 2017
1 parent 168ca93 commit 5f3dc70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php /* @var $this Aoe_Static_Block_Placeholder */ ?>
<div class="as-placeholder" <?php if ($this->getPlaceholderId()) { echo 'id="'.$this->getPlaceholderId().'"'; } ?> rel="<?php echo $this->getPlaceholderBlockname() ?>">
<div class="as-placeholder"
<?php if ($this->getPlaceholderId()) { echo 'id="'.$this->getPlaceholderId().'"'; } ?>
rel="<?php echo $this->getPlaceholderBlockname() ?>"
<?php // use skip-aoestatic to disable the use of the browsers localstorage (e.g. to show a load spinner) ?>
data-aoestatic="use-localstorage">
<?php echo $this->getChildHtml(); ?>
</div>
9 changes: 6 additions & 3 deletions js/aoestatic/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ var Aoe_Static = {
}
var rel = $(this).attr('rel');
if (rel) {
var localStorageKey = Aoe_Static._getLocalStorageKey(rel);
if (localStorage.getItem(localStorageKey)) {
Aoe_Static._replaceBlock(id, localStorage.getItem(localStorageKey));
var dataAttribute = $(this).attr('data-aoestatic');
if (!dataAttribute || dataAttribute !== 'skip-localstorage') {
var localStorageKey = Aoe_Static._getLocalStorageKey(rel);
if (localStorage.getItem(localStorageKey)) {
Aoe_Static._replaceBlock(id, localStorage.getItem(localStorageKey));
}
}
data.getBlocks[id] = rel;
counter++;
Expand Down

0 comments on commit 5f3dc70

Please sign in to comment.