Revision 6bd1416f 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 | ||
---|---|---|
1 | 1 |
// all functions use pixels |
2 | 2 |
ui.wizard ={ |
3 | 3 |
current_step: undefined, |
4 |
vm: {total_step: 4}, |
|
4 |
vm: { |
|
5 |
total_step: 4, |
|
6 |
btns: { |
|
7 |
start: undefined, |
|
8 |
close: undefined, |
|
9 |
next: undefined, |
|
10 |
previous: undefined, |
|
11 |
expand_down: undefined |
|
12 |
} |
|
13 |
}, |
|
14 |
|
|
5 | 15 |
current_position: undefined, |
6 | 16 |
relocation: undefined, |
7 | 17 |
|
18 |
|
|
8 | 19 |
// sets the width and height of the carousel and its divs |
9 | 20 |
set_dimensions: function() { |
10 | 21 |
console.log('set dimentions'); |
... | ... | |
32 | 43 |
|
33 | 44 |
|
34 | 45 |
|
35 |
move_to_step: function(prev_btn, next_btn) {
|
|
46 |
move_to_step: function() { |
|
36 | 47 |
var speed =500; |
37 | 48 |
|
38 | 49 |
// carousel movement when right or left arrow is pressed |
... | ... | |
48 | 59 |
}); |
49 | 60 |
|
50 | 61 |
// when the button "next" is pressed show the next step (if there is a next step) |
51 |
next_btn.click(function(e){
|
|
62 |
ui.wizard.vm.btns.next.click(function(e){
|
|
52 | 63 |
e.preventDefault(); |
53 | 64 |
go_next(); |
54 | 65 |
}) |
55 | 66 |
|
56 | 67 |
// when the button "previous" is pressed show the previous step (if there is a previous step) |
57 |
prev_btn.click(function(e){
|
|
68 |
ui.wizard.vm.btns.previous.click(function(e){
|
|
58 | 69 |
e.preventDefault(); |
59 | 70 |
go_prev(); |
60 | 71 |
|
... | ... | |
70 | 81 |
$('.vm-wizard-carousel').finish(); |
71 | 82 |
$('.vm-wizard-carousel').animate({left: ui.wizard.current_position+'px'}, speed); |
72 | 83 |
ui.wizard.indicate_step(ui.wizard.current_step); |
73 |
ui.wizard.set_movement_tags(ui.wizard.current_step, prev_btn, next_btn);
|
|
84 |
ui.wizard.set_movement_tags(ui.wizard.current_step, ui.wizard.vm.btns.previous, ui.wizard.vm.btns.next);
|
|
74 | 85 |
|
75 | 86 |
if(ui.wizard.current_step == 3) { |
76 | 87 |
setTimeout(function() { $('.vm-name').find('input').focus() }, speed/2); |
... | ... | |
90 | 101 |
$('.vm-wizard-carousel').finish(); |
91 | 102 |
$('.vm-wizard-carousel').animate({left: ui.wizard.current_position+'px'}, speed); |
92 | 103 |
ui.wizard.indicate_step(ui.wizard.current_step); |
93 |
ui.wizard.set_movement_tags(ui.wizard.current_step, prev_btn, next_btn);
|
|
104 |
ui.wizard.set_movement_tags(ui.wizard.current_step, ui.wizard.vm.btns.previous, ui.wizard.vm.btns.next);
|
|
94 | 105 |
|
95 | 106 |
if(ui.wizard.current_step == 3) { |
96 | 107 |
setTimeout(function() { $('.vm-name').find('input').focus() }, speed/2); |
... | ... | |
104 | 115 |
}, |
105 | 116 |
|
106 | 117 |
// sets the width and height of the steps and of the carousel (in PIXELS) |
107 |
initialize_relocation: function(start_btns){
|
|
118 |
initialize_relocation: function(){ |
|
108 | 119 |
console.log('initialize_relocation'); |
109 |
start_btns.click(function(e) {
|
|
120 |
ui.wizard.vm.btns.start.click(function(e) {
|
|
110 | 121 |
e.preventDefault(); |
111 | 122 |
ui.wizard.reset(); |
112 | 123 |
ui.wizard.adjust_to_resized_screen(); |
... | ... | |
119 | 130 |
$('.wizard .top .sub-menu[data-step]').hide(); |
120 | 131 |
$('.wizard .top .sub-menu[data-step='+step+']').fadeIn(); |
121 | 132 |
$('.nums').children().removeClass('current'); |
133 |
//$('.nums li:nth-child('+ui.wizard.current_step+'').addClass('current'); |
|
122 | 134 |
$('.nums').children().find('a:contains("'+ui.wizard.current_step+'")').parent('li').addClass('current'); |
123 | 135 |
}, |
124 | 136 |
|
125 | 137 |
// changes the text of next and previous buttons |
126 |
set_movement_tags: function(step, left_btn, right_btn) {
|
|
127 |
if (step==1) { |
|
128 |
left_btn.find('span').html('CANCEL');
|
|
129 |
right_btn.find('span').html('NEXT');
|
|
138 |
set_movement_tags: function() { |
|
139 |
if (ui.wizard.current_step==1) {
|
|
140 |
ui.wizard.vm.btns.previous.find('span').html('CANCEL');
|
|
141 |
ui.wizard.vm.btns.next.find('span').html('NEXT');
|
|
130 | 142 |
} |
131 |
else if(step==ui.wizard.vm.total_step) { |
|
132 |
left_btn.find('span').html('PREVIOUS');
|
|
133 |
right_btn.find('span').html('CREATE');
|
|
143 |
else if(ui.wizard.current_step==ui.wizard.vm.total_step) {
|
|
144 |
ui.wizard.vm.btns.previous.find('span').html('PREVIOUS');
|
|
145 |
ui.wizard.vm.btns.next.find('span').html('CREATE');
|
|
134 | 146 |
} |
135 | 147 |
else { |
136 |
left_btn.find('span').html('PREVIOUS');
|
|
137 |
right_btn.find('span').html('NEXT');
|
|
148 |
ui.wizard.vm.btns.previous.find('span').html('PREVIOUS');
|
|
149 |
ui.wizard.vm.btns.next.find('span').html('NEXT');
|
|
138 | 150 |
} |
139 | 151 |
}, |
140 | 152 |
|
... | ... | |
153 | 165 |
$('.bottom').show(); |
154 | 166 |
$('.step-1').find('.current').removeClass('current'); |
155 | 167 |
ui.wizard.indicate_step(ui.wizard.current_step); |
168 |
ui.wizard.set_movement_tags(); |
|
156 | 169 |
$('#vm-wizard').find('.snf-checkbox-checked').addClass('snf-checkbox-unchecked').removeClass('snf-checkbox-checked'); |
157 | 170 |
$('#vm-wizard').find('.default').removeClass('snf-checkbox-unchecked').addClass('snf-checkbox-checked'); |
158 | 171 |
$('.details').hide(); |
... | ... | |
164 | 177 |
$('.snf-color-picker').hide(); |
165 | 178 |
|
166 | 179 |
|
180 |
}, |
|
181 |
|
|
182 |
expand_area: function() { |
|
183 |
ui.wizard.vm.btns.expand_down.click(function(e){ |
|
184 |
e.preventDefault(); |
|
185 |
ui.expand_arrow(ui.wizard.vm.btns.expand_down); |
|
186 |
ui.wizard.vm.btns.expand_down.parents('div.advanced-conf-step').find('.advanced-conf-options').slideToggle(); |
|
187 |
}) |
|
167 | 188 |
} |
168 | 189 |
|
169 | 190 |
} |
... | ... | |
174 | 195 |
ui.wizard.current_step =1; |
175 | 196 |
ui.wizard.current_position =0; |
176 | 197 |
|
177 |
var new_vm_btn =$('.new-btn, .add-new'); |
|
178 |
var prev_btn = $('.bottom').find('.nav.prev'); |
|
179 |
var next_btn = $('.bottom').find('.nav.next'); |
|
198 |
ui.wizard.vm.btns.start =$('.new-btn, .add-new'); |
|
199 |
ui.wizard.vm.btns.previous = $('.bottom').find('.nav.prev'); |
|
200 |
ui.wizard.vm.btns.next = $('.bottom').find('.nav.next'); |
|
201 |
ui.wizard.vm.btns.expand_down =$('.adv-main').find('.expand-link'); |
|
202 |
|
|
180 | 203 |
$('.wizard .nums').click(function(e){ |
181 | 204 |
e.preventDefault(); |
182 | 205 |
}) |
183 | 206 |
|
184 |
ui.wizard.initialize_relocation(new_vm_btn); |
|
185 |
ui.wizard.move_to_step(prev_btn, next_btn); |
|
186 |
ui.wizard.set_movement_tags(ui.wizard.current_step, prev_btn, next_btn); |
|
187 |
|
|
207 |
ui.wizard.initialize_relocation(); |
|
208 |
ui.wizard.move_to_step(); |
|
209 |
ui.wizard.set_movement_tags(); |
|
210 |
ui.wizard.expand_area(); |
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
188 | 217 |
|
189 | 218 |
}); |
Also available in: Unified diff