2 * @fileoverview functions used on the table structure page
3 * @name Table Structure
7 * @required js/functions.js
11 * AJAX scripts for tbl_structure.php
13 * Actions ajaxified here:
16 * Drop Primary Key/Index
19 $(document
).ready(function() {
22 * Attach Event Handler for 'Drop Column'
24 * @uses $.PMA_confirm()
25 * @uses PMA_ajaxShowMessage()
27 $(".drop_column_anchor").live('click', function(event
) {
28 event
.preventDefault();
31 * @var curr_table_name String containing the name of the current table
33 var curr_table_name
= window
.parent
.table
;
35 * @var curr_row Object reference to the currently selected row (i.e. field in the table)
37 var curr_row
= $(this).parents('tr');
39 * @var curr_column_name String containing name of the field referred to by {@link curr_row}
41 var curr_column_name
= $(curr_row
).children('th').children('label').text();
43 * @var question String containing the question to be asked for confirmation
45 var question
= PMA_messages
['strDoYouReally'] + ' :\n ALTER TABLE `' + curr_table_name
+ '` DROP `' + curr_column_name
+ '`';
47 $(this).PMA_confirm(question
, $(this).attr('href'), function(url
) {
49 PMA_ajaxShowMessage(PMA_messages
['strDroppingColumn']);
51 $.get(url
, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data
) {
52 if(data
.success
== true) {
53 PMA_ajaxShowMessage(data
.message
);
54 $(curr_row
).hide("medium").remove();
57 PMA_ajaxShowMessage(PMA_messages
['strErrorProcessingRequest'] + " : " + data
.error
);
60 }); // end $.PMA_confirm()
61 }) ; //end of Drop Column Anchor action
64 * Ajax Event handler for 'Add Primary Key'
66 * @uses $.PMA_confirm()
67 * @uses PMA_ajaxShowMessage()
69 $(".action_primary a").live('click', function(event
) {
70 event
.preventDefault();
73 * @var curr_table_name String containing the name of the current table
75 var curr_table_name
= window
.parent
.table
;
77 * @var curr_column_name String containing name of the field referred to by {@link curr_row}
79 var curr_column_name
= $(this).parents('tr').children('th').children('label').text();
81 * @var question String containing the question to be asked for confirmation
83 var question
= PMA_messages
['strDoYouReally'] + ' :\n ALTER TABLE `' + curr_table_name
+ '` ADD PRIMARY KEY(`' + curr_column_name
+ '`)';
85 $(this).PMA_confirm(question
, $(this).attr('href'), function(url
) {
87 PMA_ajaxShowMessage(PMA_messages
['strAddingPrimaryKey']);
89 $.get(url
, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data
) {
90 if(data
.success
== true) {
91 PMA_ajaxShowMessage(data
.message
);
95 PMA_ajaxShowMessage(PMA_messages
['strErrorProcessingRequest'] + " : " + data
.error
);
98 }) // end $.PMA_confirm()
99 })//end Add Primary Key
102 * Ajax Event handler for 'Drop Primary Key/Index'
104 * @uses $.PMA_confirm()
105 * @uses PMA_ajaxShowMessage()
107 $('.drop_primary_key_index_anchor').live('click', function(event
) {
108 event
.preventDefault();
111 * @var curr_row Object containing reference to the current field's row
113 var curr_row
= $(this).parents('tr');
115 var question
= $(curr_row
).children('.drop_primary_key_index_msg').val();
117 $(this).PMA_confirm(question
, $(this).attr('href'), function(url
) {
119 PMA_ajaxShowMessage(PMA_messages
['strDroppingPrimaryKeyIndex']);
121 $.get(url
, {'is_js_confirmed': 1, 'ajax_request': true}, function(data
) {
122 if(data
.success
== true) {
123 PMA_ajaxShowMessage(data
.message
);
124 $(curr_row
).hide("medium").remove();
127 PMA_ajaxShowMessage(PMA_messages
['strErrorProcessingRequest'] + " : " + data
.error
);
130 }) // end $.PMA_confirm()
131 }) //end Drop Primary Key/Index
133 }) // end $(document).ready()