Subversion Repositories SmartDukaan

Rev

Rev 24371 | Rev 24378 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24371 Rev 24376
Line 464... Line 464...
464
	
464
	
465
}
465
}
466
function getItemAheadOptions(jqElement, callback) {
466
function getItemAheadOptions(jqElement, callback) {
467
	jqElement.typeahead('destroy').typeahead({
467
	jqElement.typeahead('destroy').typeahead({
468
		source: function(q, process) {
468
		source: function(q, process) {
469
			if(q.length <= 3) {
-
 
470
				if(typeof queryData != "undefined") {
-
 
471
					queryData = undefined;
-
 
472
				}
-
 
473
				return;
-
 
474
			} else if (q.length > 3 && typeof queryData == "undefined"){
469
			if (q.length >= 3 && typeof queryData == "undefined"){
475
				return $.ajax(context+"/item", {
470
				return $.ajax(context+"/item", {
476
					global:false,
471
					global:false,
477
					data: {query : q}, 
472
					data: {query : q}, 
478
					success: function(data){
473
					success: function(data){
479
						queryData = JSON.parse(data);
474
						queryData = JSON.parse(data);
480
						process(queryData);
475
						process(queryData);
481
					},
476
					},
482
				});
477
				});
483
			} else {
-
 
484
				return process(queryData);
-
 
485
			}
-
 
486
			return;
478
			return;
487
		},
479
		},
488
		delay: 400,
480
		delay: 400,
489
		items: 20,
481
		items: 20,
490
		displayText: function(item){return item.itemDescription;},
482
		displayText: function(item){return item.itemDescription;},
Line 493... Line 485...
493
	});
485
	});
494
}
486
}
495
function getPartnerAheadOptions(jqElement, callback) {
487
function getPartnerAheadOptions(jqElement, callback) {
496
	jqElement.typeahead('destroy').typeahead({
488
	jqElement.typeahead('destroy').typeahead({
497
		source: function(q, process) {
489
		source: function(q, process) {
498
			if(q.length <= 3) {
490
			if (q.length >= 3){
499
				if(typeof queryData != "undefined") {
-
 
500
					queryData = undefined;
-
 
501
				}
-
 
502
				return;
-
 
503
			} else if (q.length > 3 && typeof queryData == "undefined"){
-
 
504
				return $.ajax(context+"/partners", {
491
				return $.ajax(context+"/partners", {
505
					global:false,
492
					global:false,
506
					data: {query : q}, 
493
					data: {query : q}, 
507
					success: function(data){
494
					success: function(data){
508
						queryData = JSON.parse(data);
495
						queryData = JSON.parse(data);
509
						process(queryData);
496
						process(queryData);
510
					},
497
					},
511
				});
498
				});
512
			} else {
-
 
513
				return process(queryData);
-
 
514
			}
499
			}
515
			return;
-
 
516
		},
500
		},
517
		delay: 400,
501
		delay: 300,
518
		items: 20,
502
		items: 20,
519
		displayText: function(partner){return partner.displayName;},
503
		displayText: function(partner){return partner.displayName;},
520
		autoSelect: true,
504
		autoSelect: true,
521
		afterSelect: callback
505
		afterSelect: callback
522
	});
506
	});