]> cgit.babelmonkeys.de Git - adhocweb.git/blobdiff - js/adhoc.js
Add licensing information
[adhocweb.git] / js / adhoc.js
index 3638eef87a99fc4c0c86040c228b340a26a690b0..51932499f7a099ac94a96f8daa20d78f4509d1c9 100644 (file)
@@ -1,3 +1,9 @@
+// adhocweb
+// Copyright (c) 2010-2013 Florian Zeitz
+//
+// This project is MIT licensed.
+// Please see the COPYING file for more information.
+
 /*
  * Implementation of ECMA Script 5 like bind from:
  * https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
@@ -156,6 +162,7 @@ Adhoc.prototype = {
         var self = this;
         var status = $(result).find("command").attr("status");
         var kinds = {'prev': 'Prev', 'next': 'Next', 'complete': 'Complete'};
+       var actions = $(result).find("actions:first");
 
         $(self.status.view).empty();
         $(result).find("command > *").each(function() {
@@ -169,19 +176,17 @@ Adhoc.prototype = {
            var controls = $("<div class='actions'/>");
             for (kind in kinds) {
                var input;
-                (function(type) {
-                    input = $("<input type='button' disabled='disabled' class='btn' value='" + kinds[type] + "'/>").click(function() {
-                        self.executeCommand(type, (type!= 'prev') && self.serializeToDataform('form'), function(e) { self.displayResult(e) });
-                    }).appendTo(controls);
-                })(kind);
-                if ($(result).find('actions ' + kind).length > 0)
+               (function (type) {
+                   input = $("<input type='button' disabled='disabled' class='btn' value='" + kinds[type] + "'/>").click(function() {
+                       self.executeCommand(type, (type != 'prev') && self.serializeToDataform('form'), function(e) { self.displayResult(e) });
+                   }).appendTo(controls);
+               })(kind);
+                if (actions.find(kind).length > 0)
                     input.removeAttr("disabled");
+               if (actions.attr("execute") == kind)
+                   input.addClass("primary");
             }
 
-            $("<input type='button' id='executeButton' class='btn primary' value='Execute'/>").click(function() {
-                self.executeCommand("execute", self.serializeToDataform('form'), function(e) { self.displayResult(e) });
-            }).appendTo(controls);
-
             $("<input type='button' class='btn' value='Cancel'/>").click(function() {
                 self.cancelCommand(function(e) { self.displayResult(e) });
             }).appendTo(controls);