Subversion Repositories SmartDukaan

Rev

Rev 6866 | Rev 6981 | Go to most recent revision | 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
 
63
 
64
	$('a.mk_filter_close').click(function(){
65
		var search = window.location.search;
66
		if(window.location.search=="") {
67
			search = "?";
68
		}
6881 amit.gupta 69
		var newurl = window.location.pathname + search;
6866 amit.gupta 70
		var filterValue = $(this).attr("value");
71
		if(filterValue.indexOf("F_50010")>-1){
72
			$(this).closest('div').find('.mk_filter_close').each(function(index,value){
73
				newurl = newurl.replace($(value).attr("value"), "");
74
			});
75
		} else {
76
			newurl = newurl.replace($(this).attr("value"), "");
77
		}
6881 amit.gupta 78
		window.location = newurl.replace(/&page=./,"");
6866 amit.gupta 79
	});
80
 
4180 rajveer 81
	$('body').mouseup(function(){
82
		var userSelector = $('#userSelector');
83
		var isMouseOnUserSelector = $(userSelector).data('is_mouse_on_user_selector');
84
 
85
		if (typeof(isMouseOnUserSelector) == 'boolean'  && !isMouseOnUserSelector)	{
86
			$(userSelector).children('ul').hide();
87
			$(userSelector).data('usermenustate', false);
88
			$(userSelector).removeClass('active');
89
		}
90
	});
91
 
92
	$('#userSelector').click(function(){
93
 
94
		var userMenuState = $(this).data('usermenustate');
95
 
96
		if (typeof(userMenuState) == 'undefined' || !userMenuState)	{
97
			$(this).addClass('active');
98
			$(this).children('ul').show();
99
			$(this).data('usermenustate', true);
100
		} else	{
101
			$(this).removeClass('active');
102
			$(this).children('ul').hide();
103
			$(this).data('usermenustate', false);
104
		}
105
	}).hover(function(){
106
		$(this).data('is_mouse_on_user_selector', true);
107
	}, function(){
108
		$(this).data('is_mouse_on_user_selector', false);
109
	});
110
 
4810 varun.gupt 111
	/** Press Coverage Section **/
112
	$('#asSeenOnBS').click(function(){
113
		window.open('http://www.business-standard.com/india/news/spice-launches-online-shopping-portal-saholiccom/434451/', '_blank');
114
		trackEventWithGA('Press Coverage', 'Logo Click', 'Business Standard');
115
	});
116
 
117
	$('#asSeenOnTOI').click(function(){
118
		window.open("http://articles.timesofindia.indiatimes.com/2012-01-25/telecom/30662542_1_nokia-s-windows-phone-nokia-lumia-smartphone", '_blank');
119
		trackEventWithGA('Press Coverage', 'Logo Click', 'The Times of India');
120
	});
121
 
122
	$('#asSeenOnWSJ').click(function(){
123
		window.open('http://online.wsj.com/article/SB10001424052702304447804576412930555639142.html', '_blank');
124
		trackEventWithGA('Press Coverage', 'Logo Click', 'The Wall Street Journal');
125
	});
126
 
127
	$('#asSeenOnMC').click(function(){
128
		window.open("http://www.moneycontrol.com/news/technology/nokia-lumia-710-available-for-approximately-rs15700_655601.html", '_blank');
129
		trackEventWithGA('Press Coverage', 'Logo Click', 'Money Control');
130
	});
3830 chandransh 131
});