Project

General

Profile

« Previous | Next » 

Revision 5656

include jsTree for navigating the ontology hierarchy when making class selections for the search

View differences:

index.jsp
41 41
                    	    //var BP_SITE = "Sandbox";
42 42
                    	    //var BP_ORG = "OOR";
43 43
                    	  </script>
44
<script language="Javascript" type="text/JavaScript"
45
	src="<%=STYLE_SKINS_URL%>/semtools/bioportal/form_complete.js">
46
</script>
47

  
44
<!--  
45
<script language="Javascript" type="text/JavaScript" src="<%=STYLE_SKINS_URL%>/semtools/bioportal/form_complete.js"></script>
46
-->
47
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/jsTree/_lib/jquery.js"></script>
48
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/jsTree/_lib/jquery.cookie.js"></script>
49
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/jsTree/jquery.jstree.js"></script>
48 50
<script language="javascript" type="text/javascript" src="<%=STYLE_SKINS_URL%>/semtools/semtools.js"></script>
49 51
<script language="javascript" type="text/javascript" src="<%=STYLE_COMMON_URL%>/branding.js"></script>
50 52

  
51
<script language="Javascript" type="text/JavaScript">
53
<script language="Javascript" type="text/JavaScript"><!--
52 54
function populateActiveDomain(divId, class) {
53
	var entity = $("#activeEntities").val() ? $("#activeEntities").val() : "";
54
	var characteristic = $("#activeCharacteristics").val() ? $("#activeCharacteristics").val() : "";
55
	var protocol = $("#activeProtocols").val() ? $("#activeProtocols").val() : "";
56
	var measurement = $("#activeMeasurements").val() ? $("#activeMeasurements").val() : "";
55
	// collect the filtering values we have so far
56
	// these are hidden input fields in the form for holding the selected values
57
	var entity = $("#activeEntitiesValue").val() ? $("#activeEntitiesValue").val() : "";
58
	var characteristic = $("#activeCharacteristicsValue").val() ? $("#activeCharacteristicsValue").val() : "";
59
	var protocol = $("#activeProtocolsValue").val() ? $("#activeProtocolsValue").val() : "";
60
	var measurement = $("#activeMeasurementsValue").val() ? $("#activeMeasurementsValue").val() : "";
57 61
	
58
	var originalValue = $("#" + divId).val();
62
	// TODO: remember the selected value for this when filtering by active domain
63
	var selectedNode = $("#" + divId).jstree("get_selected", $("#" + divId));
64
	var selectedNodeId = $(selectedNode).attr("id");
65
	//alert(divId + " selected node: " + selectedNodeId);
66
	
67
	// load the tree for the given div, passing in the other filtered values
59 68
	$("#" + divId).load(
60
	"<%=SERVLET_URL%>", 
61
	{
62
		'action': "getactivedomain",
63
		'class': class,
64
		'entity': entity,
65
		'characteristic': characteristic,
66
		'protocol': protocol,
67
		'measurement': measurement
68
	}, 
69
	function(response, status, xhr) {
70
	  if (status == "error") {
71
	    var msg = "Sorry but there was an error: ";
72
	    $("#error").html(msg + xhr.status + " " + xhr.statusText);
73
	  }
74
	  // set the original selected value
75
	  $("#" + divId).val(originalValue);
76
	});
69
		"<%=SERVLET_URL%>", 
70
		{
71
			'action': "getactivedomain",
72
			'class': class,
73
			'entity': entity,
74
			'characteristic': characteristic,
75
			'protocol': protocol,
76
			'measurement': measurement
77
		},
78
		// call back function when loading finishes
79
		function(response, status, xhr) {
80
			//alert("callback for: " + divId + " selected node: " + selectedNodeId);
81
			// error
82
			if (status == "error") {
83
				var msg = "Sorry but there was an error: ";
84
				$("#error").html(msg + xhr.status + " " + xhr.statusText);
85
			}
86
 
87
			// make it a js tree
88
			$(function () {
89
				$("#" + divId)
90
					.jstree({
91
						"ui" : {
92
							"select_limit" : 1,
93
							"select_multiple_modifier" : "alt",
94
							"selected_parent_close" : "select_parent"//,
95
							//"initially_select" : [ selectedNodeId ]
96
						},				
97
						//"core" : { "initially_open" : [ selectedNodeId ] },
98
						"plugins" : [ "themes", "html_data", "ui", "cookies" ]
99
					});
100
			});
101

  
102
			// TODO: try to select the original node after refresh with active domain
103
			//$("#" + divId).jstree("open_node", $(selectedNode));
104
			//$("#" + divId).jstree("select_node", $(selectedNode));
105
		});
77 106
}
78 107
function initialize(source) {
108
	// we don't want to reload the source of the filtering request
109
	// but we do want to reload the other trees for active domains
110
	// we reload all of them if no source is given - first time the page loads
79 111
	if (source) {
80
		source = source.id;
112
		source = $(source).attr("id");
81 113
	}
82 114
	if (!source) {
83 115
		source = "";
......
86 118
		populateActiveDomain('activeEntities', 'org.ecoinformatics.sms.annotation.Entity');
87 119
	}
88 120
	if (source != 'activeCharacteristics') {
89
		var v = $('#activeCharacteristics').val();
90 121
		populateActiveDomain('activeCharacteristics', 'org.ecoinformatics.sms.annotation.Characteristic');
91
		$('#activeCharacteristics').val(v);
92 122
	}
93 123
	if (source != 'activeProtocols') {
94
		var v = $('#activeProtocols').val();
95 124
		populateActiveDomain('activeProtocols', 'org.ecoinformatics.sms.annotation.Protocol');
96
		$('#activeProtocols').val(v);
97 125
	}
98 126
	if (source != 'activeMeasurements') {
99
		var v = $('#activeMeasurements').val();
100 127
		populateActiveDomain('activeMeasurements', 'org.ecoinformatics.sms.annotation.Measurement');
101
		$('#activeMeasurements').val(v);
102 128
	}
103 129
}
104
</script>
130
function select(item) {
105 131

  
132
	// get the selected value, stored in the title attribute of the item <a> tag
133
	var value = $(item).attr("title");
134
	//alert("value: " + value);
135
	
136
	// get the parent div so we know what kind of class it is meant to filter
137
	// this is "the first parent of the class 'select'"
138
	var parent = $(item).parents("div.select:first");
139
	//alert("parent: " + parent);
140
	
141
	// set the value for the hidden input value
142
	// the input field of class "value" will hold it, this way we don't need to know the id
143
	var input = $(parent).children("input.value");
144
	$(input).val(value);
145
	//alert("input: " + input);
146

  
147
	// refresh the other trees for active domain after this filtering action
148
	// TODO actually do the active domain filtering when selection is made
149
	//initialize($(parent).children("div"));
150
}
151
function donothing() {}
152
--></script>
153

  
106 154
</head>
107 155
<body onload="initialize()">
108 156
<script language="javascript">
......
149 197
					</tr>
150 198
					<tr>
151 199
						<td>
152
							<select name="activeMeasurements" id="activeMeasurements" multiple="multiple" size="5" style="width: 100%" onchange="initialize(this)">
153
								<option>loading...</option>
154
							</select>
155
							<input type="hidden" name="activeMeasurementsClass" id="activeMeasurementsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Measurement"/>
200
							<div class="select">
201
								<div name="activeMeasurements" id="activeMeasurements" multiple="multiple" size="5" style="width: 100%" onchange="initialize(this)">
202
									<p>loading...</p>
203
								</div>
204
								<input type="hidden" class="value" name="activeMeasurementsValue" id="activeMeasurementsValue"/>
205
								<input type="hidden" name="activeMeasurementsClass" id="activeMeasurementsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Measurement"/>
206
							</div>
156 207
						</td>
157 208
					</tr>
158 209
					<tr>
......
177 228
					</tr>
178 229
					<tr>
179 230
						<td>
180
							(a)
181
							<select name="activeEntities" id="activeEntities" multiple="multiple" size="5" style="width: 216px" onchange="initialize(this)">
182
								<option>loading...</option>
183
							</select>
184
							<input type="hidden" name="activeEntitiesClass" id="activeEntitiesClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Entity"/>
231
							<div class="select">
232
								<div name="activeEntities" id="activeEntities" multiple="multiple" size="5" style="width: 216px" onchange="initialize(this)">
233
									<p>loading...</p>
234
								</div>
235
								<input type="hidden" class="value" name="activeEntitiesValue" id="activeEntitiesValue"/>
236
								<input type="hidden" name="activeEntitiesClass" id="activeEntitiesClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Entity"/>
237
							</div>
185 238
						</td>
186 239
					</tr>
187 240
					<tr>
188 241
						<td colspan="1">
189
							(b)
190 242
							<input type="text" name="dynamicValue" id="dynamicValue" class="bp_form_complete-all-uri" size="30" />
191 243
							<input type="hidden" name="dynamicClass" id="dynamicClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Entity"/>
192 244
						</td>
......
205 257
					</tr>
206 258
					<tr>
207 259
						<td>
208
							<select name="activeCharacteristics" id="activeCharacteristics" multiple="multiple" size="5" style="width: 216px" onchange="initialize(this)">
209
								<option>loading...</option>
210
							</select>
211
							<input type="hidden" name="activeCharacteristicsClass" id="activeCharacteristicsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Characteristic"/>
260
							<div class="select">
261
								<div name="activeCharacteristics" id="activeCharacteristics" multiple="multiple" size="5" style="width: 216px" onchange="initialize(this)">
262
									<p>loading...</p>
263
								</div>
264
								<input type="hidden" class="value" name="activeCharacteristicsValue" id="activeCharacteristicsValue"/>
265
								<input type="hidden" name="activeCharacteristicsClass" id="activeCharacteristicsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Characteristic"/>
266
							</div>
212 267
						</td>
213 268
					</tr>
214 269
					<tr>
......
219 274
					</tr>
220 275
				</table>
221 276
			</td>
222
			<!-- removing Standard
223 277
			<td>
224 278
				<table class="subGroup subGroup_border">
225 279
					<tr>
226 280
						<th colspan="1">
227
							Standard
228
						</th>
229
					</tr>
230
					<tr>
231
						<td>were recorded in units of</td>
232
					</tr>
233
					<tr>
234
						<td>
235
							<select name="activeStandards" id="activeStandards" multiple="multiple" size="5" style="width: 216px" onchange="initialize(this)">
236
								<option>loading...</option>
237
							</select>
238
							<input type="hidden" name="activeStandardsClass" id="activeStandardsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Standard"/>
239
						</td>
240
					</tr>
241
					<tr>
242
						<td colspan="1">
243
							<input type="text" name="dynamicValue" id="dynamicValue" class="bp_form_complete-all-uri" size="30" />
244
							<input type="hidden" name="dynamicClass" id="dynamicClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Standard"/>
245
						</td>
246
					</tr>
247
				</table>
248
			</td>
249
			-->
250
			<td>
251
				<table class="subGroup subGroup_border">
252
					<tr>
253
						<th colspan="1">
254 281
							Protocol
255 282
						</th>
256 283
					</tr>
......
259 286
					</tr>
260 287
					<tr>
261 288
						<td>
262
							<select name="activeProtocols" id="activeProtocols" multiple="multiple" size="5" style="width: 216px" onchange="initialize(this)">
263
								<option>loading...</option>
264
							</select>
265
							<input type="hidden" name="activeProtocolsClass" id="activeProtocolsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Protocol"/>
289
							<div class="select">
290
								<div name="activeProtocols" id="activeProtocols" multiple="multiple" size="5" style="width: 216px" onchange="initialize(this)">
291
									<p>loading...</p>
292
								</div>
293
								<input type="hidden" class="value" name="activeProtocolsValue" id="activeProtocolsValue" />
294
								<input type="hidden" name="activeProtocolsClass" id="activeProtocolsClass" value="http://ecoinformatics.org/oboe/oboe.1.0/oboe-core.owl#Protocol"/>
295
							</div>
266 296
						</td>
267 297
					</tr>
268 298
					<tr>

Also available in: Unified diff