initial player stuff
This commit is contained in:
parent
4b60ece582
commit
00f26c431e
38 changed files with 1107 additions and 93 deletions
|
@ -13,5 +13,6 @@ configure_file(themeStorage.js themeStorage.js)
|
|||
configure_file(vocabulary.js vocabulary.js)
|
||||
configure_file(attributes.js attributes.js)
|
||||
configure_file(image.js image.js)
|
||||
configure_file(button.js button.js)
|
||||
|
||||
add_subdirectory(proxy)
|
||||
|
|
90
libjs/wModel/button.js
Normal file
90
libjs/wModel/button.js
Normal file
|
@ -0,0 +1,90 @@
|
|||
"use strict";
|
||||
|
||||
var Model = require("./model");
|
||||
var ModelString = require("./string");
|
||||
|
||||
var Vocabulary = require("../wType/vocabulary");
|
||||
var Boolean = require("../wType/boolean");
|
||||
var Address = require("../wType/address");
|
||||
var String = require("../wType/string");
|
||||
|
||||
var Button = Model.inherit({
|
||||
"className": "Button",
|
||||
"constructor": function(address) {
|
||||
Model.fn.constructor.call(this, address);
|
||||
|
||||
this._enabled = true;
|
||||
this._hasImage = false;
|
||||
this._hasLabel =false;
|
||||
this._imageName = undefined;
|
||||
this._label = undefined;
|
||||
|
||||
this.addHandler("get");
|
||||
this.addHandler("activate");
|
||||
},
|
||||
"setImage": function(name) {
|
||||
if (this._hasImage) {
|
||||
if (this._imageName !== name) {
|
||||
this._image = name;
|
||||
var vc = new Vocabulary();
|
||||
vc.insert("image", new String(this._imageName));
|
||||
this.broadcast(vc, "changeImage");
|
||||
}
|
||||
} else {
|
||||
this._image = name;
|
||||
this._hasImage = true;
|
||||
var vc = new Vocabulary();
|
||||
vc.insert("image", new String(this._imageName));
|
||||
this.broadcast(vc, "setImage");
|
||||
}
|
||||
},
|
||||
"setEnabled": function(enabled) {
|
||||
if (enabled !== this._enabled) {
|
||||
this._enabled = enabled;
|
||||
var vc = new Vocabulary();
|
||||
vc.insert("enabled", new Boolean(this._enabled));
|
||||
this.broadcast(vc, "setEnabled");
|
||||
}
|
||||
},
|
||||
"setLabel": function(text) {
|
||||
if (this._hasLabel) {
|
||||
this._label.set(text);
|
||||
} else {
|
||||
this._label = new ModelString(this._address["+"](labelHop), text);
|
||||
this.addModel(this._label);
|
||||
var vc = new Vocabulary();
|
||||
vc.insert("hasLabel", new Boolean(true));
|
||||
vc.insert("label", this._label.getAddress());
|
||||
this.broadcast(vc, "setLabel");
|
||||
this._hasLabel = true;
|
||||
}
|
||||
},
|
||||
"_h_subscribe": function(ev) {
|
||||
Model.fn._h_subscribe.call(this, ev);
|
||||
|
||||
this._h_get(ev);
|
||||
},
|
||||
"_h_get": function(ev) {
|
||||
var vc = new Vocabulary();
|
||||
vc.insert("hasImage", new Boolean(this._hasImage));
|
||||
if (this._hasImage) {
|
||||
vc.insert("image", new String(this._imageName));
|
||||
}
|
||||
vc.insert("hasLabel", new Boolean(this._hasLabel));
|
||||
if (this._hasLabel) {
|
||||
vc.insert("label", this._label.getAddress());
|
||||
}
|
||||
vc.insert("enabled", new Boolean(this._enabled));
|
||||
|
||||
this.response(vc, "get", ev);
|
||||
},
|
||||
"_h_activate": function() {
|
||||
if (this._enabled) {
|
||||
this.trigger("activated");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var labelHop = new Address(["label"]);
|
||||
|
||||
module.exports = Button;
|
|
@ -299,8 +299,10 @@ Model.ModelType = {
|
|||
String: 0,
|
||||
List: 1,
|
||||
Vocabulary: 2,
|
||||
Image: 3,
|
||||
Model: 4,
|
||||
//Catalogue: 3,
|
||||
Image: 4,
|
||||
Button: 5,
|
||||
Model: 6,
|
||||
|
||||
Attributes: 50,
|
||||
|
||||
|
@ -310,7 +312,8 @@ Model.ModelType = {
|
|||
PageStorage: 103,
|
||||
PanesList: 104,
|
||||
Theme: 105,
|
||||
ThemeStorage: 106
|
||||
ThemeStorage: 106,
|
||||
Player: 107
|
||||
};
|
||||
|
||||
module.exports = Model;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue