+<!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.3.0
- * Copyright(c) 2006-2010 Ext JS, Inc.
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-<div id="cls-Ext.direct.PollingProvider"></div>/**
- * @class Ext.direct.PollingProvider
+<body onload="prettyPrint(); highlight();">
+ <pre class="prettyprint lang-js"><span id='Ext-direct-PollingProvider'>/**
+</span> * @class Ext.direct.PollingProvider
* @extends Ext.direct.JsonProvider
*
- * <p>Provides for repetitive polling of the server at distinct {@link #interval intervals}.
+ * <p>Provides for repetitive polling of the server at distinct {@link #interval intervals}.
* The initial request for data originates from the client, and then is responded to by the
- * server.</p>
+ * server.</p>
*
- * <p>All configurations for the PollingProvider should be generated by the server-side
- * API portion of the Ext.Direct stack.</p>
+ * <p>All configurations for the PollingProvider should be generated by the server-side
+ * API portion of the Ext.Direct stack.</p>
*
- * <p>An instance of PollingProvider may be created directly via the new keyword or by simply
- * specifying <tt>type = 'polling'</tt>. For example:</p>
- * <pre><code>
+ * <p>An instance of PollingProvider may be created directly via the new keyword or by simply
+ * specifying <tt>type = 'polling'</tt>. For example:</p>
+ * <pre><code>
var pollA = new Ext.direct.PollingProvider({
type:'polling',
url: 'php/pollA.php',
});
-Ext.Direct.addProvider(pollA);
+Ext.direct.Manager.addProvider(pollA);
pollA.disconnect();
-Ext.Direct.addProvider(
+Ext.direct.Manager.addProvider(
{
type:'polling',
url: 'php/pollB.php',
id: 'pollB-provider'
}
);
-var pollB = Ext.Direct.getProvider('pollB-provider');
- * </code></pre>
+var pollB = Ext.direct.Manager.getProvider('pollB-provider');
+ * </code></pre>
*/
-Ext.direct.PollingProvider = Ext.extend(Ext.direct.JsonProvider, {
- <div id="cfg-Ext.direct.PollingProvider-priority"></div>/**
- * @cfg {Number} priority
- * Priority of the request (defaults to <tt>3</tt>). See {@link Ext.direct.Provider#priority}.
- */
- // override default priority
- priority: 3,
+Ext.define('Ext.direct.PollingProvider', {
+
+ /* Begin Definitions */
+
+ extend: 'Ext.direct.JsonProvider',
+
+ alias: 'direct.pollingprovider',
- <div id="cfg-Ext.direct.PollingProvider-interval"></div>/**
- * @cfg {Number} interval
- * How often to poll the server-side in milliseconds (defaults to <tt>3000</tt> - every
- * 3 seconds).
+ uses: ['Ext.direct.ExceptionEvent'],
+
+ requires: ['Ext.Ajax', 'Ext.util.DelayedTask'],
+
+ /* End Definitions */
+
+<span id='Ext-direct-PollingProvider-cfg-interval'> /**
+</span> * @cfg {Number} interval
+ * How often to poll the server-side in milliseconds. Defaults to every 3 seconds.
*/
interval: 3000,
- <div id="cfg-Ext.direct.PollingProvider-baseParams"></div>/**
- * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
- * on every polling request
+<span id='Ext-direct-PollingProvider-cfg-baseParams'> /**
+</span> * @cfg {Object} baseParams
+ * An object containing properties which are to be sent as parameters on every polling request
*/
- <div id="cfg-Ext.direct.PollingProvider-url"></div>/**
- * @cfg {String/Function} url
+<span id='Ext-direct-PollingProvider-cfg-url'> /**
+</span> * @cfg {String/Function} url
* The url which the PollingProvider should contact with each request. This can also be
* an imported Ext.Direct method which will accept the baseParams as its only argument.
*/
// private
constructor : function(config){
- Ext.direct.PollingProvider.superclass.constructor.call(this, config);
+ this.callParent(arguments);
this.addEvents(
- <div id="event-Ext.direct.PollingProvider-beforepoll"></div>/**
- * @event beforepoll
+<span id='Ext-direct-PollingProvider-event-beforepoll'> /**
+</span> * @event beforepoll
* Fired immediately before a poll takes place, an event handler can return false
* in order to cancel the poll.
- * @param {Ext.direct.PollingProvider}
+ * @param {Ext.direct.PollingProvider} this
*/
'beforepoll',
- <div id="event-Ext.direct.PollingProvider-poll"></div>/**
- * @event poll
+<span id='Ext-direct-PollingProvider-event-poll'> /**
+</span> * @event poll
* This event has not yet been implemented.
- * @param {Ext.direct.PollingProvider}
+ * @param {Ext.direct.PollingProvider} this
*/
'poll'
);
return !!this.pollTask;
},
- <div id="method-Ext.direct.PollingProvider-connect"></div>/**
- * Connect to the server-side and begin the polling process. To handle each
+<span id='Ext-direct-PollingProvider-method-connect'> /**
+</span> * Connect to the server-side and begin the polling process. To handle each
* response subscribe to the data event.
*/
connect: function(){
- if(this.url && !this.pollTask){
- this.pollTask = Ext.TaskMgr.start({
+ var me = this, url = me.url;
+
+ if (url && !me.pollTask) {
+ me.pollTask = Ext.TaskManager.start({
run: function(){
- if(this.fireEvent('beforepoll', this) !== false){
- if(typeof this.url == 'function'){
- this.url(this.baseParams);
- }else{
+ if (me.fireEvent('beforepoll', me) !== false) {
+ if (Ext.isFunction(url)) {
+ url(me.baseParams);
+ } else {
Ext.Ajax.request({
- url: this.url,
- callback: this.onData,
- scope: this,
- params: this.baseParams
+ url: url,
+ callback: me.onData,
+ scope: me,
+ params: me.baseParams
});
}
}
},
- interval: this.interval,
- scope: this
+ interval: me.interval,
+ scope: me
});
- this.fireEvent('connect', this);
- }else if(!this.url){
- throw 'Error initializing PollingProvider, no url configured.';
+ me.fireEvent('connect', me);
+ } else if (!url) {
+ //<debug>
+ Ext.Error.raise('Error initializing PollingProvider, no url configured.');
+ //</debug>
}
},
- <div id="method-Ext.direct.PollingProvider-disconnect"></div>/**
- * Disconnect from the server-side and stop the polling process. The disconnect
+<span id='Ext-direct-PollingProvider-method-disconnect'> /**
+</span> * Disconnect from the server-side and stop the polling process. The disconnect
* event will be fired on a successful disconnect.
*/
disconnect: function(){
- if(this.pollTask){
- Ext.TaskMgr.stop(this.pollTask);
- delete this.pollTask;
- this.fireEvent('disconnect', this);
+ var me = this;
+
+ if (me.pollTask) {
+ Ext.TaskManager.stop(me.pollTask);
+ delete me.pollTask;
+ me.fireEvent('disconnect', me);
}
},
// private
- onData: function(opt, success, xhr){
- if(success){
- var events = this.getEvents(xhr);
- for(var i = 0, len = events.length; i < len; i++){
- var e = events[i];
- this.fireEvent('data', this, e);
+ onData: function(opt, success, response){
+ var me = this,
+ i = 0,
+ len,
+ events;
+
+ if (success) {
+ events = me.createEvents(response);
+ for (len = events.length; i < len; ++i) {
+ me.fireEvent('data', me, events[i]);
}
- }else{
- var e = new Ext.Direct.ExceptionEvent({
- data: e,
- code: Ext.Direct.exceptions.TRANSPORT,
+ } else {
+ me.fireEvent('data', me, Ext.create('Ext.direct.ExceptionEvent', {
+ data: null,
+ code: Ext.direct.Manager.self.exceptions.TRANSPORT,
message: 'Unable to connect to the server.',
- xhr: xhr
- });
- this.fireEvent('data', this, e);
+ xhr: response
+ }));
}
}
-});
-
-Ext.Direct.PROVIDERS['polling'] = Ext.direct.PollingProvider;</pre>
+});</pre>
</body>
-</html>
\ No newline at end of file
+</html>