root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / okeanos-ember / views.js @ 1933ffd6
History | View | Annotate | Download (3.9 kB)
1 |
/* Views */
|
---|---|
2 |
|
3 |
Synnefo.ApplicationView = Ember.View.extend({ |
4 |
classNames: ['content'] |
5 |
}); |
6 |
|
7 |
|
8 |
/* Navigation Menu */
|
9 |
|
10 |
Synnefo.NavIconView = Ember.View.extend({ |
11 |
tagName: 'span', |
12 |
click: function() { |
13 |
var parentEl = this.$().parent('a'); |
14 |
var currentEl = this.$().parents('li').siblings('li').find('a.current'); |
15 |
|
16 |
ui.replaceClass(currentEl, 'full', 'outline', 'snf-'); |
17 |
ui.replaceClass(parentEl, 'outline', 'full', 'snf-'); |
18 |
} |
19 |
|
20 |
}); |
21 |
|
22 |
Synnefo.NavigationView = Ember.CollectionView.extend({ |
23 |
tagName: "ul", |
24 |
classNames: ['icons-nav'], |
25 |
|
26 |
content: Synnefo.conf.sectors,
|
27 |
itemViewClass: Ember.View.extend({
|
28 |
templateName: "navigationItem" |
29 |
}), |
30 |
}); |
31 |
|
32 |
|
33 |
/* Items Parts */
|
34 |
|
35 |
Synnefo.ElemView = Ember.View.extend({ |
36 |
// templateName: 'elem',
|
37 |
addNewBtn: false, |
38 |
templateName: 'snfElem', |
39 |
tagName: 'li', |
40 |
selectable: true, |
41 |
initSelect: 'unchecked', |
42 |
classNameBindings: ['status'], |
43 |
attributeBindings: ['data-status'], |
44 |
'data-status': function() { |
45 |
return this.status; |
46 |
}.property(), |
47 |
status: function() { |
48 |
return this.get('controller.status'); |
49 |
}.property('controller.status')
|
50 |
}); |
51 |
|
52 |
Synnefo.ImgWrapView = Ember.View.extend({ |
53 |
templateName: 'img-wrap', |
54 |
classNames: ['img-wrap'], |
55 |
icon: function() { |
56 |
var parentView = this.get('parentView'); |
57 |
var addNewBtn = parentView.get('addNewBtn'); |
58 |
if(addNewBtn)
|
59 |
return parentView.get('icon'); |
60 |
else
|
61 |
return parentView.get('controller').get('parentController').get('icon'); |
62 |
}.property() |
63 |
}); |
64 |
|
65 |
Synnefo.NameView = Ember.View.extend({ |
66 |
templateName: 'name', |
67 |
tagName: 'h4', |
68 |
name: function() { |
69 |
// the name may be defined inside the parent view or in its model or controller
|
70 |
return this.get('parentView').get('controller').get('name'); |
71 |
}.property() |
72 |
}); |
73 |
|
74 |
// to be changed
|
75 |
Synnefo.ImmediateActionView = Ember.View.extend({ |
76 |
templateName: 'actions', |
77 |
classNames: ['actions'] |
78 |
}); |
79 |
|
80 |
|
81 |
/* Wizard */
|
82 |
|
83 |
Synnefo.WizardHeadersView = Ember.CollectionView.extend({ |
84 |
tagName: 'ul', |
85 |
classNames:['nums'], |
86 |
content: Synnefo.wizards.vmWizard.stepsHeadlines,
|
87 |
counter: 0, |
88 |
setCurrentHeader: function() { |
89 |
step = this.get('controller').get('currentStep'); |
90 |
console.log('* step', step);
|
91 |
return step;
|
92 |
}.property('controller.currentStep'),
|
93 |
didInsertElement: function() { |
94 |
console.log('collecton inserted');
|
95 |
this.setCurrentHeader;
|
96 |
}, |
97 |
itemViewClass: Ember.View.extend({
|
98 |
templateName: 'wizardStepHeader', |
99 |
classNameBindings: ['isCurrent:current::', 'isFirst:preselected', 'isPast:past::'], |
100 |
index: undefined, |
101 |
isCurrent: false, |
102 |
isFirst: false, |
103 |
init: function() { |
104 |
this._super();
|
105 |
console.log('init');
|
106 |
var prevIndex = this.get('parentView').get('counter'); |
107 |
prevIndex++; |
108 |
console.log('prevIndex', prevIndex)
|
109 |
this.get('parentView').set('counter', prevIndex); |
110 |
this.set('index', prevIndex); |
111 |
if(prevIndex === 1) { |
112 |
this.set('isFirst', true); |
113 |
// this.set('isCurrent', true);
|
114 |
} |
115 |
console.log('current', this.isVisible) |
116 |
}, |
117 |
isCurrent: function() { |
118 |
return this.index === this.get('controller').get('currentStep'); |
119 |
}.property('controller.currentStep'),
|
120 |
|
121 |
isPast: function() { |
122 |
return this.index < this.get('controller').get('currentStep'); |
123 |
}.property('controller.currentStep'),
|
124 |
|
125 |
didInsertElement: function() { |
126 |
} |
127 |
}), |
128 |
}); |
129 |
|
130 |
// The only buttons that are views are the buttons that move the wizard
|
131 |
// The reason is that they shouldn't be isolated from the surrounding
|
132 |
// (Their labels changes depanding the current step)
|
133 |
Synnefo.WizardBtnBackView = Ember.View.extend({ |
134 |
classNames: ['nav', 'prev'], |
135 |
tagName: 'a', |
136 |
templateName: 'components/btns-span', |
137 |
content: function(){ |
138 |
return this.get('controller').get('btnLeftLabel'); |
139 |
}.property('controller.btnLeftLabel'),
|
140 |
click: function() { |
141 |
this.get('controller').send('moveBack'); |
142 |
} |
143 |
}); |
144 |
|
145 |
Synnefo.WizardBtnNextView = Ember.View.extend({ |
146 |
classNames: ['nav', 'next'], |
147 |
tagName: 'a', |
148 |
templateName: 'components/btns-span', |
149 |
content: function(){ |
150 |
return this.get('controller').get('btnRightLabel'); |
151 |
}.property('controller.btnRightLabel'),
|
152 |
click: function() { |
153 |
this.get('controller').send('moveNext'); |
154 |
} |
155 |
}); |
156 |
|