source: Dev/branches/rest-dojo-ui/client/dojox/mvc/_patches.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1define([
2        "dojo/_base/lang",
3        "dojo/_base/array",
4        "dijit/_WidgetBase",
5        "./_DataBindingMixin",
6        "dijit/form/ValidationTextBox",
7        "dijit/form/NumberTextBox"
8], function(lang, array, wb, dbm, vtb, ntb){
9        /*=====
10                vtb = dijit.form.ValidationTextBox;
11                ntb = dijit.form.NumberTextBox;
12                dbm = dojox.mvc._DataBindingMixin;
13                wb = dijit._WidgetBase;
14        =====*/
15
16        //Apply the data binding mixin to all dijits, see mixin class description for details
17        lang.extend(wb, new dbm());
18
19        // monkey patch dijit._WidgetBase.startup to get data binds set up
20        var oldWidgetBaseStartup = wb.prototype.startup;
21        wb.prototype.startup = function(){
22                this._dbstartup();
23                oldWidgetBaseStartup.apply(this);
24        };
25
26        // monkey patch dijit._WidgetBase.destroy to remove watches setup in _DataBindingMixin
27        var oldWidgetBaseDestroy = wb.prototype.destroy;
28        wb.prototype.destroy = function(/*Boolean*/ preserveDom){
29                if(this._modelWatchHandles){
30                        array.forEach(this._modelWatchHandles, function(h){ h.unwatch(); });
31                }
32                if(this._viewWatchHandles){
33                        array.forEach(this._viewWatchHandles, function(h){ h.unwatch(); });
34                }
35                oldWidgetBaseDestroy.apply(this, [preserveDom]);               
36        };
37
38        // monkey patch dijit.form.ValidationTextBox.isValid to check this.inherited for isValid
39        var oldValidationTextBoxIsValid = vtb.prototype.isValid;
40        vtb.prototype.isValid = function(/*Boolean*/ isFocused){
41                return (this.inherited("isValid", arguments) !== false && oldValidationTextBoxIsValid.apply(this, [isFocused]));
42        };
43
44        // monkey patch dijit.form.NumberTextBox.isValid to check this.inherited for isValid
45        var oldNumberTextBoxIsValid = ntb.prototype.isValid;
46        ntb.prototype.isValid = function(/*Boolean*/ isFocused){
47                return (this.inherited("isValid", arguments) !== false && oldNumberTextBoxIsValid.apply(this, [isFocused]));
48        };
49});
Note: See TracBrowser for help on using the repository browser.