diff --git a/js/functions.js b/js/functions.js index c9f6112dff..be5a8bbc40 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1309,6 +1309,53 @@ function PMA_showNoticeForEnum(selectElement) { } } +/** + * Generates a dialog box to pop up the create_table form + */ +function PMA_createTableDialog( div, url , target){ + /** + * @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[PMA_messages['strCancel']] = function() {$(this).parent().dialog('close').remove();} + + var button_options_error = {}; + button_options_error[PMA_messages['strOK']] = function() {$(this).parent().dialog('close').remove();} + + var $msgbox = PMA_ajaxShowMessage(); + + $.get( target , url , function(data) { + //in the case of an error, show the error message returned. + if (data.success != undefined && data.success == false) { + div + .append(data.error) + .dialog({ + title: PMA_messages['strCreateTable'], + 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 { + div + .append(data) + .dialog({ + title: PMA_messages['strCreateTable'], + height: 600, + width: 900, + open: PMA_verifyTypeOfAllColumns, + buttons : button_options + }); // end dialog options + } + PMA_ajaxRemoveMessage($msgbox); + }) // end $.get() + +} + /** * jQuery function that uses jQueryUI's dialogs to confirm with user. Does not * return a jQuery object yet and hence cannot be chained @@ -1403,7 +1450,7 @@ jQuery.fn.PMA_sort_table = function(text_selector) { */ $(document).ready(function() { - /** + /** * Attach event handler to the submit action of the create table minimal form * and retrieve the full table form and display it in a dialog * @@ -1412,50 +1459,15 @@ $(document).ready(function() { $("#create_table_form_minimal.ajax").live('submit', function(event) { event.preventDefault(); $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[PMA_messages['strCancel']] = function() {$(this).dialog('close').remove();} - - var button_options_error = {}; - button_options_error[PMA_messages['strOK']] = function() {$(this).dialog('close').remove();} - - var $msgbox = PMA_ajaxShowMessage(); PMA_prepareForAjaxRequest($form); - $.get($form.attr('action'), $form.serialize(), function(data) { - //in the case of an error, show the error message returned. - if (data.success != undefined && data.success == false) { - $('
') - .append(data.error) - .dialog({ - title: PMA_messages['strCreateTable'], - 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 { - $('
') - .append(data) - .dialog({ - title: PMA_messages['strCreateTable'], - height: 600, - width: 900, - open: PMA_verifyTypeOfAllColumns, - buttons : button_options - }); // end dialog options - } - PMA_ajaxRemoveMessage($msgbox); - }) // end $.get() + /*variables which stores the common attributes*/ + var url = $form.serialize(); + var action = $form.attr('action'); + var div = $('
'); + + /*Calling to the createTableDialog function*/ + PMA_createTableDialog(div, url, action); // empty table name and number of columns from the minimal form $form.find('input[name=table],input[name=num_fields]').val(''); diff --git a/js/navigation.js b/js/navigation.js index 52d13cfd4d..7f9a013119 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -202,4 +202,22 @@ $(document).ready(function(){ window.parent.refreshMain($('#LeftDefaultTabTable')[0].value); } }); -}); + + /* Create table */ + $('#newtable a.ajax').click(function(event){ + event.preventDefault(); + /*Getting the url */ + var url = $('#newtable a').attr("href"); + if (url.substring(0, 15) == "tbl_create.php?") { + url = url.substring(15); + } + url = url +"&num_fields=&ajax_request=true"; + /*Creating a div on the frame_content frame */ + var div = parent.frame_content.$('
'); + var target = "tbl_create.php"; + + /*Calling to the createTableDialog function*/ + PMA_createTableDialog(div , url , target); + });//end of create new table +});//end of document get ready + 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/libraries/tbl_properties.inc.php b/libraries/tbl_properties.inc.php index 395fa7be95..501e243bb6 100644 --- a/libraries/tbl_properties.inc.php +++ b/libraries/tbl_properties.inc.php @@ -613,14 +613,22 @@ unset($_form_params); if ($action == 'tbl_create.php') { ?> - - - - + + - + + +
+
-
+ + '); ?> + + +
- - - '); ?> - - onclick="return checkFormElementInRange(this.form, 'added_fields', '', 1)" - /> -
diff --git a/navigation.php b/navigation.php index ac128070d5..dc68489d01 100644 --- a/navigation.php +++ b/navigation.php @@ -137,8 +137,10 @@ require_once './libraries/header_http.inc.php'; + +