Alien-Web-ExtJS-V3
view release on metacpan or search on metacpan
share/docs/source/UpdateManager.html view on Meta::CPAN
}
}
// private
function updateComplete(response, type, success){
this.fireEvent(type || UPDATE, this.el, response);
if(Ext.isFunction(response.argument.callback)){
response.argument.callback.call(response.argument.scope, this.el, Ext.isEmpty(success) ? true : false, response, response.argument.options);
}
}
// private
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;
}
<span id='Ext-Updater-property-el'> /**
</span> * The Element object
* @type Ext.Element
*/
me.el = el;
<span id='Ext-Updater-property-defaultUrl'> /**
</span> * 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(
<span id='Ext-Updater-event-beforeupdate'> /**
</span> * @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,
<span id='Ext-Updater-event-update'> /**
</span> * @event update
* Fired after successful update is made.
* @param {Ext.Element} el
* @param {Object} oResponseObject The response Object
*/
UPDATE,
<span id='Ext-Updater-event-failure'> /**
</span> * @event failure
* Fired on update failure.
* @param {Ext.Element} el
* @param {Object} oResponseObject The response Object
*/
FAILURE
);
Ext.apply(me, Ext.Updater.defaults);
<span id='Ext-Updater-property-sslBlankUrl'> /**
</span> * Blank page URL to use with SSL file uploads (defaults to {@link Ext.Updater.defaults#sslBlankUrl}).
* @property sslBlankUrl
* @type String
*/
<span id='Ext-Updater-property-disableCaching'> /**
</span> * Whether to append unique parameter on get request to disable caching (defaults to {@link Ext.Updater.defaults#disableCaching}).
* @property disableCaching
* @type Boolean
*/
<span id='Ext-Updater-property-indicatorText'> /**
</span> * Text for loading indicator (defaults to {@link Ext.Updater.defaults#indicatorText}).
* @property indicatorText
* @type String
*/
<span id='Ext-Updater-property-showLoadIndicator'> /**
</span> * Whether to show indicatorText when loading (defaults to {@link Ext.Updater.defaults#showLoadIndicator}).
* @property showLoadIndicator
* @type String
*/
<span id='Ext-Updater-property-timeout'> /**
</span> * Timeout for requests or form posts in seconds (defaults to {@link Ext.Updater.defaults#timeout}).
* @property timeout
* @type Number
*/
<span id='Ext-Updater-property-loadScripts'> /**
</span> * True to process scripts in the output (defaults to {@link Ext.Updater.defaults#loadScripts}).
* @property loadScripts
* @type Boolean
*/
<span id='Ext-Updater-property-transaction'> /**
</span> * Transaction object of the current executing transaction, or null if there is no active transaction.
*/
me.transaction = null;
<span id='Ext-Updater-property-refreshDelegate'> /**
</span> * Delegate for refresh() prebound to "this", use myUpdater.refreshDelegate.createCallback(arg1, arg2) to bind arguments
* @type Function
*/
me.refreshDelegate = me.refresh.createDelegate(me);
<span id='Ext-Updater-property-updateDelegate'> /**
</span> * Delegate for update() prebound to "this", use myUpdater.updateDelegate.createCallback(arg1, arg2) to bind arguments
* @type Function
*/
me.updateDelegate = me.update.createDelegate(me);
<span id='Ext-Updater-property-formUpdateDelegate'> /**
</span> * Delegate for formUpdate() prebound to "this", use myUpdater.formUpdateDelegate.createCallback(arg1, arg2) to bind arguments
* @type Function
*/
me.formUpdateDelegate = (me.formUpdate || function(){}).createDelegate(me);
<span id='Ext-Updater-property-renderer'> /**
</span> * The renderer for this Updater (defaults to {@link Ext.Updater.BasicRenderer}).
*/
me.renderer = me.renderer || me.getDefaultRenderer();
Ext.Updater.superclass.constructor.call(me);
},
<span id='Ext-Updater-method-setRenderer'> /**
</span> * 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
*/
share/docs/source/UpdateManager.html view on Meta::CPAN
nocache: true,
text: "Loading...",
timeout: 60,
scripts: false // Save time by avoiding RegExp execution.
});
</code></pre>
*/
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 = '<div class="loading-indicator">'+cfg.text+"</div>";};
if(!Ext.isEmpty(cfg.scripts)){me.loadScripts = cfg.scripts;};
if(!Ext.isEmpty(cfg.timeout)){me.timeout = cfg.timeout;};
}
me.showLoading();
if(!discardUrl){
me.defaultUrl = url;
}
if(Ext.isFunction(url)){
url = url.call(me);
}
var o = Ext.apply({}, {
url : url,
params: (Ext.isFunction(params) && callerScope) ? params.createDelegate(callerScope) : params,
success: processSuccess,
failure: processFailure,
scope: me,
callback: undefined,
timeout: (me.timeout*1000),
disableCaching: me.disableCaching,
argument: {
"options": cfg,
"url": url,
"form": null,
"callback": callback,
"scope": callerScope || window,
"params": params
}
}, cfg);
me.transaction = Ext.Ajax.request(o);
}
},
<span id='Ext-Updater-method-formUpdate'> /**
</span> * <p>Performs an asynchronous form post, updating this element with the response. If the form has the attribute
* enctype="<a href="http://www.faqs.org/rfcs/rfc2388.html">multipart/form-data</a>", it assumes it's a file upload.
* Uses this.sslBlankUrl for SSL file uploads to prevent IE security warning.</p>
* <p>File uploads are not performed using normal "Ajax" techniques, that is they are <b>not</b>
* performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the
* DOM <code>&lt;form></code> element temporarily modified to have its
* <a href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target">target</a> set to refer
* to a dynamically generated, hidden <code>&lt;iframe></code> which is inserted into the document
* but removed after the return data has been gathered.</p>
* <p>Be aware that file upload packets, sent with the content type <a href="http://www.faqs.org/rfcs/rfc2388.html">multipart/form-data</a>
* and some server technologies (notably JEE) may require some custom processing in order to
* retrieve parameter names and parameter values from the packet content.</p>
* @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:<ul>
* <li><b>el</b> : Ext.Element<p class="sub-desc">The Element being updated.</p></li>
* <li><b>success</b> : Boolean<p class="sub-desc">True for success, false for failure.</p></li>
* <li><b>response</b> : XMLHttpRequest<p class="sub-desc">The XMLHttpRequest which processed the update.</p></li></ul>
*/
formUpdate : function(form, url, reset, callback){
var me = this;
if(me.fireEvent(BEFOREUPDATE, me.el, form, url) !== false){
if(Ext.isFunction(url)){
url = url.call(me);
}
form = Ext.getDom(form);
me.transaction = Ext.Ajax.request({
form: form,
url:url,
success: processSuccess,
failure: processFailure,
scope: me,
timeout: (me.timeout*1000),
argument: {
"url": url,
"form": form,
"callback": callback,
"reset": reset
}
});
me.showLoading.defer(1, me);
}
},
<span id='Ext-Updater-method-startAutoRefresh'> /**
</span> * Set this element to auto refresh. Can be canceled by calling {@link #stopAutoRefresh}.
* @param {Number} interval How often to update (in seconds).
* @param {String/Object/Function} url (optional) The url for this request, a config object in the same format
* supported by {@link #load}, or a function to call to get the url (defaults to the last used url). Note that while
* the url used in a load call can be reused by this method, other load config options will not be reused and must be
* sepcified as part of a config object passed as this paramter if needed.
* @param {String/Object} params (optional) The parameters to pass as either a url encoded string
* "&param1=1&param2=2" or as an object {param1: 1, param2: 2}
* @param {Function} callback (optional) Callback when transaction is complete - called with signature (oElement, bSuccess)
* @param {Boolean} refreshNow (optional) Whether to execute the refresh now, or wait the interval
*/
startAutoRefresh : function(interval, url, params, callback, refreshNow){
var me = this;
if(refreshNow){
me.update(url || me.defaultUrl, params, callback, true);
}
share/docs/source/UpdateManager.html view on Meta::CPAN
<span id='Ext-Updater-method-abort'> /**
</span> * Aborts the currently executing transaction, if any.
*/
abort : function(){
if(this.transaction){
Ext.Ajax.abort(this.transaction);
}
},
<span id='Ext-Updater-method-isUpdating'> /**
</span> * Returns true if an update is in progress, otherwise false.
* @return {Boolean}
*/
isUpdating : function(){
return this.transaction ? Ext.Ajax.isLoading(this.transaction) : false;
},
<span id='Ext-Updater-method-refresh'> /**
</span> * Refresh the element with the last used url or defaultUrl. If there is no url, it returns immediately
* @param {Function} callback (optional) Callback when transaction is complete - called with signature (oElement, bSuccess)
*/
refresh : function(callback){
if(this.defaultUrl){
this.update(this.defaultUrl, null, callback, true);
}
}
};
}());
<span id='Ext-Updater-defaults'>/**
</span> * @class Ext.Updater.defaults
* The defaults collection enables customizing the default properties of Updater
*/
Ext.Updater.defaults = {
<span id='Ext-Updater-defaults-property-timeout'> /**
</span> * Timeout for requests or form posts in seconds (defaults to 30 seconds).
* @type Number
*/
timeout : 30,
<span id='Ext-Updater-defaults-property-disableCaching'> /**
</span> * True to append a unique parameter to GET requests to disable caching (defaults to false).
* @type Boolean
*/
disableCaching : false,
<span id='Ext-Updater-defaults-property-showLoadIndicator'> /**
</span> * Whether or not to show {@link #indicatorText} during loading (defaults to true).
* @type Boolean
*/
showLoadIndicator : true,
<span id='Ext-Updater-defaults-property-indicatorText'> /**
</span> * Text for loading indicator (defaults to '&lt;div class="loading-indicator"&gt;Loading...&lt;/div&gt;').
* @type String
*/
indicatorText : '<div class="loading-indicator">Loading...</div>',
<span id='Ext-Updater-defaults-property-loadScripts'> /**
</span> * True to process scripts by default (defaults to false).
* @type Boolean
*/
loadScripts : false,
<span id='Ext-Updater-defaults-property-sslBlankUrl'> /**
</span> * Blank page URL to use with SSL file uploads (defaults to {@link Ext#SSL_SECURE_URL} if set, or "javascript:false").
* @type String
*/
sslBlankUrl : Ext.SSL_SECURE_URL
};
<span id='Ext-Updater-static-method-updateElement'>/**
</span> * Static convenience method. <b>This method is deprecated in favor of el.load({url:'foo.php', ...})</b>.
* Usage:
* <pre><code>Ext.Updater.updateElement("my-div", "stuff.php");</code></pre>
* @param {Mixed} el The element to update
* @param {String} url The url
* @param {String/Object} params (optional) Url encoded param string or an object of name/value pairs
* @param {Object} options (optional) A config object with any of the Updater properties you want to set - for
* example: {disableCaching:true, indicatorText: "Loading data..."}
* @static
* @deprecated
* @member Ext.Updater
*/
Ext.Updater.updateElement = function(el, url, params, options){
var um = Ext.get(el).getUpdater();
Ext.apply(um, options);
um.update(url, params, options ? options.callback : null);
};
<span id='Ext-Updater-BasicRenderer'>/**
</span> * @class Ext.Updater.BasicRenderer
* <p>This class is a base class implementing a simple render method which updates an element using results from an Ajax request.</p>
* <p>The BasicRenderer updates the element's innerHTML with the responseText. To perform a custom render (i.e. XML or JSON processing),
* create an object with a conforming {@link #render} method and pass it to setRenderer on the Updater.</p>
*/
Ext.Updater.BasicRenderer = function(){};
Ext.Updater.BasicRenderer.prototype = {
<span id='Ext-Updater-BasicRenderer-method-render'> /**
</span> * This method is called when an Ajax response is received, and an Element needs updating.
* @param {Ext.Element} el The element being rendered
* @param {Object} xhr The XMLHttpRequest object
* @param {Updater} updateManager The calling update manager
* @param {Function} callback A callback that will need to be called if loadScripts is true on the Updater
*/
render : function(el, response, updateManager, callback){
el.update(response.responseText, updateManager.loadScripts, callback);
}
};</pre>
</body>
</html>
( run in 0.494 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )