767003094c9794f0804c663a8abc131b86554999Satyen Desai// START WRAPPER: The YUI.add wrapper is added by the build system, when you use YUI Builder to build your component from the raw source in this file
767003094c9794f0804c663a8abc131b86554999Satyen Desai// YUI.add("myplugin", function(Y) {
767003094c9794f0804c663a8abc131b86554999Satyen Desai /* Any frequently used shortcuts, strings and constants */
767003094c9794f0804c663a8abc131b86554999Satyen Desai /* MyPlugin class constructor */
767003094c9794f0804c663a8abc131b86554999Satyen Desai function MyPlugin(config) {
767003094c9794f0804c663a8abc131b86554999Satyen Desai MyPlugin.superclass.constructor.apply(this, arguments);
767003094c9794f0804c663a8abc131b86554999Satyen Desai * Required NAME static field, to identify the class and
767003094c9794f0804c663a8abc131b86554999Satyen Desai * used as an event prefix, to generate class names etc. (set to the
767003094c9794f0804c663a8abc131b86554999Satyen Desai * class name in camel case).
767003094c9794f0804c663a8abc131b86554999Satyen Desai * Required NS static field, to identify the property on the host which will,
767003094c9794f0804c663a8abc131b86554999Satyen Desai * be used to refer to the plugin instance ( e.g. host.feature.doSomething() )
767003094c9794f0804c663a8abc131b86554999Satyen Desai * The attribute configuration for the plugin. This defines the core user facing state of the plugin
767003094c9794f0804c663a8abc131b86554999Satyen Desai value: "A" // The default value for attrA, used if the user does not set a value during construction.
767003094c9794f0804c663a8abc131b86554999Satyen Desai , valueFn: "_defAttrAVal" // Can be used as a substitute for "value", when you need access to "this" to set the default value.
767003094c9794f0804c663a8abc131b86554999Satyen Desai , setter: "_setAttrA" // Used to normalize attrA's value while during set. Refers to a prototype method, to make customization easier
767003094c9794f0804c663a8abc131b86554999Satyen Desai , getter: "_getAttrA" // Used to normalize attrA's value while during get. Refers to a prototype method, to make customization easier
767003094c9794f0804c663a8abc131b86554999Satyen Desai , validator: "_validateAttrA" // Used to validate attrA's value before updating it. Refers to a prototype method, to make customization easier
767003094c9794f0804c663a8abc131b86554999Satyen Desai , readOnly: true // Cannot be set by the end user. Can be set by the component developer at any time, using _set
767003094c9794f0804c663a8abc131b86554999Satyen Desai , writeOnce: true // Can only be set once by the end user (usually during construction). Can be set by the component developer at any time, using _set
767003094c9794f0804c663a8abc131b86554999Satyen Desai , lazyAdd: false // Add (configure) the attribute during initialization.
767003094c9794f0804c663a8abc131b86554999Satyen Desai // You only need to set lazyAdd to false if your attribute is
767003094c9794f0804c663a8abc131b86554999Satyen Desai // setting some other state in your setter which needs to be set during initialization
767003094c9794f0804c663a8abc131b86554999Satyen Desai // (not generally recommended - the setter should be used for normalization.
767003094c9794f0804c663a8abc131b86554999Satyen Desai // You should use listeners to update alternate state).
767003094c9794f0804c663a8abc131b86554999Satyen Desai , broadcast: 1 // Whether the attribute change event should be broadcast or not.
767003094c9794f0804c663a8abc131b86554999Satyen Desai // ... attrB, attrC, attrD ... attribute configurations.
767003094c9794f0804c663a8abc131b86554999Satyen Desai // Can also include attributes for the super class if you want to override or add configuration parameters
767003094c9794f0804c663a8abc131b86554999Satyen Desai /* MyPlugin extends the base Plugin.Base class */
767003094c9794f0804c663a8abc131b86554999Satyen Desai initializer: function() {
767003094c9794f0804c663a8abc131b86554999Satyen Desai * initializer is part of the lifecycle introduced by
767003094c9794f0804c663a8abc131b86554999Satyen Desai * the Base class. It is invoked during construction, when
767003094c9794f0804c663a8abc131b86554999Satyen Desai * the plugin is plugged into the host, and can be used to
767003094c9794f0804c663a8abc131b86554999Satyen Desai * register listeners, or inject logic before or after methods
767003094c9794f0804c663a8abc131b86554999Satyen Desai * on the host.
767003094c9794f0804c663a8abc131b86554999Satyen Desai * It does not need to invoke the superclass initializer.
767003094c9794f0804c663a8abc131b86554999Satyen Desai * init() will call initializer() for all classes in the hierarchy.
767003094c9794f0804c663a8abc131b86554999Satyen Desai this.beforeHostMethod("show", this._beforeHostShowMethod);
767003094c9794f0804c663a8abc131b86554999Satyen Desai this.afterHostMethod("show", this._afterHostShowMethod);
767003094c9794f0804c663a8abc131b86554999Satyen Desai this.onHostEvent("render", this._onHostRenderEvent);
767003094c9794f0804c663a8abc131b86554999Satyen Desai this.afterHostEvent("render", this._afterHostRenderEvent);
767003094c9794f0804c663a8abc131b86554999Satyen Desai destructor : function() {
767003094c9794f0804c663a8abc131b86554999Satyen Desai * destructor is part of the lifecycle introduced by
767003094c9794f0804c663a8abc131b86554999Satyen Desai * the Base class. It is invoked when the plugin is unplugged.
767003094c9794f0804c663a8abc131b86554999Satyen Desai * Any listeners registered using Plugin.Base's onHostEvent/afterHostEvent methods,
767003094c9794f0804c663a8abc131b86554999Satyen Desai * or any methods displaced using it's beforeHostMethod/afterHostMethod methods
767003094c9794f0804c663a8abc131b86554999Satyen Desai * will be detached/restored by Plugin.Base's destructor.
767003094c9794f0804c663a8abc131b86554999Satyen Desai * We only need to clean up anything we change on the host
767003094c9794f0804c663a8abc131b86554999Satyen Desai * It does not need to invoke the superclass destructor.
767003094c9794f0804c663a8abc131b86554999Satyen Desai * destroy() will call initializer() for all classes in the hierarchy.
767003094c9794f0804c663a8abc131b86554999Satyen Desai /* Supporting Methods */
767003094c9794f0804c663a8abc131b86554999Satyen Desai _onHostRenderEvent : function(e) {
767003094c9794f0804c663a8abc131b86554999Satyen Desai /* React on the host render event */
767003094c9794f0804c663a8abc131b86554999Satyen Desai _afterHostRenderEvent : function(e) {
767003094c9794f0804c663a8abc131b86554999Satyen Desai /* React after the host render event */
767003094c9794f0804c663a8abc131b86554999Satyen Desai _beforeHostShowMethod : function() {
767003094c9794f0804c663a8abc131b86554999Satyen Desai /* Inject logic before the host's show method is called. */
767003094c9794f0804c663a8abc131b86554999Satyen Desai _afterHostShowMethod : function() {
767003094c9794f0804c663a8abc131b86554999Satyen Desai /* Inject logic after the host's show method is called. */
767003094c9794f0804c663a8abc131b86554999Satyen Desai Y.namespace("Plugin.MyApp").MyPlugin = MyPlugin;
767003094c9794f0804c663a8abc131b86554999Satyen Desai// }, "3.1.0", {requires:["plugin"]});
767003094c9794f0804c663a8abc131b86554999Satyen Desai// END WRAPPER