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.parents('li').show();
169 * Clears fast filter.
171 function clear_fast_filter()
173 var $elm = $('#fast_filter');
179 * Reloads the recent tables list.
181 function PMA_reloadRecentTable()
183 $.get('navigation.php', {
184 'token': window.parent.token,
185 'server': window.parent.server,
186 'ajax_request': true,
187 'recent_table': true},
189 if (data.success == true) {
190 $('#recentTable').html(data.options);
195 /* Performed on load */
196 $(document).ready(function(){
198 $('#NavFilter').css('display', 'inline');
199 var txt = $('#fast_filter').val();
201 $('#fast_filter.gray').live('focus', function() {
202 $(this).removeClass('gray');
206 $('#fast_filter:not(.gray)').live('focusout', function() {
207 var $input = $(this);
208 if ($input.val() == '') {
215 $('#clear_fast_filter').click(function() {
217 $('#fast_filter').focus();
220 $('#fast_filter').keyup(function(evt) {
221 fast_filter($(this).val());
224 /* Jump to recent table */
225 $('#recentTable').change(function() {
226 if (this.value != '') {
227 var arr = jQuery.parseJSON(this.value);
228 window.parent.setDb(arr['db']);
229 window.parent.setTable(arr['table']);
230 window.parent.refreshMain($('#LeftDefaultTabTable')[0].value);
235 $('#newtable a.ajax').click(function(event){
236 event.preventDefault();
238 var url = $('#newtable a').attr("href");
239 if (url.substring(0, 15) == "tbl_create.php?") {
240 url = url.substring(15);
242 url = url +"&num_fields=&ajax_request=true";
243 /*Creating a div on the frame_content frame */
244 var div = parent.frame_content.$('<div id="create_table_dialog"></div>');
245 var target = "tbl_create.php";
248 * Calling to the createTableDialog function
249 * (needs to be done in the context of frame_content in order
250 * for the qtip tooltips to work)
252 parent.frame_content.PMA_createTableDialog(div , url , target);
253 });//end of create new table
254 });//end of document get ready