Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

product-detail.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. 'use strict';
  2. $(document).ready(function() {
  3. // Header_portfolio js starts
  4. $('#big_banner').slick({
  5. slidesToShow: 1,
  6. slidesToScroll: 1,
  7. arrows: false,
  8. fade: true,
  9. autoplay: true,
  10. autoplaySpeed: 2000,
  11. asNavFor: '#small_banner'
  12. });
  13. $('#small_banner').slick({
  14. slidesToShow:4,
  15. slidesToScroll: 1,
  16. asNavFor: '#big_banner',
  17. dots: false,
  18. centerMode: true,
  19. autoplay: true,
  20. arrows: true,
  21. autoplaySpeed: 2000,
  22. focusOnSelect: true,
  23. responsive: [, {
  24. breakpoint: 480,
  25. settings: {
  26. slidesToShow: 3,
  27. slidesToScroll: 1
  28. }
  29. },
  30. ]
  31. });
  32. // Header_portfolio js ends
  33. // Minus And Plus in Input Caunter
  34. //plugin bootstrap minus and plus
  35. //http://jsfiddle.net/laelitenetwork/puJ6G/
  36. $( document ).ready(function() {
  37. $('.btn-number').on('click',function(e){
  38. e.preventDefault();
  39. var fieldName = $(this).attr('data-field');
  40. var type = $(this).attr('data-type');
  41. var input = $("input[name='"+fieldName+"']");
  42. var currentVal = parseInt(input.val());
  43. if (!isNaN(currentVal)) {
  44. if(type == 'minus') {
  45. var minValue = parseInt(input.attr('min'));
  46. if(!minValue) minValue = 1;
  47. if(currentVal > minValue) {
  48. input.val(currentVal - 1).change();
  49. }
  50. if(parseInt(input.val()) == minValue) {
  51. $(this).attr('disabled', true);
  52. }
  53. } else if(type == 'plus') {
  54. var maxValue = parseInt(input.attr('max'));
  55. if(!maxValue) maxValue = 9999999999999;
  56. if(currentVal < maxValue) {
  57. input.val(currentVal + 1).change();
  58. }
  59. if(parseInt(input.val()) == maxValue) {
  60. $(this).attr('disabled', true);
  61. }
  62. }
  63. } else {
  64. input.val(0);
  65. }
  66. });
  67. $('.input-number').focusin(function(){
  68. $(this).data('oldValue', $(this).val());
  69. });
  70. $('.input-number').change(function() {
  71. var minValue = parseInt($(this).attr('min'));
  72. var maxValue = parseInt($(this).attr('max'));
  73. if(!minValue) minValue = 1;
  74. if(!maxValue) maxValue = 9999999999999;
  75. var valueCurrent = parseInt($(this).val());
  76. var name = $(this).attr('name');
  77. if(valueCurrent >= minValue) {
  78. $(".btn-number[data-type='minus'][data-field='"+name+"']").removeAttr('disabled')
  79. } else {
  80. alert('Sorry, the minimum value was reached');
  81. $(this).val($(this).data('oldValue'));
  82. }
  83. if(valueCurrent <= maxValue) {
  84. $(".btn-number[data-type='plus'][data-field='"+name+"']").removeAttr('disabled')
  85. } else {
  86. alert('Sorry, the maximum value was reached');
  87. $(this).val($(this).data('oldValue'));
  88. }
  89. });
  90. $(".input-number").keydown(function (e) {
  91. // Allow: backspace, delete, tab, escape, enter and .
  92. if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 190]) !== -1 ||
  93. // Allow: Ctrl+A
  94. (e.keyCode == 65 && e.ctrlKey === true) ||
  95. // Allow: home, end, left, right
  96. (e.keyCode >= 35 && e.keyCode <= 39)) {
  97. // let it happen, don't do anything
  98. return;
  99. }
  100. // Ensure that it is a number and stop the keypress
  101. if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
  102. e.preventDefault();
  103. }
  104. });
  105. });
  106. });