diff --git a/apps/documenteditor/main/app/controller/DocumentHolder.js b/apps/documenteditor/main/app/controller/DocumentHolder.js index c941a5a183..7666117ea8 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolder.js +++ b/apps/documenteditor/main/app/controller/DocumentHolder.js @@ -189,7 +189,17 @@ define([ setApi: function(o) { this.api = o; - this.api && this.documentHolder.setApi(this.api); + if (this.api) { + if (this.mode.isEdit === true) { + this.api.asc_registerCallback('asc_onLockDocumentProps', _.bind(this.onApiLockDocumentProps, this)); + this.api.asc_registerCallback('asc_onUnLockDocumentProps', _.bind(this.onApiUnLockDocumentProps, this)); + } + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onCoAuthoringDisconnect, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); + this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this.onTextLanguage, this)); + this.api.asc_registerCallback('asc_onParaStyleName', _.bind(this.onApiParagraphStyleChange, this)); + this.documentHolder.setApi(this.api); + } return this; }, @@ -586,7 +596,23 @@ define([ }, onMouseMove: function(moveData) {}, - + + onApiLockDocumentProps: function() { + this._state.lock_doc = true; + }, + + onApiUnLockDocumentProps: function() { + this._state.lock_doc = false; + }, + + onTextLanguage: function(langid) { + this.documentHolder._currLang.id = langid; + }, + + onApiParagraphStyleChange: function(name) { + window.currentStyleName = name; + }, + onCoAuthoringDisconnect: function() { this.mode.isEdit = false; }, diff --git a/apps/documenteditor/main/app/controller/DocumentHolderExt.js b/apps/documenteditor/main/app/controller/DocumentHolderExt.js index ebe5c513d1..451bd969b4 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolderExt.js +++ b/apps/documenteditor/main/app/controller/DocumentHolderExt.js @@ -69,8 +69,6 @@ define([], function () { this.api.asc_registerCallback('asc_onSpellCheckVariantsFound', _.bind(this.onSpellCheckVariantsFound, this)); this.api.asc_registerCallback('asc_onRulerDblClick', _.bind(this.onRulerDblClick, this)); this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this.onChangeCropState, this)); - this.api.asc_registerCallback('asc_onLockDocumentProps', _.bind(this.onApiLockDocumentProps, this)); - this.api.asc_registerCallback('asc_onUnLockDocumentProps', _.bind(this.onApiUnLockDocumentProps, this)); this.api.asc_registerCallback('asc_onShowMathTrack', _.bind(this.onShowMathTrack, this)); this.api.asc_registerCallback('asc_onHideMathTrack', _.bind(this.onHideMathTrack, this)); this.api.asc_registerPlaceholderCallback(AscCommon.PlaceholderButtonType.Image, _.bind(this.onInsertImage, this)); @@ -78,11 +76,6 @@ define([], function () { this.api.asc_registerCallback('asc_onHideEyedropper', _.bind(this.hideEyedropper, this)); this.api.asc_SetMathInputType(Common.localStorage.getBool("de-equation-input-latex") ? Asc.c_oAscMathInputType.LaTeX : Asc.c_oAscMathInputType.Unicode); } - this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onCoAuthoringDisconnect, this)); - Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); - this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this.onTextLanguage, this)); - this.api.asc_registerCallback('asc_onParaStyleName', _.bind(this.onApiParagraphStyleChange, this)); - this.api.asc_registerCallback('asc_onShowForeignCursorLabel', _.bind(this.onShowForeignCursorLabel, this)); this.api.asc_registerCallback('asc_onHideForeignCursorLabel', _.bind(this.onHideForeignCursorLabel, this)); this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onFocusObject, this)); @@ -1026,10 +1019,6 @@ define([], function () { } }; - dh.onApiParagraphStyleChange = function(name) { - window.currentStyleName = name; - }; - dh.onHideContentControlsActions = function() { this.listControlMenu && this.listControlMenu.isVisible() && this.listControlMenu.hide(); var controlsContainer = this.documentHolder.cmpEl.find('#calendar-control-container'); @@ -1341,18 +1330,6 @@ define([], function () { } }; - dh.onApiLockDocumentProps = function() { - this._state.lock_doc = true; - }; - - dh.onApiUnLockDocumentProps = function() { - this._state.lock_doc = false; - }; - - dh.onTextLanguage = function(langid) { - this.documentHolder._currLang.id = langid; - }; - dh.onSpellCheckVariantsFound = function() { var me = this; var selectedElements = me.api.getSelectedElements(true); diff --git a/apps/presentationeditor/main/app/controller/DocumentHolder.js b/apps/presentationeditor/main/app/controller/DocumentHolder.js index 032a6c67a5..7878a159f9 100644 --- a/apps/presentationeditor/main/app/controller/DocumentHolder.js +++ b/apps/presentationeditor/main/app/controller/DocumentHolder.js @@ -203,6 +203,12 @@ define([ if (me.api) { me.api.asc_registerCallback('asc_onCountPages', _.bind(me.onApiCountPages, me)); me.api.asc_registerCallback('asc_onStartDemonstration', _.bind(me.onApiStartDemonstration, me)); + me.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(me.onCoAuthoringDisconnect, me)); + Common.NotificationCenter.on('api:disconnect', _.bind(me.onCoAuthoringDisconnect, me)); + me.api.asc_registerCallback('asc_onTextLanguage', _.bind(me.onTextLanguage, me)); + me.api.asc_registerCallback('asc_onUpdateThemeIndex', _.bind(me.onApiUpdateThemeIndex, me)); + me.api.asc_registerCallback('asc_onLockDocumentTheme', _.bind(me.onApiLockDocumentTheme, me)); + me.api.asc_registerCallback('asc_onUnLockDocumentTheme', _.bind(me.onApiUnLockDocumentTheme, me)); me.documentHolder.slidesCount = me.api.getCountPages(); me.documentHolder.setApi(me.api); } @@ -647,6 +653,22 @@ define([ this.documentHolder.slidesCount = count; }, + onTextLanguage: function(langid) { + this.documentHolder._currLang.id = langid; + }, + + onApiUpdateThemeIndex: function(v) { + this._state.themeId = v; + }, + + onApiLockDocumentTheme: function() { + this.documentHolder && (this.documentHolder._state.themeLock = true); + }, + + onApiUnLockDocumentTheme: function() { + this.documentHolder && (this.documentHolder._state.themeLock = false); + }, + onKeyUp: function (e) { if (e.keyCode == Common.UI.Keys.CTRL && this._needShowSpecPasteMenu && !this._handleZoomWheel && !this.btnSpecialPaste.menu.isVisible() && /area_id/.test(e.target.id)) { $('button', this.btnSpecialPaste.cmpEl).click(); diff --git a/apps/presentationeditor/main/app/controller/DocumentHolderExt.js b/apps/presentationeditor/main/app/controller/DocumentHolderExt.js index 51e11d170c..cfbb2257b4 100644 --- a/apps/presentationeditor/main/app/controller/DocumentHolderExt.js +++ b/apps/presentationeditor/main/app/controller/DocumentHolderExt.js @@ -92,16 +92,9 @@ define([], function () { me.api.asc_registerCallback('asc_onHideEyedropper', _.bind(me.hideEyedropper, me)); me.api.asc_SetMathInputType(Common.localStorage.getBool("pe-equation-input-latex") ? Asc.c_oAscMathInputType.LaTeX : Asc.c_oAscMathInputType.Unicode); } - me.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(me.onCoAuthoringDisconnect, me)); - Common.NotificationCenter.on('api:disconnect', _.bind(me.onCoAuthoringDisconnect, me)); - me.api.asc_registerCallback('asc_onTextLanguage', _.bind(me.onTextLanguage, me)); - me.api.asc_registerCallback('asc_onShowForeignCursorLabel', _.bind(me.onShowForeignCursorLabel, me)); me.api.asc_registerCallback('asc_onHideForeignCursorLabel', _.bind(me.onHideForeignCursorLabel, me)); me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onFocusObject, me)); - me.api.asc_registerCallback('asc_onUpdateThemeIndex', _.bind(me.onApiUpdateThemeIndex, me)); - me.api.asc_registerCallback('asc_onLockDocumentTheme', _.bind(me.onApiLockDocumentTheme, me)); - me.api.asc_registerCallback('asc_onUnLockDocumentTheme', _.bind(me.onApiUnLockDocumentTheme, me)); me.api.asc_registerCallback('onPluginContextMenu', _.bind(me.onPluginContextMenu, me)); } }; @@ -711,10 +704,6 @@ define([], function () { this.slideNumDiv.hide(); }; - dh.onTextLanguage = function(langid) { - this.documentHolder._currLang.id = langid; - }; - dh.onSpellCheckVariantsFound = function() { var me = this; var selectedElements = me.api.getSelectedElements(true); @@ -751,18 +740,6 @@ define([], function () { me._isFromSlideMenu = number; }; - dh.onApiUpdateThemeIndex = function(v) { - this._state.themeId = v; - }; - - dh.onApiLockDocumentTheme = function() { - this.documentHolder && (this.documentHolder._state.themeLock = true); - }; - - dh.onApiUnLockDocumentTheme = function() { - this.documentHolder && (this.documentHolder._state.themeLock = false); - }; - dh.onShowSpecialPasteOptions = function(specialPasteShowOptions) { if (this.mode && !this.mode.isEdit) return; diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 8eedebd903..123afda7a1 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -207,6 +207,12 @@ define([ setApi: function(api) { this.api = api; + if (this.api) { + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); + this.permissions && (this.permissions.isEdit===true) && this.api.asc_registerCallback('asc_onLockDefNameManager', _.bind(this.onLockDefNameManager, this)); + + } return this; }, @@ -230,6 +236,10 @@ define([ this.permissions.isEdit = false; }, + onLockDefNameManager: function(state) { + this.namedrange_locked = (state == Asc.c_oAscDefinedNameReason.LockDefNameManager); + }, + hideCoAuthTips: function() { if (this.tooltips.coauth.ref) { $(this.tooltips.coauth.ref).remove(); diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js index 05b1a5aec0..0c274147f4 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolderExt.js @@ -67,14 +67,11 @@ define([], function () { // this.api.asc_registerCallback('asc_onShowComment', this.wrapEvents.apiShowComment); /** coauthoring end **/ this.api.asc_registerCallback('asc_onHyperlinkClick', _.bind(this.onApiHyperlinkClick, this)); - this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this)); - Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this)); if (this.permissions.isEdit===true) { this.api.asc_registerCallback('asc_onSetAFDialog', _.bind(this.onApiAutofilter, this)); this.api.asc_registerCallback('asc_onEditCell', _.bind(this.onApiEditCell, this)); - this.api.asc_registerCallback('asc_onLockDefNameManager', _.bind(this.onLockDefNameManager, this)); this.api.asc_registerCallback('asc_onEntriesListMenu', _.bind(this.onEntriesListMenu, this, false)); // Alt + Down this.api.asc_registerCallback('asc_onValidationListMenu', _.bind(this.onEntriesListMenu, this, true)); this.api.asc_registerCallback('asc_onFormulaCompleteMenu', _.bind(this.onApiFormulaCompleteMenu, this)); @@ -3642,10 +3639,6 @@ define([], function () { this.isEditCell = (state != Asc.c_oAscCellEditorState.editEnd); }; - dh.onLockDefNameManager = function(state) { - this.namedrange_locked = (state == Asc.c_oAscDefinedNameReason.LockDefNameManager); - }; - dh.onChangeCropState = function(state) { this.documentHolder.menuImgCrop && this.documentHolder.menuImgCrop.menu.items[0].setChecked(state, true); };