X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..refs/heads/old:/src/util/UpdateManager.js?ds=sidebyside
diff --git a/src/util/UpdateManager.js b/src/util/UpdateManager.js
index c7c3265b..b33bcaf4 100644
--- a/src/util/UpdateManager.js
+++ b/src/util/UpdateManager.js
@@ -1,8 +1,8 @@
/*!
- * Ext JS Library 3.1.0
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
+ * Ext JS Library 3.3.1
+ * Copyright(c) 2006-2010 Sencha Inc.
+ * licensing@sencha.com
+ * http://www.sencha.com/license
*/
/**
* @class Ext.Updater
@@ -43,15 +43,15 @@
* @param {Boolean} forceNew (optional) By default the constructor checks to see if the passed element already
* has an Updater and if it does it returns the same instance. This will skip that check (useful for extending this class).
*/
-Ext.UpdateManager = Ext.Updater = Ext.extend(Ext.util.Observable,
+Ext.UpdateManager = Ext.Updater = Ext.extend(Ext.util.Observable,
function() {
- var BEFOREUPDATE = "beforeupdate",
- UPDATE = "update",
- FAILURE = "failure";
-
- // private
- function processSuccess(response){
- var me = this;
+ var BEFOREUPDATE = "beforeupdate",
+ UPDATE = "update",
+ FAILURE = "failure";
+
+ // private
+ function processSuccess(response){
+ var me = this;
me.transaction = null;
if (response.argument.form && response.argument.reset) {
try { // put in try/catch since some older FF releases had problems with this
@@ -66,7 +66,7 @@ function() {
updateComplete.call(me, response);
}
}
-
+
// private
function updateComplete(response, type, success){
this.fireEvent(type || UPDATE, this.el, response);
@@ -76,385 +76,385 @@ function() {
}
// private
- function processFailure(response){
+ function processFailure(response){
updateComplete.call(this, response, FAILURE, !!(this.transaction = null));
}
-
- return {
- constructor: function(el, forceNew){
- var me = this;
- el = Ext.get(el);
- if(!forceNew && el.updateManager){
- return el.updateManager;
- }
- /**
- * The Element object
- * @type Ext.Element
- */
- me.el = el;
- /**
- * Cached url to use for refreshes. Overwritten every time update() is called unless "discardUrl" param is set to true.
- * @type String
- */
- me.defaultUrl = null;
-
- me.addEvents(
- /**
- * @event beforeupdate
- * Fired before an update is made, return false from your handler and the update is cancelled.
- * @param {Ext.Element} el
- * @param {String/Object/Function} url
- * @param {String/Object} params
- */
- BEFOREUPDATE,
- /**
- * @event update
- * Fired after successful update is made.
- * @param {Ext.Element} el
- * @param {Object} oResponseObject The response Object
- */
- UPDATE,
- /**
- * @event failure
- * Fired on update failure.
- * @param {Ext.Element} el
- * @param {Object} oResponseObject The response Object
- */
- FAILURE
- );
-
- Ext.apply(me, Ext.Updater.defaults);
- /**
- * Blank page URL to use with SSL file uploads (defaults to {@link Ext.Updater.defaults#sslBlankUrl}).
- * @property sslBlankUrl
- * @type String
- */
- /**
- * Whether to append unique parameter on get request to disable caching (defaults to {@link Ext.Updater.defaults#disableCaching}).
- * @property disableCaching
- * @type Boolean
- */
- /**
- * Text for loading indicator (defaults to {@link Ext.Updater.defaults#indicatorText}).
- * @property indicatorText
- * @type String
- */
- /**
- * Whether to show indicatorText when loading (defaults to {@link Ext.Updater.defaults#showLoadIndicator}).
- * @property showLoadIndicator
- * @type String
- */
- /**
- * Timeout for requests or form posts in seconds (defaults to {@link Ext.Updater.defaults#timeout}).
- * @property timeout
- * @type Number
- */
- /**
- * True to process scripts in the output (defaults to {@link Ext.Updater.defaults#loadScripts}).
- * @property loadScripts
- * @type Boolean
- */
-
- /**
- * Transaction object of the current executing transaction, or null if there is no active transaction.
- */
- me.transaction = null;
- /**
- * Delegate for refresh() prebound to "this", use myUpdater.refreshDelegate.createCallback(arg1, arg2) to bind arguments
- * @type Function
- */
- me.refreshDelegate = me.refresh.createDelegate(me);
- /**
- * Delegate for update() prebound to "this", use myUpdater.updateDelegate.createCallback(arg1, arg2) to bind arguments
- * @type Function
- */
- me.updateDelegate = me.update.createDelegate(me);
- /**
- * Delegate for formUpdate() prebound to "this", use myUpdater.formUpdateDelegate.createCallback(arg1, arg2) to bind arguments
- * @type Function
- */
- me.formUpdateDelegate = (me.formUpdate || function(){}).createDelegate(me);
-
- /**
- * The renderer for this Updater (defaults to {@link Ext.Updater.BasicRenderer}).
- */
- me.renderer = me.renderer || me.getDefaultRenderer();
-
- Ext.Updater.superclass.constructor.call(me);
- },
-
- /**
- * Sets the content renderer for this Updater. See {@link Ext.Updater.BasicRenderer#render} for more details.
- * @param {Object} renderer The object implementing the render() method
- */
- setRenderer : function(renderer){
- this.renderer = renderer;
- },
-
- /**
- * Returns the current content renderer for this Updater. See {@link Ext.Updater.BasicRenderer#render} for more details.
- * @return {Object}
- */
- getRenderer : function(){
- return this.renderer;
- },
-
- /**
- * This is an overrideable method which returns a reference to a default
- * renderer class if none is specified when creating the Ext.Updater.
- * Defaults to {@link Ext.Updater.BasicRenderer}
- */
- getDefaultRenderer: function() {
- return new Ext.Updater.BasicRenderer();
- },
-
- /**
- * Sets the default URL used for updates.
- * @param {String/Function} defaultUrl The url or a function to call to get the url
- */
- setDefaultUrl : function(defaultUrl){
- this.defaultUrl = defaultUrl;
- },
-
- /**
- * Get the Element this Updater is bound to
- * @return {Ext.Element} The element
- */
- getEl : function(){
- return this.el;
- },
-
- /**
- * Performs an asynchronous request, updating this element with the response.
- * If params are specified it uses POST, otherwise it uses GET.
- * Note: Due to the asynchronous nature of remote server requests, the Element
- * will not have been fully updated when the function returns. To post-process the returned
- * data, use the callback option, or an update
event handler.
- * @param {Object} options A config object containing any of the following options:
The URL to request or a function which - * returns the URL (defaults to the value of {@link Ext.Ajax#url} if not specified).
The HTTP method to
- * use. Defaults to POST if the params
argument is present, otherwise GET.
The - * parameters to pass to the server (defaults to none). These may be specified as a url-encoded - * string, or as an object containing properties which represent parameters, - * or as a function, which returns such an object.
If true
- * any <script> tags embedded in the response text will be extracted
- * and executed (defaults to {@link Ext.Updater.defaults#loadScripts}). If this option is specified,
- * the callback will be called after the execution of the scripts.
A function to - * be called when the response from the server arrives. The following - * parameters are passed:
The Element being updated.
True for success, false for failure.
The XMLHttpRequest which processed the update.
The config object passed to the update call.
The scope in which
- * to execute the callback (The callback's this
reference.) If the
- * params
argument is a function, this scope is used for that function also.
By default, the URL of this request becomes
- * the default URL for this Updater object, and will be subsequently used in {@link #refresh}
- * calls. To bypass this behavior, pass discardUrl:true
(defaults to false).
The number of seconds to wait for a response before - * timing out (defaults to {@link Ext.Updater.defaults#timeout}).
The text to use as the innerHTML of the - * {@link Ext.Updater.defaults#indicatorText} div (defaults to 'Loading...'). To replace the entire div, not - * just the text, override {@link Ext.Updater.defaults#indicatorText} directly.
Only needed for GET - * requests, this option causes an extra, auto-generated parameter to be appended to the request - * to defeat caching (defaults to {@link Ext.Updater.defaults#disableCaching}).
- * For example: -
- um.update({
- url: "your-url.php",
- params: {param1: "foo", param2: "bar"}, // or a URL encoded string
- callback: yourFunction,
- scope: yourObject, //(optional scope)
- discardUrl: true,
- nocache: true,
- text: "Loading...",
- timeout: 60,
- scripts: false // Save time by avoiding RegExp execution.
- });
-
- */
- update : function(url, params, callback, discardUrl){
- var me = this,
- cfg,
- callerScope;
-
- if(me.fireEvent(BEFOREUPDATE, me.el, url, params) !== false){
- if(Ext.isObject(url)){ // must be config object
- cfg = url;
- url = cfg.url;
- params = params || cfg.params;
- callback = callback || cfg.callback;
- discardUrl = discardUrl || cfg.discardUrl;
- callerScope = cfg.scope;
- if(!Ext.isEmpty(cfg.nocache)){me.disableCaching = cfg.nocache;};
- if(!Ext.isEmpty(cfg.text)){me.indicatorText = 'Performs an asynchronous form post, updating this element with the response. If the form has the attribute - * enctype="multipart/form-data", it assumes it's a file upload. - * Uses this.sslBlankUrl for SSL file uploads to prevent IE security warning.
- *File uploads are not performed using normal "Ajax" techniques, that is they are not
- * performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the
- * DOM <form>
element temporarily modified to have its
- * target set to refer
- * to a dynamically generated, hidden <iframe>
which is inserted into the document
- * but removed after the return data has been gathered.
Be aware that file upload packets, sent with the content type multipart/form-data - * and some server technologies (notably JEE) may require some custom processing in order to - * retrieve parameter names and parameter values from the packet content.
- * @param {String/HTMLElement} form The form Id or form element - * @param {String} url (optional) The url to pass the form to. If omitted the action attribute on the form will be used. - * @param {Boolean} reset (optional) Whether to try to reset the form after the update - * @param {Function} callback (optional) Callback when transaction is complete. The following - * parameters are passed:The Element being updated.
True for success, false for failure.
The XMLHttpRequest which processed the update.
update
event handler.
+ * @param {Object} options A config object containing any of the following options:The URL to request or a function which + * returns the URL (defaults to the value of {@link Ext.Ajax#url} if not specified).
The HTTP method to
+ * use. Defaults to POST if the params
argument is present, otherwise GET.
The + * parameters to pass to the server (defaults to none). These may be specified as a url-encoded + * string, or as an object containing properties which represent parameters, + * or as a function, which returns such an object.
If true
+ * any <script> tags embedded in the response text will be extracted
+ * and executed (defaults to {@link Ext.Updater.defaults#loadScripts}). If this option is specified,
+ * the callback will be called after the execution of the scripts.
A function to + * be called when the response from the server arrives. The following + * parameters are passed:
The Element being updated.
True for success, false for failure.
The XMLHttpRequest which processed the update.
The config object passed to the update call.
The scope in which
+ * to execute the callback (The callback's this
reference.) If the
+ * params
argument is a function, this scope is used for that function also.
By default, the URL of this request becomes
+ * the default URL for this Updater object, and will be subsequently used in {@link #refresh}
+ * calls. To bypass this behavior, pass discardUrl:true
(defaults to false).
The number of seconds to wait for a response before + * timing out (defaults to {@link Ext.Updater.defaults#timeout}).
The text to use as the innerHTML of the + * {@link Ext.Updater.defaults#indicatorText} div (defaults to 'Loading...'). To replace the entire div, not + * just the text, override {@link Ext.Updater.defaults#indicatorText} directly.
Only needed for GET + * requests, this option causes an extra, auto-generated parameter to be appended to the request + * to defeat caching (defaults to {@link Ext.Updater.defaults#disableCaching}).
+ * For example: +
+ um.update({
+ url: "your-url.php",
+ params: {param1: "foo", param2: "bar"}, // or a URL encoded string
+ callback: yourFunction,
+ scope: yourObject, //(optional scope)
+ discardUrl: true,
+ nocache: true,
+ text: "Loading...",
+ timeout: 60,
+ scripts: false // Save time by avoiding RegExp execution.
+ });
+
+ */
+ update : function(url, params, callback, discardUrl){
+ var me = this,
+ cfg,
+ callerScope;
+
+ if(me.fireEvent(BEFOREUPDATE, me.el, url, params) !== false){
+ if(Ext.isObject(url)){ // must be config object
+ cfg = url;
+ url = cfg.url;
+ params = params || cfg.params;
+ callback = callback || cfg.callback;
+ discardUrl = discardUrl || cfg.discardUrl;
+ callerScope = cfg.scope;
+ if(!Ext.isEmpty(cfg.nocache)){me.disableCaching = cfg.nocache;};
+ if(!Ext.isEmpty(cfg.text)){me.indicatorText = 'Performs an asynchronous form post, updating this element with the response. If the form has the attribute + * enctype="multipart/form-data", it assumes it's a file upload. + * Uses this.sslBlankUrl for SSL file uploads to prevent IE security warning.
+ *File uploads are not performed using normal "Ajax" techniques, that is they are not
+ * performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the
+ * DOM <form>
element temporarily modified to have its
+ * target set to refer
+ * to a dynamically generated, hidden <iframe>
which is inserted into the document
+ * but removed after the return data has been gathered.
Be aware that file upload packets, sent with the content type multipart/form-data + * and some server technologies (notably JEE) may require some custom processing in order to + * retrieve parameter names and parameter values from the packet content.
+ * @param {String/HTMLElement} form The form Id or form element + * @param {String} url (optional) The url to pass the form to. If omitted the action attribute on the form will be used. + * @param {Boolean} reset (optional) Whether to try to reset the form after the update + * @param {Function} callback (optional) Callback when transaction is complete. The following + * parameters are passed:The Element being updated.
True for success, false for failure.
The XMLHttpRequest which processed the update.