-
Notifications
You must be signed in to change notification settings - Fork 333
/
CMSMain_left.js
executable file
·690 lines (599 loc) · 20.8 KB
/
CMSMain_left.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
if(typeof SiteTreeHandlers == 'undefined') SiteTreeHandlers = {};
SiteTreeHandlers.parentChanged_url = 'admin/ajaxupdateparent';
SiteTreeHandlers.orderChanged_url = 'admin/ajaxupdatesort';
SiteTreeHandlers.loadPage_url = 'admin/getitem';
SiteTreeHandlers.loadTree_url = 'admin/getsubtree';
_NEW_PAGES = new Array();
/**
* Add page action
*/
var addpageclass;
addpageclass = Class.create();
addpageclass.applyTo('#addpage');
addpageclass.prototype = {
originalValues: new Array(),
initialize: function () {
Observable.applyTo($(_HANDLER_FORMS[this.id]));
this.getElementsByTagName('button')[0].onclick = returnFalse;
$(_HANDLER_FORMS[this.id]).onsubmit = this.form_submit;
// Save the original page types in to this object
if ($(_HANDLER_FORMS.addpage).elements.PageType) {
var options = $(_HANDLER_FORMS.addpage).elements.PageType.options;
for(var i = 0; i < options.length; i++) {
this.originalValues.push({
'value': options[i].value,
'label': options[i].innerHTML
});
}
var selectedNode = $('sitetree').firstSelected();
if(selectedNode) this.showApplicableChildrenPageTypes(selectedNode.hints);
}
},
onclick : function() {
if(treeactions.toggleSelection(this)) {
var selectedNode = $('sitetree').firstSelected();
if(selectedNode) {
while(selectedNode.parentTreeNode && !selectedNode.hints.defaultChild) {
$('sitetree').changeCurrentTo(selectedNode.parentTreeNode);
selectedNode = selectedNode.parentTreeNode;
}
if( selectedNode.hints && selectedNode.hints.defaultChild )
$(_HANDLER_FORMS.addpage).elements.PageType.value = selectedNode.hints.defaultChild;
}
this.o1 = $('sitetree').observeMethod('SelectionChanged', this.treeSelectionChanged.bind(this));
this.o2 = $(_HANDLER_FORMS[this.id]).observeMethod('Close', this.popupClosed.bind(this));
$(_HANDLER_FORMS[this.id]).elements.PageType.onchange = this.typeDropdown_change;
}
return false;
},
// Reset the page types dropdown to its original state
resetPageTypeOptions: function() {
var select = $(_HANDLER_FORMS.addpage).elements.PageType;
while (select.childNodes.length >= 1) { select.removeChild(select.firstChild); }
for(var i = 0; i < this.originalValues.length; i++) {
var option = document.createElement('option');
option.value = this.originalValues[i].value;
option.innerHTML = this.originalValues[i].label;
select.appendChild(option);
}
},
// Hide the <option> elements in the new page <select> unless
// they are in the allowChildren array of the selected tree node
showApplicableChildrenPageTypes: function(hints) {
this.resetPageTypeOptions();
if (typeof hints.allowedChildren != 'undefined') {
var select = $(_HANDLER_FORMS.addpage).elements.PageType;
var toRemove = new Array();
for(var i = 0; i < select.options.length; i++) {
var itemFound = false;
for(var j = 0; j < hints.allowedChildren.length; j++) {
if (select.options[i].value == hints.allowedChildren[j]) { itemFound = true; break; }
}
if (!itemFound) toRemove.push(select.options[i]);
}
for(var i = 0; i < toRemove.length; i++) { select.removeChild(toRemove[i]); }
}
},
treeSelectionChanged : function(selectedNode) {
this.showApplicableChildrenPageTypes(selectedNode.hints);
$(_HANDLER_FORMS.addpage).elements.PageType.value = selectedNode.hints.defaultChild;
},
popupClosed : function() {
$('sitetree').stopObserving(this.o1);
$(_HANDLER_FORMS.addpage).stopObserving(this.o2);
},
typeDropdown_change : function() {
// Don't do anything if we're already on an appropriate node
var sel = $('sitetree').firstSelected();
if(sel && sel.hints && sel.hints.allowedChildren) {
var allowed = sel.hints.allowedChildren;
for(i=0;i<allowed.length;i++) if(allowed[i] == this.value) return;
}
if( typeof siteTreeHints == 'undefined' )
return;
// Otherwise move to the default parent for that.
if( siteTreeHints && siteTreeHints[this.value] ) {
var newNode = $('sitetree').getTreeNodeByIdx(siteTreeHints[this.value].defaultParent);
if(newNode) $('sitetree').changeCurrentTo(newNode);
}
},
form_submit : function() {
var st = $('sitetree');
var parentID = st.getIdxOf(st.firstSelected());
// TODO: Remove 'new-' code http://open.silverstripe.com/ticket/875
if(parentID && parentID.substr(0,3) == 'new') {
alert(ss.i18n._t('CMSMAIN.WARNINGSAVEPAGESBEFOREADDING'));
} else if( Element.hasClassName( st.firstSelected(), "nochildren" ) ) {
alert(ss.i18n._t('CMSMAIN.CANTADDCHILDREN') );
} else {
$(_HANDLER_FORMS.addpage).elements.ParentID.value = parentID ? parentID : 0;
if( !_NEW_PAGES[parentID] )
_NEW_PAGES[parentID] = 1;
var suffix = _NEW_PAGES[parentID]++;
Ajax.SubmitForm(_HANDLER_FORMS.addpage, "action_addpage", {
onSuccess : Ajax.Evaluator,
onFailure : function(response) { if (response.status == 403) {
alert('You cannot add that page at that location.');
}},
extraData: '&Suffix=' + suffix
});
}
return false;
}
};
/**
* Search button click action
*/
var searchclass;
searchclass = Class.create();
searchclass.applyTo('#search');
searchclass.prototype = {
initialize : function() {
Observable.applyTo($(_HANDLER_FORMS.search));
},
onclick : function() {
if(treeactions.toggleSelection(this)) {
this.o2 = $(_HANDLER_FORMS[this.id]).observeMethod('Close', this.popupClosed.bind(this));
}
return false;
},
popupClosed : function() {
$(_HANDLER_FORMS.search).stopObserving(this.o2);
batchActionGlobals.unfilterSiteTree();
}
};
var SiteTreeFilter = Class.create();
SiteTreeFilter.applyTo('#siteTreeFilterList');
SiteTreeFilter.prototype = {
initialize: function () {
},
reapplyIfNeeded: function() {
if(this.options[this.selectedIndex].value != 'all') this.onchange();
},
onchange : function() {
var value = this.options[this.selectedIndex].value;
if(value != 'all') {
$('sitetree').setCustomURL(SiteTreeHandlers.controller_url+'/getfilteredsubtree?filter='+escape(value));
} else {
$('sitetree').clearCustomURL();
}
// We can't update the tree while it's draggable; it gets b0rked.
var __makeDraggableAfterUpdate = false;
if($('sitetree').isDraggable) {
$('sitetree').stopBeingDraggable();
__makeDraggableAfterUpdate = true;
}
var indicator = $('siteTreeFilterActionIndicator');
indicator.style.display = 'inline';
$('sitetree').reload({
onSuccess: function() {
indicator.style.display = 'none';
if(__makeDraggableAfterUpdate) $('sitetree').makeDraggable();
batchActionGlobals.refreshSelected();
},
onFailure: function(response) {
errorMessage('Could not update tree', response);
}
});
}
};
/**
* Control the site tree filter
*/
var SiteTreeFilterForm = Class.create();
SiteTreeFilterForm.applyTo('form#search_options');
SiteTreeFilterForm.prototype = {
initialize: function() {
var self = this;
Form.getElements(this).each(function(el){
if (el.type == 'submit') el.onclick = function(){self.clicked = $F(this);};
});
},
onsubmit: function() {
var filters = $H();
if (this.clicked == 'Clear') {
Form.getElements(this).each(function(el){
if (el.type == 'text') el.value = '';
else if (el.type == 'select-one') el.value = 'All';
});
document.getElementsBySelector('.SearchCriteriaContainer', this).each(function(el){
Element.hide(el);
});
}
else {
Form.getElements(this).each(function(el){
if (el.type == 'text') {
if ($F(el)) filters[el.name] = $F(el);
}
else if (el.type == 'select-one') {
if ($F(el) && $F(el) != 'All') filters[el.name] = $F(el);
}
});
}
if (filters.keys().length) {
// Set new URL
$('sitetree').setCustomURL(SiteTreeHandlers.controller_url + '/getfilteredsubtree?filter=CMSSiteTreeFilter_Search', filters);
// Disable checkbox tree controls that currently don't work with search.
// @todo: Make them work together
if ($('sitetree').isDraggable) $('sitetree').stopBeingDraggable();
document.getElementsBySelector('.checkboxAboveTree input[type=checkbox]').each(function(el){
el.value = false; el.disabled = true;
});
}
else {
// Reset URL to default
$('sitetree').clearCustomURL();
// Enable checkbox tree controls
document.getElementsBySelector('.checkboxAboveTree input[type=checkbox]').each(function(el){
el.disabled = false;
});
}
$('SiteTreeSearchButton').className = $('SiteTreeSearchClearButton').className = 'hidden';
$('searchIndicator').className = 'loading';
$('sitetree').reload({
onSuccess : function(response) {
$('SiteTreeSearchButton').className = $('SiteTreeSearchClearButton').className = 'action';
$('searchIndicator').className = '';
statusMessage('Filtered tree','good');
},
onFailure : function(response) {
errorMessage('Could not filter site tree<br />' + response.responseText);
}
});
return false;
}
};
/**
* Add Criteria Drop-down onchange action which allows more criteria to be shown
*/
var SiteTreeFilterAddCriteria = Class.create();
SiteTreeFilterAddCriteria.applyTo('#SiteTreeFilterAddCriteria');
SiteTreeFilterAddCriteria.prototype = {
onchange : function() {
Element.show('Container' + this.value);
// Element.show('Text' + this.value);
// Element.show('Input' + this.value);
this.selectedIndex = 0; //reset selected criteria to prompt
}
};
/**
* Batch Actions button click action
*/
var batchactionsclass = Class.create();
batchactionsclass.applyTo('#batchactions');
batchactionsclass.prototype = {
initialize : function() {
Observable.applyTo($(_HANDLER_FORMS.batchactions));
},
onclick : function() {
if(treeactions.toggleSelection(this)) {
this.multiselectTransform();
this.actionChanged();
}
return false;
},
actionChanged: function() {
// Show parameters form, if necessary
var urlSegment = $('choose_batch_action').value.split('/').pop();
if ($('BatchActionParameters_'+urlSegment)) {
jQuery('#BatchActionParameters .params').hide();
jQuery('#BatchActionParameters_'+urlSegment).show();
jQuery('#BatchActionParameters').show();
} else {
jQuery('#BatchActionParameters').hide();
}
// Don't show actions that have failed from the previous execution
batchActionGlobals.removeFailures();
batchActionGlobals.refreshSelected();
},
multiselectTransform : function() {
batchActionGlobals.o1 = $('sitetree').observeMethod('SelectionChanged', batchActionGlobals.treeSelectionChanged);
batchActionGlobals.o2 = $(_HANDLER_FORMS.batchactions).observeMethod('Close', batchActionGlobals.popupClosed);
addClass($('sitetree'),'multiselect');
batchActionGlobals.selectedNodes = { };
var selectedNode = $('sitetree').firstSelected();
if(selectedNode && selectedNode.className.indexOf('nodelete') == -1) {
var selIdx = $('sitetree').getIdxOf(selectedNode);
batchActionGlobals.selectedNodes[selIdx] = true;
selectedNode.removeNodeClass('current');
selectedNode.addNodeClass('selected');
selectedNode.open();
// Open all existing children, which might trigger further
// ajaxExansion calls to ensure all nodes are selectable
var children = selectedNode.getElementsByTagName('li');
for(var i=0; i<children.length; i++) {
children[i].open();
}
}
}
};
// batchActionGlobals is needed because calls to observeMethod doesn't seem to preserve instance variables so a Prototype can't be used
batchActionGlobals = {
selectedNodes: { },
// count Int - The number of nodes selected
count: function() {
return batchActionGlobals.getIds().length;
},
// TODO: Remove 'new-' code http://open.silverstripe.com/ticket/875
newNodes: { },
treeSelectionChanged : function(selectedNode) {
var idx = $('sitetree').getIdxOf(selectedNode);
if(selectedNode.className.indexOf('nodelete') == -1) {
if(selectedNode.selected) {
selectedNode.removeNodeClass('selected');
selectedNode.selected = false;
batchActionGlobals.selectedNodes[idx] = false;
} else {
// Open node in order to allow proper selection of children
if(Element.hasClassName(selectedNode, 'unexpanded')) {
selectedNode.open();
}
// Select node
selectedNode.addNodeClass('selected');
selectedNode.selected = true;
batchActionGlobals.selectedNodes[idx] = true;
// Open all existing children, which might trigger further
// ajaxExansion calls to ensure all nodes are selectable
var children = selectedNode.getElementsByTagName('li');
for(var i=0; i<children.length; i++) {
children[i].open();
}
}
}
return false;
},
popupClosed : function() {
removeClass($('sitetree'),'multiselect');
$('sitetree').stopObserving(batchActionGlobals.o1);
$(_HANDLER_FORMS.batchactions).stopObserving(batchActionGlobals.o2);
for(var idx in batchActionGlobals.selectedNodes) {
if(batchActionGlobals.selectedNodes[idx]) {
node = $('sitetree').getTreeNodeByIdx(idx);
if(node) {
node.removeNodeClass('selected');
node.selected = false;
}
}
}
batchActionGlobals.selectedNodes = { };
},
getIds: function() {
var csvIDs = new Array();
var st = $('sitetree');
batchActionGlobals.newNodes = new Array();
for(var idx in batchActionGlobals.selectedNodes) {
if(batchActionGlobals.selectedNodes[idx]) {
// Delete/Publish new nodes? (Leftover from delete code?) TODO: Remove 'new-' code http://open.silverstripe.com/ticket/875
if( idx.match(/^new-[a-z0-9A-Z\-]+$/) ) {
batchActionGlobals.newNodes.push( idx );
} else {
if(csvIDs.indexOf(idx) == -1) {
csvIDs.push(idx);
}
}
}
}
return csvIDs;
},
getCsvIds : function() {
return (batchActionGlobals.getIds().toString());
},
refreshSelected : function(rootNode) {
var st = $('sitetree');
for(var idx in batchActionGlobals.selectedNodes) {
st.getTreeNodeByIdx(idx).addNodeClass('selected');
st.getTreeNodeByIdx(idx).selected = true;
}
// Default to refreshing the entire tree
if(rootNode == null) rootNode = st;
/// If batch actions is enabled, then enable/disable the appropriate tree fields
if($('batchactionsforms').style.display != 'none' && $('choose_batch_action').value) {
// Collect list of visible tree IDs
var ids = [];
jQuery(rootNode).find('li').each(function() {
var id = parseInt(this.id.replace('record-',''));
if(id) ids.push(id);
// Disable the nodes while the ajax request is being processed
this.removeNodeClass('nodelete');
this.addNodeClass('treeloading');
});
// Post to the server to ask which pages can have this batch action applied
var applicablePagesURL = $('choose_batch_action').value + '/applicablepages?csvIDs=' + ids.join(',');
jQuery.getJSON(applicablePagesURL, function(applicableIDs) {
var i;
var applicableIDMap = {};
for(i=0;i<applicableIDs.length;i++) applicableIDMap[applicableIDs[i]] = true;
// Set a CSS class on each tree node indicating which can be batch-actioned and which can't
jQuery(rootNode).find('li').each(function() {
this.removeNodeClass('treeloading');
var id = parseInt(this.id.replace('record-',''));
if(id) {
if(applicableIDMap[id] === true) {
this.removeNodeClass('nodelete');
} else {
// De-select the node if it's non-applicable
delete batchActionGlobals.selectedNodes[id];
this.removeNodeClass('selected');
this.addNodeClass('nodelete');
}
}
});
});
}
},
/**
* Deselect all nodes in the tree
*/
deselectAll : function() {
batchActionGlobals.selectedNodes = {}
jQuery('#sitetree').find('li').each(function() {
this.removeNodeClass('selected');
this.selected = false;
});
},
/**
* Remove the indications of failed batch actions
*/
removeFailures : function() {
jQuery('#sitetree').find('li.failed').each(function() {
this.removeNodeClass('failed');
});
},
unfilterSiteTree : function() {
// Reload the site tree if it has been filtered
if ($('SiteTreeIsFiltered').value == 1) {
// Show all items in Site Tree again
new Ajax.Request( 'admin/SiteTreeAsUL' + '&ajax=1', {
onSuccess: function( response ) {
$('sitetree_ul').innerHTML = response.responseText;
Behaviour.apply($('sitetree_ul'));
$('SiteTreeIsFiltered').value = 0;
$('batchactions').multiselectTransform();
statusMessage(ss.i18n._t('CMSMAIN.SUCCESSUNFILTER'),'good');
},
onFailure : function(response) {
errorMessage(ss.i18n.sprintf(
ss.i18n._t('CMSMAIN.ERRORUNFILTER'),
response.responseText
));
}
});
}
}
};
Behaviour.register({
'#choose_batch_action' : {
onchange : function() {
$('batchactions').actionChanged();
}
}
});
/**
* Publish selected pages action
*/
var publishpage = Class.create();
publishpage.applyTo('#batchactions_options');
publishpage.prototype = {
onsubmit : function() {
csvIDs = batchActionGlobals.getCsvIds();
if(csvIDs) {
var optionEl = $('choose_batch_action').options[$('choose_batch_action').selectedIndex];
var actionText = optionEl.text;
var confirmationURL = $('choose_batch_action').value + '/confirmation?csvIDs=' + csvIDs;
jQuery.getJSON(confirmationURL, function(data) {
// If a custom alert has been provided, show that.
// otherwise, show the default one
if (data.alert) {
if (!confirm(data.content)) return false;
} else {
if(!confirm(ss.i18n.sprintf(ss.i18n._t('CMSMAIN.SELECTMOREPAGES'), batchActionGlobals.count()))) {
return false;
}
}
$('batchactions_options').submitform();
});
} else {
alert(ss.i18n._t('CMSMAIN.SELECTONEPAGE'));
}
return false;
},
submitform: function() {
csvIDs = batchActionGlobals.getCsvIds();
var optionEl = $('choose_batch_action').options[$('choose_batch_action').selectedIndex];
var optionParams = eval(optionEl.className);
var ingText = optionParams.doingText;
this.elements.csvIDs.value = csvIDs;
// Select form submission URL
this.action = $('choose_batch_action').value;
// Loading indicator
statusMessage(ingText);
$('batchactions_go').className = 'loading';
// Don't show actions that have failed from the previous execution
batchActionGlobals.removeFailures();
// Submit form
Ajax.SubmitForm(this, null, {
onSuccess : function(response) {
Ajax.Evaluator(response);
$('batchactions_go').className = '';
batchActionGlobals.deselectAll();
},
onFailure : function(response) {
errorMessage('Error ' + ingText, response);
}
});
}
};
/**
* Delete selected pages action
*/
var deletepage;
deletepage = Class.create();
deletepage.applyTo('#Form_DeleteItemsForm');
deletepage.prototype = {
onsubmit : function() {
csvIDs = batchActionGlobals.getCsvIds();
if(csvIDs || batchActionGlobals.newNodes.length > 0) {
if(confirm(ss.i18n.sprintf(
ss.i18n._t('CMSMAIN.REALLYDELETEPAGES'),
batchActionGlobals.count()
))) {
this.elements.csvIDs.value = csvIDs;
statusMessage(ss.i18n._t('CMSMAIN.DELETINGPAGES'));
// TODO: Remove 'new-' code http://open.silverstripe.com/ticket/875
for( var idx = 0; idx < batchActionGlobals.newNodes.length; idx++ ) {
var newNode = $('sitetree').getTreeNodeByIdx( batchActionGlobals.newNodes[idx] );
if( newNode.parentTreeNode )
newNode.parentTreeNode.removeTreeNode( newNode );
else
alert( newNode.id + ' has no parent node');
$('Form_EditForm').reloadIfSetTo(idx);
}
batchActionGlobals.newNodes = new Array();
// Put an AJAXY loading icon on the button
$('Form_DeleteItemsForm_action_deleteitems').className = 'loading';
Ajax.SubmitForm(this, null, {
onSuccess : function(response) {
Ajax.Evaluator(response);
$('Form_DeleteItemsForm_action_deleteitems').className = '';
treeactions.closeSelection($('batchactions'));
},
onFailure : function(response) {
errorMessage(ss.i18n._t('CMSMAIN.ERRORDELETINGPAGES'), response);
}
});
}
} else {
alert(ss.i18n._t('CMSMAIN.SELECTONEPAGE'));
}
return false;
}
};
/**
* Tree context menu
*/
TreeContextMenu = {
'Edit this page' : function(treeNode) {
treeNode.selectTreeNode();
},
'Duplicate page and children' : function(treeNode) {
// First save the page silently (without confirmation) and then duplicate the page.
autoSave(false, treeNode.duplicatePageWithChildren.bind(treeNode));
},
'Duplicate just this page' : function(treeNode) {
// First save the page silently (without confirmation) and then duplicate the page.
autoSave(false, treeNode.duplicatePage.bind(treeNode));
},
'Sort sub-pages' : function(treeNode) {
var children = treeNode.treeNodeHolder().childTreeNodes();
var sortedChildren = children.sort(function(a, b) {
var titleA = a.aTag.innerHTML.replace(/<[^>]*>/g,'');
var titleB = b.aTag.innerHTML.replace(/<[^>]*>/g,'');
return titleA < titleB ? -1 : (titleA > titleB ? 1 : 0);
});
var i,child;
for(i=0;child=sortedChildren[i];i++) {
treeNode.appendTreeNode(child);
}
treeNode.onOrderChanged(sortedChildren,treeNode);
}
};