Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. <!-- Import nouislider -->
  2. <link href="/wp-includes/css/nouislider.min.css" rel="stylesheet">
  3. <script src="/wp-includes/js/nouislider.min.js"></script>
  4.  
  5. <!-- Slider -->
  6. <div id="cost"></div>
  7.  
  8. <script type="text/javascript">
  9.  
  10. // Get slider element
  11. var cost = document.getElementById('cost');
  12.  
  13. // Dynamic range for the slider
  14. var slider_range = {
  15. 'min': [ 200000 ],
  16. '25%': [ 300000, 100 ],
  17. '50%': [ 1000000, 100 ],
  18. 'max': [ 2000000 ]
  19. };
  20.  
  21. // Creates the noUiSlider
  22. noUiSlider.create(cost, {
  23. start: 300000,
  24. connect: [true,false],
  25. tooltips: false,
  26. step: 100,
  27. range: slider_range
  28. });
  29.  
  30. // Calls the calculateSavings function when the slider value is updated
  31. cost.noUiSlider.on('update', calculateSavings);
  32.  
  33. // Calculates the savings that the user will receive based on the home's cost
  34. //
  35. // values: array of values passed in by the range slider
  36. // handle: handle (#) that sent the event. In this case, it will always be 0
  37. function calculateSavings(values, handle){
  38.  
  39. //Gets the home cost from the values array
  40. cost = parseInt(values[handle]);
  41.  
  42. var saved = document.getElementById('saved'); //Savings span. Will be updated when slider moves
  43. var calc = (cost * .03) - 995; //Calculate cash back
  44. var savedValue = (calc);
  45.  
  46.  
  47. //If statement to catch page initiation
  48. if (saved != null)
  49. {
  50. // Update Buyer Cash Back span
  51. saved.innerHTML = savedValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  52.  
  53. // Update Cost span
  54. costval.innerHTML = (cost).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  55. }
  56.  
  57.  
  58. }
  59. </script>
  60.  
  61. <style>
  62. .noUi-handle {
  63. border: 8px solid #f8a321;
  64. height: 30px !important;
  65. width: 30px !important;
  66. top: -10px !important;
  67. border-radius: 40px;
  68. background: #ffffff;
  69. cursor: default;
  70. box-shadow: none;
  71. }
  72.  
  73. .noUi-handle:hover {
  74. top: -10px !important;
  75. border-radius: 40px;
  76. background: #ffffff;
  77. cursor: default;
  78. box-shadow: none;
  79. }
  80.  
  81. .noUi-handle:after, .noUi-handle:before {
  82. display: none !important;
  83. }
  84.  
  85. .noUi-target {
  86. background: #e8e9ea;
  87. border: 0px;
  88. border-radius: 10px;
  89. box-shadow: none;
  90. }
  91.  
  92. .noUi-horizontal {
  93. height: 12px;
  94. }
  95.  
  96. .noUi-connect {
  97. background-color: #F8A321;
  98. }
  99.  
  100. .noUi-connects {
  101. border-radius: 10px;
  102. }
  103.  
  104. .calculator-text {
  105. color: #F8A321;
  106. }
  107. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement