Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
24440 amit.gupta 1
var logosmapping = {
24595 tejbeer 2
	mobile_insurance_providers : {
3
		"0" : context + '/resources/images/icons/provider-logos/iffco.png',
4
		"1" : context + '/resources/images/icons/provider-logos/icici.jpg',
5
		"2" : context + '/resources/images/icons/provider-logos/tataaig.png'
6
	}
24440 amit.gupta 7
}
24595 tejbeer 8
function badRequestAlert(response) {
22956 ashik.ali 9
	console.log(response.responseText);
10
	var errorObject = JSON.parse(response.responseText);
11
	errorObject = errorObject.response;
24595 tejbeer 12
	bootbox.alert('Bad Request\n' + 'rejectedType : '
13
			+ errorObject.rejectedType + '\n' + 'rejectedValue : '
14
			+ errorObject.rejectedValue + '\n' + 'message : '
15
			+ errorObject.message);
22956 ashik.ali 16
}
24595 tejbeer 17
 
18
function internalServerErrorAlert(response) {
22956 ashik.ali 19
	console.log(response.responseText);
20
	var errorObject = JSON.parse(response.responseText);
21
	errorObject = errorObject.response;
24595 tejbeer 22
	bootbox.alert('Internal Server Error\n' + 'rejectedType : '
23
			+ errorObject.rejectedType + '\n' + 'rejectedValue : '
24
			+ errorObject.rejectedValue + '\n' + 'message : '
25
			+ errorObject.message);
22956 ashik.ali 26
}
27
 
24595 tejbeer 28
$(document).ajaxError(function(event, jqxhr, settings, thrownError) {
29
	if (typeof loaderDialogObj != "undefined")
24271 amit.gupta 30
		loaderDialogObj.modal('hide');
24595 tejbeer 31
	if (jqxhr.status == 400) {
23872 amit.gupta 32
		// $('#error-prompt-model').modal();
24595 tejbeer 33
		badRequestAlert(jqxhr);
34
	} else {
22956 ashik.ali 35
		internalServerErrorAlert(jqxhr);
36
	}
37
});
38
 
24595 tejbeer 39
$(document).ajaxComplete(function() {
40
	if (typeof loaderDialogObj != "undefined")
24271 amit.gupta 41
		loaderDialogObj.modal('hide');
23946 amit.gupta 42
});
24992 tejbeer 43
function ajaxStartHandler() {
24976 amit.gupta 44
	if (typeof loaderDialogObj != "undefined")
45
		loaderDialogObj.modal('show');
46
	if (typeof isInvestmentOk != "undefined" && !isInvestmentOk
47
			&& $('#order-details').length == 0) {
24992 tejbeer 48
		var investmentDialog = bootbox
49
				.dialog({
50
					title : '<h3	class="text-danger">ATTENTION!! ORDERING THROUGH APP MAY BE BLOCKED DUE TO LOW INVESTMENTS!</h3>',
51
					message : "<h3>Dear Partner, your investments are low by "
52
							+ shortPercentage
53
							+ "%</h3>"
54
							+ "<dl>"
55
							+ "<dt>Investment Should be</dt><dd>- "
56
							+ minimumInvestmentAmount
57
							+ "</dd>"
58
							+ "<dt>Total Invested Amount</dt><dd>-"
59
							+ totalInvestedAmount
60
							+ "</dd>"
61
							+ '<dt>Investment Amount Short By</dt><dd class="text-danger lead">-  '
62
							+ shortAmount
63
							+ '</dd></dl>'
64
							+ '<pre class="text-danger" style="font-size:18px;"><strong>To unblock your Billing, please \nadd Rs.'
65
							+ minAmountToBeAdded
66
							+ ' to wallet immediately.</strong></pre>',
67
					buttons : {
68
						cancel : {
69
							label : "OK",
70
							className : 'btn-primary'
71
						}
24595 tejbeer 72
					}
24992 tejbeer 73
				});
24976 amit.gupta 74
		investmentDialog.on('shown.bs.modal', function() {
24992 tejbeer 75
			var dialogEl = investmentDialog.find('.modal-content')[0];
76
			var dialogRect = dialogEl.getBoundingClientRect();
77
			var height = window.innerHeight - dialogRect.height;
78
			var width = window.innerWidth - dialogRect.width;
79
			var left = Math.floor(Math.random() * width) - dialogRect.left
80
			var top = Math.floor(Math.random() * height) - dialogRect.top
81
			$(dialogEl).css("left", left).css("top", top);
24976 amit.gupta 82
		});
83
	}
84
}
85
$(document).ajaxStart(ajaxStartHandler);
24595 tejbeer 86
 
