Subversion Repositories SmartDukaan

Rev

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

Rev 15065 Rev 15077
Line 454... Line 454...
454
	var cname = 'notif-count-'+me+'-'+id;
454
	var cname = 'notif-count-'+me+'-'+id;
455
	var cookieval = getCookie(cname);
455
	var cookieval = getCookie(cname);
456
	var cname = 'notif-lastshown-'+me+'-'+id;
456
	var cname = 'notif-lastshown-'+me+'-'+id;
457
	var lastshown = getCookie(cname);
457
	var lastshown = getCookie(cname);
458
	if(cookieval==''){		
458
	if(cookieval==''){		
459
		incrementPopupCount(id,0);
459
		incrementPopupCount(id,0,'notif-count-');
460
		setLastShown(id);
460
		setLastShown(id,'notif-lastshown-');
461
		return true;
461
		return true;
462
	} else{
462
	} else{
463
		var d = new Date();
463
		var d = new Date();
464
		var t = d.getTime();
464
		var t = d.getTime();
465
		console.log(t-lastshown);
465
		console.log(t-lastshown);
466
		console.log(interval*60*1000);
466
		console.log(interval*60*1000);
467
		if(t-lastshown>interval*60*1000){
467
		if(t-lastshown>interval*60*1000){
468
			if(cookieval>=count){
468
			if(cookieval>=count){
469
				return false;
469
				return false;
470
			}else{
470
			}else{
471
				setLastShown(id);
471
				setLastShown(id,'notif-lastshown-');
472
				incrementPopupCount(id,cookieval);
472
				incrementPopupCount(id,cookieval,'notif-count-');
473
				return true;	
473
				return true;	
474
			}
474
			}
475
		}
475
		}
476
	}
476
	}
