X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/2e847cf21b8ab9d15fa167b315ca5b2fa92638fc..6746dc89c47ed01b165cc1152533605f97eb8e8d:/examples/menu/actions.js?ds=sidebyside diff --git a/examples/menu/actions.js b/examples/menu/actions.js index d5701909..03470a85 100644 --- a/examples/menu/actions.js +++ b/examples/menu/actions.js @@ -1,44 +1,58 @@ -/*! - * Ext JS Library 3.1.1 - * Copyright(c) 2006-2010 Ext JS, LLC - * licensing@extjs.com - * http://www.extjs.com/license - */ -Ext.onReady(function(){ - // The action - var action = new Ext.Action({ - text: 'Action 1', - handler: function(){ - Ext.example.msg('Click','You clicked on "Action 1".'); - }, - iconCls: 'blist' - }); +/* +This file is part of Ext JS 4 - var panel = new Ext.Panel({ - title: 'Actions', - width:600, - height:300, - bodyStyle: 'padding:10px;', // lazy inline style +Copyright (c) 2011 Sencha Inc - tbar: [ - action, { // <-- Add the action directly to a toolbar - text: 'Action Menu', - menu: [action] // <-- Add the action directly to a menu - } - ], +Contact: http://www.sencha.com/contact - items: [ - new Ext.Button(action) // <-- Add the action as a button - ], +GNU General Public License Usage +This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. - renderTo: Ext.getBody() - }); +If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact. - var tb = panel.getTopToolbar(); - // Buttons added to the toolbar of the Panel above - // to test/demo doing group operations with an action - tb.add('->', { +*/ +Ext.require([ + 'Ext.panel.Panel', + 'Ext.Action', + 'Ext.button.Button', + 'Ext.window.MessageBox' +]); + +Ext.onReady(function(){ + var action = Ext.create('Ext.Action', { + text: 'Action 1', + iconCls: 'icon-add', + handler: function(){ + Ext.example.msg('Click', 'You clicked on "Action 1".'); + } + }); + + var panel = Ext.create('Ext.panel.Panel', { + title: 'Actions', + renderTo: document.body, + width: 600, + height: 300, + bodyPadding: 10, + dockedItems: { + itemId: 'toolbar', + xtype: 'toolbar', + items: [ + action, // Add the action directly to a toolbar + { + text: 'Action menu', + menu: [action] // Add the action directly to a menu + } + ] + }, + items: Ext.create('Ext.button.Button', action) // Add the action as a button + }); + + /* + * Add toolbar items dynamically after creation + */ + var toolbar = panel.child('#toolbar'); + toolbar.add('->', { text: 'Disable', handler: function(){ action.setDisabled(!action.isDisabled()); @@ -59,8 +73,8 @@ Ext.onReady(function(){ }, { text: 'Change Icon', handler: function(){ - action.setIconClass(action.getIconClass() == 'blist' ? 'bmenu' : 'blist'); + action.setIconCls(action.getIconCls() == 'icon-add' ? 'icon-edit' : 'icon-add'); } }); - tb.doLayout(); -}); \ No newline at end of file +}); +