Generic AJAX links
This commit is contained in:
parent
8ad4809bc0
commit
6585b23ba8
|
@ -139,7 +139,7 @@ document.getElementById('username').focus();
|
||||||
*/
|
*/
|
||||||
function selectQuery($query) {
|
function selectQuery($query) {
|
||||||
global $jush;
|
global $jush;
|
||||||
return "<p><a href='" . h(remove_from_uri("page")) . "&page=last' title='" . lang('Last page') . "' onclick='return !ajaxMain(this.href, undefined, event);'>>></a> <code class='jush-$jush'>" . h(str_replace("\n", " ", $query)) . "</code> <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>\n";
|
return "<p><a href='" . h(remove_from_uri("page")) . "&page=last' title='" . lang('Last page') . "'>>></a> <code class='jush-$jush'>" . h(str_replace("\n", " ", $query)) . "</code> <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Description of a row in a table
|
/** Description of a row in a table
|
||||||
|
|
|
@ -26,7 +26,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
||||||
<link rel="stylesheet" type="text/css" href="adminer.css">
|
<link rel="stylesheet" type="text/css" href="adminer.css">
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<body class="<?php echo lang('ltr'); ?>" onload="bodyLoad('<?php echo (is_object($connection) ? substr($connection->server_info, 0, 3) : ""); ?>', '<?php echo $protocol; ?>');<?php echo (isset($_COOKIE["adminer_version"]) ? "" : " verifyVersion('$protocol');"); ?>">
|
<body class="<?php echo lang('ltr'); ?>" onclick="return bodyClick(event<?php echo (isset($_GET["username"]) ? ", '" . js_escape(DB) . "'" : ""); ?>);" onload="bodyLoad('<?php echo (is_object($connection) ? substr($connection->server_info, 0, 3) : ""); ?>', '<?php echo $protocol; ?>');<?php echo (isset($_COOKIE["adminer_version"]) ? "" : " verifyVersion('$protocol');"); ?>">
|
||||||
<script type="text/javascript" src="../adminer/static/functions.js"></script>
|
<script type="text/javascript" src="../adminer/static/functions.js"></script>
|
||||||
<script type="text/javascript" src="static/editing.js"></script>
|
<script type="text/javascript" src="static/editing.js"></script>
|
||||||
|
|
||||||
|
|
|
@ -462,7 +462,7 @@ function remove_from_uri($param = "") {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function pagination($page, $current) {
|
function pagination($page, $current) {
|
||||||
return " " . ($page == $current ? $page + 1 : '<a href="' . h(remove_from_uri("page") . ($page ? "&page=$page" : "")) . '" onclick="return !ajaxMain(this.href, undefined, event);">' . ($page + 1) . "</a>");
|
return " " . ($page == $current ? $page + 1 : '<a href="' . h(remove_from_uri("page") . ($page ? "&page=$page" : "")) . '">' . ($page + 1) . "</a>");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get file contents from $_FILES
|
/** Get file contents from $_FILES
|
||||||
|
|
|
@ -263,7 +263,7 @@ if (!$columns) {
|
||||||
$rank++;
|
$rank++;
|
||||||
$names[$key] = $name;
|
$names[$key] = $name;
|
||||||
$column = idf_escape($key);
|
$column = idf_escape($key);
|
||||||
echo '<th><a href="' . h(remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key) . ($order[0] == $column || $order[0] == $key || (!$order && $group[0] == $column) ? '&desc%5B0%5D=1' : '')) . '" onclick="return !ajaxMain(this.href, undefined, event);">' . apply_sql_function($val["fun"], $name) . "</a>"; // $order[0] == $key - COUNT(*) //! columns looking like functions
|
echo '<th><a href="' . h(remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key) . ($order[0] == $column || $order[0] == $key || (!$order && $group[0] == $column) ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>"; // $order[0] == $key - COUNT(*) //! columns looking like functions
|
||||||
}
|
}
|
||||||
$functions[$key] = $val["fun"];
|
$functions[$key] = $val["fun"];
|
||||||
next($select);
|
next($select);
|
||||||
|
@ -386,7 +386,7 @@ if (!$columns) {
|
||||||
for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) {
|
for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) {
|
||||||
echo pagination($i, $page);
|
echo pagination($i, $page);
|
||||||
}
|
}
|
||||||
echo ($page + 5 < $max_page ? " ..." : "") . ($exact_count ? pagination($max_page, $page) : ' <a href="' . h(remove_from_uri() . "&page=last") . '" onclick="return !ajaxMain(this.href, undefined, event);">' . lang('last') . "</a>");
|
echo ($page + 5 < $max_page ? " ..." : "") . ($exact_count ? pagination($max_page, $page) : ' <a href="' . h(remove_from_uri() . "&page=last") . '">' . lang('last') . "</a>");
|
||||||
}
|
}
|
||||||
echo " (" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ") " . checkbox("all", 1, 0, lang('whole result')) . "\n";
|
echo " (" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ") " . checkbox("all", 1, 0, lang('whole result')) . "\n";
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ function setHtml(id, html) {
|
||||||
function pageClick(href, page, event) {
|
function pageClick(href, page, event) {
|
||||||
if (!isNaN(page) && page) {
|
if (!isNaN(page) && page) {
|
||||||
href += (page != 1 ? '&page=' + (page - 1) : '');
|
href += (page != 1 ? '&page=' + (page - 1) : '');
|
||||||
if (!ajaxMain(href, undefined, event)) {
|
if (!ajaxMain(href, '', event)) {
|
||||||
location.href = href;
|
location.href = href;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ function ajaxSend(url, data) {
|
||||||
* @return XMLHttpRequest or false in case of an error
|
* @return XMLHttpRequest or false in case of an error
|
||||||
*/
|
*/
|
||||||
function ajaxMain(url, data, event) {
|
function ajaxMain(url, data, event) {
|
||||||
if (!history.pushState || (event && event.ctrlKey)) {
|
if (!history.pushState || (event && (event.ctrlKey || event.shiftKey || event.metaKey))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
history.pushState(data, '', url);
|
history.pushState(data, '', url);
|
||||||
|
@ -286,9 +286,8 @@ function ajaxForm(form, data) {
|
||||||
}
|
}
|
||||||
if (form.method == 'post') {
|
if (form.method == 'post') {
|
||||||
return ajaxMain((/\?/.test(form.action) ? form.action : location.href), params.join('&')); // ? - always part of Adminer URL
|
return ajaxMain((/\?/.test(form.action) ? form.action : location.href), params.join('&')); // ? - always part of Adminer URL
|
||||||
} else {
|
|
||||||
return ajaxMain((form.action || location.pathname) + '?' + params.join('&'));
|
|
||||||
}
|
}
|
||||||
|
return ajaxMain((form.action || location.pathname) + '?' + params.join('&'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -341,3 +340,32 @@ function selectDblClick(td, event, text) {
|
||||||
range.select();
|
range.select();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Load link by AJAX
|
||||||
|
* @param MouseEvent
|
||||||
|
* @param [string]
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function bodyClick(event, db) {
|
||||||
|
var el = event.target || event.srcElement;
|
||||||
|
if (/^a$/i.test(el.parentNode.tagName)) {
|
||||||
|
el = el.parentNode;
|
||||||
|
}
|
||||||
|
if (/^a$/i.test(el.tagName) && !/^https?:/i.test(el.getAttribute('href')) && !el.onclick && /[&?]username=/.exec(el.href)) {
|
||||||
|
var match = /&db=([^&]*)/.exec(el.href);
|
||||||
|
if (db === (match ? match[1] : '') && ajaxMain(el.href, '', event)) {
|
||||||
|
var as = document.getElementById('menu').getElementsByTagName('a');
|
||||||
|
for (var i=0; i < as.length; i++) {
|
||||||
|
if (as[i].className == 'active') {
|
||||||
|
as[i].className = '';
|
||||||
|
} else if (el.href == as[i].href) {
|
||||||
|
as[i].className = 'active';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//! modify Export link
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue