root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / wizard.js @ cf508a0b
History | View | Annotate | Download (16.6 kB)
1 | 937c0d49 | Athina Bekakou | ui.wizard = { |
---|---|---|---|
2 | 937c0d49 | Athina Bekakou | domID: undefined, |
3 | 937c0d49 | Athina Bekakou | currentStep: undefined, |
4 | 937c0d49 | Athina Bekakou | totalStep: undefined, |
5 | 937c0d49 | Athina Bekakou | btns: {
|
6 | 937c0d49 | Athina Bekakou | start: undefined, |
7 | 937c0d49 | Athina Bekakou | close: undefined, |
8 | 937c0d49 | Athina Bekakou | next: undefined, |
9 | 937c0d49 | Athina Bekakou | previous: undefined, |
10 | 937c0d49 | Athina Bekakou | }, |
11 | 937c0d49 | Athina Bekakou | areas : {
|
12 | 937c0d49 | Athina Bekakou | top: {
|
13 | 937c0d49 | Athina Bekakou | header: undefined, |
14 | 937c0d49 | Athina Bekakou | menu: undefined |
15 | 937c0d49 | Athina Bekakou | }, |
16 | 937c0d49 | Athina Bekakou | middle: undefined, |
17 | 937c0d49 | Athina Bekakou | bottom: undefined |
18 | 937c0d49 | Athina Bekakou | }, |
19 | 937c0d49 | Athina Bekakou | speed: 500, |
20 | 937c0d49 | Athina Bekakou | onMove: 0, |
21 | 937c0d49 | Athina Bekakou | |
22 | 937c0d49 | Athina Bekakou | getCurrentStep: function(){ |
23 | 937c0d49 | Athina Bekakou | return ui.wizard.domID.find('.step').filter('.current').first(); |
24 | 937c0d49 | Athina Bekakou | }, |
25 | 937c0d49 | Athina Bekakou | |
26 | 937c0d49 | Athina Bekakou | getNextStep: function() { |
27 | 937c0d49 | Athina Bekakou | return ui.wizard.getCurrentStep().next();
|
28 | 937c0d49 | Athina Bekakou | }, |
29 | 937c0d49 | Athina Bekakou | |
30 | 937c0d49 | Athina Bekakou | getPreviousStep: function() { |
31 | 937c0d49 | Athina Bekakou | return ui.wizard.getCurrentStep().prev();
|
32 | 937c0d49 | Athina Bekakou | }, |
33 | 937c0d49 | Athina Bekakou | |
34 | 937c0d49 | Athina Bekakou | getScrollOffset: function() { |
35 | 937c0d49 | Athina Bekakou | return document.body.scrollTop;
|
36 | 937c0d49 | Athina Bekakou | }, |
37 | 937c0d49 | Athina Bekakou | |
38 | 937c0d49 | Athina Bekakou | submitData: function() { |
39 | 937c0d49 | Athina Bekakou | console.log('submit data dummy function');
|
40 | 937c0d49 | Athina Bekakou | }, |
41 | 937c0d49 | Athina Bekakou | |
42 | 937c0d49 | Athina Bekakou | |
43 | 937c0d49 | Athina Bekakou | |
44 | 937c0d49 | Athina Bekakou | move: function(stepToDisplay, pos) { |
45 | 937c0d49 | Athina Bekakou | ui.wizard.onMove = 1;
|
46 | 937c0d49 | Athina Bekakou | ui.wizard.focusFun(); |
47 | 937c0d49 | Athina Bekakou | ui.wizard.indicateStep(); |
48 | 937c0d49 | Athina Bekakou | ui.wizard.setMovementTags(); |
49 | 937c0d49 | Athina Bekakou | $('body').css('overflow','hidden'); |
50 | 937c0d49 | Athina Bekakou | // the current visible pane
|
51 | 937c0d49 | Athina Bekakou | var current = this.getCurrentStep(); |
52 | 937c0d49 | Athina Bekakou | // Set next pane position on the right of the current one
|
53 | 937c0d49 | Athina Bekakou | // Add current to the next pane, so that it will become
|
54 | 937c0d49 | Athina Bekakou | // visible
|
55 | 937c0d49 | Athina Bekakou | stepToDisplay.css({ |
56 | 937c0d49 | Athina Bekakou | left: pos.toString() + '%' |
57 | 937c0d49 | Athina Bekakou | }).addClass("current");
|
58 | 937c0d49 | Athina Bekakou | // identify the current scroll position. Use it to
|
59 | 937c0d49 | Athina Bekakou | // set next pane top position. We assume all panes
|
60 | 937c0d49 | Athina Bekakou | // are within the scroll context of the main window.
|
61 | 937c0d49 | Athina Bekakou | stepToDisplay.css({ |
62 | 937c0d49 | Athina Bekakou | top: this.getScrollOffset() + 'px' |
63 | 937c0d49 | Athina Bekakou | }); |
64 | 937c0d49 | Athina Bekakou | ui.wizard.domID.find('.step').animate({
|
65 | 937c0d49 | Athina Bekakou | marginLeft: (-pos).toString() + '%' |
66 | 937c0d49 | Athina Bekakou | }, { |
67 | 937c0d49 | Athina Bekakou | complete: _.bind(function() { |
68 | 937c0d49 | Athina Bekakou | // assuming all the following take place
|
69 | 937c0d49 | Athina Bekakou | // instantaneously within a single browser
|
70 | 937c0d49 | Athina Bekakou | // render cycle, no flickering should occur.
|
71 | 937c0d49 | Athina Bekakou | current.removeClass("current");
|
72 | 937c0d49 | Athina Bekakou | window.scroll(0, 0); |
73 | 937c0d49 | Athina Bekakou | stepToDisplay.css({ |
74 | 937c0d49 | Athina Bekakou | left: '0', |
75 | 937c0d49 | Athina Bekakou | top: '0' |
76 | 937c0d49 | Athina Bekakou | }); |
77 | 937c0d49 | Athina Bekakou | $('.step').css({ |
78 | 937c0d49 | Athina Bekakou | marginLeft: '0' |
79 | 937c0d49 | Athina Bekakou | }); |
80 | 937c0d49 | Athina Bekakou | $('body').css('overflow','visible'); |
81 | 937c0d49 | Athina Bekakou | if (ui.wizard.currentStep == 3 ){ |
82 | 937c0d49 | Athina Bekakou | $('.vm-name input').first().focus(); |
83 | 937c0d49 | Athina Bekakou | } |
84 | 937c0d49 | Athina Bekakou | $('.actions-bar').show(); |
85 | 937c0d49 | Athina Bekakou | ui.wizard.onMove = 0;
|
86 | 937c0d49 | Athina Bekakou | }, this)
|
87 | 937c0d49 | Athina Bekakou | }); |
88 | 937c0d49 | Athina Bekakou | |
89 | 937c0d49 | Athina Bekakou | }, |
90 | 937c0d49 | Athina Bekakou | |
91 | 937c0d49 | Athina Bekakou | data_next_array: ['el0', 'el2', 'el4', 'el7'], |
92 | 937c0d49 | Athina Bekakou | |
93 | 937c0d49 | Athina Bekakou | focusFun: function() { |
94 | 937c0d49 | Athina Bekakou | var step = ui.wizard.currentStep;
|
95 | 937c0d49 | Athina Bekakou | var nextBtn = ui.wizard.btns.next;
|
96 | 937c0d49 | Athina Bekakou | |
97 | 937c0d49 | Athina Bekakou | $('.firstfocus-' + step + '').first().focus(); |
98 | 937c0d49 | Athina Bekakou | nextBtn.removeAttr('data-next');
|
99 | 937c0d49 | Athina Bekakou | nextBtn.attr('data-next', ui.wizard.data_next_array[step]);
|
100 | 937c0d49 | Athina Bekakou | }, |
101 | 937c0d49 | Athina Bekakou | |
102 | 937c0d49 | Athina Bekakou | goNext: function() { |
103 | 937c0d49 | Athina Bekakou | var next = ui.wizard.getNextStep();
|
104 | 937c0d49 | Athina Bekakou | if (ui.wizard.onMove == 0) { |
105 | 937c0d49 | Athina Bekakou | ui.wizard.currentStep++; |
106 | 937c0d49 | Athina Bekakou | ui.wizard.move(next, 100);
|
107 | 937c0d49 | Athina Bekakou | } |
108 | 937c0d49 | Athina Bekakou | }, |
109 | 937c0d49 | Athina Bekakou | |
110 | 937c0d49 | Athina Bekakou | goPrev: function() { |
111 | 937c0d49 | Athina Bekakou | var prev = ui.wizard.getPreviousStep();
|
112 | 937c0d49 | Athina Bekakou | if (ui.wizard.onMove == 0) { |
113 | 937c0d49 | Athina Bekakou | ui.wizard.currentStep--; |
114 | 937c0d49 | Athina Bekakou | ui.wizard.move(prev, -100);
|
115 | 937c0d49 | Athina Bekakou | } |
116 | 937c0d49 | Athina Bekakou | }, |
117 | 937c0d49 | Athina Bekakou | |
118 | 937c0d49 | Athina Bekakou | indicateStep: function() { |
119 | 937c0d49 | Athina Bekakou | var step =ui.wizard.currentStep;
|
120 | 937c0d49 | Athina Bekakou | var menus = ui.wizard.areas.top.menu;
|
121 | 937c0d49 | Athina Bekakou | var wizardHeader = ui.wizard.areas.top.header;
|
122 | 937c0d49 | Athina Bekakou | |
123 | 937c0d49 | Athina Bekakou | menus.find('.sub-menu').hide();
|
124 | 937c0d49 | Athina Bekakou | menus.find('.sub-menu[data-step='+step+']').fadeIn(); |
125 | 937c0d49 | Athina Bekakou | wizardHeader.children().removeClass('current');
|
126 | 937c0d49 | Athina Bekakou | wizardHeader.find('li:not(".current")').show().css("display", "inline"); |
127 | 937c0d49 | Athina Bekakou | wizardHeader.find('li:nth-child(' + step + ')').addClass('current'); |
128 | 937c0d49 | Athina Bekakou | wizardHeader.find('li.current').hide();
|
129 | 937c0d49 | Athina Bekakou | wizardHeader.find('li.current').fadeIn('slow').css("display", "inline"); |
130 | 937c0d49 | Athina Bekakou | wizardHeader.find('.current').prevAll('li').hide(); |
131 | 937c0d49 | Athina Bekakou | }, |
132 | 937c0d49 | Athina Bekakou | |
133 | 937c0d49 | Athina Bekakou | // changes the text of next and previous buttons
|
134 | 937c0d49 | Athina Bekakou | setMovementTags: function() { |
135 | 337ea026 | Athina Bekakou | var step = ui.wizard.currentStep;
|
136 | 937c0d49 | Athina Bekakou | var totalStep = ui.wizard.totalStep;
|
137 | 937c0d49 | Athina Bekakou | var prevBtnLabel = ui.wizard.btns.previous.find('span'); |
138 | 937c0d49 | Athina Bekakou | var nextBtnLabel = ui.wizard.btns.next.find('span'); |
139 | 937c0d49 | Athina Bekakou | |
140 | 937c0d49 | Athina Bekakou | if(totalStep == 1) { |
141 | 937c0d49 | Athina Bekakou | prevBtnLabel.html('CANCEL');
|
142 | 937c0d49 | Athina Bekakou | nextBtnLabel.html('CREATE');
|
143 | 937c0d49 | Athina Bekakou | } |
144 | 937c0d49 | Athina Bekakou | else {
|
145 | 937c0d49 | Athina Bekakou | if (step == 1) { |
146 | 937c0d49 | Athina Bekakou | prevBtnLabel.html('CANCEL');
|
147 | 937c0d49 | Athina Bekakou | nextBtnLabel.html('NEXT');
|
148 | 937c0d49 | Athina Bekakou | } else if (step == totalStep) { |
149 | 937c0d49 | Athina Bekakou | prevBtnLabel.html('PREVIOUS');
|
150 | 937c0d49 | Athina Bekakou | nextBtnLabel.html('CREATE');
|
151 | 937c0d49 | Athina Bekakou | } else if (ui.wizard.vm.hideNext()){ |
152 | 937c0d49 | Athina Bekakou | // ***
|
153 | 937c0d49 | Athina Bekakou | ui.wizard.btns.next.hide(); |
154 | 937c0d49 | Athina Bekakou | } else {
|
155 | 937c0d49 | Athina Bekakou | prevBtnLabel.html('PREVIOUS');
|
156 | 937c0d49 | Athina Bekakou | nextBtnLabel.html('NEXT');
|
157 | 937c0d49 | Athina Bekakou | } |
158 | 937c0d49 | Athina Bekakou | } |
159 | 937c0d49 | Athina Bekakou | }, |
160 | 937c0d49 | Athina Bekakou | close: function() { |
161 | 6e73603a | Athina Bekakou | console.log('1');
|
162 | 937c0d49 | Athina Bekakou | $('body').removeClass('with-overlay'); |
163 | 6e73603a | Athina Bekakou | $('.overlay-area-custom').fadeOut(400, function() { |
164 | 937c0d49 | Athina Bekakou | $('.overlay-div').hide(); |
165 | 937c0d49 | Athina Bekakou | ui.wizard.reset(); |
166 | 937c0d49 | Athina Bekakou | }); |
167 | 937c0d49 | Athina Bekakou | }, |
168 | 937c0d49 | Athina Bekakou | |
169 | 937c0d49 | Athina Bekakou | reset: function() { |
170 | 937c0d49 | Athina Bekakou | var wizard = ui.wizard.domID;
|
171 | 937c0d49 | Athina Bekakou | var wizardType = wizard.attr('id'); |
172 | 937c0d49 | Athina Bekakou | |
173 | 937c0d49 | Athina Bekakou | if(wizardType == 'vm-wizard') { |
174 | 937c0d49 | Athina Bekakou | wizard.find('.networks-area .more').show();
|
175 | 937c0d49 | Athina Bekakou | wizard.find('.details').hide();
|
176 | 937c0d49 | Athina Bekakou | wizard.find('.os li').hide();
|
177 | 937c0d49 | Athina Bekakou | wizard.find('.advanced-conf-options').hide();
|
178 | 937c0d49 | Athina Bekakou | wizard.find('.snf-color-picker').hide();
|
179 | 937c0d49 | Athina Bekakou | |
180 | 937c0d49 | Athina Bekakou | } |
181 | 937c0d49 | Athina Bekakou | else if(wizardType == 'network-wizard') { |
182 | 937c0d49 | Athina Bekakou | wizard.find('li .manual .input').hide();
|
183 | 937c0d49 | Athina Bekakou | wizard.find('ul.subnet_options').parent('li').show(); |
184 | 937c0d49 | Athina Bekakou | } |
185 | 937c0d49 | Athina Bekakou | |
186 | 937c0d49 | Athina Bekakou | ui.wizard.currentStep = 1;
|
187 | 937c0d49 | Athina Bekakou | wizard.find('.step').removeAttr('style'); |
188 | 937c0d49 | Athina Bekakou | wizard.find('.bottom').show();
|
189 | 937c0d49 | Athina Bekakou | wizard.find('input').val(''); |
190 | 937c0d49 | Athina Bekakou | ui.wizard.indicateStep(); |
191 | 937c0d49 | Athina Bekakou | ui.wizard.setMovementTags(); |
192 | 937c0d49 | Athina Bekakou | ui.wizard.preselectElements(wizardType); |
193 | 937c0d49 | Athina Bekakou | }, |
194 | 937c0d49 | Athina Bekakou | |
195 | 937c0d49 | Athina Bekakou | preselectElements: function(wizardType) { |
196 | 937c0d49 | Athina Bekakou | var wizard = ui.wizard.domID;
|
197 | 937c0d49 | Athina Bekakou | |
198 | 937c0d49 | Athina Bekakou | wizard.find('.current').not('.preselected').removeClass('current'); |
199 | 937c0d49 | Athina Bekakou | wizard.find('.preselected').not('.current').addClass('current'); |
200 | 937c0d49 | Athina Bekakou | wizard.find('.custom.dropdown.medium a:first').addClass('current'); // to fix |
201 | 937c0d49 | Athina Bekakou | wizard.find('.snf-radio-checked').not('.prechecked').toggleClass('snf-radio-checked snf-radio-unchecked'); |
202 | 937c0d49 | Athina Bekakou | wizard.find('.snf-radio-unchecked.prechecked').toggleClass('snf-radio-checked snf-radio-unchecked'); |
203 | 937c0d49 | Athina Bekakou | wizard.find('.snf-checkbox-checked').not('.prechecked').toggleClass('snf-checkbox-checked snf-checkbox-unchecked'); |
204 | 937c0d49 | Athina Bekakou | wizard.find('.snf-checkbox-unchecked.prechecked').toggleClass('snf-checkbox-checked snf-checkbox-unchecked'); |
205 | 937c0d49 | Athina Bekakou | wizard.find('.snf-arrow-up.preselected').toggleClass('snf-arrow-up snf-arrow-down'); |
206 | 937c0d49 | Athina Bekakou | if(wizardType == 'vm-wizard') { |
207 | 937c0d49 | Athina Bekakou | var preselectedImgCategory = wizard.find('.top .sub-menu[data-step=1] .preselected').data('img-type'); |
208 | 937c0d49 | Athina Bekakou | wizard.find('.os .'+preselectedImgCategory).show();
|
209 | 937c0d49 | Athina Bekakou | } |
210 | 937c0d49 | Athina Bekakou | }, |
211 | 937c0d49 | Athina Bekakou | |
212 | 38c7643e | Athina Bekakou | // use the showExplanatory and hideExplanatory functions
|
213 | 38c7643e | Athina Bekakou | // when there's html structure as the following:
|
214 | 38c7643e | Athina Bekakou | // <div class="title">
|
215 | 38c7643e | Athina Bekakou | // <p>EXPLANATORY TEXT</p>
|
216 | 38c7643e | Athina Bekakou | // </div>
|
217 | 38c7643e | Athina Bekakou | // <div class="options-bar">
|
218 | 38c7643e | Athina Bekakou | // <div>
|
219 | 38c7643e | Athina Bekakou | // <a href="">link</a><
|
220 | 38c7643e | Athina Bekakou | // </div>
|
221 | 38c7643e | Athina Bekakou | // </div>
|
222 | 38c7643e | Athina Bekakou | showExplanatoryText: function(link) { |
223 | 38c7643e | Athina Bekakou | var paragraph = $(link).parents('.options-bar').siblings('.title').find('p'); |
224 | 38c7643e | Athina Bekakou | // var text = $(link).data('help');
|
225 | 38c7643e | Athina Bekakou | // paragraph.html(text);
|
226 | 38c7643e | Athina Bekakou | paragraph.css('visibility', 'visible'); |
227 | 38c7643e | Athina Bekakou | }, |
228 | 38c7643e | Athina Bekakou | |
229 | 38c7643e | Athina Bekakou | hideExplanatoryText: function(link) { |
230 | 38c7643e | Athina Bekakou | var paragraph = $(link).parents('.options-bar').siblings('.title').find('p'); |
231 | 38c7643e | Athina Bekakou | paragraph.css('visibility', 'hidden'); |
232 | 38c7643e | Athina Bekakou | }, |
233 | 38c7643e | Athina Bekakou | |
234 | 937c0d49 | Athina Bekakou | vm: {
|
235 | 937c0d49 | Athina Bekakou | hideNext: function() { |
236 | 937c0d49 | Athina Bekakou | if(ui.wizard.currentStep == 2 && $('.flavor a.disabled').hasClass('small')) { |
237 | 937c0d49 | Athina Bekakou | return true; |
238 | 937c0d49 | Athina Bekakou | } |
239 | 937c0d49 | Athina Bekakou | else {
|
240 | 937c0d49 | Athina Bekakou | return false; |
241 | 937c0d49 | Athina Bekakou | } |
242 | 937c0d49 | Athina Bekakou | }, |
243 | 937c0d49 | Athina Bekakou | getSize: function(elem) { |
244 | 937c0d49 | Athina Bekakou | if ($(elem).hasClass('small')) { |
245 | 937c0d49 | Athina Bekakou | return 'small'; |
246 | 937c0d49 | Athina Bekakou | } else if ($(elem).hasClass('medium')) { |
247 | 937c0d49 | Athina Bekakou | return 'medium'; |
248 | 937c0d49 | Athina Bekakou | } else if ($(elem).hasClass('large')) { |
249 | 937c0d49 | Athina Bekakou | return 'large'; |
250 | 937c0d49 | Athina Bekakou | } |
251 | 937c0d49 | Athina Bekakou | }, |
252 | 937c0d49 | Athina Bekakou | |
253 | 937c0d49 | Athina Bekakou | |
254 | 937c0d49 | Athina Bekakou | pickResources: function(resource) { |
255 | 937c0d49 | Athina Bekakou | var wizard = ui.wizard.domID;
|
256 | 937c0d49 | Athina Bekakou | wizard.find('.flavor .with-flavor a:not(.' + resource + ')').removeClass('current'); |
257 | 937c0d49 | Athina Bekakou | wizard.find('.flavor .with-flavor a.' + resource + '').addClass('current'); |
258 | 937c0d49 | Athina Bekakou | }, |
259 | 937c0d49 | Athina Bekakou | |
260 | 937c0d49 | Athina Bekakou | showImageCategory: function(imagesCategory) { |
261 | 937c0d49 | Athina Bekakou | var wizard = ui.wizard.domID;
|
262 | 937c0d49 | Athina Bekakou | var selectedImages = $(imagesCategory).data('img-type'); |
263 | 937c0d49 | Athina Bekakou | wizard.find(imagesCategory).closest('.sub-menu').find('.current').removeClass('current'); |
264 | 937c0d49 | Athina Bekakou | wizard.find(imagesCategory).addClass('current');
|
265 | 937c0d49 | Athina Bekakou | wizard.find('.os li').hide();
|
266 | 937c0d49 | Athina Bekakou | wizard.find('.os .details').hide();
|
267 | 937c0d49 | Athina Bekakou | wizard.find('.os').find('.'+selectedImages).fadeIn(); |
268 | 937c0d49 | Athina Bekakou | } |
269 | 937c0d49 | Athina Bekakou | }, |
270 | 937c0d49 | Athina Bekakou | network : { }
|
271 | 937c0d49 | Athina Bekakou | } |
272 | 937c0d49 | Athina Bekakou | |
273 | 937c0d49 | Athina Bekakou | $(document).ready(function() { |
274 | 937c0d49 | Athina Bekakou | |
275 | 937c0d49 | Athina Bekakou | if($('.wizard').length>0) { |
276 | 937c0d49 | Athina Bekakou | var wizardType = $('.wizard').attr('id'); |
277 | 937c0d49 | Athina Bekakou | var wizard = ui.wizard.domID =$('#'+wizardType); |
278 | 937c0d49 | Athina Bekakou | ui.wizard.totalStep = ui.wizard.domID.find('.step').length;
|
279 | 937c0d49 | Athina Bekakou | ui.wizard.currentStep = 1;
|
280 | 937c0d49 | Athina Bekakou | var topHeaderArea = ui.wizard.areas.top.header = wizard.find('.top .nums'); |
281 | 937c0d49 | Athina Bekakou | var topMenuArea = ui.wizard.areas.top.menu = wizard.find('.top .menus'); |
282 | 937c0d49 | Athina Bekakou | var middleArea = ui.wizard.areas.middle = wizard.find('.middle'); |
283 | 937c0d49 | Athina Bekakou | var bottomArea = ui.wizard.areas.bottom = wizard.find('.bottom'); |
284 | 937c0d49 | Athina Bekakou | |
285 | 937c0d49 | Athina Bekakou | var prevBtn = ui.wizard.btns.previous = ui.wizard.areas.bottom.find('.nav.prev'); |
286 | 937c0d49 | Athina Bekakou | var nextBtn = ui.wizard.btns.next = ui.wizard.areas.bottom.find('.nav.next'); |
287 | 937c0d49 | Athina Bekakou | var closeBtn = ui.wizard.btns.close = wizard.find('.close'); |
288 | 937c0d49 | Athina Bekakou | |
289 | 937c0d49 | Athina Bekakou | // various functions for creation wizards
|
290 | 937c0d49 | Athina Bekakou | closeBtn.click(function(e) {
|
291 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
292 | 937c0d49 | Athina Bekakou | ui.wizard.close(); |
293 | 937c0d49 | Athina Bekakou | }); |
294 | 937c0d49 | Athina Bekakou | |
295 | 937c0d49 | Athina Bekakou | nextBtn.click(function(e) {
|
296 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
297 | 937c0d49 | Athina Bekakou | if (ui.wizard.currentStep == ui.wizard.totalStep ){
|
298 | 937c0d49 | Athina Bekakou | ui.wizard.submitData(); |
299 | 937c0d49 | Athina Bekakou | ui.wizard.close(); |
300 | 937c0d49 | Athina Bekakou | return false; |
301 | 937c0d49 | Athina Bekakou | } |
302 | 937c0d49 | Athina Bekakou | ui.wizard.goNext(); |
303 | 937c0d49 | Athina Bekakou | |
304 | 937c0d49 | Athina Bekakou | }); |
305 | 937c0d49 | Athina Bekakou | |
306 | 937c0d49 | Athina Bekakou | prevBtn.click(function(e) {
|
307 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
308 | 937c0d49 | Athina Bekakou | if (ui.wizard.currentStep == 1 ){ |
309 | 937c0d49 | Athina Bekakou | ui.wizard.close(); |
310 | 937c0d49 | Athina Bekakou | return false; |
311 | 937c0d49 | Athina Bekakou | } |
312 | 937c0d49 | Athina Bekakou | ui.wizard.goPrev(); |
313 | 937c0d49 | Athina Bekakou | }); |
314 | 937c0d49 | Athina Bekakou | |
315 | 937c0d49 | Athina Bekakou | |
316 | 937c0d49 | Athina Bekakou | $(document).keydown(function(e) { |
317 | 937c0d49 | Athina Bekakou | var exp1 = $('.vm-name input').is(':focus') && $('.vm-name input').val().length>0; |
318 | 937c0d49 | Athina Bekakou | var exp2 = $('.form-item input').is(':focus') && $('.form-item input').val().length>0; |
319 | 937c0d49 | Athina Bekakou | // right arrow keyCode == 39
|
320 | 937c0d49 | Athina Bekakou | if (wizard.is(':visible').length != 0) { |
321 | 937c0d49 | Athina Bekakou | if (e.keyCode == 39 && ui.wizard.currentStep != (ui.wizard.totalStep) &&(!exp1) && (!exp2)) { |
322 | 937c0d49 | Athina Bekakou | ui.wizard.goNext(); |
323 | 937c0d49 | Athina Bekakou | return false; |
324 | 937c0d49 | Athina Bekakou | } |
325 | 937c0d49 | Athina Bekakou | // left arrow keyCode == 37
|
326 | 937c0d49 | Athina Bekakou | else if (e.keyCode == 37 && ui.wizard.currentStep != 1 &&(!exp1) &&(!exp2)) { |
327 | 937c0d49 | Athina Bekakou | ui.wizard.goPrev(); |
328 | 937c0d49 | Athina Bekakou | return false; |
329 | 937c0d49 | Athina Bekakou | } |
330 | 937c0d49 | Athina Bekakou | // ESC
|
331 | 937c0d49 | Athina Bekakou | else if (e.keyCode == 27 && ui.wizard.currentStep == 1) { |
332 | 937c0d49 | Athina Bekakou | ui.wizard.close(); |
333 | 937c0d49 | Athina Bekakou | } |
334 | 937c0d49 | Athina Bekakou | } |
335 | 937c0d49 | Athina Bekakou | }); |
336 | 937c0d49 | Athina Bekakou | |
337 | 937c0d49 | Athina Bekakou | // focus and tabs functionality
|
338 | 937c0d49 | Athina Bekakou | wizard.find('a').keyup(function(e) { |
339 | 937c0d49 | Athina Bekakou | var self = this; |
340 | 937c0d49 | Athina Bekakou | if (e.keyCode == 9 || e.which == 9) { |
341 | 937c0d49 | Athina Bekakou | if (e.shiftKey) {
|
342 | 937c0d49 | Athina Bekakou | } else {
|
343 | 937c0d49 | Athina Bekakou | //Focus next input
|
344 | 937c0d49 | Athina Bekakou | if ($(self).attr('data-next')) { |
345 | 937c0d49 | Athina Bekakou | $(self).focusout(function(e) { |
346 | 937c0d49 | Athina Bekakou | var classname = $(self).data('next'); |
347 | 937c0d49 | Athina Bekakou | wizard.find('.' + classname + '').first().focus(); |
348 | 937c0d49 | Athina Bekakou | }); |
349 | 937c0d49 | Athina Bekakou | } |
350 | 937c0d49 | Athina Bekakou | } |
351 | 937c0d49 | Athina Bekakou | } |
352 | 937c0d49 | Athina Bekakou | }); |
353 | 937c0d49 | Athina Bekakou | |
354 | 937c0d49 | Athina Bekakou | // navigation and numbers functions
|
355 | 937c0d49 | Athina Bekakou | wizard.find('.nav.previous').focus(function(e) { |
356 | 937c0d49 | Athina Bekakou | $(this).addClass('active'); |
357 | 937c0d49 | Athina Bekakou | }); |
358 | 937c0d49 | Athina Bekakou | |
359 | 937c0d49 | Athina Bekakou | wizard.find('.nav.previous').focusout(function(e) { |
360 | 937c0d49 | Athina Bekakou | $(this).removeClass('active'); |
361 | 937c0d49 | Athina Bekakou | |
362 | 937c0d49 | Athina Bekakou | }); |
363 | 937c0d49 | Athina Bekakou | |
364 | 937c0d49 | Athina Bekakou | if(wizardType == 'vm-wizard') { |
365 | 937c0d49 | Athina Bekakou | |
366 | 937c0d49 | Athina Bekakou | // step-1: pick OS
|
367 | 937c0d49 | Athina Bekakou | wizard.find('.os > li').keydown(function(e) { |
368 | 937c0d49 | Athina Bekakou | if(e.keyCode == 13) { |
369 | 937c0d49 | Athina Bekakou | $(this).trigger("click", true); |
370 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
371 | 937c0d49 | Athina Bekakou | } |
372 | 937c0d49 | Athina Bekakou | }); |
373 | 937c0d49 | Athina Bekakou | wizard.find('.os .btn-col a').keydown(function(e) { |
374 | 937c0d49 | Athina Bekakou | if(e.keyCode == 13) { |
375 | 937c0d49 | Athina Bekakou | $(this).trigger("click", true); |
376 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
377 | 937c0d49 | Athina Bekakou | e.stopPropagation(); |
378 | 937c0d49 | Athina Bekakou | } |
379 | 937c0d49 | Athina Bekakou | }); |
380 | 937c0d49 | Athina Bekakou | |
381 | 937c0d49 | Athina Bekakou | wizard.find('.os > li').click(function(e, wasEnterKey) { |
382 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
383 | 937c0d49 | Athina Bekakou | if ( $(this).hasClass('current') && wasEnterKey) { |
384 | 937c0d49 | Athina Bekakou | ui.wizard.goNext(); |
385 | 937c0d49 | Athina Bekakou | } |
386 | 937c0d49 | Athina Bekakou | wizard.find('.os >li').removeClass('current'); |
387 | 937c0d49 | Athina Bekakou | $(this).addClass('current'); |
388 | 937c0d49 | Athina Bekakou | }); |
389 | 937c0d49 | Athina Bekakou | |
390 | 937c0d49 | Athina Bekakou | wizard.find('.os .btn-col a').click(function(e) { |
391 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
392 | 937c0d49 | Athina Bekakou | e.stopPropagation(); |
393 | 937c0d49 | Athina Bekakou | $(this).toggleClass('current'); |
394 | 937c0d49 | Athina Bekakou | var self = this; |
395 | 937c0d49 | Athina Bekakou | $(this).parents('li').find('.details').stop().slideToggle(); |
396 | 937c0d49 | Athina Bekakou | }); |
397 | 937c0d49 | Athina Bekakou | |
398 | 937c0d49 | Athina Bekakou | wizard.find('.top .sub-menu[data-step=1] a').click(function(e) { |
399 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
400 | 937c0d49 | Athina Bekakou | ui.wizard.vm.showImageCategory(this);
|
401 | 937c0d49 | Athina Bekakou | }); |
402 | 937c0d49 | Athina Bekakou | |
403 | 937c0d49 | Athina Bekakou | wizard.find('.os .name-col').focus(function(e) { |
404 | 937c0d49 | Athina Bekakou | $(this).parents('li').addClass('hover'); |
405 | 937c0d49 | Athina Bekakou | }); |
406 | 937c0d49 | Athina Bekakou | |
407 | 937c0d49 | Athina Bekakou | wizard.find('.os .name-col').focusout(function(e) { |
408 | 937c0d49 | Athina Bekakou | $(this).parents('li').removeClass('hover'); |
409 | 937c0d49 | Athina Bekakou | }); |
410 | 937c0d49 | Athina Bekakou | |
411 | 937c0d49 | Athina Bekakou | // step-2: pick flavor
|
412 | 937c0d49 | Athina Bekakou | var disabledElems = wizard.find('.flavor a.disabled'); |
413 | 937c0d49 | Athina Bekakou | var disabledElemsNum = disabledElems.length;
|
414 | 937c0d49 | Athina Bekakou | var size;
|
415 | 937c0d49 | Athina Bekakou | if(disabledElemsNum>0) { |
416 | 937c0d49 | Athina Bekakou | for(i=0; i<disabledElemsNum; i++) { |
417 | 937c0d49 | Athina Bekakou | size = ui.wizard.vm.getSize(disabledElems.get(i)); |
418 | 937c0d49 | Athina Bekakou | wizard.find('.sub-menu[data-step=2] a[data-size=' + size + ']').removeClass('current').addClass('disabled'); |
419 | 937c0d49 | Athina Bekakou | wizard.find('.flavor .'+size).removeClass('current preselected'); |
420 | 937c0d49 | Athina Bekakou | if(size == 'small') { |
421 | 937c0d49 | Athina Bekakou | wizard.find('.flavor .vm-storage-selection a').removeClass('current preselected'); |
422 | 937c0d49 | Athina Bekakou | |
423 | 937c0d49 | Athina Bekakou | } |
424 | 937c0d49 | Athina Bekakou | } |
425 | 937c0d49 | Athina Bekakou | } |
426 | 937c0d49 | Athina Bekakou | wizard.find('.sub-menu a[data-size]:not(.disabled)').click(function(e) { |
427 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
428 | 937c0d49 | Athina Bekakou | $(this).parents('.sub-menu').find('a').removeClass('current'); |
429 | 937c0d49 | Athina Bekakou | $(this).addClass('current'); |
430 | 937c0d49 | Athina Bekakou | ui.wizard.vm.pickResources($(this).data('size')); |
431 | 937c0d49 | Athina Bekakou | }); |
432 | 937c0d49 | Athina Bekakou | |
433 | 937c0d49 | Athina Bekakou | wizard.find('.flavor .options:not(.vm-storage-selection) a:not(.disabled)').click(function(e) { |
434 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
435 | 937c0d49 | Athina Bekakou | wizard.find('.sub-menu a[data-size]').removeClass('current'); |
436 | 937c0d49 | Athina Bekakou | $(this).parents('.options').find('a').removeClass('current'); |
437 | 937c0d49 | Athina Bekakou | $(this).addClass('current'); |
438 | 937c0d49 | Athina Bekakou | size = ui.wizard.vm.getSize(this);
|
439 | 937c0d49 | Athina Bekakou | var count = wizard.find('.options.with-flavor .' + size + '.current').length; |
440 | 937c0d49 | Athina Bekakou | if (count == 3) { |
441 | 937c0d49 | Athina Bekakou | wizard.find('.sub-menu[data-step=2] a[data-size=' + size + ']').addClass('current'); |
442 | 937c0d49 | Athina Bekakou | } |
443 | 937c0d49 | Athina Bekakou | }); |
444 | 937c0d49 | Athina Bekakou | |
445 | 937c0d49 | Athina Bekakou | wizard.find('.flavor .options.vm-storage-selection a').click(function(e) { |
446 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
447 | 937c0d49 | Athina Bekakou | $(this).parents('.options').find('a').removeClass('current'); |
448 | 937c0d49 | Athina Bekakou | $(this).addClass('current'); |
449 | 937c0d49 | Athina Bekakou | }); |
450 | 937c0d49 | Athina Bekakou | |
451 | 937c0d49 | Athina Bekakou | wizard.find('.flavor .options a').hover(
|
452 | 937c0d49 | Athina Bekakou | function() {
|
453 | 38c7643e | Athina Bekakou | ui.wizard.showExplanatoryText($(this)) |
454 | 937c0d49 | Athina Bekakou | }, function() {
|
455 | 38c7643e | Athina Bekakou | ui.wizard.hideExplanatoryText($(this)) |
456 | 38c7643e | Athina Bekakou | }); |
457 | 937c0d49 | Athina Bekakou | |
458 | 937c0d49 | Athina Bekakou | wizard.find('.sub-menu[data-step=2] li:last').find('a').focusout(function(e) { |
459 | 937c0d49 | Athina Bekakou | $('.step-2').find('.dropdown a:first').focus(); |
460 | 937c0d49 | Athina Bekakou | }); |
461 | 937c0d49 | Athina Bekakou | |
462 | 937c0d49 | Athina Bekakou | // step-3: custom options
|
463 | 937c0d49 | Athina Bekakou | wizard.find('.expand-arrow').click(function(e) { |
464 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
465 | 937c0d49 | Athina Bekakou | ui.expandDownArea(this, wizard.find('.advanced-conf-options')); |
466 | 937c0d49 | Athina Bekakou | }); |
467 | 937c0d49 | Athina Bekakou | |
468 | 937c0d49 | Athina Bekakou | |
469 | 937c0d49 | Athina Bekakou | // reaction li.click *
|
470 | 937c0d49 | Athina Bekakou | wizard.find('.advanced-conf-options .with-checkbox').click(function(e) { |
471 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
472 | 05205849 | Athina Bekakou | $(this).find('.check').trigger('click'); |
473 | 937c0d49 | Athina Bekakou | }); |
474 | 937c0d49 | Athina Bekakou | |
475 | 937c0d49 | Athina Bekakou | // reaction a.click *
|
476 | 937c0d49 | Athina Bekakou | $('.with-checkbox .check').click(function(e) { |
477 | 937c0d49 | Athina Bekakou | e.stopPropagation(); |
478 | 05205849 | Athina Bekakou | console.log('hi');
|
479 | 937c0d49 | Athina Bekakou | var self = this; |
480 | 05205849 | Athina Bekakou | if ($(this).closest('.with-checkbox').hasClass('has-more')) { |
481 | 937c0d49 | Athina Bekakou | $(this).parent().next('.more').stop().slideToggle(400, function() { |
482 | 937c0d49 | Athina Bekakou | if ($(self).parent().next('.more:visible').length != 0) { |
483 | 937c0d49 | Athina Bekakou | $(self).find('span').removeClass('snf-checkbox-unchecked').addClass('snf-checkbox-checked'); |
484 | 937c0d49 | Athina Bekakou | } else {
|
485 | 937c0d49 | Athina Bekakou | $(self).find('span').removeClass('snf-checkbox-checked').addClass('snf-checkbox-unchecked'); |
486 | 937c0d49 | Athina Bekakou | } |
487 | 937c0d49 | Athina Bekakou | }); |
488 | 937c0d49 | Athina Bekakou | } |
489 | 937c0d49 | Athina Bekakou | }); |
490 | 937c0d49 | Athina Bekakou | } |
491 | 937c0d49 | Athina Bekakou | else if (wizardType == 'network-wizard') { |
492 | 937c0d49 | Athina Bekakou | |
493 | 937c0d49 | Athina Bekakou | wizard.find('.network_options .check').click(function(e){ |
494 | 05205849 | Athina Bekakou | e.preventDefault(); |
495 | 05205849 | Athina Bekakou | e.stopPropagation(); |
496 | 05205849 | Athina Bekakou | this.blur();
|
497 | 05205849 | Athina Bekakou | $(this).parents('li').siblings().find('ul.subnet_options').parent('li').toggle(); |
498 | 05205849 | Athina Bekakou | }); |
499 | 05205849 | Athina Bekakou | |
500 | 05205849 | Athina Bekakou | wizard.find('.network_options .dhcp_option').click(function(e){ |
501 | 05205849 | Athina Bekakou | e.preventDefault(); |
502 | 05205849 | Athina Bekakou | $(this).find('.check').trigger('click'); |
503 | 05205849 | Athina Bekakou | }); |
504 | 937c0d49 | Athina Bekakou | |
505 | 937c0d49 | Athina Bekakou | wizard.find('.network_options .radio_btn').click(function(e){ |
506 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
507 | 05205849 | Athina Bekakou | e.stopPropagation(); |
508 | 05205849 | Athina Bekakou | this.blur();
|
509 | 937c0d49 | Athina Bekakou | var state = $(this).find('span'); |
510 | 6907afd3 | Athina Bekakou | if(state.hasClass('snf-radio-checked')) { |
511 | 6907afd3 | Athina Bekakou | if($(this).hasClass('manual')) { |
512 | 6907afd3 | Athina Bekakou | $(this).siblings('.input').show(); |
513 | 6907afd3 | Athina Bekakou | } |
514 | 6907afd3 | Athina Bekakou | else {
|
515 | 6907afd3 | Athina Bekakou | $(this).closest('li').siblings('.manual').find('.input').hide(); |
516 | 6907afd3 | Athina Bekakou | } |
517 | 6907afd3 | Athina Bekakou | } |
518 | 937c0d49 | Athina Bekakou | }); |
519 | 05205849 | Athina Bekakou | |
520 | 05205849 | Athina Bekakou | wizard.find('.subnet_options>li').click(function(e) { |
521 | 05205849 | Athina Bekakou | $(this).find('.radio_btn').trigger('click'); |
522 | 05205849 | Athina Bekakou | }) |
523 | 937c0d49 | Athina Bekakou | } |
524 | 5bdb4b1c | Athina Bekakou | else if (wizardType == 'volume-wizard') { |
525 | 38c7643e | Athina Bekakou | // step-1
|
526 | 5bdb4b1c | Athina Bekakou | wizard.find('.volume_options .options a').hover(
|
527 | 5bdb4b1c | Athina Bekakou | function() {
|
528 | 38c7643e | Athina Bekakou | ui.wizard.showExplanatoryText($(this)) |
529 | 5bdb4b1c | Athina Bekakou | }, function() {
|
530 | 38c7643e | Athina Bekakou | ui.wizard.hideExplanatoryText($(this)) |
531 | 38c7643e | Athina Bekakou | }); |
532 | 38c7643e | Athina Bekakou | wizard.find('.volume_options .options a:not(.disabled)').click(function(e) { |
533 | 38c7643e | Athina Bekakou | e.preventDefault(); |
534 | 38c7643e | Athina Bekakou | if(!$(this).hasClass('current')) { |
535 | 38c7643e | Athina Bekakou | $(this).closest('.options').find('.current').removeClass('current'); |
536 | 38c7643e | Athina Bekakou | $(this).addClass('current'); |
537 | 5bdb4b1c | Athina Bekakou | } |
538 | 38c7643e | Athina Bekakou | }); |
539 | 38c7643e | Athina Bekakou | |
540 | 38c7643e | Athina Bekakou | //step-2
|
541 | 38c7643e | Athina Bekakou | wizard.find('.vms-list a').click(function(e) { |
542 | 38c7643e | Athina Bekakou | e.preventDefault(); |
543 | 38c7643e | Athina Bekakou | e.stopPropagation(); |
544 | 38c7643e | Athina Bekakou | ui.checkOneRadioButton(this);
|
545 | 38c7643e | Athina Bekakou | ui.changeRadiobuttonState(this);
|
546 | 38c7643e | Athina Bekakou | }); |
547 | 38c7643e | Athina Bekakou | |
548 | 38c7643e | Athina Bekakou | wizard.find('.vms-list li').click(function(e) { |
549 | 38c7643e | Athina Bekakou | e.preventDefault(); |
550 | 38c7643e | Athina Bekakou | $(this).find('a').trigger('click'); |
551 | 38c7643e | Athina Bekakou | }); |
552 | 38c7643e | Athina Bekakou | |
553 | 5bdb4b1c | Athina Bekakou | } |
554 | 217d9585 | Athina Bekakou | |
555 | 217d9585 | Athina Bekakou | else if(wizardType == 'snapshot-wizard') { |
556 | 217d9585 | Athina Bekakou | wizard.find('.vms-list a').click(function(e) { |
557 | 217d9585 | Athina Bekakou | e.preventDefault(); |
558 | 217d9585 | Athina Bekakou | e.stopPropagation(); |
559 | 217d9585 | Athina Bekakou | ui.checkOneRadioButton(this);
|
560 | 217d9585 | Athina Bekakou | ui.changeRadiobuttonState(this);
|
561 | 217d9585 | Athina Bekakou | }); |
562 | 217d9585 | Athina Bekakou | |
563 | 217d9585 | Athina Bekakou | wizard.find('.vms-list li').click(function(e) { |
564 | 217d9585 | Athina Bekakou | e.preventDefault(); |
565 | 217d9585 | Athina Bekakou | $(this).find('a').trigger('click'); |
566 | 217d9585 | Athina Bekakou | }); |
567 | 217d9585 | Athina Bekakou | } |
568 | 937c0d49 | Athina Bekakou | } |
569 | 937c0d49 | Athina Bekakou | |
570 | 937c0d49 | Athina Bekakou | }) |