Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20424 kshitij.so 1
$(function() {
2
 
3
	$("#query").autocomplete({  autoFocus: true, minLength: 3,
4
    	source: "/hotspot/auto-suggest",
5
    	select: function( event, ui ) {
6
    		this.value = ui.item.value;
7
			$('#formSearch').submit();
8
			return false;
9
		}
10
    });
11
 
12
	$('.imageThumbnail_li ').mouseover(function(){
13
  		$(this).css({"border-color":"#000000"});
14
		$(".default-thumbnail").find("img").attr("src",$(this).find("img").attr("src"));
15
		});
16
		$('.imageThumbnail_li ').mouseleave(function(){
17
  		$(this).css({"border-color":"#CCCCCC"});
18
	});
19
 
20
	$('input.filterList_checkBox').change(function(){
21
		var search = window.location.search;
22
		if(window.location.search=="") {
23
			search = "?";
24
		}
25
		var currenturl = (window.location.pathname + search);
26
		console.log(currenturl);
27
		console.log(this.checked + this.value);
28
		if(this.checked) {
29
			currenturl = (currenturl) + this.value;
30
		} else {
31
			currenturl = (currenturl).replace(this.value, "");
32
		}
33
		window.location = currenturl.replace(/&page=./,"");
34
	});
35
 
36
	$('a.mk_filter').click(function(){
37
		//first remove all fqs except category and sub category when 
38
		//any of the category links are clicked
39
		var search = window.location.search;
40
		if(window.location.search=="") {
41
			search = "?";
42
		}
43
		var currenturl = window.location.pathname + search;
44
		classNames = $(this).attr("class");
45
		if(classNames.indexOf("mk_bold") >= 0) {
46
			//if this is selected category filter, remove subcategory filter from url
47
			currenturl = currenturl.replace($(this).closest('ul').find('.mk_bold.mk_subcategory').attr("value"), "");
48
		}else {
49
			//check if sub-category is changed, if yes then remove the previous sub-category and add this sub-category
50
			if(classNames.indexOf("mk_subcategory") >= 0) {
51
				currenturl = currenturl.replace($(this).closest('ul').find('.mk_bold.mk_subcategory').attr("value"), "") + $(this).attr("value");
52
			}else {
53
				currenturl = (currenturl).replace($(this).closest('ul').find('.mk_bold.mk_category').attr("value"), "").replace($(this).closest('ul').find('.mk_bold.mk_subcategory').attr("value"),"") + $(this).attr("value");
54
			} 
55
		}
56
		window.location = currenturl.replace(/&page=./,"");
57
	});
58
 
59
	//also now remove unwanted filters
60
	$('a.mk_filter_close').click(function(){
61
		var rootFacets = ["F_50010","F_50011","F_50002", "F_50001", "F_50028"];
62
		var search = window.location.search;
63
		if(window.location.search=="") {
64
			search = "?";
65
		}
66
		var newurl = window.location.pathname + search;
67
		var filterValue = $(this).attr("value");
68
		console.log("newurl "+newurl);
69
		console.log("filtervalue "+filterValue);
70
		if(filterValue.indexOf("F_50010")>-1){
71
			$(this).closest('div').find('.mk_filter_close').each(function(index,value){
72
				newurl = newurl.replace($(value).attr("value"), "");
73
			});
74
		} else if(filterValue.indexOf("F_50011")>-1){
75
			$(this).closest('#currentFilters').find('.mk_filter_close').each(function(index,value){
76
				var regexS = "fq=(.*)%3A";
77
				var regex = new RegExp(regexS);
78
				var results = regex.exec($(value).attr("value"));
79
				if(rootFacets.indexOf(results[1]) == -1){
80
					newurl = newurl.replace($(value).attr("value"), "");
81
				}
82
			});
83
			newurl = newurl.replace($(this).attr("value"), "");
84
		} else {
85
			newurl = newurl.replace($(this).attr("value"), "");
86
		}
87
		window.location = newurl.replace(/&page=./,"");
88
	});
89
 
90
 
91
 
92
});