Statistics
| Branch: | Tag: | Revision:

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

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

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

    
146
        $(this).animate({top: '0'}, 600, function() {
147
                var src = $(this).find('img').attr('src').replace('_top.png', '.png')
148
                       $(this).find('img').attr("src", src);
149
                });
150
        $(this).siblings('p').find('img').animate({
151
          width: '65%'       
152
        },600);
153
      }
154
    );
155
    
156
    
157
   
158
    
159
    
160
    //if ($('.widjets'.length > 0)) {
161
                ///$('.widjets li div').equalHeights();
162
        ///}
163
    
164
    $(function() {
165
            if($("#id_issue_date").length > 0 ){
166
                        $( "#id_issue_date" ).datepicker({
167
                                defaultDate: "+0", 
168
                                dateFormat: "yy-mm-dd",
169
                                onSelect: function( selectedDate ) {
170
                                        $( "#id_expiration_date" ).datepicker( "option", "minDate", selectedDate );
171
                                }
172
                        });
173
                        $( "#id_expiration_date" ).datepicker({
174
                                defaultDate: "+1w", 
175
                                dateFormat: "yy-mm-dd",
176
                                onSelect: function( selectedDate ) {
177
                                        $( "#id_issue_date" ).datepicker( "option", "maxDate", selectedDate );
178
                                }
179
                        });
180
                }
181
                
182
                if($("#id_issue_date_demo").length > 0 ){
183
                        $( "#id_issue_date_demo" ).datepicker({
184
                                defaultDate: "+0", 
185
                                dateFormat: "yy-mm-dd",
186
                                onSelect: function( selectedDate ) {
187
                                        $( "#id_expiration_date_demo" ).datepicker( "option", "minDate", selectedDate );
188
                                }
189
                        });
190
                        $( "#id_expiration_date_demo" ).datepicker({
191
                                defaultDate: "+1w", 
192
                                dateFormat: "yy-mm-dd",
193
                                onSelect: function( selectedDate ) {
194
                                        $( "#id_issue_date_demo" ).datepicker( "option", "maxDate", selectedDate );
195
                                }
196
                        });
197
                }
198
                $( "#id_start_date" ).datepicker({
199
            dateFormat: "yy-mm-dd",
200
            onSelect: function( selectedDate ) {
201
                $( "#id_start_date" ).datepicker( "option", "maxDate", selectedDate );
202
            }
203
        });
204
        
205
        $( "#id_end_date" ).datepicker({
206
            dateFormat: "yy-mm-dd",
207
            onSelect: function( selectedDate ) {
208
                $( "#id_end_date" ).datepicker( "option", "maxDate", selectedDate );
209
            }
210
        });
211
        });
212
        
213
        
214
        $(".table_sorting").tablesorter(); 
215
        
216
        $('table .more-info').click(function(e){
217
                e.preventDefault();
218
                $(this).toggleClass('open');
219
                if ($(this).hasClass('open')){
220
                        $(this).html('- less info ')
221
                } else {
222
                        $(this).html('+ more info ')
223
                }
224
                $(this).parents('tr').next('tr').toggle();
225
                 
226
        });
227
        
228
        $('.projects .details .edit').click( function(e){
229
                e.preventDefault();
230
                $(this).parents('.details').children('.data').hide();
231
                $(this).parents('.details').children('.editable').show();
232
                $(this).hide();
233
        });
234
        
235
        
236
        $('.widjet-x').click(function(e){
237
                e.preventDefault();
238
                $(this).siblings('ul').hide('slow');
239
                $(this).hide();
240
        })
241

    
242
        // todo den doulevei
243
        $('#group_create_form').submit(function(){
244
                if ($('.quotas-form .group .form-row.with-errors').length>0 ){
245
                        return false;
246
                }
247
                var flag = 0;
248
                $('.quotas-form .group input[type="text"]').each(function() {
249
                        // get value from input
250
                         var value = $(this).val();
251
                        if (value){
252
                                flag =1;
253
                        }
254
                });
255
                if (flag =='0') {
256
                        $('#icons span.info').addClass('error-msg');
257
                        return false;
258
                        
259
                }
260
        });
261
        
262
        
263
        
264
        $("input.leave, input.join").click(function () {
265
                $(this).parents('.msg-wrap').find('.dialog').show();
266
                return false;      
267
                
268
    });
269
    
270
     $('.msg-wrap .no').click( function(e){
271
                e.preventDefault();
272
                $(this).parents('.dialog').hide();
273
        })
274
    
275
    $('.msg-wrap .yes').click( function(e){
276
                e.preventDefault();
277
                $(this).parents('.dialog').siblings('form').submit();
278
        })
279
    
280
    
281
});
282
        
283
$(window).resize(function() {
284
    
285
   setContainerMinHeight('.container .wrapper');
286
   ///if ($('.widjets').length > 0) {
287
                //$('.widjets  li div').equalHeights();
288
        //}
289

    
290
});