[312] | 1 | |
---|
| 2 | function showAssetTreePane(paneDivId, loadingImg, url) { |
---|
[316] | 3 | |
---|
[312] | 4 | Effect.Appear(paneDivId,{duration:0.4}); |
---|
[316] | 5 | |
---|
| 6 | // Pulsing loadingImg blocks the default grails animated gif till complete. |
---|
| 7 | // After which the default will show as normal. |
---|
[312] | 8 | new Effect.Pulsate($(loadingImg), { pulses: 200, duration: 133 }); |
---|
[316] | 9 | |
---|
| 10 | // The updater is only called once per page refresh. |
---|
[312] | 11 | new Ajax.Updater({ success: paneDivId }, url, {asynchronous:true,evalScripts:true}); |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | function hideAssetTreePane(paneDivId, tableDivId, saveUrl) { |
---|
| 15 | |
---|
[316] | 16 | // Collect the visible branch div's first. |
---|
[312] | 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 | |
---|
[316] | 32 | // Post the id's of all visible branch div's. |
---|
[312] | 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 | } |
---|