jqtabledit.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/tables/jqtabledit", ["jquery", "Site"], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory(require("jquery"), require("Site"));
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory(global.jQuery, global.Site);
  11. global.tablesJqtabledit = mod.exports;
  12. }
  13. })(this, function (_jquery, _Site) {
  14. "use strict";
  15. _jquery = babelHelpers.interopRequireDefault(_jquery);
  16. (0, _jquery.default)(document).ready(function ($$$1) {
  17. (0, _Site.run)();
  18. }); // Example Tabledit Toolbars
  19. // -------------------------------
  20. (function () {
  21. (0, _jquery.default)('#exampleTableditToolbars').Tabledit({
  22. columns: {
  23. identifier: [0, 'id'],
  24. editable: [[1, 'username'], [2, 'first'], [3, 'last']]
  25. },
  26. buttons: {
  27. edit: {
  28. class: 'btn btn-sm btn-icon btn-flat btn-default',
  29. html: '<span class="icon wb-wrench"></span>',
  30. action: 'edit'
  31. },
  32. delete: {
  33. class: 'btn btn-sm btn-icon btn-flat btn-default',
  34. html: '<span class="icon wb-close"></span>',
  35. action: 'delete'
  36. }
  37. }
  38. });
  39. })(); // Example Inline Tabledit Toolbars
  40. // -------------------------------
  41. (function () {
  42. (0, _jquery.default)('#exampleTableditInlineEdit').Tabledit({
  43. eventType: 'dblclick',
  44. editButton: false,
  45. columns: {
  46. identifier: [0, 'id'],
  47. editable: [[1, 'username'], [2, 'last', '{"1": "May", "2": "Green", "3": "Brant"}']]
  48. },
  49. buttons: {
  50. edit: {
  51. class: 'btn btn-sm btn-icon btn-flat btn-default',
  52. html: '<span class="icon wb-wrench"></span>',
  53. action: 'edit'
  54. },
  55. delete: {
  56. class: 'btn btn-sm btn-icon btn-flat btn-default',
  57. html: '<span class="icon wb-close"></span>',
  58. action: 'delete'
  59. }
  60. }
  61. });
  62. })(); // Example Inline Tabledit without identifier
  63. // -------------------------------
  64. (function () {
  65. (0, _jquery.default)('#InlineEditWithoutIndentify').Tabledit({
  66. editButton: false,
  67. deleteButton: false,
  68. hideIdentifier: true,
  69. columns: {
  70. identifier: [0, 'id'],
  71. editable: [[2, 'firstname'], [3, 'lastname']]
  72. },
  73. buttons: {
  74. edit: {
  75. class: 'btn btn-sm btn-icon btn-flat btn-default',
  76. html: '<span class="icon wb-wrench"></span>',
  77. action: 'edit'
  78. },
  79. delete: {
  80. class: 'btn btn-sm btn-icon btn-flat btn-default',
  81. html: '<span class="icon wb-close"></span>',
  82. action: 'delete'
  83. }
  84. }
  85. });
  86. })(); // Example Tabledit With Editbutton Only
  87. // -------------------------------
  88. (function () {
  89. (0, _jquery.default)('#tableditWithEditButtonOnly').Tabledit({
  90. deleteButton: false,
  91. saveButton: false,
  92. autoFocus: false,
  93. columns: {
  94. identifier: [0, 'id'],
  95. editable: [[1, 'car'], [2, 'color']]
  96. },
  97. buttons: {
  98. edit: {
  99. class: 'btn btn-sm btn-icon btn-flat btn-default',
  100. html: '<span class="icon wb-wrench"></span>',
  101. action: 'edit'
  102. },
  103. delete: {
  104. class: 'btn btn-sm btn-icon btn-flat btn-default',
  105. html: '<span class="icon wb-close"></span>',
  106. action: 'delete'
  107. }
  108. }
  109. });
  110. })(); // Example Toolbar With Deletebutton only
  111. // -------------------------------
  112. (function () {
  113. (0, _jquery.default)('#tableditWithDeleteButtonOnly').Tabledit({
  114. rowIdentifier: 'data-id',
  115. editButton: false,
  116. restoreButton: false,
  117. columns: {
  118. identifier: [0, 'id'],
  119. editable: [[1, 'nickname'], [2, 'firstname'], [3, 'lastname']]
  120. },
  121. buttons: {
  122. edit: {
  123. class: 'btn btn-sm btn-icon btn-flat btn-default',
  124. html: '<span class="icon wb-wrench"></span>',
  125. action: 'edit'
  126. },
  127. delete: {
  128. class: 'btn btn-sm btn-icon btn-flat btn-default',
  129. html: '<span class="icon wb-close"></span>',
  130. action: 'delete'
  131. },
  132. confirm: {
  133. class: 'btn btn-sm btn-default',
  134. html: 'Are you sure?'
  135. }
  136. }
  137. });
  138. })(); // Example Toolbar With Log All Hooks
  139. // -------------------------------
  140. (function () {
  141. (0, _jquery.default)('#tableditLogAllHooks').Tabledit({
  142. rowIdentifier: 'data-id',
  143. editButton: true,
  144. restoreButton: true,
  145. columns: {
  146. identifier: [0, 'id'],
  147. editable: [[1, 'username'], [2, 'email'], [3, 'avatar', '{"1": "Black Widow", "2": "Captain America", "3": "Iron Man"}']]
  148. },
  149. buttons: {
  150. edit: {
  151. class: 'btn btn-sm btn-icon btn-flat btn-default',
  152. html: '<span class="icon wb-wrench"></span>',
  153. action: 'edit'
  154. },
  155. delete: {
  156. class: 'btn btn-sm btn-icon btn-flat btn-default',
  157. html: '<span class="icon wb-close"></span>',
  158. action: 'delete'
  159. }
  160. },
  161. onDraw: function onDraw() {
  162. console.log('onDraw()');
  163. },
  164. onSuccess: function onSuccess(data, textStatus, jqXHR) {
  165. console.log('onSuccess(data, textStatus, jqXHR)');
  166. console.log(data);
  167. console.log(textStatus);
  168. console.log(jqXHR);
  169. },
  170. onFail: function onFail(jqXHR, textStatus, errorThrown) {
  171. console.log('onFail(jqXHR, textStatus, errorThrown)');
  172. console.log(jqXHR);
  173. console.log(textStatus);
  174. console.log(errorThrown);
  175. },
  176. onAlways: function onAlways() {
  177. console.log('onAlways()');
  178. },
  179. onAjax: function onAjax(action, serialize) {
  180. console.log('onAjax(action, serialize)');
  181. console.log(action);
  182. console.log(serialize);
  183. }
  184. });
  185. })();
  186. });