      1 (function ($, rf) {
      2
      3     rf.ui = rf.ui || {};
      4
      5     rf.ui.InputBase = function(id, options) {
      6         $super.constructor.call(this, id);
      7         this.namespace = this.getNamespace() || "." + rf.Event.createNamespace(this.getName(), this.getId());
      8
      9         this.namespace = this.namespace || "." + rf.Event.createNamespace(this.name, this.id);
     10
     11         this.input = $(document.getElementById(id + "Input"));
     12         this.attachToDom();
     13
     14         var inputEventHandlers = {};
     15         inputEventHandlers["keydown" + this.namespace] = $.proxy(this.__keydownHandler, this);
     16         inputEventHandlers["blur" + this.namespace] = $.proxy(this.__blurHandler, this);
     17         inputEventHandlers["change" + this.namespace] = $.proxy(this.__changeHandler, this);
     18         inputEventHandlers["focus" + this.namespace] = $.proxy(this.__focusHandler, this);
     19         rf.Event.bind(this.input, inputEventHandlers, this);
     20     };
     21
     22     rf.BaseComponent.extend(rf.ui.InputBase);
     23
     24     // define super class link
     25     var $super = rf.ui.InputBase.$super;
     26
     27     $.extend(rf.ui.InputBase.prototype, ( function () {
     28
     29         return {
     30
     31             name : "inputBase",
     32
     33
     34             getName: function() {
     35                 return this.name;
     36             },
     37
     38             getNamespace: function() {
     39                 return this.namespace;
     40             },
     41
     42             __focusHandler: function(e) {
     43             },
     44
     45             __keydownHandler: function(e) {
     46             },
     47
     48             __blurHandler: function(e) {
     49             },
     50
     51             __changeHandler: function(e) {
     52             },
     53
     54             __setInputFocus: function() {
     55                 this.input.focus();
     56             },
     57
     58             __getValue: function() {
     59                 return this.input.val();
     60             },
     61
     62             __setValue: function(value) {
     63                 this.input.val(value);
     64                 if (this.defaultLabelClass) {
     65                     if (value == this.defaultLabel) {
     66                         this.input.addClass(this.defaultLabelClass);
     67                     } else {
     68                         this.input.removeClass(this.defaultLabelClass);
     69                     }
     70                 }
     71             },
     72
     73             getValue: function() {
     74                 return this.__getValue();
     75             },
     76
     77             setValue: function(value) {
     78                 this.__setValue(value);
     79             },
     80
     81             getInput: function() {
     82                 return this.input;
     83             },
     84
     85             getId: function() {
     86                 return    this.id;
     87             },
     88             destroy: function() {
     89                 rf.Event.unbindById(this.input, this.namespace);
     90                 this.input = null;
     91                 $super.destroy.call(this);
     92             }
     93         }
     94     })());
     95
     96 })(RichFaces.jQuery, window.RichFaces);