Revision: 51498
Updated Code
at November 21, 2011 22:26 by casperskovgaard
Updated Code
var MYNAMESPACE = YAHOO.namespace("mynamespace"); //CLASS: MYNAMESPACE.MyClass (function() { // private var that = null; var priv1 = "123"; var priv2 = "ABC"; var privMethod = function () { priv1 += "_priv"; }; // constructor MYNAMESPACE.MyClass = function(par1, par2){ that = this; priv1 += par1; priv2 += par2; privMethod(); this.prop1 += par1; }; // public MYNAMESPACE.MyClass.prototype = { // events onClassReady : new YAHOO.util.CustomEvent("onClassReady"), onPubMethod1Loaded : new YAHOO.util.CustomEvent("onPubMethod1Loaded"), // properties prop1 : "Test1", prop2 : "999", // methods pubMethod1: function(p1){ this.onPubMethod1Loaded.fire(this.prop1, this.prop2); return this.prop1 + priv1 + p1; }, pubMethod2: function(p1){ } } // static MYNAMESPACE.MyClass.statMethod = function () { YAHOO.log(this); } })(); MYNAMESPACE.MyClass.statMethod(); // function () var myObject = new MYNAMESPACE.MyClass("_kkk", "_ppp"); myObject.onPubMethod1Loaded.subscribe(function (type, args, me) { YAHOO.log(this); // window YAHOO.log(type); // onPubMethod1Loaded YAHOO.log(args); // ["Test1_kkk", "999"] YAHOO.log(me); // Object }, myObject); YAHOO.log(myObject.prop1); YAHOO.log(myObject.pubMethod1("ioioi"));
Revision: 51497
Updated Code
at November 18, 2011 20:51 by casperskovgaard
Updated Code
(function () { // private functions var priv1 = "private1"; // Constructor MyNamespace.myClass = function () { priv1 += "23"; this.function2(); }; // assigning fields and method to global object MyNamespace.myClass.prototype = { function1 : function () { //alert(priv1) }, function2 : function () { //alert(123) } }; })(); var testClass = new MyNamespace.myClass(); testClass.function1();
Revision: 51496
Updated Code
at September 27, 2011 17:02 by casperskovgaard
Updated Code
(function() { // private functions var priv1 = "private1"; // Constructor MyNamespace.myClass = function() { priv1 += "23"; this.function2(); } // assigning fields and method to global object MyNamespace.myClass.prototype = { function1 : function() {alert(priv1)}, function2 : function() {alert(123)} } })(); var testClass = new NPCT.myClass(); testClass.function1();
Revision: 51495
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 27, 2011 00:10 by casperskovgaard
Initial Code
(function() { // private functions var priv1 = "private1"; // Constructor MyNamespace.myClass = function() { priv1 += "23"; } // assigning fields and method to global object MyNamespace.myClass.prototype = { function1 : function() {alert(priv1)}, function2 : function() {alert(123)} } })(); var testClass = new NPCT.myClass(); testClass.function1();
Initial URL
Initial Description
Initial Title
Javascript Object Oriented Template
Initial Tags
class
Initial Language
JavaScript