This repository has been archived by the owner on Dec 1, 2017. It is now read-only.
/
screen-actions.js
63 lines (54 loc) · 2.09 KB
/
screen-actions.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
53
54
55
56
57
58
59
60
61
62
63
define(['jquery', 'can', './extended', './component-list', './element-list', 'can.super'],
function($, can, ExtendedControl, ComponentListControl, ElementListControl) {
return ExtendedControl({
init: function($element, options) {
this._super($element, options);
// used for event handlers
this.off();
this.options.content = $('#content');
this.options.back = $('#back');
this.on();
// by default, the component list should be shown
this.activateComponentList();
},
activateComponentList: function() {
if (this.elementListControl) {
this.elementListControl.deactivate();
}
this.options.back.find('span').text('project page');
if (this.componentListControl) {
this.componentListControl.activate();
} else {
this.componentListControl = new ComponentListControl(this.element, {});
}
},
activateElementList: function(component) {
if (this.componentListControl) {
this.componentListControl.deactivate();
}
this.options.back.find('span').text('component list');
if (this.elementListControl) {
this.elementListControl.activate();
this.elementListControl.setComponentModel(component);
} else {
this.elementListControl = new ElementListControl(this.element, { component: component });
}
},
'{content} .component-location selected': function($element, event, component) {
this.activateElementList(component);
},
'{content} deselectedAll': function($element, event, component) {
this.activateComponentList();
},
'{back} click': function($element, event) {
if (this.elementListControl && this.elementListControl.isActive()) {
event.preventDefault();
// back button should go to component list
this.activateComponentList();
} else {
// back button should link to project page, as it normally does; no
// need to do anything
}
}
});
});