1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * @fileoverview Implements the shiftkey + click remove column
4 * from order by clause funcationality
10 function captureURL(url)
14 // Exclude the url part till HTTP
15 url = url.substr(url.search("sql.php"), url.length);
16 // The url part between ORDER BY and &session_max_rows needs to be replaced.
17 URL.head = url.substr(0, url.indexOf('ORDER+BY') + 9);
18 URL.tail = url.substr(url.indexOf("&session_max_rows"), url.length);
23 * This function is for navigating to the generated URL
25 * @param object target HTMLAnchor element
26 * @param object parent HTMLDom Object
29 function removeColumnFromMultiSort(target, parent)
31 var URL = captureURL(target);
32 var begin = target.indexOf('ORDER+BY') + 8;
33 var end = target.indexOf('&session_max_rows');
34 // get the names of the columns involved
35 var between_part = target.substr(begin, end-begin);
36 var columns = between_part.split('%2C+');
37 // If the given column is not part of the order clause exit from this function
38 var index = parent.find('small').length ? parent.find('small').text() : '';
42 // Remove the current clicked column
43 columns.splice(index-1, 1);
44 // If all the columns have been removed dont submit a query with nothing
45 // After order by clause.
46 if (columns.length === 0) {
48 head = head.slice(0,head.indexOf('ORDER+BY'));
50 // removing the last sort order should have priority over what
51 // is remembered via the RememberSorting directive
52 URL.tail += '&discard_remembered_sort=1';
54 var middle_part = columns.join('%2C+');
55 url = URL.head + middle_part + URL.tail;
59 AJAX.registerOnload('keyhandler.js', function () {
60 $("th.draggable.column_heading.pointer.marker a").on('click', function (event) {
61 var url = $(this).parent().find('input').val();
62 if (event.ctrlKey || event.altKey) {
63 event.preventDefault();
64 url = removeColumnFromMultiSort(url, $(this).parent());
66 AJAX.source = $(this);
67 PMA_ajaxShowMessage();
68 $.get(url, {'ajax_request' : true, 'ajax_page_request' : true}, AJAX.responseHandler);
70 } else if (event.shiftKey) {
71 event.preventDefault();
72 AJAX.source = $(this);
73 PMA_ajaxShowMessage();
74 $.get(url, {'ajax_request' : true, 'ajax_page_request' : true}, AJAX.responseHandler);
79 AJAX.registerTeardown('keyhandler.js', function () {
80 $(document).off('click', "th.draggable.column_heading.pointer.marker a");