diff --git a/js/db_operations.js b/js/db_operations.js index 9cc55810fd..2adbc02cad 100644 --- a/js/db_operations.js +++ b/js/db_operations.js @@ -133,8 +133,7 @@ $(document).ready(function() { PMA_prepareForAjaxRequest($form); PMA_ajaxShowMessage(PMA_messages['strChangingCharset']); - - $.get($form.attr('action'), $form.serialize() + "&submitcollation=" + $form.find("input[name=submitcollation]").attr('value'), function(data) { + $.get($form.attr('action'), $form.serialize() + "&submitcollation=" + $form.find("input[name=submitcollation]").val(), function(data) { if(data.success == true) { PMA_ajaxShowMessage(data.message); } diff --git a/js/db_structure.js b/js/db_structure.js index 5e205ed2af..827c0df0f9 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -223,8 +223,8 @@ $(document).ready(function() { */ var $form = $("#insertForm"); /**Get the submit type and the after insert type in the form*/ - var selected_submit_type = $("#insertForm").find("#actions_panel .control_at_footer option:selected").attr('value'); - var selected_after_insert = $("#insertForm").find("#actions_panel select[name=after_insert] option:selected").attr('value'); + var selected_submit_type = $("#insertForm").find("#actions_panel .control_at_footer option:selected").val(); + var selected_after_insert = $("#insertForm").find("#actions_panel select[name=after_insert] option:selected").val(); $("#result_query").remove(); PMA_prepareForAjaxRequest($form); //User wants to submit the form @@ -258,17 +258,17 @@ $(document).ready(function() { * in the drop table confirmation form */ $(".fkc_switch").click(function(event){ - if ($("#fkc_checkbox").attr('checked') == 'checked') { - $("#fkc_checkbox").removeAttr('checked'); + if ($("#fkc_checkbox").prop('checked')) { + $("#fkc_checkbox").removeProp('checked'); $("#fkc_status").html(PMA_messages['strForeignKeyCheckDisabled']); return; } - $("#fkc_checkbox").attr('checked','checked'); + $("#fkc_checkbox").prop('checked', true); $("#fkc_status").html(PMA_messages['strForeignKeyCheckEnabled']); }); $('#fkc_checkbox').change(function () { - if ($(this).attr("checked")) { + if ($(this).prop("checked")) { $("#fkc_status").html(PMA_messages['strForeignKeyCheckEnabled']); return; } diff --git a/js/export.js b/js/export.js index a356d4526c..2982e1ef14 100644 --- a/js/export.js +++ b/js/export.js @@ -13,7 +13,7 @@ $(".format_specific_options").each(function() { $(this).hide(); }); - var selected_plugin_name = $("#plugins option:selected").attr("value"); + var selected_plugin_name = $("#plugins option:selected").val(); $("#" + selected_plugin_name + "_options").show(); }); }); @@ -23,23 +23,23 @@ */ $(document).ready(function() { $("input[type='radio'][name$='sql_structure_or_data']").change(function() { - var show = $("input[type='radio'][name$='sql_structure_or_data']:checked").attr("value"); + var show = $("input[type='radio'][name$='sql_structure_or_data']:checked").val(); if(show == 'data') { // disable the SQL comment options $("#checkbox_sql_dates").parent().fadeTo('fast', 0.4); - $("#checkbox_sql_dates").attr('disabled', 'disabled'); + $("#checkbox_sql_dates").prop('disabled', true); $("#checkbox_sql_relation").parent().fadeTo('fast', 0.4); - $("#checkbox_sql_relation").attr('disabled', 'disabled'); + $("#checkbox_sql_relation").prop('disabled', true); $("#checkbox_sql_mime").parent().fadeTo('fast', 0.4); - $("#checkbox_sql_mime").attr('disabled', 'disabled'); + $("#checkbox_sql_mime").prop('disabled', true); } else { // enable the SQL comment options $("#checkbox_sql_dates").parent().fadeTo('fast', 1); - $("#checkbox_sql_dates").removeAttr('disabled'); + $("#checkbox_sql_dates").removeProp('disabled'); $("#checkbox_sql_relation").parent().fadeTo('fast', 1); - $("#checkbox_sql_relation").removeAttr('disabled'); + $("#checkbox_sql_relation").removeProp('disabled'); $("#checkbox_sql_mime").parent().fadeTo('fast', 1); - $("#checkbox_sql_mime").removeAttr('disabled'); + $("#checkbox_sql_mime").removeProp('disabled'); } }); }); @@ -55,7 +55,7 @@ function toggle_structure_data_opts(pluginName) var radioFormName = pluginName + "_structure_or_data"; var dataDiv = "#" + pluginName + "_data"; var structureDiv = "#" + pluginName + "_structure"; - var show = $("input[type='radio'][name='" + radioFormName + "']:checked").attr("value"); + var show = $("input[type='radio'][name='" + radioFormName + "']:checked").val(); if(show == 'data') { $(dataDiv).slideDown('slow'); $(structureDiv).slideUp('slow'); @@ -94,12 +94,12 @@ function toggle_save_to_file() { if($("#radio_dump_asfile:checked").length == 0) { $("#ul_save_asfile > li").fadeTo('fast', 0.4); - $("#ul_save_asfile > li > input").attr('disabled', 'disabled'); - $("#ul_save_asfile > li> select").attr('disabled', 'disabled'); + $("#ul_save_asfile > li > input").prop('disabled', true); + $("#ul_save_asfile > li> select").prop('disabled', true); } else { $("#ul_save_asfile > li").fadeTo('fast', 1); - $("#ul_save_asfile > li > input").removeAttr('disabled'); - $("#ul_save_asfile > li> select").removeAttr('disabled'); + $("#ul_save_asfile > li > input").removeProp('disabled'); + $("#ul_save_asfile > li> select").removeProp('disabled'); } } @@ -118,15 +118,15 @@ function toggle_sql_include_comments() $("#checkbox_sql_include_comments").change(function() { if($("#checkbox_sql_include_comments:checked").length == 0) { $("#ul_include_comments > li").fadeTo('fast', 0.4); - $("#ul_include_comments > li > input").attr('disabled', 'disabled'); + $("#ul_include_comments > li > input").prop('disabled', true); } else { // If structure is not being exported, the comment options for structure should not be enabled if($("#radio_sql_structure_or_data_data:checked").length == 1) { $("#text_sql_header_comment").parent("li").fadeTo('fast', 1); - $("#text_sql_header_comment").removeAttr('disabled'); + $("#text_sql_header_comment").removeProp('disabled'); } else { $("#ul_include_comments > li").fadeTo('fast', 1); - $("#ul_include_comments > li > input").removeAttr('disabled'); + $("#ul_include_comments > li > input").removeProp('disabled'); } } }); @@ -138,11 +138,11 @@ function toggle_sql_include_comments() $(document).ready(function() { $("#checkbox_sql_create_table_statements").change(function() { if($("#checkbox_sql_create_table_statements:checked").length == 0) { - $("#checkbox_sql_if_not_exists").removeAttr('checked'); - $("#checkbox_sql_auto_increment").removeAttr('checked'); + $("#checkbox_sql_if_not_exists").removeProp('checked'); + $("#checkbox_sql_auto_increment").removeProp('checked'); } else { - $("#checkbox_sql_if_not_exists").attr('checked', 'checked'); - $("#checkbox_sql_auto_increment").attr('checked', 'checked'); + $("#checkbox_sql_if_not_exists").prop('checked', true); + $("#checkbox_sql_auto_increment").prop('checked', true); } }); }); @@ -152,13 +152,13 @@ $(document).ready(function() { */ $(document).ready(function() { $("#plugins").change(function() { - var active_plugin = $("#plugins option:selected").attr("value"); - var force_file = $("#force_file_" + active_plugin).attr("value"); + var active_plugin = $("#plugins option:selected").val(); + var force_file = $("#force_file_" + active_plugin).val(); if(force_file == "true") { - $("#radio_view_as_text").attr('disabled', 'disabled'); + $("#radio_view_as_text").prop('disabled', true); $("#radio_view_as_text").parent().fadeTo('fast', 0.4); } else { - $("#radio_view_as_text").removeAttr('disabled'); + $("#radio_view_as_text").removeProp('disabled'); $("#radio_view_as_text").parent().fadeTo('fast', 1); } }); @@ -169,13 +169,13 @@ $(document).ready(function() { */ function toggle_quick_or_custom() { - if($("$(this):checked").attr("value") == "custom") { + if($("$(this):checked").val() == "custom") { $("#databases_and_tables").show(); $("#rows").show(); $("#output").show(); $("#format_specific_opts").show(); $("#output_quick_export").hide(); - var selected_plugin_name = $("#plugins option:selected").attr("value"); + var selected_plugin_name = $("#plugins option:selected").val(); $("#" + selected_plugin_name + "_options").show(); } else { $("#databases_and_tables").hide(); @@ -197,7 +197,7 @@ $(document).ready(function() { * Javascript-disabled browsers */ $(document).ready(function() { - if($("input[type='hidden'][name='export_method']").attr("value") != "custom-no-form") { + if($("input[type='hidden'][name='export_method']").val() != "custom-no-form") { $("#quick_or_custom").show(); } $("#scroll_to_options_msg").hide(); @@ -205,7 +205,7 @@ $(document).ready(function() { $(".format_specific_options").css({ "border": 0, "margin": 0, "padding": 0}); $(".format_specific_options h3").remove(); toggle_quick_or_custom(); - toggle_structure_data_opts($("select[id='plugins']").attr("value")); + toggle_structure_data_opts($("select[id='plugins']").val()); toggle_sql_include_comments(); }); @@ -214,16 +214,16 @@ $(document).ready(function() { */ $(document).ready(function() { $("input[type='radio'][name='allrows']").change(function() { - if($("input[type='radio'][name='allrows']:checked").attr("value") == "1") { + if($("input[type='radio'][name='allrows']:checked").val() == "1") { $("label[for='limit_to']").fadeTo('fast', 0.4); $("label[for='limit_from']").fadeTo('fast', 0.4); - $("input[type='text'][name='limit_to']").attr('disabled', 'disabled'); - $("input[type='text'][name='limit_from']").attr('disabled', 'disabled'); + $("input[type='text'][name='limit_to']").prop('disabled', true); + $("input[type='text'][name='limit_from']").prop('disabled', true); } else { $("label[for='limit_to']").fadeTo('fast', 1); $("label[for='limit_from']").fadeTo('fast', 1); - $("input[type='text'][name='limit_to']").removeAttr('disabled'); - $("input[type='text'][name='limit_from']").removeAttr('disabled'); + $("input[type='text'][name='limit_to']").removeProp('disabled'); + $("input[type='text'][name='limit_from']").removeProp('disabled'); } }); }); diff --git a/js/functions.js b/js/functions.js index d9c50219a3..8c3cf665e9 100644 --- a/js/functions.js +++ b/js/functions.js @@ -541,10 +541,10 @@ $(document).ready(function() { var $checkbox = $tr.find(':checkbox'); if ($checkbox.length) { // checkbox in a row, add or remove class depending on checkbox state - var checked = $checkbox.attr('checked'); + var checked = $checkbox.prop('checked'); if (!$(e.target).is(':checkbox, label')) { checked = !checked; - $checkbox.attr('checked', checked); + $checkbox.prop('checked', checked); } if (checked) { $tr.addClass('marked'); @@ -579,7 +579,7 @@ $(document).ready(function() { .slice(start, end + 1) .removeClass('marked') .find(':checkbox') - .attr('checked', false); + .prop('checked', false); } // handle new shift click @@ -595,7 +595,7 @@ $(document).ready(function() { .slice(start, end + 1) .addClass('marked') .find(':checkbox') - .attr('checked', true); + .prop('checked', true); // remember the last shift clicked row last_shift_clicked_row = curr_row; @@ -655,7 +655,7 @@ var marked_row = new Array; function markAllRows( container_id ) { - $("#"+container_id).find("input:checkbox:enabled").attr('checked', 'checked') + $("#"+container_id).find("input:checkbox:enabled").prop('checked', true) .parents("tr").addClass("marked"); return true; } @@ -669,7 +669,7 @@ function markAllRows( container_id ) function unMarkAllRows( container_id ) { - $("#"+container_id).find("input:checkbox:enabled").removeAttr('checked') + $("#"+container_id).find("input:checkbox:enabled").removeProp('checked') .parents("tr").removeClass("marked"); return true; } @@ -685,10 +685,10 @@ function setCheckboxes( container_id, state ) { if (state) { - $("#"+container_id).find("input:checkbox").attr('checked', 'checked'); + $("#"+container_id).find("input:checkbox").prop('checked', true); } else { - $("#"+container_id).find("input:checkbox").removeAttr('checked'); + $("#"+container_id).find("input:checkbox").removeProp('checked'); } return true; @@ -705,7 +705,7 @@ function setCheckboxes( container_id, state ) */ function setSelectOptions(the_form, the_select, do_check) { - $("form[name='"+ the_form +"'] select[name='"+the_select+"']").find("option").attr('selected', do_check); + $("form[name='"+ the_form +"'] select[name='"+the_select+"']").find("option").prop('selected', do_check); return true; } // end of the 'setSelectOptions()' function @@ -832,8 +832,8 @@ function goToUrl(selObj, goToLocation) */ function refreshDragOption(e) { - var elm = $('#' + e); - if (elm.css('visibility') == 'visible') { + var $elm = $('#' + e); + if ($elm.css('visibility') == 'visible') { refreshLayout(); TableDragInit(); } @@ -844,7 +844,7 @@ function refreshDragOption(e) */ function refreshLayout() { - var elm = $('#pdflayout'); + var $elm = $('#pdflayout'); var orientation = $('#orientation_opt').val(); if ($('#paper_opt').length==1) { var paper = $('#paper_opt').val(); @@ -858,8 +858,8 @@ function refreshLayout() posa = 'y'; posb = 'x'; } - elm.css('width', pdfPaperSize(paper, posa) + 'px'); - elm.css('height', pdfPaperSize(paper, posb) + 'px'); + $elm.css('width', pdfPaperSize(paper, posa) + 'px'); + $elm.css('height', pdfPaperSize(paper, posb) + 'px'); } /** @@ -867,15 +867,15 @@ function refreshLayout() */ function ToggleDragDrop(e) { - var elm = $('#' + e); - if (elm.css('visibility') == 'hidden') { + var $elm = $('#' + e); + if ($elm.css('visibility') == 'hidden') { PDFinit(); /* Defined in pdf_pages.php */ - elm.css('visibility', 'visible'); - elm.css('display', 'block'); + $elm.css('visibility', 'visible'); + $elm.css('display', 'block'); $('#showwysiwyg').val('1'); } else { - elm.css('visibility', 'hidden'); - elm.css('display', 'none'); + $elm.css('visibility', 'hidden'); + $elm.css('display', 'none'); $('#showwysiwyg').val('0'); } } @@ -886,11 +886,11 @@ function ToggleDragDrop(e) */ function dragPlace(no, axis, value) { - var elm = $('#table_' + no); + var $elm = $('#table_' + no); if (axis == 'x') { - elm.css('left', value + 'px'); + $elm.css('left', value + 'px'); } else { - elm.css('top', value + 'px'); + $elm.css('top', value + 'px'); } } @@ -1110,39 +1110,38 @@ $(document).ready(function() { $("#export_type").change(function() { if ($("#export_type").val()=='svg') { - $("#show_grid_opt").attr("disabled","disabled"); - $("#orientation_opt").attr("disabled","disabled"); - $("#with_doc").attr("disabled","disabled"); - $("#show_table_dim_opt").removeAttr("disabled"); - $("#all_table_same_wide").removeAttr("disabled"); - $("#paper_opt").removeAttr("disabled","disabled"); - $("#show_color_opt").removeAttr("disabled","disabled"); + $("#show_grid_opt").prop("disabled",true); + $("#orientation_opt").prop("disabled",true); + $("#with_doc").prop("disabled",true); + $("#show_table_dim_opt").removeProp("disabled"); + $("#all_table_same_wide").removeProp("disabled"); + $("#paper_opt").removeProp("disabled"); + $("#show_color_opt").removeProp("disabled"); //$(this).css("background-color","yellow"); } else if ($("#export_type").val()=='dia') { - $("#show_grid_opt").attr("disabled","disabled"); - $("#with_doc").attr("disabled","disabled"); - $("#show_table_dim_opt").attr("disabled","disabled"); - $("#all_table_same_wide").attr("disabled","disabled"); - $("#paper_opt").removeAttr("disabled","disabled"); - $("#show_color_opt").removeAttr("disabled","disabled"); - $("#orientation_opt").removeAttr("disabled","disabled"); + $("#show_grid_opt").prop("disabled",true); + $("#with_doc").prop("disabled",true); + $("#show_table_dim_opt").prop("disabled",true); + $("#all_table_same_wide").prop("disabled",true); + $("#paper_opt").removeProp("disabled"); + $("#show_color_opt").removeProp("disabled"); + $("#orientation_opt").removeProp("disabled"); } else if ($("#export_type").val()=='eps') { - $("#show_grid_opt").attr("disabled","disabled"); - $("#orientation_opt").removeAttr("disabled"); - $("#with_doc").attr("disabled","disabled"); - $("#show_table_dim_opt").attr("disabled","disabled"); - $("#all_table_same_wide").attr("disabled","disabled"); - $("#paper_opt").attr("disabled","disabled"); - $("#show_color_opt").attr("disabled","disabled"); - + $("#show_grid_opt").prop("disabled",true); + $("#orientation_opt").removeProp("disabled"); + $("#with_doc").prop("disabled",true); + $("#show_table_dim_opt").prop("disabled",true); + $("#all_table_same_wide").prop("disabled",true); + $("#paper_opt").prop("disabled",true); + $("#show_color_opt").prop("disabled",true); } else if ($("#export_type").val()=='pdf') { - $("#show_grid_opt").removeAttr("disabled"); - $("#orientation_opt").removeAttr("disabled"); - $("#with_doc").removeAttr("disabled","disabled"); - $("#show_table_dim_opt").removeAttr("disabled","disabled"); - $("#all_table_same_wide").removeAttr("disabled","disabled"); - $("#paper_opt").removeAttr("disabled","disabled"); - $("#show_color_opt").removeAttr("disabled","disabled"); + $("#show_grid_opt").removeProp("disabled"); + $("#orientation_opt").removeProp("disabled"); + $("#with_doc").removeProp("disabled"); + $("#show_table_dim_opt").removeProp("disabled"); + $("#all_table_same_wide").removeProp("disabled"); + $("#paper_opt").removeProp("disabled"); + $("#show_color_opt").removeProp("disabled"); } else { // nothing } @@ -2193,7 +2192,7 @@ $(document).ready(function() { $("#copyTable.ajax input[name='submit_copy']").live('click', function(event) { event.preventDefault(); var $form = $("#copyTable"); - if ($form.find("input[name='switch_to_new']").attr('checked')) { + if ($form.find("input[name='switch_to_new']").prop('checked')) { $form.append(''); $form.removeClass('ajax'); $form.find("#ajax_request_hidden").remove(); @@ -2214,7 +2213,7 @@ $(document).ready(function() { $("#sqlqueryresults").html(data.sql_query); $("#result_query .notice").remove(); $("#result_query").prepend((data.message)); - $("#copyTable").find("select[name='target_db'] option").filterByValue(data.db).attr('selected', 'selected'); + $("#copyTable").find("select[name='target_db'] option").filterByValue(data.db).prop('selected', true); //Refresh navigation frame when the table is coppied if (window.parent && window.parent.frame_navigation) { @@ -2334,8 +2333,8 @@ $(document).ready(function() { .removeClass('odd even'); var $databases_count_object = $('#databases_count'); - var databases_count = parseInt($databases_count_object.text()); - $databases_count_object.text(++databases_count); + var databases_count = parseInt($databases_count_object.text()) + 1; + $databases_count_object.text(databases_count); //Refresh navigation frame as a new database has been added if (window.parent && window.parent.frame_navigation) { window.parent.frame_navigation.location.reload(); @@ -2373,9 +2372,9 @@ $(document).ready(function() { event.preventDefault(); /** - * @var the_form Object referring to the change password form + * @var $the_form Object referring to the change password form */ - var the_form = $("#change_password_form"); + var $the_form = $("#change_password_form"); /** * @var this_value String containing the value of the submit button. @@ -2385,9 +2384,9 @@ $(document).ready(function() { var this_value = $(this).val(); var $msgbox = PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); - $(the_form).append(''); + $the_form.append(''); - $.post($(the_form).attr('action'), $(the_form).serialize() + '&change_pw='+ this_value, function(data) { + $.post($the_form.attr('action'), $the_form.serialize() + '&change_pw='+ this_value, function(data) { if (data.success == true) { $("#floating_menubar").after(data.sql_query); $("#change_password_dialog").hide().remove(); @@ -2473,7 +2472,7 @@ function PMA_hideShowDefaultValue($default_type) $default_type.siblings('.default_value').hide(); if ($default_type.val() == 'NULL') { var $null_checkbox = $default_type.closest('tr').find('.allow_null'); - $null_checkbox.attr('checked', true); + $null_checkbox.prop('checked', true); } } } @@ -2483,7 +2482,7 @@ function PMA_hideShowDefaultValue($default_type) */ function PMA_validateDefaultValue($null_checkbox) { - if (! $null_checkbox.attr('checked')) { + if (! $null_checkbox.prop('checked')) { $default = $null_checkbox.closest('tr').find('.default_type'); if ($default.val() == 'NULL') { $default.val('NONE'); @@ -2600,8 +2599,8 @@ $(document).ready(function() { value_array.push("'" + val + "'"); }); // get the Length/Values text field where this value belongs - var values_id = $(this).find("input[type='hidden']").attr("value"); - $("input#" + values_id).attr("value", value_array.join(",")); + var values_id = $(this).find("input[type='hidden']").val(); + $("input#" + values_id).val(value_array.join(",")); $(this).dialog("close"); }; buttonOptions[PMA_messages['strClose']] = function () { @@ -2772,7 +2771,7 @@ function checkIndexName(form_id) // Index is a primary key if ($the_idx_type.find("option:selected").val() == 'PRIMARY') { $the_idx_name.val('PRIMARY'); - $the_idx_name.attr("disabled", true); + $the_idx_name.prop("disabled", true); } // Other cases @@ -2780,7 +2779,7 @@ function checkIndexName(form_id) if ($the_idx_name.val() == 'PRIMARY') { $the_idx_name.val(""); } - $the_idx_name.attr("disabled", false); + $the_idx_name.prop("disabled", false); } return true; @@ -2860,16 +2859,16 @@ function menuResize() // Calculate the total width used by all the shown tabs var total_len = more_shown ? submenu_w : 0; - for (var i = 0; i < $li.length-1; i++) { + var l = $li.length - 1; + for (var i = 0; i < l; i++) { total_len += $($li[i]).outerWidth(true); } // Now hide menu elements that don't fit into the menubar - var i = $li.length-1; var hidden = false; // Whether we have hidden any tabs - while (total_len >= wmax && --i >= 0) { // Process the tabs backwards + while (total_len >= wmax && --l >= 0) { // Process the tabs backwards hidden = true; - var el = $($li[i]); + var el = $($li[l]); var el_width = el.outerWidth(true); el.data('width', el_width); if (! more_shown) { @@ -2886,7 +2885,7 @@ function menuResize() // If we didn't hide any tabs, then there might be some space to show some if (! hidden) { // Show menu elements that do fit into the menubar - for (var i = 0; i < $li2.length; i++) { + for (var i = 0, l = $li2.length; i < l; i++) { total_len += $($li2[i]).data('width'); // item fits or (it is the last item // and it would fit if More got removed) @@ -3175,10 +3174,10 @@ $(document).ready(function() { var $checkbox = $('.vmarker').filter('.row_' + row_num + ':first').find(':checkbox'); if ($checkbox.length) { // checkbox in a row, add or remove class depending on checkbox state - var checked = $checkbox.attr('checked'); + var checked = $checkbox.prop('checked'); if (!$(e.target).is(':checkbox, label')) { checked = !checked; - $checkbox.attr('checked', checked); + $checkbox.prop('checked', checked); } // for all td of the same vertical row, toggle the marked class if (checked) { @@ -3446,7 +3445,7 @@ $(document).ready(function() { if ($.browser.msie || $.browser.safari) $(this).unbind('selectstart'); else if ($.browser.mozilla) $(this).css('MozUserSelect', 'inherit'); else if ($.browser.opera) $(this).unbind('mousedown'); - else $(this).removeAttr('unselectable', 'on'); + else $(this).removeAttr('unselectable'); }); } }; //end noSelect @@ -3510,23 +3509,25 @@ function PMA_createqTip($elements, content, options) * Return value of a cell in a table. */ function PMA_getCellValue(td) { - if ($(td).is('.null')) { + var $td = $(td); + if ($td.is('.null')) { return ''; - } else if (! $(td).is('.to_be_saved') && $(td).data('original_data')) { - return $(td).data('original_data'); + } else if (! $td.is('.to_be_saved') && $td.data('original_data')) { + return $td.data('original_data'); } else { - return $(td).text(); + return $td.text(); } } /* Loads a js file, an array may be passed as well */ loadJavascript=function(file) { + var $head = $('head'); if ($.isArray(file)) { - for(var i=0; i'); + for(var i=0, l=file.length; i'); } } else { - $('head').append(''); + $head.append(''); } }; diff --git a/js/gis_data_editor.js b/js/gis_data_editor.js index 2808fc407e..86cae9e870 100644 --- a/js/gis_data_editor.js +++ b/js/gis_data_editor.js @@ -25,7 +25,7 @@ function prepareJSVersion() { // Change the text on the submit button $("input[name='gis_data[save]']") - .attr('value', PMA_messages['strCopy']) + .val(PMA_messages['strCopy']) .insertAfter($('#gis_data_textarea')) .before('

'); @@ -44,7 +44,7 @@ function prepareJSVersion() { var classes = $button.attr('class'); $button .after('+ ' + $button.attr('value') + '') + + '">+ ' + $button.val() + '') .remove(); }); } @@ -276,11 +276,11 @@ $(document).ready(function() { var prefix = name.substr(0, name.length - 11); // Find the number of points var $noOfPointsInput = $("input[name='" + prefix + "[no_of_points]" + "']"); - var noOfPoints = parseInt($noOfPointsInput.attr('value')); + var noOfPoints = parseInt($noOfPointsInput.val()); // Add the new data point var html = addDataPoint(noOfPoints, prefix); $a.before(html); - $noOfPointsInput.attr('value', noOfPoints + 1); + $noOfPointsInput.val(noOfPoints + 1); }); /** @@ -296,7 +296,7 @@ $(document).ready(function() { // Find the number of lines var $noOfLinesInput = $("input[name='" + prefix + "[no_of_lines]" + "']"); - var noOfLines = parseInt($noOfLinesInput.attr('value')); + var noOfLines = parseInt($noOfLinesInput.val()); // Add the new linesting of inner ring based on the type var html = '
'; @@ -315,7 +315,7 @@ $(document).ready(function() { + PMA_messages['strAddPoint'] + '
'; $a.before(html); - $noOfLinesInput.attr('value', noOfLines + 1); + $noOfLinesInput.val(noOfLines + 1); }); /** @@ -328,7 +328,7 @@ $(document).ready(function() { var prefix = name.substr(0, name.length - 13); // Find the number of polygons var $noOfPolygonsInput = $("input[name='" + prefix + "[no_of_polygons]" + "']"); - var noOfPolygons = parseInt($noOfPolygonsInput.attr('value')); + var noOfPolygons = parseInt($noOfPolygonsInput.val()); // Add the new polygon var html = PMA_messages['strPolygon'] + (noOfPolygons + 1) + ':
'; @@ -344,7 +344,7 @@ $(document).ready(function() { + PMA_messages['strAddInnerRing'] + '

'; $a.before(html); - $noOfPolygonsInput.attr('value', noOfPolygons + 1); + $noOfPolygonsInput.val(noOfPolygons + 1); }); /** @@ -355,7 +355,7 @@ $(document).ready(function() { var prefix = 'gis_data[GEOMETRYCOLLECTION]'; // Find the number of geoms var $noOfGeomsInput = $("input[name='" + prefix + "[geom_count]" + "']"); - var noOfGeoms = parseInt($noOfGeomsInput.attr('value')); + var noOfGeoms = parseInt($noOfGeomsInput.val()); var html1 = PMA_messages['strGeometry'] + (noOfGeoms + 1) + ':
'; var $geomType = $("select[name='gis_data[" + (noOfGeoms - 1) + "][gis_type]']").clone(); @@ -368,6 +368,6 @@ $(document).ready(function() { + '

'; $a.before(html1); $geomType.insertBefore($a); $a.before(html2); - $noOfGeomsInput.attr('value', noOfGeoms + 1); + $noOfGeomsInput.val(noOfGeoms + 1); }); }); diff --git a/js/import.js b/js/import.js index f1ab31bfe0..ec5fc9b5da 100644 --- a/js/import.js +++ b/js/import.js @@ -14,7 +14,7 @@ function changePluginOpts() $(".format_specific_options").each(function() { $(this).hide(); }); - var selected_plugin_name = $("#plugins option:selected").attr("value"); + var selected_plugin_name = $("#plugins option:selected").val(); $("#" + selected_plugin_name + "_options").fadeIn('slow'); if(selected_plugin_name == "csv") { $("#import_notification").text(PMA_messages['strImportCSV']); @@ -38,8 +38,8 @@ function matchFile(fname) } // Only toggle if the format of the file can be imported if($("select[name='format'] option").filterByValue(fname_array[len - 1]).length == 1) { - $("#plugins option:selected").removeAttr("selected"); - $("select[name='format'] option").filterByValue(fname_array[len - 1]).attr('selected', 'selected'); + $("#plugins option:selected").removeProp("selected"); + $("select[name='format'] option").filterByValue(fname_array[len - 1]).prop('selected', true); changePluginOpts(); } } @@ -54,11 +54,11 @@ $(document).ready(function() { }); $("#input_import_file").change(function() { - matchFile($(this).attr("value")); + matchFile($(this).val()); }); $("#select_local_import_file").change(function() { - matchFile($(this).attr("value")); + matchFile($(this).val()); }); /* @@ -66,12 +66,12 @@ $(document).ready(function() { * form is clicked, the radio button beside it becomes selected and the other form becomes disabled. */ $("#input_import_file").focus(function() { - $("#radio_import_file").attr('checked', 'checked'); - $("#radio_local_import_file").removeAttr('checked'); + $("#radio_import_file").prop('checked', true); + $("#radio_local_import_file").removeProp('checked'); }); $("#select_local_import_file").focus(function() { - $("#radio_local_import_file").attr('checked', 'checked'); - $("#radio_import_file").removeAttr('checked'); + $("#radio_local_import_file").prop('checked', true); + $("#radio_import_file").removeProp('checked'); }); /** diff --git a/js/indexes.js b/js/indexes.js index 8099056913..af6c990729 100644 --- a/js/indexes.js +++ b/js/indexes.js @@ -36,7 +36,7 @@ function checkIndexType() $size_header.hide(); $size_inputs.each(function(){ $(this) - .attr('disabled', true) + .prop('disabled', true) .parent('td').hide(); }); @@ -46,7 +46,7 @@ function checkIndexType() $column_input = $(this); if (! initial) { $column_input - .attr('disabled', true) + .prop('disabled', true) .parent('td').hide(); } else { initial = false; @@ -60,14 +60,14 @@ function checkIndexType() $size_header.show(); $size_inputs.each(function() { $(this) - .attr('disabled', false) + .prop('disabled', false) .parent('td').show(); }); // Enable and show the columns of the index $column_inputs.each(function() { $(this) - .attr('disabled', false) + .prop('disabled', false) .parent('td').show(); }); diff --git a/js/makegrid.js b/js/makegrid.js index 8bd4aa95ac..1027dbf6bb 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -251,11 +251,11 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi var $firstRowCols = $(g.t).find('tr:first th.draggable:visible'); var $resizeHandles = $(g.cRsz).find('div').removeClass('condition'); $('.pma_table').find('thead th:first').removeClass('before-condition'); - for (var n = 0; n < $firstRowCols.length; n++) { + for (var n = 0, l = $firstRowCols.length; n < l; n++) { var $col = $($firstRowCols[n]); $($resizeHandles[n]).css('left', $col.position().left + $col.outerWidth(true)) .show(); - if ($($firstRowCols[n]).hasClass('condition')) { + if ($col.hasClass('condition')) { $($resizeHandles[n]).addClass('condition'); if (n > 0) { $($resizeHandles[n-1]).addClass('condition'); @@ -478,10 +478,10 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi .hide(); }); g.colVisib[n] = 0; - $(g.cList).find('.lDiv div:eq(' + n + ') input').removeAttr('checked'); + $(g.cList).find('.lDiv div:eq(' + n + ') input').removeProp('checked'); } else { // cannot hide, force the checkbox to stay checked - $(g.cList).find('.lDiv div:eq(' + n + ') input').attr('checked', 'checked'); + $(g.cList).find('.lDiv div:eq(' + n + ') input').prop('checked', true); return false; } } else { // column n is not visible @@ -491,7 +491,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi .show(); }); g.colVisib[n] = 1; - $(g.cList).find('.lDiv div:eq(' + n + ') input').attr('checked', 'checked'); + $(g.cList).find('.lDiv div:eq(' + n + ') input').prop('checked', true); } return true; }, @@ -600,7 +600,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi g.currentEditCell = cell; $(g.cEdit).find('.edit_box').focus(); - $(g.cEdit).find('*').removeAttr('disabled'); + $(g.cEdit).find('*').removeProp('disabled'); } } }, @@ -748,44 +748,44 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi var $checkbox = $editArea.find('.null_div input'); // check if current is NULL if ($td.is('.null')) { - $checkbox.attr('checked', true); + $checkbox.prop('checked', true); g.wasEditedCellNull = true; } // if the select/editor is changed un-check the 'checkbox_null__'. if ($td.is('.enum, .set')) { $editArea.find('select').live('change', function(e) { - $checkbox.attr('checked', false); + $checkbox.prop('checked', false); }); } else if ($td.is('.relation')) { $editArea.find('select').live('change', function(e) { - $checkbox.attr('checked', false); + $checkbox.prop('checked', false); }); $editArea.find('.browse_foreign').live('click', function(e) { - $checkbox.attr('checked', false); + $checkbox.prop('checked', false); }); } else { $(g.cEdit).find('.edit_box').live('keypress change', function(e) { - $checkbox.attr('checked', false); + $checkbox.prop('checked', false); }); $editArea.find('textarea').live('keydown', function(e) { - $checkbox.attr('checked', false); + $checkbox.prop('checked', false); }); } // if null checkbox is clicked empty the corresponding select/editor. $checkbox.click(function(e) { if ($td.is('.enum')) { - $editArea.find('select').attr('value', ''); + $editArea.find('select').val(''); } else if ($td.is('.set')) { $editArea.find('select').find('option').each(function() { var $option = $(this); - $option.attr('selected', false); + $option.prop('selected', false); }); } else if ($td.is('.relation')) { // if the dropdown is there to select the foreign value if ($editArea.find('select').length > 0) { - $editArea.find('select').attr('value', ''); + $editArea.find('select').val(''); } } else { $editArea.find('textarea').val(''); @@ -974,7 +974,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi showTimepicker: showTimeOption, onSelect: function(dateText, inst) { // remove null checkbox if it exists - $(g.cEdit).find('.null_div input[type=checkbox]').attr('checked', false); + $(g.cEdit).find('.null_div input[type=checkbox]').prop('checked', false); } }); @@ -1020,7 +1020,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi /** * @var relational_display string 'K' if relational key, 'D' if relational display column */ - var relational_display = $("#relational_display_K").attr('checked') ? 'K' : 'D'; + var relational_display = $("#relational_display_K").prop('checked') ? 'K' : 'D'; /** * @var transform_fields Array containing the name/value pairs for transformed fields */ @@ -1044,7 +1044,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi /** * @var where_clause Array containing where clause for updated fields */ - var full_where_clause = Array(); + var full_where_clause = []; /** * @var is_unique Boolean, whether the rows in this table is unique or not */ @@ -1052,9 +1052,9 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi /** * multi edit variables */ - var me_fields_name = Array(); - var me_fields = Array(); - var me_fields_null = Array(); + var me_fields_name = []; + var me_fields = []; + var me_fields_null = []; // alert user if edited table is not unique if (!is_unique) { @@ -1072,9 +1072,9 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi * multi edit variables, for current row * @TODO array indices are still not correct, they should be md5 of field's name */ - var fields_name = Array(); - var fields = Array(); - var fields_null = Array(); + var fields_name = []; + var fields = []; + var fields_null = []; // loop each edited cell in a row $tr.find('.to_be_saved').each(function() { @@ -1181,12 +1181,11 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi }; if (!g.saveCellsAtOnce) { - $(g.cEdit).find('*').attr('disabled', 'disabled'); - var $editArea = $(g.cEdit).find('.edit_area'); + $(g.cEdit).find('*').prop('disabled', true); $(g.cEdit).find('.edit_box').addClass('edit_box_posting'); } else { $('.save_edited').addClass('saving_edited_data') - .find('input').attr('disabled', 'disabled'); // disable the save button + .find('input').prop('disabled', true); // disable the save button } $.ajax({ @@ -1197,11 +1196,11 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi function(data) { g.isSaving = false; if (!g.saveCellsAtOnce) { - $(g.cEdit).find('*').removeAttr('disabled'); + $(g.cEdit).find('*').removeProp('disabled'); $(g.cEdit).find('.edit_box').removeClass('edit_box_posting'); } else { $('.save_edited').removeClass('saving_edited_data') - .find('input').removeAttr('disabled'); // enable the save button back + .find('input').removeProp('disabled'); // enable the save button back } if(data.success == true) { PMA_ajaxShowMessage(data.message); @@ -1209,11 +1208,11 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi $('.to_be_saved').parents('tr').each(function() { var new_clause = $(this).data('new_clause'); var $where_clause = $(this).find('.where_clause'); - var old_clause = $where_clause.attr('value'); + var old_clause = $where_clause.val(); var decoded_old_clause = PMA_urldecode(old_clause); var decoded_new_clause = PMA_urldecode(new_clause); - $where_clause.attr('value', new_clause); + $where_clause.val(new_clause); // update Edit, Copy, and Delete links also $(this).find('a').each(function() { $(this).attr('href', $(this).attr('href').replace(old_clause, new_clause)); @@ -1231,10 +1230,10 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi $(this).find('input[type=checkbox]').each(function() { var $checkbox = $(this); var checkbox_name = $checkbox.attr('name'); - var checkbox_value = $checkbox.attr('value'); + var checkbox_value = $checkbox.val(); $checkbox.attr('name', checkbox_name.replace(old_clause, new_clause)); - $checkbox.attr('value', checkbox_value.replace(decoded_old_clause, decoded_new_clause)); + $checkbox.val(checkbox_value.replace(decoded_old_clause, decoded_new_clause)); }); }); // update the display of executed SQL query command diff --git a/js/navigation.js b/js/navigation.js index 337cb66173..e85bb21fa7 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -159,9 +159,9 @@ function PMA_setCookie(name, value, expires, path, domain, secure) */ function fast_filter(value) { - lowercase_value = value.toLowerCase(); - $("#subel0 a[class!='tableicon']").each(function(idx,elem){ - $elem = $(elem); + var lowercase_value = value.toLowerCase(); + $("#subel0 a[class!='tableicon']").each(function(idx, elem) { + var $elem = $(elem); // .indexOf is case sensitive so convert to lowercase to compare if (value && $elem.html().toLowerCase().indexOf(lowercase_value) == -1) { $elem.parent().hide(); diff --git a/js/querywindow.js b/js/querywindow.js index 55c895a061..0eb1cc13a5 100644 --- a/js/querywindow.js +++ b/js/querywindow.js @@ -1,14 +1,16 @@ function PMA_queryAutoCommit() { - document.getElementById('sqlqueryform').target = window.opener.frame_content.name; - document.getElementById('sqlqueryform').submit(); + var sqlqueryform = document.getElementById('sqlqueryform'); + sqlqueryform.target = window.opener.frame_content.name; + sqlqueryform.submit(); return; } function PMA_querywindowCommit(tab) { - $('#hiddenqueryform').find("input[name='querydisplay_tab']").attr("value" ,tab); - $('#hiddenqueryform').submit(); + var $hiddenqueryform = $('#hiddenqueryform'); + $hiddenqueryform.find("input[name='querydisplay_tab']").val(tab); + $hiddenqueryform.submit(); return false; } @@ -19,23 +21,26 @@ function PMA_querywindowSetFocus() function PMA_querywindowResize() { + var $el = $(this)[0]; + var $querywindowcontainer = $('#querywindowcontainer'); + // for Gecko - if (typeof($(this)[0].sizeToContent) == 'function') { - $(this)[0].sizeToContent(); + if (typeof($el.sizeToContent) == 'function') { + $el.sizeToContent(); //self.scrollbars.visible = false; // give some more space ... to prevent 'fli(pp/ck)ing' - $(this)[0].resizeBy(10, 50); + $el.resizeBy(10, 50); return; } // for IE, Opera - if ($('#querywindowcontainer') != 'undefined') { + if ($querywindowcontainer.length) { // get content size - var newWidth = $("#querywindowcontainer")[0].offsetWidth; - var newHeight = $("#querywindowcontainer")[0].offsetHeight; + var newWidth = $querywindowcontainer.width(); + var newHeight = $querywindowcontainer.height(); // set size to contentsize // plus some offset for scrollbars, borders, statusbar, menus ... - $(this)[0].resizeTo(newWidth + 45, newHeight + 75); + $el.resizeTo(newWidth + 45, newHeight + 75); } } diff --git a/js/replication.js b/js/replication.js index f3fdb1e931..2137217259 100644 --- a/js/replication.js +++ b/js/replication.js @@ -49,6 +49,6 @@ $(document).ready(function() { $('#slave_synchronization_gui').toggle(); }); $('#db_reset_href').click(function() { - $('#db_select option:selected').attr('selected', false); + $('#db_select option:selected').prop('selected', false); }); }); diff --git a/js/server_privileges.js b/js/server_privileges.js index 65feb11cf4..df67543dc9 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -172,7 +172,7 @@ $(document).ready(function() { } //We also need to post the value of the submit button in order to get this to work correctly - $.post($form.attr('action'), $form.serialize() + "&adduser_submit=" + $(this).find("input[name=adduser_submit]").attr('value'), function(data) { + $.post($form.attr('action'), $form.serialize() + "&adduser_submit=" + $(this).find("input[name=adduser_submit]").val(), function(data) { if (data.success == true) { // Refresh navigation, if we created a database with the name // that is the same as the username of the new user @@ -204,7 +204,7 @@ $(document).ready(function() { url = url + "&ajax_request=true&db_specific=true"; /* post request for get the updated userForm table */ - $.post($form.attr('action' ), url, function(priv_data) { + $.post($form.attr('action'), url, function(priv_data) { /*Remove the old userForm table*/ if ($('#userFormDiv').length != 0) { @@ -212,11 +212,11 @@ $(document).ready(function() { } else { $("#usersForm").remove(); } - var user_div = $('
'); + var $user_div = $('
'); /*If the JSON string parsed correctly*/ if (typeof priv_data.success != 'undefined') { if (priv_data.success == true) { - user_div + $user_div .html(priv_data.user_form) .insertAfter('#result_query'); } else { @@ -225,7 +225,7 @@ $(document).ready(function() { } else { /*parse the JSON string*/ var obj = $.parseJSON(priv_data); - user_div + $user_div .html(obj.user_form) .insertAfter('#result_query'); } @@ -307,7 +307,7 @@ $(document).ready(function() { $form = $("#usersForm"); - $.post($form.attr('action'), $form.serialize() + "&delete=" + $(this).attr('value') + "&ajax_request=true", function(data) { + $.post($form.attr('action'), $form.serialize() + "&delete=" + $(this).val() + "&ajax_request=true", function(data) { if(data.success == true) { PMA_ajaxShowMessage(data.message); // Refresh navigation, if we droppped some databases with the name @@ -399,19 +399,21 @@ $(document).ready(function() { PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); - $(this).append(''); + var $t = $(this); + + $t.append(''); /** * @var curr_submit_name name of the current button being submitted */ - var curr_submit_name = $(this).find('.tblFooters').find('input:submit').attr('name'); + var curr_submit_name = $t.find('.tblFooters').find('input:submit').attr('name'); /** * @var curr_submit_value value of the current button being submitted */ - var curr_submit_value = $(this).find('.tblFooters').find('input:submit').val(); + var curr_submit_value = $t.find('.tblFooters').find('input:submit').val(); - $.post($(this).attr('action'), $(this).serialize() + '&' + curr_submit_name + '=' + curr_submit_value, function(data) { + $.post($t.attr('action'), $t.serialize() + '&' + curr_submit_name + '=' + curr_submit_value, function(data) { if(data.success == true) { PMA_ajaxShowMessage(data.message); @@ -425,9 +427,9 @@ $(document).ready(function() { .remove() .end() .after(data.sql_query); - var notice_class = $("#floating_menubar").next("div").find('.notice'); - if($(notice_class).text() == '') { - $(notice_class).remove(); + var $notice_class = $("#floating_menubar").next("div").find('.notice'); + if($notice_class.text() == '') { + $notice_class.remove(); } } //Show SQL Query that was executed @@ -590,11 +592,11 @@ $(document).ready(function() { * 'Drop the databases...' */ $('#checkbox_drop_users_db').click(function() { - $this_checkbox = $(this); + var $this_checkbox = $(this); if ($this_checkbox.is(':checked')) { var is_confirmed = confirm(PMA_messages['strDropDatabaseStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + '\nDROP DATABASE'); if (! is_confirmed) { - $this_checkbox.attr('checked', false); + $this_checkbox.prop('checked', false); } } }); diff --git a/js/server_status.js b/js/server_status.js index 4826ecc1c6..893fb34d0d 100644 --- a/js/server_status.js +++ b/js/server_status.js @@ -90,7 +90,7 @@ $(function() { $(document).click( function(event) { $('.openedPopup').each(function() { var $cnt = $(this); - var pos = $(this).offset(); + var pos = $cnt.offset(); // Hide if the mouseclick is outside the popupcontent if (event.pageX < pos.left diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js index d0ec47a7de..f6e5e34e21 100644 --- a/js/server_status_monitor.js +++ b/js/server_status_monitor.js @@ -4,9 +4,17 @@ $(function() { $('div#statustabs_charting img#loadingMonitorIcon').remove(); // Codemirror is loaded on demand so we might need to initialize it if (! codemirror_editor) { - var elm = $('#sqlquery'); - if (elm.length > 0 && typeof CodeMirror != 'undefined') { - codemirror_editor = CodeMirror.fromTextArea(elm[0], { lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql" }); + var $elm = $('#sqlquery'); + if ($elm.length > 0 && typeof CodeMirror != 'undefined') { + codemirror_editor = CodeMirror.fromTextArea( + $elm[0], + { + lineNumbers: true, + matchBrackets: true, + indentUnit: 4, + mode: "text/x-mysql" + } + ); } } // Timepicker is loaded on demand so we need to initialize datetime fields from the 'load log' dialog @@ -443,7 +451,7 @@ $(function() { } } - newChart.title = $('input[name="chartTitle"]').attr('value'); + newChart.title = $('input[name="chartTitle"]').val(); // Add a cloned object to the chart grid addChart($.extend(true, {}, newChart)); @@ -468,7 +476,7 @@ $(function() { }); $presetList.change(function() { $('input#chartPreset').trigger('click'); - $('input[name="chartTitle"]').attr('value', presetCharts[$(this).prop('value')].title); + $('input[name="chartTitle"]').val(presetCharts[$(this).val()].title); }); } @@ -729,13 +737,13 @@ $(function() { $('input[name="chartType"]').change(function() { $('#chartVariableSettings').toggle(this.checked && this.value == 'variable'); - var title = $('input[name="chartTitle"]').attr('value'); + var title = $('input[name="chartTitle"]').val(); if (title == PMA_messages['strChartTitle'] || title == $('label[for="' + $('input[name="chartTitle"]').data('lastRadio') + '"]').text() ) { $('input[name="chartTitle"]') .data('lastRadio', $(this).attr('id')) - .attr('value', $('label[for="' + $(this).attr('id') + '"]').text()); + .val($('label[for="' + $(this).attr('id') + '"]').text()); } }); @@ -749,21 +757,21 @@ $(function() { $('select[name="varChartList"]').change(function () { if (this.selectedIndex != 0) { - $('#variableInput').attr('value', this.value); + $('#variableInput').val(this.value); } }); $('a[href="#kibDivisor"]').click(function() { - $('input[name="valueDivisor"]').attr('value', 1024); - $('input[name="valueUnit"]').attr('value', PMA_messages['strKiB']); + $('input[name="valueDivisor"]').val(1024); + $('input[name="valueUnit"]').val(PMA_messages['strKiB']); $('span.unitInput').toggle(true); $('input[name="useUnit"]').prop('checked', true); return false; }); $('a[href="#mibDivisor"]').click(function() { - $('input[name="valueDivisor"]').attr('value', 1024*1024); - $('input[name="valueUnit"]').attr('value', PMA_messages['strMiB']); + $('input[name="valueDivisor"]').val(1024*1024); + $('input[name="valueUnit"]').val(PMA_messages['strMiB']); $('span.unitInput').toggle(true); $('input[name="useUnit"]').prop('checked', true); return false; @@ -776,7 +784,7 @@ $(function() { }); $('a[href="#submitAddSeries"]').click(function() { - if ($('input#variableInput').attr('value').length == 0) { + if ($('input#variableInput').val() == "") { return false; } @@ -784,27 +792,27 @@ $(function() { $('#seriesPreview').html(''); newChart = { - title: $('input[name="chartTitle"]').attr('value'), + title: $('input[name="chartTitle"]').val(), nodes: [] }; } var serie = { - dataPoints: [{ type: 'statusvar', name: $('input#variableInput').attr('value') }], - name: $('input#variableInput').attr('value'), - display: $('input[name="differentialValue"]').attr('checked') ? 'differential' : '' + dataPoints: [{ type: 'statusvar', name: $('input#variableInput').val() }], + name: $('input#variableInput').val(), + display: $('input[name="differentialValue"]').prop('checked') ? 'differential' : '' }; if (serie.dataPoint == 'Processes') { serie.dataType='proc'; } - if ($('input[name="useDivisor"]').attr('checked')) { - serie.valueDivisor = parseInt($('input[name="valueDivisor"]').attr('value')); + if ($('input[name="useDivisor"]').prop('checked')) { + serie.valueDivisor = parseInt($('input[name="valueDivisor"]').val()); } - if ($('input[name="useUnit"]').attr('checked')) { - serie.unit = $('input[name="valueUnit"]').attr('value'); + if ($('input[name="useUnit"]').prop('checked')) { + serie.unit = $('input[name="valueUnit"]').val(); } var str = serie.display == 'differential' ? ', ' + PMA_messages['strDifferential'] : ''; @@ -815,10 +823,10 @@ $(function() { newChart.nodes.push(serie); - $('input#variableInput').attr('value', ''); - $('input[name="differentialValue"]').attr('checked', true); - $('input[name="useDivisor"]').attr('checked', false); - $('input[name="useUnit"]').attr('checked', false); + $('input#variableInput').val(''); + $('input[name="differentialValue"]').prop('checked', true); + $('input[name="useDivisor"]').prop('checked', false); + $('input[name="useUnit"]').prop('checked', false); $('input[name="useDivisor"]').trigger('change'); $('input[name="useUnit"]').trigger('change'); $('select[name="varChartList"]').get(0).selectedIndex = 0; @@ -849,7 +857,7 @@ $(function() { $('a[href="#clearMonitorConfig"]').toggle(runtime.charts != null); if (runtime.charts != null && monitorProtocolVersion != window.localStorage['monitorVersion']) { - $('div#emptyDialog').attr('title',PMA_messages['strIncompatibleMonitorConfig']); + $('div#emptyDialog').attr('title', PMA_messages['strIncompatibleMonitorConfig']); $('div#emptyDialog').html(PMA_messages['strIncompatibleMonitorConfigDescription']); var dlgBtns = {}; @@ -869,8 +877,8 @@ $(function() { monitorSettings = defaultMonitorSettings; } - $('select[name="gridChartRefresh"]').attr('value', monitorSettings.gridRefresh / 1000); - $('select[name="chartColumns"]').attr('value', monitorSettings.columns); + $('select[name="gridChartRefresh"]').val(monitorSettings.gridRefresh / 1000); + $('select[name="chartColumns"]').val(monitorSettings.columns); if (monitorSettings.gridMaxPoints == 'auto') { runtime.gridMaxPoints = Math.round((monitorSettings.chartSize.width - 40) / 12); @@ -945,9 +953,9 @@ $(function() { if (runtime.charts) { oldData = {}; $.each(runtime.charts, function(key, chartObj) { - for (var i = 0; i < chartObj.nodes.length; i++) { + for (var i = 0, l = chartObj.nodes.length; i < l; i++) { oldData[chartObj.nodes[i].dataPoint] = []; - for (var j = 0; j < chartObj.chart.series[i].data.length; j++) + for (var j = 0, ll = chartObj.chart.series[i].data.length; j < ll; j++) oldData[chartObj.nodes[i].dataPoint].push([chartObj.chart.series[i].data[j].x, chartObj.chart.series[i].data[j].y]); } }); @@ -958,7 +966,7 @@ $(function() { if (oldData) { $.each(runtime.charts, function(key, chartObj) { - for (var j = 0; j < chartObj.nodes.length; j++) { + for (var j = 0, l = chartObj.nodes.length; j < l; j++) { if (oldData[chartObj.nodes[j].dataPoint]) { chartObj.chart.series[j].setData(oldData[chartObj.nodes[j].dataPoint]); } @@ -979,7 +987,7 @@ $(function() { /* Adds a chart to the chart grid */ function addChart(chartObj, initialize) { series = []; - for (var j = 0; j Sum up identical columns, and hide all but 1 - q = $(this).text().replace(equalsFilter, '$1=...$6').trim(); + q = $t.text().replace(equalsFilter, '$1=...$6').trim(); q = q.replace(functionFilter, ' $1(...)'); // Js does not specify a limit on property name length, so we can abuse it as index :-) if (filteredQueries[q]) { - filteredQueries[q] += parseInt($(this).next().text()); - totalSum += parseInt($(this).next().text()); + filteredQueries[q] += parseInt($t.next().text()); + totalSum += parseInt($t.next().text()); hide = true; } else { - filteredQueries[q] = parseInt($(this).next().text());; + filteredQueries[q] = parseInt($t.next().text()); filteredQueriesLines[q] = i; - $(this).text(q); + $t.text(q); } if (isSlowLog) { - countRow(q, $(this).parent().html()); + countRow(q, $t.parent().html()); } } else { // Group off: Restore original columns - rowData = $(this).parent().data('query'); + rowData = $t.parent().data('query'); // Restore SQL text - $(this).text(rowData[queryColumnName]); + $t.text(rowData[queryColumnName]); // Restore total count - $(this).next().text(rowData[sumColumnName]); + $t.next().text(rowData[sumColumnName]); // Restore slow log columns if (isSlowLog) { - $(this).parent().children('td:nth-child(3)').text(rowData['query_time']); - $(this).parent().children('td:nth-child(4)').text(rowData['lock_time']); - $(this).parent().children('td:nth-child(5)').text(rowData['rows_sent']); - $(this).parent().children('td:nth-child(6)').text(rowData['rows_examined']); + $t.parent().children('td:nth-child(3)').text(rowData['query_time']); + $t.parent().children('td:nth-child(4)').text(rowData['lock_time']); + $t.parent().children('td:nth-child(5)').text(rowData['rows_sent']); + $t.parent().children('td:nth-child(6)').text(rowData['rows_examined']); } } } // If not required to be hidden, do we need to hide because of a not matching text filter? - if (! hide && (textFilter != null && ! textFilter.exec($(this).text()))) { + if (! hide && (textFilter != null && ! textFilter.exec($t.text()))) { hide = true; } // Now display or hide this column if (hide) { - $(this).parent().css('display', 'none'); + $t.parent().css('display', 'none'); } else { - totalSum += parseInt($(this).next().text()); + totalSum += parseInt($t.next().text()); rowSum++; odd_row = ! odd_row; - $(this).parent().css('display', ''); + $t.parent().css('display', ''); if (odd_row) { - $(this).parent().addClass('odd'); - $(this).parent().removeClass('even'); + $t.parent().addClass('odd'); + $t.parent().removeClass('even'); } else { - $(this).parent().addClass('even'); - $(this).parent().removeClass('odd'); + $t.parent().addClass('even'); + $t.parent().removeClass('odd'); } } @@ -1593,9 +1604,9 @@ $(function() { /* Turns a number into a timespan (100 into 00:01:40) */ function secToTime(timeInt) { - hours = Math.floor(timeInt / 3600); + var hours = Math.floor(timeInt / 3600); timeInt -= hours*3600; - minutes = Math.floor(timeInt / 60); + var minutes = Math.floor(timeInt / 60); timeInt -= minutes*60; if (hours < 10) { @@ -1628,7 +1639,7 @@ $(function() { return value; }; - for (var i = 0; i < rows.length; i++) { + for (var i = 0, l = rows.length; i < l; i++) { if (i == 0) { $.each(rows[0], function(key, value) { cols.push(key); @@ -1642,7 +1653,7 @@ $(function() { $tBody.append($tRow = $('')); var cl = ''; - for (var j = 0; j < cols.length; j++) { + for (var j = 0, ll = cols.length; j < ll; j++) { // Assuming the query column is the second last if (j == cols.length - 2 && rows[i][cols[j]].match(/^SELECT/i)) { $tRow.append($tCell = $('' + formatValue(cols[j], rows[i][cols[j]]) + '')); @@ -1766,7 +1777,7 @@ $(function() { explain += ')'; } explain += '

'; - for (var i = 0; i < data.explain.length; i++) { + for (var i = 0, l = data.explain.length; i < l; i++) { explain += '
0? 'style="display:none;"' : '' ) + '>'; $.each(data.explain[i], function(key, value) { value = (value == null)?'null':value; @@ -1797,7 +1808,7 @@ $(function() { var numberTable = ''; var duration; - for (var i = 0; i < data.profiling.length; i++) { + for (var i = 0, l = data.profiling.length; i < l; i++) { duration = parseFloat(data.profiling[i].duration); chartData.push([data.profiling[i].state, duration]); diff --git a/js/server_synchronize.js b/js/server_synchronize.js index 4a4b1c1288..0c2adc4890 100644 --- a/js/server_synchronize.js +++ b/js/server_synchronize.js @@ -63,7 +63,7 @@ function showDetails(i, update_size, insert_size, remove_size, insert_index, rem newRow.setAttribute("class", row_class); newRow.className = row_class; // Id assigned to this row element is same as the index of this table name in the matching_tables/source_tables_uncommon array - newRow.setAttribute("id" , i); + newRow.setAttribute("id", i); var table_name_cell = document.createElement("td"); table_name_cell.align = "center"; @@ -207,10 +207,10 @@ function showDetails(i, update_size, insert_size, remove_size, insert_index, rem { row_class_element = table_rows[index].getAttribute('class'); if (row_class_element == "even") { - table_rows[index].setAttribute("class","odd"); // for Mozilla firefox + table_rows[index].setAttribute("class", "odd"); // for Mozilla firefox table_rows[index].className = "odd"; // for IE browser } else { - table_rows[index].setAttribute("class","even"); // for Mozilla firefox + table_rows[index].setAttribute("class", "even"); // for Mozilla firefox table_rows[index].className = "even"; // for IE browser } } diff --git a/js/server_variables.js b/js/server_variables.js index ef453f02d4..691e6677b9 100644 --- a/js/server_variables.js +++ b/js/server_variables.js @@ -39,7 +39,7 @@ $(function() { var name = location.hash.substr(1).split('=')[1]; // Only allow variable names if (! name.match(/[^0-9a-zA-Z_]+/)) { - $('#filterText').attr('value',name).trigger('keyup'); + $('#filterText').val(name).trigger('keyup'); } } @@ -141,7 +141,7 @@ function editVariable(link) ajax_request: true, type: 'setval', varName: varName, - varValue: $cell.find('input').attr('value') + varValue: $cell.find('input').val() }, function(data) { if (data.success) { $cell.html(data.variable); diff --git a/js/sql.js b/js/sql.js index 6f00c75b0b..252b2fa7f1 100644 --- a/js/sql.js +++ b/js/sql.js @@ -76,7 +76,7 @@ $(document).ready(function() { $('input#bkm_label').keyup(function() { $('input#id_bkm_all_users, input#id_bkm_replace') .parent() - .toggle($(this).attr('value').length > 0); + .toggle($(this).val().length > 0); }).trigger('keyup'); /** @@ -133,7 +133,7 @@ $(document).ready(function() { // instead of the one related to Bookmarks, so empty the // id_bookmark selector to avoid misinterpretation in // import.php about what needs to be done - $form.find("select[name=id_bookmark]").attr("value",""); + $form.find("select[name=id_bookmark]").val(""); // let normal event propagation happen }); @@ -371,7 +371,7 @@ $(document).ready(function() { /*Check whether atleast one row is selected for change*/ if ($("#table_results tbody tr, #table_results tbody tr td").hasClass("marked")) { - var div = $('
'); + var $div = $('
'); /** * @var button_options Object that stores the options passed to jQueryUI @@ -386,10 +386,10 @@ $(document).ready(function() { var $form = $("#resultsForm"); var $msgbox = PMA_ajaxShowMessage(); - $.get( $form.attr('action'), $form.serialize()+"&ajax_request=true&submit_mult=row_edit", function(data) { + $.get($form.attr('action'), $form.serialize()+"&ajax_request=true&submit_mult=row_edit", function(data) { //in the case of an error, show the error message returned. if (data.success != undefined && data.success == false) { - div + $div .append(data.error) .dialog({ title: PMA_messages['strChangeTbl'], @@ -402,7 +402,7 @@ $(document).ready(function() { buttons : button_options_error }); // end dialog options } else { - div + $div .append(data) .dialog({ title: PMA_messages['strChangeTbl'], @@ -476,9 +476,8 @@ $(document).ready(function() { * @var the_form object referring to the insert form */ var $form = $("#insertForm"); - /**Get the submit type and the after insert type in the form*/ - var selected_submit_type = $("#insertForm").find("#actions_panel .control_at_footer option:selected").attr('value'); - var selected_after_insert = $("#insertForm").find("#actions_panel select[name=after_insert] option:selected").attr('value'); + /**Get the submit type in the form*/ + var selected_submit_type = $("#insertForm").find("#actions_panel .control_at_footer option:selected").val(); $("#result_query").remove(); PMA_prepareForAjaxRequest($form); //User wants to submit the form diff --git a/js/tbl_change.js b/js/tbl_change.js index d70662ea8e..d90a59833e 100644 --- a/js/tbl_change.js +++ b/js/tbl_change.js @@ -138,17 +138,15 @@ function isDate(val,tmstmp) */ function isTime(val) { - var arrayVal=val.split(":"); - for(var a=0;a
' + PMA_messages['strStatus'] + '' + PMA_messages['strTime'] + '