+<!DOCTYPE html>
<html>
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+ <style type="text/css">
+ .highlight { display: block; background-color: #ddd; }
+ </style>
+ <script type="text/javascript">
+ function highlight() {
+ document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+ }
+ </script>
</head>
-<body onload="prettyPrint();">
- <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.2.2
- * Copyright(c) 2006-2010 Ext JS, Inc.
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-<div id="cls-Ext.Action"></div>/**
- * @class Ext.Action
- * <p>An Action is a piece of reusable functionality that can be abstracted out of any particular component so that it
+<body onload="prettyPrint(); highlight();">
+ <pre class="prettyprint lang-js"><span id='Ext-Action'>/**
+</span> * @class Ext.Action
+ * <p>An Action is a piece of reusable functionality that can be abstracted out of any particular component so that it
* can be usefully shared among multiple components. Actions let you share handlers, configuration options and UI
- * updates across any components that support the Action interface (primarily {@link Ext.Toolbar}, {@link Ext.Button}
- * and {@link Ext.menu.Menu} components).</p>
- * <p>Aside from supporting the config object interface, any component that needs to use Actions must also support
- * the following method list, as these will be called as needed by the Action class: setText(string), setIconCls(string),
- * setDisabled(boolean), setVisible(boolean) and setHandler(function).</p>
- * Example usage:<br>
- * <pre><code>
-// Define the shared action. Each component below will have the same
+ * updates across any components that support the Action interface (primarily {@link Ext.toolbar.Toolbar}, {@link Ext.button.Button}
+ * and {@link Ext.menu.Menu} components).</p>
+ * <p>Use a single Action instance as the config object for any number of UI Components which share the same configuration. The
+ * Action not only supplies the configuration, but allows all Components based upon it to have a common set of methods
+ * called at once through a single call to the Action.</p>
+ * <p>Any Component that is to be configured with an Action must also support
+ * the following methods:<ul>
+ * <li><code>setText(string)</code></li>
+ * <li><code>setIconCls(string)</code></li>
+ * <li><code>setDisabled(boolean)</code></li>
+ * <li><code>setVisible(boolean)</code></li>
+ * <li><code>setHandler(function)</code></li></ul></p>
+ * <p>This allows the Action to control its associated Components.</p>
+ * Example usage:<br>
+ * <pre><code>
+// Define the shared Action. Each Component below will have the same
// display text and icon, and will display the same message on click.
var action = new Ext.Action({
{@link #text}: 'Do something',
{@link #itemId}: 'myAction'
});
-var panel = new Ext.Panel({
+var panel = new Ext.panel.Panel({
title: 'Actions',
width: 500,
height: 300,
tbar: [
- // Add the action directly to a toolbar as a menu button
+ // Add the Action directly to a toolbar as a menu button
action,
{
text: 'Action Menu',
- // Add the action to a menu as a text item
+ // Add the Action to a menu as a text item
menu: [action]
}
],
items: [
- // Add the action to the panel body as a standard button
- new Ext.Button(action)
+ // Add the Action to the panel body as a standard button
+ new Ext.button.Button(action)
],
renderTo: Ext.getBody()
});
-// Change the text for all components using the action
+// Change the text for all components using the Action
action.setText('Something else');
-// Reference an action through a container using the itemId
+// Reference an Action through a container using the itemId
var btn = panel.getComponent('myAction');
var aRef = btn.baseAction;
aRef.setText('New text');
-</code></pre>
- * @constructor
- * @param {Object} config The configuration options
+</code></pre>
*/
-Ext.Action = Ext.extend(Object, {
- <div id="cfg-Ext.Action-text"></div>/**
- * @cfg {String} text The text to set for all components using this action (defaults to '').
+Ext.define('Ext.Action', {
+
+ /* Begin Definitions */
+
+ /* End Definitions */
+
+<span id='Ext-Action-cfg-text'> /**
+</span> * @cfg {String} [text='']
+ * The text to set for all components configured by this Action.
*/
- <div id="cfg-Ext.Action-iconCls"></div>/**
- * @cfg {String} iconCls
+<span id='Ext-Action-cfg-iconCls'> /**
+</span> * @cfg {String} [iconCls='']
* The CSS class selector that specifies a background image to be used as the header icon for
- * all components using this action (defaults to '').
- * <p>An example of specifying a custom icon class would be something like:
- * </p><pre><code>
+ * all components configured by this Action.
+ * <p>An example of specifying a custom icon class would be something like:
+ * </p><pre><code>
// specify the property in the config for the class:
...
iconCls: 'do-something'
// css class that specifies background image to be used as the icon image:
.do-something { background-image: url(../images/my-icon.gif) 0 6px no-repeat !important; }
-</code></pre>
+</code></pre>
*/
- <div id="cfg-Ext.Action-disabled"></div>/**
- * @cfg {Boolean} disabled True to disable all components using this action, false to enable them (defaults to false).
+<span id='Ext-Action-cfg-disabled'> /**
+</span> * @cfg {Boolean} [disabled=false]
+ * True to disable all components configured by this Action, false to enable them.
*/
- <div id="cfg-Ext.Action-hidden"></div>/**
- * @cfg {Boolean} hidden True to hide all components using this action, false to show them (defaults to false).
+<span id='Ext-Action-cfg-hidden'> /**
+</span> * @cfg {Boolean} [hidden=false]
+ * True to hide all components configured by this Action, false to show them.
*/
- <div id="cfg-Ext.Action-handler"></div>/**
- * @cfg {Function} handler The function that will be invoked by each component tied to this action
- * when the component's primary event is triggered (defaults to undefined).
+<span id='Ext-Action-cfg-handler'> /**
+</span> * @cfg {Function} handler
+ * The function that will be invoked by each component tied to this Action
+ * when the component's primary event is triggered.
*/
- <div id="cfg-Ext.Action-itemId"></div>/**
- * @cfg {String} itemId
+<span id='Ext-Action-cfg-itemId'> /**
+</span> * @cfg {String} itemId
* See {@link Ext.Component}.{@link Ext.Component#itemId itemId}.
*/
- <div id="cfg-Ext.Action-scope"></div>/**
- * @cfg {Object} scope The scope (<tt><b>this</b></tt> reference) in which the
- * <code>{@link #handler}</code> is executed. Defaults to this Button.
+<span id='Ext-Action-cfg-scope'> /**
+</span> * @cfg {Object} scope
+ * The scope (this reference) in which the {@link #handler} is executed.
+ * Defaults to the browser window.
*/
+<span id='Ext-Action-method-constructor'> /**
+</span> * Creates new Action.
+ * @param {Object} config Config object.
+ */
constructor : function(config){
this.initialConfig = config;
this.itemId = config.itemId = (config.itemId || config.id || Ext.id());
this.items = [];
},
-
+
// private
isAction : true,
- <div id="method-Ext.Action-setText"></div>/**
- * Sets the text to be displayed by all components using this action.
+<span id='Ext-Action-method-setText'> /**
+</span> * Sets the text to be displayed by all components configured by this Action.
* @param {String} text The text to display
*/
setText : function(text){
this.callEach('setText', [text]);
},
- <div id="method-Ext.Action-getText"></div>/**
- * Gets the text currently displayed by all components using this action.
+<span id='Ext-Action-method-getText'> /**
+</span> * Gets the text currently displayed by all components configured by this Action.
*/
getText : function(){
return this.initialConfig.text;
},
- <div id="method-Ext.Action-setIconClass"></div>/**
- * Sets the icon CSS class for all components using this action. The class should supply
+<span id='Ext-Action-method-setIconCls'> /**
+</span> * Sets the icon CSS class for all components configured by this Action. The class should supply
* a background image that will be used as the icon image.
* @param {String} cls The CSS class supplying the icon image
*/
- setIconClass : function(cls){
+ setIconCls : function(cls){
this.initialConfig.iconCls = cls;
- this.callEach('setIconClass', [cls]);
+ this.callEach('setIconCls', [cls]);
},
- <div id="method-Ext.Action-getIconClass"></div>/**
- * Gets the icon CSS class currently used by all components using this action.
+<span id='Ext-Action-method-getIconCls'> /**
+</span> * Gets the icon CSS class currently used by all components configured by this Action.
*/
- getIconClass : function(){
+ getIconCls : function(){
return this.initialConfig.iconCls;
},
- <div id="method-Ext.Action-setDisabled"></div>/**
- * Sets the disabled state of all components using this action. Shortcut method
+<span id='Ext-Action-method-setDisabled'> /**
+</span> * Sets the disabled state of all components configured by this Action. Shortcut method
* for {@link #enable} and {@link #disable}.
* @param {Boolean} disabled True to disable the component, false to enable it
*/
this.callEach('setDisabled', [v]);
},
- <div id="method-Ext.Action-enable"></div>/**
- * Enables all components using this action.
+<span id='Ext-Action-method-enable'> /**
+</span> * Enables all components configured by this Action.
*/
enable : function(){
this.setDisabled(false);
},
- <div id="method-Ext.Action-disable"></div>/**
- * Disables all components using this action.
+<span id='Ext-Action-method-disable'> /**
+</span> * Disables all components configured by this Action.
*/
disable : function(){
this.setDisabled(true);
},
- <div id="method-Ext.Action-isDisabled"></div>/**
- * Returns true if the components using this action are currently disabled, else returns false.
+<span id='Ext-Action-method-isDisabled'> /**
+</span> * Returns true if the components using this Action are currently disabled, else returns false.
*/
isDisabled : function(){
return this.initialConfig.disabled;
},
- <div id="method-Ext.Action-setHidden"></div>/**
- * Sets the hidden state of all components using this action. Shortcut method
- * for <code>{@link #hide}</code> and <code>{@link #show}</code>.
+<span id='Ext-Action-method-setHidden'> /**
+</span> * Sets the hidden state of all components configured by this Action. Shortcut method
+ * for <code>{@link #hide}</code> and <code>{@link #show}</code>.
* @param {Boolean} hidden True to hide the component, false to show it
*/
setHidden : function(v){
this.callEach('setVisible', [!v]);
},
- <div id="method-Ext.Action-show"></div>/**
- * Shows all components using this action.
+<span id='Ext-Action-method-show'> /**
+</span> * Shows all components configured by this Action.
*/
show : function(){
this.setHidden(false);
},
- <div id="method-Ext.Action-hide"></div>/**
- * Hides all components using this action.
+<span id='Ext-Action-method-hide'> /**
+</span> * Hides all components configured by this Action.
*/
hide : function(){
this.setHidden(true);
},
- <div id="method-Ext.Action-isHidden"></div>/**
- * Returns true if the components using this action are currently hidden, else returns false.
+<span id='Ext-Action-method-isHidden'> /**
+</span> * Returns true if the components configured by this Action are currently hidden, else returns false.
*/
isHidden : function(){
return this.initialConfig.hidden;
},
- <div id="method-Ext.Action-setHandler"></div>/**
- * Sets the function that will be called by each Component using this action when its primary event is triggered.
+<span id='Ext-Action-method-setHandler'> /**
+</span> * Sets the function that will be called by each Component using this action when its primary event is triggered.
* @param {Function} fn The function that will be invoked by the action's components. The function
* will be called with no arguments.
- * @param {Object} scope The scope (<code>this</code> reference) in which the function is executed. Defaults to the Component firing the event.
+ * @param {Object} scope The scope (<code>this</code> reference) in which the function is executed. Defaults to the Component firing the event.
*/
setHandler : function(fn, scope){
this.initialConfig.handler = fn;
this.callEach('setHandler', [fn, scope]);
},
- <div id="method-Ext.Action-each"></div>/**
- * Executes the specified function once for each Component currently tied to this action. The function passed
+<span id='Ext-Action-method-each'> /**
+</span> * Executes the specified function once for each Component currently tied to this Action. The function passed
* in should accept a single argument that will be an object that supports the basic Action config/method interface.
* @param {Function} fn The function to execute for each component
- * @param {Object} scope The scope (<code>this</code> reference) in which the function is executed. Defaults to the Component.
+ * @param {Object} scope The scope (<code>this</code> reference) in which the function is executed. Defaults to the Component.
*/
each : function(fn, scope){
Ext.each(this.items, fn, scope);
// private
callEach : function(fnName, args){
- var cs = this.items;
- for(var i = 0, len = cs.length; i < len; i++){
- cs[i][fnName].apply(cs[i], args);
+ var items = this.items,
+ i = 0,
+ len = items.length;
+
+ for(; i < len; i++){
+ items[i][fnName].apply(items[i], args);
}
},
// private
removeComponent : function(comp){
- this.items.remove(comp);
+ Ext.Array.remove(this.items, comp);
},
- <div id="method-Ext.Action-execute"></div>/**
- * Executes this action manually using the handler function specified in the original config object
- * or the handler function set with <code>{@link #setHandler}</code>. Any arguments passed to this
+<span id='Ext-Action-method-execute'> /**
+</span> * Executes this Action manually using the handler function specified in the original config object
+ * or the handler function set with <code>{@link #setHandler}</code>. Any arguments passed to this
* function will be passed on to the handler function.
- * @param {Mixed} arg1 (optional) Variable number of arguments passed to the handler function
- * @param {Mixed} arg2 (optional)
- * @param {Mixed} etc... (optional)
+ * @param {Object...} args (optional) Variable number of arguments passed to the handler function
*/
execute : function(){
- this.initialConfig.handler.apply(this.initialConfig.scope || window, arguments);
+ this.initialConfig.handler.apply(this.initialConfig.scope || Ext.global, arguments);
}
});
-</pre>
+</pre>
</body>
-</html>
\ No newline at end of file
+</html>