[9f3905]: / docs / lagunita / js / base.js

Download this file

67 lines (57 with data), 2.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// JavaScript Document
/***
Utility functions available across the site
***/
var LAGUNITA = {
size: function(){
// return window size based on visibility as calculated by CSS
var size = 'lg';
// if we don't already have the size-detect div's, add them
if ( $('.size-detect-xs').length == 0 ) {
$('body')
.append('<div class="size-detect-xs" />')
.append('<div class="size-detect-sm" />')
.append('<div class="size-detect-md" />')
.append('<div class="size-detect-lg" />');
}
$(['xs', 'sm', 'md', 'lg']).each(function(i, sz) {
if ($('.size-detect-'+sz).css('display') != 'none') {
size = sz;
}
});
return size;
},
stickFooter: function(){
// adjust css to make footer sticky
var h = $('#footer').height() + 'px';
$('#su-content').css('padding-bottom', h);
$('#footer').css('margin-top', '-'+h);
}
};
$(document).ready(function() {
LAGUNITA.stickFooter();
// note resize events and trigger resizeEnd event when resizing stops
$(window).resize(function() {
if(this.resizeTO) clearTimeout(this.resizeTO);
this.resizeTO = setTimeout(function() {
$(this).trigger('resizeEnd');
}, 200);
});
// Call responsive funtion when browser window resizing is complete
$(window).bind('resizeEnd', function() {
// show or hide the hamburger based on window size
var size = LAGUNITA.size(); // what size is our window (xs, sm, md or lg)
if (size == 'md' || size == 'lg') { // if size is md or lg, unhide search and gateway blocks
$('.navbar-collapse').collapse('hide');
// $('.navbar-collapse').removeClass('in').addClass('collapse');
}
// re-stick the footer in case its height has changed
LAGUNITA.stickFooter();
});
$('.navbar-collapse').collapse({toggle: false}); // activate collapsibility without toggling state
$('#skip > a').click(function(e){
var href = $(this).attr('href').substr(1); // remove the #
var target = $('a[name="' + href + '"]');
target.focus();
});
});