Skip to content

Commit 7d1e647

Browse files
committed
ui sticky tab memory
1 parent 945a432 commit 7d1e647

File tree

1 file changed

+28
-0
lines changed
  • server/src/main/webapp/public/resources/js

1 file changed

+28
-0
lines changed

server/src/main/webapp/public/resources/js/main.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ PWM_MAIN.loadLocaleBundle = function(bundleName, completeFunction) {
126126

127127
PWM_MAIN.initPage = function() {
128128
PWM_MAIN.applyFormAttributes();
129+
PWM_MAIN.initDisplayTabPreferences();
129130

130131
require(["dojo"], function (dojo) {
131132
if (dojo.isIE) {
@@ -219,6 +220,33 @@ PWM_MAIN.initPage = function() {
219220
console.log('initPage completed');
220221
};
221222

223+
PWM_MAIN.initDisplayTabPreferences = function() {
224+
var storageName = 'lastTabState-' + window.location.pathname + '-';
225+
var knownTabNames = [];
226+
PWM_MAIN.doQuery('div.tab-container>input[type="radio"]',function(formElement) {
227+
var name = formElement.name;
228+
var id = formElement.id;
229+
if (!PWM_MAIN.JSLibrary.arrayContains(knownTabNames,name)) {
230+
knownTabNames.push(name);
231+
}
232+
PWM_MAIN.addEventHandler(formElement, 'click', function(){
233+
PWM_MAIN.Preferences.writeSessionStorage(storageName + name, id);
234+
});
235+
236+
});
237+
238+
knownTabNames.forEach(function(name){
239+
var value = PWM_MAIN.Preferences.readSessionStorage(storageName + name);
240+
if (value) {
241+
var selector = "input[name='" + name + "'][type='radio'][id='" + value + "']";
242+
PWM_MAIN.doQuery(selector,function(formElement){
243+
formElement.checked = true;
244+
});
245+
}
246+
});
247+
};
248+
249+
222250
PWM_MAIN.applyFormAttributes = function() {
223251
PWM_MAIN.doQuery('form',function(formElement) {
224252
formElement.setAttribute('autocomplete', 'off');

0 commit comments

Comments
 (0)