toloframework
Version:
Javascript/HTML/CSS compiler for Firefox OS or nodewebkit apps using modules in the nodejs style.
166 lines (159 loc) • 6.76 kB
JavaScript
/**********************************************************************
require( 'require' )
-----------------------------------------------------------------------
@example
var Path = require("node://path"); // Only in NodeJS/NW.js environment.
var Button = require("tfw.button");
**********************************************************************/
var require = function() {
var modules = {};
var definitions = {};
var nodejs_require = typeof window.require === 'function' ? window.require : null;
var f = function(id, body) {
if( id.substr( 0, 7 ) == 'node://' ) {
// Calling for a NodeJS module.
if( !nodejs_require ) {
throw Error( "[require] NodeJS is not available to load module `" + id + "`!" );
}
return nodejs_require( id.substr( 7 ) );
}
if( typeof body === 'function' ) {
definitions[id] = body;
return;
}
var mod;
body = definitions[id];
if (typeof body === 'undefined') {
var err = new Error("Required module is missing: " + id);
console.error(err.stack);
throw err;
}
mod = modules[id];
if (typeof mod === 'undefined') {
mod = {exports: {}};
var exports = mod.exports;
body(exports, mod);
modules[id] = mod.exports;
mod = mod.exports;
//console.log("Module initialized: " + id);
}
return mod;
};
return f;
}();
function addListener(e,l) {
if (window.addEventListener) {
window.addEventListener(e,l,false);
} else {
window.attachEvent('on' + e, l);
}
};
addListener(
'DOMContentLoaded',
function() {
document.body.parentNode.$data = {};
// Attach controllers.
var W = require('x-widget');
W('wdg.label15', 'wdg.label', {"value": "ok"})
W('wdg.label16', 'wdg.label', {"value": "icon"})
W('wdg.label17', 'wdg.label', {"value": "false"})
W('wdg.label18', 'wdg.label', {"value": "2em"})
W('wdg.label19', 'wdg.label', {"value": "#000"})
W('wdg.label20', 'wdg.label', {"value": "#fff"})
W('wdg.label21', 'wdg.label', {"value": "#777"})
W('wdg.label22', 'wdg.label', {"value": "#f00"})
W('wdg.label23', 'wdg.label', {"value": "#0f0"})
W('wdg.label24', 'wdg.label', {"value": "#00f"})
W('wdg.label25', 'wdg.label', {"value": "false"})
W('wdg.label26', 'wdg.label', {"value": "true"})
W('wdg.icon27', 'wdg.icon', {
content: "ok",
value: "icon",
rotate: "false",
size: "2em",
color0: "#000",
color1: "#fff",
color2: "#777",
color3: "#f00",
color4: "#0f0",
color5: "#00f",
wide: "false",
visible: "true"})
W('wdg.icon28', 'wdg.icon', {
content: "ok",
value: "icon",
rotate: "false",
size: "2em",
color0: "#000",
color1: "#fff",
color2: "#777",
color3: "#f00",
color4: "#0f0",
color5: "#00f",
wide: "false",
visible: "true"})
W('txtContent', 'wdg.area', {
label: "content",
value: "ok",
wide: "true"})
W('txtSize', 'wdg.text', {
label: "size",
value: "2em",
wide: "true"})
W('txtValue', 'wdg.text', {
label: "value",
value: "icon",
wide: "true"})
W('chkRotate', 'wdg.checkbox', {
text: "rotate",
value: "false",
wide: "true"})
W('txtColor0', 'wdg.text', {
label: "color0",
value: "#000",
wide: "true"})
W('txtColor1', 'wdg.text', {
label: "color1",
value: "#fff",
wide: "true"})
W('txtColor2', 'wdg.text', {
label: "color2",
value: "#777",
wide: "true"})
W('txtColor3', 'wdg.text', {
label: "color3",
value: "#f00",
wide: "true"})
W('txtColor4', 'wdg.text', {
label: "color4",
value: "#0f0",
wide: "true"})
W('txtColor5', 'wdg.text', {
label: "color5",
value: "#00f",
wide: "true"})
W('chkWide', 'wdg.checkbox', {
text: "wide",
value: "false",
wide: "true"})
W('chkVisible', 'wdg.checkbox', {
text: "visible",
value: "true",
wide: "true"})
W('help.wdg.icon29', 'help.wdg.icon', {})
W.bind('wdg.label15',{"value":{"B":[["txtContent","action"]]}});
W.bind('wdg.label16',{"value":{"B":[["txtValue","action"]]}});
W.bind('wdg.label17',{"value":{"B":[["chkRotate","action"]]}});
W.bind('wdg.label18',{"value":{"B":[["txtSize","action"]]}});
W.bind('wdg.label19',{"value":{"B":[["txtColor0","action"]]}});
W.bind('wdg.label20',{"value":{"B":[["txtColor1","action"]]}});
W.bind('wdg.label21',{"value":{"B":[["txtColor2","action"]]}});
W.bind('wdg.label22',{"value":{"B":[["txtColor3","action"]]}});
W.bind('wdg.label23',{"value":{"B":[["txtColor4","action"]]}});
W.bind('wdg.label24',{"value":{"B":[["txtColor5","action"]]}});
W.bind('wdg.label25',{"value":{"B":[["chkWide","action"]]}});
W.bind('wdg.label26',{"value":{"B":[["chkVisible","action"]]}});
W.bind('wdg.icon27',{"content":{"B":[["txtContent","action"]]},"value":{"B":[["txtValue","action"]]},"rotate":{"B":[["chkRotate","action"]]},"size":{"B":[["txtSize","action"]]},"color0":{"B":[["txtColor0","action"]]},"color1":{"B":[["txtColor1","action"]]},"color2":{"B":[["txtColor2","action"]]},"color3":{"B":[["txtColor3","action"]]},"color4":{"B":[["txtColor4","action"]]},"color5":{"B":[["txtColor5","action"]]},"wide":{"B":[["chkWide","action"]]},"visible":{"B":[["chkVisible","action"]]}});
W.bind('wdg.icon28',{"content":{"B":[["txtContent","action"]]},"value":{"B":[["txtValue","action"]]},"rotate":{"B":[["chkRotate","action"]]},"size":{"B":[["txtSize","action"]]},"color0":{"B":[["txtColor0","action"]]},"color1":{"B":[["txtColor1","action"]]},"color2":{"B":[["txtColor2","action"]]},"color3":{"B":[["txtColor3","action"]]},"color4":{"B":[["txtColor4","action"]]},"color5":{"B":[["txtColor5","action"]]},"wide":{"B":[["chkWide","action"]]},"visible":{"B":[["chkVisible","action"]]}});
}
);