From: Anthony Talarico Date: Mon, 21 Dec 2015 18:34:48 +0000 (-0500) Subject: adding nav functionality to grid and list toggle icons X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=5ca53b73491c68e70900dc37bb2caab61bfabdff;p=WP-Themes%2Fmichsci.git adding nav functionality to grid and list toggle icons --- diff --git a/js/app.js b/js/app.js index 74ba970..8902fe3 100644 --- a/js/app.js +++ b/js/app.js @@ -22,23 +22,30 @@ $(document).ready(function () { $(document).ready(function () { "use strict"; - if ((window.location.href.indexOf("products-2/?pagename") >= 0)) { + // navigate back to products page if on product page + if ((window.location.href.indexOf("products/?pagename") >= 0)) { // $("#viewBtns").css("display", "none"); - $("#grid").on("click", function () { + $("#grid").on("click", function (e) { + document.cookie = "view=grid"; + window.location.href = window.location.pathname; + }); + $("#list").on("click", function (e) { + document.cookie = "view=list"; window.location.href = window.location.pathname; }); } - $("#list").on("click", function (e) { - document.cookie = "view=list"; - location.reload(); - }); - - if (!(window.location.href.indexOf("products-2/?pagename") >= 0)) { + // change output view + + if (!(window.location.href.indexOf("products/?pagename") >= 0)) { $("#grid").on("click", function (e) { document.cookie = "view=grid"; location.reload(); }); + $("#list").on("click", function (e) { + document.cookie = "view=list"; + location.reload(); + }); } $("#categoryDropdown").change(function() { diff --git a/js/custom/upcp.js b/js/custom/upcp.js index 40ff23a..60e611b 100644 --- a/js/custom/upcp.js +++ b/js/custom/upcp.js @@ -2,23 +2,30 @@ $(document).ready(function () { "use strict"; - if ((window.location.href.indexOf("products-2/?pagename") >= 0)) { + // navigate back to products page if on product page + if ((window.location.href.indexOf("products/?pagename") >= 0)) { // $("#viewBtns").css("display", "none"); - $("#grid").on("click", function () { + $("#grid").on("click", function (e) { + document.cookie = "view=grid"; + window.location.href = window.location.pathname; + }); + $("#list").on("click", function (e) { + document.cookie = "view=list"; window.location.href = window.location.pathname; }); } - $("#list").on("click", function (e) { - document.cookie = "view=list"; - location.reload(); - }); - - if (!(window.location.href.indexOf("products-2/?pagename") >= 0)) { + // change output view + + if (!(window.location.href.indexOf("products/?pagename") >= 0)) { $("#grid").on("click", function (e) { document.cookie = "view=grid"; location.reload(); }); + $("#list").on("click", function (e) { + document.cookie = "view=list"; + location.reload(); + }); } $("#categoryDropdown").change(function() {