7604 |
25 Feb 19 |
nicklas |
/* $Id $ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2012 Nicklas Nordborg |
7604 |
25 Feb 19 |
nicklas |
4 |
|
7604 |
25 Feb 19 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
7604 |
25 Feb 19 |
nicklas |
Available at http://base.thep.lu.se/ |
7604 |
25 Feb 19 |
nicklas |
7 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is free software; you can redistribute it and/or |
7604 |
25 Feb 19 |
nicklas |
modify it under the terms of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
as published by the Free Software Foundation; either version 3 |
7604 |
25 Feb 19 |
nicklas |
of the License, or (at your option) any later version. |
7604 |
25 Feb 19 |
nicklas |
12 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is distributed in the hope that it will be useful, |
7604 |
25 Feb 19 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7604 |
25 Feb 19 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7604 |
25 Feb 19 |
nicklas |
GNU General Public License for more details. |
7604 |
25 Feb 19 |
nicklas |
17 |
|
7604 |
25 Feb 19 |
nicklas |
You should have received a copy of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7604 |
25 Feb 19 |
nicklas |
20 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
21 |
|
7604 |
25 Feb 19 |
nicklas |
@author Nicklas |
7604 |
25 Feb 19 |
nicklas |
23 |
*/ |
7604 |
25 Feb 19 |
nicklas |
'use strict'; |
7604 |
25 Feb 19 |
nicklas |
25 |
|
7604 |
25 Feb 19 |
nicklas |
var Options = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var options = {}; |
7604 |
25 Feb 19 |
nicklas |
29 |
|
7604 |
25 Feb 19 |
nicklas |
options.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
31 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSave', options.save); |
7604 |
25 Feb 19 |
nicklas |
34 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('presets', 'change', options.presetOnChange); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSaveAsPreset', options.saveAsPresetOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRemovePreset', options.removePresetOnClick); |
7604 |
25 Feb 19 |
nicklas |
38 |
} |
7604 |
25 Feb 19 |
nicklas |
39 |
|
7604 |
25 Feb 19 |
nicklas |
options.initGroup = function(element, autoInit) |
7604 |
25 Feb 19 |
nicklas |
41 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (autoInit == 'group-toggle') |
7604 |
25 Feb 19 |
nicklas |
43 |
{ |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(element, 'click', options.toggleGroup); |
7604 |
25 Feb 19 |
nicklas |
45 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'group-severity') |
7604 |
25 Feb 19 |
nicklas |
47 |
{ |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(element, 'change', options.setGroupSeverity); |
7604 |
25 Feb 19 |
nicklas |
49 |
} |
7604 |
25 Feb 19 |
nicklas |
50 |
} |
7604 |
25 Feb 19 |
nicklas |
51 |
|
7604 |
25 Feb 19 |
nicklas |
options.save = function() |
7604 |
25 Feb 19 |
nicklas |
53 |
{ |
7604 |
25 Feb 19 |
nicklas |
document.forms['options'].submit(); |
7604 |
25 Feb 19 |
nicklas |
55 |
} |
7604 |
25 Feb 19 |
nicklas |
56 |
|
7604 |
25 Feb 19 |
nicklas |
options.presetOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
58 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['options']; |
7604 |
25 Feb 19 |
nicklas |
var selected = frm.presets.value; |
7604 |
25 Feb 19 |
nicklas |
if (selected == '') |
7604 |
25 Feb 19 |
nicklas |
62 |
{ |
7604 |
25 Feb 19 |
nicklas |
location.href = 'options.jsp?ID='+App.getSessionId()+'&resetToDefault=1'; |
7604 |
25 Feb 19 |
nicklas |
64 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (selected != '---') |
7604 |
25 Feb 19 |
nicklas |
66 |
{ |
7604 |
25 Feb 19 |
nicklas |
location.href = 'options.jsp?ID='+App.getSessionId()+'&presetName='+encodeURIComponent(selected); |
7604 |
25 Feb 19 |
nicklas |
68 |
} |
7604 |
25 Feb 19 |
nicklas |
69 |
} |
7604 |
25 Feb 19 |
nicklas |
70 |
|
7604 |
25 Feb 19 |
nicklas |
options.saveAsPresetOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
72 |
{ |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup('save_preset.jsp?ID='+App.getSessionId(), 'SaveValidationPreset', 450, 300); |
7604 |
25 Feb 19 |
nicklas |
74 |
} |
7604 |
25 Feb 19 |
nicklas |
75 |
|
7604 |
25 Feb 19 |
nicklas |
options.saveAsPreset = function(name) |
7604 |
25 Feb 19 |
nicklas |
77 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['options']; |
7604 |
25 Feb 19 |
nicklas |
frm.cmd.value = 'SaveAsPreset'; |
7604 |
25 Feb 19 |
nicklas |
Forms.addHidden(frm, 'presetName', name); |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
82 |
} |
7604 |
25 Feb 19 |
nicklas |
83 |
|
7604 |
25 Feb 19 |
nicklas |
options.removePresetOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
85 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['options']; |
7604 |
25 Feb 19 |
nicklas |
var selected = frm.presets.value; |
7604 |
25 Feb 19 |
nicklas |
if (selected == '') |
7604 |
25 Feb 19 |
nicklas |
89 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification('btnRemovePreset', 'Built-in presets can\'t be removed'); |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
92 |
} |
7604 |
25 Feb 19 |
nicklas |
if (selected != '---') |
7604 |
25 Feb 19 |
nicklas |
94 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (confirm('Remove preset: \'' + selected + '\'? This can\'t be undone.')) |
7604 |
25 Feb 19 |
nicklas |
96 |
{ |
7604 |
25 Feb 19 |
nicklas |
location.href = 'index.jsp?ID='+App.getSessionId()+'&cmd=RemovePreset&presetName='+encodeURIComponent(selected); |
7604 |
25 Feb 19 |
nicklas |
98 |
} |
7604 |
25 Feb 19 |
nicklas |
99 |
} |
7604 |
25 Feb 19 |
nicklas |
100 |
} |
7604 |
25 Feb 19 |
nicklas |
101 |
|
7604 |
25 Feb 19 |
nicklas |
options.toggleGroup = function(event) |
7604 |
25 Feb 19 |
nicklas |
103 |
{ |
7604 |
25 Feb 19 |
nicklas |
var grpId = Data.get(event.currentTarget, 'group-id'); |
7604 |
25 Feb 19 |
nicklas |
var grp = Doc.element('grp.'+grpId); |
7604 |
25 Feb 19 |
nicklas |
var grpIcon = Doc.element('grp.'+grpId+'.icon').firstChild; |
7604 |
25 Feb 19 |
nicklas |
var vldId = 1; |
7604 |
25 Feb 19 |
nicklas |
var vld = Doc.element('vld.'+grpId+'.'+vldId); |
7604 |
25 Feb 19 |
nicklas |
if (vld && vld.style.display == 'none') |
7604 |
25 Feb 19 |
nicklas |
110 |
{ |
7604 |
25 Feb 19 |
nicklas |
grpIcon.src = App.getRoot()+'images/move_down.png'; |
7604 |
25 Feb 19 |
nicklas |
112 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
114 |
{ |
7604 |
25 Feb 19 |
nicklas |
grpIcon.src = App.getRoot()+'images/move_right.png'; |
7604 |
25 Feb 19 |
nicklas |
116 |
} |
7604 |
25 Feb 19 |
nicklas |
while (vld) |
7604 |
25 Feb 19 |
nicklas |
118 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.showHide(vld); |
7604 |
25 Feb 19 |
nicklas |
vldId++; |
7604 |
25 Feb 19 |
nicklas |
vld = Doc.element('vld.'+grpId+'.'+vldId); |
7604 |
25 Feb 19 |
nicklas |
122 |
} |
7604 |
25 Feb 19 |
nicklas |
123 |
} |
7604 |
25 Feb 19 |
nicklas |
124 |
|
7604 |
25 Feb 19 |
nicklas |
options.setGroupSeverity = function(event) |
7604 |
25 Feb 19 |
nicklas |
126 |
{ |
7604 |
25 Feb 19 |
nicklas |
var grpId = Data.get(event.currentTarget, 'group-id'); |
7604 |
25 Feb 19 |
nicklas |
var selectedSeverity = event.currentTarget.value; |
7604 |
25 Feb 19 |
nicklas |
event.currentTarget.selectedIndex = 0; |
7604 |
25 Feb 19 |
nicklas |
var vldId = 1; |
7604 |
25 Feb 19 |
nicklas |
var vld = Doc.element('select.'+grpId+'.'+vldId); |
7604 |
25 Feb 19 |
nicklas |
while (vld) |
7604 |
25 Feb 19 |
nicklas |
133 |
{ |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < vld.length; i++) |
7604 |
25 Feb 19 |
nicklas |
135 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (vld[i].value == selectedSeverity) |
7604 |
25 Feb 19 |
nicklas |
137 |
{ |
7604 |
25 Feb 19 |
nicklas |
vld.selectedIndex = i; |
7604 |
25 Feb 19 |
nicklas |
i = vld.length; |
7604 |
25 Feb 19 |
nicklas |
140 |
} |
7604 |
25 Feb 19 |
nicklas |
141 |
} |
7604 |
25 Feb 19 |
nicklas |
vldId++; |
7604 |
25 Feb 19 |
nicklas |
vld = Doc.element('select.'+grpId+'.'+vldId); |
7604 |
25 Feb 19 |
nicklas |
144 |
} |
7604 |
25 Feb 19 |
nicklas |
145 |
} |
7604 |
25 Feb 19 |
nicklas |
146 |
|
7604 |
25 Feb 19 |
nicklas |
return options; |
7604 |
25 Feb 19 |
nicklas |
148 |
}(); |
7604 |
25 Feb 19 |
nicklas |
149 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.addElementInitializer(Options.initGroup); |
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(Options.initPage); |
7604 |
25 Feb 19 |
nicklas |
152 |
|
7604 |
25 Feb 19 |
nicklas |
153 |
|