be_ui_activity.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Document : be_ui_activity.js
  3. * Author : pixelcave
  4. * Description: Custom JS code used in Activity Page
  5. */
  6. var BeUIActivity = function() {
  7. // Randomize progress bars values
  8. var barsRandomize = function(){
  9. jQuery('.js-bar-randomize').on('click', function(){
  10. jQuery(this)
  11. .parents('.block')
  12. .find('.progress-bar')
  13. .each(function() {
  14. var el = jQuery(this);
  15. var random = Math.floor((Math.random() * 91) + 10);
  16. // Update progress width
  17. el.css('width', random + '%');
  18. // Update progress label
  19. jQuery('.progress-bar-label', el).html(random + '%');
  20. });
  21. });
  22. };
  23. // SweetAlert2, for more examples you can check out https://github.com/limonte/sweetalert2
  24. var sweetAlert2 = function(){
  25. // Set default properties
  26. swal.setDefaults({
  27. buttonsStyling: false,
  28. confirmButtonClass: 'btn btn-lg btn-alt-success m-5',
  29. cancelButtonClass: 'btn btn-lg btn-alt-danger m-5',
  30. inputClass: 'form-control'
  31. });
  32. // Init a simple alert on button click
  33. jQuery('.js-swal-alert').on('click', function(){
  34. swal('Hi, this is a simple alert!');
  35. });
  36. // Init an success alert on button click
  37. jQuery('.js-swal-success').on('click', function(){
  38. swal('Success', 'Everything updated perfectly!', 'success');
  39. });
  40. // Init an info alert on button click
  41. jQuery('.js-swal-info').on('click', function(){
  42. swal('Info', 'Just an informational modal!', 'info');
  43. });
  44. // Init an warning alert on button click
  45. jQuery('.js-swal-warning').on('click', function(){
  46. swal('Warning', 'Something needs your attention!', 'warning');
  47. });
  48. // Init an error alert on button click
  49. jQuery('.js-swal-error').on('click', function(){
  50. swal('Oops...', 'Something went wrong!', 'error');
  51. });
  52. // Init an question alert on button click
  53. jQuery('.js-swal-question').on('click', function(){
  54. swal('Question', 'Are you sure?', 'question');
  55. });
  56. // Init an example confirm alert on button click
  57. jQuery('.js-swal-confirm').on('click', function(){
  58. swal({
  59. title: 'Are you sure?',
  60. text: 'You will not be able to recover this imaginary file!',
  61. type: 'warning',
  62. showCancelButton: true,
  63. confirmButtonColor: '#d26a5c',
  64. confirmButtonText: 'Yes, delete it!',
  65. html: false,
  66. preConfirm: function() {
  67. return new Promise(function (resolve) {
  68. setTimeout(function () {
  69. resolve();
  70. }, 50);
  71. });
  72. }
  73. }).then(function(result){
  74. if (result.value) {
  75. swal('Deleted!', 'Your imaginary file has been deleted.', 'success');
  76. // result.dismiss can be 'overlay', 'cancel', 'close', 'esc', 'timer'
  77. } else if (result.dismiss === 'cancel') {
  78. swal('Cancelled', 'Your imaginary file is safe :)', 'error');
  79. }
  80. });
  81. });
  82. };
  83. return {
  84. init: function() {
  85. // Init randomize bar values
  86. barsRandomize();
  87. // Init SweetAlert2
  88. sweetAlert2();
  89. }
  90. };
  91. }();
  92. // Initialize when page loads
  93. jQuery(function(){ BeUIActivity.init(); });