Skip to content

Commit

Permalink
store sidebar user's preference visibility in localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
saleem-hadad committed Sep 2, 2018
1 parent 0fc9d54 commit e8ab553
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion publishable/assets/js/app.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,20 @@ const app = new Vue({
forceLightSidebar: false
}
},
watch: {
// listen to the sidebar value if changed => if so, cache it.
sidebar: function (newValue, oldValue) {
localStorage.setItem('larecipeSidebar', this.sidebar);
}
},
el: '#app',
mounted() {
// check if the user already save some sidebar's visiblity preferenece
// if yes, load it from the cache.
if(typeof(Storage) !== "undefined" && localStorage.getItem('larecipeSidebar') !== null) {
this.sidebar = localStorage.getItem('larecipeSidebar') == 'true';
}

// heading links
$('.documentation').find('a[name]').each(function () {
var anchor = $('<a href="#' + this.name + '"/>');
Expand Down

0 comments on commit e8ab553

Please sign in to comment.