Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / examples / ux / TabCloseMenu.js
similarity index 73%
rename from examples/tabs/TabCloseMenu.js
rename to examples/ux/TabCloseMenu.js
index bddae50..9c6a1aa 100644 (file)
@@ -1,24 +1,27 @@
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
+/*!
+ * Ext JS Library 3.0.0
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+/**\r
+ * @class Ext.ux.TabCloseMenu\r
+ * @extends Object \r
+ * Plugin (ptype = 'tabclosemenu') for adding a close context menu to tabs.\r
  * \r
- * http://extjs.com/license\r
+ * @ptype tabclosemenu\r
  */\r
-\r
-\r
-// Very simple plugin for adding a close context menu to tabs\r
-\r
 Ext.ux.TabCloseMenu = function(){\r
     var tabs, menu, ctxItem;\r
     this.init = function(tp){\r
         tabs = tp;\r
         tabs.on('contextmenu', onContextMenu);\r
-    }\r
+    };\r
 \r
     function onContextMenu(ts, item, e){\r
         if(!menu){ // create context menu on first right click\r
-            menu = new Ext.menu.Menu([{\r
+            menu = new Ext.menu.Menu({            \r
+            items: [{\r
                 id: tabs.id + '-close',\r
                 text: 'Close Tab',\r
                 handler : function(){\r
@@ -34,7 +37,7 @@ Ext.ux.TabCloseMenu = function(){
                         }\r
                     });\r
                 }\r
-            }]);\r
+            }]});\r
         }\r
         ctxItem = item;\r
         var items = menu.items;\r
@@ -47,6 +50,9 @@ Ext.ux.TabCloseMenu = function(){
             }\r
         });\r
         items.get(tabs.id + '-close-others').setDisabled(disableOthers);\r
+       e.stopEvent();\r
         menu.showAt(e.getPoint());\r
     }\r
-};
\ No newline at end of file
+};\r
+\r
+Ext.preg('tabclosemenu', Ext.ux.TabCloseMenu);\r