From bc2cd16c4c3cf3255412035919d504b2050cd7cf Mon Sep 17 00:00:00 2001 From: Rouslan Placella Date: Tue, 5 Jul 2011 13:19:58 +0100 Subject: [PATCH] Moved code common to Routines, Triggers and Events from "functions.js" to "rte/common.js" --- js/functions.js | 101 ----------------------------------------------- js/rte/common.js | 97 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 101 deletions(-) diff --git a/js/functions.js b/js/functions.js index 91cfde8250..d226a0c29a 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2552,44 +2552,6 @@ $(document).ready(function() { }) // end of $(document).ready() -/** - * Attach Ajax event handlers for Export of Routines, Triggers and Events. - * - * @uses PMA_ajaxShowMessage() - * @uses PMA_ajaxRemoveMessage() - * - * @see $cfg['AjaxEnable'] - */ -$(document).ready(function() { - $('.ajax_export_anchor').live('click', function(event) { - event.preventDefault(); - var $msg = PMA_ajaxShowMessage(PMA_messages['strLoading']); - $.get($(this).attr('href'), {'ajax_request': true}, function(data) { - if(data.success == true) { - PMA_ajaxRemoveMessage($msg); - /** - * @var button_options Object containing options for jQueryUI dialog buttons - */ - var button_options = {}; - button_options[PMA_messages['strClose']] = function() {$(this).dialog("close").remove();} - /** - * Display the dialog to the user - */ - var $ajaxDialog = $('
'+data.message+'
').dialog({ - width: 500, - buttons: button_options, - title: data.title - }); - // Attach syntax highlited editor to export dialog - var elm = $ajaxDialog.find('textarea'); - CodeMirror.fromTextArea(elm[0], {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql"}); - } else { - PMA_ajaxShowMessage(data.error); - } - }) // end $.get() - }); // end $.live() -}); // end of $(document).ready() for Export of Routines, Triggers and Events. - /** * Creates a message inside an object with a sliding effect * @@ -2667,69 +2629,6 @@ function PMA_slidingMessage(msg, $obj) { return true; } // end PMA_slidingMessage() -/** - * Attach Ajax event handlers for Drop functionality of Routines, Triggers and Events. - * - * @uses $.PMA_confirm() - * @uses PMA_ajaxShowMessage() - * @see $cfg['AjaxEnable'] - */ -$(document).ready(function() { - $('.ajax_drop_anchor').live('click', function(event) { - event.preventDefault(); - /** - * @var $curr_row Object containing reference to the current row - */ - var $curr_row = $(this).parents('tr'); - /** - * @var question String containing the question to be asked for confirmation - */ - var question = $('
').text($curr_row.children('td').children('.drop_sql').html()); - $(this).PMA_confirm(question, $(this).attr('href'), function(url) { - /** - * @var $msg jQuery object containing the reference to - * the AJAX message shown to the user. - */ - var $msg = PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); - $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) { - if(data.success == true) { - /** - * @var $table Object containing reference to the main list of elements. - */ - var $table = $curr_row.parent(); - if ($table.find('tr').length == 2) { - $table.hide("slow", function () { - $(this).find('tr.even, tr.odd').remove(); - $('#nothing2display').show("slow"); - }); - } else { - $curr_row.hide("slow", function () { - $(this).remove(); - // Now we have removed the row from the list, but maybe - // some row classes are wrong now. So we will itirate - // throught all rows and assign correct classes to them. - /** - * @var ct Count of processed rows. - */ - var ct = 0; - $table.find('tr').has('td').each(function() { - rowclass = (ct % 2 == 0) ? 'even' : 'odd'; - $(this).removeClass().addClass(rowclass); - ct++; - }); - }); - } - // Show the query that we just executed - PMA_ajaxRemoveMessage($msg); - PMA_slidingMessage(data.sql_query); - } else { - PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error); - } - }) // end $.get() - }) // end $.PMA_confirm() - }); // end $.live() -}); //end $(document).ready() for Drop functionality of Routines, Triggers and Events. - /** * Attach Ajax event handlers for Drop Table. * diff --git a/js/rte/common.js b/js/rte/common.js index 529a3239a3..84bec0f8c0 100644 --- a/js/rte/common.js +++ b/js/rte/common.js @@ -224,4 +224,101 @@ $(document).ready(function() { } } }); + + /** + * Attach Ajax event handlers for Export of Routines, Triggers and Events. + * + * @uses PMA_ajaxShowMessage() + * @uses PMA_ajaxRemoveMessage() + * + * @see $cfg['AjaxEnable'] + */ + $('.ajax_export_anchor').live('click', function(event) { + event.preventDefault(); + var $msg = PMA_ajaxShowMessage(PMA_messages['strLoading']); + $.get($(this).attr('href'), {'ajax_request': true}, function(data) { + if(data.success == true) { + PMA_ajaxRemoveMessage($msg); + /** + * @var button_options Object containing options for jQueryUI dialog buttons + */ + var button_options = {}; + button_options[PMA_messages['strClose']] = function() {$(this).dialog("close").remove();} + /** + * Display the dialog to the user + */ + var $ajaxDialog = $('
'+data.message+'
').dialog({ + width: 500, + buttons: button_options, + title: data.title + }); + // Attach syntax highlited editor to export dialog + var elm = $ajaxDialog.find('textarea'); + CodeMirror.fromTextArea(elm[0], {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql"}); + } else { + PMA_ajaxShowMessage(data.error); + } + }) // end $.get() + }); // end $.live() + + /** + * Attach Ajax event handlers for Drop functionality of Routines, Triggers and Events. + * + * @uses $.PMA_confirm() + * @uses PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] + */ + $('.ajax_drop_anchor').live('click', function(event) { + event.preventDefault(); + /** + * @var $curr_row Object containing reference to the current row + */ + var $curr_row = $(this).parents('tr'); + /** + * @var question String containing the question to be asked for confirmation + */ + var question = $('
').text($curr_row.children('td').children('.drop_sql').html()); + $(this).PMA_confirm(question, $(this).attr('href'), function(url) { + /** + * @var $msg jQuery object containing the reference to + * the AJAX message shown to the user. + */ + var $msg = PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); + $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) { + if(data.success == true) { + /** + * @var $table Object containing reference to the main list of elements. + */ + var $table = $curr_row.parent(); + if ($table.find('tr').length == 2) { + $table.hide("slow", function () { + $(this).find('tr.even, tr.odd').remove(); + $('#nothing2display').show("slow"); + }); + } else { + $curr_row.hide("slow", function () { + $(this).remove(); + // Now we have removed the row from the list, but maybe + // some row classes are wrong now. So we will itirate + // throught all rows and assign correct classes to them. + /** + * @var ct Count of processed rows. + */ + var ct = 0; + $table.find('tr').has('td').each(function() { + rowclass = (ct % 2 == 0) ? 'even' : 'odd'; + $(this).removeClass().addClass(rowclass); + ct++; + }); + }); + } + // Show the query that we just executed + PMA_ajaxRemoveMessage($msg); + PMA_slidingMessage(data.sql_query); + } else { + PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error); + } + }) // end $.get() + }) // end $.PMA_confirm() + }); // end $.live() }); // end of $(document).ready()