1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * function used in or for navigation frame
9 var today = new Date();
10 var expires = new Date(today.getTime() + (56 * 86400000));
12 var pma_saveframesize_timeout = null;
15 * opens/closes (hides/shows) tree elements
17 * @param string id id of the element in the DOM
18 * @param boolean only_open do not close/hide element
20 function toggle(id, only_open)
22 var el = document.getElementById('subel' + id);
27 var img = document.getElementById('el' + id + 'Img');
29 if (el.style.display == 'none' || only_open) {
30 el.style.display = '';
32 var newimg = PMA_getImage('b_minus.png');
33 img.className = newimg.attr('class');
34 img.src = newimg.attr('src');
38 el.style.display = 'none';
40 var newimg = PMA_getImage('b_plus.png');
41 img.className = newimg.attr('class');
42 img.src = newimg.attr('src');
49 function PMA_callFunctionDelayed(myfunction, delay)
51 if (typeof pma_saveframesize_timeout == "number") {
52 window.clearTimeout(pma_saveframesize_timeout);
53 pma_saveframesize_timeout = null;
58 * saves current navigation frame width in a cookie
59 * usally called on resize of the navigation frame
61 function PMA_saveFrameSizeReal()
63 if (parent.text_dir == 'ltr') {
64 pma_navi_width = parseInt(parent.document.getElementById('mainFrameset').cols)
66 pma_navi_width = parent.document.getElementById('mainFrameset').cols.match(/\d+$/)
68 if ((pma_navi_width > 0) && (pma_navi_width != PMA_getCookie('pma_navi_width'))) {
69 PMA_setCookie('pma_navi_width', pma_navi_width, expires);
74 * calls PMA_saveFrameSizeReal with delay
76 function PMA_saveFrameSize()
78 //alert(typeof(pma_saveframesize_timeout) + ' : ' + pma_saveframesize_timeout);
80 if (typeof pma_saveframesize_timeout == "number") {
81 window.clearTimeout(pma_saveframesize_timeout);
82 pma_saveframesize_timeout = null;
85 pma_saveframesize_timeout = window.setTimeout(PMA_saveFrameSizeReal, 2000);
89 * sets navigation frame width to the value stored in the cookie
90 * usally called on document load
92 function PMA_setFrameSize()
94 pma_navi_width = PMA_getCookie('pma_navi_width');
95 //alert('from cookie: ' + typeof(pma_navi_width) + ' : ' + pma_navi_width);
96 if (pma_navi_width != null && parent.document != document) {
97 if (parent.text_dir == 'ltr') {
98 parent.document.getElementById('mainFrameset').cols = pma_navi_width + ',*';
100 parent.document.getElementById('mainFrameset').cols = '*,' + pma_navi_width;
102 //alert('framesize set');
107 * retrieves a named value from cookie
109 * @param string name name of the value to retrieve
110 * @return string value value for the given name from cookie
112 function PMA_getCookie(name)
114 var start = document.cookie.indexOf(name + "=");
115 var len = start + name.length + 1;
116 if ((!start) && (name != document.cookie.substring(0, name.length))) {
122 var end = document.cookie.indexOf(";", len);
124 end = document.cookie.length;
126 return unescape(document.cookie.substring(len,end));
130 * stores a named value into cookie
132 * @param string name name of value
133 * @param string value value to be stored
134 * @param Date expires expire time
136 * @param string domain
137 * @param boolean secure
139 function PMA_setCookie(name, value, expires, path, domain, secure)
141 document.cookie = name + "=" + escape(value) +
142 ( (expires) ? ";expires=" + expires.toGMTString() : "") +
143 ( (path) ? ";path=" + path : "") +
144 ( (domain) ? ";domain=" + domain : "") +
145 ( (secure) ? ";secure" : "");
149 * hide all LI elements with second A tag which doesn`t contain requested value
151 * @param string value requested value
154 function fast_filter(value)
156 lowercase_value = value.toLowerCase();
157 $("#subel0 a[class!='tableicon']").each(function(idx,elem){
159 // .indexOf is case sensitive so convert to lowercase to compare
160 if (value && $elem.html().toLowerCase().indexOf(lowercase_value) == -1) {
161 $elem.parent().hide();
163 $elem.parent().show();
169 * Clears fast filter.
171 function clear_fast_filter()
173 var elm = $('#NavFilter input');
180 * Reloads the recent tables list.
182 function PMA_reloadRecentTable()
184 $.get('navigation.php', {
185 'token': window.parent.token,
186 'server': window.parent.server,
187 'ajax_request': true,
188 'recent_table': true},
190 if (data.success == true) {
191 $('#recentTable').html(data.options);
196 /* Performed on load */
197 $(document).ready(function(){
199 $('#NavFilter').css('display', 'inline');
200 $('input[id="fast_filter"]').focus(function() {
201 if($(this).attr("value") === "filter tables by name") {
205 $('#clear_fast_filter').click(clear_fast_filter);
206 $('#fast_filter').focus(function (evt) {evt.target.select();});
207 $('#fast_filter').keyup(function (evt) {fast_filter(evt.target.value);});
209 /* Jump to recent table */
210 $('#recentTable').change(function() {
211 if (this.value != '') {
212 var arr = jQuery.parseJSON(this.value);
213 window.parent.setDb(arr['db']);
214 window.parent.setTable(arr['table']);
215 window.parent.refreshMain($('#LeftDefaultTabTable')[0].value);
220 $('#newtable a.ajax').click(function(event){
221 event.preventDefault();
223 var url = $('#newtable a').attr("href");
224 if (url.substring(0, 15) == "tbl_create.php?") {
225 url = url.substring(15);
227 url = url +"&num_fields=&ajax_request=true";
228 /*Creating a div on the frame_content frame */
229 var div = parent.frame_content.$('<div id="create_table_dialog"></div>');
230 var target = "tbl_create.php";
233 * Calling to the createTableDialog function
234 * (needs to be done in the context of frame_content in order
235 * for the qtip tooltips to work)
237 parent.frame_content.PMA_createTableDialog(div , url , target);
238 });//end of create new table
239 });//end of document get ready