Fix for the Open in New Window in Patient/Client->Patients search gui, take 2.
[openemr.git] / phpmyadmin / js / navigation.js
blob44ffc44bd19b68dc2fd067601b4b8425ef31a3b1
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * function used in or for navigation frame
4  */
6 /**
7  * init
8  */
9 var today = new Date();
10 var expires = new Date(today.getTime() + (56 * 86400000));
11 var pma_navi_width;
12 var pma_saveframesize_timeout = null;
14 /**
15  * opens/closes (hides/shows) tree elements
16  *
17  * @param   string  id          id of the element in the DOM
18  * @param   boolean only_open   do not close/hide element
19  */
20 function toggle(id, only_open) {
21     var el = document.getElementById('subel' + id);
22     if (! el) {
23         return false;
24     }
26     var img = document.getElementById('el' + id + 'Img');
28     if (el.style.display == 'none' || only_open) {
29         el.style.display = '';
30         if (img) {
31             img.src = image_minus;
32             img.alt = '-';
33         }
34     } else {
35         el.style.display = 'none';
36         if (img) {
37             img.src = image_plus;
38             img.alt = '+';
39         }
40     }
41     return true;
44 function PMA_callFunctionDelayed(myfunction, delay)
46     if (typeof pma_saveframesize_timeout == "number") {
47          window.clearTimeout(pma_saveframesize_timeout);
48         pma_saveframesize_timeout = null;
49     }
52 /**
53  * saves current navigation frame width in a cookie
54  * usally called on resize of the navigation frame
55  */
56 function PMA_saveFrameSizeReal()
58     if (parent.text_dir == 'ltr') {
59         pma_navi_width = parseInt(parent.document.getElementById('mainFrameset').cols)
60     } else {
61         pma_navi_width = parent.document.getElementById('mainFrameset').cols.match(/\d+$/) 
62     }
63     if ((pma_navi_width > 0) && (pma_navi_width != PMA_getCookie('pma_navi_width'))) {
64         PMA_setCookie('pma_navi_width', pma_navi_width, expires);
65     }
68 /**
69  * calls PMA_saveFrameSizeReal with delay
70  */
71 function PMA_saveFrameSize()
73     //alert(typeof(pma_saveframesize_timeout) + ' : ' + pma_saveframesize_timeout);
75     if (typeof pma_saveframesize_timeout == "number") {
76         window.clearTimeout(pma_saveframesize_timeout);
77         pma_saveframesize_timeout = null;
78     }
80     pma_saveframesize_timeout = window.setTimeout(PMA_saveFrameSizeReal, 2000);
83 /**
84  * sets navigation frame width to the value stored in the cookie
85  * usally called on document load
86  */
87 function PMA_setFrameSize()
89     pma_navi_width = PMA_getCookie('pma_navi_width');
90     //alert('from cookie: ' + typeof(pma_navi_width) + ' : ' + pma_navi_width);
91     if (pma_navi_width != null) {
92         if (parent.text_dir == 'ltr') {
93             parent.document.getElementById('mainFrameset').cols = pma_navi_width + ',*';
94         } else {
95             parent.document.getElementById('mainFrameset').cols = '*,' + pma_navi_width;
96         }
97         //alert('framesize set');
98     }
102  * retrieves a named value from cookie
104  * @param   string  name    name of the value to retrieve
105  * @return  string  value   value for the given name from cookie
106  */
107 function PMA_getCookie(name) {
108     var start = document.cookie.indexOf(name + "=");
109     var len = start + name.length + 1;
110     if ((!start) && (name != document.cookie.substring(0, name.length))) {
111         return null;
112     }
113     if (start == -1) {
114         return null;
115     }
116     var end = document.cookie.indexOf(";", len);
117     if (end == -1) {
118         end = document.cookie.length;
119     }
120     return unescape(document.cookie.substring(len,end));
124  * stores a named value into cookie
126  * @param   string  name    name of value
127  * @param   string  value   value to be stored
128  * @param   Date    expires expire time
129  * @param   string  path
130  * @param   string  domain
131  * @param   boolean secure
132  */
133 function PMA_setCookie(name, value, expires, path, domain, secure) {
134     document.cookie = name + "=" + escape(value) +
135         ( (expires) ? ";expires=" + expires.toGMTString() : "") +
136         ( (path)    ? ";path=" + path : "") +
137         ( (domain)  ? ";domain=" + domain : "") +
138         ( (secure)  ? ";secure" : "");