Work.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/App/Work", ["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.AppWork = 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.AppWork = void 0;
  21. _BaseApp2 = babelHelpers.interopRequireDefault(_BaseApp2);
  22. var AppWork =
  23. /*#__PURE__*/
  24. function (_BaseApp) {
  25. babelHelpers.inherits(AppWork, _BaseApp);
  26. function AppWork() {
  27. babelHelpers.classCallCheck(this, AppWork);
  28. return babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(AppWork).apply(this, arguments));
  29. }
  30. babelHelpers.createClass(AppWork, [{
  31. key: "initialize",
  32. value: function initialize() {
  33. babelHelpers.get(babelHelpers.getPrototypeOf(AppWork.prototype), "initialize", this).call(this);
  34. this.items = [];
  35. this.handleChart();
  36. this.handleSelective();
  37. }
  38. }, {
  39. key: "process",
  40. value: function process() {
  41. babelHelpers.get(babelHelpers.getPrototypeOf(AppWork.prototype), "process", this).call(this);
  42. this.bindChart();
  43. }
  44. }, {
  45. key: "handleChart",
  46. value: function handleChart() {
  47. /* create line chart */
  48. this.scoreChart = function (data) {
  49. var scoreChart = new Chartist.Line(data, {
  50. labels: ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'],
  51. series: [{
  52. name: 'series-1',
  53. data: [0.8, 1.5, 0.8, 2.7, 2.4, 3.9, 1.1]
  54. }, {
  55. name: 'series-2',
  56. data: [2.2, 3, 2.7, 3.6, 1.5, 1, 2.9]
  57. }]
  58. }, {
  59. lineSmooth: Chartist.Interpolation.simple({
  60. divisor: 100
  61. }),
  62. fullWidth: true,
  63. chartPadding: {
  64. right: 25
  65. },
  66. series: {
  67. 'series-1': {
  68. showArea: false
  69. },
  70. 'series-2': {
  71. showArea: false
  72. }
  73. },
  74. axisX: {
  75. showGrid: false
  76. },
  77. axisY: {
  78. scaleMinSpace: 40
  79. },
  80. plugins: [Chartist.plugins.tooltip()],
  81. low: 0,
  82. height: 250
  83. });
  84. scoreChart.on('draw', function (data) {
  85. if (data.type === 'point') {
  86. var parent = new Chartist.Svg(data.element._node.parentNode);
  87. parent.elem('line', {
  88. x1: data.x,
  89. y1: data.y,
  90. x2: data.x + 0.01,
  91. y2: data.y,
  92. class: 'ct-point-content'
  93. });
  94. }
  95. });
  96. }; // let WeekLabelList = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'];
  97. // let WeekSeries1List = {
  98. // name: 'series-1',
  99. // data: [0.8, 1.5, 0.8, 2.7, 2.4, 3.9, 1.1]
  100. // };
  101. // let WeekSeries2List = {
  102. // name: 'series-2',
  103. // data: [2.2, 3, 2.7, 3.6, 1.5, 1, 2.9]
  104. // };
  105. /* create bar chart */
  106. this.barChart = function (data) {
  107. var barChart = new Chartist.Bar(data, {
  108. labels: ['Damon', 'Jimmy', 'Jhon', 'Alex', 'Lucy', 'Peter', 'Chris'],
  109. series: [[3.3, 3.5, 2.5, 2, 3.7, 2.7, 1.9], [2, 4, 3.5, 2.7, 3.3, 3.5, 2.5]]
  110. }, {
  111. axisX: {
  112. showGrid: false
  113. },
  114. axisY: {
  115. showGrid: false,
  116. scaleMinSpace: 30
  117. },
  118. height: 210,
  119. seriesBarDistance: 24
  120. });
  121. barChart.on('draw', function (data) {
  122. if (data.type === 'bar') {
  123. var parent = new Chartist.Svg(data.element._node.parentNode);
  124. parent.elem('line', {
  125. x1: data.x1,
  126. x2: data.x2,
  127. y1: data.y2,
  128. y2: 0,
  129. class: 'ct-bar-fill'
  130. });
  131. data.element.attr({
  132. style: 'stroke-width: 20px'
  133. });
  134. }
  135. });
  136. };
  137. }
  138. }, {
  139. key: "bindChart",
  140. value: function bindChart() {
  141. var _this = this;
  142. /* run chart */
  143. $(document).on('slidePanel::afterLoad', function () {
  144. _this.scoreChart('.trends-chart');
  145. _this.barChart('.member-chart');
  146. });
  147. }
  148. }, {
  149. key: "handleSelective",
  150. value: function handleSelective() {
  151. var _this2 = this;
  152. var self = this;
  153. var member = [{
  154. id: 'uid_1',
  155. name: 'Herman Beck',
  156. avatar: '../../../../global/portraits/1.jpg'
  157. }, {
  158. id: 'uid_2',
  159. name: 'Mary Adams',
  160. avatar: '../../../../global/portraits/2.jpg'
  161. }, {
  162. id: 'uid_3',
  163. name: 'Caleb Richards',
  164. avatar: '../../../../global/portraits/3.jpg'
  165. }, {
  166. id: 'uid_4',
  167. name: 'June Lane',
  168. avatar: '../../../../global/portraits/4.jpg'
  169. }, {
  170. id: 'uid_5',
  171. name: 'June Lane',
  172. avatar: '../../../../global/portraits/5.jpg'
  173. }, {
  174. id: 'uid_6',
  175. name: 'June Lane',
  176. avatar: '../../../../global/portraits/6.jpg'
  177. }, {
  178. id: 'uid_7',
  179. name: 'June Lane',
  180. avatar: '../../../../global/portraits/7.jpg'
  181. }];
  182. var getNum = function getNum(num) {
  183. return Math.ceil(Math.random() * (num + 1));
  184. };
  185. var getMember = function getMember() {
  186. return member[getNum(member.length - 1) - 1];
  187. };
  188. var isSame = function isSame(items) {
  189. var _items = items;
  190. var _member = getMember();
  191. if (_items.indexOf(_member) === -1) {
  192. return _member;
  193. }
  194. return isSame(_items);
  195. };
  196. var pushMember = function pushMember(num) {
  197. var items = [];
  198. for (var i = 0; i < num; i++) {
  199. items.push(isSame(items));
  200. }
  201. _this2.items = items;
  202. };
  203. var setItems = function setItems(membersNum) {
  204. var num = getNum(membersNum - 1);
  205. pushMember(num);
  206. };
  207. $('.plugin-selective').each(function () {
  208. setItems(member.length);
  209. var items = self.items;
  210. $(this).selective({
  211. namespace: 'addMember',
  212. local: member,
  213. selected: items,
  214. buildFromHtml: false,
  215. tpl: {
  216. optionValue: function optionValue(data) {
  217. return data.id;
  218. },
  219. frame: function frame() {
  220. 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>"); // i++;
  221. },
  222. triggerButton: function triggerButton() {
  223. return "<div class=\"".concat(this.namespace, "-trigger-button\"><i class=\"wb-plus\"></i></div>");
  224. },
  225. listItem: function listItem(data) {
  226. return "<li class=\"".concat(this.namespace, "-list-item\"><img class=\"avatar\" src=\"").concat(data.avatar, "\">").concat(data.name, "</li>");
  227. },
  228. item: function item(data) {
  229. return "<li class=\"".concat(this.namespace, "-item\"><img class=\"avatar\" src=\"").concat(data.avatar, "\" title=\"").concat(data.name, "\">").concat(this.options.tpl.itemRemove.call(this), "</li>");
  230. },
  231. itemRemove: function itemRemove() {
  232. return "<span class=\"".concat(this.namespace, "-remove\"><i class=\"wb-minus-circle\"></i></span>");
  233. },
  234. option: function option(data) {
  235. return "<option value=\"".concat(this.options.tpl.optionValue.call(this, data), "\">").concat(data.name, "</option>");
  236. }
  237. }
  238. });
  239. });
  240. }
  241. }]);
  242. return AppWork;
  243. }(_BaseApp2.default);
  244. _exports.AppWork = AppWork;
  245. var instance = null;
  246. function getInstance() {
  247. if (!instance) {
  248. instance = new AppWork();
  249. }
  250. return instance;
  251. }
  252. function run() {
  253. var app = getInstance();
  254. app.run();
  255. }
  256. var _default = AppWork;
  257. _exports.default = _default;
  258. });