Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (5.5 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').addClass('success');
120
    $('.top-msg .error').parents('.top-msg').addClass('error');
121
    $('.top-msg .warning').parents('.top-msg').addClass('warning');
122
    $('.top-msg .info').parents('.top-msg').addClass('info');
123
    
124
    // clouds homepage animation
125
    $('#animation a').hover(
126
      function () {
127
              
128
        $(this).animate({
129
           top: '+=-10'   
130
           }, 600, function() {
131
                   if ($(this).find('img').attr('src').indexOf("_top") == -1) {
132
                           var src = $(this).find('img').attr('src').replace('.png', '_top.png')
133
                        $(this).find('img').attr("src", src);
134
                   }
135

    
136
                });
137
        $(this).siblings('p').find('img').animate({
138
          width: '60%'       
139
        }, 600);
140
      }, 
141
      function () {
142

    
143
        $(this).animate({top: '0'}, 600, function() {
144
                var src = $(this).find('img').attr('src').replace('_top.png', '.png')
145
                       $(this).find('img').attr("src", src);
146
                });
147
        $(this).siblings('p').find('img').animate({
148
          width: '65%'       
149
        },600);
150
      }
151
    );
152
    
153
    
154
   
155
    
156
    
157
    if ($('.widjets'.length > 0)) {
158
                $('.widjets li div').equalHeights();
159
        }
160
    
161
    $(function() {
162
            if($("#id_issue_date").length > 0 ){
163
                        $( "#id_issue_date" ).datepicker({
164
                                defaultDate: "+0", 
165
                                dateFormat: "yy-mm-dd",
166
                                onSelect: function( selectedDate ) {
167
                                        $( "#id_expiration_date" ).datepicker( "option", "minDate", selectedDate );
168
                                }
169
                        });
170
                        $( "#id_expiration_date" ).datepicker({
171
                                defaultDate: "+1w", 
172
                                dateFormat: "yy-mm-dd",
173
                                onSelect: function( selectedDate ) {
174
                                        $( "#id_issue_date" ).datepicker( "option", "maxDate", selectedDate );
175
                                }
176
                        });
177
                }
178
        });
179
        
180
        
181
        $(".table_sorting").tablesorter(); 
182
        
183
        $('table .more-info').click(function(e){
184
                e.preventDefault();
185
                $(this).toggleClass('open');
186
                $(this).parents('tr').next('tr').toggle();
187
                 
188
        });
189
        
190
        $('.projects .details .edit').click( function(e){
191
                e.preventDefault();
192
                $(this).parents('.details').children('.data').hide();
193
                $(this).parents('.details').children('.editable').show();
194
                $(this).hide();
195
        })
196
        
197
        
198
        $('.widjet-x').click(function(e){
199
                e.preventDefault();
200
                $(this).siblings('ul').hide('slow');
201
                $(this).hide();
202
        })
203
        
204
});
205

    
206
$(window).resize(function() {
207
    
208
   setContainerMinHeight('.container .wrapper');
209
   if ($('.widjets').length > 0) {
210
                $('.widjets  li div').equalHeights();
211
        }
212

    
213
});