1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * @fileoverview functions used on the table structure page
4 * @name Table Structure
8 * @required js/functions.js
12 * AJAX scripts for tbl_structure.php
14 * Actions ajaxified here:
17 * Drop Primary Key/Index
20 $(document).ready(function() {
23 * Attach Event Handler for 'Drop Column'
25 * @uses $.PMA_confirm()
26 * @uses PMA_ajaxShowMessage()
28 $(".drop_column_anchor").live('click', function(event) {
29 event.preventDefault();
32 * @var curr_table_name String containing the name of the current table
34 var curr_table_name = window.parent.table;
36 * @var curr_row Object reference to the currently selected row (i.e. field in the table)
38 var curr_row = $(this).parents('tr');
40 * @var curr_column_name String containing name of the field referred to by {@link curr_row}
42 var curr_column_name = $(curr_row).children('th').children('label').text();
44 * @var question String containing the question to be asked for confirmation
46 var question = PMA_messages['strDoYouReally'] + ' :\n ALTER TABLE `' + curr_table_name + '` DROP `' + curr_column_name + '`';
48 $(this).PMA_confirm(question, $(this).attr('href'), function(url) {
50 PMA_ajaxShowMessage(PMA_messages['strDroppingColumn']);
52 $.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) {
53 if(data.success == true) {
54 PMA_ajaxShowMessage(data.message);
55 $(curr_row).hide("medium").remove();
58 PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
61 }); // end $.PMA_confirm()
62 }) ; //end of Drop Column Anchor action
65 * Ajax Event handler for 'Add Primary Key'
67 * @uses $.PMA_confirm()
68 * @uses PMA_ajaxShowMessage()
70 $(".action_primary a").live('click', function(event) {
71 event.preventDefault();
74 * @var curr_table_name String containing the name of the current table
76 var curr_table_name = window.parent.table;
78 * @var curr_column_name String containing name of the field referred to by {@link curr_row}
80 var curr_column_name = $(this).parents('tr').children('th').children('label').text();
82 * @var question String containing the question to be asked for confirmation
84 var question = PMA_messages['strDoYouReally'] + ' :\n ALTER TABLE `' + curr_table_name + '` ADD PRIMARY KEY(`' + curr_column_name + '`)';
86 $(this).PMA_confirm(question, $(this).attr('href'), function(url) {
88 PMA_ajaxShowMessage(PMA_messages['strAddingPrimaryKey']);
90 $.get(url, {'is_js_confirmed' : 1, 'ajax_request' : true}, function(data) {
91 if(data.success == true) {
92 PMA_ajaxShowMessage(data.message);
94 if (typeof data.reload != 'undefined') {
95 window.parent.frame_content.location.reload();
99 PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
102 }) // end $.PMA_confirm()
103 })//end Add Primary Key
106 * Ajax Event handler for 'Drop Primary Key/Index'
108 * @uses $.PMA_confirm()
109 * @uses PMA_ajaxShowMessage()
111 $('.drop_primary_key_index_anchor').live('click', function(event) {
112 event.preventDefault();
115 * @var curr_row Object containing reference to the current field's row
117 var curr_row = $(this).parents('tr');
119 var question = $(curr_row).children('.drop_primary_key_index_msg').val();
121 $(this).PMA_confirm(question, $(this).attr('href'), function(url) {
123 PMA_ajaxShowMessage(PMA_messages['strDroppingPrimaryKeyIndex']);
125 $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) {
126 if(data.success == true) {
127 PMA_ajaxShowMessage(data.message);
128 $(curr_row).hide("medium").remove();
131 PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
134 }) // end $.PMA_confirm()
135 }) //end Drop Primary Key/Index
137 }) // end $(document).ready()