Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / common.js @ e275e061

History | View | Annotate | Download (22.9 kB)

1
/*
2
* Various functions that will be used throughout all templates
3
* are inside ui Object
4
*/
5

    
6
ui = {};
7
/*
8
* ui.wizards get populated in vm-wizard.js
9
* here is the declaration only
10
*/
11
ui.wizard = {};
12

    
13
/* when closeEl el is clicked, its parent with class divToCloseClass slidesUp */
14
ui.closeDiv = function(closeEl, divToCloseClass) {
15
    closeEl.click(function(e){
16
        e.preventDefault();
17
        $(this).parents(divToCloseClass).slideUp('slow');
18
    });
19
}
20

    
21

    
22
ui.trimChars = function( str, chars) {
23
    if ( str.length>chars){
24
        return $.trim(str).substring(0, chars)+ "...";
25
    } else {
26
        return str;
27
    }
28
}
29

    
30

    
31
/* Sets element min-height
32
* Used for .details, .lt-bar divs
33
*/
34
ui.setElminHeight = function(el){
35
    var WindowHeight = $(window).height();
36
    var header = $('.header').outerHeight();
37
    var actions = $('.actions-bar').height();
38
    var h1= WindowHeight - (header+actions);
39
    el.css('min-height', h1);
40
}
41

    
42
/* Sets element height
43
* Used for .details, .lt-bar divs
44
*/
45
ui.setElHeight = function(el){
46
    var WindowHeight = $(window).height();
47
    var header = $('.header').outerHeight();
48
    var actions = $('.actions-bar').height();
49
    var h1= WindowHeight - (header+actions);
50
    el.css('height', h1);
51
}
52

    
53
/* 
54
* Logic for Entities actions. Present in items_list pages
55
* Available categories are :
56
*  - both/single ( for multiple entities/single entities)
57
*  - running/off ( for running/off entities)
58
*  - permanent ( for entities always active )
59
*/
60
ui.entitiesActionsEnabled = function(){
61
    var all = $('.snf-checkbox-checked').length;
62
    var running = $('.snf-checkbox-checked').parents('li.running').length;
63
    var off = $('.snf-checkbox-checked').parents('li.off').length;
64
    console.log(off, 'actions here');
65
    $('.lt-bar .lt-actions li:not(.permanent) a').removeClass('active');
66
    if ( (running*off) > 0 ){
67
         $('.lt-actions li.both a').addClass('active');
68
         $('.lt-actions li.single a').removeClass('active');
69
    } else {
70
        if (running > 0) {
71
            $('.lt-actions li.both a').addClass('active');
72
            $('.lt-actions li.running a').addClass('active');
73
        } else if (off>0) {
74
            $('.lt-actions li.both a').addClass('active');
75
            $('.lt-actions li.off a').addClass('active');
76
        }
77
        if ( all > 1 ) {
78
            $('.lt-actions li.single a').removeClass('active');
79
        }
80
    }
81
}
82

    
83
ui.inactiveActions = function() {
84

    
85
    // Availble actions: connect, reboot, shut, destroy, start
86
    // These actions will be DISABLED
87
    var statesActions ={
88
        'off'      : ['connect', 'reboot', 'shut'],
89
        'error'    : ['connect', 'reboot', 'shut', 'start'],
90
        'building' : ['reboot', 'start'],
91
        'running'  : ['start'],
92
        'rebooting': ['start'],
93
        'starting' : ['start'],
94
        'shutting' : ['connect', 'reboot', 'shut']
95
    } ;
96

    
97
    _.each (statesActions, function(val, key) {
98
        _.each(val, function(value) {
99
            var el = '.' + key + ' .' + value;
100
            $(el).addClass('inactive');
101
        });
102
    })
103
}
104

    
105
ui.detailsCustom = function(area) {
106
    // position last connected item
107
    var el = area.find('.item').last();
108
    // -2 is the border width;
109
    var moveY = el.find('.connections >li').last().outerHeight(true) - 2;
110
    el.css('top',moveY);
111
    el.css('marginTop', -moveY);
112
}
113

    
114
ui.firewallSetup = function(){
115
    $('.firewall').each(function(){
116
        $(this).removeClass('fully unprotected basic');
117
        $(this).addClass($(this).data('firewall'));
118
        if($(this).hasClass('unprotected')){
119
            $(this).find('p').first().find('em').html('off');
120
        } else {
121
            $(this).find('p').first().find('em').html('on');
122
        }
123
    });
124
    $('.firewall .more span').each(function(e){
125
        var that = this;
126
        if ($(this).hasClass('snf-radio-checked')){
127
            $(that).siblings('em').html('on');
128
        } else {
129
            $(that).siblings('em').html('off');
130
        }
131
    })
132
}
133

    
134

    
135
/*
136
* In order for the editable value functionality to work, the html markup
137
* should be:
138
    <div class="editable">
139
        <span class="input-txt">editable value</span>
140
        <input type="text">
141
        <a href="#" class="edit">edit</a>
142
        <a href="#" class="save">save</a>
143
        <a href="#" class="cancel">cancel</a>
144
    </div>
145
*/
146
ui.editable = function(){
147

    
148
/*
149
* resetForm hides save and cancel buttons,
150
* text input and shows input-txt. resetForm does not alter
151
* input-txt content.
152
*/
153

    
154
    function resetForm(e, elem) {
155
        var el = elem.parents('.editable');
156
        el.find('input[type="text"]').hide();
157
        el.find('a.cancel, a.save').hide();
158
        el.find('a.edit, .input-txt').show();
159
    }
160

    
161
/* 
162
* showForm hides input-txt, shows save and cancel buttons and
163
* sets input value to input-txt content.
164
*/
165
    function showForm(e,elem) {
166
        e.stopPropagation(); 
167
        e.preventDefault();
168
        var el = elem.parents('.editable'); 
169
        el.find('input[type="text"]').val(el.find('.input-txt').html());
170
        el.find('input[type="text"]').show();
171
        el.find('a.cancel, a.save').show();
172
        elem.hide();
173
        el.find('.input-txt').hide();
174
    }
175

    
176
/*
177
setValue sets input-txt value to the input value.
178
Makes sure that the input value is not empty.
179
TODO:
180
Ajax request to submit form
181
*/
182

    
183
    function setValue(elem) {
184
        var el = elem.parents('.editable');
185
        if( el.find('input[type="text"]').val() ) {
186
            el.find('.input-txt').html(el.find('input[type="text"]').val());
187
        }
188
    }
189

    
190

    
191
    $('.editable .edit').click(function(e){
192
        showForm(e, $(this));
193
    })
194

    
195
    $('.editable .cancel').click(function(e){
196
        e.stopPropagation();
197
        e.preventDefault();
198
        resetForm(e, $(this));
199
    })
200

    
201
    $('.editable .save').click(function(e){
202
        e.stopPropagation();
203
        e.preventDefault();
204
        setValue($(this));
205
        resetForm(e, $(this));
206

    
207
    })
208

    
209

    
210
    $('.editable input[type="text"]').click(function(e){
211
        e.stopPropagation();
212
    })
213

    
214
    $('.editable input[type="text"]').keyup(function(e){
215
        if(e.keyCode == 13) { 
216
            setValue($(this));
217
            resetForm(e, $(this));
218
            
219
        }
220
    
221
    })
222

    
223
    $('html').click(function(e) {
224
        resetForm(e, $('.editable a.cancel'));
225
        // not sure if we want to hide the error window after every click in the ui
226
        if($('.communication-error').css('bottom') == '0px') {
227
            $('.communication-error').animate({bottom: "-151px"});
228
        }
229
    });
230

    
231
}
232

    
233
/* TODO: better overlay functionality */
234
ui.overlay = function() {
235
    $('[data-overlay-id]').click(function(e){
236
        e.preventDefault();
237
        var el = $(this);
238
        var id = '#'+el.data('overlay-id');
239

    
240
        $('.overlay-area-custom').fadeIn(100);
241
        $('body').addClass('with-overlay');
242
        $(id).fadeIn('slow');
243
        if (id=='#network-wizard') {
244
            $(id).find('input').first().focus();
245
            return false;
246
        }
247
        $(id).find('a').first().focus();
248
    });
249
}
250

    
251
function goToByScroll(id){
252
      // Remove "link" from the ID
253
    id = id.replace("link", "");
254
      // Scroll
255
    $('html,body').animate({
256
        scrollTop: $("#"+id).offset().top},
257
        'slow');
258
}
259

    
260

    
261
/*
262
* functions concerning checkboxes and radiobuttons links
263
*/
264

    
265
ui.changeCheckboxState =function(checkbox_link) {
266
    $(checkbox_link).find('.snf-checkbox-unchecked, .snf-checkbox-checked').toggleClass('snf-checkbox-unchecked snf-checkbox-checked');
267
    ui.entitiesActionsEnabled();
268
}
269

    
270
// to use the above functions use first the ui.checkOneRadioButton and then ui.changeRadiobuttonState
271
ui.checkOneRadioButton = function(radiobtn_link) {
272
    $(radiobtn_link).closest('ul').find('span.snf-radio-checked').toggleClass('snf-radio-unchecked snf-radio-checked');
273
}
274
ui.changeRadiobuttonState = function(radiobtn_link) {
275
    $(radiobtn_link).find('span.snf-radio-unchecked, span.snf-radio-checked').toggleClass('snf-radio-unchecked snf-radio-checked');
276
}
277

    
278

    
279

    
280
// toggle expand arrrow  and corresponding area
281
// todo: one function for all the areas we reveal
282
ui.expandDownArea = function(arrow_link, area) {
283
    var arrow_link = $(arrow_link);
284
    var area = $(area);
285
            arrow_link.find('span.snf-arrow-up, span.snf-arrow-down').toggleClass('snf-arrow-up snf-arrow-down');
286
            // $('.wizard-content').removeAttr('style');
287
            area.stop().slideToggle(600, function() {
288
                if (area.is(':visible')) {
289
                    arrow_link.find('.snf-arrow-down .snf-arrow-up').removeClass('snf-arrow-down').addClass('snf-arrow-up');
290
                } else {
291
                    arrow_link.find('.snf-arrow-down .snf-arrow-up').addClass('snf-arrow-down');
292
                }
293

    
294
            });
295
}
296

    
297

    
298
/* Tabs functionality
299
* tabsEl is the div/ul with the links to the sections and the sections that
300
* with toggle have class sectionEl.
301
* Markup needed is an href to each a with the id of the relative section.
302
*/
303

    
304
ui.tabsSection = function(link, sectionEl) {
305
    $(sectionEl).hide();
306
    var el = $(link.attr('href'));
307
    el.stop(true, true).show(0);
308
    el.css('opacity',0);
309
    ui.detailsCustom(el);
310
    el.animate({
311
        'opacity':1,
312
    }, 500)
313
}
314

    
315
ui.tabs = function(tabsEl, sectionEl) {
316
    var tabLink = tabsEl.find('a');
317
    ui.replaceClass(tabLink.find('.active'), 'outline', 'full');
318
    function href(a) {
319
        return a.attr('href');
320
    }
321
    tabLink.click(function(e){
322
        e.preventDefault();
323
        if ( $(this).hasClass('active')){
324
             return false;
325
        } else {
326
            window.location.hash = $(this).attr('href');
327
            ui.replaceClass($(this).parents(tabsEl).find('.active'), 'full', 'outline');
328
            $(this).parents(tabsEl).find('a').removeClass('active');
329
            $(this).addClass('active');
330
            ui.replaceClass($(this), 'outline', 'full');
331
            ui.tabsSection( $(this), sectionEl);
332
        }
333
    })
334
}
335

    
336
// the function replaces part of the class of a span that is placed inside an a element
337
ui.replaceClass = function(elements, str1, str2) {
338
    $.each($(elements), function() {
339
        classOld = $(this).find('span').attr('class');
340
        if(classOld != undefined && classOld.indexOf(str1) != -1) {
341
            var classNew =classOld.replace(str1, str2);
342
            if(classOld.indexOf(' ') == -1) {
343
                $(this).find('.'+classOld).removeClass(classOld).addClass(classNew);
344
            }
345
            else {
346
                var classToReplace;
347
                if(classOld.indexOf(' ') > classOld.indexOf(str1)) {
348
                    classToReplace = classOld.substring(0,classOld.indexOf(' '));
349

    
350
                }
351
                else {
352

    
353
                    classToReplace = classOld.substring(classOld.indexOf(' ')+1, classOld.indexOf(str1)+str1.length);
354
                }
355

    
356
                if($(this).find('.'+classToReplace).hasClass(classOld)) {
357
                    console.log('classToReplace ', classToReplace)
358
                       $(this).find('.'+classToReplace).removeClass(classToReplace).addClass(classNew);
359
                }
360
            }
361
        }
362
    });
363
}
364

    
365
// in a page with tabs, allow navigation with hash tags
366
ui.hashTabs = function(tabsEl, sectionEl){
367
    var hash = window.location.hash;
368
    if ($(hash).length<=0){
369
        return;
370
    }
371
    tabsEl.find('a').removeClass('active');
372
    var link = tabsEl.find('a[href="'+hash+'"]');
373
    link.addClass('active');
374
    ui.tabsSection(link, sectionEl);
375

    
376
}
377

    
378
$(document).ready(function(){
379

    
380
    if($('.vms.entities').length!=0){
381
        ui.inactiveActions();
382
    };
383
    ui.setElminHeight($('.main > .details'));
384
    ui.setElminHeight($('.lt-bar'));
385
    ui.setElHeight($('.scroll-wrap'));
386
    $('#hd-search .hd-icon-search').click(function(e){
387
        var that = this;
388
        $(this).parents('.hd-search').toggleClass('hd-open');
389
        if ($(this).parents('.hd-search').hasClass('hd-open')) {
390
            $(that).parents('.hd-search').find('input[type="search"]').focus();
391
        } else {
392
            $(that).parents('.hd-search').find('input[type="search"]').val('');
393
        }
394
    })
395

    
396
    $('.header .login').mouseenter(function(e){
397
        $(this).find('ul').stop(true, true).slideDown(200);
398
    });
399
    $('.header .login').mouseleave(function(e){
400
        $(this).find('ul').stop(true, true).slideUp(200);
401
    });
402

    
403
    $('.entities a').click(function(){
404
        if ($(this).attr('data-reveal-id') && !($(this).hasClass('inactive'))) {
405
            $('.entities li .more').hide();
406
        }
407
    });
408

    
409
    $('.inactive').click(function(e){
410
        e.stopPropagation();
411
        e.preventDefault();
412
     })
413

    
414

    
415
    $('.lt-actions a:not(.active)').click(function(e){
416
        e.preventDefault();
417
    })
418

    
419
    if ($('.entities .items-list >li').length == 1) {
420
        $('.overlay-wrapper').addClass('no-vm');
421
    };
422
    $('.entities li .more').each(function(){
423
        var width = $(this).parent('li').outerWidth()  + 20;
424
        $(this).css('width', width);
425
    });
426

    
427
    $('.items-list li .img-wrap').on("mouseenter", function(e) {
428
        var that = this;
429
        if ($(this).parents('.entities').hasClass('grid-view')) {
430
            if ($(that).parent('.container').siblings('.more').length>0) {
431
                $(that).parent('.container').fadeOut(50,'easeInCirc');
432
                $(that).parent('.container').siblings('.more').fadeIn(150,'easeInCirc');
433
            }
434
        }
435
    });
436
    $('.entities li .more').mouseleave(function(e) {
437
        $(this).fadeOut(50, function() {
438
            $(this).siblings('.container').fadeIn(50);
439
        });
440
    });
441
    $('.grid-view .items-list > li').mouseleave(function(e){
442
        var that = this;
443
        setTimeout(function(){
444
            $(that).find('.more').fadeOut(200, function() {
445
                $(this).siblings('.container').fadeIn('fast');
446
            });
447
        },50)
448
    });
449

    
450
    ui.closeDiv($('.info .close'), '.info');
451
    ui.editable();
452
    ui.overlay();
453
    ui.colorPickerVisible = 0;
454

    
455
    $("a.disabled").each(function() {
456
        $(this).removeAttr('href');
457
    });
458
    
459
    $("a.disabled").click(function(e) {
460
        e.preventDefault();
461
    });
462

    
463
    // checkbox: basic reaction on click (checked, unchecked)
464
    // see wizard
465
    $('.check').click(function(e){
466
        e.preventDefault();
467
        e.stopPropagation();
468
        ui.changeCheckboxState(this);
469
    });
470

    
471

    
472
    $('.with-checkbox').click(function(e){
473
        e.preventDefault();
474
        e.stopPropagation();
475
        var checkbox = self.find('.check');
476
        ui.changeCheckboxState(checkbox);
477
    });
478

    
479
    $('.radio_btn').click(function(e) {
480
        e.preventDefault();
481
         var state = $(this).find('span');
482
         if(state.hasClass('snf-radio-unchecked')) {
483
            ui.checkOneRadioButton(this);
484
            ui.changeRadiobuttonState(this);
485
        }
486
    });
487

    
488
    $('.main-actions li a').click(function(e){
489
        if (!($(this).hasClass('active'))) {
490
            e.preventDefault();
491
        }
492
    });
493

    
494
    $('.main-actions li a').click(function(e){
495
        if (!($(this).hasClass('active'))) {
496
            e.preventDefault();
497
        }
498
    });
499
    $('.overlay-area-custom').children('.close').click(function(e){
500
        e.preventDefault();
501
        e.stopPropagation();
502
        $(this).parents('.overlay-area-custom').hide();
503
        $(this).parents('.overlay-area-custom').find($('.overlay-div')).hide();
504
        $('body').removeClass('with-overlay');
505
    })
506

    
507
    $('.browse-files').click(function(e){
508
        e.preventDefault();
509
    })
510

    
511
    Dropzone.options.filesDropzone = {
512
        dictDefaultMessage:'',
513
        clickable: '.browse-files',
514
        previewsContainer: '.dropzone-files',
515
        createImageThumbnails: false,
516
        dictRemoveFile: "snf-Remove file",
517
    };
518

    
519

    
520
    $('.main .files').magnificPopup({
521
        delegate: 'a.show.image',
522
        type: 'image',
523
        tLoading: 'Loading image #%curr%...',
524
        mainClass: 'mfp-img-mobile',
525
        gallery: {
526
            enabled: true,
527
            navigateByImgClick: true,
528
            preload: [0,1] // Will preload 0 - before current, and 1 after the current image
529
        },
530
        image: {
531
            tError: 'The image could not be loaded.',
532
            titleSrc: function(item) {
533
                return item.el.data('title');
534
            }
535
        }
536
    });
537

    
538
    if($('#picker').length>0) {
539
        $('#picker').farbtastic('#color');
540
    };
541
    if($('#sb-search').length>0) {
542
        new UISearch( document.getElementById( 'sb-search' ) );
543
    }
544

    
545

    
546
    /* grid/list view for items-list */
547

    
548
    $('.view-type .list').click(function(e){
549
        e.preventDefault();
550
        $('.view-type .grid span').removeClass('current');
551
        $(this).find('span').addClass('current');
552
        $('.entities').removeClass('grid-view');
553
        $('.entities').addClass('list-view');
554
    });
555

    
556
     $('.view-type .grid').click(function(e){
557
        e.preventDefault();
558
        $('.view-type .list span').removeClass('current');
559
        $(this).find('span').addClass('current');
560
        $('.entities').addClass('grid-view');
561
        $('.entities').removeClass('list-view');
562
    });
563

    
564
     $('.lt-bar .select').click(function(e){
565
        $(this).find('span').toggleClass('snf-checkbox-checked snf-checkbox-unchecked');
566
        $(this).find('em').toggle();
567
        if ( $(this).find('span').hasClass('snf-checkbox-unchecked')){
568
            $('.list-view  li .check span').removeClass('snf-checkbox-checked');
569
            $('.list-view  li .check span').addClass('snf-checkbox-unchecked');
570
        } else {
571
            $('.list-view  li .check span').addClass('snf-checkbox-checked');
572
            $('.list-view  li .check span').removeClass('snf-checkbox-unchecked');
573
        }
574
        ui.entitiesActionsEnabled();
575
     });
576

    
577

    
578
    // set filter visible
579
    $('.filter-menu .filter').click(function(e) {
580
        e.preventDefault();
581
        $(this).parents('.filter-menu').toggleClass('current');
582
    });
583

    
584
    // temp function used to demonstrate the visual effect of the building state of vm
585
    $('[data-status="building"] .btn5.temp').click(function(e) {
586
        e.preventDefault();
587
        $(this).siblings('.container').find('.complete').toggleClass('build-progress');
588
    });
589

    
590
    $('[data-status="rebooting"] .btn5.temp').click(function(e) {
591
        e.preventDefault();
592
        $(this).siblings('.container').find('.snf-pc-full').toggleClass('reboot-progress');
593
    })
594

    
595
    // //temp function to preventDefault of links in modal
596
    // $('.reveal-modal a:not(".close-reveal-modal, .generate-key-btn, .import-key-btn")').click(function(e){
597
    //     e.preventDefault();
598
    //     $('a.close-reveal-modal').trigger('click');
599
    // });
600

    
601
     // temp btn to show communication error message
602
    $('.temp-for-btns .communication-error-btn').click(function(e) {
603
         e.preventDefault();
604
         e.stopPropagation();
605
         $('.communication-error').animate({bottom: "0px"});
606
     });
607

    
608
    $('.communication-error a').click(function(e) {
609
        e.preventDefault();
610
        e.stopPropagation();
611
        $('.communication-error').animate({bottom: "-151px"});
612

    
613
    });
614
    $('.communication-error').click(function(e) {
615
        e.stopPropagation();
616
    });
617

    
618
    $('.show-add-tag').click(function(e) {
619
    e.preventDefault();
620
    $(this).parents('.tags-area, .tags').find('.snf-color-picker').slideDown('slow', function() {
621
        $('#hide-add-tag-dummy').scrollintoview({
622
            'duration': 'slow'
623
        });
624
    });
625
    ui.colorPickerVisible = 1;
626
    });
627

    
628
    $('.hide-add-tag').click(function(e) {
629
    e.preventDefault();
630
    $(this).parents('.tags-area, .tags').find('.snf-color-picker').slideUp(400, function() {
631
        $('.show-add-tag').first().scrollintoview({
632
            'duration': 'slow'
633
        });
634
        ui.colorPickerVisible = 0;
635
    });
636
    });
637

    
638
    // connected details js
639
    ui.detailsCustom($('#disk-connected'));
640
    ui.detailsCustom($('#network-connected'));
641
    ui.detailsCustom($('#vm-connected'));
642
    ui.firewallSetup();
643
    $('.firewall .more  a').click(function(e){
644
        e.preventDefault();
645
        if ($(this).find('span').hasClass('snf-radio-checked')) {
646
            return false;
647
        }
648
        $(this).parents('.firewall').removeAttr('data-firewall');
649
        $(this).parents('.firewall').data('firewall', $(this).parent().attr('class'));
650
        $(this).find('span').toggleClass('snf-radio-unchecked snf-radio-checked');
651
        $(this).parent('p').siblings('p').find('span').removeClass('snf-radio-checked');
652
        $(this).parent('p').siblings('p').find('span').addClass('snf-radio-unchecked');
653
         ui.firewallSetup();
654
    });
655
    $('.firewall').mouseenter(function(e){
656
        $(this).css('z-index',2);
657
        $(this).find('.more').stop(true, true).slideDown(200);
658
    });
659
    $('.firewall').mouseleave(function(e){
660
        $(this).css('z-index',1);
661
        $(this).find('.more').stop(true, true).slideUp(200);
662
    });
663
    ui.tabs($('.tabs'), $('.content'));
664
    ui.hashTabs($('.tabs'), $('.content'));
665

    
666
    $('.toggle-lt-bar').click(function(e){
667
        e.preventDefault();
668
        var self =this;
669
        if($(this).hasClass('fix-position')) {
670
            $(this).fadeOut({
671
                complete: function() {
672
                $(self).removeClass('fix-position');
673
                $(self).fadeIn();
674
                },
675
                start: function() {
676
                $('.lt-bar').animate({ width: 'toggle' });
677
                }
678
        });
679
        }
680
        else {
681
            $(this).addClass('fix-position');
682
            $('.lt-bar').animate({ width: 'toggle' });
683
        }
684
    });
685

    
686

    
687
    $('.act').click(function(e) {
688
        $(this).addClass('pending last');
689
    });
690

    
691
    $('.remove .cancel').click(function(e) {
692
        e.preventDefault();
693
        $('a.close-reveal-modal').trigger('click');
694
        $('.last').removeClass('pending last');
695
    });
696

    
697
    $('.remove .ok').click(function(e) {
698
        e.preventDefault();
699
        $('a.close-reveal-modal').trigger('click');
700
        var connection_img = $('.connections').find('.last');
701
        connection_img.addClass('open', 0);
702
        connection_img.removeClass('last');
703
        var img = connection_img.closest('.item').find('.img-wrap .snf-font');
704
        img.addClass('reboot-progress');
705
        setTimeout(function() {
706
            var connections_list = connection_img.closest('.connections').children('li:not(".hidden")');
707
            if(connections_list.length>1) {
708
                connection_img.closest('li').slideUp(function(){
709
                    connection_img.closest('li').addClass('hidden');
710
                    if(connections_list.find('.pending').length == 0) {
711
                      img.removeClass('reboot-progress');
712
                    }
713
                });
714
            }
715
            else {
716
                connection_img.closest('.item').slideUp(function(){
717
                    img.closest('li').addClass('hidden');
718
                    img.removeClass('reboot-progress');
719
                    img.removeClass('reboot-progress');
720
                });
721
            }
722
            connection_img.removeClass('pending');
723
        }, 3000)
724
    });
725
    // end of connected details js
726

    
727
    ui.replaceClass($('a.current, a.active'), 'outline', 'full');
728

    
729
    $('.delete').click(function(e) {
730
        e.preventDefault();
731
        $(this).closest('div').fadeOut('slow');
732
    })
733
})
734

    
735

    
736
$(window).resize(function(e){
737
    ui.setElminHeight($('.main > .details'));
738
    ui.setElminHeight($('.lt-bar'));
739
    ui.setElHeight($('.scroll-wrap'));
740
})