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 img
.className
= 'icon ic_b_minus';
36 el
.style
.display
= 'none';
38 img
.className
= 'icon ic_b_plus';
45 function PMA_callFunctionDelayed(myfunction
, delay
)
47 if (typeof pma_saveframesize_timeout
== "number") {
48 window
.clearTimeout(pma_saveframesize_timeout
);
49 pma_saveframesize_timeout
= null;
54 * saves current navigation frame width in a cookie
55 * usally called on resize of the navigation frame
57 function PMA_saveFrameSizeReal()
59 if (parent
.text_dir
== 'ltr') {
60 pma_navi_width
= parseInt(parent
.document
.getElementById('mainFrameset').cols
)
62 pma_navi_width
= parent
.document
.getElementById('mainFrameset').cols
.match(/\d+$/)
64 if ((pma_navi_width
> 0) && (pma_navi_width
!= PMA_getCookie('pma_navi_width'))) {
65 PMA_setCookie('pma_navi_width', pma_navi_width
, expires
);
70 * calls PMA_saveFrameSizeReal with delay
72 function PMA_saveFrameSize()
74 //alert(typeof(pma_saveframesize_timeout) + ' : ' + pma_saveframesize_timeout);
76 if (typeof pma_saveframesize_timeout
== "number") {
77 window
.clearTimeout(pma_saveframesize_timeout
);
78 pma_saveframesize_timeout
= null;
81 pma_saveframesize_timeout
= window
.setTimeout(PMA_saveFrameSizeReal
, 2000);
85 * sets navigation frame width to the value stored in the cookie
86 * usally called on document load
88 function PMA_setFrameSize()
90 pma_navi_width
= PMA_getCookie('pma_navi_width');
91 //alert('from cookie: ' + typeof(pma_navi_width) + ' : ' + pma_navi_width);
92 if (pma_navi_width
!= null && parent
.document
!= document
) {
93 if (parent
.text_dir
== 'ltr') {
94 parent
.document
.getElementById('mainFrameset').cols
= pma_navi_width
+ ',*';
96 parent
.document
.getElementById('mainFrameset').cols
= '*,' + pma_navi_width
;
98 //alert('framesize set');
103 * retrieves a named value from cookie
105 * @param string name name of the value to retrieve
106 * @return string value value for the given name from cookie
108 function PMA_getCookie(name
)
110 var start
= document
.cookie
.indexOf(name
+ "=");
111 var len
= start
+ name
.length
+ 1;
112 if ((!start
) && (name
!= document
.cookie
.substring(0, name
.length
))) {
118 var end
= document
.cookie
.indexOf(";", len
);
120 end
= document
.cookie
.length
;
122 return unescape(document
.cookie
.substring(len
,end
));
126 * stores a named value into cookie
128 * @param string name name of value
129 * @param string value value to be stored
130 * @param Date expires expire time
132 * @param string domain
133 * @param boolean secure
135 function PMA_setCookie(name
, value
, expires
, path
, domain
, secure
)
137 document
.cookie
= name
+ "=" + escape(value
) +
138 ( (expires
) ? ";expires=" + expires
.toGMTString() : "") +
139 ( (path
) ? ";path=" + path
: "") +
140 ( (domain
) ? ";domain=" + domain
: "") +
141 ( (secure
) ? ";secure" : "");
145 * hide all LI elements with second A tag which doesn`t contain requested value
147 * @param string value requested value
150 function fast_filter(value
)
152 lowercase_value
= value
.toLowerCase();
153 $("#subel0 a[class!='tableicon']").each(function(idx
,elem
){
155 // .indexOf is case sensitive so convert to lowercase to compare
156 if (value
&& $elem
.html().toLowerCase().indexOf(lowercase_value
) == -1) {
157 $elem
.parent().hide();
159 $elem
.parent().show();
165 * Clears fast filter.
167 function clear_fast_filter()
169 var elm
= $('#NavFilter input');
176 * Reloads the recent tables list.
178 function PMA_reloadRecentTable()
180 $.get('navigation.php', {
181 'token': window
.parent
.token
,
182 'server': window
.parent
.server
,
183 'ajax_request': true,
184 'recent_table': true},
186 if (data
.success
== true) {
187 $('#recentTable').html(data
.options
);
192 /* Performed on load */
193 $(document
).ready(function(){
195 $('#NavFilter').css('display', 'inline');
196 $('input[id="fast_filter"]').focus(function() {
197 if($(this).attr("value") === "filter tables by name") {
201 $('#clear_fast_filter').click(clear_fast_filter
);
202 $('#fast_filter').focus(function (evt
) {evt
.target
.select();});
203 $('#fast_filter').keyup(function (evt
) {fast_filter(evt
.target
.value
);});
205 /* Jump to recent table */
206 $('#recentTable').change(function() {
207 if (this.value
!= '') {
208 var arr
= jQuery
.parseJSON(this.value
);
209 window
.parent
.setDb(arr
['db']);
210 window
.parent
.setTable(arr
['table']);
211 window
.parent
.refreshMain($('#LeftDefaultTabTable')[0].value
);
216 $('#newtable a.ajax').click(function(event
){
217 event
.preventDefault();
219 var url
= $('#newtable a').attr("href");
220 if (url
.substring(0, 15) == "tbl_create.php?") {
221 url
= url
.substring(15);
223 url
= url
+"&num_fields=&ajax_request=true";
224 /*Creating a div on the frame_content frame */
225 var div
= parent
.frame_content
.$('<div id="create_table_dialog"></div>');
226 var target
= "tbl_create.php";
228 /*Calling to the createTableDialog function*/
229 PMA_createTableDialog(div
, url
, target
);
230 });//end of create new table
231 });//end of document get ready