forked from extmvc/extmvc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Presenter.js
52 lines (44 loc) · 1.16 KB
/
Presenter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @class ExtMVC.Presenter
* @extends Ext.util.Observable
* Used as an interface between a controller and its views
*/
ExtMVC.Presenter = Ext.extend(Ext.util.Observable, {
constructor: function(config) {
ExtMVC.Presenter.superclass.constructor.apply(this, arguments);
this.addEvents(
/**
* @event load
* Fires when all items in the Presenter have been loaded
*/
'load'
);
/**
* @property loaded
* @type Boolean
* True if all items that must be loaded before rendering have been
*/
this.loaded = false;
/**
* @property loading
* @type Boolean
* True while the loader is loading
*/
this.loading = false;
},
load: function() {
if (this.loaded || this.loading) return;
this.each(function(item, index, length) {
var callback = function(index) {
return function() {
if (index == length) {
this.loaded = true;
this.loading = false;
this.fireEvent('load');
}
};
}(index);
item.on('load', callback, this, {single: true});
}, this);
}
});