Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (24.1 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
}
125

    
126

    
127
/*
128
* In order for the editable value functionality to work, the html markup
129
* should be:
130
    <div class="editable">
131
        <span class="input-txt">editable value</span>
132
        <input type="text">
133
        <a href="#" class="edit">edit</a>
134
        <a href="#" class="save">save</a>
135
        <a href="#" class="cancel">cancel</a>
136
    </div>
137
*/
138
ui.editable = function(){
139

    
140
/*
141
* resetForm hides save and cancel buttons,
142
* text input and shows input-txt. resetForm does not alter
143
* input-txt content.
144
*/
145

    
146
    function resetForm(e, elem) {
147
        var el = elem.parents('.editable');
148
        el.find('input[type="text"]').hide();
149
        el.find('a.cancel, a.save').hide();
150
        el.find('a.edit, .input-txt').show();
151
    }
152

    
153
/* 
154
* showForm hides input-txt, shows save and cancel buttons and
155
* sets input value to input-txt content.
156
*/
157
    function showForm(e,elem) {
158
        e.stopPropagation(); 
159
        e.preventDefault();
160
        var el = elem.parents('.editable'); 
161
        el.find('input[type="text"]').val(el.find('.input-txt').html());
162
        el.find('input[type="text"]').show();
163
        el.find('a.cancel, a.save').show();
164
        elem.hide();
165
        el.find('.input-txt').hide();
166
    }
167

    
168
/*
169
setValue sets input-txt value to the input value.
170
Makes sure that the input value is not empty.
171
TODO:
172
Ajax request to submit form
173
*/
174

    
175
    function setValue(elem) {
176
        var el = elem.parents('.editable');
177
        if( el.find('input[type="text"]').val() ) {
178
            el.find('.input-txt').html(el.find('input[type="text"]').val());
179
        }
180
    }
181

    
182

    
183
    $('.editable .edit').click(function(e){
184
        showForm(e, $(this));
185
    })
186

    
187
    $('.editable .cancel').click(function(e){
188
        e.stopPropagation();
189
        e.preventDefault();
190
        resetForm(e, $(this));
191
    })
192

    
193
    $('.editable .save').click(function(e){
194
        e.stopPropagation();
195
        e.preventDefault();
196
        setValue($(this));
197
        resetForm(e, $(this));
198

    
199
    })
200

    
201

    
202
    $('.editable input[type="text"]').click(function(e){
203
        e.stopPropagation();
204
    })
205

    
206
    $('.editable input[type="text"]').keyup(function(e){
207
        if(e.keyCode == 13) { 
208
            setValue($(this));
209
            resetForm(e, $(this));
210
            
211
        }
212
    
213
    })
214

    
215
    $('html').click(function(e) {
216
        resetForm(e, $('.editable a.cancel'));
217
    });
218

    
219
}
220

    
221
/* TODO: better overlay functionality */
222
ui.overlay = function() {
223
    $('[data-overlay-id]').click(function(e){
224
        e.preventDefault();
225
        var el = $(this);
226
        var id = '#'+el.data('overlay-id');
227

    
228
        $('.overlay-area-custom').fadeIn(100);
229
        $('body').addClass('with-overlay');
230
        $(id).fadeIn('slow');
231
        if (id=='#network-wizard') {
232
            $(id).find('input').first().focus();
233
            return false;
234
        }
235
        $(id).find('a').first().focus();
236
    });
237
}
238

    
239
function goToByScroll(id){
240
      // Remove "link" from the ID
241
    id = id.replace("link", "");
242
      // Scroll
243
    $('html,body').animate({
244
        scrollTop: $("#"+id).offset().top},
245
        'slow');
246
}
247

    
248

    
249
/*
250
* functions concerning checkboxes and radiobuttons links
251
*/
252

    
253
ui.changeCheckboxState =function(checkbox_link) {
254
    $(checkbox_link).find('.snf-checkbox-unchecked, .snf-checkbox-checked').toggleClass('snf-checkbox-unchecked snf-checkbox-checked');
255
    ui.entitiesActionsEnabled();
256
}
257

    
258
// to use the above functions use first the ui.checkOneRadioButton and then ui.changeRadiobuttonState
259
ui.checkOneRadioButton = function(radiobtn_link) {
260
    $(radiobtn_link).closest('ul').find('span.snf-radio-checked').toggleClass('snf-radio-unchecked snf-radio-checked');
261
}
262
ui.changeRadiobuttonState = function(radiobtn_link) {
263
    $(radiobtn_link).find('span.snf-radio-unchecked, span.snf-radio-checked').toggleClass('snf-radio-unchecked snf-radio-checked');
264
}
265

    
266

    
267

    
268
// toggle expand arrrow  and corresponding area
269
// todo: one function for all the areas we reveal
270
ui.expandDownArea = function(arrow_link, area) {
271
    var arrow_link = $(arrow_link);
272
    var area = $(area);
273
            arrow_link.find('span.snf-arrow-up, span.snf-arrow-down').toggleClass('snf-arrow-up snf-arrow-down');
274
            // $('.wizard-content').removeAttr('style');
275
            area.stop().slideToggle(600, function() {
276
                if (area.is(':visible')) {
277
                    arrow_link.find('.snf-arrow-down .snf-arrow-up').removeClass('snf-arrow-down').addClass('snf-arrow-up');
278
                } else {
279
                    arrow_link.find('.snf-arrow-down .snf-arrow-up').addClass('snf-arrow-down');
280
                }
281

    
282
            });
283
}
284

    
285

    
286
/* Tabs functionality
287
* tabsEl is the div/ul with the links to the sections and the sections that
288
* with toggle have class sectionEl.
289
* Markup needed is an href to each a with the id of the relative section.
290
*/
291

    
292
ui.tabsSection = function(link, sectionEl) {
293
    sectionEl.hide();
294
    var el = $(link.attr('href'));
295
    el.stop(true, true).show(0);
296
    el.css('opacity',0);
297
    ui.detailsCustom(el);
298
    el.animate({
299
        'opacity':1,
300
    }, 500)
301
}
302

    
303
ui.tabs = function(tabsEl, sectionEl) {
304
    var tabLink = tabsEl.find('a');
305
    ui.replaceClass(tabLink.find('.active'), 'outline', 'full');
306
    function href(a) {
307
        return a.attr('href');
308
    }
309
    tabLink.click(function(e){
310
        e.preventDefault();
311
        if ( $(this).hasClass('active')){
312
             return false;
313
        } else {
314
            window.location.hash = $(this).attr('href');
315
            ui.replaceClass($(this).parents(tabsEl).find('.active'), 'full', 'outline');
316
            $(this).parents(tabsEl).find('a').removeClass('active');
317
            $(this).addClass('active');
318
            ui.replaceClass($(this), 'outline', 'full');
319
            ui.tabsSection( $(this), sectionEl);
320
        }
321
    })
322
}
323

    
324
// the function replaces part of the class of a span that is placed inside an a element
325
ui.replaceClass = function(elements, str1, str2) {
326
    $.each($(elements), function() {
327
        classOld = $(this).find('span').attr('class');
328
        if(classOld != undefined && classOld.indexOf(str1) != -1) {
329
            var classNew =classOld.replace(str1, str2);
330
            if(classOld.indexOf(' ') == -1) {
331
                $(this).find('.'+classOld).removeClass(classOld).addClass(classNew);
332
            }
333
            else {
334
                var classToReplace;
335
                if(classOld.indexOf(' ') > classOld.indexOf(str1)) {
336
                    classToReplace = classOld.substring(0,classOld.indexOf(' '));
337

    
338
                }
339
                else {
340

    
341
                    classToReplace = classOld.substring(classOld.indexOf(' ')+1, classOld.indexOf(str1)+str1.length);
342
                }
343

    
344
                if($(this).find('.'+classToReplace).hasClass(classOld)) {
345
                    console.log('classToReplace ', classToReplace)
346
                       $(this).find('.'+classToReplace).removeClass(classToReplace).addClass(classNew);
347
                }
348
            }
349
        }
350
    });
351
}
352

    
353
// in a page with tabs, allow navigation with hash tags
354
ui.hashTabs = function(tabsEl, sectionEl){
355
    var hash = window.location.hash;
356
    if ($(hash).length<=0){
357
        return;
358
    }
359
    tabsEl.find('a').removeClass('active');
360
    var link = tabsEl.find('a[href="'+hash+'"]');
361
    link.addClass('active');
362
    ui.tabsSection(link, sectionEl);
363

    
364
}
365

    
366
ui.ltBarToggle = function(speed){
367

    
368
    var cmarg = parseInt($('.lt-bar').width()) - parseInt($('.toggle-lt-bar').outerWidth(true));        
369
    var ctemp = cmarg / parseInt($('.lt-bar').width());
370
    var cvelocity = parseInt($('.lt-bar').width())/speed;
371
    var cdelay = parseInt($('.toggle-lt-bar').outerWidth(true))/cvelocity;
372

    
373
    $('.lt-bar').click(function(e) {
374
        e.stopPropagation();
375
    })
376
    $('.toggle-lt-bar').click(function(e){
377
        e.preventDefault();
378
        e.stopPropagation();
379
        var self =this;
380
        if($(this).hasClass('fix-position')) {
381
            var marg = parseInt($(self).css('marginLeft')) - cmarg;
382
            $(this).animate({
383
                'margin-left': marg,
384
            }, ctemp * speed, 'linear', function(){
385
                $(self).removeAttr('style');
386
                $(self).removeClass('fix-position');
387
            });
388
            $('.lt-bar').animate({
389
                width: 'toggle'
390
            }, speed, 'linear');
391
        }
392
        else {
393
            $(this).addClass('fix-position');
394
            var marg = parseInt($(self).css('marginLeft')) + cmarg;
395
            setTimeout(function(){
396
                $(self).animate({
397
                    'margin-left': marg,
398
                }, speed, 'linear')
399
            }, cdelay);
400
            $('.lt-bar').animate({
401
                width: 'toggle'
402
            }, speed, 'linear');
403
        }
404
    });
405
}
406

    
407

    
408
$(document).ready(function(){
409

    
410
    $('html').click(function(e) {
411
        // not sure if we want to hide the error window after every click in the ui
412
        if($('.communication-error').css('bottom') == '0px') {
413
            $('.communication-error').animate({bottom: "-151px"});
414
        }
415
        if($('.details .lt-bar').is(':visible')) {
416
            $('.toggle-lt-bar').trigger('click');
417
        }
418
    });
419

    
420
    if($('.vms.entities').length!=0){
421
        ui.inactiveActions();
422
    };
423
    ui.setElminHeight($('.main > .details'));
424
    ui.setElminHeight($('.lt-bar'));
425
    ui.setElHeight($('.scroll-wrap'));
426
    $('#hd-search .hd-icon-search').click(function(e){
427
        var that = this;
428
        $(this).parents('.hd-search').toggleClass('hd-open');
429
        if ($(this).parents('.hd-search').hasClass('hd-open')) {
430
            $(that).parents('.hd-search').find('input[type="search"]').focus();
431
        } else {
432
            $(that).parents('.hd-search').find('input[type="search"]').val('');
433
        }
434
    })
435

    
436
    $('.header .login').mouseenter(function(e){
437
        $(this).find('ul').stop(true, true).slideDown(200);
438
    });
439
    $('.header .login').mouseleave(function(e){
440
        $(this).find('ul').stop(true, true).slideUp(200);
441
    });
442

    
443
    $('.entities a').click(function(){
444
        if ($(this).attr('data-reveal-id') && !($(this).hasClass('inactive'))) {
445
            $('.entities li .more').hide();
446
        }
447
    });
448

    
449
    $('.inactive').click(function(e){
450
        e.stopPropagation();
451
        e.preventDefault();
452
     })
453

    
454

    
455
    $('.lt-actions a:not(.active)').click(function(e){
456
        e.preventDefault();
457
    })
458

    
459
    if ($('.entities .items-list >li').length == 1) {
460
        $('.overlay-wrapper').addClass('no-vm');
461
    };
462
    $('.entities li .more').each(function(){
463
        var width = $(this).parent('li').outerWidth()  + 20;
464
        $(this).css('width', width);
465
    });
466

    
467
    $('.items-list li .img-wrap').on("mouseenter", function(e) {
468
        var that = this;
469
        if ($(this).parents('.entities').hasClass('grid-view')) {
470
            if ($(that).parent('.container').siblings('.more').length>0) {
471
                $(that).parent('.container').fadeOut(50,'easeInCirc');
472
                $(that).parent('.container').siblings('.more').fadeIn(150,'easeInCirc');
473
            }
474
        }
475
    });
476
    $('.entities li .more').mouseleave(function(e) {
477
        $(this).fadeOut(50, function() {
478
            $(this).siblings('.container').fadeIn(50);
479
        });
480
    });
481
    $('.grid-view .items-list > li').mouseleave(function(e){
482
        var that = this;
483
        setTimeout(function(){
484
            $(that).find('.more').fadeOut(200, function() {
485
                $(this).siblings('.container').fadeIn('fast');
486
            });
487
        },50)
488
    });
489

    
490
    ui.closeDiv($('.info .close'), '.info');
491
    ui.editable();
492
    ui.overlay();
493
    ui.colorPickerVisible = 0;
494

    
495
    $("a.disabled").each(function() {
496
        $(this).removeAttr('href');
497
    });
498
    
499
    $("a.disabled").click(function(e) {
500
        e.preventDefault();
501
    });
502

    
503
    // checkbox: basic reaction on click (checked, unchecked)
504
    // see wizard
505
    $('.check').click(function(e){
506
        e.preventDefault();
507
        e.stopPropagation();
508
        ui.changeCheckboxState(this);
509
    });
510

    
511

    
512
    $('.with-checkbox').click(function(e){
513
        e.preventDefault();
514
        e.stopPropagation();
515
        var checkbox = self.find('.check');
516
        ui.changeCheckboxState(checkbox);
517
    });
518

    
519
    $('.radio_btn').click(function(e) {
520
        e.preventDefault();
521
         var state = $(this).find('span');
522
         if(state.hasClass('snf-radio-unchecked')) {
523
            ui.checkOneRadioButton(this);
524
            ui.changeRadiobuttonState(this);
525
        }
526
    });
527

    
528
    $('.main-actions li a').click(function(e){
529
        if (!($(this).hasClass('active'))) {
530
            e.preventDefault();
531
        }
532
    });
533

    
534
    $('.main-actions li a').click(function(e){
535
        if (!($(this).hasClass('active'))) {
536
            e.preventDefault();
537
        }
538
    });
539
    $('.overlay-area-custom').children('.close').click(function(e){
540
        e.preventDefault();
541
        e.stopPropagation();
542
        $(this).parents('.overlay-area-custom').hide();
543
        $(this).parents('.overlay-area-custom').find($('.overlay-div')).hide();
544
        $('body').removeClass('with-overlay');
545
    })
546

    
547
    $('.browse-files').click(function(e){
548
        e.preventDefault();
549
    })
550

    
551
    Dropzone.options.filesDropzone = {
552
        dictDefaultMessage:'',
553
        clickable: '.browse-files',
554
        previewsContainer: '.dropzone-files',
555
        createImageThumbnails: false,
556
        dictRemoveFile: "snf-Remove file",
557
    };
558

    
559

    
560
    $('.main .files').magnificPopup({
561
        delegate: 'a.show.image',
562
        type: 'image',
563
        tLoading: 'Loading image #%curr%...',
564
        mainClass: 'mfp-img-mobile',
565
        gallery: {
566
            enabled: true,
567
            navigateByImgClick: true,
568
            preload: [0,1] // Will preload 0 - before current, and 1 after the current image
569
        },
570
        image: {
571
            tError: 'The image could not be loaded.',
572
            titleSrc: function(item) {
573
                return item.el.data('title');
574
            }
575
        }
576
    });
577

    
578
    if($('#picker').length>0) {
579
        $('#picker').farbtastic('#color');
580
    };
581
    if($('#sb-search').length>0) {
582
        new UISearch( document.getElementById( 'sb-search' ) );
583
    }
584

    
585
    if ($('.toggle-lt-bar').length>0) {
586
        ui.ltBarToggle(400);
587
    }
588

    
589
    /* grid/list view for items-list */
590

    
591
    $('.view-type .list').click(function(e){
592
        e.preventDefault();
593
        $('.view-type .grid span').removeClass('current');
594
        $(this).find('span').addClass('current');
595
        $('.entities').removeClass('grid-view');
596
        $('.entities').addClass('list-view');
597
    });
598

    
599
     $('.view-type .grid').click(function(e){
600
        e.preventDefault();
601
        $('.view-type .list span').removeClass('current');
602
        $(this).find('span').addClass('current');
603
        $('.entities').addClass('grid-view');
604
        $('.entities').removeClass('list-view');
605
    });
606

    
607
     $('.lt-bar .select').click(function(e){
608
        $(this).find('span').toggleClass('snf-checkbox-checked snf-checkbox-unchecked');
609
        $(this).find('em').toggle();
610
        if ( $(this).find('span').hasClass('snf-checkbox-unchecked')){
611
            $('.list-view  li .check span').removeClass('snf-checkbox-checked');
612
            $('.list-view  li .check span').addClass('snf-checkbox-unchecked');
613
        } else {
614
            $('.list-view  li .check span').addClass('snf-checkbox-checked');
615
            $('.list-view  li .check span').removeClass('snf-checkbox-unchecked');
616
        }
617
        ui.entitiesActionsEnabled();
618
     });
619

    
620
    // set filter visible
621
    $('.filter-menu .filter').click(function(e) {
622
        e.preventDefault();
623
        $(this).parents('.filter-menu').toggleClass('current');
624
    });
625

    
626
    // temp function used to demonstrate the visual effect of the building state of vm
627
    $('[data-status="building"] .btn5.temp').click(function(e) {
628
        e.preventDefault();
629
        $(this).siblings('.container').find('.complete').toggleClass('build-progress');
630
    });
631

    
632
    $('[data-status="rebooting"] .btn5.temp').click(function(e) {
633
        e.preventDefault();
634
        $(this).siblings('.container').find('.snf-pc-full').toggleClass('reboot-progress');
635
    })
636

    
637
    // //temp function to preventDefault of links in modal
638
    // $('.reveal-modal a:not(".close-reveal-modal, .generate-key-btn, .import-key-btn")').click(function(e){
639
    //     e.preventDefault();
640
    //     $('a.close-reveal-modal').trigger('click');
641
    // });
642

    
643
     // temp btn to show communication error message
644
    $('.temp-for-btns .communication-error-btn').click(function(e) {
645
         e.preventDefault();
646
         e.stopPropagation();
647
         $('.communication-error').animate({bottom: "0px"});
648
     });
649

    
650
    $('.communication-error a').click(function(e) {
651
        e.preventDefault();
652
        e.stopPropagation();
653
        $('.communication-error').animate({bottom: "-151px"});
654

    
655
    });
656
    $('.communication-error').click(function(e) {
657
        e.stopPropagation();
658
    });
659

    
660
    $('.show-add-tag').click(function(e) {
661
    e.preventDefault();
662
    $(this).parents('.tags-area, .tags').find('.snf-color-picker').slideDown('slow', function() {
663
        $('#hide-add-tag-dummy').scrollintoview({
664
            'duration': 'slow'
665
        });
666
    });
667
    ui.colorPickerVisible = 1;
668
    });
669

    
670
    $('.hide-add-tag').click(function(e) {
671
    e.preventDefault();
672
    $(this).parents('.tags-area, .tags').find('.snf-color-picker').slideUp(400, function() {
673
        $('.show-add-tag').first().scrollintoview({
674
            'duration': 'slow'
675
        });
676
        ui.colorPickerVisible = 0;
677
    });
678
    });
679

    
680
    // connected details js
681
    ui.detailsCustom($('#disk-connected'));
682
    ui.detailsCustom($('#network-connected'));
683
    ui.detailsCustom($('#vm-connected'));
684
    ui.firewallSetup();
685
    $('.firewall .more  a').click(function(e){
686
        e.preventDefault();
687
        if ($(this).find('span').hasClass('snf-radio-checked')) {
688
            return false;
689
        }
690
        $(this).parents('.firewall').removeAttr('data-firewall');
691
        $(this).parents('.firewall').data('firewall', $(this).parent().attr('class'));
692
        $(this).find('span').toggleClass('snf-radio-unchecked snf-radio-checked');
693
        $(this).parent('p').siblings('p').find('span').removeClass('snf-radio-checked');
694
        $(this).parent('p').siblings('p').find('span').addClass('snf-radio-unchecked');
695
         ui.firewallSetup();
696
    });
697
    $('.firewall').mouseenter(function(e){
698
        $(this).css('z-index',2);
699
        $(this).find('.more').stop(true, true).slideDown(200);
700
    });
701
    $('.firewall').mouseleave(function(e){
702
        $(this).css('z-index',1);
703
        $(this).find('.more').stop(true, true).slideUp(200);
704
    });
705
    ui.tabs($('.tabs'), $('.content'));
706
    ui.hashTabs($('.tabs'), $('.content'));
707

    
708
    $('.act').click(function(e) {
709
        $(this).addClass('pending last');
710
    });
711

    
712
    $('.remove .cancel').click(function(e) {
713
        e.preventDefault();
714
        $('a.close-reveal-modal').trigger('click');
715
        $('.last').removeClass('pending last');
716
    });
717

    
718
    $('.remove .ok').click(function(e) {
719
        e.preventDefault();
720
        $('a.close-reveal-modal').trigger('click');
721
        var connection_img = $('.connections').find('.last');
722
        connection_img.addClass('open', 0);
723
        connection_img.removeClass('last');
724
        var img = connection_img.closest('.item').find('.img-wrap .snf-font');
725
        img.addClass('reboot-progress');
726
        setTimeout(function() {
727
            var connections_list = connection_img.closest('.connections').children('li:not(".hidden")');
728
            if(connections_list.length>1) {
729
                connection_img.closest('li').slideUp(function(){
730
                    connection_img.closest('li').addClass('hidden');
731
                    if(connections_list.find('.pending').length == 0) {
732
                      img.removeClass('reboot-progress');
733
                    }
734
                });
735
            }
736
            else {
737
                connection_img.closest('.item').slideUp(function(){
738
                    img.closest('li').addClass('hidden');
739
                    img.removeClass('reboot-progress');
740
                    img.removeClass('reboot-progress');
741
                });
742
            }
743
            connection_img.removeClass('pending');
744
        }, 3000)
745
    });
746
    // end of connected details js
747

    
748
    ui.replaceClass($('a.current, a.active'), 'outline', 'full');
749

    
750
    // with the function below the sidebar in detailed views
751
    // will not hide if we click something in a wizard
752
    $('.wizard').click(function(e) {
753
        e.stopPropagation();
754
    })
755

    
756
    $('.tag-data').mouseover(function() {
757
        $(this).find('.delete').css({visibility: 'visible'})
758
    });
759
    $('.tag-data').mouseleave(function(){
760
        $(this).find('.delete').css({visibility: 'hidden'})
761
    });
762
    $('.delete').click(function(e) {
763
        e.preventDefault();
764
        $(this).closest('div').fadeOut('slow');
765
    });
766
})
767

    
768

    
769
$(window).resize(function(e){
770
    ui.setElminHeight($('.main > .details'));
771
    ui.setElminHeight($('.lt-bar'));
772
    ui.setElHeight($('.scroll-wrap'));
773
})