1 | |
---|
2 | function showAssetTreePane(paneDivId, loadingImg, url) { |
---|
3 | |
---|
4 | Effect.Appear(paneDivId,{duration:0.4}); |
---|
5 | |
---|
6 | // Pulsing loadingImg blocks the default grails animated gif till complete. |
---|
7 | // After which the default will show as normal. |
---|
8 | new Effect.Pulsate($(loadingImg), { pulses: 200, duration: 133 }); |
---|
9 | |
---|
10 | // The updater is only called once per page refresh. |
---|
11 | new Ajax.Updater({ success: paneDivId }, url, {asynchronous:true,evalScripts:true}); |
---|
12 | } |
---|
13 | |
---|
14 | function hideAssetTreePane(paneDivId, tableDivId, saveUrl) { |
---|
15 | |
---|
16 | // Collect the visible branch div's first. |
---|
17 | var visibleDivs = $(tableDivId).select('div').findAll(function(el) { return el.visible(); }) |
---|
18 | var params = "assetTreeVisibleBranches="; |
---|
19 | |
---|
20 | // Hide the pane. |
---|
21 | $(paneDivId).toggle(); |
---|
22 | |
---|
23 | // Add the id of each visible div to params. |
---|
24 | visibleDivs.each(function(it) { |
---|
25 | params += it.identify(); |
---|
26 | params += "," |
---|
27 | }); |
---|
28 | |
---|
29 | // Remove the trailing comma. |
---|
30 | params = params.slice(0,params.length-1); |
---|
31 | |
---|
32 | // Post the id's of all visible branch div's. |
---|
33 | // asynchronous: false is against the prototype recommendations but appears to be needed in this case. |
---|
34 | new Ajax.Request(saveUrl, {parameters: params, asynchronous: false}); |
---|
35 | } |
---|
36 | |
---|
37 | function toggleBranch(divId, imageId, openImgUrl, closedImgUrl) { |
---|
38 | |
---|
39 | $(divId).toggle(); |
---|
40 | |
---|
41 | if( $(divId).visible() ) { |
---|
42 | $(imageId).src= openImgUrl; |
---|
43 | } |
---|
44 | else { |
---|
45 | $(imageId).src= closedImgUrl; |
---|
46 | } |
---|
47 | |
---|
48 | } |
---|