1 /** 2 * @fileoverview The XRX++ main class. 3 */ 4 5 goog.provide('xrx'); 6 7 goog.require('goog.dom'); 8 goog.require('xrx.bind'); 9 goog.require('xrx.console'); 10 goog.require('xrx.input'); 11 goog.require('xrx.instance'); 12 goog.require('xrx.markup'); 13 goog.require('xrx.output'); 14 goog.require('xrx.xpath'); 15 goog.require('xrx.xpath.DataType'); 16 goog.require('xrx.xpath.FunctionCall'); 17 goog.require('xrx.xpath.NodeSet'); 18 19 20 21 xrx.Namespace = { 22 XRX: xrx.xpath.declareNamespace('xrx', 'http://www.monasterium.net/NS/xrx') 23 }; 24 25 26 27 xrx.Function = { 28 INSTANCE: xrx.xpath.FunctionCall.createFunc('xrx:instance', 29 xrx.xpath.DataType.NODESET, true, true, true, 30 function(ctx, expr) { 31 var nodeset = new xrx.xpath.NodeSet(); 32 nodeset.add(xrx.Model[expr.evaluate(ctx)].document()); 33 34 return nodeset; 35 }, 1, 1) 36 }; 37 38 39 40 xrx.Model = {}; 41 42 43 44 xrx.View = {}; 45 46 47 48 xrx.install_ = function(className, component, cache) { 49 var element = goog.dom.getElementsByClass(className); 50 for(var i = 0, len = element.length; i < len; i++) { 51 var e = element[i]; 52 var cmp = new component(e); 53 cache[cmp.getId()] = cmp; 54 } 55 56 }; 57 58 59 60 xrx.install = function() { 61 xrx.install_('xrx-instance', xrx.instance, xrx.Model); 62 xrx.install_('xrx-bind', xrx.bind, xrx.Model); 63 xrx.install_('xrx-console', xrx.console, xrx.View); 64 xrx.install_('xrx-output', xrx.output, xrx.View); 65 xrx.install_('xrx-input', xrx.input, xrx.View); 66 };