diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 5009f3668..68629b54e 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -901,3 +901,20 @@ Common.Utils.InternalSettings.set('window-inactive-area-top', 0); Common.Utils.InternalSettings.set('toolbar-height-compact', Common.Utils.InternalSettings.get('toolbar-height-tabs')); Common.Utils.InternalSettings.set('toolbar-height-normal', Common.Utils.InternalSettings.get('toolbar-height-tabs') + Common.Utils.InternalSettings.get('toolbar-height-controls')); + +Common.Utils.ModalWindow = new(function() { + var count = 0; + return { + show: function() { + count++; + }, + + close: function() { + count--; + }, + + isVisible: function() { + return count>0; + } + } +})(); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 9521e300d..0c2c96c87 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -157,7 +157,7 @@ define([ this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; this.languages = null; - this.isModalShowed = 0; + // Initialize viewport if (!Common.Utils.isBrowserSupported()){ @@ -229,13 +229,13 @@ define([ me.beforeShowDummyComment = me.beforeCloseDummyComment = false; } else if (/textarea-control/.test(e.target.className)) me.inTextareaControl = true; - else if (!me.isModalShowed && /form-control/.test(e.target.className)) + else if (!Common.Utils.ModalWindow.isVisible() && /form-control/.test(e.target.className)) me.inFormControl = true; } }); $(document.body).on('blur', 'input, textarea', function(e) { - if (!me.isModalShowed) { + if (!Common.Utils.ModalWindow.isVisible()) { if (/form-control/.test(e.target.className)) me.inFormControl = false; if (me.getApplication().getController('LeftMenu').getView('LeftMenu').getMenu('file').isVisible()) @@ -283,31 +283,31 @@ define([ Common.NotificationCenter.on({ 'modal:show': function(){ - me.isModalShowed++; + Common.Utils.ModalWindow.show(); me.api.asc_enableKeyEvents(false); }, 'modal:close': function(dlg) { - me.isModalShowed--; - if (!me.isModalShowed) + Common.Utils.ModalWindow.close(); + if (!Common.Utils.ModalWindow.isVisible()) me.api.asc_enableKeyEvents(true); }, 'modal:hide': function(dlg) { - me.isModalShowed--; - if (!me.isModalShowed) + Common.Utils.ModalWindow.close(); + if (!Common.Utils.ModalWindow.isVisible()) me.api.asc_enableKeyEvents(true); }, 'settings:unitschanged':_.bind(this.unitsChanged, this), 'dataview:focus': function(e){ }, 'dataview:blur': function(e){ - if (!me.isModalShowed) { + if (!Common.Utils.ModalWindow.isVisible()) { me.api.asc_enableKeyEvents(true); } }, 'menu:show': function(e){ }, 'menu:hide': function(e, isFromInputControl){ - if (!me.isModalShowed && !isFromInputControl) + if (!Common.Utils.ModalWindow.isVisible() && !isFromInputControl) me.api.asc_enableKeyEvents(true); }, 'edit:complete': _.bind(me.onEditComplete, me) @@ -754,7 +754,7 @@ define([ if ( type == Asc.c_oAscAsyncActionType.BlockInteraction && (!this.getApplication().getController('LeftMenu').dlgSearch || !this.getApplication().getController('LeftMenu').dlgSearch.isVisible()) && (!this.getApplication().getController('Toolbar').dlgSymbolTable || !this.getApplication().getController('Toolbar').dlgSymbolTable.isVisible()) && - !((id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.inTextareaControl || this.isModalShowed || this.inFormControl)) ) { + !((id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.inTextareaControl || Common.Utils.ModalWindow.isVisible() || this.inFormControl)) ) { // this.onEditComplete(this.loadMask); //если делать фокус, то при принятии чужих изменений, заканчивается свой композитный ввод this.api.asc_enableKeyEvents(true); } @@ -2140,7 +2140,7 @@ define([ }, onPrint: function() { - if (!this.appOptions.canPrint || this.isModalShowed) return; + if (!this.appOptions.canPrint || Common.Utils.ModalWindow.isVisible()) return; if (this.api) this.api.asc_Print(new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isSafari || Common.Utils.isOpera)); // if isChrome or isSafari or isOpera == true use asc_onPrintUrl event diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 376659a6f..f73d38dcb 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -420,7 +420,7 @@ define([ }, onApiChangeFont: function(font) { - !this.getApplication().getController('Main').isModalShowed && this.toolbar.cmbFontName.onApiChangeFont(font); + !Common.Utils.ModalWindow.isVisible() && this.toolbar.cmbFontName.onApiChangeFont(font); }, onApiFontSize: function(size) { @@ -1232,7 +1232,7 @@ define([ onFontNameSelect: function(combo, record) { if (this.api) { if (record.isNewFont) { - !this.getApplication().getController('Main').isModalShowed && + !Common.Utils.ModalWindow.isVisible() && Common.UI.warning({ width: 500, closable: false, diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 3323fef10..b32a87ac0 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -135,7 +135,6 @@ define([ this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; this.languages = null; - this.isModalShowed = 0; window.storagename = 'presentation'; @@ -204,13 +203,13 @@ define([ me.dontCloseDummyComment = true; else if (/textarea-control/.test(e.target.className)) me.inTextareaControl = true; - else if (!me.isModalShowed && /form-control/.test(e.target.className)) + else if (!Common.Utils.ModalWindow.isVisible() && /form-control/.test(e.target.className)) me.inFormControl = true; } }); $(document.body).on('blur', 'input, textarea', function(e) { - if (!me.isModalShowed) { + if (!Common.Utils.ModalWindow.isVisible()) { if (/form-control/.test(e.target.className)) me.inFormControl = false; if (me.getApplication().getController('LeftMenu').getView('LeftMenu').getMenu('file').isVisible()) @@ -250,31 +249,31 @@ define([ Common.NotificationCenter.on({ 'modal:show': function(e){ - me.isModalShowed++; + Common.Utils.ModalWindow.show(); me.api.asc_enableKeyEvents(false); }, 'modal:close': function(dlg) { - me.isModalShowed--; - if (!me.isModalShowed) + Common.Utils.ModalWindow.close(); + if (!Common.Utils.ModalWindow.isVisible()) me.api.asc_enableKeyEvents(true); }, 'modal:hide': function(dlg) { - me.isModalShowed--; - if (!me.isModalShowed) + Common.Utils.ModalWindow.close(); + if (!Common.Utils.ModalWindow.isVisible()) me.api.asc_enableKeyEvents(true); }, 'settings:unitschanged':_.bind(this.unitsChanged, this), 'dataview:focus': function(e){ }, 'dataview:blur': function(e){ - if (!me.isModalShowed) { + if (!Common.Utils.ModalWindow.isVisible()) { me.api.asc_enableKeyEvents(true); } }, 'menu:show': function(e){ }, 'menu:hide': function(e, isFromInputControl){ - if (!me.isModalShowed && !isFromInputControl) + if (!Common.Utils.ModalWindow.isVisible() && !isFromInputControl) me.api.asc_enableKeyEvents(true); }, 'edit:complete': _.bind(me.onEditComplete, me) @@ -517,7 +516,7 @@ define([ if (this.appOptions.isEdit && (id==Asc.c_oAscAsyncAction['Save'] || id==Asc.c_oAscAsyncAction['ForceSaveButton']) && (!this._state.fastCoauth || this._state.usersCount<2)) this.synchronizeChanges(); - if (type == Asc.c_oAscAsyncActionType.BlockInteraction && !((id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.inTextareaControl || this.isModalShowed || this.inFormControl))) { + if (type == Asc.c_oAscAsyncActionType.BlockInteraction && !((id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.inTextareaControl || Common.Utils.ModalWindow.isVisible() || this.inFormControl))) { this.onEditComplete(this.loadMask); this.api.asc_enableKeyEvents(true); } @@ -1796,7 +1795,7 @@ define([ }, onPrint: function() { - if (!this.appOptions.canPrint || this.isModalShowed) return; + if (!this.appOptions.canPrint || Common.Utils.ModalWindow.isVisible()) return; if (this.api) this.api.asc_Print(new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isSafari || Common.Utils.isOpera)); // if isChrome or isSafari or isOpera == true use asc_onPrintUrl event diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 6d4c89df1..a99b68c08 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -396,7 +396,7 @@ define([ }, onApiChangeFont: function(font) { - !this.getApplication().getController('Main').isModalShowed && this.toolbar.cmbFontName.onApiChangeFont(font); + !Common.Utils.ModalWindow.isVisible() && this.toolbar.cmbFontName.onApiChangeFont(font); }, onApiFontSize: function(size) { @@ -1154,7 +1154,7 @@ define([ onFontNameSelect: function(combo, record) { if (this.api) { if (record.isNewFont) { - !this.getApplication().getController('Main').isModalShowed && + !Common.Utils.ModalWindow.isVisible() && Common.UI.warning({ width: 500, closable: false, diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index bb8cd489b..7dee9bd7c 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -149,7 +149,6 @@ define([ var me = this; this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; - this.isModalShowed = 0; if (!Common.Utils.isBrowserSupported()){ Common.Utils.showBrowserRestriction(); @@ -218,7 +217,7 @@ define([ me.dontCloseDummyComment = true; else if (/textarea-control/.test(e.target.className)) me.inTextareaControl = true; - else if (!me.isModalShowed && /form-control/.test(e.target.className)) + else if (!Common.Utils.ModalWindow.isVisible() && /form-control/.test(e.target.className)) me.inFormControl = true; } }); @@ -226,7 +225,7 @@ define([ $(document.body).on('blur', 'input, textarea', function(e) { if (me.isAppDisabled === true || me.isFrameClosed) return; - if ((!me.isModalShowed || $('.asc-window.enable-key-events:visible').length>0) && !(me.loadMask && me.loadMask.isVisible())) { + if ((!Common.Utils.ModalWindow.isVisible() || $('.asc-window.enable-key-events:visible').length>0) && !(me.loadMask && me.loadMask.isVisible())) { if (/form-control/.test(e.target.className)) me.inFormControl = false; if (me.getApplication().getController('LeftMenu').getView('LeftMenu').getMenu('file').isVisible()) @@ -266,30 +265,30 @@ define([ Common.NotificationCenter.on({ 'modal:show': function(e){ - me.isModalShowed++; + Common.Utils.ModalWindow.show(); me.api.asc_enableKeyEvents(false); }, 'modal:close': function(dlg) { - me.isModalShowed--; - if (!me.isModalShowed) + Common.Utils.ModalWindow.close(); + if (!Common.Utils.ModalWindow.isVisible()) me.api.asc_enableKeyEvents(true); }, 'modal:hide': function(dlg) { - me.isModalShowed--; - if (!me.isModalShowed) + Common.Utils.ModalWindow.close(); + if (!Common.Utils.ModalWindow.isVisible()) me.api.asc_enableKeyEvents(true); }, 'dataview:focus': function(e){ }, 'dataview:blur': function(e){ - if (!me.isModalShowed) { + if (!Common.Utils.ModalWindow.isVisible()) { me.api.asc_enableKeyEvents(true); } }, 'menu:show': function(e){ }, 'menu:hide': function(menu, isFromInputControl){ - if (!me.isModalShowed && (!menu || !menu.cmpEl.hasClass('from-cell-edit')) && !isFromInputControl) { + if (!Common.Utils.ModalWindow.isVisible() && (!menu || !menu.cmpEl.hasClass('from-cell-edit')) && !isFromInputControl) { me.api.asc_InputClearKeyboardElement(); me.api.asc_enableKeyEvents(true); } @@ -565,12 +564,12 @@ define([ this.setLongActionView(action); } else { if (this.loadMask) { - if (this.loadMask.isVisible() && !this.dontCloseDummyComment && !this.inTextareaControl && !this.isModalShowed && !this.inFormControl) + if (this.loadMask.isVisible() && !this.dontCloseDummyComment && !this.inTextareaControl && !Common.Utils.ModalWindow.isVisible() && !this.inFormControl) this.api.asc_enableKeyEvents(true); this.loadMask.hide(); } - if (type == Asc.c_oAscAsyncActionType.BlockInteraction && !( (id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.inTextareaControl || this.isModalShowed || this.inFormControl) )) + if (type == Asc.c_oAscAsyncActionType.BlockInteraction && !( (id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.inTextareaControl || Common.Utils.ModalWindow.isVisible() || this.inFormControl) )) this.onEditComplete(this.loadMask, {restorefocus:true}); } }, @@ -1959,7 +1958,7 @@ define([ this.isAppDisabled = data.data; break; case 'queryClose': - if ($('body .asc-window:visible').length === 0) { + if (!Common.Utils.ModalWindow.isVisible()) { this.isFrameClosed = true; this.api.asc_closeCellEditor(); Common.UI.Menu.Manager.hideAll(); @@ -2130,7 +2129,7 @@ define([ }, onPrint: function() { - if (!this.appOptions.canPrint || this.isModalShowed) return; + if (!this.appOptions.canPrint || Common.Utils.ModalWindow.isVisible()) return; Common.NotificationCenter.trigger('print', this); }, diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 08cd523a2..737263986 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -425,7 +425,7 @@ define([ // }, onApiChangeFont: function(font) { - !this.getApplication().getController('Main').isModalShowed && this.toolbar.cmbFontName.onApiChangeFont(font); + !Common.Utils.ModalWindow.isVisible() && this.toolbar.cmbFontName.onApiChangeFont(font); }, onContextMenu: function() { @@ -1353,7 +1353,7 @@ define([ onFontNameSelect: function(combo, record) { if (this.api) { if (record.isNewFont) { - !this.getApplication().getController('Main').isModalShowed && + !Common.Utils.ModalWindow.isVisible() && Common.UI.warning({ width: 500, closable: false,