/* vim: set expandtab sw=4 ts=4 sts=4: */ /** * @fileoverview functions used wherever an sql query form is used * * @requires jQuery * @requires js/functions.js * */ var $data_a; var prevScrollX = 0, fixedTop; /** * decode a string URL_encoded * * @param string str * @return string the URL-decoded string */ function PMA_urldecode(str) { if (typeof str !== 'undefined') { return decodeURIComponent(str.replace(/\+/g, '%20')); } } /** * endecode a string URL_decoded * * @param string str * @return string the URL-encoded string */ function PMA_urlencode(str) { if (typeof str !== 'undefined') { return encodeURIComponent(str).replace(/\%20/g, '+'); } } /** * Get the field name for the current field. Required to construct the query * for grid editing * * @param $this_field jQuery object that points to the current field's tr */ function getFieldName($this_field) { var this_field_index = $this_field.index(); // ltr or rtl direction does not impact how the DOM was generated // check if the action column in the left exist var left_action_exist = !$('#table_results').find('th:first').hasClass('draggable'); // number of column span for checkbox and Actions var left_action_skip = left_action_exist ? $('#table_results').find('th:first').attr('colspan') - 1 : 0; // If this column was sorted, the text of the a element contains something // like 1 that is useful to indicate the order in case // of a sort on multiple columns; however, we dont want this as part // of the column name so we strip it ( .clone() to .end() ) var field_name = $('#table_results') .find('thead') .find('th:eq(' + (this_field_index - left_action_skip) + ') a') .clone() // clone the element .children() // select all the children .remove() // remove all of them .end() // go back to the selected element .text(); // grab the text // happens when just one row (headings contain no a) if (field_name === '') { var $heading = $('#table_results').find('thead').find('th:eq(' + (this_field_index - left_action_skip) + ')').children('span'); // may contain column comment enclosed in a span - detach it temporarily to read the column name var $tempColComment = $heading.children().detach(); field_name = $heading.text(); // re-attach the column comment $heading.append($tempColComment); } field_name = $.trim(field_name); return field_name; } /** * Unbind all event handlers before tearing down a page */ AJAX.registerTeardown('sql.js', function () { $('a.delete_row.ajax').die('click'); $('#bookmarkQueryForm').die('submit'); $('input#bkm_label').unbind('keyup'); $("#sqlqueryresults").die('makegrid'); $("#sqlqueryresults").die('stickycolumns'); $("#togglequerybox").unbind('click'); $("#button_submit_query").die('click'); $("input[name=bookmark_variable]").unbind("keypress"); $("#sqlqueryform.ajax").die('submit'); $("input[name=navig].ajax").die('click'); $("#pageselector").die('change'); $("#table_results.ajax").find("a[title=Sort]").die('click'); $("#displayOptionsForm.ajax").die('submit'); $('th.column_heading.pointer').die('hover'); $('th.column_heading.marker').die('click'); $(window).unbind('scroll'); $(".filter_rows").die("keyup"); $('body').off('click', '.navigation .showAllRows'); $('body').off('click','a.browse_foreign'); $('body').off('click', '#simulate_dml'); $('body').off('keyup', '#sqlqueryform'); $('body').off('click', '#resultsForm.ajax button[name="submit_mult"], #resultsForm.ajax input[name="submit_mult"]'); }); /** * @description
Ajax scripts for sql and browse pages
* * Actions ajaxified here: *