File: //old_home_backup/climatecampscotland.org.uk/public_html/js/init.js
/*
html5up.net | @n33co
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
*/
(function($) {
skel.init({
reset: 'full',
breakpoints: {
global: { range: '*', href: 'css/style.css', containers: 1400, grid: { gutters: 50 } },
wide: { range: '-1680', href: 'css/style-wide.css', containers: 1200, grid: { gutters: 40 } },
normal: { range: '-1280', href: 'css/style-normal.css', containers: 960, viewport: { scalable: false } },
narrow: { range: '-980', href: 'css/style-narrow.css', containers: '95%', grid: { gutters: 30 } },
narrower: { range: '-840', href: 'css/style-narrower.css', grid: { collapse: 1 } },
mobile: { range: '-736', href: 'css/style-mobile.css', containers: '100%', grid: { gutters: 15, collapse: 2 } }
},
plugins: {
layers: {
config: {
transformTest: function() { return (skel.vars.isMobile); }
},
topPanel: {
states: '/global/wide/normal/narrow/narrower/mobile',
position: 'top-center',
side: 'top',
hidden: true,
animation: 'pushY',
width: '100%',
height: 275,
html: '<nav data-action="navList" data-args="nav"></nav>',
clickToClose: true,
swipeToClose: false,
orientation: 'vertical'
},
topButton: {
states: '/global/wide/normal/narrow/narrower/mobile',
position: 'top-center',
width: 120,
height: 50,
html: '<span class="toggle" data-action="toggleLayer" data-args="topPanel"></span>'
},
sidePanel: {
states: '/global/wide/normal/narrow/narrower',
position: 'top-left',
side: 'left',
hidden: true,
animation: 'revealX',
width: 250,
height: '100%',
html: '<nav data-action="navList" data-args="nav"></nav>',
clickToClose: true,
orientation: 'vertical'
},
sideButton: {
states: '/global/wide/normal/narrow/narrower',
position: 'top-left',
width: 100,
height: 60,
html: '<span class="toggle" data-action="toggleLayer" data-args="sidePanel"></span>'
}
}
}
});
$(function() {
var $window = $(window),
$body = $('body'),
$header = $('#header'),
$banner = $('#banner');
// Disable animations/transitions until the page has loaded.
$body.addClass('is-loading');
$window.on('load', function() {
$body.removeClass('is-loading');
});
// CSS polyfills (IE<9).
if (skel.vars.IEVersion < 9)
$(':last-child').addClass('last-child');
// Forms (IE<10).
var $form = $('form');
if ($form.length > 0) {
if (skel.vars.IEVersion < 10) {
$.fn.n33_formerize=function(){var _fakes=new Array(),_form = $(this);_form.find('input[type=text],textarea').each(function() { var e = $(this); if (e.val() == '' || e.val() == e.attr('placeholder')) { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } }).blur(function() { var e = $(this); if (e.attr('name').match(/_fakeformerizefield$/)) return; if (e.val() == '') { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } }).focus(function() { var e = $(this); if (e.attr('name').match(/_fakeformerizefield$/)) return; if (e.val() == e.attr('placeholder')) { e.removeClass('formerize-placeholder'); e.val(''); } }); _form.find('input[type=password]').each(function() { var e = $(this); var x = $($('<div>').append(e.clone()).remove().html().replace(/type="password"/i, 'type="text"').replace(/type=password/i, 'type=text')); if (e.attr('id') != '') x.attr('id', e.attr('id') + '_fakeformerizefield'); if (e.attr('name') != '') x.attr('name', e.attr('name') + '_fakeformerizefield'); x.addClass('formerize-placeholder').val(x.attr('placeholder')).insertAfter(e); if (e.val() == '') e.hide(); else x.hide(); e.blur(function(event) { event.preventDefault(); var e = $(this); var x = e.parent().find('input[name=' + e.attr('name') + '_fakeformerizefield]'); if (e.val() == '') { e.hide(); x.show(); } }); x.focus(function(event) { event.preventDefault(); var x = $(this); var e = x.parent().find('input[name=' + x.attr('name').replace('_fakeformerizefield', '') + ']'); x.hide(); e.show().focus(); }); x.keypress(function(event) { event.preventDefault(); x.val(''); }); }); _form.submit(function() { $(this).find('input[type=text],input[type=password],textarea').each(function(event) { var e = $(this); if (e.attr('name').match(/_fakeformerizefield$/)) e.attr('name', ''); if (e.val() == e.attr('placeholder')) { e.removeClass('formerize-placeholder'); e.val(''); } }); }).bind("reset", function(event) { event.preventDefault(); $(this).find('select').val($('option:first').val()); $(this).find('input,textarea').each(function() { var e = $(this); var x; e.removeClass('formerize-placeholder'); switch (this.type) { case 'submit': case 'reset': break; case 'password': e.val(e.attr('defaultValue')); x = e.parent().find('input[name=' + e.attr('name') + '_fakeformerizefield]'); if (e.val() == '') { e.hide(); x.show(); } else { e.show(); x.hide(); } break; case 'checkbox': case 'radio': e.attr('checked', e.attr('defaultValue')); break; case 'text': case 'textarea': e.val(e.attr('defaultValue')); if (e.val() == '') { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } break; default: e.val(e.attr('defaultValue')); break; } }); window.setTimeout(function() { for (x in _fakes) _fakes[x].trigger('formerize_sync'); }, 10); }); return _form; };
$form.n33_formerize();
}
}
// Scrolly links.
$('.scrolly').scrolly(1000, -10);
// Dropdowns.
$('#nav > ul').dropotron({
mode: 'fade',
noOpenerFade: true,
expandMode: (skel.vars.isTouch ? 'click' : 'hover')
});
// Header.
// If the header is using "alt" styling and #banner is present, use scrollwatch
// to revert it back to normal styling once the user scrolls past the banner.
// Note: This is disabled on mobile devices.
if (!skel.vars.isMobile
&& $header.hasClass('alt')
&& $banner.length > 0) {
$window.on('load', function() {
$banner.scrollwatch({
delay: 0,
range: 1,
anchor: 'top',
on: function() { $header.addClass('alt reveal'); },
off: function() { $header.removeClass('alt'); }
});
});
}
});
})(jQuery);