| 1 |
dojo.provide("dojox.lang.oo.general"); |
| 2 |
|
| 3 |
dojo.require("dojox.lang.oo.Decorator"); |
| 4 |
|
| 5 |
(function(){ |
| 6 |
var oo = dojox.lang.oo, md = oo.makeDecorator, oog = oo.general, |
| 7 |
isF = dojo.isFunction; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
oog.augment = md(function(name, newValue, oldValue){ |
| 12 |
|
| 13 |
|
| 14 |
return typeof oldValue == "undefined" ? newValue : oldValue; |
| 15 |
}); |
| 16 |
|
| 17 |
oog.override = md(function(name, newValue, oldValue){ |
| 18 |
|
| 19 |
|
| 20 |
return typeof oldValue != "undefined" ? newValue : oldValue; |
| 21 |
}); |
| 22 |
|
| 23 |
oog.shuffle = md(function(name, newValue, oldValue){ |
| 24 |
|
| 25 |
|
| 26 |
return isF(oldValue) ? |
| 27 |
function(){ |
| 28 |
return oldValue.apply(this, newValue.apply(this, arguments)); |
| 29 |
} : oldValue; |
| 30 |
}); |
| 31 |
|
| 32 |
oog.wrap = md(function(name, newValue, oldValue){ |
| 33 |
|
| 34 |
|
| 35 |
return function(){ return newValue.call(this, oldValue, arguments); }; |
| 36 |
}); |
| 37 |
|
| 38 |
oog.tap = md(function(name, newValue, oldValue){ |
| 39 |
|
| 40 |
|
| 41 |
return function(){ newValue.apply(this, arguments); return this; }; |
| 42 |
}); |
| 43 |
|
| 44 |
oog.before = md(function(name, newValue, oldValue){ |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
return isF(oldValue) ? |
| 49 |
function(){ |
| 50 |
newValue.apply(this, arguments); |
| 51 |
return oldValue.apply(this, arguments); |
| 52 |
} : newValue; |
| 53 |
}); |
| 54 |
|
| 55 |
oog.after = md(function(name, newValue, oldValue){ |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
return isF(oldValue) ? |
| 60 |
function(){ |
| 61 |
oldValue.apply(this, arguments); |
| 62 |
return newValue.apply(this, arguments); |
| 63 |
} : newValue; |
| 64 |
}); |
| 65 |
})(); |