minor tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-09-04 17:31:05 +04:00
parent b9e25f0c03
commit c8e9bbc006
2 changed files with 24 additions and 9 deletions

View File

@ -97,32 +97,44 @@ proxyMethods(ClientPrototype)
// XXX auto apply this...
function chainSelfAttrMethods(cls, attr, meth){
function chainSelfAttrMethod(cls, attr, name, func){
return function(){
// NOTE: this is super, python-style but without multiple
// inheritance...
// ...that last part makes this more of a code reuse
// than a programming tool...
cls.__proto__[meth].apply(this, arguments)
cls.__proto__[name].apply(this, arguments)
// call the encapsulated method...
this[attr][meth].apply(this[attr], arguments)
this[attr][name].apply(this[attr], arguments)
if(func != null){
return func.apply(this, arguments)
}
return this
}),
}
function chainSelfAttrMethods(obj, map){
for(var attr in map){
var methods = map[attr]
for(var name in methods){
obj[name] = doc(methods[name], chainSelfAttrMethod(obj, attr, name))
}
}
}
var ViewerPrototype = {
// this expects the folowing attrs:
//
// .ribbons
//
focusImage: doc('Focus image',
chainSelfAttrMethods(ViewerPrototype, 'ribbons', 'focusImage')),
focusRibbon: doc('Focus ribbon',
chainSelfAttrMethods(ViewerPrototype, 'ribbons', 'focusRibbon')),
}
chainSelfAttrMethods(ViewerPrototype, {
ribbons: {
focusImage: 'Focus image',
focusRibbon: 'Focus ribbon',
},
})
ViewerPrototype.__proto__ = ClientPrototype

View File

@ -3,6 +3,9 @@
* Data generation 4 implementation.
*
*
* XXX might be a good idea to make a set of universal argument parsing
* utils...
*
**********************************************************************/
define(function(require){ var module = {}