MainController.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. onToggleNavigationSize: function () {
  9. var me = this,
  10. viewModel = me.getViewModel(),
  11. refs = me.getReferences(),
  12. navigationList = refs.navigationTreeList,
  13. navCollapsed = !navigationList.navCollapsed,
  14. new_width = navCollapsed ? viewModel.get('smallNavWidth') : viewModel.get('navWidth'),
  15. newLogoImgStyle = navCollapsed ? { width: 36, height: 36, top: 6, left: 12 } : { width: 32, height: 32, top: 8, left: 28 },
  16. newLogoTextStyle = navCollapsed ? {
  17. 0: { opacity: 0 },
  18. 100: { opacity: 0, display: 'none' }
  19. } : {
  20. 10: { opacity: 0 },
  21. 90: { opacity: 1 }
  22. },
  23. newNavIconStyle = navCollapsed ? { marginLeft: 6, fontSize: 28 } : { marginLeft: 22, fontSize: 24 },
  24. newNavTextStyle = navCollapsed ? { opacity: 0 } : { opacity: 1 },
  25. ope = navCollapsed ? 'addCls' : 'removeCls',
  26. toggleIconCls = navCollapsed ? 'sa-arrows-right' : 'sa-arrows-left';
  27. var mainLogo = refs.mainLogo;
  28. var logoImg = mainLogo.el.dom.getElementsByTagName('img')[0];
  29. var logoText = mainLogo.el.dom.getElementsByClassName('logo-text')[0];
  30. var navItems = navigationList.el.dom.getElementsByClassName('x-navitem');
  31. var toggleIcon = Ext.getCmp('main-navigation-toggle-btn');
  32. Ext.suspendLayouts();
  33. toggleIcon.setIconCls('x-sa ' + toggleIconCls);
  34. mainLogo.animate({dynamic: true, duration: 500, to: {width: new_width}});
  35. Ext.fly(logoImg).animate({dynamic: true, duration: 500, to: newLogoImgStyle});
  36. Ext.fly(logoText).animate({dynamic: true, duration: 500, keyframes: newLogoTextStyle});
  37. navigationList.body.animate({dynamic: true, duration: 500, to: {width: new_width}});
  38. navigationList.animate({dynamic: true, duration: 500, to: {width: new_width}});
  39. for(var i = 0; i < navItems.length; i++) {
  40. var item = navItems[i];
  41. var icon = item.getElementsByClassName('nav-inner-icon')[0];
  42. var text = item.getElementsByClassName('nav-inner-text')[0];
  43. Ext.fly(icon).animate({dynamic: true, duration: 500, to: newNavIconStyle});
  44. Ext.fly(text).animate({dynamic: true, duration: 500, to: newNavTextStyle});
  45. }
  46. navigationList.el[ope]('nav-collapsed');
  47. navigationList.navCollapsed = navCollapsed;
  48. Ext.resumeLayouts(true);
  49. },
  50. onLogout: function() {
  51. this.fireEvent('logout');
  52. }
  53. });