[common] lock/unlock header buttons on file menu events
This commit is contained in:
parent
482a7d11bf
commit
39f29c5ef8
|
@ -630,6 +630,35 @@ define([
|
||||||
return this.btnSave;
|
return this.btnSave;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
lockHeaderBtns: function (alias, lock) {
|
||||||
|
var me = this;
|
||||||
|
if ( alias == 'users' ) {
|
||||||
|
if ( lock )
|
||||||
|
$btnUsers.addClass('disabled').attr('disabled', 'disabled'); else
|
||||||
|
$btnUsers.removeClass('disabled').attr('disabled', '');
|
||||||
|
} else {
|
||||||
|
function _lockButton(btn) {
|
||||||
|
if ( btn ) {
|
||||||
|
if ( lock ) {
|
||||||
|
btn.keepState = {
|
||||||
|
disabled: btn.isDisabled()
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
btn.setDisabled( btn.keepState.disabled );
|
||||||
|
delete me.btnUndo.keepState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( alias == 'undo' ) {
|
||||||
|
_lockButton(me.btnUndo);
|
||||||
|
} else
|
||||||
|
if ( alias == 'redo' ) {
|
||||||
|
_lockButton(me.btnRedo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
textBack: 'Go to Documents',
|
textBack: 'Go to Documents',
|
||||||
txtRename: 'Rename',
|
txtRename: 'Rename',
|
||||||
textSaveBegin: 'Saving...',
|
textSaveBegin: 'Saving...',
|
||||||
|
|
|
@ -168,6 +168,11 @@
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
opacity: 0.65;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.cousers-menu {
|
.cousers-menu {
|
||||||
|
@ -180,6 +185,12 @@
|
||||||
width: 285px;
|
width: 285px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|
||||||
|
z-index: 1042;
|
||||||
|
|
||||||
|
.top-title & {
|
||||||
|
top: @height-title + @height-tabs - 8px;
|
||||||
|
}
|
||||||
|
|
||||||
> label {
|
> label {
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,10 @@ define([
|
||||||
|
|
||||||
var me = this;
|
var me = this;
|
||||||
this.addListeners({
|
this.addListeners({
|
||||||
|
'FileMenu': {
|
||||||
|
'menu:hide': me.onFileMenu.bind(me, 'hide'),
|
||||||
|
'menu:show': me.onFileMenu.bind(me, 'show')
|
||||||
|
},
|
||||||
'Toolbar': {
|
'Toolbar': {
|
||||||
'render:before' : function (toolbar) {
|
'render:before' : function (toolbar) {
|
||||||
var config = DE.getController('Main').appOptions;
|
var config = DE.getController('Main').appOptions;
|
||||||
|
@ -79,12 +83,17 @@ define([
|
||||||
Common.Utils.InternalSettings.get('toolbar-height-compact') : Common.Utils.InternalSettings.get('toolbar-height-normal');
|
Common.Utils.InternalSettings.get('toolbar-height-compact') : Common.Utils.InternalSettings.get('toolbar-height-normal');
|
||||||
},
|
},
|
||||||
'undo:disabled' : function (state) {
|
'undo:disabled' : function (state) {
|
||||||
if ( me.header.btnUndo )
|
if ( me.header.btnUndo ) {
|
||||||
me.header.btnUndo.setDisabled(state);
|
if ( me.header.btnUndo.keepState )
|
||||||
|
me.header.btnUndo.keepState.disabled = state;
|
||||||
|
else me.header.btnUndo.setDisabled(state);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'redo:disabled' : function (state) {
|
'redo:disabled' : function (state) {
|
||||||
if ( me.header.btnRedo )
|
if ( me.header.btnRedo )
|
||||||
me.header.btnRedo.setDisabled(state);
|
if ( me.header.btnRedo.keepState )
|
||||||
|
me.header.btnRedo.keepState.disabled = state;
|
||||||
|
else me.header.btnRedo.setDisabled(state);
|
||||||
},
|
},
|
||||||
'save:disabled' : function (state) {
|
'save:disabled' : function (state) {
|
||||||
if ( me.header.btnSave )
|
if ( me.header.btnSave )
|
||||||
|
@ -197,6 +206,14 @@ define([
|
||||||
onWindowResize: function(e) {
|
onWindowResize: function(e) {
|
||||||
this.onLayoutChanged('window');
|
this.onLayoutChanged('window');
|
||||||
Common.NotificationCenter.trigger('window:resize');
|
Common.NotificationCenter.trigger('window:resize');
|
||||||
|
},
|
||||||
|
|
||||||
|
onFileMenu: function (opts) {
|
||||||
|
var me = this;
|
||||||
|
var _need_disable = opts == 'show';
|
||||||
|
|
||||||
|
me.header.lockHeaderBtns( 'undo', _need_disable );
|
||||||
|
me.header.lockHeaderBtns( 'redo', _need_disable );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -69,6 +69,10 @@ define([
|
||||||
|
|
||||||
// This most important part when we will tell our controller what events should be handled
|
// This most important part when we will tell our controller what events should be handled
|
||||||
this.addListeners({
|
this.addListeners({
|
||||||
|
'FileMenu': {
|
||||||
|
'menu:hide': me.onFileMenu.bind(me, 'hide'),
|
||||||
|
'menu:show': me.onFileMenu.bind(me, 'show')
|
||||||
|
},
|
||||||
'Toolbar': {
|
'Toolbar': {
|
||||||
'render:before' : function (toolbar) {
|
'render:before' : function (toolbar) {
|
||||||
var config = PE.getController('Main').appOptions;
|
var config = PE.getController('Main').appOptions;
|
||||||
|
@ -80,12 +84,18 @@ define([
|
||||||
Common.Utils.InternalSettings.get('toolbar-height-compact') : Common.Utils.InternalSettings.get('toolbar-height-normal');
|
Common.Utils.InternalSettings.get('toolbar-height-compact') : Common.Utils.InternalSettings.get('toolbar-height-normal');
|
||||||
},
|
},
|
||||||
'undo:disabled' : function (state) {
|
'undo:disabled' : function (state) {
|
||||||
if ( me.header.btnUndo )
|
if ( me.header.btnUndo ) {
|
||||||
me.header.btnUndo.setDisabled(state);
|
if ( me.header.btnUndo.keepState )
|
||||||
|
me.header.btnUndo.keepState.disabled = state;
|
||||||
|
else me.header.btnUndo.setDisabled(state);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'redo:disabled' : function (state) {
|
'redo:disabled' : function (state) {
|
||||||
if ( me.header.btnRedo )
|
if ( me.header.btnRedo ) {
|
||||||
me.header.btnRedo.setDisabled(state);
|
if ( me.header.btnRedo.keepState )
|
||||||
|
me.header.btnRedo.keepState.disabled = state;
|
||||||
|
else me.header.btnRedo.setDisabled(state);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'save:disabled' : function (state) {
|
'save:disabled' : function (state) {
|
||||||
if ( me.header.btnSave )
|
if ( me.header.btnSave )
|
||||||
|
@ -236,6 +246,14 @@ define([
|
||||||
element.msRequestFullscreen();
|
element.msRequestFullscreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onFileMenu: function (opts) {
|
||||||
|
var me = this;
|
||||||
|
var _need_disable = opts == 'show';
|
||||||
|
|
||||||
|
me.header.lockHeaderBtns( 'undo', _need_disable );
|
||||||
|
me.header.lockHeaderBtns( 'redo', _need_disable );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -67,6 +67,10 @@ define([
|
||||||
|
|
||||||
// This most important part when we will tell our controller what events should be handled
|
// This most important part when we will tell our controller what events should be handled
|
||||||
this.addListeners({
|
this.addListeners({
|
||||||
|
'FileMenu': {
|
||||||
|
'menu:hide': me.onFileMenu.bind(me, 'hide'),
|
||||||
|
'menu:show': me.onFileMenu.bind(me, 'show')
|
||||||
|
},
|
||||||
'Toolbar': {
|
'Toolbar': {
|
||||||
'render:before' : function (toolbar) {
|
'render:before' : function (toolbar) {
|
||||||
var config = SSE.getController('Main').appOptions;
|
var config = SSE.getController('Main').appOptions;
|
||||||
|
@ -78,12 +82,18 @@ define([
|
||||||
Common.Utils.InternalSettings.get('toolbar-height-compact') : Common.Utils.InternalSettings.get('toolbar-height-normal');
|
Common.Utils.InternalSettings.get('toolbar-height-compact') : Common.Utils.InternalSettings.get('toolbar-height-normal');
|
||||||
},
|
},
|
||||||
'undo:disabled' : function (state) {
|
'undo:disabled' : function (state) {
|
||||||
if ( me.header.btnUndo )
|
if ( me.header.btnUndo ) {
|
||||||
me.header.btnUndo.setDisabled(state);
|
if ( me.header.btnUndo.keepState )
|
||||||
|
me.header.btnUndo.keepState.disabled = state;
|
||||||
|
else me.header.btnUndo.setDisabled(state);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'redo:disabled' : function (state) {
|
'redo:disabled' : function (state) {
|
||||||
if ( me.header.btnRedo )
|
if ( me.header.btnRedo ) {
|
||||||
me.header.btnRedo.setDisabled(state);
|
if ( me.header.btnRedo.keepState )
|
||||||
|
me.header.btnRedo.keepState.disabled = state;
|
||||||
|
else me.header.btnRedo.setDisabled(state);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'save:disabled' : function (state) {
|
'save:disabled' : function (state) {
|
||||||
if ( me.header.btnSave )
|
if ( me.header.btnSave )
|
||||||
|
@ -205,6 +215,14 @@ define([
|
||||||
onWindowResize: function(e) {
|
onWindowResize: function(e) {
|
||||||
this.onLayoutChanged('window');
|
this.onLayoutChanged('window');
|
||||||
Common.NotificationCenter.trigger('window:resize');
|
Common.NotificationCenter.trigger('window:resize');
|
||||||
|
},
|
||||||
|
|
||||||
|
onFileMenu: function (opts) {
|
||||||
|
var me = this;
|
||||||
|
var _need_disable = opts == 'show';
|
||||||
|
|
||||||
|
me.header.lockHeaderBtns( 'undo', _need_disable );
|
||||||
|
me.header.lockHeaderBtns( 'redo', _need_disable );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue