Don't scroll with AJAX image buttons
This commit is contained in:
parent
56a1bdd7fc
commit
2140f09b68
|
@ -304,9 +304,10 @@ var ajaxState = 0;
|
||||||
* @param string
|
* @param string
|
||||||
* @param [string]
|
* @param [string]
|
||||||
* @param [boolean]
|
* @param [boolean]
|
||||||
|
* @param [boolean]
|
||||||
* @return XMLHttpRequest or false in case of an error
|
* @return XMLHttpRequest or false in case of an error
|
||||||
*/
|
*/
|
||||||
function ajaxSend(url, data, popState) {
|
function ajaxSend(url, data, popState, noscroll) {
|
||||||
if (!history.pushState) {
|
if (!history.pushState) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -332,8 +333,10 @@ function ajaxSend(url, data, popState) {
|
||||||
} else {
|
} else {
|
||||||
if (!popState) {
|
if (!popState) {
|
||||||
if (data || url != location.href) {
|
if (data || url != location.href) {
|
||||||
history.pushState(data, '', url);
|
history.pushState(data, '', url); //! remember window position
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!noscroll) {
|
||||||
scrollTo(0, 0);
|
scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
setHtml('content', xmlhttp.responseText);
|
setHtml('content', xmlhttp.responseText);
|
||||||
|
@ -380,9 +383,10 @@ onpopstate = function (event) {
|
||||||
/** Send form by AJAX GET
|
/** Send form by AJAX GET
|
||||||
* @param HTMLFormElement
|
* @param HTMLFormElement
|
||||||
* @param [string]
|
* @param [string]
|
||||||
|
* @param [boolean]
|
||||||
* @return XMLHttpRequest or false in case of an error
|
* @return XMLHttpRequest or false in case of an error
|
||||||
*/
|
*/
|
||||||
function ajaxForm(form, data) {
|
function ajaxForm(form, data, noscroll) {
|
||||||
if (/&(database|scheme|create|view|sql|user|dump|call)=/.test(location.href) && !/\./.test(data)) { // . - type="image"
|
if (/&(database|scheme|create|view|sql|user|dump|call)=/.test(location.href) && !/\./.test(data)) { // . - type="image"
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -399,9 +403,9 @@ function ajaxForm(form, data) {
|
||||||
params.push(data);
|
params.push(data);
|
||||||
}
|
}
|
||||||
if (form.method == 'post') {
|
if (form.method == 'post') {
|
||||||
return ajaxSend((/\?/.test(form.action) ? form.action : location.href), params.join('&')); // ? - always part of Adminer URL
|
return ajaxSend((/\?/.test(form.action) ? form.action : location.href), params.join('&'), noscroll); // ? - always part of Adminer URL
|
||||||
}
|
}
|
||||||
return ajaxSend((form.action || location.href).replace(/\?.*/, '') + '?' + params.join('&'));
|
return ajaxSend((form.action || location.href).replace(/\?.*/, '') + '?' + params.join('&'), noscroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -493,7 +497,7 @@ function bodyClick(event, db, ns) {
|
||||||
return !(db == (match ? match[1] : '') && ns == (match2 ? match2[1] : '') && ajaxSend(el.href));
|
return !(db == (match ? match[1] : '') && ns == (match2 ? match2[1] : '') && ajaxSend(el.href));
|
||||||
}
|
}
|
||||||
if (/^input$/i.test(el.tagName) && /image|submit/.test(el.type)) {
|
if (/^input$/i.test(el.tagName) && /image|submit/.test(el.type)) {
|
||||||
return !ajaxForm(el.form, (el.name ? encodeURIComponent(el.name) + (el.type == 'image' ? '.x' : '') + '=1' : ''));
|
return !ajaxForm(el.form, (el.name ? encodeURIComponent(el.name) + (el.type == 'image' ? '.x' : '') + '=1' : ''), el.type == 'image');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue