MainController.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**
  2. * This class is the controller for the main view for the application. It is specified as
  3. * the "controller" of the Main view class.
  4. */
  5. Ext.define('saas.view.main.MainController', {
  6. extend: 'Ext.app.ViewController',
  7. alias: 'controller.main',
  8. init: function() {
  9. this.setCompanyMenu();
  10. },
  11. setCompanyMenu: function() {
  12. var me = this, view = me.getView(), viewModel = me.getViewModel(),
  13. account = viewModel.get('account'), companies = account && account.companies,
  14. companyMenu = view.lookup('mainprofile').getMenu(), items = [];
  15. if (companies) {
  16. items = companies.map(function(c){
  17. return {
  18. text: c.name,
  19. value: c.id,
  20. handler: 'selectCompany',
  21. iconCls: c.id == account.companyId ? 'x-fa fa-check' : ''
  22. }
  23. });
  24. }
  25. companyMenu.insert(0, items);
  26. },
  27. onToggleNavigationSize: function () {
  28. var me = this,
  29. viewModel = me.getViewModel(),
  30. refs = me.getReferences(),
  31. navigationList = refs.navigationTreeList,
  32. navCollapsed = !navigationList.navCollapsed,
  33. new_width = navCollapsed ? viewModel.get('smallNavWidth') : viewModel.get('navWidth'),
  34. newLogoImgStyle = navCollapsed ? { width: 36, height: 36, top: 12, left: 12 } : { width: 32, height: 32, top: 16, left: 28 },
  35. newLogoTextStyle = navCollapsed ? {
  36. 5: { opacity: 0 },
  37. 10: { opacity: 0 },
  38. 100: { opacity: 0, display: 'none' }
  39. } : {
  40. 10: { opacity: 0 },
  41. 50: { opacity: 1 }
  42. },
  43. newNavIconStyle = navCollapsed ? { marginLeft: 6, fontSize: 28 } : { marginLeft: 22, fontSize: 24 },
  44. newNavTextStyle = navCollapsed ? { opacity: 0 } : { opacity: 1 },
  45. ope = navCollapsed ? 'addCls' : 'removeCls',
  46. toggleIconCls = navCollapsed ? 'sa-arrows-right' : 'sa-arrows-left';
  47. var mainLogo = refs.mainLogo;
  48. var logoImg = mainLogo.el.dom.getElementsByTagName('img')[0];
  49. var logoText = mainLogo.el.dom.getElementsByClassName('logo-text')[0];
  50. var navItems = navigationList.el.dom.getElementsByClassName('x-navitem');
  51. var toggleIcon = Ext.getCmp('main-navigation-toggle-btn');
  52. Ext.suspendLayouts();
  53. toggleIcon.setIconCls('x-sa ' + toggleIconCls);
  54. mainLogo.animate({dynamic: true, duration: 500, to: {width: new_width}});
  55. Ext.fly(logoImg).animate({dynamic: true, duration: 500, to: newLogoImgStyle});
  56. Ext.fly(logoText).animate({dynamic: true, duration: 500, keyframes: newLogoTextStyle});
  57. navigationList.body.animate({dynamic: true, duration: 500, to: {width: new_width}});
  58. navigationList.animate({dynamic: true, duration: 500, to: {width: new_width}});
  59. for(var i = 0; i < navItems.length; i++) {
  60. var item = navItems[i];
  61. var icon = item.getElementsByClassName('nav-inner-icon')[0];
  62. var text = item.getElementsByClassName('nav-inner-text')[0];
  63. Ext.fly(icon).animate({dynamic: true, duration: 500, to: newNavIconStyle});
  64. Ext.fly(text).animate({dynamic: true, duration: 500, to: newNavTextStyle});
  65. }
  66. navigationList.el[ope]('nav-collapsed');
  67. navigationList.navCollapsed = navCollapsed;
  68. Ext.resumeLayouts(true);
  69. },
  70. selectCompany: function(item) {
  71. this.fireEvent('selectCompany', item.value);
  72. },
  73. onLogout: function() {
  74. this.fireEvent('logout');
  75. },
  76. feedbackMsg:function(btn){
  77. var me = this,
  78. win = Ext.getCmp("feedbackWin");
  79. if (!win) {
  80. win = Ext.create('Ext.window.Window', {
  81. modal: true,
  82. draggable: false,
  83. resizable: false,
  84. id:"feedbackWin",
  85. height: 343,
  86. width: 756,
  87. title: '意见反馈',
  88. scrollable: true,
  89. constrain: true,
  90. closable: true,
  91. layout: 'fit',
  92. items: [{
  93. xtype: 'sys-feedback-formpanel'
  94. }]
  95. });
  96. };
  97. win.show();
  98. }
  99. });