BUG #29 Cleaned up whitespace that caused some browsers to not render JS

This commit is contained in:
Sean Harvey 2014-07-30 16:10:31 +12:00
parent 84c1215f91
commit aaf8d0f8b7

View File

@ -1,8 +1,7 @@
jQuery.noConflict(); jQuery.noConflict();
(function($) {     (function($) {
   $(document).ready(function() { $(document).ready(function() {
/* removes text from search form on focus and replaces it on unfocus - if text is entered then it does not get replaced with default on unfocus */ /* removes text from search form on focus and replaces it on unfocus - if text is entered then it does not get replaced with default on unfocus */
$('#SearchForm_SearchForm_action_results').val('L'); $('#SearchForm_SearchForm_action_results').val('L');
var searchField = $('#SearchForm_SearchForm_Search'); var searchField = $('#SearchForm_SearchForm_Search');
@ -18,29 +17,28 @@ jQuery.noConflict();
searchField.val(default_value); searchField.val(default_value);
} }
}); });
if (!$.browser.msie || ($.browser.msie && (parseInt($.browser.version, 10) > 8))) { if (!$.browser.msie || ($.browser.msie && (parseInt($.browser.version, 10) > 8))) {
var searchBarButton = $("span.search-dropdown-icon"); var searchBarButton = $("span.search-dropdown-icon");
var searchBar = $('div.search-bar'); var searchBar = $('div.search-bar');
var menuButton = $("span.nav-open-button"); var menuButton = $("span.nav-open-button");
var menu = $('.header .primary ul'); var menu = $('.header .primary ul');
var mobile = false; var mobile = false;
var changed = false; var changed = false;
$('body').append('<div id="media-query-trigger"></div>'); $('body').append('<div id="media-query-trigger"></div>');
function menuWidthCheck() { function menuWidthCheck() {
var header_w = $('header .inner').width(); var header_w = $('header .inner').width();
var elements_w = menu.width() + $('.brand').width(); var elements_w = menu.width() + $('.brand').width();
if ((header_w < elements_w) || ($(window).width() <= 768)) { if ((header_w < elements_w) || ($(window).width() <= 768)) {
$('body').addClass('tablet-nav'); $('body').addClass('tablet-nav');
} }
else { else {
$('body').removeClass('tablet-nav'); $('body').removeClass('tablet-nav');
} }
mobile_old = mobile; mobile_old = mobile;
if ($('#media-query-trigger').css('visibility') == 'hidden') { if ($('#media-query-trigger').css('visibility') == 'hidden') {
mobile = false; mobile = false;
@ -48,7 +46,7 @@ jQuery.noConflict();
else { else {
mobile = true; mobile = true;
} }
if (mobile_old != mobile) { if (mobile_old != mobile) {
changed = true; changed = true;
} }
@ -56,12 +54,12 @@ jQuery.noConflict();
changed = false; changed = false;
} }
} }
menuWidthCheck(); menuWidthCheck();
$(window).resize(function() { $(window).resize(function() {
menuWidthCheck(); menuWidthCheck();
if (!mobile) { if (!mobile) {
menu.show(); menu.show();
searchBar.show(); searchBar.show();
@ -69,23 +67,21 @@ jQuery.noConflict();
else { else {
if (changed) { if (changed) {
menu.hide(); menu.hide();
searchBar.hide(); searchBar.hide();
} }
} }
}); });
/* toggle navigation and search in mobile view */ /* toggle navigation and search in mobile view */
searchBarButton.click(function() { searchBarButton.click(function() {
menu.slideUp(); menu.slideUp();
searchBar.slideToggle(200); searchBar.slideToggle(200);
}); });
menuButton.click(function() {
searchBar.slideUp();
menu.slideToggle(200);
});
menuButton.click(function() {
searchBar.slideUp();
menu.slideToggle(200);
});
} }
});
   });
}(jQuery)); }(jQuery));