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

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

Asset tree taglib now saves it's status in the http session along with some improvement to the button css.

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