1 /** 2 * @fileoverview A class which represents the view of 3 * the model-view-controller. 4 */ 5 6 goog.provide('xrx.view'); 7 8 9 goog.require('goog.string'); 10 goog.require('xrx.control'); 11 12 13 14 /** 15 * @constructor 16 */ 17 xrx.view = function(element) { 18 19 20 21 goog.base(this, element); 22 23 24 25 this.createDom(); 26 27 28 29 this.refresh(); 30 }; 31 goog.inherits(xrx.view, xrx.control); 32 33 34 35 xrx.view.prototype.eventBeforeChange = goog.abstractMethod; 36 37 38 39 xrx.view.prototype.eventFocus = goog.abstractMethod; 40 41 42 43 xrx.view.prototype.getValue = goog.abstractMethod; 44 45 46 47 xrx.view.prototype.setFocus = goog.abstractMethod; 48 49 50 51 xrx.view.prototype.refresh = goog.abstractMethod; 52 53 54 55 xrx.view.classes = [ 56 'xrx-console', 57 'xrx-input', 58 'xrx-output', 59 'xrx-textarea', 60 'xrx-richxml', 61 'xrx-richxml-tagname' 62 ]; 63 64 65 66 xrx.view.addClass = function(name) { 67 68 if (goog.string.startsWith(name, 'xrx-')) { 69 throw Error('Class names starting with "xrx-" are reserved' + 70 'for built-in components.'); 71 } 72 xrx.view.classes.push(name); 73 }; 74 75 76 xrx.view.components_ = {}; 77 78 79 80 xrx.view.addComponent = function(id, component) { 81 xrx.view.components_[id] = component; 82 }; 83 84 85 86 xrx.view.getComponent = function(id) { 87 return xrx.view.components_[id]; 88 }; 89 90 91 92 xrx.view.getComponents = function() { 93 return xrx.view.components_; 94 }; 95 96 97