+// 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
addForm: function (x) {
var self = this;
- var form = $("<form action='#'/>");
+ var form = $("<form class='form-stacked' action='#'/>");
form.submit(function(event) {
self.executeCommand("execute", self.serializeToDataform('form'),
function(e) { self.displayResult(e) });
$(x).find("title").each(function() { $("<legend/>").text($(this).text()).appendTo(fieldset); });
$(x).find("instructions").each(function() { $("<p/>").text($(this).text()).appendTo(fieldset); });
$(x).find("field").each(function() {
+ var clearfix = $("<div class='clearfix'/>");
var item = self.buildHTMLField(this);
var label = $(this).attr("label");
if(label) {
- $("<label/>").text(label).attr("for", $(this).attr("var")).appendTo(fieldset);
- $("<br/>").appendTo(fieldset);
+ $("<label/>").text(label).attr("for", $(this).attr("var")).appendTo(clearfix);
}
if ($(x).attr("type") === "result")
item.attr("readonly", true);
- fieldset.append(item);
- if ($(this).attr("type") !== "hidden")
- fieldset.append("<br/>");
+ clearfix.append(item);
+ fieldset.append(clearfix);
});
$(self.status.view).append(form);
},
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() {
}
});
if (status === "executing") {
+ var controls = $("<div class='actions'/>");
for (kind in kinds) {
- (function(type) {
- input = $("<input type='button' disabled='disabled' value='" + kinds[type] + "'/>").click(function() {
- self.executeCommand(type, (type!= 'prev') && self.serializeToDataform('form'), function(e) { self.displayResult(e) });
- });
- })(kind);
- if ($(result).find('actions ' + kind).length > 0)
+ 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 (actions.find(kind).length > 0)
input.removeAttr("disabled");
- $(self.status.view).append(input);
+ if (actions.attr("execute") == kind)
+ input.addClass("primary");
}
- $("<input type='button' id='executeButton' value='Execute'/>").click(function() {
- self.executeCommand("execute", self.serializeToDataform('form'), function(e) { self.displayResult(e) });
- }).appendTo(self.status.view);
-
- $("<input type='button' value='Cancel'/>").click(function() {
+ $("<input type='button' class='btn' value='Cancel'/>").click(function() {
self.cancelCommand(function(e) { self.displayResult(e) });
- }).appendTo(self.status.view);
+ }).appendTo(controls);
+ $(self.status.view + " fieldset").append(controls);
} else {
self.status.sessionid = null;
self.status.cmdNode = null;