[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_3_7-10382-g14c02c1

Marc Delisle lem9 at users.sourceforge.net
Sun Sep 26 13:23:09 CEST 2010


The branch, master has been updated
       via  14c02c1e67b1fbf019e4752fc50f8f4f2c612c2c (commit)
      from  8cf1e880f5972e09134fc6dedfb2373ae004bfe6 (commit)


- Log -----------------------------------------------------------------
commit 14c02c1e67b1fbf019e4752fc50f8f4f2c612c2c
Author: Marc Delisle <marc at infomarc.info>
Date:   Sun Sep 26 07:22:58 2010 -0400

    to avoid undefined attribute errors, give different ids to the create table form and add fields form; then use the .live() method directly after a selector as recommended

-----------------------------------------------------------------------

Summary of changes:
 js/functions.js                  |  142 +++++++++++++++++++++-----------------
 libraries/tbl_properties.inc.php |    2 +-
 2 files changed, 80 insertions(+), 64 deletions(-)

diff --git a/js/functions.js b/js/functions.js
index 292e544..f327884 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -2035,17 +2035,15 @@ $(document).ready(function() {
     });
 
     /**
-     * Attach event handler for submission of create table form
+     * Attach event handler for submission of create table form (save)
      *
      * @uses    PMA_ajaxShowMessage()
      * @uses    $.PMA_sort_table()
      * @uses    window.parent.refreshNavigation()
      *
-     * The create_table_form whose action is tbl_create.php is the
-     * one which is ajaxified; in this form the action could be 
-     * tbl_addfield.php but it's not ajaxified yet.
      */
-    $("#create_table_form").attr('action').is('tbl_create.php').find("input[name=submit_num_fields], input[name=do_save_data]").live('click', function(event) {
+    // .live() must be called after a selector, see http://api.jquery.com/live
+    $("#create_table_form input[name=do_save_data]").live('click', function(event) {
         event.preventDefault();
 
         /**
@@ -2055,65 +2053,83 @@ $(document).ready(function() {
 
         PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
         $(the_form).append('<input type="hidden" name="ajax_request" value="true" />');
+        //User wants to submit the form
+        $.post($(the_form).attr('action'), $(the_form).serialize() + "&do_save_data=" + $(this).val(), function(data) {
+            if(data.success == true) {
+                PMA_ajaxShowMessage(data.message);
+                $("#create_table_dialog").dialog("close").remove();
+
+                /**
+                 * @var tables_table    Object referring to the <tbody> element that holds the list of tables
+                 */
+                var tables_table = $("#tablesForm").find("tbody").not("#tbl_summary_row");
+
+                /**
+                 * @var curr_last_row   Object referring to the last <tr> element in {@link tables_table}
+                 */
+                var curr_last_row = $(tables_table).find('tr:last');
+                /**
+                 * @var curr_last_row_index_string   String containing the index of {@link curr_last_row}
+                 */
+                var curr_last_row_index_string = $(curr_last_row).find('input:checkbox').attr('id').match(/\d+/)[0];
+                /**
+                 * @var curr_last_row_index Index of {@link curr_last_row}
+                 */
+                var curr_last_row_index = parseFloat(curr_last_row_index_string);
+                /**
+                 * @var new_last_row_index   Index of the new row to be appended to {@link tables_table}
+                 */
+                var new_last_row_index = curr_last_row_index + 1;
+                /**
+                 * @var new_last_row_id String containing the id of the row to be appended to {@link tables_table}
+                 */
+                var new_last_row_id = 'checkbox_tbl_' + new_last_row_index;
+
+                //append to table
+                $(data.new_table_string)
+                .find('input:checkbox')
+                .val(new_last_row_id)
+                .end()
+                .appendTo(tables_table);
+
+                //Sort the table
+                $(tables_table).PMA_sort_table('th');
+
+                //Refresh navigation frame as a new table has been added
+                window.parent.refreshNavigation();
+            }
+            else {
+                PMA_ajaxShowMessage(data.error);
+            }
+        }) // end $.post()
+    }) // end create table form (save) 
 
-        if($(this).attr('name') == 'submit_num_fields') {
-            //User wants to add more fields to the table
-            $.post($(the_form).attr('action'), $(the_form).serialize() + "&submit_num_fields=" + $(this).val(), function(data) {
-                $("#create_table_dialog").html(data);
-            }) //end $.post()
-        }
-        else if($(this).attr('name') == 'do_save_data') {
-            //User wants to submit the form
-            $.post($(the_form).attr('action'), $(the_form).serialize() + "&do_save_data=" + $(this).val(), function(data) {
-                if(data.success == true) {
-                    PMA_ajaxShowMessage(data.message);
-                    $("#create_table_dialog").dialog("close").remove();
-
-                    /**
-                     * @var tables_table    Object referring to the <tbody> element that holds the list of tables
-                     */
-                    var tables_table = $("#tablesForm").find("tbody").not("#tbl_summary_row");
-
-                    /**
-                     * @var curr_last_row   Object referring to the last <tr> element in {@link tables_table}
-                     */
-                    var curr_last_row = $(tables_table).find('tr:last');
-                    /**
-                     * @var curr_last_row_index_string   String containing the index of {@link curr_last_row}
-                     */
-                    var curr_last_row_index_string = $(curr_last_row).find('input:checkbox').attr('id').match(/\d+/)[0];
-                    /**
-                     * @var curr_last_row_index Index of {@link curr_last_row}
-                     */
-                    var curr_last_row_index = parseFloat(curr_last_row_index_string);
-                    /**
-                     * @var new_last_row_index   Index of the new row to be appended to {@link tables_table}
-                     */
-                    var new_last_row_index = curr_last_row_index + 1;
-                    /**
-                     * @var new_last_row_id String containing the id of the row to be appended to {@link tables_table}
-                     */
-                    var new_last_row_id = 'checkbox_tbl_' + new_last_row_index;
-
-                    //append to table
-                    $(data.new_table_string)
-                    .find('input:checkbox')
-                    .val(new_last_row_id)
-                    .end()
-                    .appendTo(tables_table);
+    /**
+     * Attach event handler for create table form (add fields)
+     *
+     * @uses    PMA_ajaxShowMessage()
+     * @uses    $.PMA_sort_table()
+     * @uses    window.parent.refreshNavigation()
+     *
+     */
+    // .live() must be called after a selector, see http://api.jquery.com/live
+    $("#create_table_form input[name=submit_num_fields]").live('click', function(event) {
+        event.preventDefault();
 
-                    //Sort the table
-                    $(tables_table).PMA_sort_table('th');
+        /**
+         *  @var    the_form    object referring to the create table form
+         */
+        var the_form = $("#create_table_form");
 
-                    //Refresh navigation frame as a new table has been added
-                    window.parent.refreshNavigation();
-                }
-                else {
-                    PMA_ajaxShowMessage(data.error);
-                }
-            }) // end $.post()
-        } // end elseif()
-    }) // end create table form submit button actions
+        PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
+        $(the_form).append('<input type="hidden" name="ajax_request" value="true" />');
+
+        //User wants to add more fields to the table
+        $.post($(the_form).attr('action'), $(the_form).serialize() + "&submit_num_fields=" + $(this).val(), function(data) {
+            $("#create_table_dialog").html(data);
+        }) //end $.post()
+
+    }) // end create table form (add fields) 
 
 }, 'top.frame_content'); //end $(document).ready for 'Create Table'
 
diff --git a/libraries/tbl_properties.inc.php b/libraries/tbl_properties.inc.php
index c093635..0127ae2 100644
--- a/libraries/tbl_properties.inc.php
+++ b/libraries/tbl_properties.inc.php
@@ -610,7 +610,7 @@ document.onkeydown = onKeyDownArrowsHandler;
 }
 ?>
 
-<form id="create_table_form" method="post" action="<?php echo $action; ?>">
+<form id="<?php echo ($action == 'tbl_create.php' ? 'create_table' : 'append_fields'); ?>_form" method="post" action="<?php echo $action; ?>">
 <?php
 echo PMA_generate_common_hidden_inputs($_form_params);
 unset($_form_params);


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list