]> git.joonet.de Git - adminer.git/commitdiff
Edit, clone and delete by AJAX
authorJakub Vrana <jakub@vrana.cz>
Sun, 17 Oct 2010 21:54:41 +0000 (23:54 +0200)
committerJakub Vrana <jakub@vrana.cz>
Sun, 17 Oct 2010 21:54:41 +0000 (23:54 +0200)
adminer/select.inc.php
adminer/static/functions.js

index 6606e19ef063d7d617ef9a6afcdb33dec57a8594..2bcac10d533ef0454af48bb473b3e6bee9f7b822 100644 (file)
@@ -380,10 +380,10 @@ if (!$columns) {
                        if (!information_schema(DB)) {
                                ?>
 <fieldset><legend><?php echo lang('Edit'); ?></legend><div>
-<input type="submit" id="save" value="<?php echo lang('Save'); ?>" title="<?php echo lang('Double click on a value to modify it.'); ?>" onclick='return !ajaxForm(this.form);'>
-<input type="submit" name="edit" value="<?php echo lang('Edit'); ?>">
-<input type="submit" name="clone" value="<?php echo lang('Clone'); ?>">
-<input type="submit" name="delete" value="<?php echo lang('Delete'); ?>" onclick="return confirm('<?php echo lang('Are you sure?'); ?> (' + (this.form['all'].checked ? <?php echo $found_rows; ?> : formChecked(this, /check/)) + ')');">
+<input type="submit" id="save" value="<?php echo lang('Save'); ?>" title="<?php echo lang('Double click on a value to modify it.'); ?>" onclick="return !ajaxForm(this.form);">
+<input type="submit" name="edit" value="<?php echo lang('Edit'); ?>" onclick="return !ajaxForm(this.form, 'edit=1');">
+<input type="submit" name="clone" value="<?php echo lang('Clone'); ?>" onclick="return !ajaxForm(this.form, 'clone=1');">
+<input type="submit" name="delete" value="<?php echo lang('Delete'); ?>" onclick="return confirm('<?php echo lang('Are you sure?'); ?> (' + (this.form['all'].checked ? <?php echo $found_rows; ?> : formChecked(this, /check/)) + ')') &amp;&amp; !ajaxForm(this.form, 'delete=1');">
 </div></fieldset>
 <?php
                        }
index 7b32fd0c7c5a563f95c6590e9178dbfa0cfa7a9e..d9d93846eec0ec6f42a670278b8bb5a9b38022be 100644 (file)
@@ -168,7 +168,7 @@ var ajaxTimeout;
 
 /** Create AJAX request
 * @param string
-* @param string
+* @param [string]
 * @return XMLHttpRequest or false in case of an error
 */
 function ajax(url, data) {
@@ -202,9 +202,10 @@ function ajax(url, data) {
 
 /** Send form by AJAX GET
 * @param HTMLFormElement
+* @param [string]
 * @return XMLHttpRequest or false in case of an error
 */
-function ajaxForm(form) {
+function ajaxForm(form, data) {
        var params = [ ];
        for (var i=0; i < form.elements.length; i++) {
                var el = form.elements[i];
@@ -212,6 +213,9 @@ function ajaxForm(form) {
                        params.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(/select/i.test(el.tagName) ? selectValue(el) : el.value));
                }
        }
+       if (data) {
+               params.push(data);
+       }
        if (form.method == 'post') {
                return ajax(form.action || location.href, params.join('&'));
        } else {