updates to structure, css, js
[jkinsey.net.git] / js / script.js
index 1fabcaf40b3a6ce0264fef3bff47136020f7b6b4..c5f2c7a4167db351e8af42da240d9cb2ea965c72 100644 (file)
@@ -1,14 +1,27 @@
 window.addEventListener('load', function() {
-    var menuLoc = 0;
     var links = document.getElementById("links").children[0].children;
-    var menu = document.getElementById("menu");
-    function menuMove(node) {
-        if(menuLoc) return;
-        menu.setAttribute("class", "top");
-        setTimeout(function() { menu.setAttribute("class", "left") }, 600);
-        menuLoc = 1;
+    var home = document.getElementsByClassName("home");
+    var directions = [];
+    for(var i = 0; i < links.length - 1; i++) {
+        directions.push(links[i]);
+    }
+    for(var i = 0; i < home.length; i++) {
+        directions.push(home[i]);
     }
-    for(var i = 0; i < links.length; i++) {
-        links[i].onclick = function(node) { menuMove(node); };
+    var menu = document.getElementById("menu");
+    var menuLoc = parseInt(getComputedStyle(menu).getPropertyValue("top"));
+
+    for(var i = 0; i < directions.length; i++) {
+        directions[i].children[0].onclick = function(event) { 
+            event.preventDefault();
+            var node = event.currentTarget;
+            if(menuLoc != 10) {
+                menuLoc = 0;
+                menu.setAttribute("class", "top");
+                window.history.pushState("object or string", "Title", node.href);
+            } else {
+                window.history.pushState("object or string", "Title", node.href);
+            }
+        };
     }
 }, false);