| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- /**
- * This class is the controller for the main view for the application. It is specified as
- * the "controller" of the Main view class.
- */
- Ext.define('saas.view.main.MainController', {
- extend: 'Ext.app.ViewController',
- alias: 'controller.main',
- onNavigationTreeItemClick: function(tree, info) {
- var node = info.node;
- if (node && node.get('viewType')) {
- this.setActiveTab(node.getData());
- }
- },
- menuItemClick: function(view, record, item, index, e, eOpts) {
- var me = this,
- target = e.target,
- clsName = target.className;
- debugger;
- return;
- if(clsName == 'item-text') {
- me.setActiveTab(record);
- }
- },
- setActiveTab: function(nodeData) {
- var me = this,
- refs = me.getReferences(),
- mainTab = refs.mainTabPanel,
- // existingItem = mainTab.child(type),
- newView,
- id = 'maintab-' + nodeData.id,
- title = nodeData.text;
- existingItem = mainTab.down('[id=' + id + ']'),
- lastView = mainTab.getActiveTab();
- if (!existingItem) {
- newView = Ext.create('saas.view.core.tab.Panel', {
- id: id,
- title: title,
- tabConfig: nodeData
- });
- }
- if (!newView || !newView.isWindow) {
- // !newView means we have an existing view, but if the newView isWindow
- // we don't add it to the card layout.
- if (existingItem) {
- // We don't have a newView, so activate the existing view.
- if (existingItem !== lastView) {
- mainTab.setActiveTab(existingItem);
- }
- newView = existingItem;
- }
- else {
- // newView is set (did not exist already), so add it and make it the
- // activeItem.
- Ext.suspendLayouts();
- mainTab.setActiveTab(mainTab.add(newView));
- Ext.resumeLayouts(true);
- }
- }
- if (newView.isFocusable(true)) {
- newView.focus();
- }
- },
- onToggleNavigationSize: function () {
- var me = this,
- refs = me.getReferences(),
- navigationList = refs.navigationTreeList,
- wrapContainer = refs.mainContainerWrap,
- navCollapsed = !navigationList.navCollapsed,
- new_width = navCollapsed ? 64 : 160,
- ope = navCollapsed ? 'addCls' : 'removeCls';
-
- refs.mainLogo.animate({dynamic: true, to: {width: new_width}});
- navigationList.body.animate({dynamic: true, to: {width: new_width}});
- navigationList.animate({dynamic: true, to: {width: new_width}});
- navigationList.el[ope]('nav-collapsed');
- navigationList.navCollapsed = navCollapsed;
- }
- });
|