Skip to content

Commit

Permalink
Fixed issues that would prevent Incognito / Private browsing to work …
Browse files Browse the repository at this point in the history
…in Safari (fixes #527)
  • Loading branch information
w00fz committed May 3, 2016
1 parent 3447229 commit cfe2188
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Fix for visibility toggle on new page not working [#551](https://github.com/getgrav/grav-plugin-admin/issues/551)
* Page tooltips usability issue [#496](https://github.com/getgrav/grav-plugin-admin/issues/496)
* Fix removed title attribute from editor toolbar buttons [#539](https://github.com/getgrav/grav-plugin-admin/issues/539)
* Allow Incognito / Private browsing to still function in Safari [#527](https://github.com/getgrav/grav-plugin-admin/issues/527)

# v1.1.0-beta.2
## 04/27/2016
Expand Down
1 change: 1 addition & 0 deletions themes/grav/app/pages/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import request from '../utils/request';
import debounce from 'debounce';
import { Instance as pagesTree } from './tree';
import 'selectize';
import '../utils/storage';

/* @formatter:off */
/* eslint-disable */
Expand Down
3 changes: 2 additions & 1 deletion themes/grav/app/pages/tree.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import $ from 'jquery';
import '../utils/storage';

const sessionKey = 'grav:admin:pages';

Expand All @@ -9,7 +10,7 @@ if (!sessionStorage.getItem(sessionKey)) {
export default class PagesTree {
constructor(elements) {
this.elements = $(elements);
this.session = JSON.parse(sessionStorage.getItem(sessionKey));
this.session = JSON.parse(sessionStorage.getItem(sessionKey) || '{}');

if (!this.elements.length) { return; }

Expand Down
41 changes: 41 additions & 0 deletions themes/grav/app/utils/storage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// localStorage
(function() {
function isSupported() {
var item = 'localStoragePollyfill';
try {
localStorage.setItem(item, item);
localStorage.removeItem(item);
sessionStorage.setItem(item, item);
sessionStorage.removeItem(item);
return true;
} catch (e) {
return false;
}
}

if (!isSupported()) {
try {
Storage.prototype._data = {};

Storage.prototype.setItem = function(id, val) {
this._data[id] = String(val);
return this._data[id];
};

Storage.prototype.getItem = function(id) {
return this._data.hasOwnProperty(id) ? this._data[id] : undefined;
};

Storage.prototype.removeItem = function(id) {
return delete this._data[id];
};

Storage.prototype.clear = function() {
this._data = {};
return this._data;
};
} catch (e) {
console.error('localStorage pollyfill error: ', e);
}
}
}());
22 changes: 11 additions & 11 deletions themes/grav/js/admin.min.js

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions themes/grav/js/vendor.min.js

Large diffs are not rendered by default.

0 comments on commit cfe2188

Please sign in to comment.