WinJS.Class
define: function define(constructor, instanceMembers, staticMembers) { /// /// /// Defines a class using the given constructor and the specified instance members. /// ////// A constructor function that is used to instantiate this class. /// ////// The set of instance fields, properties, and methods made available on the class. /// ////// The set of static fields, properties, and methods made available on the class. /// /// /// The newly-defined class. /// /// constructor = constructor || function () { }; WinJS.Utilities.markSupportedForProcessing(constructor); if (instanceMembers) { initializeProperties(constructor.prototype, instanceMembers); } if (staticMembers) { initializeProperties(constructor, staticMembers); } return constructor; }
derive: function derive(baseClass, constructor, instanceMembers, staticMembers) { /// /// /// Creates a sub-class based on the supplied baseClass parameter, using prototypal inheritance. /// /// /// The class to inherit from. /// /// /// A constructor function that is used to instantiate this class. /// /// /// The set of instance fields, properties, and methods to be made available on the class. /// /// /// The set of static fields, properties, and methods to be made available on the class. /// /// /// The newly-defined class. /// /// if (baseClass) { constructor = constructor || function () { }; var basePrototype = baseClass.prototype; constructor.prototype = Object.create(basePrototype); WinJS.Utilities.markSupportedForProcessing(constructor); Object.defineProperty(constructor.prototype, "constructor", { value: constructor, writable: true, configurable: true, enumerable: true }); if (instanceMembers) { initializeProperties(constructor.prototype, instanceMembers); } if (staticMembers) { initializeProperties(constructor, staticMembers); } return constructor; } else { return define(constructor, instanceMembers, staticMembers); } }
mix: function mix(constructor) { /// /// /// Defines a class using the given constructor and the union of the set of instance members /// specified by all the mixin objects. The mixin parameter list is of variable length. /// /// /// A constructor function that is used to instantiate this class. /// /// /// The newly-defined class. /// /// constructor = constructor || function () { }; var i, len; for (i = 1, len = arguments.length; i < len; i++) { initializeProperties(constructor.prototype, arguments[i]); } return constructor; }