Contacts.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/App/Contacts", ["exports", "BaseApp"], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory(exports, require("BaseApp"));
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory(mod.exports, global.BaseApp);
  11. global.AppContacts = mod.exports;
  12. }
  13. })(this, function (_exports, _BaseApp2) {
  14. "use strict";
  15. Object.defineProperty(_exports, "__esModule", {
  16. value: true
  17. });
  18. _exports.run = run;
  19. _exports.getInstance = getInstance;
  20. _exports.default = _exports.AppContacts = void 0;
  21. _BaseApp2 = babelHelpers.interopRequireDefault(_BaseApp2);
  22. var AppContacts =
  23. /*#__PURE__*/
  24. function (_BaseApp) {
  25. babelHelpers.inherits(AppContacts, _BaseApp);
  26. function AppContacts() {
  27. babelHelpers.classCallCheck(this, AppContacts);
  28. return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(AppContacts).apply(this, arguments));
  29. }
  30. babelHelpers.createClass(AppContacts, [{
  31. key: "initialize",
  32. value: function initialize() {
  33. babelHelpers.get(babelHelpers.getPrototypeOf(AppContacts.prototype), "initialize", this).call(this);
  34. this.$actionBtn = $('.site-action');
  35. this.$actionToggleBtn = this.$actionBtn.find('.site-action-toggle');
  36. this.$addMainForm = $('#addUserForm').modal({
  37. show: false
  38. });
  39. this.$content = $('#contactsContent'); // states
  40. this.states = {
  41. checked: false
  42. };
  43. }
  44. }, {
  45. key: "process",
  46. value: function process() {
  47. babelHelpers.get(babelHelpers.getPrototypeOf(AppContacts.prototype), "process", this).call(this);
  48. this.setupActionBtn();
  49. this.bindListChecked();
  50. this.handlSlidePanelContent();
  51. }
  52. }, {
  53. key: "listChecked",
  54. value: function listChecked(checked) {
  55. var api = this.$actionBtn.data('actionBtn');
  56. if (checked) {
  57. api.show();
  58. } else {
  59. api.hide();
  60. }
  61. this.states.checked = checked;
  62. }
  63. }, {
  64. key: "setupActionBtn",
  65. value: function setupActionBtn() {
  66. var _this = this;
  67. this.$actionToggleBtn.on('click', function (e) {
  68. if (!_this.states.checked) {
  69. _this.$addMainForm.modal('show');
  70. e.stopPropagation();
  71. }
  72. });
  73. }
  74. }, {
  75. key: "bindListChecked",
  76. value: function bindListChecked() {
  77. var _this2 = this;
  78. this.$content.on('asSelectable::change', function (e, api, checked) {
  79. _this2.listChecked(checked);
  80. });
  81. }
  82. }, {
  83. key: "handlSlidePanelContent",
  84. value: function handlSlidePanelContent() {
  85. var _this3 = this;
  86. $(document).on('click', '[data-toggle=edit]', function () {
  87. var $button = $(this);
  88. var $panel = $button.parents('.slidePanel');
  89. var $form = $panel.find('.user-info');
  90. $button.toggleClass('active');
  91. $form.toggleClass('active');
  92. });
  93. $(document).on('change', '.user-info .form-group', function (e) {
  94. var $input = $(_this3).find('input');
  95. var $span = $(_this3).siblings('span');
  96. $span.html($input.val());
  97. });
  98. }
  99. }]);
  100. return AppContacts;
  101. }(_BaseApp2.default);
  102. _exports.AppContacts = AppContacts;
  103. var instance = null;
  104. function getInstance() {
  105. if (!instance) {
  106. instance = new AppContacts();
  107. }
  108. return instance;
  109. }
  110. function run() {
  111. var app = getInstance();
  112. app.run();
  113. }
  114. var _default = AppContacts;
  115. _exports.default = _default;
  116. });