Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (5.6 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
    //$('.dropkick-select').dropkick();
114
    
115
 
116
    
117
    $('.top-msg .success').parents('.top-msg').css(
118
            {
119
                    backgroundColor: '#77C596',
120
                    color: '#fff'
121
            }
122
    );
123
    
124
    $('.top-msg .error').parents('.top-msg').css(
125
            {
126
                    backgroundColor: '#EF4F54',
127
                    color: '#fff'
128
            }
129
    );
130
    
131
    
132
    $('.top-msg .warning').parents('.top-msg').css(
133
            {
134
                    backgroundColor: '#F6921E',
135
                    color: '#fff'
136
            }
137
    );
138
    
139
    $('.top-msg .info').parents('.top-msg').css(
140
            {
141
                    backgroundColor: '#C3C3B9',
142
                    color: '#fff'
143
            }
144
    );
145
    
146
    // clouds homepage animation
147
    $('#animation a').hover(
148
      function () {
149
              
150
        $(this).animate({
151
           top: '+=-10'   
152
           }, 600, function() {
153
                   if ($(this).find('img').attr('src').indexOf("_top") == -1) {
154
                           var src = $(this).find('img').attr('src').replace('.png', '_top.png')
155
                        $(this).find('img').attr("src", src);
156
                   }
157

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

    
165
        $(this).animate({top: '0'}, 600, function() {
166
                var src = $(this).find('img').attr('src').replace('_top.png', '.png')
167
                       $(this).find('img').attr("src", src);
168
                });
169
        $(this).siblings('p').find('img').animate({
170
          width: '65%'       
171
        },600);
172
      }
173
    );
174
    
175
    
176
    /*$('#animation a').hover(
177
      function () {
178
              
179
        $(this).animate({
180
           top: '+=-10'   
181
           }, 600);
182
        $(this).siblings('p').find('img').animate({
183
          width: '60%'       
184
        });
185
      }, 
186
      function () {
187

188
        $(this).animate({top: '0'}, 600);
189
        $(this).siblings('p').find('img').animate({
190
          width: '65%'       
191
        });
192
      }
193
    );*/
194
    
195
    
196
    if ($('.widjets'.length > 0)) {
197
                $('.widjets li div').equalHeights();
198
        }
199
    
200
    $(function() {
201
            if($("#from").length > 0 ){
202
                        $( "#from" ).datepicker({
203
                                defaultDate: "+0", 
204
                                dateFormat: "dd-mm-yy",
205
                                onSelect: function( selectedDate ) {
206
                                        $( "#to" ).datepicker( "option", "minDate", selectedDate );
207
                                }
208
                        });
209
                        $( "#to" ).datepicker({
210
                                defaultDate: "+1w", 
211
                                dateFormat: "dd-mm-yy",
212
                                onSelect: function( selectedDate ) {
213
                                        $( "#from" ).datepicker( "option", "maxDate", selectedDate );
214
                                }
215
                        });
216
                }
217
        });
218
});
219

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

    
227
});
228

    
229

    
230

    
231

    
232
 
233

    
234