Created
October 3, 2012 11:00
-
-
Save gabriel403/3826400 to your computer and use it in GitHub Desktop.
a simple base class for having setters and getters by default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(["dojo/_base/declare", "dojo/_base/lang", "gmk/library/utilities/string"], | |
function(declare, lang, strUtil){ | |
return declare([ ], { | |
get: function(varName) { | |
var retVal = null; | |
if ( "function" == typeof lang.getObject("get"+strUtil.ucfirst(varName), false, this) ) { | |
retVal = lang.getObject("get"+strUtil.ucfirst(varName), false, this)(); | |
} else { | |
retVal = lang.getObject(varName, false, this); | |
} | |
return retVal; | |
}, | |
set: function(varName, value) { | |
if ( "function" == typeof lang.getObject("set"+strUtil.ucfirst(varName), false, this) ) { | |
lang.getObject("set"+strUtil.ucfirst(varName), false, this)(value); | |
} else { | |
lang.setObject(varName, value, this); | |
} | |
return this; | |
} | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(["dojo/_base/declare", "gmk/library/base/mvc/view"], | |
function(declare, baseView){ | |
return declare([baseView], { | |
someVar: null, | |
someOtherVar: null, | |
constructor: function(props) { | |
this.set("someVar","somevalue"); | |
this.set("someOtherVar",5); | |
}, | |
setSomeOtherVar: function(value){ | |
this.someOtherVar = ++value; | |
} | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([], function(){ | |
return { | |
ucfirst: function(string) { | |
return string.charAt(0).toUpperCase() + string.slice(1); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(["dojo/_base/declare", "dojo/_base/lang", "gmk/library/base/getterSetterBase"], | |
function(declare, lang, getterSetterBase){ | |
return declare([getterSetterBase], { | |
setupDom: function() { | |
}, | |
setupDijits: function() { | |
}, | |
setupConnections: function() { | |
}, | |
init : function() { | |
this.setupDom(); | |
this.setupDijits(); | |
this.setupConnections(); | |
}, | |
constructor: function(props) { | |
lang.mixin(this, props); | |
this.init(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment