aboutsummaryrefslogtreecommitdiff
path: root/assets/js/main.js
diff options
context:
space:
mode:
authorDylan Bolger <dylanbolger@Dylans-MacBook-Air.local>2018-03-18 00:13:48 -0500
committerDylan Bolger <dylanbolger@Dylans-MacBook-Air.local>2018-03-18 00:13:48 -0500
commitf3195ea547bae0c0a31aef22119c0d2af50ec760 (patch)
treedc5cf29d80f4f09460b889acabdefce7d432c112 /assets/js/main.js
parentfdc4d84659a602447a77834b64595d9e9450a6c4 (diff)
downloadpersonal-website-f3195ea547bae0c0a31aef22119c0d2af50ec760.tar.xz
personal-website-f3195ea547bae0c0a31aef22119c0d2af50ec760.zip
c
Diffstat (limited to 'assets/js/main.js')
-rwxr-xr-xassets/js/main.js113
1 files changed, 113 insertions, 0 deletions
diff --git a/assets/js/main.js b/assets/js/main.js
new file mode 100755
index 0000000..3601ce3
--- /dev/null
+++ b/assets/js/main.js
@@ -0,0 +1,113 @@
+/*
+ Read Only by HTML5 UP
+ html5up.net | @ajlkn
+ Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
+*/
+
+(function($) {
+
+ skel.breakpoints({
+ xlarge: '(max-width: 1680px)',
+ large: '(max-width: 1280px)',
+ medium: '(max-width: 1024px)',
+ small: '(max-width: 736px)',
+ xsmall: '(max-width: 480px)'
+ });
+
+ $(function() {
+
+ var $body = $('body'),
+ $header = $('#header'),
+ $nav = $('#nav'), $nav_a = $nav.find('a'),
+ $wrapper = $('#wrapper');
+
+ // Fix: Placeholder polyfill.
+ $('form').placeholder();
+
+ // Prioritize "important" elements on medium.
+ skel.on('+medium -medium', function() {
+ $.prioritize(
+ '.important\\28 medium\\29',
+ skel.breakpoint('medium').active
+ );
+ });
+
+ // Header.
+ var ids = [];
+
+ // Set up nav items.
+ $nav_a
+ .scrolly({ offset: 44 })
+ .on('click', function(event) {
+
+ var $this = $(this),
+ href = $this.attr('href');
+
+ // Not an internal link? Bail.
+ if (href.charAt(0) != '#')
+ return;
+
+ // Prevent default behavior.
+ event.preventDefault();
+
+ // Remove active class from all links and mark them as locked (so scrollzer leaves them alone).
+ $nav_a
+ .removeClass('active')
+ .addClass('scrollzer-locked');
+
+ // Set active class on this link.
+ $this.addClass('active');
+
+ })
+ .each(function() {
+
+ var $this = $(this),
+ href = $this.attr('href'),
+ id;
+
+ // Not an internal link? Bail.
+ if (href.charAt(0) != '#')
+ return;
+
+ // Add to scrollzer ID list.
+ id = href.substring(1);
+ $this.attr('id', id + '-link');
+ ids.push(id);
+
+ });
+
+ // Initialize scrollzer.
+ $.scrollzer(ids, { pad: 300, lastHack: true });
+
+ // Off-Canvas Navigation.
+
+ // Title Bar.
+ $(
+ '<div id="titleBar">' +
+ '<a href="#header" class="toggle"></a>' +
+ '<span class="title">' + $('#logo').html() + '</span>' +
+ '</div>'
+ )
+ .appendTo($body);
+
+ // Header.
+ $('#header')
+ .panel({
+ delay: 500,
+ hideOnClick: true,
+ hideOnSwipe: true,
+ resetScroll: true,
+ resetForms: true,
+ side: 'right',
+ target: $body,
+ visibleClass: 'header-visible'
+ });
+
+ // Fix: Remove navPanel transitions on WP<10 (poor/buggy performance).
+ if (skel.vars.os == 'wp' && skel.vars.osVersion < 10)
+ $('#titleBar, #header, #wrapper')
+ .css('transition', 'none');
+
+ });
+
+})(jQuery); \ No newline at end of file