[306] | 1 | function toggleDiv(id) { |
---|
[307] | 2 | $(divId).toggle(); |
---|
[306] | 3 | } |
---|
[278] | 4 | |
---|
[306] | 5 | function showDiv(id) { |
---|
[307] | 6 | Effect.Appear(id,{duration:0.4,queue:'end'}); |
---|
[306] | 7 | } |
---|
| 8 | |
---|
[307] | 9 | function hideAssetTreePane(paneDivId, tableDivId, saveUrl) { |
---|
| 10 | |
---|
| 11 | var visibleDivs = $(tableDivId).select('div').findAll(function(el) { return el.visible(); }) |
---|
| 12 | var params = "assetTreeVisibleBranches="; |
---|
| 13 | |
---|
| 14 | // Add the id of each visible div. |
---|
| 15 | visibleDivs.each(function(it) { |
---|
| 16 | params += it.identify(); |
---|
| 17 | params += "," |
---|
| 18 | }); |
---|
| 19 | |
---|
| 20 | // Remove the trailing comma. |
---|
| 21 | params = params.slice(0,params.length-1); |
---|
| 22 | |
---|
| 23 | // Post the id's of all visible divs. |
---|
[309] | 24 | // asynchronous: false is against the prototype recommendations but appears to be needed in this case. |
---|
| 25 | new Ajax.Request(saveUrl, {parameters: params, asynchronous: false}); |
---|
| 26 | |
---|
| 27 | // Hide the pane. |
---|
| 28 | $(paneDivId).toggle(); |
---|
[307] | 29 | } |
---|
| 30 | |
---|
[306] | 31 | function toggleBranch(divId, imageId, openImgUrl, closedImgUrl) { |
---|
| 32 | |
---|
[307] | 33 | $(divId).toggle(); |
---|
[278] | 34 | |
---|
[307] | 35 | if( $(divId).visible() ) { |
---|
| 36 | $(imageId).src= openImgUrl; |
---|
| 37 | } |
---|
| 38 | else { |
---|
| 39 | $(imageId).src= closedImgUrl; |
---|
| 40 | } |
---|
[278] | 41 | |
---|
| 42 | } |
---|
| 43 | |
---|
[155] | 44 | function showElement(id) { |
---|
| 45 | try { |
---|
| 46 | if (typeof Effect != "undefined" && typeof Effect.Appear != "undefined") { |
---|
| 47 | if ($(id) && Element.visible(id) == false) |
---|
[306] | 48 | Effect.Appear(id,{duration:0.4,queue:'end'}); |
---|
[155] | 49 | } else { |
---|
| 50 | var el = document.getElementById(id) |
---|
| 51 | if (el && el.style.display == 'none') { |
---|
| 52 | el.style.display = 'block'; |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | } catch (err) {alert(err)} |
---|
| 56 | return false; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | function hideElement(id) { |
---|
| 60 | if (typeof Effect != "undefined" && typeof Effect.Fade != "undefined") { |
---|
| 61 | if ($(id) && Element.visible(id)) |
---|
[306] | 62 | Effect.Fade(id,{duration:0.4,queue:'end'}); |
---|
[155] | 63 | } else { |
---|
| 64 | var el = document.getElementById(id) |
---|
| 65 | if (el && el.style.display != 'none') { |
---|
| 66 | el.style.display = 'none'; |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | return false; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | function clearFilterPane(id) { |
---|
| 73 | var form = document.getElementById(id) |
---|
| 74 | |
---|
| 75 | for (var i = 0; i < form.elements.length; i++) { |
---|
| 76 | var el = form.elements[i] |
---|
| 77 | if (el.type == 'select-one') { |
---|
| 78 | el.selectedIndex = 0 |
---|
| 79 | } else if (el.type == 'text' || el.type == 'textarea') { |
---|
| 80 | form.elements[i].value = '' |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | function filterOpChange(id, controlId) { |
---|
| 86 | // id should be of the form op.propertyName |
---|
| 87 | if (id.slice(0, 10) == 'filter.op.') { |
---|
| 88 | var prop = id.substring(10) |
---|
| 89 | var el = document.getElementById(id) |
---|
| 90 | var selection = el.options[el.selectedIndex] |
---|
| 91 | if (el) { |
---|
| 92 | if (el.type == 'select-one') { |
---|
| 93 | if (selection.value == 'Between') { |
---|
| 94 | showElement('between-span-'+prop) |
---|
| 95 | } else { |
---|
| 96 | hideElement('between-span-'+prop) |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | var containerName = prop+'-container' |
---|
| 101 | if (selection.value == 'IsNull' || selection.value == 'IsNotNull') { |
---|
| 102 | hideElement(controlId); |
---|
| 103 | // Take care of date picker fields we created. |
---|
| 104 | if (document.getElementById(containerName)) hideElement(containerName) |
---|
| 105 | } else { |
---|
| 106 | showElement(controlId); |
---|
| 107 | // Take care of date picker fields. |
---|
| 108 | if (document.getElementById(containerName)) showElement(containerName) |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | function selectDefaultOperator(id) { |
---|
| 115 | var dropdown = document.getElementById(id) |
---|
| 116 | if (dropdown && dropdown.selectedIndex <= 0) { |
---|
| 117 | dropdown.selectedIndex = 1 |
---|
| 118 | } |
---|
| 119 | } |
---|