data-list-view.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*=========================================================================================
  2. File Name: data-list-view.js
  3. Description: List View
  4. ----------------------------------------------------------------------------------------
  5. Item Name: Vuexy - Vuejs, HTML & Laravel Admin Dashboard Template
  6. Author: PIXINVENT
  7. Author URL: http://www.themeforest.net/user/pixinvent
  8. ==========================================================================================*/
  9. $(document).ready(function() {
  10. "use strict"
  11. // init list view datatable
  12. var dataListView = $(".data-list-view").DataTable({
  13. responsive: false,
  14. columnDefs: [
  15. {
  16. orderable: true,
  17. targets: 0,
  18. checkboxes: { selectRow: true }
  19. }
  20. ],
  21. dom:
  22. '<"top"<"actions action-btns"B><"action-filters"lf>><"clear">rt<"bottom"<"actions">p>',
  23. oLanguage: {
  24. sLengthMenu: "_MENU_",
  25. sSearch: ""
  26. },
  27. aLengthMenu: [[4, 10, 15, 20], [4, 10, 15, 20]],
  28. select: {
  29. style: "multi"
  30. },
  31. order: [[1, "asc"]],
  32. bInfo: false,
  33. pageLength: 4,
  34. buttons: [
  35. {
  36. text: "<i class='feather icon-plus'></i> Add New",
  37. action: function() {
  38. $(this).removeClass("btn-secondary")
  39. $(".add-new-data").addClass("show")
  40. $(".overlay-bg").addClass("show")
  41. $("#data-name, #data-price").val("")
  42. $("#data-category, #data-status").prop("selectedIndex", 0)
  43. },
  44. className: "btn-outline-primary"
  45. }
  46. ],
  47. initComplete: function(settings, json) {
  48. $(".dt-buttons .btn").removeClass("btn-secondary")
  49. }
  50. });
  51. dataListView.on('draw.dt', function(){
  52. setTimeout(function(){
  53. if (navigator.userAgent.indexOf("Mac OS X") != -1) {
  54. $(".dt-checkboxes-cell input, .dt-checkboxes").addClass("mac-checkbox")
  55. }
  56. }, 50);
  57. });
  58. // init thumb view datatable
  59. var dataThumbView = $(".data-thumb-view").DataTable({
  60. responsive: false,
  61. columnDefs: [
  62. {
  63. orderable: true,
  64. targets: 0,
  65. checkboxes: { selectRow: true }
  66. }
  67. ],
  68. dom:
  69. '<"top"<"actions action-btns"B><"action-filters"lf>><"clear">rt<"bottom"<"actions">p>',
  70. oLanguage: {
  71. sLengthMenu: "_MENU_",
  72. sSearch: ""
  73. },
  74. aLengthMenu: [[4, 10, 15, 20], [4, 10, 15, 20]],
  75. select: {
  76. style: "multi"
  77. },
  78. order: [[1, "asc"]],
  79. bInfo: false,
  80. pageLength: 4,
  81. buttons: [
  82. {
  83. text: "<i class='feather icon-plus'></i> Add New",
  84. action: function() {
  85. $(this).removeClass("btn-secondary")
  86. $(".add-new-data").addClass("show")
  87. $(".overlay-bg").addClass("show")
  88. },
  89. className: "btn-outline-primary"
  90. }
  91. ],
  92. initComplete: function(settings, json) {
  93. $(".dt-buttons .btn").removeClass("btn-secondary")
  94. }
  95. })
  96. dataThumbView.on('draw.dt', function(){
  97. setTimeout(function(){
  98. if (navigator.userAgent.indexOf("Mac OS X") != -1) {
  99. $(".dt-checkboxes-cell input, .dt-checkboxes").addClass("mac-checkbox")
  100. }
  101. }, 50);
  102. });
  103. // To append actions dropdown before add new button
  104. var actionDropdown = $(".actions-dropodown")
  105. actionDropdown.insertBefore($(".top .actions .dt-buttons"))
  106. // Scrollbar
  107. if ($(".data-items").length > 0) {
  108. new PerfectScrollbar(".data-items", { wheelPropagation: false })
  109. }
  110. // Close sidebar
  111. $(".hide-data-sidebar, .cancel-data-btn, .overlay-bg").on("click", function() {
  112. $(".add-new-data").removeClass("show")
  113. $(".overlay-bg").removeClass("show")
  114. $("#data-name, #data-price").val("")
  115. $("#data-category, #data-status").prop("selectedIndex", 0)
  116. })
  117. // On Edit
  118. $('.action-edit').on("click",function(e){
  119. e.stopPropagation();
  120. $('#data-name').val('Altec Lansing - Bluetooth Speaker');
  121. $('#data-price').val('$99');
  122. $(".add-new-data").addClass("show");
  123. $(".overlay-bg").addClass("show");
  124. });
  125. // On Delete
  126. $('.action-delete').on("click", function(e){
  127. e.stopPropagation();
  128. $(this).closest('td').parent('tr').fadeOut();
  129. });
  130. // dropzone init
  131. Dropzone.options.dataListUpload = {
  132. complete: function(files) {
  133. var _this = this
  134. // checks files in class dropzone and remove that files
  135. $(".hide-data-sidebar, .cancel-data-btn, .actions .dt-buttons").on(
  136. "click",
  137. function() {
  138. $(".dropzone")[0].dropzone.files.forEach(function(file) {
  139. file.previewElement.remove()
  140. })
  141. $(".dropzone").removeClass("dz-started")
  142. }
  143. )
  144. }
  145. }
  146. Dropzone.options.dataListUpload.complete()
  147. // mac chrome checkbox fix
  148. if (navigator.userAgent.indexOf("Mac OS X") != -1) {
  149. $(".dt-checkboxes-cell input, .dt-checkboxes").addClass("mac-checkbox")
  150. }
  151. })