Revision ca3c8b6e snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/vm-wizard.js
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/vm-wizard.js | ||
---|---|---|
12 | 12 |
expand_down: undefined |
13 | 13 |
}, |
14 | 14 |
speed: 500, |
15 |
/*set_container_height: function(step) { |
|
16 |
if (step === true) { |
|
17 |
step =0; |
|
18 |
} else { |
|
19 |
step = ui.wizard.current_step; |
|
20 |
} |
|
21 |
var topHeight = $('.top').height(); |
|
22 |
var stepHeight = $('.step-'+(step+1)+'').height(); |
|
23 |
var res = topHeight+stepHeight; |
|
24 |
console.log('step', step); |
|
25 |
if (step == 2) { |
|
26 |
$('.wizard-content').removeAttr('style'); |
|
27 |
} else { |
|
28 |
$('.wizard-content').height(res); |
|
29 |
} |
|
30 |
}, |
|
31 |
set_container_height_back: function(step) { |
|
32 |
if (step === true) { |
|
33 |
step =1; |
|
34 |
} else { |
|
35 |
step = ui.wizard.current_step; |
|
36 |
} |
|
37 |
var topHeight = $('.top').height(); |
|
38 |
var stepHeight = $('.step-'+step+'').height(); |
|
39 |
var res = topHeight+stepHeight; |
|
40 |
console.log('step', step); |
|
41 |
if (step == 3) { |
|
42 |
$('.wizard-content').removeAttr('style'); |
|
43 |
} else { |
|
44 |
$('.wizard-content').height(res); |
|
45 |
} |
|
46 |
},*/ |
|
47 | 15 |
|
48 | 16 |
set_dimensions: function (){ |
49 | 17 |
$('.vm-wizard-carousel').css('width', 100*ui.wizard.total_step+'%'); |
50 | 18 |
$('.vm-wizard-carousel .step').css('width', 100/ui.wizard.total_step+'%'); |
19 |
ui.wizard.set_step_height('.step', '.top', '.bottom', '.header'); |
|
51 | 20 |
}, |
52 | 21 |
|
53 | 22 |
submit_data: function (){ |
... | ... | |
57 | 26 |
data_next_array: ['test1','el2','el4','el7'], |
58 | 27 |
|
59 | 28 |
focus_fun: function(){ |
60 |
$('.nav.next').attr('data-step',ui.wizard.current_step); |
|
61 |
$('.nav.next').removeAttr('data-next'); |
|
62 |
$('.nav.next').attr('data-next', ui.wizard.data_next_array[ui.wizard.current_step]); |
|
63 |
$('.'+ui.wizard.data_next_array[ui.wizard.current_step]+'').first().focus(); |
|
64 |
console.log('focus_fun',ui.wizard.data_next_array[ui.wizard.current_step]); |
|
29 |
// $('.nav.next').attr('data-step',ui.wizard.current_step);
|
|
30 |
// $('.nav.next').removeAttr('data-next');
|
|
31 |
// $('.nav.next').attr('data-next', ui.wizard.data_next_array[ui.wizard.current_step]);
|
|
32 |
// $('.'+ui.wizard.data_next_array[ui.wizard.current_step]+'').first().focus();
|
|
33 |
// console.log('focus_fun',ui.wizard.data_next_array[ui.wizard.current_step]);
|
|
65 | 34 |
}, |
66 | 35 |
|
67 | 36 |
move: function () { |
... | ... | |
96 | 65 |
|
97 | 66 |
init_events: function(){ |
98 | 67 |
ui.wizard.set_dimensions(); |
68 |
|
|
99 | 69 |
$(document).keydown(function(e) { |
100 | 70 |
// right arrow keyCode == 39 |
101 | 71 |
// ui.wizard.total_step+1 because current_step has not changed yet |
... | ... | |
155 | 125 |
$(total_area).slideUp('slow', function(){ |
156 | 126 |
ui.wizard.reset(); |
157 | 127 |
}); |
128 |
ui.wizard.preselect_elements(bottom_area); |
|
129 |
ui.wizard.preselect_elements(main_area); |
|
130 |
ui.wizard.preselect_elements(total_area); |
|
158 | 131 |
}, |
159 | 132 |
|
160 | 133 |
// manually sets elements to a initial state |
161 | 134 |
reset: function() { |
162 |
ui.wizard.current_step = 1; |
|
163 |
$('.vm-wizard-carousel').css('left',0); |
|
164 |
$('.bottom').show(); |
|
165 |
$('.os li').removeClass('current'); |
|
166 |
$('.os .btn-col a').removeClass('current'); |
|
167 |
$('.os li.preselected').addClass('current'); |
|
168 |
//$('.step-1').find('.current').removeClass('current'); |
|
169 |
ui.wizard.indicate_step(ui.wizard.current_step); |
|
170 |
ui.wizard.set_movement_tags(); |
|
171 |
$('.ssh-keys-area').find('.snf-checkbox-checked').addClass('snf-checkbox-unchecked'); |
|
172 |
$('.ssh-keys-area').find('.snf-checkbox-checked').removeClass('snf-checkbox-checked'); |
|
173 |
$('.networks-area .checkbox').find('.snf-checkbox-checked').addClass('snf-checkbox-unchecked'); |
|
174 |
$('.networks-area .checkbox').find('.snf-checkbox-checked').removeClass('snf-checkbox-checked'); |
|
175 |
$('.networks-area .more').hide(); |
|
176 |
$('#vm-wizard').find('.snf-checkbox-checked').addClass('snf-checkbox-unchecked').removeClass('snf-checkbox-checked'); |
|
177 |
$('#vm-wizard').find('.default').removeClass('snf-checkbox-unchecked').addClass('snf-checkbox-checked'); |
|
178 |
$('.details').hide(); |
|
179 |
$('.wizard .top .sub-menu[data-step="1"] ul li:first-child a').addClass('current'); |
|
180 |
ui.pickResources('small'); |
|
181 |
//$('.wizard .step-2 .options li a:contains(DRBD)').addClass('current') |
|
182 |
$('.vm-name input').val(''); |
|
183 |
$('.advanced-conf-options').hide(); |
|
184 |
$('.snf-color-picker').hide(); |
|
185 |
|
|
186 |
|
|
135 |
ui.wizard.current_step = 1; |
|
136 |
$('.vm-wizard-carousel').css('left',0); |
|
137 |
$('.bottom').show(); |
|
138 |
ui.wizard.indicate_step(ui.wizard.current_step); |
|
139 |
ui.wizard.set_movement_tags(); |
|
140 |
$('.networks-area .more').show(); |
|
141 |
$('.details').hide(); |
|
142 |
$('.vm-name input').val(''); |
|
143 |
$('.advanced-conf-options').hide(); |
|
144 |
$('.snf-color-picker').hide(); |
|
145 |
$('.step').scrollTop(0); |
|
187 | 146 |
}, |
188 | 147 |
|
189 | 148 |
expand_area: function() { |
... | ... | |
196 | 155 |
focus_custom: function(el, step) { |
197 | 156 |
el.focus(); |
198 | 157 |
el.attr('data-step',step); |
199 |
} |
|
158 |
}, |
|
159 |
|
|
160 |
preselect_elements: function(area) { |
|
161 |
$(area).find('.current').not('.preselected').removeClass('current'); |
|
162 |
$(area).find('.preselected').not('.current').addClass('current'); //needs improvement |
|
163 |
$(area).find('.snf-radio-checked').not('.preselected').toggleClass('snf-radio-checked snf-radio-unchecked'); |
|
164 |
$(area).find('.snf-radio-unchecked.preselected').toggleClass('snf-radio-checked snf-radio-unchecked'); |
|
165 |
$(area).find('.snf-checkbox-checked').not('.preselected').toggleClass('snf-checkbox-checked snf-checkbox-unchecked'); |
|
166 |
$(area).find('.snf-checkbox-unchecked.preselected').toggleClass('snf-checkbox-checked snf-checkbox-unchecked'); |
|
167 |
$('.expand-link').find('.snf-arrow-up').toggleClass('snf-arrow-up snf-arrow-down'); //needs improvement |
|
168 |
}, |
|
169 |
|
|
170 |
set_step_height: function(stepEl, fixedTopEl, fixedBottomEl, headerEl) { |
|
171 |
topHeight = $(fixedTopEl).height(); |
|
172 |
bottomHeight = $('.bottom .row').height(); |
|
173 |
totalHeight = $(window).height(); |
|
174 |
headerHeight = $(headerEl).height(); |
|
175 |
stepHeight = totalHeight-topHeight-bottomHeight-headerHeight; |
|
176 |
console.log('stepHeight: ', stepHeight) |
|
177 |
tt=stepEl; |
|
178 |
$(stepEl).outerHeight(stepHeight); |
|
179 |
$('.wizard-content').outerHeight(stepHeight); |
|
180 |
}, |
|
181 |
|
|
182 |
|
|
200 | 183 |
|
201 | 184 |
} |
202 | 185 |
|
... | ... | |
341 | 324 |
ui.wizard.btns.close.click(function(e) { |
342 | 325 |
ui.wizard.close('.bottom', '#vm-wizard', '.overlay-area') |
343 | 326 |
}); |
327 |
|
|
328 |
$(window).resize(function() { |
|
329 |
ui.wizard.set_step_height('.step', '.top', '.bottom', '.header') |
|
330 |
}); |
|
344 | 331 |
}); |
Also available in: Unified diff