Blame view

frontend/web/js/begunok.js 1.82 KB
4253cbec   root   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  jQuery(document).ready(function(){
  
  
  /* слайдер цен */
  
  jQuery("#begunok").slider({
  	min: 0,
  	max: $('#max').val(),
  	values: [0,$('#max').val()],
  	range: true,
  	stop: function(event, ui) {
  		jQuery("input#products-mincost").val(jQuery("#begunok").slider("values",0));
  		jQuery("input#products-maxcost").val(jQuery("#begunok").slider("values",1));
  		
      },
      slide: function(event, ui){
  		jQuery("input#products-mincost").val(jQuery("#begunok").slider("values",0));
  		jQuery("input#products-maxcost").val(jQuery("#begunok").slider("values",1));
      }
  });
  
  var min_cost = function(){
  	var value1=jQuery("input#products-mincost").val();
  	var value2=jQuery("input#products-maxcost").val();
  
      if(parseInt(value1) > parseInt(value2)){
  		value1 = value2;
  		jQuery("input#products-mincost").val(value1);
  	}
  	jQuery("#begunok").slider("values",0,value1);	
  }
  
  jQuery("input#minCost").change(function(){
  
  	min_cost();
  });
  min_cost();
  
  var max_cost = function(){
  	var value1=jQuery("input#products-mincost").val();
  	var value2=jQuery("input#products-maxcost").val();
  	
  	if (value2 > $('#max').val()) { value2 = $('#max').val(); jQuery("input#products-maxcost").val($('#max').val())}
  
  	if(parseInt(value1) > parseInt(value2)){
  		value2 = value1;
  		jQuery("input#products-maxcost").val(value2);
  	}
  	jQuery("#begunok").slider("values",1,value2);	
  }
  	
  jQuery("input#maxCost").change(function(){
  	max_cost();	
  
  });
  max_cost();
  
  
  // фильтрация ввода в поля
  	jQuery('input').keypress(function(event){
  		var key, keyChar;
  		if(!event) var event = window.event;
  		
  		if (event.keyCode) key = event.keyCode;
  		else if(event.which) key = event.which;
  	
  		if(key==null || key==0 || key==8 || key==13 || key==9 || key==46 || key==37 || key==39 ) return true;
  		keyChar=String.fromCharCode(key);
  		
  		if(!/\d/.test(keyChar))	return false;
  	
  	});
  
  
  });