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