123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- if(!dojo._hasResource["dojox.lang.observable"]){
- dojo._hasResource["dojox.lang.observable"] = true;
- dojo.provide("dojox.lang.observable");
- dojo.experimental("dojox.lang.observable");
- dojox.lang.observable = function(/*Object*/wrapped,/*function*/onRead,/*function*/onWrite,/*function*/onInvoke){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return dojox.lang.makeObservable(onRead,onWrite,onInvoke)(wrapped);
- }
- dojox.lang.makeObservable = function(/*function*/onRead,/*function*/onWrite,/*function*/onInvoke,/*Object*/hiddenFunctions){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- hiddenFunctions = hiddenFunctions || {};
- onInvoke = onInvoke || function(scope,obj,method,args){
-
- return obj[method].apply(scope,args);
- };
- function makeInvoker(scope,wrapped,i){
- return function(){
-
- return onInvoke(scope,wrapped,i,arguments);
- };
- }
-
- if(dojox.lang.lettableWin){
- var factory = dojox.lang.makeObservable;
- factory.inc = (factory.inc || 0) + 1;
-
- var getName = "gettable_"+factory.inc;
- dojox.lang.lettableWin[getName] = onRead;
- var setName = "settable_"+factory.inc;
- dojox.lang.lettableWin[setName] = onWrite;
- var cache = {};
- return function(wrapped){
- if(wrapped.__observable){
- return wrapped.__observable;
- }
- if(wrapped.data__){
- throw new Error("Can wrap an object that is already wrapped");
- }
-
- var props = [], i, l;
- for(i in hiddenFunctions){
- props.push(i);
- }
- var vbReservedWords = {type:1,event:1};
-
- for(i in wrapped){
- if(i.match(/^[a-zA-Z][\w\$_]*$/) && !(i in hiddenFunctions) && !(i in vbReservedWords)){
- props.push(i);
- }
- }
- var signature = props.join(",");
- var prop,clazz = cache[signature];
- if(!clazz){
- var tname = "dj_lettable_"+(factory.inc++);
- var gtname = tname+"_dj_getter";
- var cParts = [
- "Class "+tname,
- " Public data__"
- ];
- for(i=0, l=props.length; i<l; i++){
- prop = props[i];
- var type = typeof wrapped[prop];
- if(type == 'function' || hiddenFunctions[prop]){
- cParts.push(" Public " + prop);
- }else if(type != 'object'){
- cParts.push(
- " Public Property Let "+prop+"(val)",
- " Call "+setName+"(me.data__,\""+prop+"\",val)",
- " End Property",
- " Public Property Get "+prop,
- " "+prop+" = "+getName+"(me.data__,\""+prop+"\")",
- " End Property");
- }
- }
- cParts.push("End Class");
- cParts.push(
- "Function "+gtname+"()",
- " Dim tmp",
- " Set tmp = New "+tname,
- " Set "+gtname+" = tmp",
- "End Function");
- dojox.lang.lettableWin.vbEval(cParts.join("\n"));
-
-
- cache[signature] = clazz = function(){
- return dojox.lang.lettableWin.construct(gtname);
- };
- }
- console.log("starting5");
- var newObj = clazz();
- newObj.data__ = wrapped;
- console.log("starting6");
- try {
- wrapped.__observable = newObj;
- } catch(e){
- }
- for(i = 0, l = props.length; i < l; i++){
- prop = props[i];
- try {
- var val = wrapped[prop];
- }
- catch(e){
- console.log("error ",prop,e);
- }
- if(typeof val == 'function' || hiddenFunctions[prop]){
- newObj[prop] = makeInvoker(newObj,wrapped,prop);
- }
- }
- return newObj;
- };
- }else{
- return function(wrapped){
- if(wrapped.__observable){
- return wrapped.__observable;
- }
- var newObj = wrapped instanceof Array ? [] : {};
- newObj.data__ = wrapped;
- for(var i in wrapped){
- if(i.charAt(0) != '_'){
- if(typeof wrapped[i] == 'function'){
- newObj[i] = makeInvoker(newObj,wrapped,i);
- }else if(typeof wrapped[i] != 'object'){
- (function(i){
- newObj.__defineGetter__(i,function(){
- return onRead(wrapped,i);
- });
- newObj.__defineSetter__(i,function(value){
- return onWrite(wrapped,i,value);
- });
- })(i);
- }
- }
- }
- for(i in hiddenFunctions){
- newObj[i] = makeInvoker(newObj,wrapped,i);
- }
- wrapped.__observable = newObj;
- return newObj;
- };
- }
- };
- if(!{}.__defineGetter__){
- if(dojo.isIE){
-
-
-
-
-
-
- var frame;
- if(document.body){
- frame = document.createElement("iframe");
- document.body.appendChild(frame);
- }else{
- document.write("<iframe id='dj_vb_eval_frame'></iframe>");
- frame = document.getElementById("dj_vb_eval_frame");
- }
- frame.style.display="none";
- var doc = frame.contentWindow.document;
- dojox.lang.lettableWin = frame.contentWindow;
- doc.write('<html><head><script language="VBScript" type="text/VBScript">' +
- 'Function vb_global_eval(code)' +
- 'ExecuteGlobal(code)' +
- 'End Function' +
- '</script>' +
- '<script type="text/javascript">' +
- 'function vbEval(code){ \n' +
- 'return vb_global_eval(code);' +
- '}' +
- 'function construct(name){ \n' +
- 'return window[name]();' +
- '}' +
- '</script>' +
- '</head><body>vb-eval</body></html>');
- doc.close();
- }else{
- throw new Error("This browser does not support getters and setters");
- }
- }
- dojox.lang.ReadOnlyProxy =
- dojox.lang.makeObservable(function(obj,i){
- return obj[i];
- },function(obj,i,value){
-
- });
- }
|