Statistics
| Branch: | Tag: | Revision:

root / snf-astakos-app / astakos / im / static / im / js / common.js @ c8977d75

History | View | Annotate | Download (5.7 kB)

1
function setContainerMinHeight( applicableDiv){
2
        
3
    if ( $(applicableDiv).length > 0 ) {
4
        //var h = $('.header').height(); div.header is not found 
5
        var f = $('.footer').height();
6
        var w = $(window).height();
7
        var pTop = parseInt (($(applicableDiv).css('padding-top').replace("px", "")) );
8
        var pBottom = parseInt (($(applicableDiv).css('padding-bottom').replace("px", "")));
9

    
10
        var c = w - ( f+pTop+pBottom+36);//36 is header's height.
11
        $(applicableDiv).css('min-height', c);
12
    }    
13

    
14
}
15

    
16

    
17
//equal heights
18
 
19
(function($) {
20
        $.fn.equalHeights = function(minHeight, maxHeight) {
21
                tallest = (minHeight) ? minHeight : 0;
22
                this.each(function() {
23
                        if($(this).height() > tallest) {
24
                                tallest = $(this).height();
25
                        }
26
                });
27
                if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
28
                return this.each(function() {
29
                        $(this).height(tallest);
30
                });
31
        }
32
})(jQuery);
33

    
34

    
35

    
36
// fix for iPhone - iPad orientation bug 
37
var metas = document.getElementsByTagName('meta');
38
function resetViewport() {
39
    var i;
40
    if (navigator.userAgent.match(/iPhone/i)) {
41
                  for (i=0; i<metas.length; i++) {
42
                    if (metas[i].name == "viewport") {
43
                              metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
44
                    }
45
                  }
46
          }
47
}
48
resetViewport();
49
    
50
window.onorientationchange = function() {
51
    resetViewport();
52
};
53
    
54
function gestureStart() {
55
  for (i=0; i<metas.length; i++) {
56
    if (metas[i].name == "viewport") {
57
      metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
58
    }
59
  }
60
}
61

    
62
if (navigator.userAgent.match(/iPhone/i)) {
63
        document.addEventListener("gesturestart", gestureStart, false);
64
}
65
//end of fix
66

    
67
$(document).ready(function() {
68
        
69
         
70
    setContainerMinHeight('.container .wrapper');
71
    
72
        
73
    $('.show-extra').click(function(e) {
74
        e.preventDefault();
75
        $(this).parents('.bg-wrap').find('.extra').slideToggle(600);
76
    });
77
    $('.hide-extra').click(function(e) {
78
        e.preventDefault();
79
        $(this).parents('.bg-wrap').find('.extra').slideUp(600);
80
    });
81
    
82
    $('.box-more p').click(function(e) {
83
        $(this).siblings('.clearfix').toggle('slow');
84
        $(this).parents('.box-more').toggleClass('border');
85
    });
86
        
87
        var fixTopMessageHeight = function() {
88
                var topMargin = parseInt($('.mainlogo img').height())+parseInt($('.top-msg').css('marginBottom'));
89
                $('.mainlogo').css('marginTop','-'+topMargin+'px');
90
        }
91
        
92
        if ($('.mainlogo img').length > 0) {
93
                $('.mainlogo img').bind('load', fixTopMessageHeight)
94
        } else {
95
                fixTopMessageHeight();
96
        }
97
        
98
        $('.top-msg a.close').click(function(e) {
99
                e.preventDefault();
100
        $('.top-msg').animate({
101
            paddingTop:'0',
102
            paddingBottom:'0',
103
            height:'0'
104
        }, 1000, function (){
105
             $('.top-msg').removeClass('active')
106
        });
107
        $('.mainlogo').animate({
108
            marginTop:'0'
109
        }, 1000, function (){
110
             //todo
111
        });
112
    });        
113
    
114
    
115
     
116
        $('select').dropkick();
117
 
118
    
119
    $('.top-msg .success').parents('.top-msg').css(
120
            {
121
                    backgroundColor: '#77C596',
122
                    color: '#fff'
123
            }
124
    );
125
    
126
    $('.top-msg .error').parents('.top-msg').css(
127
            {
128
                    backgroundColor: '#EF4F54',
129
                    color: '#fff'
130
            }
131
    );
132
    
133
    
134
    $('.top-msg .warning').parents('.top-msg').css(
135
            {
136
                    backgroundColor: '#F6921E',
137
                    color: '#fff'
138
            }
139
    );
140
    
141
    $('.top-msg .info').parents('.top-msg').css(
142
            {
143
                    backgroundColor: '#C3C3B9',
144
                    color: '#fff'
145
            }
146
    );
147
    
148
    // clouds homepage animation
149
    $('#animation a').hover(
150
      function () {
151
              
152
        $(this).animate({
153
           top: '+=-10'   
154
           }, 600, function() {
155
                   if ($(this).find('img').attr('src').indexOf("_top") == -1) {
156
                           var src = $(this).find('img').attr('src').replace('.png', '_top.png')
157
                        $(this).find('img').attr("src", src);
158
                   }
159

    
160
                });
161
        $(this).siblings('p').find('img').animate({
162
          width: '60%'       
163
        }, 600);
164
      }, 
165
      function () {
166

    
167
        $(this).animate({top: '0'}, 600, function() {
168
                var src = $(this).find('img').attr('src').replace('_top.png', '.png')
169
                       $(this).find('img').attr("src", src);
170
                });
171
        $(this).siblings('p').find('img').animate({
172
          width: '65%'       
173
        },600);
174
      }
175
    );
176
    
177
    
178
   
179
    
180
    
181
    if ($('.widjets'.length > 0)) {
182
                $('.widjets li div').equalHeights();
183
        }
184
    
185
    $(function() {
186
            if($("#id_issue_date").length > 0 ){
187
                        $( "#id_issue_date" ).datepicker({
188
                                defaultDate: "+0", 
189
                                dateFormat: "yy-mm-dd",
190
                                onSelect: function( selectedDate ) {
191
                                        $( "#id_expiration_date" ).datepicker( "option", "minDate", selectedDate );
192
                                }
193
                        });
194
                        $( "#id_expiration_date" ).datepicker({
195
                                defaultDate: "+1w", 
196
                                dateFormat: "yy-mm-dd",
197
                                onSelect: function( selectedDate ) {
198
                                        $( "#id_issue_date" ).datepicker( "option", "maxDate", selectedDate );
199
                                }
200
                        });
201
                }
202
        });
203
        
204
        
205
        $(".table_sorting").tablesorter(); 
206
        
207
        $('table .more-info').click(function(e){
208
                e.preventDefault();
209
                $(this).toggleClass('open');
210
                $(this).parents('tr').next('tr').toggle();
211
                check_table_info();
212
        })
213
        
214
        function check_table_info() {
215
           if ($('table .more-info').hasClass('open')){
216
                           $(this).text('[- Less Info]')
217
           } else {
218
                           $(this).text('[+ More Info]')
219
           }
220
        }
221
});
222

    
223
$(window).resize(function() {
224
    
225
   setContainerMinHeight('.container .wrapper');
226
   if ($('.widjets').length > 0) {
227
                $('.widjets  li div').equalHeights();
228
        }
229

    
230
});