Program.js
2.71 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Ext.define('MyMA.controller.Program', {
extend: 'Ext.app.Controller',
stores: ['Programs'],
refs: [{
selector: 'taskpanel',
ref: 'taskPanel'
}],
init: function() {
var control = {};
Ext.each(this.refs, function(item){
this.control[item.selector] = {
beforeclose: this.me.programStop,
hide: this.me.programState,
show: this.me.programState,
minimize: this.me.programMinimize
}
}, {
control: control,
me: this
});
this.control(control);
},
/**
* Register controll for the created "Program"
* @param String, selector name
*/
registerControl: function(selector) {
var selector = selector || null,
ctrl = {};
if(!selector) {
return;
}
ctrl[selector] = {
beforeclose: this.programStop,
hide: this.programState,
show: this.programState,
minimize: this.programMinimize
};
this.control(ctrl);
}, // end registerControl()
/**
* Hides widget and sets status to the Store object
* @param {Object} item
*/
programMinimize: function(item) {
var record;
if(!(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
})))
{
return false;
}
this.getTaskPanel().items.get(record.get('control')).toggle(false);
item.hide();
this.programState(item);
}, // end programMinimize()
/**
* Writes program state to the Store object
* @param {Object} item
* @param {Object} opt
*/
programState: function(item, opt) {
var record;
if(!(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
})))
{
return false;
}
record.set('state', item.isHidden() ? 'hide' : 'show');
}, // end programState()
/**
* Destroyes wiget and removes program information from the Store
* @param {Object} item
* @param {Object} record
*/
programStop: function(item, record) {
var record = record || Ext.undefined;
if (!record['data']) {
(record = this.getStore('Programs').getProccess({
property: 'item',
value: item.getId()
}));
}
if(item.animateTarget) {
item.animateTarget = null;
}
if(record && record['data']) {
this.getTaskPanel().items.get(record.get('control')).destroy();
this.getStore('Programs').remove(record);
}
} // end programStop()
});