Skip to content

Commit

Permalink
Unique history
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Sep 11, 2014
1 parent c280922 commit b17f12e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/js/f7-intro.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ window.Framework7 = function (params) {
cacheIgnoreGetParameters: false,
cacheDuration: 1000 * 60 * 10, // Ten minutes
preloadPreviousPage: true,
uniqueHistory: false,
// Push State
pushState: false,
pushStateRoot: undefined,
Expand Down
14 changes: 14 additions & 0 deletions src/js/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,17 @@ function _load(view, url, content, options) {
view.url = url;
view.history.push(url);

// Unique history
var history = false;
var historyBecameUnique = false;
if (view.params.uniqueHistory) {
if (view.history.indexOf(url) !== view.history.lastIndexOf(url)) {
view.history = view.history.slice(0, view.history.indexOf(url));
view.history.push(url);
historyBecameUnique = true;
}
}

// Append New Page
pagesContainer.append(newPage[0]);

Expand Down Expand Up @@ -550,6 +561,9 @@ function _load(view, url, content, options) {
oldNavbarInner.remove();
}
}
if (view.params.uniqueHistory && historyBecameUnique) {
view.refreshPreviousPage();
}
}

if (animatePages) {
Expand Down
1 change: 1 addition & 0 deletions src/js/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var View = function (selector, params) {
dynamicNavbar: false,
domCache: false,
linksView: undefined,
uniqueHistory: app.params.uniqueHistory,
swipeBackPage: app.params.swipeBackPage,
swipeBackPageBoxShadow: app.params.swipeBackPageBoxShadow,
swipeBackPageActiveArea: app.params.swipeBackPageActiveArea,
Expand Down

0 comments on commit b17f12e

Please sign in to comment.