root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / common.js @ c997f7b6
History | View | Annotate | Download (28.7 kB)
1 | 5acf3fcf | Olga Brani | /*
|
---|---|---|---|
2 | 5acf3fcf | Olga Brani | * Various functions that will be used throughout all templates
|
3 | 5acf3fcf | Olga Brani | * are inside ui Object
|
4 | 5acf3fcf | Olga Brani | */
|
5 | b3c1328b | Olga Brani | |
6 | 5acf3fcf | Olga Brani | ui = {}; |
7 | 9b6be833 | Olga Brani | /*
|
8 | 9b6be833 | Olga Brani | * ui.wizards get populated in vm-wizard.js
|
9 | 9b6be833 | Olga Brani | * here is the declaration only
|
10 | 9b6be833 | Olga Brani | */
|
11 | 6bd1416f | Athina Bekakou | ui.wizard = {}; |
12 | 98714f8a | Olga Brani | |
13 | 5acf3fcf | Olga Brani | /* when closeEl el is clicked, its parent with class divToCloseClass slidesUp */
|
14 | 98714f8a | Olga Brani | ui.closeDiv = function(closeEl, divToCloseClass) { |
15 | d3bfabe8 | Olga Brani | closeEl.click(function(e){
|
16 | d3bfabe8 | Olga Brani | e.preventDefault(); |
17 | d3bfabe8 | Olga Brani | $(this).parents(divToCloseClass).slideUp('slow'); |
18 | d3bfabe8 | Olga Brani | }); |
19 | b3c1328b | Olga Brani | } |
20 | b3c1328b | Olga Brani | |
21 | 98714f8a | Olga Brani | |
22 | 9569cdc8 | Olga Brani | ui.trimChars = function( str, chars) { |
23 | 9569cdc8 | Olga Brani | if ( str.length>chars){
|
24 | 5acf3fcf | Olga Brani | return $.trim(str).substring(0, chars)+ "..."; |
25 | 9569cdc8 | Olga Brani | } else {
|
26 | 9569cdc8 | Olga Brani | return str;
|
27 | 9569cdc8 | Olga Brani | } |
28 | 9569cdc8 | Olga Brani | } |
29 | 9569cdc8 | Olga Brani | |
30 | 9a0058e2 | Olga Brani | |
31 | 9a0058e2 | Olga Brani | /* Sets element min-height
|
32 | 9a0058e2 | Olga Brani | * Used for .details, .lt-bar divs
|
33 | 34d12b31 | Olga Brani | */
|
34 | 34d12b31 | Olga Brani | ui.setElminHeight = function(el){ |
35 | d3bfabe8 | Olga Brani | var WindowHeight = $(window).height(); |
36 | 34d12b31 | Olga Brani | var header = $('.header').outerHeight(); |
37 | 9a0058e2 | Olga Brani | var actions = $('.actions-bar').height(); |
38 | 34d12b31 | Olga Brani | var h1= WindowHeight - (header+actions);
|
39 | 34d12b31 | Olga Brani | el.css('min-height', h1);
|
40 | 98714f8a | Olga Brani | } |
41 | 98714f8a | Olga Brani | |
42 | 9a0058e2 | Olga Brani | /* Sets element height
|
43 | 9a0058e2 | Olga Brani | * Used for .details, .lt-bar divs
|
44 | 9a0058e2 | Olga Brani | */
|
45 | 9a0058e2 | Olga Brani | ui.setElHeight = function(el){ |
46 | 9a0058e2 | Olga Brani | var WindowHeight = $(window).height(); |
47 | 9a0058e2 | Olga Brani | var header = $('.header').outerHeight(); |
48 | 9a0058e2 | Olga Brani | var actions = $('.actions-bar').height(); |
49 | 9a0058e2 | Olga Brani | var h1= WindowHeight - (header+actions);
|
50 | 9a0058e2 | Olga Brani | el.css('height', h1);
|
51 | 9a0058e2 | Olga Brani | } |
52 | 5acf3fcf | Olga Brani | |
53 | 7327e185 | Olga Brani | /* Sets element max-height
|
54 | 7327e185 | Olga Brani | * Used for div.storage-progress
|
55 | 7327e185 | Olga Brani | */
|
56 | 7327e185 | Olga Brani | ui.setElmaxHeight = function(el){ |
57 | 7327e185 | Olga Brani | var WindowHeight = $(window).height(); |
58 | 7327e185 | Olga Brani | var header = $('.header').outerHeight(); |
59 | 7327e185 | Olga Brani | var actions = $('.actions-bar').height(); |
60 | 7327e185 | Olga Brani | var h1= WindowHeight - (header+actions);
|
61 | 7327e185 | Olga Brani | el.css('max-height', h1);
|
62 | 7327e185 | Olga Brani | } |
63 | 7327e185 | Olga Brani | |
64 | 5acf3fcf | Olga Brani | /*
|
65 | 5acf3fcf | Olga Brani | * Logic for Entities actions. Present in items_list pages
|
66 | 5acf3fcf | Olga Brani | * Available categories are :
|
67 | 5acf3fcf | Olga Brani | * - both/single ( for multiple entities/single entities)
|
68 | 4e7c16f1 | Olga Brani | * - running/off ( for running/off entities)
|
69 | 5acf3fcf | Olga Brani | * - permanent ( for entities always active )
|
70 | 9b0b486b | Olga Brani | * Can be used for pithos as well
|
71 | 9b0b486b | Olga Brani | * Available categories are :
|
72 | 9b0b486b | Olga Brani | * - files ( for files only actions)
|
73 | 9b0b486b | Olga Brani | * - folders ( for folders only actions)
|
74 | 9b0b486b | Olga Brani | * - all ( for files/folders actions)
|
75 | 5acf3fcf | Olga Brani | */
|
76 | 5acf3fcf | Olga Brani | ui.entitiesActionsEnabled = function(){ |
77 | 8db75456 | Athina Bekakou | var all = $('.snf-checkbox-checked').length; |
78 | 4e7c16f1 | Olga Brani | var running = $('.snf-checkbox-checked').parents('li.running').length; |
79 | 4e7c16f1 | Olga Brani | var off = $('.snf-checkbox-checked').parents('li.off').length; |
80 | 9b0b486b | Olga Brani | var files = $('.snf-checkbox-checked').parents('li.file').length; |
81 | 9b0b486b | Olga Brani | var folders = $('.snf-checkbox-checked').parents('li.folder').length; |
82 | 9b0b486b | Olga Brani | |
83 | 9b0b486b | Olga Brani | console.log(files,'files');
|
84 | 9b0b486b | Olga Brani | console.log(folders,'folders');
|
85 | 9b0b486b | Olga Brani | |
86 | 4e7c16f1 | Olga Brani | $('.lt-bar .lt-actions li:not(.permanent) a').removeClass('active'); |
87 | 9b0b486b | Olga Brani | |
88 | 9b0b486b | Olga Brani | if ( ( files * folders )>0 ) { |
89 | 9b0b486b | Olga Brani | $('.lt-actions li.all a').addClass('active'); |
90 | 9b0b486b | Olga Brani | } else {
|
91 | 9b0b486b | Olga Brani | if ( files>0 ) { |
92 | 9b0b486b | Olga Brani | $('.lt-actions li.files a').addClass('active'); |
93 | 9b0b486b | Olga Brani | } |
94 | 9b0b486b | Olga Brani | if ( folders>0 ){ |
95 | 9b0b486b | Olga Brani | $('.lt-actions li.folders a').addClass('active'); |
96 | 9b0b486b | Olga Brani | } |
97 | 9b0b486b | Olga Brani | } |
98 | 9b0b486b | Olga Brani | |
99 | 4e7c16f1 | Olga Brani | if ( (running*off) > 0 ){ |
100 | 4e7c16f1 | Olga Brani | $('.lt-actions li.both a').addClass('active'); |
101 | 4e7c16f1 | Olga Brani | $('.lt-actions li.single a').removeClass('active'); |
102 | 5e62e9c1 | Olga Brani | } else {
|
103 | 5e62e9c1 | Olga Brani | if (running > 0) { |
104 | 4e7c16f1 | Olga Brani | $('.lt-actions li.both a').addClass('active'); |
105 | 4e7c16f1 | Olga Brani | $('.lt-actions li.running a').addClass('active'); |
106 | 4e7c16f1 | Olga Brani | } else if (off>0) { |
107 | 4e7c16f1 | Olga Brani | $('.lt-actions li.both a').addClass('active'); |
108 | 4e7c16f1 | Olga Brani | $('.lt-actions li.off a').addClass('active'); |
109 | 5e62e9c1 | Olga Brani | } |
110 | 5e62e9c1 | Olga Brani | if ( all > 1 ) { |
111 | 4e7c16f1 | Olga Brani | $('.lt-actions li.single a').removeClass('active'); |
112 | 5e62e9c1 | Olga Brani | } |
113 | 5e62e9c1 | Olga Brani | } |
114 | 5e62e9c1 | Olga Brani | } |
115 | a18bd0ed | Olga Brani | |
116 | ca0d2b34 | Olga Brani | ui.inactiveActions = function() { |
117 | ca0d2b34 | Olga Brani | |
118 | ca0d2b34 | Olga Brani | // Availble actions: connect, reboot, shut, destroy, start
|
119 | ca0d2b34 | Olga Brani | // These actions will be DISABLED
|
120 | ca0d2b34 | Olga Brani | var statesActions ={
|
121 | ca0d2b34 | Olga Brani | 'off' : ['connect', 'reboot', 'shut'], |
122 | ca0d2b34 | Olga Brani | 'error' : ['connect', 'reboot', 'shut', 'start'], |
123 | ca0d2b34 | Olga Brani | 'building' : ['reboot', 'start'], |
124 | ca0d2b34 | Olga Brani | 'running' : ['start'], |
125 | ca0d2b34 | Olga Brani | 'rebooting': ['start'], |
126 | ca0d2b34 | Olga Brani | 'starting' : ['start'], |
127 | ca0d2b34 | Olga Brani | 'shutting' : ['connect', 'reboot', 'shut'] |
128 | ca0d2b34 | Olga Brani | } ; |
129 | ca0d2b34 | Olga Brani | |
130 | ca0d2b34 | Olga Brani | _.each (statesActions, function(val, key) {
|
131 | ca0d2b34 | Olga Brani | _.each(val, function(value) {
|
132 | ca0d2b34 | Olga Brani | var el = '.' + key + ' .' + value; |
133 | ca0d2b34 | Olga Brani | $(el).addClass('inactive'); |
134 | ca0d2b34 | Olga Brani | }); |
135 | ca0d2b34 | Olga Brani | }) |
136 | ca0d2b34 | Olga Brani | } |
137 | ca0d2b34 | Olga Brani | |
138 | 86e6c139 | Olga Brani | ui.detailsCustom = function(area) { |
139 | 34d12b31 | Olga Brani | // position last connected item
|
140 | 86e6c139 | Olga Brani | var el = area.find('.item').last(); |
141 | 3549163d | Olga Brani | // -2 is the border width;
|
142 | 9a0058e2 | Olga Brani | var moveY = el.find('.connections >li').last().outerHeight(true) - 2; |
143 | 3549163d | Olga Brani | el.css('top',moveY);
|
144 | 3549163d | Olga Brani | el.css('marginTop', -moveY);
|
145 | 3549163d | Olga Brani | } |
146 | 3549163d | Olga Brani | |
147 | 3549163d | Olga Brani | ui.firewallSetup = function(){ |
148 | 3549163d | Olga Brani | $('.firewall').each(function(){ |
149 | 3549163d | Olga Brani | $(this).removeClass('fully unprotected basic'); |
150 | 3549163d | Olga Brani | $(this).addClass($(this).data('firewall')); |
151 | 3549163d | Olga Brani | if($(this).hasClass('unprotected')){ |
152 | 3549163d | Olga Brani | $(this).find('p').first().find('em').html('off'); |
153 | 3549163d | Olga Brani | } else {
|
154 | 3549163d | Olga Brani | $(this).find('p').first().find('em').html('on'); |
155 | 3549163d | Olga Brani | } |
156 | 3549163d | Olga Brani | }); |
157 | 3549163d | Olga Brani | } |
158 | 3549163d | Olga Brani | |
159 | 7327e185 | Olga Brani | ui.checkedListItems = function (){ |
160 | 7327e185 | Olga Brani | $('.list-view .items-list').find('.snf-checkbox-checked').each(function(){ |
161 | 7327e185 | Olga Brani | $(this).parents('li').addClass('selected'); |
162 | 7327e185 | Olga Brani | }); |
163 | 7327e185 | Olga Brani | $('.list-view .items-list').find('.snf-checkbox-unchecked').each(function(){ |
164 | 7327e185 | Olga Brani | $(this).parents('li').removeClass('selected'); |
165 | 7327e185 | Olga Brani | }); |
166 | 7327e185 | Olga Brani | }; |
167 | ca0d2b34 | Olga Brani | |
168 | 5acf3fcf | Olga Brani | /*
|
169 | 5acf3fcf | Olga Brani | * In order for the editable value functionality to work, the html markup
|
170 | 5acf3fcf | Olga Brani | * should be:
|
171 | 5acf3fcf | Olga Brani | <div class="editable">
|
172 | 5acf3fcf | Olga Brani | <span class="input-txt">editable value</span>
|
173 | 5acf3fcf | Olga Brani | <input type="text">
|
174 | 5acf3fcf | Olga Brani | <a href="#" class="edit">edit</a>
|
175 | 5acf3fcf | Olga Brani | <a href="#" class="save">save</a>
|
176 | 5acf3fcf | Olga Brani | <a href="#" class="cancel">cancel</a>
|
177 | 5acf3fcf | Olga Brani | </div>
|
178 | 5acf3fcf | Olga Brani | */
|
179 | 788833c7 | Olga Brani | ui.editable = function(){ |
180 | 788833c7 | Olga Brani | |
181 | 788833c7 | Olga Brani | /*
|
182 | 5acf3fcf | Olga Brani | * resetForm hides save and cancel buttons,
|
183 | 5acf3fcf | Olga Brani | * text input and shows input-txt. resetForm does not alter
|
184 | 5acf3fcf | Olga Brani | * input-txt content.
|
185 | 788833c7 | Olga Brani | */
|
186 | 788833c7 | Olga Brani | |
187 | 788833c7 | Olga Brani | function resetForm(e, elem) { |
188 | 788833c7 | Olga Brani | var el = elem.parents('.editable'); |
189 | 788833c7 | Olga Brani | el.find('input[type="text"]').hide();
|
190 | 788833c7 | Olga Brani | el.find('a.cancel, a.save').hide();
|
191 | 5acf3fcf | Olga Brani | el.find('a.edit, .input-txt').show();
|
192 | 788833c7 | Olga Brani | } |
193 | 788833c7 | Olga Brani | |
194 | 788833c7 | Olga Brani | /*
|
195 | 5acf3fcf | Olga Brani | * showForm hides input-txt, shows save and cancel buttons and
|
196 | 5acf3fcf | Olga Brani | * sets input value to input-txt content.
|
197 | 788833c7 | Olga Brani | */
|
198 | 788833c7 | Olga Brani | function showForm(e,elem) { |
199 | 788833c7 | Olga Brani | e.stopPropagation(); |
200 | 788833c7 | Olga Brani | e.preventDefault(); |
201 | 788833c7 | Olga Brani | var el = elem.parents('.editable'); |
202 | 788833c7 | Olga Brani | el.find('input[type="text"]').val(el.find('.input-txt').html()); |
203 | 788833c7 | Olga Brani | el.find('input[type="text"]').show();
|
204 | 788833c7 | Olga Brani | el.find('a.cancel, a.save').show();
|
205 | 788833c7 | Olga Brani | elem.hide(); |
206 | 788833c7 | Olga Brani | el.find('.input-txt').hide();
|
207 | 788833c7 | Olga Brani | } |
208 | 788833c7 | Olga Brani | |
209 | 788833c7 | Olga Brani | /*
|
210 | 788833c7 | Olga Brani | setValue sets input-txt value to the input value.
|
211 | 788833c7 | Olga Brani | Makes sure that the input value is not empty.
|
212 | 788833c7 | Olga Brani | TODO:
|
213 | 788833c7 | Olga Brani | Ajax request to submit form
|
214 | 788833c7 | Olga Brani | */
|
215 | 788833c7 | Olga Brani | |
216 | 788833c7 | Olga Brani | function setValue(elem) { |
217 | 788833c7 | Olga Brani | var el = elem.parents('.editable'); |
218 | 788833c7 | Olga Brani | if( el.find('input[type="text"]').val() ) { |
219 | 788833c7 | Olga Brani | el.find('.input-txt').html(el.find('input[type="text"]').val()); |
220 | 788833c7 | Olga Brani | } |
221 | 788833c7 | Olga Brani | } |
222 | 788833c7 | Olga Brani | |
223 | 788833c7 | Olga Brani | |
224 | 788833c7 | Olga Brani | $('.editable .edit').click(function(e){ |
225 | 788833c7 | Olga Brani | showForm(e, $(this)); |
226 | 788833c7 | Olga Brani | }) |
227 | 788833c7 | Olga Brani | |
228 | 788833c7 | Olga Brani | $('.editable .cancel').click(function(e){ |
229 | 788833c7 | Olga Brani | e.stopPropagation(); |
230 | 788833c7 | Olga Brani | e.preventDefault(); |
231 | 788833c7 | Olga Brani | resetForm(e, $(this)); |
232 | 788833c7 | Olga Brani | }) |
233 | 788833c7 | Olga Brani | |
234 | 788833c7 | Olga Brani | $('.editable .save').click(function(e){ |
235 | 788833c7 | Olga Brani | e.stopPropagation(); |
236 | 788833c7 | Olga Brani | e.preventDefault(); |
237 | 788833c7 | Olga Brani | setValue($(this)); |
238 | 788833c7 | Olga Brani | resetForm(e, $(this)); |
239 | 788833c7 | Olga Brani | |
240 | 788833c7 | Olga Brani | }) |
241 | 788833c7 | Olga Brani | |
242 | 788833c7 | Olga Brani | |
243 | 788833c7 | Olga Brani | $('.editable input[type="text"]').click(function(e){ |
244 | 788833c7 | Olga Brani | e.stopPropagation(); |
245 | 788833c7 | Olga Brani | }) |
246 | 788833c7 | Olga Brani | |
247 | 788833c7 | Olga Brani | $('.editable input[type="text"]').keyup(function(e){ |
248 | 788833c7 | Olga Brani | if(e.keyCode == 13) { |
249 | 788833c7 | Olga Brani | setValue($(this)); |
250 | 788833c7 | Olga Brani | resetForm(e, $(this)); |
251 | 788833c7 | Olga Brani | |
252 | 788833c7 | Olga Brani | } |
253 | 788833c7 | Olga Brani | |
254 | 788833c7 | Olga Brani | }) |
255 | 788833c7 | Olga Brani | |
256 | 788833c7 | Olga Brani | $('html').click(function(e) { |
257 | 788833c7 | Olga Brani | resetForm(e, $('.editable a.cancel')); |
258 | 788833c7 | Olga Brani | }); |
259 | 788833c7 | Olga Brani | |
260 | 9569cdc8 | Olga Brani | } |
261 | 9569cdc8 | Olga Brani | |
262 | 5acf3fcf | Olga Brani | /* TODO: better overlay functionality */
|
263 | 9569cdc8 | Olga Brani | ui.overlay = function() { |
264 | 9569cdc8 | Olga Brani | $('[data-overlay-id]').click(function(e){ |
265 | 9569cdc8 | Olga Brani | e.preventDefault(); |
266 | 9569cdc8 | Olga Brani | var el = $(this); |
267 | 6e73603a | Athina Bekakou | var id = '#'+el.data('overlay-id'); |
268 | 03bcb595 | Olga Brani | |
269 | 6e73603a | Athina Bekakou | $('.overlay-area-custom').fadeIn(100); |
270 | bb8cc1dc | Olga Brani | $('body').addClass('with-overlay'); |
271 | 6fcab23b | Olga Brani | $(id).fadeIn('slow'); |
272 | bdf1d2fd | Olga Brani | if (id=='#network-wizard') { |
273 | bdf1d2fd | Olga Brani | $(id).find('input').first().focus(); |
274 | bdf1d2fd | Olga Brani | return false; |
275 | bdf1d2fd | Olga Brani | } |
276 | 9b6be833 | Olga Brani | $(id).find('a').first().focus(); |
277 | 9569cdc8 | Olga Brani | }); |
278 | 788833c7 | Olga Brani | } |
279 | 788833c7 | Olga Brani | |
280 | 5c4713f8 | Olga Brani | function goToByScroll(id){ |
281 | 5c4713f8 | Olga Brani | // Remove "link" from the ID
|
282 | 5c4713f8 | Olga Brani | id = id.replace("link", ""); |
283 | 5c4713f8 | Olga Brani | // Scroll
|
284 | 5c4713f8 | Olga Brani | $('html,body').animate({ |
285 | 5c4713f8 | Olga Brani | scrollTop: $("#"+id).offset().top}, |
286 | 5c4713f8 | Olga Brani | 'slow');
|
287 | 5c4713f8 | Olga Brani | } |
288 | f5321878 | Olga Brani | |
289 | f5321878 | Olga Brani | |
290 | 9b6be833 | Olga Brani | /*
|
291 | 9b6be833 | Olga Brani | * functions concerning checkboxes and radiobuttons links
|
292 | 9b6be833 | Olga Brani | */
|
293 | 656c135b | Olga Brani | |
294 | 9b6be833 | Olga Brani | ui.changeCheckboxState =function(checkbox_link) { |
295 | 77d5883f | Olga Brani | $(checkbox_link).find('.snf-checkbox-unchecked, .snf-checkbox-checked').toggleClass('snf-checkbox-unchecked snf-checkbox-checked'); |
296 | 77d5883f | Olga Brani | ui.entitiesActionsEnabled(); |
297 | 7327e185 | Olga Brani | ui.checkedListItems(); |
298 | 9b6be833 | Olga Brani | } |
299 | 9b6be833 | Olga Brani | |
300 | 112e5dd2 | Athina Bekakou | // to use the above functions use first the ui.checkOneRadioButton and then ui.changeRadiobuttonState
|
301 | 112e5dd2 | Athina Bekakou | ui.checkOneRadioButton = function(radiobtn_link) { |
302 | 112e5dd2 | Athina Bekakou | $(radiobtn_link).closest('ul').find('span.snf-radio-checked').toggleClass('snf-radio-unchecked snf-radio-checked'); |
303 | 112e5dd2 | Athina Bekakou | } |
304 | 9b6be833 | Olga Brani | ui.changeRadiobuttonState = function(radiobtn_link) { |
305 | 9b6be833 | Olga Brani | $(radiobtn_link).find('span.snf-radio-unchecked, span.snf-radio-checked').toggleClass('snf-radio-unchecked snf-radio-checked'); |
306 | 9b6be833 | Olga Brani | } |
307 | 9b6be833 | Olga Brani | |
308 | 9b6be833 | Olga Brani | |
309 | 9b6be833 | Olga Brani | |
310 | 937c0d49 | Athina Bekakou | // toggle expand arrrow and corresponding area
|
311 | 937c0d49 | Athina Bekakou | // todo: one function for all the areas we reveal
|
312 | 937c0d49 | Athina Bekakou | ui.expandDownArea = function(arrow_link, area) { |
313 | 937c0d49 | Athina Bekakou | var arrow_link = $(arrow_link); |
314 | 937c0d49 | Athina Bekakou | var area = $(area); |
315 | 937c0d49 | Athina Bekakou | arrow_link.find('span.snf-arrow-up, span.snf-arrow-down').toggleClass('snf-arrow-up snf-arrow-down'); |
316 | 937c0d49 | Athina Bekakou | // $('.wizard-content').removeAttr('style');
|
317 | 937c0d49 | Athina Bekakou | area.stop().slideToggle(600, function() { |
318 | e3de445d | Athina Bekakou | if (area.is(':visible')) { |
319 | 937c0d49 | Athina Bekakou | arrow_link.find('.snf-arrow-down .snf-arrow-up').removeClass('snf-arrow-down').addClass('snf-arrow-up'); |
320 | 937c0d49 | Athina Bekakou | } else {
|
321 | 937c0d49 | Athina Bekakou | arrow_link.find('.snf-arrow-down .snf-arrow-up').addClass('snf-arrow-down'); |
322 | 937c0d49 | Athina Bekakou | } |
323 | 937c0d49 | Athina Bekakou | |
324 | 937c0d49 | Athina Bekakou | }); |
325 | 937c0d49 | Athina Bekakou | } |
326 | 9b6be833 | Olga Brani | |
327 | 34d12b31 | Olga Brani | |
328 | 34d12b31 | Olga Brani | /* Tabs functionality
|
329 | 34d12b31 | Olga Brani | * tabsEl is the div/ul with the links to the sections and the sections that
|
330 | 34d12b31 | Olga Brani | * with toggle have class sectionEl.
|
331 | 34d12b31 | Olga Brani | * Markup needed is an href to each a with the id of the relative section.
|
332 | 34d12b31 | Olga Brani | */
|
333 | 4081ed61 | Olga Brani | |
334 | 4081ed61 | Olga Brani | ui.tabsSection = function(link, sectionEl) { |
335 | 92747314 | Olga Brani | sectionEl.hide(); |
336 | 4081ed61 | Olga Brani | var el = $(link.attr('href')); |
337 | 4081ed61 | Olga Brani | el.stop(true, true).show(0); |
338 | 4081ed61 | Olga Brani | el.css('opacity',0); |
339 | 4081ed61 | Olga Brani | ui.detailsCustom(el); |
340 | 4081ed61 | Olga Brani | el.animate({ |
341 | 4081ed61 | Olga Brani | 'opacity':1, |
342 | 4081ed61 | Olga Brani | }, 500)
|
343 | 4081ed61 | Olga Brani | } |
344 | 4081ed61 | Olga Brani | |
345 | 34d12b31 | Olga Brani | ui.tabs = function(tabsEl, sectionEl) { |
346 | 34d12b31 | Olga Brani | var tabLink = tabsEl.find('a'); |
347 | 7e6e43e1 | Athina Bekakou | ui.replaceClass(tabLink.find('.active'), 'outline', 'full', 'snf-'); |
348 | 34d12b31 | Olga Brani | function href(a) { |
349 | 34d12b31 | Olga Brani | return a.attr('href'); |
350 | 34d12b31 | Olga Brani | } |
351 | 34d12b31 | Olga Brani | tabLink.click(function(e){
|
352 | 34d12b31 | Olga Brani | e.preventDefault(); |
353 | 34d12b31 | Olga Brani | if ( $(this).hasClass('active')){ |
354 | 34d12b31 | Olga Brani | return false; |
355 | 34d12b31 | Olga Brani | } else {
|
356 | e275e061 | Athina Bekakou | window.location.hash = $(this).attr('href'); |
357 | 7e6e43e1 | Athina Bekakou | ui.replaceClass($(this).parents(tabsEl).find('.active'), 'full', 'outline', 'snf-'); |
358 | 34d12b31 | Olga Brani | $(this).parents(tabsEl).find('a').removeClass('active'); |
359 | 34d12b31 | Olga Brani | $(this).addClass('active'); |
360 | 7e6e43e1 | Athina Bekakou | ui.replaceClass($(this), 'outline', 'full', 'snf-'); |
361 | 4081ed61 | Olga Brani | ui.tabsSection( $(this), sectionEl); |
362 | 34d12b31 | Olga Brani | } |
363 | 34d12b31 | Olga Brani | }) |
364 | 34d12b31 | Olga Brani | } |
365 | 34d12b31 | Olga Brani | |
366 | 9a057bb4 | Athina Bekakou | // the function replaces part of the class of a span that is placed inside an a element
|
367 | 7e6e43e1 | Athina Bekakou | // the class is a word with the form : firstSubStr+*+str1 and it will be converted to: firstSubStr+*+str2
|
368 | 7e6e43e1 | Athina Bekakou | // it must be uniquely recognized by the firstSubStr and the str1.
|
369 | 7e6e43e1 | Athina Bekakou | |
370 | 7e6e43e1 | Athina Bekakou | ui.replaceClass = function(elements, str1, str2, firstSubStr) { |
371 | 9a057bb4 | Athina Bekakou | $.each($(elements), function() { |
372 | 7e6e43e1 | Athina Bekakou | var classOld = $(this).find('span').attr('class'); |
373 | 7e6e43e1 | Athina Bekakou | var classNew;
|
374 | 9a057bb4 | Athina Bekakou | if(classOld != undefined && classOld.indexOf(str1) != -1) { |
375 | e3bd17f3 | Athina Bekakou | if(classOld.indexOf(' ') == -1) { |
376 | 7e6e43e1 | Athina Bekakou | classNew = classOld.replace(str1, str2); |
377 | e3bd17f3 | Athina Bekakou | $(this).find('.'+classOld).removeClass(classOld).addClass(classNew); |
378 | e3bd17f3 | Athina Bekakou | } |
379 | e3bd17f3 | Athina Bekakou | else {
|
380 | 7e6e43e1 | Athina Bekakou | // the string starts with the firstSubStr and after the end of the word there's a space
|
381 | 7e6e43e1 | Athina Bekakou | var expr1 = new RegExp('^'+firstSubStr+'+(\\S*)+'+str1+'+(\\s+)', 'g'); |
382 | e3bd17f3 | Athina Bekakou | |
383 | 7e6e43e1 | Athina Bekakou | // the word is between spaces
|
384 | 7e6e43e1 | Athina Bekakou | var expr2 = new RegExp('(\\s+)'+firstSubStr+'+(\\S*)+'+str1+'+(\\s+)', 'g'); |
385 | e3bd17f3 | Athina Bekakou | |
386 | 7e6e43e1 | Athina Bekakou | // before the word there's at least one space and the string ends with this word
|
387 | 7e6e43e1 | Athina Bekakou | var expr3 = new RegExp('(\\s+)'+firstSubStr+'+(\\S*)+'+str1+'$', 'g'); |
388 | e3bd17f3 | Athina Bekakou | |
389 | 7e6e43e1 | Athina Bekakou | // spaces all over the string
|
390 | 7e6e43e1 | Athina Bekakou | var spacesExp = new RegExp('\\s+', 'g'); |
391 | 7e6e43e1 | Athina Bekakou | |
392 | 7e6e43e1 | Athina Bekakou | if(classOld.match(expr1) != null) { |
393 | 7e6e43e1 | Athina Bekakou | classToReplace = classOld.match(expr1); |
394 | 7e6e43e1 | Athina Bekakou | } |
395 | 7e6e43e1 | Athina Bekakou | else if(classOld.match(expr2) != null) { |
396 | 7e6e43e1 | Athina Bekakou | classToReplace = classOld.match(expr2); |
397 | 7e6e43e1 | Athina Bekakou | } |
398 | 7e6e43e1 | Athina Bekakou | else if (classOld.match(expr3) != null) { |
399 | 7e6e43e1 | Athina Bekakou | classToReplace = classOld.match(expr3); |
400 | e3bd17f3 | Athina Bekakou | } |
401 | 7e6e43e1 | Athina Bekakou | classToReplace = classToReplace.toString().replace(spacesExp,"");
|
402 | 7e6e43e1 | Athina Bekakou | classNew = classToReplace.replace(str1, str2); |
403 | 7e6e43e1 | Athina Bekakou | $(this).find('.'+classToReplace).removeClass(classToReplace).addClass(classNew); |
404 | e3bd17f3 | Athina Bekakou | } |
405 | 9a057bb4 | Athina Bekakou | } |
406 | 9a057bb4 | Athina Bekakou | }); |
407 | 9a057bb4 | Athina Bekakou | } |
408 | 9a057bb4 | Athina Bekakou | |
409 | 4081ed61 | Olga Brani | // in a page with tabs, allow navigation with hash tags
|
410 | 4081ed61 | Olga Brani | ui.hashTabs = function(tabsEl, sectionEl){ |
411 | 4081ed61 | Olga Brani | var hash = window.location.hash;
|
412 | 4081ed61 | Olga Brani | if ($(hash).length<=0){ |
413 | 4081ed61 | Olga Brani | return;
|
414 | 4081ed61 | Olga Brani | } |
415 | 4081ed61 | Olga Brani | tabsEl.find('a').removeClass('active'); |
416 | 4081ed61 | Olga Brani | var link = tabsEl.find('a[href="'+hash+'"]'); |
417 | 4081ed61 | Olga Brani | link.addClass('active');
|
418 | 4081ed61 | Olga Brani | ui.tabsSection(link, sectionEl); |
419 | 4081ed61 | Olga Brani | |
420 | 4081ed61 | Olga Brani | } |
421 | 9a057bb4 | Athina Bekakou | |
422 | 701c9a61 | Olga Brani | ui.ltBarToggle = function(speed){ |
423 | 701c9a61 | Olga Brani | |
424 | 6753a08b | Olga Brani | var cmarg = parseInt($('.lt-bar').width()) - parseInt($('.toggle-lt-bar').outerWidth(true)); |
425 | 701c9a61 | Olga Brani | var ctemp = cmarg / parseInt($('.lt-bar').width()); |
426 | 701c9a61 | Olga Brani | var cvelocity = parseInt($('.lt-bar').width())/speed; |
427 | 701c9a61 | Olga Brani | var cdelay = parseInt($('.toggle-lt-bar').outerWidth(true))/cvelocity; |
428 | 6753a08b | Olga Brani | |
429 | 4e7df8be | Athina Bekakou | $('.lt-bar').click(function(e) { |
430 | 4e7df8be | Athina Bekakou | e.stopPropagation(); |
431 | 4e7df8be | Athina Bekakou | }) |
432 | 6753a08b | Olga Brani | $('.toggle-lt-bar').click(function(e){ |
433 | 6753a08b | Olga Brani | e.preventDefault(); |
434 | 4e7df8be | Athina Bekakou | e.stopPropagation(); |
435 | 6753a08b | Olga Brani | var self =this; |
436 | 6753a08b | Olga Brani | if($(this).hasClass('fix-position')) { |
437 | 6753a08b | Olga Brani | var marg = parseInt($(self).css('marginLeft')) - cmarg; |
438 | 6753a08b | Olga Brani | $(this).animate({ |
439 | 6753a08b | Olga Brani | 'margin-left': marg,
|
440 | 701c9a61 | Olga Brani | }, ctemp * speed, 'linear', function(){ |
441 | 6753a08b | Olga Brani | $(self).removeAttr('style'); |
442 | 6753a08b | Olga Brani | $(self).removeClass('fix-position'); |
443 | 6753a08b | Olga Brani | }); |
444 | 6753a08b | Olga Brani | $('.lt-bar').animate({ |
445 | 6753a08b | Olga Brani | width: 'toggle' |
446 | 701c9a61 | Olga Brani | }, speed, 'linear');
|
447 | 6753a08b | Olga Brani | } |
448 | 6753a08b | Olga Brani | else {
|
449 | 6753a08b | Olga Brani | $(this).addClass('fix-position'); |
450 | 7e6e43e1 | Athina Bekakou | var scrollBarWidth = 14; |
451 | 7e6e43e1 | Athina Bekakou | var marg = parseInt($(self).css('marginLeft')) + cmarg - scrollBarWidth; |
452 | 7e6e43e1 | Athina Bekakou | tt = marg; |
453 | 701c9a61 | Olga Brani | setTimeout(function(){
|
454 | 701c9a61 | Olga Brani | $(self).animate({
|
455 | 701c9a61 | Olga Brani | 'margin-left': marg,
|
456 | 701c9a61 | Olga Brani | }, speed, 'linear')
|
457 | 701c9a61 | Olga Brani | }, cdelay); |
458 | 6753a08b | Olga Brani | $('.lt-bar').animate({ |
459 | 6753a08b | Olga Brani | width: 'toggle' |
460 | ff9c77d4 | Athina Bekakou | }, speed, 'linear', ui.setCustomScrollBar);
|
461 | 6753a08b | Olga Brani | } |
462 | 6753a08b | Olga Brani | }); |
463 | 6753a08b | Olga Brani | } |
464 | 6753a08b | Olga Brani | |
465 | 6753a08b | Olga Brani | |
466 | ff9c77d4 | Athina Bekakou | ui.setCustomScrollBar = function() { |
467 | ff9c77d4 | Athina Bekakou | $('.scroll-pane-arrows').jScrollPane({ |
468 | ff9c77d4 | Athina Bekakou | showArrows: true, |
469 | ff9c77d4 | Athina Bekakou | horizontalGutter: 10, |
470 | ff9c77d4 | Athina Bekakou | verticalDragMinHeight: 300, |
471 | ff9c77d4 | Athina Bekakou | verticalDragMaxHeight: 300, |
472 | ff9c77d4 | Athina Bekakou | mouseWheelSpeed: 50 |
473 | ff9c77d4 | Athina Bekakou | }); |
474 | ff9c77d4 | Athina Bekakou | } |
475 | ff9c77d4 | Athina Bekakou | |
476 | 71acaee4 | Olga Brani | function bytesToSize(bytes) { |
477 | 71acaee4 | Olga Brani | var sizes = [ 'n/a', 'bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; |
478 | 71acaee4 | Olga Brani | var i = +Math.floor(Math.log(bytes) / Math.log(1024)); |
479 | 71acaee4 | Olga Brani | return (bytes / Math.pow(1024, i)).toFixed( 0 ) + sizes[ isNaN( bytes ) ? 0 : i+1 ]; |
480 | 71acaee4 | Olga Brani | } |
481 | 71acaee4 | Olga Brani | function date_ddmmmyytime(date) |
482 | 71acaee4 | Olga Brani | { |
483 | 71acaee4 | Olga Brani | var d = date.getDate();
|
484 | 71acaee4 | Olga Brani | var m = date.getMonth();
|
485 | 71acaee4 | Olga Brani | var y = date.getYear();
|
486 | 71acaee4 | Olga Brani | if(y >= 100) |
487 | 71acaee4 | Olga Brani | { |
488 | 71acaee4 | Olga Brani | y -= 100;
|
489 | 71acaee4 | Olga Brani | y += 2000;
|
490 | 71acaee4 | Olga Brani | } |
491 | 71acaee4 | Olga Brani | |
492 | 71acaee4 | Olga Brani | var curr_hour = date.getHours();
|
493 | 71acaee4 | Olga Brani | |
494 | 71acaee4 | Olga Brani | if (curr_hour < 12){ |
495 | 71acaee4 | Olga Brani | a_p = "am";
|
496 | 71acaee4 | Olga Brani | } else {
|
497 | 71acaee4 | Olga Brani | a_p = "pm";
|
498 | 71acaee4 | Olga Brani | } |
499 | 71acaee4 | Olga Brani | |
500 | 71acaee4 | Olga Brani | if (curr_hour == 0) { |
501 | 71acaee4 | Olga Brani | curr_hour = 12;
|
502 | 71acaee4 | Olga Brani | } |
503 | 71acaee4 | Olga Brani | if (curr_hour > 12){ |
504 | 71acaee4 | Olga Brani | curr_hour = curr_hour - 12;
|
505 | 71acaee4 | Olga Brani | } |
506 | 71acaee4 | Olga Brani | |
507 | 71acaee4 | Olga Brani | var curr_min = date.getMinutes();
|
508 | 71acaee4 | Olga Brani | |
509 | 71acaee4 | Olga Brani | return "" + |
510 | 71acaee4 | Olga Brani | (d<10?"0"+d:d) + "/" +m + "/" + y + ' '+curr_hour + ":" + curr_min + a_p; |
511 | 71acaee4 | Olga Brani | } |
512 | 71acaee4 | Olga Brani | |
513 | ff9c77d4 | Athina Bekakou | |
514 | b3c1328b | Olga Brani | $(document).ready(function(){ |
515 | b3c1328b | Olga Brani | |
516 | 4e7df8be | Athina Bekakou | $('html').click(function(e) { |
517 | 4e7df8be | Athina Bekakou | // not sure if we want to hide the error window after every click in the ui
|
518 | 4e7df8be | Athina Bekakou | if($('.communication-error').css('bottom') == '0px') { |
519 | 4e7df8be | Athina Bekakou | $('.communication-error').animate({bottom: "-151px"}); |
520 | 4e7df8be | Athina Bekakou | } |
521 | 4e7df8be | Athina Bekakou | if($('.details .lt-bar').is(':visible')) { |
522 | 4e7df8be | Athina Bekakou | $('.toggle-lt-bar').trigger('click'); |
523 | 4e7df8be | Athina Bekakou | } |
524 | 4e7df8be | Athina Bekakou | }); |
525 | 4e7df8be | Athina Bekakou | |
526 | 208dd6d1 | Athina Bekakou | if($('.vms.entities').length!=0){ |
527 | 208dd6d1 | Athina Bekakou | ui.inactiveActions(); |
528 | 208dd6d1 | Athina Bekakou | }; |
529 | 337ea026 | Athina Bekakou | ui.setElminHeight($('.main > .details')); |
530 | 9a0058e2 | Olga Brani | ui.setElminHeight($('.lt-bar')); |
531 | 7327e185 | Olga Brani | ui.setElmaxHeight($('.storage-progress')); |
532 | 9a0058e2 | Olga Brani | ui.setElHeight($('.scroll-wrap')); |
533 | 283f4927 | Olga Brani | $('#hd-search .hd-icon-search').click(function(e){ |
534 | 164fdcd9 | Olga Brani | var that = this; |
535 | 283f4927 | Olga Brani | $(this).parents('.hd-search').toggleClass('hd-open'); |
536 | 164fdcd9 | Olga Brani | if ($(this).parents('.hd-search').hasClass('hd-open')) { |
537 | 164fdcd9 | Olga Brani | $(that).parents('.hd-search').find('input[type="search"]').focus(); |
538 | 164fdcd9 | Olga Brani | } else {
|
539 | 164fdcd9 | Olga Brani | $(that).parents('.hd-search').find('input[type="search"]').val(''); |
540 | 164fdcd9 | Olga Brani | } |
541 | 283f4927 | Olga Brani | }) |
542 | 283f4927 | Olga Brani | |
543 | 77d5883f | Olga Brani | $('.header .login').mouseenter(function(e){ |
544 | 4e7c16f1 | Olga Brani | $(this).find('ul').stop(true, true).slideDown(200); |
545 | 77d5883f | Olga Brani | }); |
546 | 77d5883f | Olga Brani | $('.header .login').mouseleave(function(e){ |
547 | 4e7c16f1 | Olga Brani | $(this).find('ul').stop(true, true).slideUp(200); |
548 | 77d5883f | Olga Brani | }); |
549 | 77d5883f | Olga Brani | |
550 | 656c135b | Olga Brani | $('.entities a').click(function(){ |
551 | ca0d2b34 | Olga Brani | if ($(this).attr('data-reveal-id') && !($(this).hasClass('inactive'))) { |
552 | 656c135b | Olga Brani | $('.entities li .more').hide(); |
553 | 656c135b | Olga Brani | } |
554 | 656c135b | Olga Brani | }); |
555 | 656c135b | Olga Brani | |
556 | ca0d2b34 | Olga Brani | $('.inactive').click(function(e){ |
557 | ca0d2b34 | Olga Brani | e.stopPropagation(); |
558 | ca0d2b34 | Olga Brani | e.preventDefault(); |
559 | ca0d2b34 | Olga Brani | }) |
560 | ca0d2b34 | Olga Brani | |
561 | ca0d2b34 | Olga Brani | |
562 | 4e7c16f1 | Olga Brani | $('.lt-actions a:not(.active)').click(function(e){ |
563 | 4e7c16f1 | Olga Brani | e.preventDefault(); |
564 | 4e7c16f1 | Olga Brani | }) |
565 | 4e7c16f1 | Olga Brani | |
566 | 656c135b | Olga Brani | if ($('.entities .items-list >li').length == 1) { |
567 | 9b0b486b | Olga Brani | $('.body-wrapper').addClass('no-vm'); |
568 | 656c135b | Olga Brani | }; |
569 | 656c135b | Olga Brani | $('.entities li .more').each(function(){ |
570 | 656c135b | Olga Brani | var width = $(this).parent('li').outerWidth() + 20; |
571 | 656c135b | Olga Brani | $(this).css('width', width); |
572 | 656c135b | Olga Brani | }); |
573 | 656c135b | Olga Brani | |
574 | 656c135b | Olga Brani | $('.items-list li .img-wrap').on("mouseenter", function(e) { |
575 | 656c135b | Olga Brani | var that = this; |
576 | 656c135b | Olga Brani | if ($(this).parents('.entities').hasClass('grid-view')) { |
577 | 656c135b | Olga Brani | if ($(that).parent('.container').siblings('.more').length>0) { |
578 | 656c135b | Olga Brani | $(that).parent('.container').fadeOut(50,'easeInCirc'); |
579 | 656c135b | Olga Brani | $(that).parent('.container').siblings('.more').fadeIn(150,'easeInCirc'); |
580 | 656c135b | Olga Brani | } |
581 | 656c135b | Olga Brani | } |
582 | 656c135b | Olga Brani | }); |
583 | 656c135b | Olga Brani | $('.entities li .more').mouseleave(function(e) { |
584 | 656c135b | Olga Brani | $(this).fadeOut(50, function() { |
585 | 656c135b | Olga Brani | $(this).siblings('.container').fadeIn(50); |
586 | 656c135b | Olga Brani | }); |
587 | 656c135b | Olga Brani | }); |
588 | 656c135b | Olga Brani | $('.grid-view .items-list > li').mouseleave(function(e){ |
589 | 656c135b | Olga Brani | var that = this; |
590 | 656c135b | Olga Brani | setTimeout(function(){
|
591 | 656c135b | Olga Brani | $(that).find('.more').fadeOut(200, function() { |
592 | 656c135b | Olga Brani | $(this).siblings('.container').fadeIn('fast'); |
593 | 656c135b | Olga Brani | }); |
594 | 656c135b | Olga Brani | },50)
|
595 | 656c135b | Olga Brani | }); |
596 | 164fdcd9 | Olga Brani | |
597 | d3bfabe8 | Olga Brani | ui.closeDiv($('.info .close'), '.info'); |
598 | 5acf3fcf | Olga Brani | ui.editable(); |
599 | 5acf3fcf | Olga Brani | ui.overlay(); |
600 | 4ff5dda5 | Athina Bekakou | ui.colorPickerVisible = 0;
|
601 | d3bfabe8 | Olga Brani | |
602 | 937c0d49 | Athina Bekakou | $("a.disabled").each(function() { |
603 | 937c0d49 | Athina Bekakou | $(this).removeAttr('href'); |
604 | 937c0d49 | Athina Bekakou | }); |
605 | 937c0d49 | Athina Bekakou | |
606 | 937c0d49 | Athina Bekakou | $("a.disabled").click(function(e) { |
607 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
608 | 937c0d49 | Athina Bekakou | }); |
609 | 937c0d49 | Athina Bekakou | |
610 | 62462e34 | Athina Bekakou | // checkbox: basic reaction on click (checked, unchecked)
|
611 | 05205849 | Athina Bekakou | // see wizard
|
612 | 71acaee4 | Olga Brani | $('.check').on('click', function(e){ |
613 | 62462e34 | Athina Bekakou | e.preventDefault(); |
614 | 62462e34 | Athina Bekakou | e.stopPropagation(); |
615 | 62462e34 | Athina Bekakou | ui.changeCheckboxState(this);
|
616 | 62462e34 | Athina Bekakou | }); |
617 | 62462e34 | Athina Bekakou | |
618 | c997f7b6 | Olga Brani | // for checkboxes created after document.ready
|
619 | c997f7b6 | Olga Brani | $('.items-list').on('click','.check', function(e){ |
620 | c997f7b6 | Olga Brani | e.preventDefault(); |
621 | c997f7b6 | Olga Brani | e.stopPropagation(); |
622 | c997f7b6 | Olga Brani | ui.changeCheckboxState(this);
|
623 | c997f7b6 | Olga Brani | }) |
624 | c997f7b6 | Olga Brani | |
625 | 937c0d49 | Athina Bekakou | |
626 | 937c0d49 | Athina Bekakou | $('.with-checkbox').click(function(e){ |
627 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
628 | 937c0d49 | Athina Bekakou | e.stopPropagation(); |
629 | 937c0d49 | Athina Bekakou | var checkbox = self.find('.check'); |
630 | 937c0d49 | Athina Bekakou | ui.changeCheckboxState(checkbox); |
631 | 937c0d49 | Athina Bekakou | }); |
632 | 937c0d49 | Athina Bekakou | |
633 | 937c0d49 | Athina Bekakou | $('.radio_btn').click(function(e) { |
634 | 937c0d49 | Athina Bekakou | e.preventDefault(); |
635 | 937c0d49 | Athina Bekakou | var state = $(this).find('span'); |
636 | 937c0d49 | Athina Bekakou | if(state.hasClass('snf-radio-unchecked')) { |
637 | 937c0d49 | Athina Bekakou | ui.checkOneRadioButton(this);
|
638 | 937c0d49 | Athina Bekakou | ui.changeRadiobuttonState(this);
|
639 | 937c0d49 | Athina Bekakou | } |
640 | 9a0058e2 | Olga Brani | }); |
641 | 937c0d49 | Athina Bekakou | |
642 | d3bfabe8 | Olga Brani | $('.main-actions li a').click(function(e){ |
643 | d3bfabe8 | Olga Brani | if (!($(this).hasClass('active'))) { |
644 | d3bfabe8 | Olga Brani | e.preventDefault(); |
645 | d3bfabe8 | Olga Brani | } |
646 | 9a0058e2 | Olga Brani | }); |
647 | 9569cdc8 | Olga Brani | |
648 | f2126967 | Olga Brani | $('.main-actions li a').click(function(e){ |
649 | f2126967 | Olga Brani | if (!($(this).hasClass('active'))) { |
650 | f2126967 | Olga Brani | e.preventDefault(); |
651 | f2126967 | Olga Brani | } |
652 | 9a0058e2 | Olga Brani | }); |
653 | 6e73603a | Athina Bekakou | $('.overlay-area-custom').children('.close').click(function(e){ |
654 | 9569cdc8 | Olga Brani | e.preventDefault(); |
655 | 62462e34 | Athina Bekakou | e.stopPropagation(); |
656 | 6e73603a | Athina Bekakou | $(this).parents('.overlay-area-custom').hide(); |
657 | 6e73603a | Athina Bekakou | $(this).parents('.overlay-area-custom').find($('.overlay-div')).hide(); |
658 | bb8cc1dc | Olga Brani | $('body').removeClass('with-overlay'); |
659 | 9569cdc8 | Olga Brani | }) |
660 | f2126967 | Olga Brani | |
661 | 182f3fe2 | Olga Brani | $('.browse-files').click(function(e){ |
662 | 182f3fe2 | Olga Brani | e.preventDefault(); |
663 | 182f3fe2 | Olga Brani | }) |
664 | 182f3fe2 | Olga Brani | |
665 | 846f5913 | Olga Brani | Dropzone.options.filesDropzone = { |
666 | 182f3fe2 | Olga Brani | dictDefaultMessage:'', |
667 | 182f3fe2 | Olga Brani | clickable: '.browse-files', |
668 | 846f5913 | Olga Brani | previewsContainer: '.dropzone-files', |
669 | 846f5913 | Olga Brani | createImageThumbnails: false, |
670 | 846f5913 | Olga Brani | dictRemoveFile: "snf-Remove file", |
671 | 182f3fe2 | Olga Brani | }; |
672 | 182f3fe2 | Olga Brani | |
673 | 342fa48b | Olga Brani | |
674 | 342fa48b | Olga Brani | $('.main .files').magnificPopup({ |
675 | 342fa48b | Olga Brani | delegate: 'a.show.image', |
676 | 342fa48b | Olga Brani | type: 'image', |
677 | 342fa48b | Olga Brani | tLoading: 'Loading image #%curr%...', |
678 | 342fa48b | Olga Brani | mainClass: 'mfp-img-mobile', |
679 | 342fa48b | Olga Brani | gallery: {
|
680 | 342fa48b | Olga Brani | enabled: true, |
681 | 342fa48b | Olga Brani | navigateByImgClick: true, |
682 | 342fa48b | Olga Brani | preload: [0,1] // Will preload 0 - before current, and 1 after the current image |
683 | 342fa48b | Olga Brani | }, |
684 | 342fa48b | Olga Brani | image: {
|
685 | bb8cc1dc | Olga Brani | tError: 'The image could not be loaded.', |
686 | 342fa48b | Olga Brani | titleSrc: function(item) { |
687 | 342fa48b | Olga Brani | return item.el.data('title'); |
688 | 342fa48b | Olga Brani | } |
689 | 342fa48b | Olga Brani | } |
690 | 342fa48b | Olga Brani | }); |
691 | 342fa48b | Olga Brani | |
692 | 62462e34 | Athina Bekakou | if($('#picker').length>0) { |
693 | 62462e34 | Athina Bekakou | $('#picker').farbtastic('#color'); |
694 | 62462e34 | Athina Bekakou | }; |
695 | f2380a69 | Athina Bekakou | if($('#sb-search').length>0) { |
696 | f2380a69 | Athina Bekakou | new UISearch( document.getElementById( 'sb-search' ) ); |
697 | f2380a69 | Athina Bekakou | } |
698 | 026edcbc | Olga Brani | |
699 | 6753a08b | Olga Brani | if ($('.toggle-lt-bar').length>0) { |
700 | 701c9a61 | Olga Brani | ui.ltBarToggle(400);
|
701 | 6753a08b | Olga Brani | } |
702 | 026edcbc | Olga Brani | |
703 | 026edcbc | Olga Brani | /* grid/list view for items-list */
|
704 | 026edcbc | Olga Brani | |
705 | 9b0b486b | Olga Brani | $('.actions-bar .list, .actions-bar .grid').click(function(e){ |
706 | 026edcbc | Olga Brani | e.preventDefault(); |
707 | 9b0b486b | Olga Brani | if (!($(this).find('span').hasClass('current'))) { |
708 | 9b0b486b | Olga Brani | $('.actions-bar .grid span, .actions-bar .list span').removeClass('current'); |
709 | 9b0b486b | Olga Brani | $(this).find('span').addClass('current'); |
710 | 9b0b486b | Olga Brani | $('.entities').toggleClass('grid-view list-view'); |
711 | 9b0b486b | Olga Brani | } |
712 | 775d43ea | Athina Bekakou | }); |
713 | 775d43ea | Athina Bekakou | |
714 | 656c135b | Olga Brani | $('.lt-bar .select').click(function(e){ |
715 | 656c135b | Olga Brani | $(this).find('span').toggleClass('snf-checkbox-checked snf-checkbox-unchecked'); |
716 | 656c135b | Olga Brani | $(this).find('em').toggle(); |
717 | 656c135b | Olga Brani | if ( $(this).find('span').hasClass('snf-checkbox-unchecked')){ |
718 | 656c135b | Olga Brani | $('.list-view li .check span').removeClass('snf-checkbox-checked'); |
719 | 656c135b | Olga Brani | $('.list-view li .check span').addClass('snf-checkbox-unchecked'); |
720 | 656c135b | Olga Brani | } else {
|
721 | 656c135b | Olga Brani | $('.list-view li .check span').addClass('snf-checkbox-checked'); |
722 | 656c135b | Olga Brani | $('.list-view li .check span').removeClass('snf-checkbox-unchecked'); |
723 | 656c135b | Olga Brani | } |
724 | 77d5883f | Olga Brani | ui.entitiesActionsEnabled(); |
725 | 7327e185 | Olga Brani | ui.checkedListItems(); |
726 | 656c135b | Olga Brani | }); |
727 | 656c135b | Olga Brani | |
728 | 775d43ea | Athina Bekakou | // set filter visible
|
729 | 775d43ea | Athina Bekakou | $('.filter-menu .filter').click(function(e) { |
730 | 775d43ea | Athina Bekakou | e.preventDefault(); |
731 | 283f4927 | Olga Brani | $(this).parents('.filter-menu').toggleClass('current'); |
732 | d4427ef0 | Athina Bekakou | }); |
733 | d4427ef0 | Athina Bekakou | |
734 | d4427ef0 | Athina Bekakou | // temp function used to demonstrate the visual effect of the building state of vm
|
735 | f0ac40a4 | Athina Bekakou | $('[data-status="building"] .btn5.temp').click(function(e) { |
736 | d4427ef0 | Athina Bekakou | e.preventDefault(); |
737 | d4427ef0 | Athina Bekakou | $(this).siblings('.container').find('.complete').toggleClass('build-progress'); |
738 | f0ac40a4 | Athina Bekakou | }); |
739 | f0ac40a4 | Athina Bekakou | |
740 | f0ac40a4 | Athina Bekakou | $('[data-status="rebooting"] .btn5.temp').click(function(e) { |
741 | f0ac40a4 | Athina Bekakou | e.preventDefault(); |
742 | de9b2b51 | Athina Bekakou | $(this).siblings('.container').find('.snf-pc-full').toggleClass('reboot-progress'); |
743 | 026edcbc | Olga Brani | }) |
744 | 4e7c16f1 | Olga Brani | |
745 | aafd8478 | Athina Bekakou | // //temp function to preventDefault of links in modal
|
746 | aafd8478 | Athina Bekakou | // $('.reveal-modal a:not(".close-reveal-modal, .generate-key-btn, .import-key-btn")').click(function(e){
|
747 | aafd8478 | Athina Bekakou | // e.preventDefault();
|
748 | aafd8478 | Athina Bekakou | // $('a.close-reveal-modal').trigger('click');
|
749 | aafd8478 | Athina Bekakou | // });
|
750 | 8e94f2a9 | Athina Bekakou | |
751 | 8e94f2a9 | Athina Bekakou | // temp btn to show communication error message
|
752 | aafd8478 | Athina Bekakou | $('.temp-for-btns .communication-error-btn').click(function(e) { |
753 | 8e94f2a9 | Athina Bekakou | e.preventDefault(); |
754 | 8e94f2a9 | Athina Bekakou | e.stopPropagation(); |
755 | aafd8478 | Athina Bekakou | $('.communication-error').animate({bottom: "0px"}); |
756 | 8e94f2a9 | Athina Bekakou | }); |
757 | 8e94f2a9 | Athina Bekakou | |
758 | aafd8478 | Athina Bekakou | $('.communication-error a').click(function(e) { |
759 | 8e94f2a9 | Athina Bekakou | e.preventDefault(); |
760 | 8e94f2a9 | Athina Bekakou | e.stopPropagation(); |
761 | aafd8478 | Athina Bekakou | $('.communication-error').animate({bottom: "-151px"}); |
762 | 8e94f2a9 | Athina Bekakou | |
763 | aafd8478 | Athina Bekakou | }); |
764 | aafd8478 | Athina Bekakou | $('.communication-error').click(function(e) { |
765 | aafd8478 | Athina Bekakou | e.stopPropagation(); |
766 | 9bae51cb | Athina Bekakou | }); |
767 | 9bae51cb | Athina Bekakou | |
768 | 9bae51cb | Athina Bekakou | $('.show-add-tag').click(function(e) { |
769 | 9bae51cb | Athina Bekakou | e.preventDefault(); |
770 | 9bae51cb | Athina Bekakou | $(this).parents('.tags-area, .tags').find('.snf-color-picker').slideDown('slow', function() { |
771 | 9bae51cb | Athina Bekakou | $('#hide-add-tag-dummy').scrollintoview({ |
772 | 9bae51cb | Athina Bekakou | 'duration': 'slow' |
773 | 9bae51cb | Athina Bekakou | }); |
774 | 9bae51cb | Athina Bekakou | }); |
775 | 9bae51cb | Athina Bekakou | ui.colorPickerVisible = 1;
|
776 | 9bae51cb | Athina Bekakou | }); |
777 | 9bae51cb | Athina Bekakou | |
778 | 9bae51cb | Athina Bekakou | $('.hide-add-tag').click(function(e) { |
779 | 9bae51cb | Athina Bekakou | e.preventDefault(); |
780 | 9bae51cb | Athina Bekakou | $(this).parents('.tags-area, .tags').find('.snf-color-picker').slideUp(400, function() { |
781 | 9bae51cb | Athina Bekakou | $('.show-add-tag').first().scrollintoview({ |
782 | 9bae51cb | Athina Bekakou | 'duration': 'slow' |
783 | 9bae51cb | Athina Bekakou | }); |
784 | 9bae51cb | Athina Bekakou | ui.colorPickerVisible = 0;
|
785 | 9bae51cb | Athina Bekakou | }); |
786 | aafd8478 | Athina Bekakou | }); |
787 | 3549163d | Olga Brani | |
788 | 3549163d | Olga Brani | // connected details js
|
789 | 86e6c139 | Olga Brani | ui.detailsCustom($('#disk-connected')); |
790 | 86e6c139 | Olga Brani | ui.detailsCustom($('#network-connected')); |
791 | 86e6c139 | Olga Brani | ui.detailsCustom($('#vm-connected')); |
792 | 3549163d | Olga Brani | ui.firewallSetup(); |
793 | 3549163d | Olga Brani | $('.firewall .more a').click(function(e){ |
794 | 3549163d | Olga Brani | e.preventDefault(); |
795 | 3549163d | Olga Brani | if ($(this).find('span').hasClass('snf-radio-checked')) { |
796 | 3549163d | Olga Brani | return false; |
797 | 3549163d | Olga Brani | } |
798 | 3549163d | Olga Brani | $(this).parents('.firewall').removeAttr('data-firewall'); |
799 | 3549163d | Olga Brani | $(this).parents('.firewall').data('firewall', $(this).parent().attr('class')); |
800 | 3549163d | Olga Brani | $(this).find('span').toggleClass('snf-radio-unchecked snf-radio-checked'); |
801 | 3549163d | Olga Brani | $(this).parent('p').siblings('p').find('span').removeClass('snf-radio-checked'); |
802 | 3549163d | Olga Brani | $(this).parent('p').siblings('p').find('span').addClass('snf-radio-unchecked'); |
803 | 3549163d | Olga Brani | ui.firewallSetup(); |
804 | 3549163d | Olga Brani | }); |
805 | 3549163d | Olga Brani | $('.firewall').mouseenter(function(e){ |
806 | 54f6789d | Olga Brani | $(this).css('z-index',2); |
807 | 3549163d | Olga Brani | $(this).find('.more').stop(true, true).slideDown(200); |
808 | 3549163d | Olga Brani | }); |
809 | 3549163d | Olga Brani | $('.firewall').mouseleave(function(e){ |
810 | 54f6789d | Olga Brani | $(this).css('z-index',1); |
811 | 3549163d | Olga Brani | $(this).find('.more').stop(true, true).slideUp(200); |
812 | 3549163d | Olga Brani | }); |
813 | 34d12b31 | Olga Brani | ui.tabs($('.tabs'), $('.content')); |
814 | 4081ed61 | Olga Brani | ui.hashTabs($('.tabs'), $('.content')); |
815 | 9a0058e2 | Olga Brani | |
816 | 112e5dd2 | Athina Bekakou | $('.act').click(function(e) { |
817 | 112e5dd2 | Athina Bekakou | $(this).addClass('pending last'); |
818 | 112e5dd2 | Athina Bekakou | }); |
819 | 112e5dd2 | Athina Bekakou | |
820 | 112e5dd2 | Athina Bekakou | $('.remove .cancel').click(function(e) { |
821 | 112e5dd2 | Athina Bekakou | e.preventDefault(); |
822 | 112e5dd2 | Athina Bekakou | $('a.close-reveal-modal').trigger('click'); |
823 | 112e5dd2 | Athina Bekakou | $('.last').removeClass('pending last'); |
824 | 112e5dd2 | Athina Bekakou | }); |
825 | 112e5dd2 | Athina Bekakou | |
826 | 112e5dd2 | Athina Bekakou | $('.remove .ok').click(function(e) { |
827 | 84e9a07d | Olga Brani | e.preventDefault(); |
828 | 112e5dd2 | Athina Bekakou | $('a.close-reveal-modal').trigger('click'); |
829 | 112e5dd2 | Athina Bekakou | var connection_img = $('.connections').find('.last'); |
830 | 112e5dd2 | Athina Bekakou | connection_img.addClass('open', 0); |
831 | e3bd17f3 | Athina Bekakou | connection_img.removeClass('last');
|
832 | 112e5dd2 | Athina Bekakou | var img = connection_img.closest('.item').find('.img-wrap .snf-font'); |
833 | a716e840 | Athina Bekakou | img.addClass('reboot-progress');
|
834 | a716e840 | Athina Bekakou | setTimeout(function() {
|
835 | 112e5dd2 | Athina Bekakou | var connections_list = connection_img.closest('.connections').children('li:not(".hidden")'); |
836 | a716e840 | Athina Bekakou | if(connections_list.length>1) { |
837 | 112e5dd2 | Athina Bekakou | connection_img.closest('li').slideUp(function(){ |
838 | 112e5dd2 | Athina Bekakou | connection_img.closest('li').addClass('hidden'); |
839 | 112e5dd2 | Athina Bekakou | if(connections_list.find('.pending').length == 0) { |
840 | 112e5dd2 | Athina Bekakou | img.removeClass('reboot-progress');
|
841 | 112e5dd2 | Athina Bekakou | } |
842 | a716e840 | Athina Bekakou | }); |
843 | a716e840 | Athina Bekakou | } |
844 | a716e840 | Athina Bekakou | else {
|
845 | 112e5dd2 | Athina Bekakou | connection_img.closest('.item').slideUp(function(){ |
846 | 112e5dd2 | Athina Bekakou | img.closest('li').addClass('hidden'); |
847 | 112e5dd2 | Athina Bekakou | img.removeClass('reboot-progress');
|
848 | 9a057bb4 | Athina Bekakou | img.removeClass('reboot-progress');
|
849 | a716e840 | Athina Bekakou | }); |
850 | a716e840 | Athina Bekakou | } |
851 | 112e5dd2 | Athina Bekakou | connection_img.removeClass('pending');
|
852 | a716e840 | Athina Bekakou | }, 3000)
|
853 | 112e5dd2 | Athina Bekakou | }); |
854 | 3549163d | Olga Brani | // end of connected details js
|
855 | 9a057bb4 | Athina Bekakou | |
856 | 7e6e43e1 | Athina Bekakou | ui.replaceClass($('a.current, a.active'), 'outline', 'full', 'snf-'); |
857 | d73d1554 | Athina Bekakou | |
858 | 4e7df8be | Athina Bekakou | // with the function below the sidebar in detailed views
|
859 | 4e7df8be | Athina Bekakou | // will not hide if we click something in a wizard
|
860 | 4e7df8be | Athina Bekakou | $('.wizard').click(function(e) { |
861 | 4e7df8be | Athina Bekakou | e.stopPropagation(); |
862 | 4e7df8be | Athina Bekakou | }) |
863 | 4e7df8be | Athina Bekakou | |
864 | 4e7df8be | Athina Bekakou | $('.tag-data').mouseover(function() { |
865 | 4e7df8be | Athina Bekakou | $(this).find('.delete').css({visibility: 'visible'}) |
866 | 4e7df8be | Athina Bekakou | }); |
867 | 4e7df8be | Athina Bekakou | $('.tag-data').mouseleave(function(){ |
868 | 4e7df8be | Athina Bekakou | $(this).find('.delete').css({visibility: 'hidden'}) |
869 | 4e7df8be | Athina Bekakou | }); |
870 | d73d1554 | Athina Bekakou | $('.delete').click(function(e) { |
871 | d73d1554 | Athina Bekakou | e.preventDefault(); |
872 | d73d1554 | Athina Bekakou | $(this).closest('div').fadeOut('slow'); |
873 | 4e7df8be | Athina Bekakou | }); |
874 | ff9c77d4 | Athina Bekakou | |
875 | 7327e185 | Olga Brani | $('.storage-progress').hover( |
876 | 0ef95fe4 | Olga Brani | function(e){
|
877 | 7327e185 | Olga Brani | $(this).find('.details').stop(false,true).slideDown(); |
878 | 0ef95fe4 | Olga Brani | }, |
879 | 0ef95fe4 | Olga Brani | function(e){
|
880 | 7327e185 | Olga Brani | $(this).find('.details').stop(false,true).slideUp(); |
881 | 0ef95fe4 | Olga Brani | } |
882 | 0ef95fe4 | Olga Brani | ); |
883 | 0ef95fe4 | Olga Brani | |
884 | 2eef02ae | Athina Bekakou | $('.btn-more').mouseenter(function(e) { |
885 | 2eef02ae | Athina Bekakou | $(this).find('.explain').stop(true, true).show('slow'); |
886 | 2eef02ae | Athina Bekakou | $(this).addClass('style-1'); |
887 | 2eef02ae | Athina Bekakou | $(this).find('.snf-arrow-down').removeClass('style-1'); |
888 | 2eef02ae | Athina Bekakou | // $(this).siblings('.available').stop(true, true).slideDown(200);
|
889 | 2eef02ae | Athina Bekakou | }); |
890 | 7327e185 | Olga Brani | |
891 | 2eef02ae | Athina Bekakou | $('.btn-more').click(function(e) { |
892 | 2eef02ae | Athina Bekakou | e.preventDefault(); |
893 | 2eef02ae | Athina Bekakou | $(this).addClass('style-2'); |
894 | 2eef02ae | Athina Bekakou | $(this).closest('.project').css('z-index', 2); |
895 | 2eef02ae | Athina Bekakou | $(this).siblings('.available').stop(true, true).slideDown('slow'); |
896 | 2eef02ae | Athina Bekakou | }) |
897 | 7327e185 | Olga Brani | |
898 | 2eef02ae | Athina Bekakou | $('.project').mouseleave(function(e) { |
899 | 2eef02ae | Athina Bekakou | $(this).find('.available').stop(true, true).slideUp(200); |
900 | 2eef02ae | Athina Bekakou | var btn = $(this).find('.btn-more'); |
901 | 2eef02ae | Athina Bekakou | btn.find('.explain').stop(true, true).hide('slow'); |
902 | 2eef02ae | Athina Bekakou | $(btn).find('.snf-arrow-down').addClass('style-1'); |
903 | 2eef02ae | Athina Bekakou | btn.removeClass('style-2');
|
904 | 2eef02ae | Athina Bekakou | $(btn).removeClass('style-1'); |
905 | 2eef02ae | Athina Bekakou | $(this).closest('.project').css('z-index',1); |
906 | 2eef02ae | Athina Bekakou | }) |
907 | 98714f8a | Olga Brani | }) |
908 | b3c1328b | Olga Brani | |
909 | 9569cdc8 | Olga Brani | |
910 | 98714f8a | Olga Brani | $(window).resize(function(e){ |
911 | 337ea026 | Athina Bekakou | ui.setElminHeight($('.main > .details')); |
912 | 9a0058e2 | Olga Brani | ui.setElminHeight($('.lt-bar')); |
913 | 9a0058e2 | Olga Brani | ui.setElHeight($('.scroll-wrap')); |
914 | ff9c77d4 | Athina Bekakou | ui.setCustomScrollBar(); |
915 | 7327e185 | Olga Brani | ui.setElmaxHeight($('.storage-progress')); |
916 | 7327e185 | Olga Brani | |
917 | b3c1328b | Olga Brani | }) |