added tag links
authorAnthony Talarico <talarico@gaslightmedia.com>
Wed, 30 Dec 2015 20:45:15 +0000 (15:45 -0500)
committerAnthony Talarico <talarico@gaslightmedia.com>
Wed, 30 Dec 2015 20:45:15 +0000 (15:45 -0500)
js/app.js
js/custom/upcp.js

index 80af492..2d6ace6 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -21,6 +21,13 @@ $(document).ready(function () {
 ;/*global document, window, alert, console, require*/
 $(document).ready(function () {
     "use strict";
+    
+    function createCookie(name, value) {
+        var date = new Date();
+        date.setTime(date.getTime()+(3*1000));
+        var expires = "; expires="+date.toGMTString();
+        document.cookie = name+"="+value+expires+"; path=/";
+    }
     document.cookie = "catView=grid";
     // don't display products on the main "products page"
     if ((window.location.href.indexOf("products-2") >= 0)){
@@ -73,7 +80,7 @@ $(document).ready(function () {
         });
 
     // show products if filter is selected else only display categories
-    $("#tagBox :checkbox").click(function() {
+    $("#tagBox :checkbox").on("click",function() {
         $(".product").hide();
         $("#gridView").css("display", "inherit");
         $("#listView").css("display", "inherit");
@@ -104,8 +111,40 @@ $(document).ready(function () {
        // $('.searchform').css("right", "5px");
         $("#search-icon").css("visibility", "visible");
     });
-
     $("#page-title").append($("#productBreadcrumbs"));
     $("#blog-side-info-wrapper").insertBefore("#categoriesGridView");
     $("#blog-side-info-wrapper").insertBefore("#categoriesListView");
-});
+
+    var link; 
+    $('#tags a').click(function() {
+        link = $(this).text();
+        createCookie("link", link);
+       // $("#tagBox :checkbox").trigger("click");
+        
+    });
+    // get value of clicked tag /////////////////////
+    function getCookie(cname) {
+        var name = cname + "=";
+        var ca = document.cookie.split(';');
+        for(var i=0; i<ca.length; i++) {
+            var c = ca[i];
+            while (c.charAt(0)==' ') c = c.substring(1);
+            if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
+        }
+        return "";
+    } 
+    ///////////////////////////////////////////////
+    var selectedTag = getCookie("link");
+    $(":checkbox[value=" + selectedTag + "]").prop("checked", true);
+    if($(":checkbox[value=" + selectedTag + "]").prop("checked", true)){
+        $(".product").hide();
+        $("#gridView").css("display", "inherit");
+        $("#listView").css("display", "inherit");
+        $("#categoriesGridView").hide();
+        $("#categoriesListView").hide()
+        $("#tagBox :checkbox:checked").each(function() {
+            $("." + $(this).val()).show();
+        });
+    }
+                                           
+});
\ No newline at end of file
index b93e3a7..29ed799 100644 (file)
@@ -1,6 +1,13 @@
 /*global document, window, alert, console, require*/
 $(document).ready(function () {
     "use strict";
+    
+    function createCookie(name, value) {
+        var date = new Date();
+        date.setTime(date.getTime()+(3*1000));
+        var expires = "; expires="+date.toGMTString();
+        document.cookie = name+"="+value+expires+"; path=/";
+    }
     document.cookie = "catView=grid";
     // don't display products on the main "products page"
     if ((window.location.href.indexOf("products-2") >= 0)){
@@ -53,7 +60,7 @@ $(document).ready(function () {
         });
 
     // show products if filter is selected else only display categories
-    $("#tagBox :checkbox").click(function() {
+    $("#tagBox :checkbox").on("click",function() {
         $(".product").hide();
         $("#gridView").css("display", "inherit");
         $("#listView").css("display", "inherit");
@@ -84,8 +91,40 @@ $(document).ready(function () {
        // $('.searchform').css("right", "5px");
         $("#search-icon").css("visibility", "visible");
     });
-
     $("#page-title").append($("#productBreadcrumbs"));
     $("#blog-side-info-wrapper").insertBefore("#categoriesGridView");
     $("#blog-side-info-wrapper").insertBefore("#categoriesListView");
-});
+
+    var link; 
+    $('#tags a').click(function() {
+        link = $(this).text();
+        createCookie("link", link);
+       // $("#tagBox :checkbox").trigger("click");
+        
+    });
+    // get value of clicked tag /////////////////////
+    function getCookie(cname) {
+        var name = cname + "=";
+        var ca = document.cookie.split(';');
+        for(var i=0; i<ca.length; i++) {
+            var c = ca[i];
+            while (c.charAt(0)==' ') c = c.substring(1);
+            if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
+        }
+        return "";
+    } 
+    ///////////////////////////////////////////////
+    var selectedTag = getCookie("link");
+    $(":checkbox[value=" + selectedTag + "]").prop("checked", true);
+    if($(":checkbox[value=" + selectedTag + "]").prop("checked", true)){
+        $(".product").hide();
+        $("#gridView").css("display", "inherit");
+        $("#listView").css("display", "inherit");
+        $("#categoriesGridView").hide();
+        $("#categoriesListView").hide()
+        $("#tagBox :checkbox:checked").each(function() {
+            $("." + $(this).val()).show();
+        });
+    }
+                                           
+});
\ No newline at end of file