Subversion Repositories SmartDukaan

Rev

Rev 10014 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3830 chandransh 1
$(function(){
4180 rajveer 2
	$("#userSelector .default").truncate({addtitle: true});
3966 varun.gupt 3
 
4
	function submitSeachForm()	{
5
		var query = $.trim($('#query').val());
6
 
7
		if(query != '' && query != 'Search for more items...')	{
8
			$('#formSearch').submit();	
9
		} else	{
10
			$('#query').focus();
11
		}
12
	}
13
 
3830 chandransh 14
	/** Search in Header **/
15
	$('#query').val('Search for more items...')
16
		.focus(function(){
17
			$(this).val('');
18
		})
19
		.blur(function(){
20
			if ($(this).val() == '')	$(this).val('Search for more items...');
21
		});
22
 
23
	$('#searchButton').click(function(){
3966 varun.gupt 24
		submitSeachForm();
3830 chandransh 25
	});
26
 
6866 amit.gupta 27
	$('input.mk_filter').change(function(){
28
		var search = window.location.search;
29
		if(window.location.search=="") {
30
			search = "?";
31
		}
32
		var currenturl = window.location.pathname + search;
33
		if(this.checked) {
6881 amit.gupta 34
			currenturl = (currenturl) + this.value;
6866 amit.gupta 35
		} else {
6881 amit.gupta 36
			currenturl = (currenturl).replace(this.value, "");
6866 amit.gupta 37
		}
6881 amit.gupta 38
		window.location = currenturl.replace(/&page=./,"");
6866 amit.gupta 39
	});
40
	$('a.mk_filter').click(function(){
41
		//first remove all fqs except category and sub category when 
42
		//any of the category links are clicked
43
		var search = window.location.search;
44
		if(window.location.search=="") {
45
			search = "?";
46
		}
47
		var currenturl = window.location.pathname + search;
48
		classNames = $(this).attr("class");
49
		if(classNames.indexOf("mk_bold") >= 0) {
50
			//if this is selected category filter, remove subcategory filter from url
6881 amit.gupta 51
			currenturl = currenturl.replace($(this).closest('ul').find('.mk_bold.mk_subcategory').attr("value"), "");
6866 amit.gupta 52
		}else {
53
			//check if sub-category is changed, if yes then remove the previous sub-category and add this sub-category
54
			if(classNames.indexOf("mk_subcategory") >= 0) {
6881 amit.gupta 55
				currenturl = currenturl.replace($(this).closest('ul').find('.mk_bold.mk_subcategory').attr("value"), "") + $(this).attr("value");
6866 amit.gupta 56
			}else {
6881 amit.gupta 57
				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");
6866 amit.gupta 58
			} 
59
		}
6881 amit.gupta 60
		window.location = currenturl.replace(/&page=./,"");
6866 amit.gupta 61
	});
62
 
6998 amit.gupta 63
	//also now remove unwanted filters
6866 amit.gupta 64
	$('a.mk_filter_close').click(function(){
6998 amit.gupta 65
		var rootFacets = ["F_50010","F_50011","F_50002", "F_50001", "F_50028"];
6866 amit.gupta 66
		var search = window.location.search;
67
		if(window.location.search=="") {
68
			search = "?";
69
		}
6881 amit.gupta 70
		var newurl = window.location.pathname + search;
6866 amit.gupta 71
		var filterValue = $(this).attr("value");
72
		if(filterValue.indexOf("F_50010")>-1){
73
			$(this).closest('div').find('.mk_filter_close').each(function(index,value){
74
				newurl = newurl.replace($(value).attr("value"), "");
75
			});
6998 amit.gupta 76
		} else if(filterValue.indexOf("F_50011")>-1){
7002 amit.gupta 77
			$(this).closest('#currentFilters').find('.mk_filter_close').each(function(index,value){
6998 amit.gupta 78
				var regexS = "fq=(.*)%3A";
79
				var regex = new RegExp(regexS);
7002 amit.gupta 80
				var results = regex.exec($(value).attr("value"));
6998 amit.gupta 81
				if(rootFacets.indexOf(results[1]) == -1){
82
					newurl = newurl.replace($(value).attr("value"), "");
83
				}
84
			});
85
			newurl = newurl.replace($(this).attr("value"), "");
6866 amit.gupta 86
		} else {
87
			newurl = newurl.replace($(this).attr("value"), "");
88
		}
6881 amit.gupta 89
		window.location = newurl.replace(/&page=./,"");
6866 amit.gupta 90
	});
91
 
4180 rajveer 92
	$('body').mouseup(function(){
93
		var userSelector = $('#userSelector');
94
		var isMouseOnUserSelector = $(userSelector).data('is_mouse_on_user_selector');
95
 
96
		if (typeof(isMouseOnUserSelector) == 'boolean'  && !isMouseOnUserSelector)	{
97
			$(userSelector).children('ul').hide();
98
			$(userSelector).data('usermenustate', false);
99
			$(userSelector).removeClass('active');
100
		}
101
	});
102
 
103
	$('#userSelector').click(function(){
104
 
105
		var userMenuState = $(this).data('usermenustate');
106
 
107
		if (typeof(userMenuState) == 'undefined' || !userMenuState)	{
108
			$(this).addClass('active');
109
			$(this).children('ul').show();
110
			$(this).data('usermenustate', true);
111
		} else	{
112
			$(this).removeClass('active');
113
			$(this).children('ul').hide();
114
			$(this).data('usermenustate', false);
115
		}
116
	}).hover(function(){
117
		$(this).data('is_mouse_on_user_selector', true);
118
	}, function(){
119
		$(this).data('is_mouse_on_user_selector', false);
120
	});
121
 
4810 varun.gupt 122
	/** Press Coverage Section **/
123
	$('#asSeenOnBS').click(function(){
6981 kshitij.so 124
		window.open('http://www.business-standard.com/article/companies/saholic-com-offering-theft-insurance-for-mobile-handsets-113031100002_1.html', '_blank');
4810 varun.gupt 125
		trackEventWithGA('Press Coverage', 'Logo Click', 'Business Standard');
126
	});
6981 kshitij.so 127
 
128
	$('#asSeenOnBT').click(function(){
129
		window.open('http://businesstoday.intoday.in/story/saholic.com-to-compensate-customers-for-late-deliveries/1/191649.html', '_blank');
130
		trackEventWithGA('Press Coverage', 'Logo Click', 'Business Today');
131
	});
4810 varun.gupt 132
 
133
	$('#asSeenOnTOI').click(function(){
134
		window.open("http://articles.timesofindia.indiatimes.com/2012-01-25/telecom/30662542_1_nokia-s-windows-phone-nokia-lumia-smartphone", '_blank');
135
		trackEventWithGA('Press Coverage', 'Logo Click', 'The Times of India');
136
	});
137
 
138
	$('#asSeenOnWSJ').click(function(){
139
		window.open('http://online.wsj.com/article/SB10001424052702304447804576412930555639142.html', '_blank');
140
		trackEventWithGA('Press Coverage', 'Logo Click', 'The Wall Street Journal');
141
	});
142
 
143
	$('#asSeenOnMC').click(function(){
144
		window.open("http://www.moneycontrol.com/news/technology/nokia-lumia-710-available-for-approximately-rs15700_655601.html", '_blank');
145
		trackEventWithGA('Press Coverage', 'Logo Click', 'Money Control');
146
	});
8917 kshitij.so 147
 
148
	jQuery("#promotion-banners").find("a, area").click(
149
		    function(){
150
		        if($(this).attr("href") != "#") {
151
		            bannername = $(this).attr("banner-name");
152
		            url = $(this).attr("href");
153
					trackEventWithGA('Side Banner Region Clicked', bannername, 'Location '+document.URL+' Target Url '+url);
154
		        }
155
		    }
156
		);
157
 
8936 kshitij.so 158
	jQuery("#banner-menu").find("a, area").click(
159
		    function(){
160
		        if($(this).attr("href") != "#") {
161
		            bannername = $(this).attr("banner-name");
162
		            url = $(this).attr("href");
163
					trackEventWithGA('Banner Region Clicked', bannername, 'Location '+document.URL+' Target Url '+url);
164
		        }
165
		    }
11747 amit.gupta 166
		);	
3830 chandransh 167
});