Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
24106 tejbeer 1
$(function() {
2
 
3
	$(".feature").live('click', function() {
4
		loadFeaturePanel("main-content");
5
	});
6
 
7
	$("#feature-paginated .next").live(
8
			'click',
9
			function() {
10
				loadPaginatedNextItems('/getPaginatedfeature', null,
11
						'feature-paginated', 'feature-table',
12
						'feature-container');
13
 
14
				$(this).blur();
15
			});
16
 
17
	$("#feature-paginated .previous").live(
18
			'click',
19
			function() {
20
 
21
				loadPaginatedPreviousItems('/getPaginatedfeature', null,
22
						'feature-paginated', 'feature-table',
23
						'feature-container');
24
 
25
				$(this).blur();
26
			});
27
 
24766 tejbeer 28
	$("#submitFeature").live(
29
			'click',
30
			function() {
24106 tejbeer 31
				var editorData = CKEDITOR.instances['featureEditor'].getData();
32
				console.log(editorData)
33
				var catalogItemid = $('#catalogItemid').val();
34
				var rankPoints = $('#rankPoints').val();
35
				var featureData = {};
36
				if (catalogItemid === "" && rankPoints === ""
37
						&& editorData === "") {
38
					alert("Field can't be empty");
39
					return;
40
				}
41
				if (catalogItemid === "") {
42
					alert("Catalog Item Id is required");
43
					return;
44
				}
45
				if (rankPoints === "") {
46
					alert("Rank Point is required");
47
					return;
48
				}
49
 
50
				featureData['feature'] = editorData;
51
				featureData['catalogItemId'] = $('#catalogItemid').val();
52
				featureData['rankPoints'] = $('#rankPoints').val();
53
				console.log(featureData)
54
				console.log(JSON.stringify(featureData))
55
				if (confirm("Are you sure you want add item feature") == true) {
56
					doPostAjaxRequestWithJsonHandler(context + "/itemfeature",
57
							JSON.stringify(featureData), function(response) {
58
								if (response == 'true') {
59
									alert("successfully add feature");
60
									loadFeaturePanel("main-content");
61
								}
62
							});
63
 
64
					return false;
65
				}
66
			});
67
 
68
	$(".editfeature").live('click', function() {
69
		rank = $(this).data('rank');
70
		catalogItemId = $(this).data('requestid');
71
		$('#catalogItemid').attr('readonly', true);
72
		feature = $(this).data('feature');
73
		$('#catalogItemid').val(catalogItemId);
74
		$('#rankPoints').val(rank);
75
		CKEDITOR.instances['featureEditor'].setData(feature);
76
		console.log(rank);
77
		console.log(catalogItemId);
78
		console.log(feature);
79
 
80
	});
81
 
82
});
83
 
84
function loadFeaturePanel(domId) {
85
 
86
	doGetAjaxRequestHandler(context + "/featurePanel", function(response) {
87
		$('#' + domId).html(response);
24766 tejbeer 88
 
24106 tejbeer 89
		CKEDITOR.replace("featureEditor");
90
		console.log(response);
91
 
92
	});
93
 
94
}