/** * 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('school.view.main.MainController', { extend: 'Ext.app.ViewController', alias: 'controller.main', onToggleNavigationSize: function () { var me = this, viewModel = me.getViewModel(), refs = me.getReferences(), navigationList = refs.navigationTreeList, navCollapsed = !navigationList.navCollapsed, new_width = navCollapsed ? viewModel.get('smallNavWidth') : viewModel.get('navWidth'), newLogoImgStyle = navCollapsed ? { width: 51, height: 32, top: 8, left: 6 } : { width: 45, height: 30, top: 10, left: 10 }, newLogoTextStyle = navCollapsed ? { 0: { opacity: 0 }, 70: { opacity: 0 } } : { 10: { opacity: 0 }, 90: { opacity: 1 } }, newNavIconStyle = navCollapsed ? { marginLeft: 6, fontSize: 28 } : { marginLeft: 16, fontSize: 24 }, newNavTextStyle = navCollapsed ? { opacity: 0 } : { opacity: 1 }, ope = navCollapsed ? 'addCls' : 'removeCls', toggleIconCls = navCollapsed ? 'sa-arrows-right' : 'sa-arrows-left'; var mainLogo = refs.mainLogo; var logoImg = mainLogo.el.dom.getElementsByTagName('img')[0]; var logoText = mainLogo.el.dom.getElementsByClassName('logo-text')[0]; var navItems = navigationList.el.dom.getElementsByClassName('x-navitem'); var toggleIcon = Ext.getCmp('main-navigation-toggle-btn'); Ext.suspendLayouts(); toggleIcon.setIconCls('x-sa ' + toggleIconCls); mainLogo.animate({dynamic: true, duration: 500, to: {width: new_width}}); Ext.fly(logoImg).animate({dynamic: true, duration: 500, to: newLogoImgStyle}); Ext.fly(logoText).animate({dynamic: true, duration: 500, keyframes: newLogoTextStyle}); navigationList.body.animate({dynamic: true, duration: 500, to: {width: new_width}}); navigationList.animate({dynamic: true, duration: 500, to: {width: new_width}}); for(var i = 0; i < navItems.length; i++) { var item = navItems[i]; var icon = item.getElementsByClassName('nav-inner-icon')[0]; var text = item.getElementsByClassName('nav-inner-text')[0]; Ext.fly(icon).animate({dynamic: true, duration: 500, to: newNavIconStyle}); Ext.fly(text).animate({dynamic: true, duration: 500, to: newNavTextStyle}); } navigationList.el[ope]('nav-collapsed'); navigationList.navCollapsed = navCollapsed; Ext.resumeLayouts(true); }, onResetPassword: function() { var win = Ext.getCmp('resetpassword'); if(!win) { win = Ext.create('Ext.window.Window', { title: '修改密码', width: 400, height: 260, padding: 20, modal: true, items: [{ xtype: 'form', items: [{ xtype: 'textfield', cls: 'auth-textbox', fieldLabel: '新密码', emptyText: '请输入新密码', inputType: 'password', name: 'password1', allowBlank : false, listeners: { change: function(field) { var form = field.up('form'), field2 = form.getForm().findField('password2'); field2.isValid(); } } }, { xtype: 'textfield', cls: 'auth-textbox', fieldLabel: '新密码确认', emptyText: '请再次输入新密码', inputType: 'password', name: 'password2', allowBlank : false, validator: function (val) { var field = this, form = field.up('form'), field1 = form.getForm().findField('password1'), value1 = field1.getValue(); var errMsg = "两次输入密码不一致"; return (value1 == val) ? true : errMsg; } }], bbar: ['->', { xtype: 'button', text: '确认修改', formBind: true, handler: function(btn) { var window = btn.up('window'), form = window.down('form'), values = form.getValues(), userId = school.util.BaseUtil.getCurrentUser().id; window.setLoading(true); school.util.BaseUtil.request({ url: '/api/account/account/password/reset?password=' + values.password1 + '&userId=' + userId, method: 'POST', }).then(function(res) { window.setLoading(false); school.util.BaseUtil.showSuccessToast('修改密码成功'); }).catch(function(e) { window.setLoading(false); school.util.BaseUtil.showErrorToast('修改密码失败: ' + e.message); }); } }, '->'] }] }); } win.show(); }, onLogout: function() { this.fireEvent('logout'); } });