-<html>\r
-<head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \r
- <title>The source code</title>\r
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body onload="prettyPrint();">\r
- <pre class="prettyprint lang-js"><div id="cls-Ext.Action"></div>/**\r
- * @class Ext.Action\r
- * <p>An Action is a piece of reusable functionality that can be abstracted out of any particular component so that it\r
- * can be usefully shared among multiple components. Actions let you share handlers, configuration options and UI\r
- * updates across any components that support the Action interface (primarily {@link Ext.Toolbar}, {@link Ext.Button}\r
- * and {@link Ext.menu.Menu} components).</p>\r
- * <p>Aside from supporting the config object interface, any component that needs to use Actions must also support\r
- * the following method list, as these will be called as needed by the Action class: setText(string), setIconCls(string),\r
- * setDisabled(boolean), setVisible(boolean) and setHandler(function).</p>\r
- * Example usage:<br>\r
- * <pre><code>\r
-// Define the shared action. Each component below will have the same\r
-// display text and icon, and will display the same message on click.\r
-var action = new Ext.Action({\r
- {@link #text}: 'Do something',\r
- {@link #handler}: function(){\r
- Ext.Msg.alert('Click', 'You did something.');\r
- },\r
- {@link #iconCls}: 'do-something',\r
- {@link #itemId}: 'myAction'\r
-});\r
-\r
-var panel = new Ext.Panel({\r
- title: 'Actions',\r
- width: 500,\r
- height: 300,\r
- tbar: [\r
- // Add the action directly to a toolbar as a menu button\r
- action,\r
- {\r
- text: 'Action Menu',\r
- // Add the action to a menu as a text item\r
- menu: [action]\r
- }\r
- ],\r
- items: [\r
- // Add the action to the panel body as a standard button\r
- new Ext.Button(action)\r
- ],\r
- renderTo: Ext.getBody()\r
-});\r
-\r
-// Change the text for all components using the action\r
-action.setText('Something else');\r
-\r
-// Reference an action through a container using the itemId\r
-var btn = panel.getComponent('myAction');\r
-var aRef = btn.baseAction;\r
-aRef.setText('New text');\r
-</code></pre>\r
- * @constructor\r
- * @param {Object} config The configuration options\r
- */\r
-Ext.Action = Ext.extend(Object, {\r
- <div id="cfg-Ext.Action-text"></div>/**\r
- * @cfg {String} text The text to set for all components using this action (defaults to '').\r
- */\r
- <div id="cfg-Ext.Action-iconCls"></div>/**\r
- * @cfg {String} iconCls\r
- * The CSS class selector that specifies a background image to be used as the header icon for\r
- * all components using this action (defaults to '').\r
- * <p>An example of specifying a custom icon class would be something like:\r
- * </p><pre><code>\r
-// specify the property in the config for the class:\r
- ...\r
- iconCls: 'do-something'\r
-\r
-// css class that specifies background image to be used as the icon image:\r
-.do-something { background-image: url(../images/my-icon.gif) 0 6px no-repeat !important; }\r
-</code></pre>\r
- */\r
- <div id="cfg-Ext.Action-disabled"></div>/**\r
- * @cfg {Boolean} disabled True to disable all components using this action, false to enable them (defaults to false).\r
- */\r
- <div id="cfg-Ext.Action-hidden"></div>/**\r
- * @cfg {Boolean} hidden True to hide all components using this action, false to show them (defaults to false).\r
- */\r
- <div id="cfg-Ext.Action-handler"></div>/**\r
- * @cfg {Function} handler The function that will be invoked by each component tied to this action\r
- * when the component's primary event is triggered (defaults to undefined).\r
- */\r
- <div id="cfg-Ext.Action-itemId"></div>/**\r
- * @cfg {String} itemId\r
- * See {@link Ext.Component}.{@link Ext.Component#itemId itemId}.\r
- */\r
- <div id="cfg-Ext.Action-scope"></div>/**\r
- * @cfg {Object} scope The scope (<tt><b>this</b></tt> reference) in which the\r
- * <code>{@link #handler}</code> is executed. Defaults to this Button.\r
- */\r
-\r
- constructor : function(config){\r
- this.initialConfig = config;\r
- this.itemId = config.itemId = (config.itemId || config.id || Ext.id());\r
- this.items = [];\r
- },\r
- \r
- // private\r
- isAction : true,\r
-\r
- <div id="method-Ext.Action-setText"></div>/**\r
- * Sets the text to be displayed by all components using this action.\r
- * @param {String} text The text to display\r
- */\r
- setText : function(text){\r
- this.initialConfig.text = text;\r
- this.callEach('setText', [text]);\r
- },\r
-\r
- <div id="method-Ext.Action-getText"></div>/**\r
- * Gets the text currently displayed by all components using this action.\r
- */\r
- getText : function(){\r
- return this.initialConfig.text;\r
- },\r
-\r
- <div id="method-Ext.Action-setIconClass"></div>/**\r
- * Sets the icon CSS class for all components using this action. The class should supply\r
- * a background image that will be used as the icon image.\r
- * @param {String} cls The CSS class supplying the icon image\r
- */\r
- setIconClass : function(cls){\r
- this.initialConfig.iconCls = cls;\r
- this.callEach('setIconClass', [cls]);\r
- },\r
-\r
- <div id="method-Ext.Action-getIconClass"></div>/**\r
- * Gets the icon CSS class currently used by all components using this action.\r
- */\r
- getIconClass : function(){\r
- return this.initialConfig.iconCls;\r
- },\r
-\r
- <div id="method-Ext.Action-setDisabled"></div>/**\r
- * Sets the disabled state of all components using this action. Shortcut method\r
- * for {@link #enable} and {@link #disable}.\r
- * @param {Boolean} disabled True to disable the component, false to enable it\r
- */\r
- setDisabled : function(v){\r
- this.initialConfig.disabled = v;\r
- this.callEach('setDisabled', [v]);\r
- },\r
-\r
- <div id="method-Ext.Action-enable"></div>/**\r
- * Enables all components using this action.\r
- */\r
- enable : function(){\r
- this.setDisabled(false);\r
- },\r
-\r
- <div id="method-Ext.Action-disable"></div>/**\r
- * Disables all components using this action.\r
- */\r
- disable : function(){\r
- this.setDisabled(true);\r
- },\r
-\r
- <div id="method-Ext.Action-isDisabled"></div>/**\r
- * Returns true if the components using this action are currently disabled, else returns false. \r
- */\r
- isDisabled : function(){\r
- return this.initialConfig.disabled;\r
- },\r
-\r
- <div id="method-Ext.Action-setHidden"></div>/**\r
- * Sets the hidden state of all components using this action. Shortcut method\r
- * for <code>{@link #hide}</code> and <code>{@link #show}</code>.\r
- * @param {Boolean} hidden True to hide the component, false to show it\r
- */\r
- setHidden : function(v){\r
- this.initialConfig.hidden = v;\r
- this.callEach('setVisible', [!v]);\r
- },\r
-\r
- <div id="method-Ext.Action-show"></div>/**\r
- * Shows all components using this action.\r
- */\r
- show : function(){\r
- this.setHidden(false);\r
- },\r
-\r
- <div id="method-Ext.Action-hide"></div>/**\r
- * Hides all components using this action.\r
- */\r
- hide : function(){\r
- this.setHidden(true);\r
- },\r
-\r
- <div id="method-Ext.Action-isHidden"></div>/**\r
- * Returns true if the components using this action are currently hidden, else returns false. \r
- */\r
- isHidden : function(){\r
- return this.initialConfig.hidden;\r
- },\r
-\r
- <div id="method-Ext.Action-setHandler"></div>/**\r
- * Sets the function that will be called by each Component using this action when its primary event is triggered.\r
- * @param {Function} fn The function that will be invoked by the action's components. The function\r
- * will be called with no arguments.\r
- * @param {Object} scope The scope (<code>this</code> reference) in which the function is executed. Defaults to the Component firing the event.\r
- */\r
- setHandler : function(fn, scope){\r
- this.initialConfig.handler = fn;\r
- this.initialConfig.scope = scope;\r
- this.callEach('setHandler', [fn, scope]);\r
- },\r
-\r
- <div id="method-Ext.Action-each"></div>/**\r
- * Executes the specified function once for each Component currently tied to this action. The function passed\r
- * in should accept a single argument that will be an object that supports the basic Action config/method interface.\r
- * @param {Function} fn The function to execute for each component\r
- * @param {Object} scope The scope (<code>this</code> reference) in which the function is executed. Defaults to the Component.\r
- */\r
- each : function(fn, scope){\r
- Ext.each(this.items, fn, scope);\r
- },\r
-\r
- // private\r
- callEach : function(fnName, args){\r
- var cs = this.items;\r
- for(var i = 0, len = cs.length; i < len; i++){\r
- cs[i][fnName].apply(cs[i], args);\r
- }\r
- },\r
-\r
- // private\r
- addComponent : function(comp){\r
- this.items.push(comp);\r
- comp.on('destroy', this.removeComponent, this);\r
- },\r
-\r
- // private\r
- removeComponent : function(comp){\r
- this.items.remove(comp);\r
- },\r
-\r
- <div id="method-Ext.Action-execute"></div>/**\r
- * Executes this action manually using the handler function specified in the original config object\r
- * or the handler function set with <code>{@link #setHandler}</code>. Any arguments passed to this\r
- * function will be passed on to the handler function.\r
- * @param {Mixed} arg1 (optional) Variable number of arguments passed to the handler function\r
- * @param {Mixed} arg2 (optional)\r
- * @param {Mixed} etc... (optional)\r
- */\r
- execute : function(){\r
- this.initialConfig.handler.apply(this.initialConfig.scope || window, arguments);\r
- }\r
-});\r
-</pre> \r
-</body>\r
-</html>
\ No newline at end of file
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>The source code</title>
+ <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../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(); highlight();">
+ <pre class="prettyprint lang-js"><span id='Ext-form-action-Action'>/**
+</span> * @class Ext.form.action.Action
+ * @extends Ext.Base
+ * <p>The subclasses of this class provide actions to perform upon {@link Ext.form.Basic Form}s.</p>
+ * <p>Instances of this class are only created by a {@link Ext.form.Basic Form} when
+ * the Form needs to perform an action such as submit or load. The Configuration options
+ * listed for this class are set through the Form's action methods: {@link Ext.form.Basic#submit submit},
+ * {@link Ext.form.Basic#load load} and {@link Ext.form.Basic#doAction doAction}</p>
+ * <p>The instance of Action which performed the action is passed to the success
+ * and failure callbacks of the Form's action methods ({@link Ext.form.Basic#submit submit},
+ * {@link Ext.form.Basic#load load} and {@link Ext.form.Basic#doAction doAction}),
+ * and to the {@link Ext.form.Basic#actioncomplete actioncomplete} and
+ * {@link Ext.form.Basic#actionfailed actionfailed} event handlers.</p>
+ */
+Ext.define('Ext.form.action.Action', {
+ alternateClassName: 'Ext.form.Action',
+
+<span id='Ext-form-action-Action-cfg-form'> /**
+</span> * @cfg {Ext.form.Basic} form The {@link Ext.form.Basic BasicForm} instance that
+ * is invoking this Action. Required.
+ */
+
+<span id='Ext-form-action-Action-cfg-url'> /**
+</span> * @cfg {String} url The URL that the Action is to invoke. Will default to the {@link Ext.form.Basic#url url}
+ * configured on the {@link #form}.
+ */
+
+<span id='Ext-form-action-Action-cfg-reset'> /**
+</span> * @cfg {Boolean} reset When set to <tt><b>true</b></tt>, causes the Form to be
+ * {@link Ext.form.Basic#reset reset} on Action success. If specified, this happens
+ * before the {@link #success} callback is called and before the Form's
+ * {@link Ext.form.Basic#actioncomplete actioncomplete} event fires.
+ */
+
+<span id='Ext-form-action-Action-cfg-method'> /**
+</span> * @cfg {String} method The HTTP method to use to access the requested URL. Defaults to the
+ * {@link Ext.form.Basic#method BasicForm's method}, or 'POST' if not specified.
+ */
+
+<span id='Ext-form-action-Action-cfg-params'> /**
+</span> * @cfg {Object/String} params <p>Extra parameter values to pass. These are added to the Form's
+ * {@link Ext.form.Basic#baseParams} and passed to the specified URL along with the Form's
+ * input fields.</p>
+ * <p>Parameters are encoded as standard HTTP parameters using {@link Ext#urlEncode Ext.Object.toQueryString}.</p>
+ */
+
+<span id='Ext-form-action-Action-cfg-headers'> /**
+</span> * @cfg {Object} headers <p>Extra headers to be sent in the AJAX request for submit and load actions. See
+ * {@link Ext.data.Connection#headers}.</p>
+ */
+
+<span id='Ext-form-action-Action-cfg-timeout'> /**
+</span> * @cfg {Number} timeout The number of seconds to wait for a server response before
+ * failing with the {@link #failureType} as {@link Ext.form.action.Action#CONNECT_FAILURE}. If not specified,
+ * defaults to the configured <tt>{@link Ext.form.Basic#timeout timeout}</tt> of the
+ * {@link #form}.
+ */
+
+<span id='Ext-form-action-Action-cfg-success'> /**
+</span> * @cfg {Function} success The function to call when a valid success return packet is received.
+ * The function is passed the following parameters:<ul class="mdetail-params">
+ * <li><b>form</b> : Ext.form.Basic<div class="sub-desc">The form that requested the action</div></li>
+ * <li><b>action</b> : Ext.form.action.Action<div class="sub-desc">The Action class. The {@link #result}
+ * property of this object may be examined to perform custom postprocessing.</div></li>
+ * </ul>
+ */
+
+<span id='Ext-form-action-Action-cfg-failure'> /**
+</span> * @cfg {Function} failure The function to call when a failure packet was received, or when an
+ * error ocurred in the Ajax communication.
+ * The function is passed the following parameters:<ul class="mdetail-params">
+ * <li><b>form</b> : Ext.form.Basic<div class="sub-desc">The form that requested the action</div></li>
+ * <li><b>action</b> : Ext.form.action.Action<div class="sub-desc">The Action class. If an Ajax
+ * error ocurred, the failure type will be in {@link #failureType}. The {@link #result}
+ * property of this object may be examined to perform custom postprocessing.</div></li>
+ * </ul>
+ */
+
+<span id='Ext-form-action-Action-cfg-scope'> /**
+</span> * @cfg {Object} scope The scope in which to call the configured <tt>success</tt> and <tt>failure</tt>
+ * callback functions (the <tt>this</tt> reference for the callback functions).
+ */
+
+<span id='Ext-form-action-Action-cfg-waitMsg'> /**
+</span> * @cfg {String} waitMsg The message to be displayed by a call to {@link Ext.window.MessageBox#wait}
+ * during the time the action is being processed.
+ */
+
+<span id='Ext-form-action-Action-cfg-waitTitle'> /**
+</span> * @cfg {String} waitTitle The title to be displayed by a call to {@link Ext.window.MessageBox#wait}
+ * during the time the action is being processed.
+ */
+
+<span id='Ext-form-action-Action-cfg-submitEmptyText'> /**
+</span> * @cfg {Boolean} submitEmptyText If set to <tt>true</tt>, the emptyText value will be sent with the form
+ * when it is submitted. Defaults to <tt>true</tt>.
+ */
+
+<span id='Ext-form-action-Action-property-type'> /**
+</span> * @property type
+ * The type of action this Action instance performs.
+ * Currently only "submit" and "load" are supported.
+ * @type {String}
+ */
+
+<span id='Ext-form-action-Action-property-failureType'> /**
+</span> * The type of failure detected will be one of these: {@link Ext.form.action.Action#CLIENT_INVALID},
+ * {@link Ext.form.action.Action#SERVER_INVALID}, {@link Ext.form.action.Action#CONNECT_FAILURE}, or
+ * {@link Ext.form.action.Action#LOAD_FAILURE}. Usage:
+ * <pre><code>
+var fp = new Ext.form.Panel({
+...
+buttons: [{
+ text: 'Save',
+ formBind: true,
+ handler: function(){
+ if(fp.getForm().isValid()){
+ fp.getForm().submit({
+ url: 'form-submit.php',
+ waitMsg: 'Submitting your data...',
+ success: function(form, action){
+ // server responded with success = true
+ var result = action.{@link #result};
+ },
+ failure: function(form, action){
+ if (action.{@link #failureType} === {@link Ext.form.action.Action#CONNECT_FAILURE}) {
+ Ext.Msg.alert('Error',
+ 'Status:'+action.{@link #response}.status+': '+
+ action.{@link #response}.statusText);
+ }
+ if (action.failureType === {@link Ext.form.action.Action#SERVER_INVALID}){
+ // server responded with success = false
+ Ext.Msg.alert('Invalid', action.{@link #result}.errormsg);
+ }
+ }
+ });
+ }
+ }
+},{
+ text: 'Reset',
+ handler: function(){
+ fp.getForm().reset();
+ }
+}]
+ * </code></pre>
+ * @property failureType
+ * @type {String}
+ */
+
+<span id='Ext-form-action-Action-property-response'> /**
+</span> * The raw XMLHttpRequest object used to perform the action.
+ * @property response
+ * @type {Object}
+ */
+
+<span id='Ext-form-action-Action-property-result'> /**
+</span> * The decoded response object containing a boolean <tt>success</tt> property and
+ * other, action-specific properties.
+ * @property result
+ * @type {Object}
+ */
+
+<span id='Ext-form-action-Action-method-constructor'> /**
+</span> * Creates new Action.
+ * @param {Object} config (optional) Config object.
+ */
+ constructor: function(config) {
+ if (config) {
+ Ext.apply(this, config);
+ }
+
+ // Normalize the params option to an Object
+ var params = config.params;
+ if (Ext.isString(params)) {
+ this.params = Ext.Object.fromQueryString(params);
+ }
+ },
+
+<span id='Ext-form-action-Action-property-run'> /**
+</span> * Invokes this action using the current configuration.
+ */
+ run: Ext.emptyFn,
+
+<span id='Ext-form-action-Action-method-onSuccess'> /**
+</span> * @private
+ * @method onSuccess
+ * Callback method that gets invoked when the action completes successfully. Must be implemented by subclasses.
+ * @param {Object} response
+ */
+
+<span id='Ext-form-action-Action-method-handleResponse'> /**
+</span> * @private
+ * @method handleResponse
+ * Handles the raw response and builds a result object from it. Must be implemented by subclasses.
+ * @param {Object} response
+ */
+
+<span id='Ext-form-action-Action-method-onFailure'> /**
+</span> * @private
+ * Handles a failure response.
+ * @param {Object} response
+ */
+ onFailure : function(response){
+ this.response = response;
+ this.failureType = Ext.form.action.Action.CONNECT_FAILURE;
+ this.form.afterAction(this, false);
+ },
+
+<span id='Ext-form-action-Action-method-processResponse'> /**
+</span> * @private
+ * Validates that a response contains either responseText or responseXML and invokes
+ * {@link #handleResponse} to build the result object.
+ * @param {Object} response The raw response object.
+ * @return {Object/Boolean} result The result object as built by handleResponse, or <tt>true</tt> if
+ * the response had empty responseText and responseXML.
+ */
+ processResponse : function(response){
+ this.response = response;
+ if (!response.responseText && !response.responseXML) {
+ return true;
+ }
+ return (this.result = this.handleResponse(response));
+ },
+
+<span id='Ext-form-action-Action-method-getUrl'> /**
+</span> * @private
+ * Build the URL for the AJAX request. Used by the standard AJAX submit and load actions.
+ * @return {String} The URL.
+ */
+ getUrl: function() {
+ return this.url || this.form.url;
+ },
+
+<span id='Ext-form-action-Action-method-getMethod'> /**
+</span> * @private
+ * Determine the HTTP method to be used for the request.
+ * @return {String} The HTTP method
+ */
+ getMethod: function() {
+ return (this.method || this.form.method || 'POST').toUpperCase();
+ },
+
+<span id='Ext-form-action-Action-method-getParams'> /**
+</span> * @private
+ * Get the set of parameters specified in the BasicForm's baseParams and/or the params option.
+ * Items in params override items of the same name in baseParams.
+ * @return {Object} the full set of parameters
+ */
+ getParams: function() {
+ return Ext.apply({}, this.params, this.form.baseParams);
+ },
+
+<span id='Ext-form-action-Action-method-createCallback'> /**
+</span> * @private
+ * Creates a callback object.
+ */
+ createCallback: function() {
+ var me = this,
+ undef,
+ form = me.form;
+ return {
+ success: me.onSuccess,
+ failure: me.onFailure,
+ scope: me,
+ timeout: (this.timeout * 1000) || (form.timeout * 1000),
+ upload: form.fileUpload ? me.onSuccess : undef
+ };
+ },
+
+ statics: {
+<span id='Ext-form-action-Action-property-CLIENT_INVALID'> /**
+</span> * @property CLIENT_INVALID
+ * Failure type returned when client side validation of the Form fails
+ * thus aborting a submit action. Client side validation is performed unless
+ * {@link Ext.form.action.Submit#clientValidation} is explicitly set to <tt>false</tt>.
+ * @type {String}
+ * @static
+ */
+ CLIENT_INVALID: 'client',
+
+<span id='Ext-form-action-Action-property-SERVER_INVALID'> /**
+</span> * @property SERVER_INVALID
+ * <p>Failure type returned when server side processing fails and the {@link #result}'s
+ * <tt>success</tt> property is set to <tt>false</tt>.</p>
+ * <p>In the case of a form submission, field-specific error messages may be returned in the
+ * {@link #result}'s <tt>errors</tt> property.</p>
+ * @type {String}
+ * @static
+ */
+ SERVER_INVALID: 'server',
+
+<span id='Ext-form-action-Action-property-CONNECT_FAILURE'> /**
+</span> * @property CONNECT_FAILURE
+ * Failure type returned when a communication error happens when attempting
+ * to send a request to the remote server. The {@link #response} may be examined to
+ * provide further information.
+ * @type {String}
+ * @static
+ */
+ CONNECT_FAILURE: 'connect',
+
+<span id='Ext-form-action-Action-property-LOAD_FAILURE'> /**
+</span> * @property LOAD_FAILURE
+ * Failure type returned when the response's <tt>success</tt>
+ * property is set to <tt>false</tt>, or no field values are returned in the response's
+ * <tt>data</tt> property.
+ * @type {String}
+ * @static
+ */
+ LOAD_FAILURE: 'load'
+
+
+ }
+});
+</pre>
+</body>
+</html>