Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / AbstractPlugin.js
diff --git a/src/AbstractPlugin.js b/src/AbstractPlugin.js
new file mode 100644 (file)
index 0000000..bc3ebef
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ * @class Ext.AbstractPlugin
+ * @extends Object
+ *
+ * Plugins are injected 
+ */
+Ext.define('Ext.AbstractPlugin', {
+    disabled: false,
+    
+    constructor: function(config) {
+        //<debug>
+        if (!config.cmp && Ext.global.console) {
+            Ext.global.console.warn("Attempted to attach a plugin ");
+        }
+        //</debug>
+        Ext.apply(this, config);
+    },
+    
+    getCmp: function() {
+        return this.cmp;
+    },
+
+    /**
+     * The init method is invoked after initComponent has been run for the
+     * component which we are injecting the plugin into.
+     */
+    init: Ext.emptyFn,
+
+    /**
+     * The destroy method is invoked by the owning Component at the time the Component is being destroyed.
+     * Use this method to clean up an resources.
+     */
+    destroy: Ext.emptyFn,
+
+    /**
+     * Enable the plugin and set the disabled flag to false.
+     */
+    enable: function() {
+        this.disabled = false;
+    },
+
+    /**
+     * Disable the plugin and set the disabled flag to true.
+     */
+    disable: function() {
+        this.disabled = true;
+    }
+});