source: trunk/web-app/js/overlayPane.js @ 309

Last change on this file since 309 was 309, checked in by gav, 14 years ago

Change asset tree taglib Ajax.Request to asynchronous: false.

File size: 3.6 KB
Line 
1function toggleDiv(id) {
2    $(divId).toggle();
3}
4
5function showDiv(id) {
6    Effect.Appear(id,{duration:0.4,queue:'end'});
7}
8
9function 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.
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();
29}
30
31function toggleBranch(divId, imageId, openImgUrl, closedImgUrl) {
32
33    $(divId).toggle();
34
35    if( $(divId).visible() ) {
36        $(imageId).src= openImgUrl;
37    }
38    else {
39        $(imageId).src= closedImgUrl;
40    }
41
42}
43
44function showElement(id) {
45    try {
46        if (typeof Effect != "undefined" && typeof Effect.Appear != "undefined") {
47                    if ($(id) && Element.visible(id) == false)
48            Effect.Appear(id,{duration:0.4,queue:'end'});
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
59function hideElement(id) {
60    if (typeof Effect != "undefined" && typeof Effect.Fade != "undefined") {
61            if ($(id) && Element.visible(id))
62        Effect.Fade(id,{duration:0.4,queue:'end'});
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
72function 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
85function 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
114function selectDefaultOperator(id) {
115    var dropdown = document.getElementById(id)
116    if (dropdown && dropdown.selectedIndex <= 0) {
117        dropdown.selectedIndex = 1
118    }
119}
Note: See TracBrowser for help on using the repository browser.