]> git.joonet.de Git - adminer.git/commitdiff
Add javascript move for editing
authorJonathan Vollebregt <jnvsor@gmail.com>
Tue, 31 May 2016 18:36:00 +0000 (20:36 +0200)
committerJakub Vrana <jakub@vrana.cz>
Sun, 19 Feb 2017 12:55:50 +0000 (13:55 +0100)
adminer/create.inc.php
adminer/include/editing.inc.php
adminer/static/editing.js

index 7af80dd85c26fa74c3ec94aa30d9d561892321d0..19ae3f5381602b0cdeaaaca303128979f7e92d9f 100644 (file)
@@ -35,7 +35,6 @@ if ($_POST && !process_fields($row["fields"]) && !$error) {
                $all_fields = array();
                $use_all_fields = false;
                $foreign = array();
-               ksort($row["fields"]);
                $orig_field = reset($orig_fields);
                $after = " FIRST";
 
index e7b5cc5ea1dfad59720327e798c51e7810b6ce35..51569303fa43df8f8dc93d460b272a93e4a6c556 100644 (file)
@@ -277,8 +277,8 @@ echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "
                echo "<td>";
                echo (support("move_col") ?
                        "<input type='image' class='icon' name='add[$i]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "' onclick='return !editingAddRow(this, 1);'>&nbsp;"
-                       . "<input type='image' class='icon' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "'>&nbsp;"
-                       . "<input type='image' class='icon' name='down[$i]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "'>&nbsp;"
+                       . "<input type='image' class='icon' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "' onclick='return !editingMoveRow(this, 1);'>&nbsp;"
+                       . "<input type='image' class='icon' name='down[$i]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "' onclick='return !editingMoveRow(this, 0);'>&nbsp;"
                : "");
                echo ($orig == "" || support("drop_col") ? "<input type='image' class='icon' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick=\"return !editingRemoveRow(this, 'fields\$1[field]');\">" : "");
                echo "\n";
@@ -290,7 +290,6 @@ echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "
 * @return bool
 */
 function process_fields(&$fields) {
-       ksort($fields);
        $offset = 0;
        if ($_POST["up"]) {
                $last = 0;
index f0ce0e3427f09aa064683e99764260dd934c36be..ceea6b1d50deeb63ddefe0b76424f00776ef4b21 100644 (file)
@@ -271,6 +271,22 @@ function editingRemoveRow(button, name) {
        return true;
 }
 
+/** Move table row for field
+* @param HTMLInputElement
+* @param boolean direction to move row, true for up or false for down
+* @return boolean
+*/
+function editingMoveRow(button, dir){
+       var row = parentTag(button, 'tr');
+       if (!('nextElementSibling' in row)) {
+               return false;
+       }
+       row.parentNode.insertBefore(row, dir
+               ? row.previousElementSibling
+               : row.nextElementSibling ? row.nextElementSibling.nextElementSibling : row.parentNode.firstChild);
+       return true;
+}
+
 var lastType = '';
 
 /** Clear length and hide collation or unsigned