File menu refactoring

This commit is contained in:
Julia Radzhabova 2021-06-28 20:03:50 +03:00
parent 26b2384ba1
commit b6b8123881
3 changed files with 26 additions and 6 deletions

View file

@ -416,9 +416,9 @@ define([
_btn_rename = this.getButton('rename'), _btn_rename = this.getButton('rename'),
_btn_protect = this.getButton('protect'); _btn_protect = this.getButton('protect');
_btn_save[(disable || !this.mode.isEdit)?'hide':'show'](); _btn_save.setDisabled(disable || !this.mode.isEdit);
_btn_protect[(disable || !this.mode.isEdit)?'hide':'show'](); _btn_protect.setDisabled(disable || !this.mode.isEdit);
_btn_rename[(disable || !this.mode.canRename || this.mode.isDesktopApp) ?'hide':'show'](); _btn_rename.setDisabled(disable || !this.mode.canRename || this.mode.isDesktopApp);
}, },
isVisible: function () { isVisible: function () {

View file

@ -140,6 +140,10 @@ define([
caption : this.btnRenameCaption, caption : this.btnRenameCaption,
canFocused: false canFocused: false
}); });
if ( !!this.options.miRename ) {
this.miRename.setDisabled(this.options.miRename.isDisabled());
delete this.options.miRename;
}
this.miProtect = new Common.UI.MenuItem({ this.miProtect = new Common.UI.MenuItem({
el : $markup.elementById('#fm-btn-protect'), el : $markup.elementById('#fm-btn-protect'),
@ -452,9 +456,9 @@ define([
_btn_rename = this.getButton('rename'), _btn_rename = this.getButton('rename'),
_btn_protect = this.getButton('protect'); _btn_protect = this.getButton('protect');
_btn_save[(disable || !this.mode.isEdit)?'hide':'show'](); _btn_save.setDisabled(disable || !this.mode.isEdit);
_btn_protect[(disable || !this.mode.isEdit)?'hide':'show'](); _btn_protect.setDisabled(disable || !this.mode.isEdit);
_btn_rename[(disable || !this.mode.canRename || this.mode.isDesktopApp) ?'hide':'show'](); _btn_rename.setDisabled(disable || !this.mode.canRename || this.mode.isDesktopApp);
}, },
btnSaveCaption : 'Save', btnSaveCaption : 'Save',

View file

@ -127,6 +127,10 @@ define([
caption : this.btnRenameCaption, caption : this.btnRenameCaption,
canFocused: false canFocused: false
}); });
if ( !!this.options.miRename ) {
this.miRename.setDisabled(this.options.miRename.isDisabled());
delete this.options.miRename;
}
this.miProtect = new Common.UI.MenuItem({ this.miProtect = new Common.UI.MenuItem({
el : $markup.elementById('#fm-btn-protect'), el : $markup.elementById('#fm-btn-protect'),
@ -402,6 +406,8 @@ define([
if ( !this.rendered ) { if ( !this.rendered ) {
if (type == 'save') { if (type == 'save') {
return this.options.miSave ? this.options.miSave : (this.options.miSave = new Common.UI.MenuItem({})); return this.options.miSave ? this.options.miSave : (this.options.miSave = new Common.UI.MenuItem({}));
} else if (type == 'rename') {
return this.options.miRename ? this.options.miRename : (this.options.miRename = new Common.UI.MenuItem({}));
} else } else
if (type == 'protect') { if (type == 'protect') {
return this.options.miProtect ? this.options.miProtect : (this.options.miProtect = new Common.UI.MenuItem({})); return this.options.miProtect ? this.options.miProtect : (this.options.miProtect = new Common.UI.MenuItem({}));
@ -410,6 +416,9 @@ define([
if (type == 'save') { if (type == 'save') {
return this.miSave; return this.miSave;
} else } else
if (type == 'rename') {
return this.miRename;
}else
if (type == 'protect') { if (type == 'protect') {
return this.miProtect; return this.miProtect;
} }
@ -423,6 +432,13 @@ define([
this.panels['opts'].disableEditing(disabled); this.panels['opts'].disableEditing(disabled);
this.miProtect.setDisabled(disabled); this.miProtect.setDisabled(disabled);
} }
var _btn_save = this.getButton('save'),
_btn_rename = this.getButton('rename'),
_btn_protect = this.getButton('protect');
_btn_save.setDisabled(disable || !this.mode.isEdit);
_btn_protect.setDisabled(disable || !this.mode.isEdit);
_btn_rename.setDisabled(disable || !this.mode.canRename || this.mode.isDesktopApp);
}, },
btnSaveCaption : 'Save', btnSaveCaption : 'Save',