]> git.proxmox.com Git - extjs.git/blob - extjs/packages/core/src/event/publisher/ElementPaint.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / core / src / event / publisher / ElementPaint.js
1 /**
2 * @private
3 */
4 Ext.define('Ext.event.publisher.ElementPaint', {
5
6 extend: 'Ext.event.publisher.Publisher',
7
8 requires: [
9 'Ext.util.PaintMonitor',
10 'Ext.TaskQueue'
11 ],
12
13 type: 'paint',
14
15 handledEvents: ['painted'],
16
17 constructor: function() {
18 this.monitors = {};
19 this.subscribers = {};
20
21 this.callParent(arguments);
22 },
23
24 subscribe: function(element) {
25 var me = this,
26 id = element.id,
27 subscribers = me.subscribers;
28
29 if (subscribers[id]) {
30 ++subscribers[id];
31 } else {
32 subscribers[id] = 1;
33
34 me.monitors[id] = new Ext.util.PaintMonitor({
35 element: element,
36 callback: me.onElementPainted,
37 scope: me,
38 args: [element]
39 });
40 }
41 },
42
43 unsubscribe: function(element) {
44 var id = element.id,
45 subscribers = this.subscribers,
46 monitors = this.monitors;
47
48 if (subscribers[id] && !--subscribers[id]) {
49 delete subscribers[id];
50 monitors[id].destroy();
51 delete monitors[id];
52 }
53 },
54
55 onElementPainted: function(element) {
56 Ext.TaskQueue.requestRead('fire', this, [element, 'painted', [element]]);
57 }
58 }, function(ElementPaint) {
59 ElementPaint.instance = new ElementPaint();
60 });