From 8e35b712179fb6f85a3f8f62897c5f26954b43f6 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Wed, 18 Apr 2012 17:30:32 +0100 Subject: [PATCH 1/2] PMD should use PMA_ajaxShowMessage() instead of custom notifications --- js/pmd/ajax.js | 15 ++++----------- pmd_general.php | 1 - themes/original/css/theme_right.css.php | 12 ------------ themes/pmahomme/css/theme_right.css.php | 12 ------------ 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/js/pmd/ajax.js b/js/pmd/ajax.js index 380e67be03..28fab2e477 100644 --- a/js/pmd/ajax.js +++ b/js/pmd/ajax.js @@ -51,20 +51,14 @@ function makeRequest(url, parameters) */ function alertContents() { - // @todo: replace with PMA_ajaxShowMessage() and remove layer_action - var layer = document.getElementById("layer_action"); - if (http_request.readyState == 1) { - layer.style.left = (document.body.clientWidth + document.body.scrollLeft - 85) + 'px'; - layer.style.top = (document.body.scrollTop + 10) + 'px'; - layer.style.visibility = 'visible'; - layer.innerHTML = 'Loading...'; + PMA_ajaxShowMessage(); } if (http_request.readyState == 2) { - layer.innerHTML = 'Loaded'; + PMA_ajaxShowMessage('Loaded'); } if (http_request.readyState == 3) { - layer.innerHTML = 'Loading 99%'; + PMA_ajaxShowMessage('Loading 99%'); } if (http_request.readyState == 4) { if (http_request.status == 200) { @@ -72,9 +66,8 @@ function alertContents() //alert(textdoc); xmldoc = http_request.responseXML; PrintXML(); - //layer.style.visibility = 'hidden'; } else { - alert('There was a problem with the request.'); + PMA_ajaxShowMessage('There was a problem with the request.'); } } } diff --git a/pmd_general.php b/pmd_general.php index 0044697668..11ca4dfdc7 100644 --- a/pmd_general.php +++ b/pmd_general.php @@ -344,7 +344,6 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) { ?>
- diff --git a/themes/original/css/theme_right.css.php b/themes/original/css/theme_right.css.php index 65bc3c88f6..9810bd6431 100644 --- a/themes/original/css/theme_right.css.php +++ b/themes/original/css/theme_right.css.php @@ -2885,18 +2885,6 @@ a.M_butt:hover { border: #999999 solid 1px; } -#layer_action { - position: absolute; - left: 638px; - top: 52px; - z-index: 1000; - background-color: #CCFF99; - padding: 3px; - border: #009933 solid 1px; - white-space: nowrap; - font-weight: bold; -} - #layer_upd_relation { position: absolute; left: 637px; diff --git a/themes/pmahomme/css/theme_right.css.php b/themes/pmahomme/css/theme_right.css.php index c97dc8dff3..88f5ea8189 100644 --- a/themes/pmahomme/css/theme_right.css.php +++ b/themes/pmahomme/css/theme_right.css.php @@ -3410,18 +3410,6 @@ a.M_butt:hover { border: #999 solid 1px; } -#layer_action { - position: absolute; - left: 638px; - top: 52px; - z-index: 1000; - background-color: #CCFF99; - padding: 3px; - border: #009933 solid 1px; - white-space: nowrap; - font-weight: bold; -} - #layer_upd_relation { position: absolute; left: 637px; From 2af9f1e1206ab0e2402416f4479fd20b5044d528 Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Wed, 18 Apr 2012 18:09:44 +0100 Subject: [PATCH 2/2] Use jQuery for ajax functionality in PMD --- js/pmd/ajax.js | 110 +++++++++++-------------------------------------- 1 file changed, 24 insertions(+), 86 deletions(-) diff --git a/js/pmd/ajax.js b/js/pmd/ajax.js index 28fab2e477..766c3dd060 100644 --- a/js/pmd/ajax.js +++ b/js/pmd/ajax.js @@ -4,111 +4,49 @@ * @package PhpMyAdmin-Designer */ -/** - * - */ -var http_request = false; -var xmldoc; -var textdoc; - /** * */ function makeRequest(url, parameters) { - http_request = false; - if (window.XMLHttpRequest) { - // Mozilla, Safari,... - http_request = new XMLHttpRequest(); - if (http_request.overrideMimeType) { - http_request.overrideMimeType('text/xml'); - } - } else if (window.ActiveXObject) { - // IE - try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } - catch (e) { - try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } - catch (e) {} - } - } - - if (!http_request) { - alert('Giving up :( Cannot create an XMLHTTP instance'); - return false; - } - - http_request.onreadystatechange = alertContents; - http_request.open('POST', url, true); - http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - http_request.setRequestHeader("Content-length", parameters.length); - http_request.setRequestHeader("Connection", "close"); - http_request.send(parameters); + var $msg = PMA_ajaxShowMessage(); + $.post(url, parameters, function (data) { + PMA_ajaxRemoveMessage($msg); + PrintXML(data); + }); return true; } /** * */ -function alertContents() +function PrintXML(data) { - if (http_request.readyState == 1) { - PMA_ajaxShowMessage(); - } - if (http_request.readyState == 2) { - PMA_ajaxShowMessage('Loaded'); - } - if (http_request.readyState == 3) { - PMA_ajaxShowMessage('Loading 99%'); - } - if (http_request.readyState == 4) { - if (http_request.status == 200) { - textdoc = http_request.responseText; - //alert(textdoc); - xmldoc = http_request.responseXML; - PrintXML(); - } else { - PMA_ajaxShowMessage('There was a problem with the request.'); - } - } -} - -/** - * - */ -function PrintXML() -{ - var root = xmldoc.getElementsByTagName('root').item(0); //root - //alert(xmldoc.getElementsByTagName('root').item(1)); - if (root == null) { - // if error + var $root = $(data).find('root'); + if ($root.length == 0) { + // error var myWin=window.open('','Report','width=400, height=250, resizable=1, scrollbars=1, status=1'); var tmp = myWin.document; - tmp.write(textdoc); + tmp.write(data); tmp.close(); } else { - //alert(xmldoc.getElementsByTagName('root')[0]); - //alert(root.attributes[0].nodeValue); - //alert(xmldoc.getElementsByTagName('root')[0].attributes[0].nodeValue); - //xmldoc.getElementsByTagName('root')[0].getAttribute("act") - - if (root.getAttribute('act') == 'save_pos') { - PMA_ajaxShowMessage(root.getAttribute('return')); - } - if (root.getAttribute('act') == 'relation_upd') { - PMA_ajaxShowMessage(root.getAttribute('return')); - if (root.getAttribute('b') == '1') { - contr.splice(root.getAttribute('K'), 1); + // success + if ($root.attr('act') == 'save_pos') { + PMA_ajaxShowMessage($root.attr('return')); + } else if ($root.attr('act') == 'relation_upd') { + PMA_ajaxShowMessage($root.attr('return')); + if ($root.attr('b') == '1') { + contr.splice($root.attr('K'), 1); Re_load(); } - } - if (root.getAttribute('act') == 'relation_new') { - PMA_ajaxShowMessage(root.getAttribute('return')); - if (root.getAttribute('b') == '1') { + } else if ($root.attr('act') == 'relation_new') { + PMA_ajaxShowMessage($root.attr('return')); + if ($root.attr('b') == '1') { var i = contr.length; - var t1 = root.getAttribute('DB1') + '.' + root.getAttribute('T1'); - var f1 = root.getAttribute('F1'); - var t2 = root.getAttribute('DB2') + '.' + root.getAttribute('T2'); - var f2 = root.getAttribute('F2'); + var t1 = $root.attr('DB1') + '.' + $root.attr('T1'); + var f1 = $root.attr('F1'); + var t2 = $root.attr('DB2') + '.' + $root.attr('T2'); + var f2 = $root.attr('F2'); contr[i] = []; contr[i][''] = []; contr[i][''][t2] = [];