coffeescript-ui
Version:
Coffeescript User Interface System
97 lines (91 loc) • 2.26 kB
JavaScript
// Generated by CoffeeScript 1.10.0
(function() {
var App;
App = (function() {
function App() {
var body, button, data, form, resultLabel;
resultLabel = new CUI.Label({
multiline: true
});
data = {};
form = new CUI.Form({
data: data,
fields: [
{
type: CUI.Input,
name: "name",
regexp: "^([^0-9]*)$",
form: {
label: "Name"
}
}, {
type: CUI.NumberInput,
name: "age",
form: {
label: "Age"
}
}, {
type: CUI.Select,
name: "country",
options: [
{
value: "Germany"
}, {
value: "Argentina"
}
],
form: {
label: "Country"
}
}
],
onDataChanged: (function(_this) {
return function(data, field, event) {
var fieldName;
console.log("----------------------");
console.log("Data:", data);
console.log("Field:", field);
console.log("Event:", event);
fieldName = field.getName();
return resultLabel.setText("Data changed! Input: " + fieldName + " -> " + data[fieldName]);
};
})(this)
});
form.start();
button = new CUI.Button({
text: "Show data!",
onClick: (function(_this) {
return function() {
return CUI.alert({
text: CUI.util.dump(data)
});
};
})(this)
});
body = new CUI.HorizontalLayout({
left: {
content: new CUI.Label({
centered: true,
text: "Left !!"
})
},
center: {
content: new CUI.VerticalList({
content: [form, button, resultLabel]
})
},
right: {
content: new CUI.Label({
centered: true,
text: "Right"
})
}
});
CUI.dom.append(document.body, body);
}
return App;
})();
CUI.ready(function() {
return new App();
});
}).call(this);