Commit 67d70673 by Иван Кубота

D.assign works similar to Object.assign, but subscribe to all callbacks. For…

D.assign works similar to Object.assign, but subscribe to all callbacks. For example if `onChange` presented — it would call obj.on('change', obj2.onChange)
parent afda31a8
...@@ -724,6 +724,32 @@ NS.apply = function(a,b) { ...@@ -724,6 +724,32 @@ NS.apply = function(a,b) {
}; };
//#end subscribe //#end subscribe
//#assign
D._protected = {on: 1, un: 1, fire: 1};
D.assign = function( obj ){
var i, _i, j, _j, name,
other = Array.prototype.slice.call(arguments, 1),
protected = obj._protected || D._protected;
for(j = 0, _j = other.length; j < _j; j++) {
var cfg = other[j]
for( i in cfg )
if( cfg.hasOwnProperty( i ) ) {
name = i.toLowerCase();
if( name in protected )
continue;
if( name.substr( 0, 2 ) === 'on' ) {
obj.on( name.substr( 2, 1 ).toLowerCase()+name.substr( 3 ), cfg[ i ]);
} else {
obj[ i ] = cfg[ i ];
}
}
}
return obj;
}
//#end assign
//#overlay //#overlay
D.overlay = { D.overlay = {
inited: false, inited: false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment