UNPKG

toloframework

Version:

Javascript/HTML/CSS compiler for Firefox OS or nodewebkit apps using modules in the nodejs style.

137 lines (130 loc) 5.35 kB
/********************************************************************** 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.label0', 'wdg.label', {"value": "OK"}) W('wdg.label1', 'wdg.label', {"value": "ok"}) W('wdg.label2', 'wdg.label', {"value": "standard"}) W('wdg.label3', 'wdg.label', {"value": "button"}) W('wdg.label4', 'wdg.label', {"value": "false"}) W('wdg.label5', 'wdg.label', {"value": "true"}) W('wdg.label6', 'wdg.label', {"value": "false"}) W('wdg.label7', 'wdg.label', {"value": "true"}) W('btn', 'wdg.button', { text: "OK", icon: "ok", type: "standard", value: "button", small: "false", enabled: "true", wide: "false", visible: "true"}) W('wdg.button8', 'wdg.button', { text: "OK", icon: "ok", type: "standard", value: "button", small: "false", enabled: "true", wide: "false", visible: "true"}) W('txtText', 'wdg.text', { label: "text", value: "OK", wide: "true"}) W('txtType', 'wdg.text', { label: "type", value: "standard", list: "standard, simple, warning, shadow, special", wide: "true"}) W('txtIcon', 'wdg.text', { label: "icon", value: "ok", wide: "true", list: "ok, cancel, close, menu"}) W('txtValue', 'wdg.text', { label: "value", value: "button", wide: "true"}) W('chkSmall', 'wdg.checkbox', { text: "small", value: "false", wide: "true"}) W('chkEnabled', 'wdg.checkbox', { text: "enabled", value: "true", wide: "true"}) W('chkWide', 'wdg.checkbox', { text: "wide", value: "false", wide: "true"}) W('chkVisible', 'wdg.checkbox', { text: "visible", value: "true", wide: "true"}) W('wdg.label9', 'wdg.label', {"value": ""}) W.bind('wdg.label0',{"value":{"B":[["txtText","action"]]}}); W.bind('wdg.label1',{"value":{"B":[["txtIcon","action"]]}}); W.bind('wdg.label2',{"value":{"B":[["txtType","action"]]}}); W.bind('wdg.label3',{"value":{"B":[["txtValue","action"]]}}); W.bind('wdg.label4',{"value":{"B":[["chkSmall","action"]]}}); W.bind('wdg.label5',{"value":{"B":[["chkEnabled","action"]]}}); W.bind('wdg.label6',{"value":{"B":[["chkWide","action"]]}}); W.bind('wdg.label7',{"value":{"B":[["chkVisible","action"]]}}); W.bind('btn',{"text":{"B":[["txtText","action"]]},"icon":{"B":[["txtIcon","action"]]},"type":{"B":[["txtType","action"]]},"value":{"B":[["txtValue","action"]]},"small":{"B":[["chkSmall","action"]]},"enabled":{"B":[["chkEnabled","action"]]},"wide":{"B":[["chkWide","action"]]},"visible":{"B":[["chkVisible","action"]]}}); W.bind('wdg.button8',{"text":{"B":[["txtText","action"]]},"icon":{"B":[["txtIcon","action"]]},"type":{"B":[["txtType","action"]]},"value":{"B":[["txtValue","action"]]},"small":{"B":[["chkSmall","action"]]},"enabled":{"B":[["chkEnabled","action"]]},"wide":{"B":[["chkWide","action"]]},"visible":{"B":[["chkVisible","action"]]}}); W.bind('wdg.label9',{"value":{"B":[["btn","action"]]}}); } );