blob: 292d118ae5c78e4cb5b1eb9de48aab681cbf7963 [file] [log] [blame]
Felix Meschbergerb812b2e2010-02-18 15:36:53 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
Carsten Ziegeler149faaa2010-03-10 16:41:53 +000017// tables container - will get hidden, when no config service available
18var configContent = false;
19
20// config table list
21var configTable = false;
22var configBody = false;
23var configRow = false;
24
25// factories table list
Carsten Ziegeler149faaa2010-03-10 16:41:53 +000026var factoryBody = false;
27var factoryRow = false;
Felix Meschbergerb812b2e2010-02-18 15:36:53 +000028
29
Carsten Ziegeler149faaa2010-03-10 16:41:53 +000030// editor dialog
31var editor = false;
Valentin Valchevde160882010-03-22 09:30:38 +000032var editorMessage = false;
Felix Meschbergerb812b2e2010-02-18 15:36:53 +000033
Carsten Ziegeler149faaa2010-03-10 16:41:53 +000034function configure(pid, create) {
35 var uri = pluginRoot + '/' + pid;
Carsten Ziegelerd2637c32012-12-11 17:46:47 +000036 // we have to add a cache killer for IE8
Carsten Ziegeler0d98fa912013-10-21 11:11:43 +000037 var postUri = uri + '?post=true&';
Carsten Ziegelerd2637c32012-12-11 17:46:47 +000038 if ( create ) {
Felix Meschberger27870e82012-12-28 15:19:38 +000039 postUri += param.create + '=1&';
Carsten Ziegelerd2637c32012-12-11 17:46:47 +000040 }
41 postUri = postUri + 'ts='+new Date().getMilliseconds();
Carsten Ziegeler0d98fa912013-10-21 11:11:43 +000042 $.get(postUri, null, displayConfigForm, 'json');
Felix Meschbergerb812b2e2010-02-18 15:36:53 +000043}
44
45function displayConfigForm(obj) {
Carsten Ziegeler149faaa2010-03-10 16:41:53 +000046 var parent = document.getElementById('editorTable');
47 clearChildren( parent )
Felix Meschbergerb812b2e2010-02-18 15:36:53 +000048
Carsten Ziegeler149faaa2010-03-10 16:41:53 +000049 var trEl = tr( );
Felix Meschbergerb812b2e2010-02-18 15:36:53 +000050 parent.appendChild( trEl );
51
Carsten Ziegeler149faaa2010-03-10 16:41:53 +000052 var tdEl = td( null, { colSpan: "2" } );
Felix Meschbergerb812b2e2010-02-18 15:36:53 +000053 trEl.appendChild( tdEl );
54
55 var formEl = createElement( "form", null, {
Carsten Ziegeler149faaa2010-03-10 16:41:53 +000056 id : "editorForm",
Felix Meschbergerb812b2e2010-02-18 15:36:53 +000057 method: "POST",
58 action: pluginRoot + "/" + obj.pid
59 });
60 tdEl.appendChild( formEl );
61
62 var inputEl = createElement( "input", null, {
63 type: "hidden",
Felix Meschberger27870e82012-12-28 15:19:38 +000064 name: param.apply,
Felix Meschbergerb812b2e2010-02-18 15:36:53 +000065 value: "true"
66 });
67 formEl.appendChild( inputEl );
68
69 // add the factory PID as a hidden form field if present
70 if (obj.factoryPid)
71 {
72 inputEl = createElement( "input", null, {
73 type: "hidden",
74 name: "factoryPid",
75 value: obj.factoryPid
76 });
77 formEl.appendChild( inputEl );
78 }
79
80 // add the PID filter as a hidden form field if present
Felix Meschberger27870e82012-12-28 15:19:38 +000081 if (obj[ param.pidFilter ])
Felix Meschbergerb812b2e2010-02-18 15:36:53 +000082 {
83 inputEl = createElement( "input", null, {
84 type: "hidden",
Felix Meschberger27870e82012-12-28 15:19:38 +000085 name: param.pidFilter,
Felix Meschbergerb812b2e2010-02-18 15:36:53 +000086 value: obj.pidFilter
87 });
88 formEl.appendChild( inputEl );
89 }
90
91 inputEl = createElement( "input", null, {
92 type: "hidden",
93 name: "action",
94 value: "ajaxConfigManager"
95 });
96 formEl.appendChild( inputEl );
97
98 var tableEl = createElement( "table", null, {
99 border: 0,
100 width: "100%"
101 });
102 formEl.appendChild( tableEl );
103
104 var bodyEl = createElement( "tbody" );
105 tableEl.appendChild( bodyEl );
106
107 if (obj.description)
108 {
109 trEl = tr( );
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000110 tdEl = td( null, { colSpan: "3" } );
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000111 addText( tdEl, obj.description );
112 trEl.appendChild( tdEl );
113 bodyEl.appendChild( trEl );
114 }
115
Felix Meschbergera87e8592011-12-17 16:19:41 +0000116 if (obj.properties)
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000117 {
Felix Meschbergera87e8592011-12-17 16:19:41 +0000118 printForm(bodyEl, obj.properties);
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000119 }
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000120
121 printConfigurationInfo(parent, obj);
Valentin Valchevde160882010-03-22 09:30:38 +0000122 if ( obj.service_location && obj.bundle_location && obj.service_location != obj.bundle_location) {
123 editorMessage.removeClass('ui-helper-hidden').text(i18n.err_bind.msgFormat(obj.pid, obj.bundle_location, obj.service_location));
124 } else editorMessage.addClass('ui-helper-hidden');
Valentin Valchev0fc8b7b2010-04-15 12:33:58 +0000125
126 // ugly workaround for IE6 and IE7 - these browsers don't show correctly the dialog
127 var ua = navigator.userAgent;
128 if (ua.indexOf('MSIE 6') != -1 || ua.indexOf('MSIE 7') != -1) $(parent).html(parent.innerHTML);
129
Felix Meschberger07741202011-07-07 11:55:53 +0000130 initStaticWidgets(editor
131 .attr('__pid', obj.pid)
132 .attr('__location', obj.bundleLocation?obj.bundleLocation:'')
133 .dialog('option', 'title', obj.title)
134 .dialog('open'));
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000135}
136
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000137/* Element */ function addDefaultValue( /* Element */ element ) {
138 if (element) {
139 element.appendChild(
140 createElement('span', 'default_value ui-state-highlight1 ui-icon ui-icon-alert', {
141 title : i18n.dflt_value
142 })
143 );
144 }
145 return element;
146}
147
Felix Meschbergera87e8592011-12-17 16:19:41 +0000148function printForm( /* Element */ parent, /* Object */ properties ) {
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000149 var propList;
Felix Meschbergera87e8592011-12-17 16:19:41 +0000150 for (var prop in properties)
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000151 {
Felix Meschbergera87e8592011-12-17 16:19:41 +0000152 var attr = properties[prop];
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000153
154 // create optionality element
155 var optElement = false;
156 if (attr.optional) {
157 var elAttributes = {
158 type: "checkbox",
159 name: "opt" + prop,
160 title: i18n.opt_value
161 };
162 if (attr.is_set) {
163 elAttributes['checked'] = 'checked';
164 }
165 optElement = createElement( "input", "optionality", elAttributes);
166 } else {
167 optElement = text( "" );
168 }
169 // create the raw
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000170 var trEl = tr( null, null, [
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000171 td( null, null, [ optElement ] ),
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000172 td( null, null, [ text( attr.name ) ] )
173 ]);
174 parent.appendChild( trEl );
175
176 var tdEl = td( null, { style: { width: "99%" } } );
177 trEl.appendChild( tdEl );
178
179 if (attr.value != undefined)
180 {
181 // check is required to also handle empty strings, 0 and false
Valentin Valchevcb68caa2014-10-20 07:48:07 +0000182 var inputName = (prop == "action" || prop == "propertylist" || prop == "apply" || prop == "delete") ? '$' + prop : prop;
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000183 var inputEl = createInput( inputName, attr.value, attr.type, '99%' );
184 tdEl.appendChild( inputEl );
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000185 tdEl.appendChild( createElement( "br" ) );
186 }
187 else if (typeof(attr.type) == 'object')
188 {
189 // assume attr.values and multiselect
190 createMultiSelect( tdEl, prop, attr.values, attr.type, '99%' );
191 tdEl.appendChild( createElement( "br" ) );
192 }
193 else if (attr.values.length == 0)
194 {
195 tdEl.appendChild( createSpan( prop, "", attr.type ) );
196 }
197 else
198 {
199 for (var i=0;i<attr.values.length;i++)
200 {
201 tdEl.appendChild( createSpan( prop, attr.values[i], attr.type ) );
202 }
203 }
204
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000205 if (!attr.is_set) {
206 addDefaultValue( tdEl );
207 }
208
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000209 if (attr.description)
210 {
211 addText( tdEl, attr.description );
212 }
213
214 if (propList) {
215 propList += ',' + prop;
216 } else {
217 propList = prop;
218 }
219 }
220
221 parent.appendChild( createElement( "input", null, {
222 type: "hidden",
Felix Meschberger27870e82012-12-28 15:19:38 +0000223 name: param.propertylist,
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000224 value: propList
225 })
226 );
Felix Meschbergera87e8592011-12-17 16:19:41 +0000227
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000228 // FIX for IE6 and above: checkbox can only be checked after it is in the DOM
229 $(".checked_box").attr("checked", true).removeClass("checked_box");
230}
231
232function printConfigurationInfo( /* Element */ parent, obj )
233{
234 parent.appendChild( tr( null, null, [
235 createElement( "th", null, { colSpan: "2" }, [
236 text( i18n.cfg_title )
237 ])
238 ])
239 );
240
241 parent.appendChild( tr( null, null, [
242 td( null, null, [
243 text( i18n.pid )
244 ]),
245 td( null, null, [
246 text( obj.pid )
247 ])
248 ])
249 );
250
251 if (obj.factoryPid)
252 {
253 parent.appendChild( tr( null, null, [
254 td( null, null, [
255 text( i18n.fpid )
256 ]),
257 td( null, null, [
258 text( obj.factoryPid )
259 ])
260 ])
261 );
262 }
263
264 var binding = obj.bundleLocation;
265 if (!binding)
266 {
267 binding = i18n.unbound;
268 }
269
270 parent.appendChild( tr( null, null, [
271 td( null, null, [
272 text( i18n.binding )
273 ]),
274 td( null, null, [
275 text( binding )
276 ])
277 ])
278 );
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000279
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000280}
281
282
283var spanCounter = 0;
284/* Element */ function createSpan(prop, value, type) {
285 spanCounter++;
286 var newId = prop + spanCounter;
287
288 var addButton = createElement("input", null,
289 { type: "button",
290 style: {width : "5%"},
291 value: "+"
292 }
293 );
294 $(addButton).click(function() {addValue(prop, newId)});
295 var remButton = createElement("input", null,
296 { type: "button",
297 style: {width : "5%"},
298 value: "-"
299 }
300 );
301 $(remButton).click(function() {removeValue(newId)});
302 var spanEl = createElement( "span", null, { id: newId }, [
303 createInput( prop, value, type, '89%' ), addButton, remButton,
304 createElement("br")
305 ]);
306
307 return spanEl;
308}
309
310/* Element */ function createInput(prop, value, type, width) {
311 if (type == 11) { // AttributeDefinition.BOOLEAN
312
313 var inputEl = createElement( "input", null, {
314 type: "checkbox",
315 name: prop,
316 value: "true"
317 });
318
319 if (value && typeof(value) != "boolean")
320 {
321 value = value.toString().toLowerCase() == "true";
322 }
323 if (value)
324 {
325 $(inputEl).addClass("checked_box");
326 }
327 var hiddenEl = createElement( "input", null, {
328 type: "hidden",
329 name: prop,
330 value: "false"
331 });
332 var divEl = createElement("div");
333 divEl.appendChild(inputEl);
334 divEl.appendChild(hiddenEl);
335 return divEl;
336
337 } else if (typeof(type) == "object") { // predefined values
338
339 var selectEl = createElement( "select", null, {
340 name: prop,
341 style: { width: width }
342 });
343
344 var labels = type.labels;
345 var values = type.values;
346 for (var idx in labels) {
347 var optionEl = createElement( "option", null, {
348 value: values[idx]
349 }, [ text( labels[idx] ) ]);
350
351 if (value == values[idx])
352 {
353 optionEl.setAttribute( "selected", true );
354 }
355 selectEl.appendChild( optionEl );
356 }
357
358 return selectEl;
359
360 } else { // Simple
Felix Meschbergerd5fe6b62011-12-17 15:26:02 +0000361 // Metatype 1.2: Attr type 12 is PASSWORD
362 var elType = (type == 12) ? "password" : "text";
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000363 return createElement( "input", null, {
Felix Meschbergerd5fe6b62011-12-17 15:26:02 +0000364 type: elType,
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000365 name: prop,
366 value: value,
367 style: { width: width }
368 });
369 }
370}
371
372function createMultiSelect(/* Element */ parent, prop, values, options, width) {
373 // convert value list into 'set'
374 var valueSet = new Object();
375 for (var idx in values) {
376 valueSet[ values[idx] ] = true;
377 }
378
379 var labels = options.labels;
380 var values = options.values;
381 for (var idx in labels) {
382
383 var inputEl = createElement( "input", null, {
384 type: "checkbox",
385 name: prop,
386 value: values[idx]
387 });
388
389 if (valueSet[ values[idx] ])
390 {
391 inputEl.setAttribute( "checked", true );
392 }
393
394 var labelEl = createElement( "label", "multiselect" );
395 labelEl.appendChild( inputEl );
396 addText( labelEl, labels[idx] );
397
398 parent.appendChild( labelEl );
399 }
400}
401
402
403function addValue(prop, vidx)
404{
405 var span = document.getElementById(vidx);
406 if (!span)
407 {
408 return;
409 }
410 var newSpan = createSpan(prop, '');
411 span.parentNode.insertBefore(newSpan, span.nextSibling);
412 // FIX for IE6 and above: checkbox can only be checked after it is in the DOM
413 $(".checked_box").attr("checked", true).removeClass("checked_box");
414 //$(span).ready(initStaticWidgets);
415}
416
417function removeValue(vidx)
418{
419 var span = document.getElementById(vidx);
420 if (!span)
421 {
422 return;
423 }
424 span.parentNode.removeChild(span);
425}
426
427function configConfirm(/* String */ message, /* String */ title, /* String */ location)
428{
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000429 if (title) {
430 message += "\r\n" + i18n.del_config + title;
431 }
432 if (location) {
433 message += "\r\n" + i18n.del_bundle + location;
434 }
435
436 return confirm(message);
437}
438
Felix Meschberger07741202011-07-07 11:55:53 +0000439function deleteConfig(/* String */ configId, /* String */ bundleLocation)
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000440{
Felix Meschberger07741202011-07-07 11:55:53 +0000441 if ( configConfirm(i18n.del_ask, configId, bundleLocation) ) {
Valentin Valchev4317f092014-11-26 10:04:11 +0000442 $.post(pluginRoot + '/' + configId, param.apply + '=1&' + param.dele + '=1', function() {
Felix Meschberger07741202011-07-07 11:55:53 +0000443 document.location.href = pluginRoot;
444 }, 'json');
445 return true;
446 }
447 return false;
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000448}
449
Felix Meschberger07741202011-07-07 11:55:53 +0000450function unbindConfig(/* String */ configId, /* String */ bundleLocation)
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000451{
Felix Meschberger07741202011-07-07 11:55:53 +0000452 if ( configConfirm(i18n.unbind_ask, configId, bundleLocation) ) {
Valentin Valchev4317f092014-11-26 10:04:11 +0000453 $.post(pluginRoot + '/' + configId, param.unbind + '=1', function() {
Felix Meschberger07741202011-07-07 11:55:53 +0000454 document.location.href = pluginRoot + '/' + configId;
455 }, 'json');
456 return true;
457 }
458 return false;
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000459}
460
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000461function addConfig(conf) {
462 var tr = configRow.clone().appendTo(configBody);
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000463
464 if (!conf.has_config) {
465 tr.find('td:eq(0)').empty();
466 }
Felix Meschberger67726fe2010-03-17 06:55:00 +0000467
468 // rendering name - indented if factory pid is set
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000469 var nms = tr.find('td:eq(1) div');
Felix Meschberger67726fe2010-03-17 06:55:00 +0000470 if (conf.fpid) {
471 nms.after(conf.id);
472 tr.attr('fpid', conf.name);
473 } else {
474 nms.addClass('ui-helper-hidden').parent().text(conf.name);
475 }
476
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000477 tr.find('td:eq(1)').click(function() { // name & edit
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000478 configure(conf.id);
479 });
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000480 tr.find('td:eq(2)').html(conf.bundle ? '<a href="' + pluginRoot + '/../bundles/' + conf.bundle + '">' + conf.bundle_name + '</a>' : '-'); // binding
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000481
482 // buttons
483 tr.find('li:eq(0)').click(function() { // edit
484 configure(conf.id);
485 });
486 tr.find('li:eq(2)').click(function() { // delete
Felix Meschberger07741202011-07-07 11:55:53 +0000487 deleteConfig(conf.id, conf.bundle_name);
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000488 });
Felix Meschberger07741202011-07-07 11:55:53 +0000489 if (conf.bundle) {
490 tr.find('li:eq(1)').click(function() { // unbind
491 unbindConfig(conf.id, conf.bundle_name);
492 }).removeClass('ui-state-disabled');
493 }
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000494}
495
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000496function addFactoryConfig(conf) {
Felix Meschberger67726fe2010-03-17 06:55:00 +0000497 var tr = factoryRow.clone().appendTo(configTable).attr('fpid', conf.name);
498 //tr.find('td:eq(1)').text(conf.id); // fpid
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000499 tr.find('td:eq(1)').text(conf.name).click(function() { // name & edit
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000500 configure(conf.id, true);
501 });
502 // buttons
Valentin Valchev605354e2014-12-19 08:22:00 +0000503 tr.find('li:eq(0)').click(function() { // edit
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000504 configure(conf.id, true);
505 });
506}
507
Felix Meschberger67726fe2010-03-17 06:55:00 +0000508function treetableExtraction(node) {
509 var td = $(node);
510 var text = td.text();
511 if (!text) return text;
512
513 // current sort order
514 var desc = $(this)[0].sortList[0][1];
515
516 var row = td.parent();
517 var fpid = row.attr('fpid');
518
519 // factory row
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000520 if ( row.hasClass('fpid') && fpid) return fpid + (desc==1?1:0) + text;
Felix Meschberger67726fe2010-03-17 06:55:00 +0000521
522 // bundle or name row
523 if ( fpid ) return fpid + desc + text;
524
525 return mixedLinksExtraction(node);
526};
527
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000528$(document).ready(function() {
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000529 configContent = $('#configContent');
530 // config table list
Felix Meschberger67726fe2010-03-17 06:55:00 +0000531 configTable = $('#configTable');
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000532 configBody = configTable.find('tbody');
Felix Meschberger67726fe2010-03-17 06:55:00 +0000533 configRow = configBody.find('tr:eq(0)').clone();
534 factoryRow = configBody.find('tr:eq(1)').clone();
Felix Meschberger1e671e12010-03-13 15:09:51 +0000535
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000536 // setup button - cannot inline in dialog option because of i18n
537 var _buttons = {};
538 _buttons[i18n.abort] = function() {
539 $(this).dialog('close');
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000540 }
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000541 _buttons[i18n.reset] = function() {
542 var form = document.getElementById('editorForm');
543 if (form) form.reset();
544 }
Felix Meschberger07741202011-07-07 11:55:53 +0000545 _buttons[i18n.del] = function() {
546 if (deleteConfig($(this).attr('__pid'), $(this).attr('__location'))) {
547 $(this).dialog('close');
548 }
549 }
550 _buttons[i18n.unbind_btn] = function() {
551 unbindConfig($(this).attr('__pid'), $(this).attr('__location'));
552 }
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000553 _buttons[i18n.save] = function() {
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000554 // get all the configuration properties names
555 var propListElement = $(this).find('form').find('[name=propertylist]');
556 var propListArray = propListElement.val().split(',');
557
558 // removes the properties, that are unchecked
559 $(this).find('form').find('input.optionality:not(:checked)').each( function(idx, el) {
560 var name = $(el).attr('name').substring(3); // name - 'opt'
561 var index = propListArray.indexOf(name);
562 if (index >= 0) {
563 propListArray.splice(index, 1);
564 }
565 });
566 propListElement.val(propListArray.join(','));
567
Felix Meschbergerc89425a2013-11-04 16:08:19 +0000568 $.post(pluginRoot + '/' + $(this).attr('__pid'), $(this).find('form').serialize(), function() {
Valentin Valchev4b25d4f2011-09-15 07:06:36 +0000569 // reload on success - prevents AJAX errors - see FELIX-3116
570 document.location.href = pluginRoot;
571 });
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000572 $(this).dialog('close');
573 }
574 // prepare editor, but don't open yet!
575 editor = $('#editor').dialog({
576 autoOpen : false,
577 modal : true,
578 width : '90%',
579 closeText: i18n.abort,
580 buttons : _buttons
581 });
Valentin Valchevde160882010-03-22 09:30:38 +0000582 editorMessage = editor.find('p');
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000583
584 // display the configuration data
585 $(".statline").html(configData.status ? i18n.stat_ok : i18n.stat_missing);
586 if (configData.status) {
Felix Meschberger67726fe2010-03-17 06:55:00 +0000587 configBody.empty();
588 var factories = {};
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000589
Felix Meschberger67726fe2010-03-17 06:55:00 +0000590 for(var i in configData.pids) {
591 var c = configData.pids[i];
592 if (c.fpid) {
593 if (!factories[c.fpid]) factories[c.fpid] = new Array();
594 factories[c.fpid].push(c);
595 } else {
596 addConfig(c);
597 }
598 }
599 for(var i in configData.fpids) {
600 addFactoryConfig(configData.fpids[i]);
Felix Meschberger1e671e12010-03-13 15:09:51 +0000601
Felix Meschbergerb58af942011-12-19 12:54:03 +0000602 var fpid = configData.fpids[i].id;
603 var confs = factories[ fpid ];
604 if (confs) {
605 for (var j in confs) {
606 addConfig(confs[j]);
607 }
608 delete factories[ fpid ];
Felix Meschberger67726fe2010-03-17 06:55:00 +0000609 }
610 }
Felix Meschbergerb58af942011-12-19 12:54:03 +0000611 for(var fpid in factories) {
612 var flist = factories[fpid];
613 for(var i in flist) {
614 delete flist[i].fpid; // render as regular config
615 addConfig(flist[i]);
616 }
617 }
Felix Meschberger67726fe2010-03-17 06:55:00 +0000618 initStaticWidgets(configTable);
619
620 // init tablesorte
621 configTable.tablesorter({
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000622 headers: {
623 0: { sorter: false },
624 3: { sorter: false }
625 },
626 sortList: [[1,1]],
Felix Meschberger67726fe2010-03-17 06:55:00 +0000627 textExtraction: treetableExtraction
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000628 }).bind('sortStart', function() { // clear cache, otherwise extraction will not work
Felix Meschberger67726fe2010-03-17 06:55:00 +0000629 var table = $(this).trigger('update');
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000630 }).find('th:eq(1)').click();
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000631 } else {
632 configContent.addClass('ui-helper-hidden');
633 }
634 if (selectedPid) configure(selectedPid);
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000635});