X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2Feuphorik.js;h=d2cd248bc462e257a346f46985b269857a9de30e;hp=8c138417761f4cbf428c186a5b511a3211bc31df;hb=a427cabd1a5f3fba6650157913b113164d70ffc0;hpb=ff1b8889e37bdecb354caa1f330a3ce2cfa82519 diff --git a/js/euphorik.js b/js/euphorik.js index 8c13841..d2cd248 100755 --- a/js/euphorik.js +++ b/js/euphorik.js @@ -94,7 +94,35 @@ String.prototype.ltrim = function() { String.prototype.rtrim = function() { return this.replace(/\s+$/, ""); -} +} + + +/** + * Voir : http://www.coolpage.com/developer/javascript/Correct%20OOP%20for%20Javascript.html + * + * Exemple : + * + * function Mammal(name) { + * this.name = name; + * } + * + * Cat.Inherits(Mammal); + * function Cat(name) { + * this.Super(Mammal, name); + * } + */ +Object.prototype.Super = function(parent) { + if(arguments.length > 1) { + parent.apply( this, Array.prototype.slice.call( arguments, 1 ) ); + } else { + parent.call( this ); + } +} +Function.prototype.Inherits = function(parent) { + this.prototype = new parent(); + this.prototype.constructor = this; +} + ///////////////////////////////////////////////////////////////////////////////////////////////////