Skip to content

Commit

Permalink
Merge pull request #2304 from yuzawa-san/composer-history
Browse files Browse the repository at this point in the history
Allow history tracking in composer
  • Loading branch information
deniszh committed Jun 10, 2018
2 parents e15593a + 0b8a818 commit 7380410
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 16 additions & 2 deletions webapp/content/js/composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ GraphiteComposer.prototype = {
}
this.window.updateTimeDisplay(timeInfo);
this.window.updateUI();
this.updateImage();
this.updateImage(true);
},

syncTargetList: function () {
Expand All @@ -107,14 +107,28 @@ GraphiteComposer.prototype = {
}, this);
},

updateImage: function () {
updateImage: function (urlLoad) {
/* Set the image's url to reflect this.url's current params */
var img = this.window.getImage();
if (img) {
var now = new Date();
var unixTime = now.valueOf() / 1000;
this.url.setParam('_salt', unixTime.toString() );
img.src = this.url.getURL();
if (this.topWindow && !urlLoad) {
this.url.removeParam('_salt');
this.topWindow.history.pushState('', '', '?' + this.url.queryString);
}
}
},

enableHistory: function (topWindow) {
if (topWindow.history && topWindow.history.pushState) {
this.topWindow = topWindow;
var that = this;
topWindow.onpopstate = function() {
that.loadURL(topWindow.location.href);
};
}
},

Expand Down
3 changes: 2 additions & 1 deletion webapp/graphite/templates/composer.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
recursiveExpand.expand(Browser.trees.graphite, parts);

}

/* Enable forward / backward functionality */
Composer.enableHistory(window.top);
} // init

</script>
Expand Down

0 comments on commit 7380410

Please sign in to comment.