Browse files

converting code to use events

  • Loading branch information...
1 parent 5350e69 commit c501ffbf6c5a9f38218ac6f8c41e6a25a7e7a31f @VinylFox committed Jan 10, 2011
Showing with 11 additions and 11 deletions.
  1. +2 −0 README.rdoc
  2. +9 −11 src/Ext.ux.touch.ListPullRefresh.js
View
2 README.rdoc
@@ -4,6 +4,8 @@ This is a plugin based on enormego's EGOTableViewPullRefresh implementation whic
Same concept as usual - you have a list of items, and you drag the list down which reveals the 'Pull To Refresh...' section. Releasing the list and letting it bounce back into place will trigger a reload. Sliding the list back up past a certian point then releasing it will not cause a reload.
+http://content.screencast.com/users/VinylFox/folders/Jing/media/7060ea80-1e2c-4cd6-a102-a53120d7e665/2010-11-29_1457.png
+
Resources for CSS and Images are located in the resources folder. Image URL's in the CSS will need to be updated to suit your particular setup.
= Usage
View
20 src/Ext.ux.touch.ListPullRefresh.js
@@ -42,21 +42,23 @@ Ext.ns('Ext.ux.touch');
* </code></pre>
*/
Ext.ux.touch.ListPullRefresh = Ext.extend(Ext.util.Observable, {
+ constructor: function(config){
+ Ext.apply(this,config);
+ this.addEvents({
+ 'released': true
+ });
+ Ext.ux.touch.ListPullRefresh.superclass.constructor.call(this, config);
+ },
langPullRefresh: 'Pull down to refresh...',
langReleaseRefresh: 'Release to refresh...',
langLoading: 'Loading...',
loading: false,
- //define the function to call for reloading.
- reloadFn: undefined,
// private
init: function(cmp){
this.cmp = cmp;
this.lastUpdate = new Date();
cmp.loadingText = undefined;
cmp.on('render', this.initPullHandler, this);
- if (!this.reloadFn){
- cmp.getStore().on('load', this.reloadComplete, this);
- }
},
// private
initPullHandler: function(){
@@ -95,11 +97,7 @@ Ext.ux.touch.ListPullRefresh = Ext.extend(Ext.util.Observable, {
this.loading = true;
this.lastUpdate = new Date();
this.pullEl.hide();
- if (this.reloadFn){
- this.reloadFn.call(this,this.reloadComplete,this);
- }else{
- this.cmp.getStore().load();
- }
+ this.fireEvent('released',this,this.cmp);
}
}
}else{
@@ -118,7 +116,7 @@ Ext.ux.touch.ListPullRefresh = Ext.extend(Ext.util.Observable, {
}
},
//private
- reloadComplete: function(){
+ processComplete: function(){
this.loading = false;
this.lastUpdate = new Date();
this.pullTpl.overwrite(this.pullEl, {h:0,m:this.langPullRefresh,l:this.lastUpdate});

0 comments on commit c501ffb

Please sign in to comment.