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.

j-pro-additions.js 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. $(document).ready(function() {
  2. /***************************************/
  3. /* Show password */
  4. /***************************************/
  5. $("#show-pass").on("change", function(){
  6. $("#show-pass").is(":checked") ? $("#password").attr("type", "text") : $("#password").attr("type", "password");
  7. });
  8. /***************************************/
  9. /* end show password */
  10. /***************************************/
  11. /***************************************/
  12. /* Enabled input */
  13. /***************************************/
  14. $('#check-enable-input').on('change', function() {
  15. if ( $('#check-enable-input').is(':checked') ) {
  16. $('#enable-input').attr('disabled', false).parent().removeClass('j-disabled-view');
  17. } else {
  18. $('#enable-input').attr('disabled', true).parent().addClass('j-disabled-view');
  19. }
  20. });
  21. /***************************************/
  22. /* end enabled input */
  23. /***************************************/
  24. /***************************************/
  25. /* Enabled button */
  26. /***************************************/
  27. $('#check-enable-button').on('change', function() {
  28. if ( $('#check-enable-button').is(':checked') ) {
  29. $('#enable-button').attr('disabled', false).removeClass('j-disabled-view');
  30. } else {
  31. $('#enable-button').attr('disabled', true).addClass('j-disabled-view');
  32. }
  33. });
  34. /***************************************/
  35. /* end enabled button */
  36. /***************************************/
  37. /***************************************/
  38. /* Select conditions */
  39. /***************************************/
  40. // Arrays
  41. $models = [];
  42. $colors = [];
  43. // start select № 2
  44. // Car models
  45. $models['VO'] = ['V70', 'XC60', 'XC90'];
  46. $models['VW'] = ['Golf', 'Polo', 'Scirocco', 'Touareg'];
  47. $models['BMW'] = ['M6', 'X5', 'Z3'];
  48. // end select № 2
  49. // start select № 3
  50. // Model colors for 'VO'
  51. $colors['V70'] = ['black', 'white'];
  52. $colors['XC60'] = ['green', 'orange'];
  53. $colors['XC90'] = ['brown', 'red'];
  54. // Model colors for 'VW'
  55. $colors['Golf'] = ['purple', 'yellow'];
  56. $colors['Polo'] = ['grey', 'indigo'];
  57. $colors['Scirocco'] = ['blue', 'teal', 'cyan'];
  58. $colors['Touareg'] = ['red', 'black', 'orange', 'brown'];
  59. // Model colors for 'BMW'
  60. $colors['M6'] = ['orange', 'brown', 'red', 'indigo', 'cyan'];
  61. $colors['X5'] = ['white', 'green', 'cyan'];
  62. $colors['Z3'] = ['teal', 'purple', 'cyan'];
  63. // end select № 3
  64. // If first select is changed
  65. $( "#car" ).change(function () {
  66. // If next selects have values
  67. // Clear next selects
  68. if ( $("#car-model option").length) {
  69. $("#car-model option:gt(0)").remove();
  70. }
  71. if ( $("#car-model-color option").length) {
  72. $("#car-model-color option:gt(0)").remove();
  73. }
  74. // Get the "car" value from the current select
  75. $( "#car option:selected" ).each(function() {
  76. $car_val = $( this ).val();
  77. });
  78. // Get the "car models" values
  79. $car = $models[$car_val];
  80. // if "car models" exists
  81. // Add values to the next select
  82. if ( $car ) {
  83. for ($i = 0; $i < $car.length; $i++) {
  84. $opt = '<option value="' + $car[$i] + '">' + $car[$i] + '</option>';
  85. $('#car-model').append($opt);
  86. }
  87. }
  88. });
  89. // If second select is changed
  90. $( "#car-model" ).change(function () {
  91. // If next select has value
  92. // Clear next select
  93. if ( $("#car-model-color option").length) {
  94. $("#car-model-color option:gt(0)").remove();
  95. }
  96. // Get the "car model" value from the current select
  97. $( "#car-model option:selected" ).each(function() {
  98. $car_model_val = $( this ).val();
  99. });
  100. // Get the "car models colors" values
  101. $color = $colors[$car_model_val];
  102. // if "car models colors" exists
  103. // Add values to the next select
  104. if ( $color ) {
  105. for ($i = 0; $i < $color.length; $i++) {
  106. $opt = '<option value="' + $color[$i] + '">' + $color[$i] + '</option>';
  107. $("#car-model-color").append($opt);
  108. }
  109. }
  110. });
  111. /***************************************/
  112. /* end select conditions */
  113. /***************************************/
  114. /***************************************/
  115. /* Hidden elements checkbox */
  116. /***************************************/
  117. $('#show-elements-checkbox').on('change', function() {
  118. if ( $('#show-elements-checkbox').is(':checked') ) {
  119. $('.hidden-elements').removeClass('j-hidden');
  120. } else {
  121. $('.hidden-elements').addClass('j-hidden');
  122. }
  123. });
  124. /***************************************/
  125. /* end hidden elements checkbox */
  126. /***************************************/
  127. /***************************************/
  128. /* Hidden elements select */
  129. /***************************************/
  130. $( "#show-elements-select" ).change(function () {
  131. // Variables
  132. var $value = "",
  133. $field_1 = $("#field-1"),
  134. $field_2 = $("#field-2");
  135. // Get the value
  136. $( "#show-elements-select option:selected" ).each(function() {
  137. $value = $( this ).val();
  138. });
  139. // Display fields according to the value
  140. if ( $value == 'none' ) {
  141. if ( !$field_1.hasClass("j-hidden") ) $field_1.addClass("j-hidden");
  142. if ( !$field_2.hasClass("j-hidden") ) $field_2.addClass("j-hidden");
  143. }
  144. if ( $value == 'field-1' ) {
  145. if ( $field_1.hasClass("j-hidden") ) $field_1.removeClass("j-hidden");
  146. if ( !$field_2.hasClass("j-hidden") ) $field_2.addClass("j-hidden");
  147. }
  148. if ( $value == 'field-2' ) {
  149. if ( $field_2.hasClass("j-hidden") ) $field_2.removeClass("j-hidden");
  150. if ( !$field_1.hasClass("j-hidden") ) $field_1.addClass("j-hidden");
  151. }
  152. if ( $value == 'field-1-2' ) {
  153. if ( $field_1.hasClass("j-hidden") ) $field_1.removeClass("j-hidden");
  154. if ( $field_2.hasClass("j-hidden") ) $field_2.removeClass("j-hidden");
  155. }
  156. }).change();
  157. /***************************************/
  158. /* end hidden elements select */
  159. /***************************************/
  160. /***************************************/
  161. /* Checkbox conditions */
  162. /***************************************/
  163. /* Subscribe checkbox condition */
  164. $('#subscribe').change(function () {
  165. if ($('#subscribe').is(':checked')) {
  166. $('.subscribe').removeClass('j-disabled-view');
  167. $('.subscribe input[type="checkbox"]').removeAttr('disabled');
  168. } else {
  169. $('.subscribe').addClass('j-disabled-view');
  170. $('.subscribe input[type="checkbox"]').attr('disabled', 'true').removeAttr('checked');
  171. }
  172. }).change();
  173. /* end Subscribe checkbox condition */
  174. /***************************************/
  175. /* end Checkbox conditions */
  176. /***************************************/
  177. });