blob: 4096d5fcc8664f9fc6d37e11d5bd5674eaaab4ab [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'));
Carsten Ziegelerb0efb6d2014-12-29 14:24:03 +0000135
136 // autosize
137 $('textarea').trigger('autosize.resize');
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000138}
139
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000140/* Element */ function addDefaultValue( /* Element */ element ) {
141 if (element) {
142 element.appendChild(
143 createElement('span', 'default_value ui-state-highlight1 ui-icon ui-icon-alert', {
144 title : i18n.dflt_value
145 })
146 );
147 }
148 return element;
149}
150
Felix Meschbergera87e8592011-12-17 16:19:41 +0000151function printForm( /* Element */ parent, /* Object */ properties ) {
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000152 var propList;
Felix Meschbergera87e8592011-12-17 16:19:41 +0000153 for (var prop in properties)
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000154 {
Felix Meschbergera87e8592011-12-17 16:19:41 +0000155 var attr = properties[prop];
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000156
157 // create optionality element
158 var optElement = false;
159 if (attr.optional) {
160 var elAttributes = {
161 type: "checkbox",
162 name: "opt" + prop,
163 title: i18n.opt_value
164 };
165 if (attr.is_set) {
166 elAttributes['checked'] = 'checked';
167 }
168 optElement = createElement( "input", "optionality", elAttributes);
169 } else {
170 optElement = text( "" );
171 }
172 // create the raw
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000173 var trEl = tr( null, null, [
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000174 td( null, null, [ optElement ] ),
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000175 td( null, null, [ text( attr.name ) ] )
176 ]);
177 parent.appendChild( trEl );
178
179 var tdEl = td( null, { style: { width: "99%" } } );
180 trEl.appendChild( tdEl );
181
182 if (attr.value != undefined)
183 {
184 // check is required to also handle empty strings, 0 and false
Valentin Valchevcb68caa2014-10-20 07:48:07 +0000185 var inputName = (prop == "action" || prop == "propertylist" || prop == "apply" || prop == "delete") ? '$' + prop : prop;
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000186 var inputEl = createInput( inputName, attr.value, attr.type, '99%' );
187 tdEl.appendChild( inputEl );
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000188 tdEl.appendChild( createElement( "br" ) );
189 }
190 else if (typeof(attr.type) == 'object')
191 {
192 // assume attr.values and multiselect
193 createMultiSelect( tdEl, prop, attr.values, attr.type, '99%' );
194 tdEl.appendChild( createElement( "br" ) );
195 }
196 else if (attr.values.length == 0)
197 {
198 tdEl.appendChild( createSpan( prop, "", attr.type ) );
199 }
200 else
201 {
202 for (var i=0;i<attr.values.length;i++)
203 {
204 tdEl.appendChild( createSpan( prop, attr.values[i], attr.type ) );
205 }
206 }
207
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000208 if (!attr.is_set) {
209 addDefaultValue( tdEl );
210 }
211
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000212 if (attr.description)
213 {
214 addText( tdEl, attr.description );
215 }
216
217 if (propList) {
218 propList += ',' + prop;
219 } else {
220 propList = prop;
221 }
222 }
223
224 parent.appendChild( createElement( "input", null, {
225 type: "hidden",
Felix Meschberger27870e82012-12-28 15:19:38 +0000226 name: param.propertylist,
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000227 value: propList
228 })
229 );
Felix Meschbergera87e8592011-12-17 16:19:41 +0000230
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000231 // FIX for IE6 and above: checkbox can only be checked after it is in the DOM
232 $(".checked_box").attr("checked", true).removeClass("checked_box");
233}
234
235function printConfigurationInfo( /* Element */ parent, obj )
236{
237 parent.appendChild( tr( null, null, [
238 createElement( "th", null, { colSpan: "2" }, [
239 text( i18n.cfg_title )
240 ])
241 ])
242 );
243
244 parent.appendChild( tr( null, null, [
245 td( null, null, [
246 text( i18n.pid )
247 ]),
248 td( null, null, [
249 text( obj.pid )
250 ])
251 ])
252 );
253
254 if (obj.factoryPid)
255 {
256 parent.appendChild( tr( null, null, [
257 td( null, null, [
258 text( i18n.fpid )
259 ]),
260 td( null, null, [
261 text( obj.factoryPid )
262 ])
263 ])
264 );
265 }
266
267 var binding = obj.bundleLocation;
268 if (!binding)
269 {
270 binding = i18n.unbound;
271 }
272
273 parent.appendChild( tr( null, null, [
274 td( null, null, [
275 text( i18n.binding )
276 ]),
277 td( null, null, [
278 text( binding )
279 ])
280 ])
281 );
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000282
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000283}
284
285
286var spanCounter = 0;
287/* Element */ function createSpan(prop, value, type) {
288 spanCounter++;
289 var newId = prop + spanCounter;
290
291 var addButton = createElement("input", null,
292 { type: "button",
293 style: {width : "5%"},
294 value: "+"
295 }
296 );
297 $(addButton).click(function() {addValue(prop, newId)});
298 var remButton = createElement("input", null,
299 { type: "button",
300 style: {width : "5%"},
301 value: "-"
302 }
303 );
304 $(remButton).click(function() {removeValue(newId)});
305 var spanEl = createElement( "span", null, { id: newId }, [
306 createInput( prop, value, type, '89%' ), addButton, remButton,
307 createElement("br")
308 ]);
309
310 return spanEl;
311}
312
313/* Element */ function createInput(prop, value, type, width) {
314 if (type == 11) { // AttributeDefinition.BOOLEAN
315
316 var inputEl = createElement( "input", null, {
317 type: "checkbox",
318 name: prop,
319 value: "true"
320 });
321
322 if (value && typeof(value) != "boolean")
323 {
324 value = value.toString().toLowerCase() == "true";
325 }
326 if (value)
327 {
328 $(inputEl).addClass("checked_box");
329 }
330 var hiddenEl = createElement( "input", null, {
331 type: "hidden",
332 name: prop,
333 value: "false"
334 });
335 var divEl = createElement("div");
336 divEl.appendChild(inputEl);
337 divEl.appendChild(hiddenEl);
338 return divEl;
339
340 } else if (typeof(type) == "object") { // predefined values
341
342 var selectEl = createElement( "select", null, {
343 name: prop,
344 style: { width: width }
345 });
346
347 var labels = type.labels;
348 var values = type.values;
349 for (var idx in labels) {
350 var optionEl = createElement( "option", null, {
351 value: values[idx]
352 }, [ text( labels[idx] ) ]);
353
354 if (value == values[idx])
355 {
356 optionEl.setAttribute( "selected", true );
357 }
358 selectEl.appendChild( optionEl );
359 }
360
361 return selectEl;
362
Carsten Ziegelerb0efb6d2014-12-29 14:24:03 +0000363 } else if (type == 12) { // Metatype 1.2: Attr type 12 is PASSWORD
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000364 return createElement( "input", null, {
Carsten Ziegelerb0efb6d2014-12-29 14:24:03 +0000365 type: "password",
366 name: prop,
367 value: value,
368 style: { width: width }
369 });
370 } else { // Simple
371 var textareaEl = createElement( "textarea", null, {
372 name: prop,
373 style: { width: width }
374 });
375 addText(textareaEl, value.toString());
376 $(textareaEl).autosize();
377 return textareaEl;
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000378 }
379}
380
381function createMultiSelect(/* Element */ parent, prop, values, options, width) {
382 // convert value list into 'set'
383 var valueSet = new Object();
384 for (var idx in values) {
385 valueSet[ values[idx] ] = true;
386 }
387
388 var labels = options.labels;
389 var values = options.values;
390 for (var idx in labels) {
391
392 var inputEl = createElement( "input", null, {
393 type: "checkbox",
394 name: prop,
395 value: values[idx]
396 });
397
398 if (valueSet[ values[idx] ])
399 {
400 inputEl.setAttribute( "checked", true );
401 }
402
403 var labelEl = createElement( "label", "multiselect" );
404 labelEl.appendChild( inputEl );
405 addText( labelEl, labels[idx] );
406
407 parent.appendChild( labelEl );
408 }
409}
410
411
412function addValue(prop, vidx)
413{
414 var span = document.getElementById(vidx);
415 if (!span)
416 {
417 return;
418 }
419 var newSpan = createSpan(prop, '');
420 span.parentNode.insertBefore(newSpan, span.nextSibling);
421 // FIX for IE6 and above: checkbox can only be checked after it is in the DOM
422 $(".checked_box").attr("checked", true).removeClass("checked_box");
423 //$(span).ready(initStaticWidgets);
424}
425
426function removeValue(vidx)
427{
428 var span = document.getElementById(vidx);
429 if (!span)
430 {
431 return;
432 }
433 span.parentNode.removeChild(span);
434}
435
436function configConfirm(/* String */ message, /* String */ title, /* String */ location)
437{
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000438 if (title) {
439 message += "\r\n" + i18n.del_config + title;
440 }
441 if (location) {
442 message += "\r\n" + i18n.del_bundle + location;
443 }
444
445 return confirm(message);
446}
447
Felix Meschberger07741202011-07-07 11:55:53 +0000448function deleteConfig(/* String */ configId, /* String */ bundleLocation)
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000449{
Felix Meschberger07741202011-07-07 11:55:53 +0000450 if ( configConfirm(i18n.del_ask, configId, bundleLocation) ) {
Valentin Valchev4317f092014-11-26 10:04:11 +0000451 $.post(pluginRoot + '/' + configId, param.apply + '=1&' + param.dele + '=1', function() {
Felix Meschberger07741202011-07-07 11:55:53 +0000452 document.location.href = pluginRoot;
453 }, 'json');
454 return true;
455 }
456 return false;
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000457}
458
Felix Meschberger07741202011-07-07 11:55:53 +0000459function unbindConfig(/* String */ configId, /* String */ bundleLocation)
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000460{
Felix Meschberger07741202011-07-07 11:55:53 +0000461 if ( configConfirm(i18n.unbind_ask, configId, bundleLocation) ) {
Valentin Valchev4317f092014-11-26 10:04:11 +0000462 $.post(pluginRoot + '/' + configId, param.unbind + '=1', function() {
Felix Meschberger07741202011-07-07 11:55:53 +0000463 document.location.href = pluginRoot + '/' + configId;
464 }, 'json');
465 return true;
466 }
467 return false;
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000468}
469
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000470function addConfig(conf) {
471 var tr = configRow.clone().appendTo(configBody);
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000472
473 if (!conf.has_config) {
474 tr.find('td:eq(0)').empty();
475 }
Felix Meschberger67726fe2010-03-17 06:55:00 +0000476
477 // rendering name - indented if factory pid is set
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000478 var nms = tr.find('td:eq(1) div');
Felix Meschberger67726fe2010-03-17 06:55:00 +0000479 if (conf.fpid) {
Carsten Ziegelere1f29c42014-12-29 13:21:01 +0000480 if (conf.nameHint) {
481 nms.after("<span title='" + conf.id + "'>" + conf.nameHint + "</span>");
482 } else {
483 nms.after(conf.id);
484 }
Felix Meschberger67726fe2010-03-17 06:55:00 +0000485 tr.attr('fpid', conf.name);
486 } else {
487 nms.addClass('ui-helper-hidden').parent().text(conf.name);
488 }
489
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000490 tr.find('td:eq(1)').click(function() { // name & edit
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000491 configure(conf.id);
492 });
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000493 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 +0000494
495 // buttons
496 tr.find('li:eq(0)').click(function() { // edit
497 configure(conf.id);
498 });
499 tr.find('li:eq(2)').click(function() { // delete
Felix Meschberger07741202011-07-07 11:55:53 +0000500 deleteConfig(conf.id, conf.bundle_name);
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000501 });
Felix Meschberger07741202011-07-07 11:55:53 +0000502 if (conf.bundle) {
503 tr.find('li:eq(1)').click(function() { // unbind
504 unbindConfig(conf.id, conf.bundle_name);
505 }).removeClass('ui-state-disabled');
506 }
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000507}
508
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000509function addFactoryConfig(conf) {
Felix Meschberger67726fe2010-03-17 06:55:00 +0000510 var tr = factoryRow.clone().appendTo(configTable).attr('fpid', conf.name);
511 //tr.find('td:eq(1)').text(conf.id); // fpid
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000512 tr.find('td:eq(1)').text(conf.name).click(function() { // name & edit
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000513 configure(conf.id, true);
514 });
515 // buttons
Valentin Valchev605354e2014-12-19 08:22:00 +0000516 tr.find('li:eq(0)').click(function() { // edit
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000517 configure(conf.id, true);
518 });
519}
520
Felix Meschberger67726fe2010-03-17 06:55:00 +0000521function treetableExtraction(node) {
522 var td = $(node);
523 var text = td.text();
524 if (!text) return text;
525
526 // current sort order
527 var desc = $(this)[0].sortList[0][1];
528
529 var row = td.parent();
530 var fpid = row.attr('fpid');
531
532 // factory row
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000533 if ( row.hasClass('fpid') && fpid) return fpid + (desc==1?1:0) + text;
Felix Meschberger67726fe2010-03-17 06:55:00 +0000534
535 // bundle or name row
536 if ( fpid ) return fpid + desc + text;
537
538 return mixedLinksExtraction(node);
539};
540
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000541$(document).ready(function() {
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000542 configContent = $('#configContent');
543 // config table list
Felix Meschberger67726fe2010-03-17 06:55:00 +0000544 configTable = $('#configTable');
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000545 configBody = configTable.find('tbody');
Felix Meschberger67726fe2010-03-17 06:55:00 +0000546 configRow = configBody.find('tr:eq(0)').clone();
547 factoryRow = configBody.find('tr:eq(1)').clone();
Felix Meschberger1e671e12010-03-13 15:09:51 +0000548
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000549 // setup button - cannot inline in dialog option because of i18n
550 var _buttons = {};
551 _buttons[i18n.abort] = function() {
552 $(this).dialog('close');
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000553 }
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000554 _buttons[i18n.reset] = function() {
555 var form = document.getElementById('editorForm');
556 if (form) form.reset();
557 }
Felix Meschberger07741202011-07-07 11:55:53 +0000558 _buttons[i18n.del] = function() {
559 if (deleteConfig($(this).attr('__pid'), $(this).attr('__location'))) {
560 $(this).dialog('close');
561 }
562 }
563 _buttons[i18n.unbind_btn] = function() {
564 unbindConfig($(this).attr('__pid'), $(this).attr('__location'));
565 }
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000566 _buttons[i18n.save] = function() {
Valentin Valchevf7fe52e2014-11-17 13:07:24 +0000567 // get all the configuration properties names
568 var propListElement = $(this).find('form').find('[name=propertylist]');
569 var propListArray = propListElement.val().split(',');
570
571 // removes the properties, that are unchecked
572 $(this).find('form').find('input.optionality:not(:checked)').each( function(idx, el) {
573 var name = $(el).attr('name').substring(3); // name - 'opt'
574 var index = propListArray.indexOf(name);
575 if (index >= 0) {
576 propListArray.splice(index, 1);
577 }
578 });
579 propListElement.val(propListArray.join(','));
580
Felix Meschbergerc89425a2013-11-04 16:08:19 +0000581 $.post(pluginRoot + '/' + $(this).attr('__pid'), $(this).find('form').serialize(), function() {
Valentin Valchev4b25d4f2011-09-15 07:06:36 +0000582 // reload on success - prevents AJAX errors - see FELIX-3116
583 document.location.href = pluginRoot;
584 });
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000585 $(this).dialog('close');
586 }
587 // prepare editor, but don't open yet!
588 editor = $('#editor').dialog({
589 autoOpen : false,
590 modal : true,
591 width : '90%',
592 closeText: i18n.abort,
593 buttons : _buttons
594 });
Valentin Valchevde160882010-03-22 09:30:38 +0000595 editorMessage = editor.find('p');
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000596
597 // display the configuration data
598 $(".statline").html(configData.status ? i18n.stat_ok : i18n.stat_missing);
599 if (configData.status) {
Felix Meschberger67726fe2010-03-17 06:55:00 +0000600 configBody.empty();
601 var factories = {};
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000602
Felix Meschberger67726fe2010-03-17 06:55:00 +0000603 for(var i in configData.pids) {
604 var c = configData.pids[i];
605 if (c.fpid) {
606 if (!factories[c.fpid]) factories[c.fpid] = new Array();
607 factories[c.fpid].push(c);
608 } else {
609 addConfig(c);
610 }
611 }
612 for(var i in configData.fpids) {
613 addFactoryConfig(configData.fpids[i]);
Felix Meschberger1e671e12010-03-13 15:09:51 +0000614
Felix Meschbergerb58af942011-12-19 12:54:03 +0000615 var fpid = configData.fpids[i].id;
616 var confs = factories[ fpid ];
617 if (confs) {
618 for (var j in confs) {
619 addConfig(confs[j]);
620 }
621 delete factories[ fpid ];
Felix Meschberger67726fe2010-03-17 06:55:00 +0000622 }
623 }
Felix Meschbergerb58af942011-12-19 12:54:03 +0000624 for(var fpid in factories) {
625 var flist = factories[fpid];
626 for(var i in flist) {
627 delete flist[i].fpid; // render as regular config
628 addConfig(flist[i]);
629 }
630 }
Felix Meschberger67726fe2010-03-17 06:55:00 +0000631 initStaticWidgets(configTable);
632
633 // init tablesorte
634 configTable.tablesorter({
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000635 headers: {
636 0: { sorter: false },
637 3: { sorter: false }
638 },
639 sortList: [[1,1]],
Felix Meschberger67726fe2010-03-17 06:55:00 +0000640 textExtraction: treetableExtraction
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000641 }).bind('sortStart', function() { // clear cache, otherwise extraction will not work
Felix Meschberger67726fe2010-03-17 06:55:00 +0000642 var table = $(this).trigger('update');
Valentin Valchev7c4a80f2014-12-03 12:51:09 +0000643 }).find('th:eq(1)').click();
Carsten Ziegeler149faaa2010-03-10 16:41:53 +0000644 } else {
645 configContent.addClass('ui-helper-hidden');
646 }
647 if (selectedPid) configure(selectedPid);
Felix Meschbergerb812b2e2010-02-18 15:36:53 +0000648});