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 Inherit = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var inherit = {}; |
7604 |
25 Feb 19 |
nicklas |
var joustTree; |
7604 |
25 Feb 19 |
nicklas |
30 |
|
7604 |
25 Feb 19 |
nicklas |
inherit.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
32 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Buttons (on standalone dialog) |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnInherit', inherit.save); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnClone', inherit.save); |
7604 |
25 Feb 19 |
nicklas |
37 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('quickFilter', 'keyup', inherit.quickFilter); |
7604 |
25 Feb 19 |
nicklas |
39 |
|
7604 |
25 Feb 19 |
nicklas |
IconStore.addDefaultIcons(); |
7604 |
25 Feb 19 |
nicklas |
IconStore.addIconSet('Annotatable', 'item.png'); |
7604 |
25 Feb 19 |
nicklas |
IconStore.addIconSet('Annotation', 'annotation.png'); |
7604 |
25 Feb 19 |
nicklas |
IconStore.addIconSet('Parameter', 'parameter.png'); |
7604 |
25 Feb 19 |
nicklas |
IconStore.addIconSet('NonParent', 'item-error.png'); |
7604 |
25 Feb 19 |
nicklas |
45 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('joust', 'joust-select', inherit.onSelect); |
7604 |
25 Feb 19 |
nicklas |
Joust2.draw('joust'); |
7604 |
25 Feb 19 |
nicklas |
joustTree = Data.json('joust', 'joust-tree'); |
7604 |
25 Feb 19 |
nicklas |
49 |
} |
7604 |
25 Feb 19 |
nicklas |
50 |
|
7604 |
25 Feb 19 |
nicklas |
51 |
/** |
7604 |
25 Feb 19 |
nicklas |
Display annotation values in the right frame. |
7604 |
25 Feb 19 |
nicklas |
53 |
*/ |
7604 |
25 Feb 19 |
nicklas |
inherit.onSelect = function(event) |
7604 |
25 Feb 19 |
nicklas |
55 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['annotations']; |
7604 |
25 Feb 19 |
nicklas |
var menuItem = event.target.item; |
7604 |
25 Feb 19 |
nicklas |
if (menuItem.type == 'annotation') |
7604 |
25 Feb 19 |
nicklas |
59 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.element('annotationType').innerHTML = menuItem.annotationType; |
7604 |
25 Feb 19 |
nicklas |
Doc.element('annotationValues').innerHTML = menuItem.values; |
7604 |
25 Feb 19 |
nicklas |
menuItem.modified = menuItem.inherited != frm[menuItem.id].checked; |
7604 |
25 Feb 19 |
nicklas |
63 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (menuItem.type == 'annotation-set') |
7604 |
25 Feb 19 |
nicklas |
65 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (menuItem.children) |
7604 |
25 Feb 19 |
nicklas |
67 |
{ |
7604 |
25 Feb 19 |
nicklas |
var checked = frm[menuItem.id].checked; |
7604 |
25 Feb 19 |
nicklas |
// If the annotation-set is checked all child items should |
7604 |
25 Feb 19 |
nicklas |
// be checked and disabled |
7604 |
25 Feb 19 |
nicklas |
// If the annotation-set is not checked all child items should |
7604 |
25 Feb 19 |
nicklas |
// be enabled and check if they are currently inherited |
7604 |
25 Feb 19 |
nicklas |
for (var childNo = 0; childNo < menuItem.children.length; childNo++) |
7604 |
25 Feb 19 |
nicklas |
74 |
{ |
7604 |
25 Feb 19 |
nicklas |
var child = menuItem.children[childNo]; |
7604 |
25 Feb 19 |
nicklas |
frm[child.id].checked = checked || (child.inherited != child.modified); |
7604 |
25 Feb 19 |
nicklas |
frm[child.id].disabled = checked; |
7604 |
25 Feb 19 |
nicklas |
78 |
} |
7604 |
25 Feb 19 |
nicklas |
79 |
} |
7604 |
25 Feb 19 |
nicklas |
80 |
} |
7604 |
25 Feb 19 |
nicklas |
81 |
|
7604 |
25 Feb 19 |
nicklas |
82 |
} |
7604 |
25 Feb 19 |
nicklas |
83 |
|
7604 |
25 Feb 19 |
nicklas |
inherit.saveInheritedAnnotations = function(clone) |
7604 |
25 Feb 19 |
nicklas |
85 |
{ |
7604 |
25 Feb 19 |
nicklas |
var tree = Doc.element('joust'); |
7604 |
25 Feb 19 |
nicklas |
var target = window.top.opener.document.getElementById(Data.get('page-data', 'callback')); |
7604 |
25 Feb 19 |
nicklas |
88 |
|
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['annotations']; |
7604 |
25 Feb 19 |
nicklas |
var menuElements = tree.getElementsByClassName('joustitem'); |
7604 |
25 Feb 19 |
nicklas |
for (var menuNo = 0; menuNo < menuElements.length; menuNo++) |
7604 |
25 Feb 19 |
nicklas |
92 |
{ |
7604 |
25 Feb 19 |
nicklas |
var menuElement = menuElements[menuNo]; |
7604 |
25 Feb 19 |
nicklas |
var menuItem = menuElement.item; |
7604 |
25 Feb 19 |
nicklas |
95 |
|
7604 |
25 Feb 19 |
nicklas |
var wasInherited = menuItem.inherited; |
7604 |
25 Feb 19 |
nicklas |
var isInherited = frm[menuItem.id].checked; |
7604 |
25 Feb 19 |
nicklas |
if (wasInherited != isInherited) |
7604 |
25 Feb 19 |
nicklas |
99 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (menuItem.type == 'annotation') |
7604 |
25 Feb 19 |
nicklas |
101 |
{ |
7604 |
25 Feb 19 |
nicklas |
var detail = {}; |
7604 |
25 Feb 19 |
nicklas |
detail.id = menuItem.externalId; |
7604 |
25 Feb 19 |
nicklas |
detail.clone = clone; |
7604 |
25 Feb 19 |
nicklas |
if (isInherited) |
7604 |
25 Feb 19 |
nicklas |
106 |
{ |
7604 |
25 Feb 19 |
nicklas |
Events.sendCustomEvent(target, 'inherit-annotation', detail); |
7604 |
25 Feb 19 |
nicklas |
108 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
110 |
{ |
7604 |
25 Feb 19 |
nicklas |
Events.sendCustomEvent(target, 'remove-annotation', detail); |
7604 |
25 Feb 19 |
nicklas |
112 |
} |
7604 |
25 Feb 19 |
nicklas |
113 |
} |
7604 |
25 Feb 19 |
nicklas |
114 |
} |
7604 |
25 Feb 19 |
nicklas |
115 |
} |
7604 |
25 Feb 19 |
nicklas |
116 |
} |
7604 |
25 Feb 19 |
nicklas |
117 |
|
7604 |
25 Feb 19 |
nicklas |
inherit.quickFilter = function() |
7604 |
25 Feb 19 |
nicklas |
119 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['annotations']; |
7604 |
25 Feb 19 |
nicklas |
var filter = frm.quickFilter.value.toLowerCase(); |
7604 |
25 Feb 19 |
nicklas |
var totalVisible = 0; |
7604 |
25 Feb 19 |
nicklas |
for (var itemNo = 0; itemNo < joustTree.length; itemNo++) |
7604 |
25 Feb 19 |
nicklas |
124 |
{ |
7604 |
25 Feb 19 |
nicklas |
var menuItem = joustTree[itemNo]; |
7604 |
25 Feb 19 |
nicklas |
var childrenVisible = 0; |
7604 |
25 Feb 19 |
nicklas |
for (var childNo = 0; childNo < menuItem.children.length; childNo++) |
7604 |
25 Feb 19 |
nicklas |
128 |
{ |
7604 |
25 Feb 19 |
nicklas |
var childItem = menuItem.children[childNo]; |
7604 |
25 Feb 19 |
nicklas |
var visible = !filter || childItem.annotationType.toLowerCase().indexOf(filter)>=0; |
7604 |
25 Feb 19 |
nicklas |
Doc.showHide(childItem.id, visible); |
7604 |
25 Feb 19 |
nicklas |
if (visible) childrenVisible++; |
7604 |
25 Feb 19 |
nicklas |
133 |
} |
7604 |
25 Feb 19 |
nicklas |
totalVisible += childrenVisible; |
7604 |
25 Feb 19 |
nicklas |
Doc.showHide(menuItem.id, childrenVisible > 0); |
7604 |
25 Feb 19 |
nicklas |
136 |
} |
7604 |
25 Feb 19 |
nicklas |
137 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.showHide('noMatchingFilter', totalVisible == 0); |
7604 |
25 Feb 19 |
nicklas |
139 |
} |
7604 |
25 Feb 19 |
nicklas |
140 |
|
7604 |
25 Feb 19 |
nicklas |
141 |
|
7604 |
25 Feb 19 |
nicklas |
142 |
/** |
7604 |
25 Feb 19 |
nicklas |
Save the annotations in standalone mode. |
7604 |
25 Feb 19 |
nicklas |
144 |
*/ |
7604 |
25 Feb 19 |
nicklas |
inherit.save = function(event) |
7604 |
25 Feb 19 |
nicklas |
146 |
{ |
7604 |
25 Feb 19 |
nicklas |
var clone = Data.int(event.currentTarget, 'clone', 0); |
7604 |
25 Feb 19 |
nicklas |
inherit.saveInheritedAnnotations(clone); |
7604 |
25 Feb 19 |
nicklas |
App.closeWindow(); |
7604 |
25 Feb 19 |
nicklas |
150 |
} |
7604 |
25 Feb 19 |
nicklas |
151 |
|
7604 |
25 Feb 19 |
nicklas |
return inherit; |
7604 |
25 Feb 19 |
nicklas |
153 |
}(); |
7604 |
25 Feb 19 |
nicklas |
154 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(Inherit.initPage); |
7604 |
25 Feb 19 |
nicklas |
156 |
|
7604 |
25 Feb 19 |
nicklas |
157 |
|