summaryrefslogtreecommitdiff
path: root/templates/assets/js/hipster-cards.js
blob: f74de6bac051fd553f7958c06ef83d746121673b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$(document).ready(function(){
    window_width = $(window).width();
        
    // Make the images from the card fill the hole space
    hipster_cards.fitBackgroundForCards();
      
});

hipster_cards = {
    misc:{
        navbar_menu_visible: 0
    },
    
    fitBackgroundForCards: function(){
        $('[data-background="image"]').each(function(){
            $this = $(this);
                        
            background_src = $this.data("src");                                
            
            if(background_src != "undefined"){                
                new_css = {
                    "background-image": "url('" + background_src + "')",
                    "background-position": "center center",
                    "background-size": "cover"
                };
                
                $this.css(new_css);                
            }              
        });
        
        $('.card .header img').each(function(){
            $card = $(this).parent().parent();
            $header = $(this).parent();
                        
            background_src = $(this).attr("src");                                
            
            if(background_src != "undefined"){                
                new_css = {
                    "background-image": "url('" + background_src + "')",
                    "background-position": "center center",
                    "background-size": "cover"
                };
                
                $header.css(new_css);                
            }              
        });
        
    },   
}