Projects.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/App/Projects", ["exports", "Site"], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory(exports, require("Site"));
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory(mod.exports, global.Site);
  11. global.AppProjects = mod.exports;
  12. }
  13. })(this, function (_exports, _Site2) {
  14. "use strict";
  15. Object.defineProperty(_exports, "__esModule", {
  16. value: true
  17. });
  18. _exports.run = run;
  19. _exports.getInstance = getInstance;
  20. _exports.default = _exports.AppProjects = void 0;
  21. _Site2 = babelHelpers.interopRequireDefault(_Site2);
  22. var AppProjects =
  23. /*#__PURE__*/
  24. function (_Site) {
  25. babelHelpers.inherits(AppProjects, _Site);
  26. function AppProjects() {
  27. babelHelpers.classCallCheck(this, AppProjects);
  28. return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(AppProjects).apply(this, arguments));
  29. }
  30. babelHelpers.createClass(AppProjects, [{
  31. key: "initialize",
  32. value: function initialize() {
  33. babelHelpers.get(babelHelpers.getPrototypeOf(AppProjects.prototype), "initialize", this).call(this);
  34. this.handleSelective();
  35. }
  36. }, {
  37. key: "process",
  38. value: function process() {
  39. babelHelpers.get(babelHelpers.getPrototypeOf(AppProjects.prototype), "process", this).call(this);
  40. this.handleProject();
  41. }
  42. }, {
  43. key: "handleSelective",
  44. value: function handleSelective() {
  45. var members = [{
  46. id: 'uid_1',
  47. name: 'Herman Beck',
  48. img: '../../../../global/portraits/1.jpg'
  49. }, {
  50. id: 'uid_2',
  51. name: 'Mary Adams',
  52. img: '../../../../global/portraits/2.jpg'
  53. }, {
  54. id: 'uid_3',
  55. name: 'Caleb Richards',
  56. img: '../../../../global/portraits/3.jpg'
  57. }, {
  58. id: 'uid_4',
  59. name: 'June Lane',
  60. img: '../../../../global/portraits/4.jpg'
  61. }];
  62. var selected = [{
  63. id: 'uid_1',
  64. name: 'Herman Beck',
  65. img: '../../../../global/portraits/1.jpg'
  66. }, {
  67. id: 'uid_2',
  68. name: 'Caleb Richards',
  69. img: '../../../../global/portraits/2.jpg'
  70. }];
  71. $('.plugin-selective').selective({
  72. namespace: 'addMember',
  73. local: members,
  74. selected: selected,
  75. buildFromHtml: false,
  76. tpl: {
  77. optionValue: function optionValue(data) {
  78. return data.id;
  79. },
  80. frame: function frame() {
  81. return "<div class=\"".concat(this.namespace, "\">\n ").concat(this.options.tpl.items.call(this), "\n <div class=\"").concat(this.namespace, "-trigger\">\n ").concat(this.options.tpl.triggerButton.call(this), "\n <div class=\"").concat(this.namespace, "-trigger-dropdown\">\n ").concat(this.options.tpl.list.call(this), "\n </div>\n </div>\n </div>");
  82. },
  83. triggerButton: function triggerButton() {
  84. return "<div class=\"".concat(this.namespace, "-trigger-button\"><i class=\"wb-plus\"></i></div>");
  85. },
  86. listItem: function listItem(data) {
  87. return "<li class=\"".concat(this.namespace, "-list-item\"><img class=\"avatar\" src=\"").concat(data.img, "\">").concat(data.name, "</li>");
  88. },
  89. item: function item(data) {
  90. return "<li class=\"".concat(this.namespace, "-item\"><img class=\"avatar\" src=\"").concat(data.img, "\">").concat(this.options.tpl.itemRemove.call(this), "</li>");
  91. },
  92. itemRemove: function itemRemove() {
  93. return "<span class=\"".concat(this.namespace, "-remove\"><i class=\"wb-minus-circle\"></i></span>");
  94. },
  95. option: function option(data) {
  96. return "<option value=\"".concat(this.options.tpl.optionValue.call(this, data), "\">").concat(data.name, "</option>");
  97. }
  98. }
  99. });
  100. }
  101. }, {
  102. key: "handleProject",
  103. value: function handleProject() {
  104. $(document).on('click', '[data-tag=project-delete]', function (e) {
  105. bootbox.dialog({
  106. message: 'Do you want to delete the project?',
  107. buttons: {
  108. success: {
  109. label: 'Delete',
  110. className: 'btn-danger',
  111. callback: function callback() {// $(e.target).closest('.list-group-item').remove();
  112. }
  113. }
  114. }
  115. });
  116. });
  117. }
  118. }]);
  119. return AppProjects;
  120. }(_Site2.default);
  121. _exports.AppProjects = AppProjects;
  122. var instance = null;
  123. function getInstance() {
  124. if (!instance) {
  125. instance = new AppProjects();
  126. }
  127. return instance;
  128. }
  129. function run() {
  130. var app = getInstance();
  131. app.run();
  132. }
  133. var _default = AppProjects;
  134. _exports.default = _default;
  135. });