public
Created

  • Download Gist
Element.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
// Upgrade from MooTools Core 1.2 to MooTools Core 1.3
//
// Brings compatibility for Element.set and Element.get with multipe arguments.
// Use at your own risk; if cou can - fix your code and do not use this script.
// -- @cpojer
 
(function(){
 
Element.implement({
// from 1.2
set: function(prop, value){
switch (typeOf(prop)){
case 'object':
for (var p in prop) this.set(p, prop[p]);
break;
case 'string':
var property = Element.Properties[prop];
(property && property.set) ? property.set.apply(this, Array.slice(arguments, 1)) : this.setProperty(prop, value);
}
return this;
},
 
get: function(prop){
var property = Element.Properties[prop];
return (property && property.get) ? property.get.apply(this, Array.slice(arguments, 1)) : this.getProperty(prop);
}
});
 
var props = Element.Properties;
 
var wrap = function(prop){
if (!props[prop]) return wrap;
var getter = props[prop].get;
props[prop].get = function(options){
if (options) this.set(prop, options);
return getter.call(this);
};
return wrap;
};
 
wrap('tween')('morph')('load')('send');
 
})(Element.Properties);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.