Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (9 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
function tableFixedCols(table, firstColWidth ){
17
        ColsNum = $('table th').size();
18
        var ColWidth = parseFloat( (100 - firstColWidth)/ColsNum ).toFixed(0);
19
        var ColWidthPercentage = ColWidth+'%';
20
        var firstColWidthPercentage = firstColWidth+'%';
21
        $('table th, table td').attr('width',ColWidthPercentage ); 
22
        $('table tr td:first-child, table tr th:first-child').attr('width',firstColWidthPercentage );
23
        
24
}
25

    
26
function addClassHover(hoverEl, applicableEl){ 
27
        $(hoverEl).hover(
28
      function () {
29
               
30
         $(applicableEl).addClass('red-border')
31
      }, 
32
      function () {
33
              $(applicableEl).removeClass('red-border');
34
    
35
    });
36
}
37
//equal heights
38
 
39
(function($) {
40
        $.fn.equalHeights = function(minHeight, maxHeight) {
41
                tallest = (minHeight) ? minHeight : 0;
42
                this.each(function() {
43
                        if($(this).height() > tallest) {
44
                                tallest = $(this).height();
45
                        }
46
                });
47
                if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
48
                return this.each(function() {
49
                        $(this).height(tallest);
50
                });
51
        }
52
})(jQuery);
53

    
54

    
55

    
56
// fix for iPhone - iPad orientation bug 
57
var metas = document.getElementsByTagName('meta');
58
function resetViewport() {
59
    var i;
60
    if (navigator.userAgent.match(/iPhone/i)) {
61
                  for (i=0; i<metas.length; i++) {
62
                    if (metas[i].name == "viewport") {
63
                              metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
64
                    }
65
                  }
66
          }
67
}
68
resetViewport();
69
    
70
window.onorientationchange = function() {
71
    resetViewport();
72
};
73
    
74
function gestureStart() {
75
  for (i=0; i<metas.length; i++) {
76
    if (metas[i].name == "viewport") {
77
      metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
78
    }
79
  }
80
}
81

    
82
if (navigator.userAgent.match(/iPhone/i)) {
83
        document.addEventListener("gesturestart", gestureStart, false);
84
}
85
//end of fix
86

    
87
 
88
$(document).ready(function() {
89
        
90
         
91
    setContainerMinHeight('.container .wrapper');
92
    tableFixedCols('my-projects', 25);
93
        
94
    $('.show-extra').click(function(e) {
95
        e.preventDefault();
96
        $(this).parents('.bg-wrap').find('.extra').slideToggle(600);
97
    });
98
    $('.hide-extra').click(function(e) {
99
        e.preventDefault();
100
        $(this).parents('.bg-wrap').find('.extra').slideUp(600);
101
    });
102
    
103
    $('.box-more p').click(function(e) {
104
        $(this).siblings('.clearfix').toggle('slow');
105
        $(this).parents('.box-more').toggleClass('border');
106
    });
107
        
108
        var fixTopMessageHeight = function() {
109
                var topMargin = parseInt($('.mainlogo img').height())+parseInt($('.top-msg').css('marginBottom'));
110
                $('.mainlogo').css('marginTop','-'+topMargin+'px');
111
        }
112
        
113
        if ($('.mainlogo img').length > 0) {
114
                $('.mainlogo img').bind('load', fixTopMessageHeight)
115
        } else {
116
                fixTopMessageHeight();
117
        }
118
        
119
        $('.top-msg a.close').click(function(e) {
120
                e.preventDefault();
121
        $('.top-msg').animate({
122
            paddingTop:'0',
123
            paddingBottom:'0',
124
            height:'0'
125
        }, 1000, function (){
126
             $('.top-msg').removeClass('active')
127
        });
128
        $('.mainlogo').animate({
129
            marginTop:'0'
130
        }, 1000, function (){
131
             //todo
132
        });
133
    });        
134
    
135
     
136
        $('select.dropkicked').dropkick({
137
                change: function (value, label) {
138
                    $(this).parents('form').submit();
139
                    
140
                }
141
        });
142
        
143
        $('.with-info select').attr('tabindex','1');
144
    $('.with-info select').dropkick();
145
    
146
    $('.top-msg .success').parents('.top-msg').addClass('success');
147
    $('.top-msg .error').parents('.top-msg').addClass('error');
148
    $('.top-msg .warning').parents('.top-msg').addClass('warning');
149
    $('.top-msg .info').parents('.top-msg').addClass('info');
150
    
151
    // clouds homepage animation
152
    $('#animation a').hover(
153
      function () {
154
              
155
        $(this).animate({
156
           top: '+=-10'   
157
           }, 600, function() {
158
                   if ($(this).find('img').attr('src').indexOf("_top") == -1) {
159
                           var src = $(this).find('img').attr('src').replace('.png', '_top.png')
160
                        $(this).find('img').attr("src", src);
161
                   }
162

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

    
170
        $(this).animate({top: '0'}, 600, function() {
171
                var src = $(this).find('img').attr('src').replace('_top.png', '.png')
172
                       $(this).find('img').attr("src", src);
173
                });
174
        $(this).siblings('p').find('img').animate({
175
          width: '65%'       
176
        },600);
177
      }
178
    );
179
    
180
    
181
    
182
    
183
    $(function() {                 
184
                $( "#id_start_date" ).datepicker({
185
                        minDate: 0,
186
                        defaultDate: "+0", 
187
            dateFormat: "yy-mm-dd",
188
            onSelect: function( selectedDate ) {
189
                $( "#id_end_date" ).datepicker( "option", "minDate", selectedDate );
190
            }
191
        });
192
        
193
        $( "#id_end_date" ).datepicker({
194
                defaultDate: "+3w", 
195
            dateFormat: "yy-mm-dd",
196
            onSelect: function( selectedDate ) {
197
                $( "#id_start_date" ).datepicker( "option", "maxDate", selectedDate );
198
            }
199
        });
200
        });
201
        
202
         
203
        
204
        $('table .more-info').click(function(e){
205
                e.preventDefault();
206
                $(this).toggleClass('open');
207
                if ($(this).hasClass('open')){
208
                        $(this).html('- less info ')
209
                } else {
210
                        $(this).html('+ more info ')
211
                }
212
                $(this).parents('tr').next('tr').toggle();
213
                 
214
        });
215
        
216
        $('.projects .details .edit').click( function(e){
217
                e.preventDefault();
218
                $(this).parents('.details').children('.data').hide();
219
                $(this).parents('.details').children('.editable').slideDown(500, 'linear');
220
                $(this).hide();
221
        });
222
        
223
        $('.editable .form-row').each(function() {
224
                        if ( $(this).hasClass('with-errors') ){
225
                                $('.editable').show();
226
                                $('.projects .details a.edit, .projects .details .data').hide();
227
                                
228
                        }
229
                });
230
        
231
 
232
        $("input.leave, input.join").click(function () {
233
                $('dialog').hide();
234
                $(this).parents('.msg-wrap').find('.dialog').show();
235
                return false;      
236
                
237
    });
238
    
239
     $('.msg-wrap .no').click( function(e){
240
                e.preventDefault();
241
                $(this).parents('.dialog').hide();
242
        })
243
    
244
    $('.msg-wrap .yes').click( function(e){
245
                e.preventDefault();
246
                $(this).parents('.dialog').siblings('form').submit();
247
        })
248
    
249
    $('.hidden-submit input[readonly!="True"]').focus(function () {
250
         $('.hidden-submit .form-row.submit').slideDown(500);
251
    });
252
    
253
    
254
    
255
   
256
      
257
    
258
    setTimeout(function() {
259
      if ($('input#id_username').val()){ 
260
              $('input#id_username').siblings('label').css('opacity','0');
261
      };
262
      if ($('input#id_password').val()){ 
263
              $('input#id_password').siblings('label').css('opacity','0');
264
      }
265
        }, 100);
266
        
267
        
268
        
269
        
270
        $('.landing-page .cms').hover(
271
      function () {
272
               el = $('.cloudbar ul.services li').first();
273
               var offset = el.offset();
274
               positionX = offset.left;
275
               $('#hand').css('left',positionX);                   
276
         $('#hand').show();
277
      }, 
278
      function () {
279
              $('#hand').hide();
280
    
281
    });  
282
    
283
    $('.landing-page .pithos').hover(
284
      function () {
285
               el = $('.cloudbar ul.services li:nth-child(3)');
286
               var offset = el.offset();
287
               positionX = offset.left;
288
               left = parseInt(positionX) +20;
289
               $('#hand').css('left',left+'px');                   
290
         $('#hand').show();
291
      }, 
292
      function () {
293
              $('#hand').hide();
294
    
295
    });  
296
    
297
    $('.landing-page .cyclades').hover(
298
      function () {
299
               el = $('.cloudbar ul.services li:nth-child(2)').first();
300
               var offset = el.offset();
301
               positionX = offset.left;
302
               left = parseInt(positionX) +20;
303
               $('#hand').css('left',left+'px');                   
304
         $('#hand').show();
305
      }, 
306
      function () {
307
              $('#hand').hide();
308
    
309
    });  
310
    
311
    
312
    $('.landing-page .dashboard').hover(
313
      function () {
314
               el = $('.cloudbar .profile');
315
               var offset = el.offset();
316
               positionX = offset.left +50;
317
               $('#hand').css('left',positionX);                   
318
         $('#hand').show();
319
      }, 
320
      function () {
321
              $('#hand').hide();
322
    
323
    });  
324
    
325
    $('.pagination a.disabled').click(function(e){
326
            e.preventDefault();
327
    });
328
          
329
        // fix for recaptcha fields
330
        $('#okeanos_recaptcha').parents('.form-row').find('.extra-img').hide();          
331
     
332
         
333
            
334
});
335
        
336
$(window).resize(function() {
337
    
338
   setContainerMinHeight('.container .wrapper');
339
    
340

    
341
});