Revision 788833c7 snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js | ||
---|---|---|
50 | 50 |
} |
51 | 51 |
|
52 | 52 |
ui.setCheckedVMBgColor = function(){ |
53 |
console.log('test'); |
|
53 |
|
|
54 | 54 |
if ($('.check span').length >0) { |
55 | 55 |
$('.more_checkbox .checkbox-checked').parents('.container').addClass('set-bg'); |
56 | 56 |
} else { |
... | ... | |
60 | 60 |
} |
61 | 61 |
|
62 | 62 |
|
63 |
ui.EntitiesActionsInit = function(){
|
|
63 |
ui.entitiesActionsInit = function(){
|
|
64 | 64 |
|
65 | 65 |
// if VM is stopped hide connect option |
66 | 66 |
$('.vms .container .stopped').parents('.container').find('.options .connect').hide(); |
... | ... | |
122 | 122 |
|
123 | 123 |
} |
124 | 124 |
|
125 |
ui.editable = function(){ |
|
126 |
|
|
127 |
/* |
|
128 |
resetForm hides save and cancel buttons, |
|
129 |
text input and shows input-txt. resetForm does not alter |
|
130 |
input-txt content. |
|
131 |
*/ |
|
132 |
|
|
133 |
function resetForm(e, elem) { |
|
134 |
var el = elem.parents('.editable'); |
|
135 |
el.find('input[type="text"]').hide(); |
|
136 |
el.find('a.cancel, a.save').hide(); |
|
137 |
el.find('a.edit').show(); |
|
138 |
el.find('.input-txt').show(); |
|
139 |
} |
|
140 |
|
|
141 |
/* |
|
142 |
showForm hides input-txt, shows save and cancel buttons and |
|
143 |
set input value to input-txt content. |
|
144 |
*/ |
|
145 |
function showForm(e,elem) { |
|
146 |
e.stopPropagation(); |
|
147 |
e.preventDefault(); |
|
148 |
var el = elem.parents('.editable'); |
|
149 |
el.find('input[type="text"]').val(el.find('.input-txt').html()); |
|
150 |
el.find('input[type="text"]').show(); |
|
151 |
el.find('a.cancel, a.save').show(); |
|
152 |
elem.hide(); |
|
153 |
el.find('.input-txt').hide(); |
|
154 |
|
|
155 |
} |
|
156 |
|
|
157 |
/* |
|
158 |
setValue sets input-txt value to the input value. |
|
159 |
Makes sure that the input value is not empty. |
|
160 |
TODO: |
|
161 |
Ajax request to submit form |
|
162 |
*/ |
|
163 |
|
|
164 |
function setValue(elem) { |
|
165 |
var el = elem.parents('.editable'); |
|
166 |
if( el.find('input[type="text"]').val() ) { |
|
167 |
el.find('.input-txt').html(el.find('input[type="text"]').val()); |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
|
|
172 |
$('.editable .edit').click(function(e){ |
|
173 |
showForm(e, $(this)); |
|
174 |
}) |
|
175 |
|
|
176 |
$('.editable .cancel').click(function(e){ |
|
177 |
e.stopPropagation(); |
|
178 |
e.preventDefault(); |
|
179 |
resetForm(e, $(this)); |
|
180 |
}) |
|
181 |
|
|
182 |
$('.editable .save').click(function(e){ |
|
183 |
e.stopPropagation(); |
|
184 |
e.preventDefault(); |
|
185 |
setValue($(this)); |
|
186 |
resetForm(e, $(this)); |
|
187 |
|
|
188 |
}) |
|
189 |
|
|
190 |
|
|
191 |
$('.editable input[type="text"]').click(function(e){ |
|
192 |
e.stopPropagation(); |
|
193 |
}) |
|
194 |
|
|
195 |
$('.editable input[type="text"]').keyup(function(e){ |
|
196 |
if(e.keyCode == 13) { |
|
197 |
setValue($(this)); |
|
198 |
resetForm(e, $(this)); |
|
199 |
|
|
200 |
} |
|
201 |
|
|
202 |
}) |
|
203 |
|
|
204 |
$('html').click(function(e) { |
|
205 |
resetForm(e, $('.editable a.cancel')); |
|
206 |
}); |
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
} |
|
211 |
|
|
125 | 212 |
|
126 | 213 |
$(document).ready(function(){ |
127 | 214 |
|
... | ... | |
149 | 236 |
e.preventDefault(); |
150 | 237 |
}) |
151 | 238 |
|
152 |
ui.EntitiesActionsInit(); |
|
239 |
ui.entitiesActionsInit(); |
|
240 |
ui.editable(); |
|
153 | 241 |
|
154 | 242 |
$('.main-actions li a').click(function(e){ |
155 | 243 |
if (!($(this).hasClass('active'))) { |
156 | 244 |
e.preventDefault(); |
157 | 245 |
} |
158 | 246 |
}) |
159 |
//$('.scroll-pane').jScrollPane();
|
|
247 |
$('.scroll-pane').jScrollPane(); |
|
160 | 248 |
|
161 | 249 |
// TODO: more general function |
162 | 250 |
$('.has-overlay a').click(function(e){ |
... | ... | |
175 | 263 |
}) |
176 | 264 |
|
177 | 265 |
|
178 |
|
|
179 | 266 |
}) |
180 | 267 |
|
181 | 268 |
$(window).resize(function(e){ |
Also available in: Unified diff