Statistics
| Branch: | Tag: | Revision:

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

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

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

    
169
        $(this).animate({top: '0'}, 600, function() {
170
                var src = $(this).find('img').attr('src').replace('_top.png', '.png')
171
                       $(this).find('img').attr("src", src);
172
                });
173
        $(this).siblings('p').find('img').animate({
174
          width: '65%'       
175
        },600);
176
      }
177
    );
178
    
179
    
180
    
181
    
182
    $(function() {                 
183
                $( "#id_start_date" ).datepicker({
184
                        minDate: 0,
185
                        defaultDate: "+0", 
186
            dateFormat: "yy-mm-dd",
187
            onSelect: function( selectedDate ) {
188
                $( "#id_end_date" ).datepicker( "option", "minDate", selectedDate );
189
            }
190
        });
191
        
192
        $( "#id_end_date" ).datepicker({
193
                defaultDate: "+3w", 
194
            dateFormat: "yy-mm-dd",
195
            onSelect: function( selectedDate ) {
196
                $( "#id_start_date" ).datepicker( "option", "maxDate", selectedDate );
197
            }
198
        });
199
        });
200
        
201
         
202
        
203
        $('table .more-info').click(function(e){
204
                e.preventDefault();
205
                $(this).toggleClass('open');
206
                if ($(this).hasClass('open')){
207
                        $(this).html('- less info ')
208
                } else {
209
                        $(this).html('+ more info ')
210
                }
211
                $(this).parents('tr').next('tr').toggle();
212
                 
213
        });
214
        
215
        $('.projects .details .edit').click( function(e){
216
                e.preventDefault();
217
                $(this).parents('.details').children('.data').hide();
218
                $(this).parents('.details').children('.editable').slideDown(500, 'linear');
219
                $(this).hide();
220
        });
221
        
222
        $('.editable .form-row').each(function() {
223
                        if ( $(this).hasClass('with-errors') ){
224
                                $('.editable').show();
225
                                $('.projects .details a.edit, .projects .details .data').hide();
226
                                
227
                        }
228
                });
229
        
230
 
231
        $("input.leave, input.join").click(function () {
232
                $('dialog').hide();
233
                $(this).parents('.msg-wrap').find('.dialog').show();
234
                return false;      
235
                
236
    });
237
    
238
     $('.msg-wrap .no').click( function(e){
239
                e.preventDefault();
240
                $(this).parents('.dialog').hide();
241
        })
242
    
243
    $('.msg-wrap .yes').click( function(e){
244
                e.preventDefault();
245
                $(this).parents('.dialog').siblings('form').submit();
246
        })
247
    
248
    $('.hidden-submit input[readonly!="True"]').focus(function () {
249
         $('.hidden-submit .form-row.submit').slideDown(500);
250
    });
251
    
252
    
253
    
254
   
255
      
256
    
257
    setTimeout(function() {
258
      if ($('input#id_username').val()){ 
259
              $('input#id_username').siblings('label').css('opacity','0');
260
      };
261
      if ($('input#id_password').val()){ 
262
              $('input#id_password').siblings('label').css('opacity','0');
263
      }
264
        }, 100);
265
        
266
         // clouds homepage animation
267
        /*
268
        addClassHover('.landing-page .pithos','.cloudbar ul.services li:first');
269
        addClassHover('.landing-page .cyclades','.cloudbar ul.services li:nth-child(2)');
270
        addClassHover('.landing-page .dashboard','.cloudbar .profile')
271
    */
272
         
273
            
274
});
275
        
276
$(window).resize(function() {
277
    
278
   setContainerMinHeight('.container .wrapper');
279
    
280

    
281
});