Subversion Repositories SmartDukaan

Rev

Rev 24766 | Go to most recent revision | Details | 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
 
28
	$("#submitFeature").live('click', function() {
29
				var editorData = CKEDITOR.instances['featureEditor'].getData();
30
				console.log(editorData)
31
				var catalogItemid = $('#catalogItemid').val();
32
				var rankPoints = $('#rankPoints').val();
33
				var featureData = {};
34
				if (catalogItemid === "" && rankPoints === ""
35
						&& editorData === "") {
36
					alert("Field can't be empty");
37
					return;
38
				}
39
				if (catalogItemid === "") {
40
					alert("Catalog Item Id is required");
41
					return;
42
				}
43
				if (rankPoints === "") {
44
					alert("Rank Point is required");
45
					return;
46
				}
47
				if (editorData === "") {
48
					alert("Editor Data is required");
49
					return;
50
				}
51
 
52
				featureData['feature'] = editorData;
53
				featureData['catalogItemId'] = $('#catalogItemid').val();
54
				featureData['rankPoints'] = $('#rankPoints').val();
55
				console.log(featureData)
56
				console.log(JSON.stringify(featureData))
57
				if (confirm("Are you sure you want add item feature") == true) {
58
					doPostAjaxRequestWithJsonHandler(context + "/itemfeature",
59
							JSON.stringify(featureData), function(response) {
60
								if (response == 'true') {
61
									alert("successfully add feature");
62
									loadFeaturePanel("main-content");
63
								}
64
							});
65
 
66
					return false;
67
				}
68
			});
69
 
70
	$(".editfeature").live('click', function() {
71
		rank = $(this).data('rank');
72
		catalogItemId = $(this).data('requestid');
73
		$('#catalogItemid').attr('readonly', true);
74
		feature = $(this).data('feature');
75
		$('#catalogItemid').val(catalogItemId);
76
		$('#rankPoints').val(rank);
77
		CKEDITOR.instances['featureEditor'].setData(feature);
78
		console.log(rank);
79
		console.log(catalogItemId);
80
		console.log(feature);
81
 
82
	});
83
 
84
});
85
 
86
function loadFeaturePanel(domId) {
87
 
88
	doGetAjaxRequestHandler(context + "/featurePanel", function(response) {
89
		$('#' + domId).html(response);
90
 
91
		CKEDITOR.replace("featureEditor");
92
		console.log(response);
93
 
94
	});
95
 
96
}