87
function doAjaxRequestWithParamsHandler(urlString, httpType, params,
88
		callback_function) {
89
	$.ajax({
90
		url : urlString,
91
		async : true,
92
		cache : false,
93
		data : params,
94
		// dataType:'json',
95
		type : httpType,
96
		success : function(response) {
97
			callback_function(response);
98
			$('.currency').each(function(index, ele) {
99
				if (!isNaN(parseInt($(ele).html()))) {
100
					$(ele).html(numberToComma($(ele).html()));
101
				}
23918 amit.gupta 102
			});
103
		}
104
	});
23193 ashik.ali 105
}
106
 
24595 tejbeer 107
function doGetAjaxRequestWithParamsHandler(urlString, params, callback_function) {
23500 ashik.ali 108
	doAjaxRequestWithParamsHandler(urlString, "GET", params, callback_function);
109
}
110
 
24595 tejbeer 111
function doPostAjaxRequestWithParamsHandler(urlString, params,
112
		callback_function) {
23500 ashik.ali 113
	doAjaxRequestWithParamsHandler(urlString, "POST", params, callback_function);
114
}
115
 
24595 tejbeer 116
function doAjaxRequestWithJsonHandler(urlString, httpType, json,
117
		callback_function) {
23032 ashik.ali 118
	$.ajax({
24595 tejbeer 119
		url : urlString,
120
		async : true,
121
		cache : false,
122
		processData : false,
123
		data : json,
124
		contentType : 'application/json',
125
		type : httpType,
126
		success : function(response) {
127
			// console.log("response"+JSON.stringify(data));
128
			callback_function(response);
129
			$('.currency').each(function(index, ele) {
130
				if (!isNaN(parseInt($(ele).html()))) {
131
					$(ele).html(numberToComma($(ele).html()));
132
				}
133
			});
134
		}
23032 ashik.ali 135
	});
136
}
137
 
24595 tejbeer 138
function doPostAjaxRequestWithJsonHandler(urlString, json, callback_function) {
23500 ashik.ali 139
	doAjaxRequestWithJsonHandler(urlString, "POST", json, callback_function);
140
}
23032 ashik.ali 141
 
24595 tejbeer 142
function doPutAjaxRequestWithJsonHandler(urlString, json, callback_function) {
23500 ashik.ali 143
	doAjaxRequestWithJsonHandler(urlString, "PUT", json, callback_function);
144
}
145
 
24595 tejbeer 146
function doAjaxRequestHandler(urlString, httpType, callback_function) {
22982 ashik.ali 147
	$.ajax({
24595 tejbeer 148
		url : urlString,
149
		async : true,
150
		cache : false,
151
		type : httpType,
152
		success : function(response) {
153
			callback_function(response);
154
			$('.currency').each(function(index, ele) {
155
				if (!isNaN(parseInt($(ele).html()))) {
156
					$(ele).html(numberToComma($(ele).html()));
157
				}
158
			});
159
		}
22982 ashik.ali 160
	});
161
}
162
 
24595 tejbeer 163
function doGetAjaxRequestHandler(urlString, callback_function) {
23500 ashik.ali 164
	doAjaxRequestHandler(urlString, "GET", callback_function);
165
}
166
 
24595 tejbeer 167
function doPutAjaxRequestHandler(urlString, callback_function) {
23500 ashik.ali 168
	doAjaxRequestHandler(urlString, "PUT", callback_function);
169
}
170
 
24595 tejbeer 171
function doPostAjaxRequestHandler(urlString, callback_function) {
23629 ashik.ali 172
	doAjaxRequestHandler(urlString, "POST", callback_function);
173
}
174
 
24595 tejbeer 175
function doDeleteAjaxRequestHandler(urlString, callback_function) {
23783 ashik.ali 176
	doAjaxRequestHandler(urlString, "DELETE", callback_function);
177
}
178
 
24595 tejbeer 179
function doAjaxUploadRequest(urlString, httpType, file) {
23347 ashik.ali 180
	var response;
24595 tejbeer 181
	doAjaxUploadRequestHandler(urlString, httpType, file,
182
			function(ajaxResponse) {
183
				response = ajaxResponse;
184
			});
23347 ashik.ali 185
	return response;
186
}
187
 
