Bug #3166356 Search result panel duplicates the elements in Chrome
[phpmyadmin/crack.git] / js / tbl_structure.js
blob40397c1d65806993e612a7e6d3cf3fc453972739
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * @fileoverview    functions used on the table structure page
4  * @name            Table Structure
5  *
6  * @requires    jQuery
7  * @requires    jQueryUI
8  * @required    js/functions.js
9  */
11 /**
12  * AJAX scripts for tbl_structure.php
13  *
14  * Actions ajaxified here:
15  * Drop Column
16  * Add Primary Key
17  * Drop Primary Key/Index
18  *
19  */
20 $(document).ready(function() {
21     
22     /**
23      * Attach Event Handler for 'Drop Column'
24      *
25      * @uses    $.PMA_confirm()
26      * @uses    PMA_ajaxShowMessage()
27      */
28     $(".drop_column_anchor").live('click', function(event) {
29         event.preventDefault();
31         /**
32          * @var curr_table_name String containing the name of the current table
33          */
34         var curr_table_name = window.parent.table;
35         /**
36          * @var curr_row    Object reference to the currently selected row (i.e. field in the table)
37          */
38         var curr_row = $(this).parents('tr');
39         /**
40          * @var curr_column_name    String containing name of the field referred to by {@link curr_row}
41          */
42         var curr_column_name = $(curr_row).children('th').children('label').text();
43         /**
44          * @var question    String containing the question to be asked for confirmation
45          */
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();
56                 }
57                 else {
58                     PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
59                 }
60             }) // end $.get()
61         }); // end $.PMA_confirm()
62     }) ; //end of Drop Column Anchor action
64     /**
65      * Ajax Event handler for 'Add Primary Key'
66      *
67      * @uses    $.PMA_confirm()
68      * @uses    PMA_ajaxShowMessage()
69      */
70     $(".action_primary a").live('click', function(event) {
71         event.preventDefault();
73         /**
74          * @var curr_table_name String containing the name of the current table
75          */
76         var curr_table_name = window.parent.table;
77         /**
78          * @var curr_column_name    String containing name of the field referred to by {@link curr_row}
79          */
80         var curr_column_name = $(this).parents('tr').children('th').children('label').text();
81         /**
82          * @var question    String containing the question to be asked for confirmation
83          */
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);
93                     $(this).remove();
94                     if (typeof data.reload != 'undefined') {
95                         window.parent.frame_content.location.reload();
96                     }
97                 }
98                 else {
99                     PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
100                 }
101             }) // end $.get()
102         }) // end $.PMA_confirm()
103     })//end Add Primary Key
105     /**
106      * Ajax Event handler for 'Drop Primary Key/Index'
107      *
108      * @uses    $.PMA_confirm()
109      * @uses    PMA_ajaxShowMessage()
110      */
111     $('.drop_primary_key_index_anchor').live('click', function(event) {
112         event.preventDefault();
114         /**
115          * @var curr_row    Object containing reference to the current field's row
116          */
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();
129                 }
130                 else {
131                     PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error);
132                 }
133             }) // end $.get()
134         }) // end $.PMA_confirm()
135     }) //end Drop Primary Key/Index
136     
137 }) // end $(document).ready()