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) {
21 var el = document.getElementById('subel' + id);
26 var img = document.getElementById('el' + id + 'Img');
28 if (el.style.display == 'none' || only_open) {
29 el.style.display = '';
31 img.src = image_minus;
35 el.style.display = 'none';
44 function PMA_callFunctionDelayed(myfunction, delay)
46 if (typeof pma_saveframesize_timeout == "number") {
47 window.clearTimeout(pma_saveframesize_timeout);
48 pma_saveframesize_timeout = null;
53 * saves current navigation frame width in a cookie
54 * usally called on resize of the navigation frame
56 function PMA_saveFrameSizeReal()
58 if (parent.text_dir == 'ltr') {
59 pma_navi_width = parseInt(parent.document.getElementById('mainFrameset').cols)
61 pma_navi_width = parent.document.getElementById('mainFrameset').cols.match(/\d+$/)
63 if ((pma_navi_width > 0) && (pma_navi_width != PMA_getCookie('pma_navi_width'))) {
64 PMA_setCookie('pma_navi_width', pma_navi_width, expires);
69 * calls PMA_saveFrameSizeReal with delay
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;
80 pma_saveframesize_timeout = window.setTimeout(PMA_saveFrameSizeReal, 2000);
84 * sets navigation frame width to the value stored in the cookie
85 * usally called on document load
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 && parent.document != document) {
92 if (parent.text_dir == 'ltr') {
93 parent.document.getElementById('mainFrameset').cols = pma_navi_width + ',*';
95 parent.document.getElementById('mainFrameset').cols = '*,' + pma_navi_width;
97 //alert('framesize set');
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
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))) {
116 var end = document.cookie.indexOf(";", len);
118 end = document.cookie.length;
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
130 * @param string domain
131 * @param boolean secure
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" : "");
142 * hide all LI elements with second A tag which doesn`t contain requested value
144 * @param string value requested value
147 function fast_filter(value){
148 lowercase_value = value.toLowerCase();
149 $("#subel0 a[class!='tableicon']").each(function(idx,elem){
151 // .indexOf is case sensitive so convert to lowercase to compare
152 if (value && $elem.html().toLowerCase().indexOf(lowercase_value) == -1) {
153 $elem.parent().hide();
155 $elem.parent().show();
161 * Clears fast filter.
163 function clear_fast_filter() {
164 var elm = $('#NavFilter input');
171 * Reloads the recent tables list.
173 function PMA_reloadRecentTable() {
174 $.get('navigation.php', {
175 'token': window.parent.token,
176 'server': window.parent.server,
177 'ajax_request': true,
178 'recent_table': true},
180 if (data.success == true) {
181 $('#recentTable').html(data.options);
186 /* Performed on load */
187 $(document).ready(function(){
189 $('#NavFilter').css('display', 'inline');
190 $('input[id="fast_filter"]').focus(function() {
191 if($(this).attr("value") === "filter tables by name") {
195 $('#clear_fast_filter').click(clear_fast_filter);
196 $('#fast_filter').focus(function (evt) {evt.target.select();});
197 $('#fast_filter').keyup(function (evt) {fast_filter(evt.target.value);});
199 /* Jump to recent table */
200 $('#recentTable').change(function() {
201 if (this.value != '') {
202 var arr = this.value.split('.');
203 window.parent.setDb(arr[0]);
204 window.parent.setTable(arr[1]);
205 window.parent.refreshMain($('#LeftDefaultTabTable')[0].value);
210 $('#newtable a.ajax').click(function(event){
211 event.preventDefault();
213 var url = $('#newtable a').attr("href");
214 if (url.substring(0, 15) == "tbl_create.php?") {
215 url = url.substring(15);
217 url = url +"&num_fields=&ajax_request=true";
218 /*Creating a div on the frame_content frame */
219 var div = parent.frame_content.$('<div id="create_table_dialog"></div>');
220 var target = "tbl_create.php";
222 /*Calling to the createTableDialog function*/
223 PMA_createTableDialog(div , url , target);
224 });//end of create new table
225 });//end of document get ready