24595 tejbeer 188
function doAjaxUploadRequestHandler(urlString, httpType, file,
189
		callback_function) {
22982 ashik.ali 190
	var formData = new FormData();
191
	formData.append("file", file);
192
	$.ajax({
24595 tejbeer 193
		url : urlString,
194
		type : httpType,
195
		data : formData,
196
		dataType : 'json',
197
		async : true,
198
		cache : false,
199
		contentType : false,
200
		enctype : 'multipart/form-data',
201
		processData : false,
202
		success : function(response) {
203
			// console.log("response"+JSON.stringify(data));
204
			callback_function(response);
205
		}
22982 ashik.ali 206
	});
207
}
24595 tejbeer 208
function doAjaxUploadRequestJsonHandler(urlString, httpType, file, json,
209
		callback_function) {
24171 govind 210
	var formData = new FormData();
211
	formData.append("file", file);
24595 tejbeer 212
	formData.append('json', new Blob([ json ]));
24171 govind 213
	$.ajax({
24595 tejbeer 214
		url : urlString,
215
		type : httpType,
216
		data : formData,
217
		enctype : 'multipart/form-data',
218
		contentType : false,
219
		processData : false,
220
		success : function(response) {
221
			// console.log("response"+JSON.stringify(data));
222
			callback_function(response);
223
		}
24171 govind 224
	});
225
}
22982 ashik.ali 226
 
24595 tejbeer 227
function uploadDocument(file) {
228
	var url = webApiScheme + '://' + webApiHost + ':' + webApiPort + webApiRoot
229
			+ '/document-upload';
230
	doAjaxUploadRequestHandler(url, 'POST', file, function(response) {
231
		var documentId = response.response.document_id;
232
		console.log("documentId : " + documentId);
23377 ashik.ali 233
		return documentId;
234
	});
23347 ashik.ali 235
}
236
 
24595 tejbeer 237
function doAjaxGetDownload(urlString, fileName) {
238
	console.log("fileName : " + fileName);
23343 ashik.ali 239
	doAjaxDownload(urlString, "GET", null, fileName);
22982 ashik.ali 240
}
241
 
24595 tejbeer 242
function doAjaxPostDownload(urlString, data, fileName) {
23343 ashik.ali 243
	doAjaxDownload(urlString, "POST", data, fileName);
21627 kshitij.so 244
}
245
 
24595 tejbeer 246
function doAjaxDownload(urlString, httpType, data, fileName) {
22488 ashik.ali 247
	xhttp = new XMLHttpRequest();
248
	xhttp.onreadystatechange = function() {
24595 tejbeer 249
		var a;
250
		if (xhttp.readyState === 2) {
251
			if (xhttp.status == 200) {
252
				xhttp.responseType = "blob";
253
			} else {
254
				xhttp.responseType = "text";
255
			}
256
		} else if (xhttp.readyState === 4 && xhttp.status === 200) {
257
			// Trick for making downloadable link
24976 amit.gupta 258
			if (typeof loaderDialogObj != "undefined")
259
				loaderDialogObj.modal('hide');
24595 tejbeer 260
			a = document.createElement('a');
261
			a.href = window.URL.createObjectURL(xhttp.response);
262
			// Give filename you wish to download
263
			a.download = fileName;
264
			a.style.display = 'none';
265
			document.body.appendChild(a);
266
			a.click();
267
		} else if (xhttp.readyState == 4 && xhttp.status === 400) {
24976 amit.gupta 268
			if (typeof loaderDialogObj != "undefined")
269
				loaderDialogObj.modal('hide');
24595 tejbeer 270
			badRequestAlert(xhttp);
271
		} else if (xhttp.readyState == 4 && xhttp.status === 500) {
24976 amit.gupta 272
			if (typeof loaderDialogObj != "undefined")
273
				loaderDialogObj.modal('hide');
24595 tejbeer 274
			internalServerErrorAlert(xhttp);
275
		}
22488 ashik.ali 276
	};
277
	// Post data to URL which handles post request
23343 ashik.ali 278
	xhttp.open(httpType, urlString);
24595 tejbeer 279
	if (httpType == "POST") {
23343 ashik.ali 280
		xhttp.setRequestHeader("Content-Type", "application/json");
281
	}
22488 ashik.ali 282
	// You should set responseType as blob for binary responses
23872 amit.gupta 283
	// xhttp.responseType = 'blob';
22488 ashik.ali 284
	xhttp.send(data);
23405 amit.gupta 285
}
286
 
