From 0598d99925efdda3983656a6b9497e159f9d7e82 Mon Sep 17 00:00:00 2001 From: Thilanka Kaushalya Date: Sat, 21 May 2011 16:45:51 +0530 Subject: [PATCH 001/779] Ajaxify the create table option in navigation panel - have bugs --- js/functions.js | 2 +- js/navigation.js | 66 +++++++++++++++++++++++++++++++++++++++- libraries/common.inc.php | 1 + navigation.php | 5 ++- 4 files changed, 71 insertions(+), 3 deletions(-) diff --git a/js/functions.js b/js/functions.js index a5118df9a2..30a8fc8900 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1499,7 +1499,7 @@ $(document).ready(function() { PMA_ajaxShowMessage(data.message); // Only if the create table dialog (distinct panel) exists if ($("#create_table_dialog").length > 0) { - $("#create_table_dialog").dialog("close").remove(); + $("#create_table_dialog").parent().dialog("close").remove(); } /** diff --git a/js/navigation.js b/js/navigation.js index 505284895a..93fddbf238 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -179,4 +179,68 @@ $(document).ready(function(){ $('#clear_fast_filter').click(clear_fast_filter); $('#fast_filter').focus(function (evt) {evt.target.select();}); $('#fast_filter').keyup(function (evt) {fast_filter(evt.target.value);}); -}); + + /* Create table */ + $('#newtable').click(function(event){ + event.preventDefault(); + cls = $('#newtable a').attr("class"); + if(cls == 'ajax'){ + url = $('#newtable a').attr("href"); + //$div = parent.frame_content.$('
'); + //$form = $(this); + + /* @todo Validate this form! */ + + /** + * @var button_options Object that stores the options passed to jQueryUI + * dialog + */ + var button_options = {}; + // in the following function we need to use $(this) + button_options["Cancel"] = function() {$(this).parent().dialog('close').remove();} + + var button_options_error = {}; + button_options_error["OK"] = function() {$(this).parent().dialog('close').remove();} + + //var $msgbox = PMA_ajaxShowMessage(); + //PMA_prepareForAjaxRequest($form); + + $.get( url , function(data) { + //in the case of an error, show the error message returned. + if (data.success != undefined && data.success == false) { + parent.frame_content.$('
') + //$div + .append(data.error) + .dialog({ + title: 'Create Table', + height: 230, + width: 900, + //open: PMA_verifyTypeOfAllColumns, + buttons : button_options_error + })// end dialog options + //remove the redundant [Back] link in the error message. + .find('fieldset').remove(); + } else { + parent.frame_content.$('
') + //$div + .append(data) + .dialog({ + title: 'Create Table', + height: 600, + width: 900, + //open: PMA_verifyTypeOfAllColumns, + buttons : button_options + // buttons : {"Close" : function() {$(this).dialog('close');}} + }); // end dialog options + } + //PMA_ajaxRemoveMessage($msgbox); + }) // end $.get() + //$div.remove(); + // empty table name and number of columns from the minimal form + // $form.find('input[name=table],input[name=num_fields]').val(''); + //event.preventDefault(); + }else{} + });//end of create new form + + +});//end of document get ready \ No newline at end of file diff --git a/libraries/common.inc.php b/libraries/common.inc.php index d75084b3cf..70b70fe797 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -540,6 +540,7 @@ $_REQUEST['js_frame'] = PMA_ifSetOr($_REQUEST['js_frame'], ''); */ $GLOBALS['js_include'] = array(); $GLOBALS['js_include'][] = 'jquery/jquery-1.6.1.js'; +$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; $GLOBALS['js_include'][] = 'update-location.js'; /** diff --git a/navigation.php b/navigation.php index a07a5166ec..47bc9577f7 100644 --- a/navigation.php +++ b/navigation.php @@ -127,6 +127,7 @@ require_once './libraries/header_http.inc.php'; + - + + - +