Subversion Repositories SmartDukaan

Rev

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