Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (7.3 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
        $('select.dropkicked').dropkick({
116
                change: function (value, label) {
117
                    $(this).parents('form').submit();
118
                    
119
                }
120
        });
121
        
122
        $('.with-info select').attr('tabindex','1');
123
    $('.with-info select').dropkick();
124
    
125
    $('.top-msg .success').parents('.top-msg').addClass('success');
126
    $('.top-msg .error').parents('.top-msg').addClass('error');
127
    $('.top-msg .warning').parents('.top-msg').addClass('warning');
128
    $('.top-msg .info').parents('.top-msg').addClass('info');
129
    
130
    // clouds homepage animation
131
    $('#animation a').hover(
132
      function () {
133
              
134
        $(this).animate({
135
           top: '+=-10'   
136
           }, 600, function() {
137
                   if ($(this).find('img').attr('src').indexOf("_top") == -1) {
138
                           var src = $(this).find('img').attr('src').replace('.png', '_top.png')
139
                        $(this).find('img').attr("src", src);
140
                   }
141

    
142
                });
143
        $(this).siblings('p').find('img').animate({
144
          width: '60%'       
145
        }, 600);
146
      }, 
147
      function () {
148

    
149
        $(this).animate({top: '0'}, 600, function() {
150
                var src = $(this).find('img').attr('src').replace('_top.png', '.png')
151
                       $(this).find('img').attr("src", src);
152
                });
153
        $(this).siblings('p').find('img').animate({
154
          width: '65%'       
155
        },600);
156
      }
157
    );
158
    
159
    
160
    
161
    
162
    $(function() {                 
163
                $( "#id_start_date" ).datepicker({
164
                        minDate: 0,
165
                        defaultDate: "+0", 
166
            dateFormat: "yy-mm-dd",
167
            onSelect: function( selectedDate ) {
168
                $( "#id_end_date" ).datepicker( "option", "minDate", selectedDate );
169
            }
170
        });
171
        
172
        $( "#id_end_date" ).datepicker({
173
                defaultDate: "+3w", 
174
            dateFormat: "yy-mm-dd",
175
            onSelect: function( selectedDate ) {
176
                $( "#id_start_date" ).datepicker( "option", "maxDate", selectedDate );
177
            }
178
        });
179
        });
180
        
181
        
182
        $(".table_sorting").tablesorter(); 
183
        
184
        $('table .more-info').click(function(e){
185
                e.preventDefault();
186
                $(this).toggleClass('open');
187
                if ($(this).hasClass('open')){
188
                        $(this).html('- less info ')
189
                } else {
190
                        $(this).html('+ more info ')
191
                }
192
                $(this).parents('tr').next('tr').toggle();
193
                 
194
        });
195
        
196
        $('.projects .details .edit').click( function(e){
197
                e.preventDefault();
198
                $(this).parents('.details').children('.data').hide();
199
                $(this).parents('.details').children('.editable').slideDown(500, 'linear');
200
                $(this).hide();
201
        });
202
        
203
        $('.editable .form-row').each(function() {
204
                        if ( $(this).hasClass('with-errors') ){
205
                                $('.editable').show();
206
                                $('.projects .details a.edit, .projects .details .data').hide();
207
                                
208
                        }
209
                });
210
        
211
        $('.widjet-x').click(function(e){
212
                e.preventDefault();
213
                $(this).siblings('ul').hide('slow');
214
                $(this).hide();
215
        })
216

    
217
        
218
        
219
        
220
        
221
        $("input.leave, input.join").click(function () {
222
                $(this).parents('.msg-wrap').find('.dialog').show();
223
                return false;      
224
                
225
    });
226
    
227
     $('.msg-wrap .no').click( function(e){
228
                e.preventDefault();
229
                $(this).parents('.dialog').hide();
230
        })
231
    
232
    $('.msg-wrap .yes').click( function(e){
233
                e.preventDefault();
234
                $(this).parents('.dialog').siblings('form').submit();
235
        })
236
    
237
    $('.hidden-submit input[readonly!="True"]').focus(function () {
238
         $('.hidden-submit .form-row.submit').slideDown(500);
239
    });
240
    
241
    
242
    
243
     $('.auth_methods').find('li>a').click(function(e){
244
             e.preventDefault();
245
             $(this).siblings('.wrap').toggle('slow');
246
             $(this).toggleClass('up');
247
     });
248
     
249
     $('.auth_methods a.red').click(function(e){
250
             e.preventDefault();
251
             $(this).siblings('.dialog').show();
252
     })
253
     
254
      
255
     $('.auth_methods .dialog .no').click( function(e){         
256
             e.preventDefault();
257
             console.log($(this));
258
             $(this).parents('.dialog').hide();
259
     })
260
    
261
    setTimeout(function() {
262
      if ($('input#id_username').val()){ 
263
              $('input#id_username').siblings('label').css('opacity','0');
264
      };
265
      if ($('input#id_password').val()){ 
266
              $('input#id_password').siblings('label').css('opacity','0');
267
      }
268
        }, 100);
269
            
270
});
271
        
272
$(window).resize(function() {
273
    
274
   setContainerMinHeight('.container .wrapper');
275
    
276

    
277
});