Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js/rte.js
diff options
context:
space:
mode:
authorMadhura Jayaratne <madhura.cj@gmail.com>2015-12-01 04:20:16 +0300
committerMadhura Jayaratne <madhura.cj@gmail.com>2015-12-01 04:20:16 +0300
commit547c977bc18e4b126ccd2d61d4c51278daba3259 (patch)
tree73194ae396469e2a13fc4f5ffb773d7e1584d6bf /js/rte.js
parent6259eb0b3c8b52efbd26ddcab14918ac625952a7 (diff)
issue #11701 Allow changing parameter order of routines
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
Diffstat (limited to 'js/rte.js')
-rw-r--r--js/rte.js72
1 files changed, 43 insertions, 29 deletions
diff --git a/js/rte.js b/js/rte.js
index 79382aeb62..ce3a696a71 100644
--- a/js/rte.js
+++ b/js/rte.js
@@ -591,6 +591,48 @@ RTE.ROUTINE = {
$('table.rte_table').last().find('select[name=item_returnopts_text]'),
$('table.rte_table').last().find('select[name=item_returnopts_num]')
);
+ // Allow changing parameter order
+ $('.routine_params_table tbody').sortable({
+ containment: '.routine_params_table tbody',
+ handle: '.dragHandle',
+ stop: function(event, ui) {
+ that.reindexParameters();
+ },
+ });
+ },
+ /**
+ * Reindexes the parameters after dropping a parameter or reordering parameters
+ */
+ reindexParameters: function () {
+ /**
+ * @var index Counter used for reindexing the input
+ * fields in the routine parameters table
+ */
+ var index = 0;
+ $('table.routine_params_table tbody').find('tr').each(function () {
+ $(this).find(':input').each(function () {
+ /**
+ * @var inputname The value of the name attribute of
+ * the input field being reindexed
+ */
+ var inputname = $(this).attr('name');
+ if (inputname.substr(0, 14) === 'item_param_dir') {
+ $(this).attr('name', inputname.substr(0, 14) + '[' + index + ']');
+ } else if (inputname.substr(0, 15) === 'item_param_name') {
+ $(this).attr('name', inputname.substr(0, 15) + '[' + index + ']');
+ } else if (inputname.substr(0, 15) === 'item_param_type') {
+ $(this).attr('name', inputname.substr(0, 15) + '[' + index + ']');
+ } else if (inputname.substr(0, 17) === 'item_param_length') {
+ $(this).attr('name', inputname.substr(0, 17) + '[' + index + ']');
+ $(this).attr('id', 'item_param_length_' + index);
+ } else if (inputname.substr(0, 20) === 'item_param_opts_text') {
+ $(this).attr('name', inputname.substr(0, 20) + '[' + index + ']');
+ } else if (inputname.substr(0, 19) === 'item_param_opts_num') {
+ $(this).attr('name', inputname.substr(0, 19) + '[' + index + ']');
+ }
+ });
+ index++;
+ });
},
/**
* Overriding the validateCustom() function defined in common.js
@@ -1014,34 +1056,6 @@ $(function () {
$(this).parent().parent().remove();
// After removing a parameter, the indices of the name attributes in
// the input fields lose the correct order and need to be reordered.
- /**
- * @var index Counter used for reindexing the input
- * fields in the routine parameters table
- */
- var index = 0;
- $(this).closest('div.ui-dialog').find('table.routine_params_table').find('tr').has('td').each(function () {
- $(this).find(':input').each(function () {
- /**
- * @var inputname The value of the name attribute of
- * the input field being reindexed
- */
- var inputname = $(this).attr('name');
- if (inputname.substr(0, 14) === 'item_param_dir') {
- $(this).attr('name', inputname.substr(0, 14) + '[' + index + ']');
- } else if (inputname.substr(0, 15) === 'item_param_name') {
- $(this).attr('name', inputname.substr(0, 15) + '[' + index + ']');
- } else if (inputname.substr(0, 15) === 'item_param_type') {
- $(this).attr('name', inputname.substr(0, 15) + '[' + index + ']');
- } else if (inputname.substr(0, 17) === 'item_param_length') {
- $(this).attr('name', inputname.substr(0, 17) + '[' + index + ']');
- $(this).attr('id', 'item_param_length_' + index);
- } else if (inputname.substr(0, 20) === 'item_param_opts_text') {
- $(this).attr('name', inputname.substr(0, 20) + '[' + index + ']');
- } else if (inputname.substr(0, 19) === 'item_param_opts_num') {
- $(this).attr('name', inputname.substr(0, 19) + '[' + index + ']');
- }
- });
- index++;
- });
+ RTE.ROUTINE.reindexParameters();
}); // end $(document).on()
}); // end of $()