MainController.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. setActiveTab: function(dataset) {
  9. var me = this,
  10. refs = me.getReferences(),
  11. mainTab = refs.mainTabPanel,
  12. // existingItem = mainTab.child(type),
  13. newView,
  14. type = dataset.type,
  15. title = dataset.text,
  16. tabTitle = title + (type == 'form' ? '' : '查询'),
  17. id = dataset.id,
  18. tabId = 'maintab-' + type + '-' + id,
  19. existingItem = mainTab.down('[id=' + tabId + ']'),
  20. lastView = mainTab.getActiveTab();
  21. if (!existingItem) {
  22. existingItem = Ext.create('saas.view.core.tab.Panel', {
  23. id: tabId,
  24. title: tabTitle,
  25. tabViewConfig: dataset
  26. });
  27. Ext.suspendLayouts();
  28. mainTab.setActiveTab(mainTab.add(existingItem));
  29. Ext.resumeLayouts(true);
  30. }else {
  31. mainTab.setActiveTab(existingItem);
  32. }
  33. },
  34. onToggleNavigationSize: function () {
  35. var me = this,
  36. refs = me.getReferences(),
  37. navigationList = refs.navigationTreeList,
  38. navCollapsed = !navigationList.navCollapsed,
  39. new_width = navCollapsed ? 64 : 160,
  40. ope = navCollapsed ? 'addCls' : 'removeCls';
  41. refs.mainLogo.animate({dynamic: true, to: {width: new_width}});
  42. navigationList.body.animate({dynamic: true, to: {width: new_width}});
  43. navigationList.animate({dynamic: true, to: {width: new_width}});
  44. navigationList.el[ope]('nav-collapsed');
  45. navigationList.navCollapsed = navCollapsed;
  46. }
  47. });