Merge Polish update from QA_3_3.
[phpmyadmin/dkf.git] / js / tbl_structure.js
blob693442e7b6164ade522c0b2d61750e85d3d767df
1 /**
2 * @fileoverview functions used on the table structure page
3 * @name Table Structure
5 * @requires jQuery
6 * @requires jQueryUI
7 * @required js/functions.js
8 */
10 /**
11 * AJAX scripts for tbl_structure.php
13 * Actions ajaxified here:
14 * Drop Column
15 * Add Primary Key
16 * Drop Primary Key/Index
19 $(document).ready(function() {
21 /**
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();
30 /**
31 * @var curr_table_name String containing the name of the current table
33 var curr_table_name = window.parent.table;
34 /**
35 * @var curr_row Object reference to the currently selected row (i.e. field in the table)
37 var curr_row = $(this).parents('tr');
38 /**
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();
42 /**
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();
56 else {
57 PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
59 }) // end $.get()
60 }); // end $.PMA_confirm()
61 }) ; //end of Drop Column Anchor action
63 /**
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();
72 /**
73 * @var curr_table_name String containing the name of the current table
75 var curr_table_name = window.parent.table;
76 /**
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();
80 /**
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);
92 $(this).remove();
94 else {
95 PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
97 }) // end $.get()
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();
126 else {
127 PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
129 }) // end $.get()
130 }) // end $.PMA_confirm()
131 }) //end Drop Primary Key/Index
133 }) // end $(document).ready()