Subversion Repositories SmartDukaan

Rev

Rev 13672 | Rev 13686 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13579 anikendra 1
$(function(){
2
	$('.scroll').jscroll({
3
		loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
4
	    autoTriggerUntil: 3,
5
	    padding: 20,
6
	});
13599 anikendra 7
	$('.row').on('click','.viewproduct',function(e){
13579 anikendra 8
		var url = apihost+"clicks/add/"+me+"/"+$(this).data('id');
9
		$.ajax({
10
			url: url,
11
			// The name of the callback parameter, as specified by the YQL service
12
			jsonp: "callback",
13
			// Tell jQuery we're expecting JSONP
14
			dataType: "jsonp",
15
			// Tell YQL what we want and that we want JSON
16
			data: {
17
				format: "json"
18
			},
19
			// Work with the response
20
			success: function( response ) {
21
				if(response.success && response.type=='redirect'){
22
					document.location = response.url;
23
				}
24
			}
25
		});
13583 anikendra 26
	});
13599 anikendra 27
	$('.row').on('click','.likedeal',function(e){		
13583 anikendra 28
		var that = $(this);
13682 anikendra 29
		if($(that).hasClass('active')){
13583 anikendra 30
			//User has already liked it,so remove like
31
			var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/like";	
32
		}else{
33
			var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/like";
34
		}
35
		$.ajax({
36
			url: url,
37
			// The name of the callback parameter, as specified by the YQL service
38
			jsonp: "callback",
39
			// Tell jQuery we're expecting JSONP
40
			dataType: "jsonp",
41
			// Tell YQL what we want and that we want JSON
42
			data: {
43
				format: "json"
44
			},
45
			// Work with the response
46
			success: function( response ) {
47
				if(response.success){
13672 anikendra 48
					$(that).toggleClass('active');
49
					$(that).parent().find('li.dislikedeal',0).removeClass('active');
13583 anikendra 50
				}
51
			}
52
		});
53
	});
13682 anikendra 54
	$('.row').on('click','#unlikebtn',function(e){
55
		e.preventDefault();
56
		var url = $('#unlikeproductform').attr('action')+'?'+$('#unlikeproductform').serialize()
57
		console.log(url);
58
		$.ajax({
59
			url: url,
60
			// The name of the callback parameter, as specified by the YQL service
61
			jsonp: "callback",
62
			// Tell jQuery we're expecting JSONP
63
			dataType: "jsonp",
64
			// Tell YQL what we want and that we want JSON
65
			data: {
66
				format: "json"
67
			},
68
			// Work with the response
69
			success: function( response ) {
70
				// console.log(response);						
71
			}
72
		});
73
		$('#myModal').modal('hide');
74
	})
75
	$('.row').on('click','.dislikedeal',function(e){			
13583 anikendra 76
		var that = $(this);
13682 anikendra 77
		if($(that).hasClass('active')){
13583 anikendra 78
			//User has already liked it,so remove like
79
			var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/dislike";	
80
		}else{
13682 anikendra 81
			console.log('show modal');
82
			$('#myModal').find('#productToHide',0).val($(this).data('id'));
83
			$('#myModal').modal();
13583 anikendra 84
			var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/dislike";
85
		}
86
		$.ajax({
87
			url: url,
88
			// The name of the callback parameter, as specified by the YQL service
89
			jsonp: "callback",
90
			// Tell jQuery we're expecting JSONP
91
			dataType: "jsonp",
92
			// Tell YQL what we want and that we want JSON
93
			data: {
94
				format: "json"
95
			},
96
			// Work with the response
97
			success: function( response ) {
98
				if(response.success){
13672 anikendra 99
					$(that).toggleClass('active');
100
					$(that).parent().find('li.likedeal',0).removeClass('active');
13583 anikendra 101
				}
102
			}
103
		});
104
	});
13599 anikendra 105
});