24595 tejbeer 287
function loadPaginatedNextItems(url, params, paginatedIdentifier,
288
		tableIdentifier, detailsContainerIdentifier) {
289
	var start = $("#" + paginatedIdentifier + " .start").text();
290
	var end = $("#" + paginatedIdentifier + " .end").text();
23629 ashik.ali 291
	url = context + url + "?offset=" + end;
24595 tejbeer 292
 
293
	if (params != null) {
294
		for ( var key in params) {
23629 ashik.ali 295
			if (params.hasOwnProperty(key)) {
23872 amit.gupta 296
				// console.log(key + " -> " + p[key]);
24595 tejbeer 297
				url = url + "&" + key + "=" + params[key];
23629 ashik.ali 298
			}
299
		}
300
	}
24595 tejbeer 301
 
302
	doGetAjaxRequestHandler(url, function(response) {
303
		var size = $("#" + paginatedIdentifier + " .size").text();
304
		if ((parseInt(end) + 10) > parseInt(size)) {
23629 ashik.ali 305
			console.log("(end + 10) > size == true");
24595 tejbeer 306
			$("#" + paginatedIdentifier + " .end").text(size);
307
		} else {
23629 ashik.ali 308
			console.log("(end + 10) > size == false");
24595 tejbeer 309
			$("#" + paginatedIdentifier + " .end").text(+end + +10);
23629 ashik.ali 310
		}
24595 tejbeer 311
		$("#" + paginatedIdentifier + " .start").text(+start + +10);
312
		var last = $("#" + paginatedIdentifier + " .end").text();
313
		var temp = $("#" + paginatedIdentifier + " .size").text();
314
		if (parseInt(last) >= parseInt(temp)) {
315
			$("#" + paginatedIdentifier + " .next").prop('disabled', true);
23872 amit.gupta 316
			// $( "#good-inventory-paginated .end" ).text(temp);
23629 ashik.ali 317
		}
24595 tejbeer 318
		$('#' + tableIdentifier).html(response);
319
		if (detailsContainerIdentifier != null) {
320
			$('#' + detailsContainerIdentifier).html('');
23629 ashik.ali 321
		}
24595 tejbeer 322
		$("#" + paginatedIdentifier + " .previous").prop('disabled', false);
23629 ashik.ali 323
	});
24595 tejbeer 324
 
23629 ashik.ali 325
}
23405 amit.gupta 326
 
24595 tejbeer 327
function loadPaginatedPreviousItems(url, params, paginatedIdentifier,
328
		tableIdentifier, detailsContainerIdentifier) {
329
	var start = $("#" + paginatedIdentifier + " .start").text();
330
	var end = $("#" + paginatedIdentifier + " .end").text();
331
	var size = $("#" + paginatedIdentifier + " .size").text();
332
	if (parseInt(end) == parseInt(size) && parseInt(end) % 10 != 0) {
23629 ashik.ali 333
		var mod = parseInt(end) % 10;
24595 tejbeer 334
		end = parseInt(end) + (10 - mod);
23629 ashik.ali 335
	}
336
	var pre = end - 20;
24595 tejbeer 337
 
23629 ashik.ali 338
	url = context + url + "?offset=" + pre;
24595 tejbeer 339
 
340
	if (params != null) {
341
		for ( var key in params) {
23629 ashik.ali 342
			if (params.hasOwnProperty(key)) {
24595 tejbeer 343
				url = url + "&" + key + "=" + params[key];
23629 ashik.ali 344
			}
345
		}
346
	}
24595 tejbeer 347
 
348
	doGetAjaxRequestHandler(url, function(response) {
349
		$("#" + paginatedIdentifier + " .end").text(+end - +10);
350
		$("#" + paginatedIdentifier + " .start").text(+start - +10);
351
		$('#' + tableIdentifier).html(response);
352
		if (detailsContainerIdentifier != null) {
353
			$('#' + detailsContainerIdentifier).html('');
23629 ashik.ali 354
		}
24595 tejbeer 355
		$("#" + paginatedIdentifier + " .next").prop('disabled', false);
356
		if (parseInt(pre) == 0) {
357
			$("#" + paginatedIdentifier + " .previous").prop('disabled', true);
23629 ashik.ali 358
		}
24595 tejbeer 359
	});
360
 
23629 ashik.ali 361
}
362
 
23405 amit.gupta 363
function numberToComma(x) {
24992 tejbeer 364
 
24595 tejbeer 365
	x = x.toString();
24992 tejbeer 366
	x = x.split('.');
367
	var x1 = x[0];
368
	var x2 = x.length > 1 ? '.' + x[1] : '';
369
	var lastThree = x1.substring(x1.length - 3);
25066 tejbeer 370
	var otherNumbers = x1.substring(0, x1.length - 3);
371
	if(x1.charAt(x1.length-4)==',' || x1.charAt(x1.length-4)=='-'){
24992 tejbeer 372
	console.log(lastThree)
25066 tejbeer 373
	}
374
	else{
24595 tejbeer 375
	if (otherNumbers != '')
376
		lastThree = ',' + lastThree;
25066 tejbeer 377
	}
24992 tejbeer 378
	return otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + (lastThree)
379
			+ x2;
380
 
23786 amit.gupta 381
}
23870 amit.gupta 382
 
383
function dateRangeCallback(start, end) {
23886 amit.gupta 384
	startMoment = start;
385
	endMoment = end;
386
	startDate = start.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
387
	endDate = end.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
23872 amit.gupta 388
}
389
 
24595 tejbeer 390
function getSingleDatePicker() {
391
	var singleDatePicker = {
392
		"todayHighlight" : true,
393
		"startDate" : startMoment || moment(),
394
		"autoclose" : true,
395
		"autoUpdateInput" : true,
396
		"singleDatePicker" : true,
397
		"locale" : {
398
			'format' : 'DD/MM/YYYY'
399
		}
400
	};
23872 amit.gupta 401
	return singleDatePicker;
23886 amit.gupta 402
}
403
 
24595 tejbeer 404
function getRangedDatePicker(showRanges) {
405
	if (typeof showRanges == "undefined") {
23886 amit.gupta 406
		showRanges = false;
407
	}
24595 tejbeer 408
	var rangedDatePicker = {
409
		"todayHighlight" : true,
410
		"opens" : "right",
411
		"startDate" : startMoment || moment(),
412
		"endDate" : endMoment || moment(),
413
		"autoclose" : true,
414
		"alwaysShowCalendars" : false,
415
		"autoUpdateInput" : true,
416
		"locale" : {
417
			'format' : 'DD/MM/YYYY'
418
		}
23886 amit.gupta 419
	};
24595 tejbeer 420
	if (showRanges) {
421
		rangedDatePicker['ranges'] = {
422
			'Today' : [ moment(), moment() ],
423
			'Yesterday' : [ moment().subtract(1, 'days'),
424
					moment().subtract(1, 'days') ],
425
			'Last 7 Days' : [ moment().subtract(6, 'days'), moment() ],
426
			'Last 30 Days' : [ moment().subtract(29, 'days'), moment() ],
427
			'This Month' : [ moment().startOf('month'), moment().endOf('month') ],
428
			'Last Month' : [ moment().subtract(1, 'month').startOf('month'),
429
					moment().subtract(1, 'month').endOf('month') ]
430
		}
23886 amit.gupta 431
	}
432
	return rangedDatePicker;
23892 amit.gupta 433
}
23946 amit.gupta 434
function showPosition(position) {
24595 tejbeer 435
	if (typeof latitude == "undefined") {
436
		var coords = {
437
			latitude : position.coords.latitude,
438
			longitude : position.coords.longitude
439
		}
440
		doAjaxRequestWithJsonHandler('partner/location', 'PUT', JSON
441
				.stringify(coords), function() {
24016 amit.gupta 442
			latitude = position.coords.latitude;
443
			longitude = position.coords.longitude;
24052 amit.gupta 444
		});
445
	}
24176 amit.gupta 446
	// distance = getDistance(latitude, longitude, position.coords.latitude,
447
	// position.coords.longitude);
24168 amit.gupta 448
}
449
 
