Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. Room A with Capacity for 4 Pax and 1 Adult is required.
  2. Adult/Child/Infant : 1/0/0 is less than 4 is OK
  3. Adult/Child/Infant : 2/1/1 is equal to 4 is Ok
  4. Adult/Child/Infant : 0/2/1 is less than 4 but NO Adult, therefore NOT OK
  5.  
  6. $("#mainSlider").slider({
  7. slide: function(event, ui) {
  8. //Insert logic here..
  9. }
  10. });
  11.  
  12. $("#secondarySlider").slider("max", x);
  13.  
  14. var sliders = $("#sliders .slider"),
  15. smax = 4,
  16. smin = 0;
  17.  
  18. sliders.each(function() {
  19. var availableTotal = smax;
  20.  
  21. $(this).empty().slider({
  22. value: 0,
  23. // Check - is this the adult slider?
  24. min: (this.id === 'adult') ? 1 : smin,
  25. max: smax,
  26. range: 'min',
  27. step: 1,
  28. slide: function(event, ui) {
  29. // Update display to current value
  30. $(this).siblings().text(ui.value);
  31.  
  32. // Get current total
  33. var total = 0;
  34.  
  35. sliders.not(this).each(function() {
  36. total += $(this).slider("option", "value");
  37. });
  38.  
  39. // Need to do this because apparently jQ UI
  40. // does not update value until this event completes
  41. total += ui.value;
  42.  
  43. var max = availableTotal - total;
  44.  
  45. // Update each slider
  46. sliders.not(this).each(function() {
  47. var t = $(this),
  48. value = t.slider("option", "value");
  49.  
  50. t.slider("option", "max", max + value)
  51. .siblings().text(value + '/' + (max + value));
  52. t.slider('value', value);
  53. });
  54. }
  55. });
  56. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement