website.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. $(document).ready(function() {
  2. $('#config-text').keyup(function() {
  3. eval($(this).val());
  4. });
  5. $('.configurator input, .configurator select').change(function() {
  6. updateConfig();
  7. });
  8. $('.demo i').click(function() {
  9. $(this).parent().find('input').click();
  10. });
  11. $('#startDate').daterangepicker({
  12. singleDatePicker: true,
  13. startDate: moment().subtract(6, 'days')
  14. });
  15. $('#endDate').daterangepicker({
  16. singleDatePicker: true,
  17. startDate: moment()
  18. });
  19. //updateConfig();
  20. function updateConfig() {
  21. var options = {};
  22. if ($('#singleDatePicker').is(':checked'))
  23. options.singleDatePicker = true;
  24. if ($('#showDropdowns').is(':checked'))
  25. options.showDropdowns = true;
  26. if ($('#minYear').val().length && $('#minYear').val() != 1)
  27. options.minYear = parseInt($('#minYear').val(), 10);
  28. if ($('#maxYear').val().length && $('#maxYear').val() != 1)
  29. options.maxYear = parseInt($('#maxYear').val(), 10);
  30. if ($('#showWeekNumbers').is(':checked'))
  31. options.showWeekNumbers = true;
  32. if ($('#showISOWeekNumbers').is(':checked'))
  33. options.showISOWeekNumbers = true;
  34. if ($('#timePicker').is(':checked'))
  35. options.timePicker = true;
  36. if ($('#timePicker24Hour').is(':checked'))
  37. options.timePicker24Hour = true;
  38. if ($('#timePickerIncrement').val().length && $('#timePickerIncrement').val() != 1)
  39. options.timePickerIncrement = parseInt($('#timePickerIncrement').val(), 10);
  40. if ($('#timePickerSeconds').is(':checked'))
  41. options.timePickerSeconds = true;
  42. if ($('#autoApply').is(':checked'))
  43. options.autoApply = true;
  44. if ($('#maxSpan').is(':checked'))
  45. options.maxSpan = { days: 7 };
  46. if ($('#ranges').is(':checked')) {
  47. options.ranges = {
  48. 'Today': [moment(), moment()],
  49. 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
  50. 'Last 7 Days': [moment().subtract(6, 'days'), moment()],
  51. 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
  52. 'This Month': [moment().startOf('month'), moment().endOf('month')],
  53. 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
  54. };
  55. }
  56. if ($('#locale').is(':checked')) {
  57. options.locale = {
  58. format: 'MM/DD/YYYY',
  59. separator: ' - ',
  60. applyLabel: 'Apply',
  61. cancelLabel: 'Cancel',
  62. fromLabel: 'From',
  63. toLabel: 'To',
  64. customRangeLabel: 'Custom',
  65. weekLabel: 'W',
  66. daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr','Sa'],
  67. monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
  68. firstDay: 1
  69. };
  70. }
  71. if (!$('#linkedCalendars').is(':checked'))
  72. options.linkedCalendars = false;
  73. if (!$('#autoUpdateInput').is(':checked'))
  74. options.autoUpdateInput = false;
  75. if (!$('#showCustomRangeLabel').is(':checked'))
  76. options.showCustomRangeLabel = false;
  77. if ($('#alwaysShowCalendars').is(':checked'))
  78. options.alwaysShowCalendars = true;
  79. if ($('#parentEl').val().length)
  80. options.parentEl = $('#parentEl').val();
  81. if ($('#startDate').val().length)
  82. options.startDate = $('#startDate').val();
  83. if ($('#endDate').val().length)
  84. options.endDate = $('#endDate').val();
  85. if ($('#minDate').val().length)
  86. options.minDate = $('#minDate').val();
  87. if ($('#maxDate').val().length)
  88. options.maxDate = $('#maxDate').val();
  89. if ($('#opens').val().length && $('#opens').val() != 'right')
  90. options.opens = $('#opens').val();
  91. if ($('#drops').val().length && $('#drops').val() != 'down')
  92. options.drops = $('#drops').val();
  93. if ($('#buttonClasses').val().length && $('#buttonClasses').val() != 'btn btn-sm')
  94. options.buttonClasses = $('#buttonClasses').val();
  95. if ($('#applyButtonClasses').val().length && $('#applyButtonClasses').val() != 'btn-primary')
  96. options.applyButtonClasses = $('#applyButtonClasses').val();
  97. if ($('#cancelButtonClasses').val().length && $('#cancelButtonClasses').val() != 'btn-default')
  98. options.cancelClass = $('#cancelButtonClasses').val();
  99. $('#config-demo').daterangepicker(options, function(start, end, label) { console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')'); });
  100. if (typeof options.ranges !== 'undefined') {
  101. options.ranges = {};
  102. }
  103. var option_text = JSON.stringify(options, null, ' ');
  104. var replacement = "ranges: {\n"
  105. + " 'Today': [moment(), moment()],\n"
  106. + " 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],\n"
  107. + " 'Last 7 Days': [moment().subtract(6, 'days'), moment()],\n"
  108. + " 'Last 30 Days': [moment().subtract(29, 'days'), moment()],\n"
  109. + " 'This Month': [moment().startOf('month'), moment().endOf('month')],\n"
  110. + " 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]\n"
  111. + " }";
  112. option_text = option_text.replace(new RegExp('"ranges"\: \{\}', 'g'), replacement);
  113. $('#config-text').val("$('#demo').daterangepicker(" + option_text + ", function(start, end, label) {\n console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')');\n});");
  114. }
  115. $(window).scroll(function (event) {
  116. var scroll = $(window).scrollTop();
  117. if (scroll > 180) {
  118. $('.leftcol').css('position', 'fixed');
  119. $('.leftcol').css('top', '10px');
  120. } else {
  121. $('.leftcol').css('position', 'absolute');
  122. $('.leftcol').css('top', '180px');
  123. }
  124. });
  125. var bg = new Trianglify({
  126. x_colors: ["#e1f3fd", "#eeeeee", "#407dbf"],
  127. y_colors: 'match_x',
  128. width: document.body.clientWidth,
  129. height: 150,
  130. stroke_width: 0,
  131. cell_size: 20
  132. });
  133. $('#jumbo').css('background-image', 'url(' + bg.png() + ')');
  134. });