24595 tejbeer 450
function getAuthorisedWarehouses(callback) {
451
	bootBoxObj = {
452
		size : "small",
453
		title : "Choose Warehouse",
454
		callback : callback,
455
		inputType : 'select',
456
		inputOptions : typeof inputOptions == "undefined" ? undefined
457
				: inputOptions
24168 amit.gupta 458
	}
24595 tejbeer 459
	if (typeof inputOptions == "undefined") {
460
		doGetAjaxRequestHandler(context + "/authorisedWarehouses", function(
461
				response) {
24168 amit.gupta 462
			response = JSON.parse(response);
463
			inputOptions = [];
24595 tejbeer 464
			response.forEach(function(warehouse) {
24168 amit.gupta 465
				inputOptions.push({
24595 tejbeer 466
					text : warehouse.name,
467
					value : warehouse.id,
24168 amit.gupta 468
				});
469
			});
470
			bootBoxObj['inputOptions'] = inputOptions;
471
			bootbox.prompt(bootBoxObj);
472
		});
24595 tejbeer 473
	} else if (inputOptions.length == 1) {
24168 amit.gupta 474
		callback(inputOptions[0].warehouse.id);
24595 tejbeer 475
	} else {
24168 amit.gupta 476
		bootbox.prompt(bootBoxObj);
477
	}
24595 tejbeer 478
 
24176 amit.gupta 479
}
24410 amit.gupta 480
function getColorsForItems(catalogId, itemId, description, callback) {
24595 tejbeer 481
	bootBoxObj = {
482
		size : "small",
483
		className : "item-wrapper",
484
		title : description,
485
		callback : callback,
486
		inputType : 'checkbox',
24349 amit.gupta 487
	}
24595 tejbeer 488
	doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
489
			+ catalogId + "&itemId=" + itemId, function(response) {
24406 amit.gupta 490
		coloredItems = JSON.parse(response);
24595 tejbeer 491
		inputOptions = [ {
492
			text : "All",
493
			value : "0",
494
			onclick : "toggleAll('itemIds')"
495
		} ];
496
		coloredItems.forEach(function(item) {
24406 amit.gupta 497
			inputOptions.push({
24595 tejbeer 498
				text : item.color,
499
				value : item.id,
500
				selected : item.active
24349 amit.gupta 501
			});
502
		});
24406 amit.gupta 503
		bootBoxObj['inputOptions'] = inputOptions;
24349 amit.gupta 504
		bootbox.prompt(bootBoxObj);
24595 tejbeer 505
		$('.item-wrapper').find('input[type="checkbox"]').slice(1).each(
506
				function(index, checkbox) {
507
					checkbox.checked = coloredItems[index].active;
508
				});
24406 amit.gupta 509
	});
510
}
24595 tejbeer 511
$(".item-wrapper").find("input[type='checkbox']:first").live(
512
		'change',
513
		function() {
514
			if (this.value == "0") {
515
				$(this).closest('.item-wrapper').find("input[type='checkbox']")
516
						.slice(1).prop('checked', $(this).prop('checked'));
517
			}
518
		});
24176 amit.gupta 519
function getItemAheadOptions(jqElement, callback) {
520
	jqElement.typeahead('destroy').typeahead({
24595 tejbeer 521
		source : function(q, process) {
522
			if (q.length >= 3) {
523
				return $.ajax(context + "/item", {
524
					global : false,
525
					data : {
526
						query : q
527
					},
528
					success : function(data) {
24191 amit.gupta 529
						queryData = JSON.parse(data);
530
						process(queryData);
24176 amit.gupta 531
					},
532
				});
24378 amit.gupta 533
			}
24176 amit.gupta 534
		},
24595 tejbeer 535
		delay : 400,
536
		items : 20,
537
		displayText : function(item) {
538
			return item.itemDescription;
539
		},
540
		autoSelect : true,
541
		afterSelect : callback
24176 amit.gupta 542
	});
543
}
24349 amit.gupta 544
function getPartnerAheadOptions(jqElement, callback) {
545
	jqElement.typeahead('destroy').typeahead({
24595 tejbeer 546
		source : function(q, process) {
547
			if (q.length >= 3) {
548
				return $.ajax(context + "/partners", {
549
					global : false,
550
					data : {
551
						query : q
552
					},
553
					success : function(data) {
24349 amit.gupta 554
						queryData = JSON.parse(data);
555
						process(queryData);
556
					},
557
				});
558
			}
559
		},
24595 tejbeer 560
		delay : 300,
561
		items : 20,
562
		displayText : function(partner) {
563
			return partner.displayName;
564
		},
565
		autoSelect : true,
566
		afterSelect : callback
24349 amit.gupta 567
	});
568
}
24406 amit.gupta 569
 
24595 tejbeer 570
function loadPriceDrop(domId) {
571
	doGetAjaxRequestHandler(context + "/getItemDescription",
572
			function(response) {
573
				$('#' + domId).html(response);
574
			});
24406 amit.gupta 575
}
576
$(".price_drop").live('click', function() {
577
	loadPriceDrop("main-content");
24595 tejbeer 578
});