Skip to content

Commit

Permalink
Use browser local storage for UI preferences | refs #37627
Browse files Browse the repository at this point in the history
  • Loading branch information
sdiemer committed Jan 16, 2024
1 parent ba77141 commit 7458d26
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dist/ms-browser.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ms-full.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/ms-browser-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ MSBrowser.prototype.getTopMenuJq = function () {
}
event.data.obj.displayCount = newValue;
$('.ms-browser-more-btn button').text(event.data.obj.moreLabel.replace(/\{count\}/, event.data.obj.displayCount));
jsu.setCookie('catalog-displayCount', newValue);
window.localStorage.setItem('nudgis.legacyCatalog.displayCount', newValue);
});
// detect focus change
try {
Expand Down Expand Up @@ -369,7 +369,7 @@ MSBrowser.prototype.setDisplayAsList = function () {
if (!this.useOverlay) {
$('#global').addClass('max-width-1200');
}
jsu.setCookie('catalog-displayMode', 'list');
window.localStorage.setItem('nudgis.legacyCatalog.displayMode', 'list');
this.channels.refreshDisplay();
this.latest.refreshDisplay();
this.search.refreshDisplay();
Expand All @@ -386,7 +386,7 @@ MSBrowser.prototype.setDisplayAsThumbnails = function () {
if (!this.useOverlay) {
$('#global').removeClass('max-width-1200');
}
jsu.setCookie('catalog-displayMode', 'thumbnail');
window.localStorage.setItem('nudgis.legacyCatalog.displayMode', 'thumbnail');
this.channels.refreshDisplay();
this.latest.refreshDisplay();
this.search.refreshDisplay();
Expand All @@ -398,7 +398,7 @@ MSBrowser.prototype.setDisplayTypesIcons = function (checked) {
} else {
this.$widget.removeClass('show-types-icons');
}
jsu.setCookie('catalog-displayTypesIcons', checked ? 'yes' : 'no');
window.localStorage.setItem('nudgis.legacyCatalog.displayTypesIcons', checked ? 'yes' : 'no');
};
MSBrowser.prototype.getActiveTab = function () {
const $active = $('.ms-browser-tab.active', this.$menu);
Expand Down
6 changes: 3 additions & 3 deletions src/ms-browser-latest.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ MSBrowserLatest.prototype.getMenuJq = function () {
$('.ms-browser-latest-types input', this.$menu).change({ obj: this }, function (event) {
event.data.obj.refreshDisplay(true);
const typeLetter = this.id.split('_')[2][0];
let types = jsu.getCookie('catalog-lastestTypes');
let types = window.localStorage.getItem('nudgis.legacyCatalog.lastestTypes');
if (!types) {
types = 'vlp';
}
Expand All @@ -79,7 +79,7 @@ MSBrowserLatest.prototype.getMenuJq = function () {
} else {
types = types.replace(new RegExp(typeLetter), '');
}
jsu.setCookie('catalog-lastestTypes', types);
window.localStorage.setItem('nudgis.legacyCatalog.lastestTypes', types);
});
}
return this.$menu;
Expand Down Expand Up @@ -107,7 +107,7 @@ MSBrowserLatest.prototype.onShow = function () {

const dc = this.getDisplayableContent();
if (dc.length > 1) {
let types = jsu.getCookie('catalog-lastestTypes');
let types = window.localStorage.getItem('nudgis.legacyCatalog.lastestTypes');
if (!types) {
types = 'cvlp';
}
Expand Down
6 changes: 3 additions & 3 deletions src/ms-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function MSBrowser (options) {
this.moreVideos = [];
this.morePhotosGroups = [];

this.displayCount = jsu.getCookie('catalog-displayCount') || 30;
this.displayCount = window.localStorage.getItem('nudgis.legacyCatalog.displayCount') || 30;

jsu.setObjectAttributes(this, options, [
// allowed options
Expand Down Expand Up @@ -107,14 +107,14 @@ MSBrowser.prototype.init = function () {
}
this.initialized = true;

if (jsu.getCookie('catalog-displayMode') == 'thumbnail') {
if (window.localStorage.getItem('nudgis.legacyCatalog.displayMode') == 'thumbnail') {
this.displayAsThumbnails = true;
if (!this.useOverlay) {
$('#container').removeClass('max-width-1200');
}
}

if (jsu.getCookie('catalog-displayTypesIcons') == 'yes') {
if (window.localStorage.getItem('nudgis.legacyCatalog.displayTypesIcons') == 'yes') {
this.displayTypesIcons = true;
}

Expand Down

0 comments on commit 7458d26

Please sign in to comment.