477
}
477
}
478
function setLastShown(id){
478
function setLastShown(id,cookiename){
479
	var cname = 'notif-lastshown-'+me+'-'+id;
479
	var cname = cookiename+me+'-'+id;
480
	var d = new Date();
480
	var d = new Date();
481
	setCookie(cname, d.getTime(), 365);
481
	setCookie(cname, d.getTime(), 365);
482
}
482
}
483
function incrementPopupCount(id,currentCount) {
483
function incrementPopupCount(id,currentCount,cookiename) {
484
	var cname = 'notif-count-'+me+'-'+id;
484
	var cname = cookiename+me+'-'+id;
485
	setCookie(cname, parseInt(currentCount)+1, 365);
485
	setCookie(cname, parseInt(currentCount)+1, 365);
486
}
486
}
487
var hidden, visibilityChange; 
487
var hidden, visibilityChange; 
488
function handleVisibilityChange() {
488
function handleVisibilityChange() {
489
  if (document[hidden]) {
489
  if (document[hidden]) {
Line 505... Line 505...
505
  hidden = "webkitHidden";
505
  hidden = "webkitHidden";
506
  visibilityChange = "webkitvisibilitychange";
506
  visibilityChange = "webkitvisibilitychange";
507
}
507
}
508
if (typeof document.addEventListener === "undefined" || 
508
if (typeof document.addEventListener === "undefined" || 
509
  typeof document[hidden] === "undefined") {
509
  typeof document[hidden] === "undefined") {
510
  alert("This feature requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API.");
510
  console.log("This feature requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API.");
511
} else {
511
} else {
512
  // Handle page visibility change   
512
  // Handle page visibility change   
513
  document.addEventListener(visibilityChange, handleVisibilityChange, false);
513
  document.addEventListener(visibilityChange, handleVisibilityChange, false);
514
}    
514
}    
515
$('.notificationok').on('click',function(e){
515
$('.notificationok').on('click',function(e){
Line 556... Line 556...
556
	var that = $(this);
556
	var that = $(this);
557
	$('li.brand').filter(function() { 
557
	$('li.brand').filter(function() { 
558
	  return $(this).data("brand").toLowerCase().indexOf($(that).val().toLowerCase()) != -1;
558
	  return $(this).data("brand").toLowerCase().indexOf($(that).val().toLowerCase()) != -1;
559
	}).removeClass('hidden','slow');
559
	}).removeClass('hidden','slow');
560
});
560
});
561
$(document).on('click','.brand',function(){
561
$(document).on('click','.filterbrand',function(){
562
	var clicked = $(this);
562
	var clicked = $(this).parent().parent();
-
 
563
	console.log(clicked.prop('class'));
563
	clicked.find('.filterbrand',0).prop('checked',true);
564
	// clicked.find('.filterbrand',0).prop('checked',true);
564
	// all the LIs above the clicked one
565
	// all the LIs above the clicked one
565
	var previousAll = clicked.prevAll();
566
	var previousAll = clicked.prevAll();
566
 
567
 
567
	// only proceed if it's not already on top (no previous siblings)
568
	// only proceed if it's not already on top (no previous siblings)
568
	if(previousAll.length > 0) {
569
	if(previousAll.length > 0) {
Line 600... Line 601...
600
	if(brandschosen && brandschosen.length>0){
601
	if(brandschosen && brandschosen.length>0){
601
		var brands = brandschosen.split(',');
602
		var brands = brandschosen.split(',');
602
		for(var i in brands){
603
		for(var i in brands){
603
			$('.brand').filter(function() { 
604
			$('.brand').filter(function() { 
604
			  	return $(this).data("brandid") == brands[i];
605
			  	return $(this).data("brandid") == brands[i];
605
			}).trigger( "click" ).removeClass('hidden');
606
			}).removeClass('hidden').find('.filterbrand',0).trigger( "click" );
606
		}
607
		}
607
	}
608
	}
608
}
609
}
609
$(function () {
610
$(function () {
-
 
611
	var poid = 'popovertrigger';
-
 
612
	/*
610
  var popovershown = getCookie('popovershown');
613
  var popovershown = getCookie('popovershown');
611
  if(!popovershown){
614
  if(!popovershown){
-
 
615
  	popovershown = 0;
-
 
616
  }
-
 
617
  if(popovershown < 2){
612
  	$('[data-toggle="popover"]').popover({'html':true});
618
  	$('[data-toggle="popover"]').popover({'html':true});
613
  	$('[data-toggle="popover"]').trigger('click');
619
  	$('[data-toggle="popover"]').trigger('click');
614
  }  
620
  }  
-
 
621
  */
615
  $('#dropdownMenu1').on('click',function(){
622
  $('#dropdownMenu1').on('click',function(){
616
  	$('#popovertrigger').popover('hide');
623
  	$('#popovertrigger').popover('hide');
-
 
624
  	incrementPopupCount(poid,0,'popover-count-');
617
  	setCookie('popovershown', 1, 1);
625
	setLastShown(poid,'popover-lastshown-');
618
  })
626
  })
619
})
-
 
620
627
   
-
 
628
  	var cname = 'popover-count-'+me+'-'+poid;
-
 
629
	var cookieval = getCookie(cname);
-
 
630
	var cname = 'popover-lastshown-'+me+'-'+poid;
-
 
631
	var lastshown = getCookie(cname);
-
 
632
	if(cookieval==''){				
-
 
633
		showpopover(poid);
-
 
634
	} else{
-
 
635
		var d = new Date();
-
 
636
		var t = d.getTime();
-
 
637
		console.log('time elapsed '+(t-lastshown));
-
 
638
		if(t-lastshown>1*18*1000){
-
 
639
			if(cookieval>2){
-
 
640
				return false;
-
 
641
			}else{
-
 
642
				showpopover(poid);
-
 
643
			  	incrementPopupCount(poid,cookieval,'popover-count-');
-
 
644
				setLastShown(poid,'popover-lastshown-');
-
 
645
			}
-
 
646
		}
-
 
647
	}
-
 
648
});
-
 
649
function showpopover(id){
-
 
650
	$('[data-toggle="popover"]#'+id).popover({'html':true});
-
 
651
	$('[data-toggle="popover"]#'+id).trigger('click');		
-
 
652
}
-
 
653
621
654