Ajaxified "Create index" dialog
This commit is contained in:
parent
5cb7a002f3
commit
a97eeae7ad
@ -45,6 +45,8 @@ $js_messages['strBLOBRepositoryDisableAreYouSure'] = sprintf(__('Are you sure yo
|
||||
/* For indexes */
|
||||
$js_messages['strFormEmpty'] = __('Missing value in the form!');
|
||||
$js_messages['strNotNumber'] = __('This is not a number!');
|
||||
$js_messages['strAddIndex'] = __('Add Index');
|
||||
$js_messages['strEditIndex'] = __('Edit Index');
|
||||
|
||||
/* Charts */
|
||||
/* l10n: Default description for the y-Axis of Charts */
|
||||
|
||||
@ -196,13 +196,21 @@ $(document).ready(function() {
|
||||
/**
|
||||
*Ajax event handler for index edit
|
||||
**/
|
||||
$("#table_index tbody tr td.edit_index.ajax").live('click', function(event){
|
||||
$("#table_index tbody tr td.edit_index.ajax, #indexes .add_index.ajax").live('click', function(event){
|
||||
event.preventDefault();
|
||||
var url = $(this).find("a").attr("href");
|
||||
if (url.substring(0, 16) == "tbl_indexes.php?") {
|
||||
url = url.substring(16, url.length );
|
||||
if ($(this).find("a").length == 0) {
|
||||
// Add index
|
||||
var url = $(this).closest('form').serialize();
|
||||
var title = PMA_messages['strAddIndex'];
|
||||
} else {
|
||||
// Edit index
|
||||
var url = $(this).find("a").attr("href");
|
||||
if (url.substring(0, 16) == "tbl_indexes.php?") {
|
||||
url = url.substring(16, url.length );
|
||||
}
|
||||
var title = PMA_messages['strEditIndex'];
|
||||
}
|
||||
url = url + "&ajax_request=true";
|
||||
url += "&ajax_request=true";
|
||||
|
||||
/*Remove the hidden dialogs if there are*/
|
||||
if ($('#edit_index_dialog').length != 0) {
|
||||
@ -211,48 +219,36 @@ $(document).ready(function() {
|
||||
var $div = $('<div id="edit_index_dialog"></div>');
|
||||
|
||||
/**
|
||||
* @var button_options Object that stores the options passed to jQueryUI
|
||||
* dialog
|
||||
* @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();}
|
||||
button_options[PMA_messages['strCancel']] = function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
var $msgbox = PMA_ajaxShowMessage();
|
||||
|
||||
$.get( "tbl_indexes.php" , url , function(data) {
|
||||
$.get("tbl_indexes.php", 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['strEdit'],
|
||||
height: 230,
|
||||
width: 900,
|
||||
open: PMA_verifyColumnsProperties,
|
||||
modal: true,
|
||||
buttons : button_options_error
|
||||
})// end dialog options
|
||||
if (data.error) {
|
||||
PMA_ajaxShowMessage(data.error);
|
||||
} else {
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
$div
|
||||
.append(data)
|
||||
.dialog({
|
||||
title: PMA_messages['strEdit'],
|
||||
height: 600,
|
||||
title: title,
|
||||
width: 900,
|
||||
open: PMA_verifyColumnsProperties,
|
||||
modal: true,
|
||||
buttons : button_options
|
||||
})
|
||||
//Remove the top menu container from the dialog
|
||||
.find("#topmenucontainer").hide()
|
||||
; // end dialog options
|
||||
buttons: button_options,
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
checkIndexType();
|
||||
checkIndexName("index_frm");
|
||||
}
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
}) // end $.get()
|
||||
});
|
||||
|
||||
|
||||
@ -123,9 +123,10 @@ if (isset($_REQUEST['do_save_data'])) {
|
||||
|
||||
// Displays headers (if needed)
|
||||
$GLOBALS['js_include'][] = 'indexes.js';
|
||||
|
||||
require_once './libraries/tbl_info.inc.php';
|
||||
require_once './libraries/tbl_links.inc.php';
|
||||
if ( $GLOBALS['is_ajax_request'] != true) {
|
||||
require_once './libraries/tbl_links.inc.php';
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) {
|
||||
// coming already from form
|
||||
|
||||
@ -706,7 +706,8 @@ if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
|
||||
echo sprintf(__('Create an index on %s columns'),
|
||||
'<input type="text" size="2" name="added_fields" value="1" />');
|
||||
?>
|
||||
<input type="submit" name="create_index" value="<?php echo __('Go'); ?>" />
|
||||
<input type="hidden" name="create_index" value="1" />
|
||||
<input class="add_index<?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' ajax' : '');?>" type="submit" value="<?php echo __('Go'); ?>" />
|
||||
</form>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user