diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 5eaf739ac8..2883fa875d 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -64,13 +64,17 @@ define([ initialize: function () { this.addListeners({ + 'FileMenu': { + 'settings:apply': this.applySettings.bind(this) + }, 'Common.Views.ReviewChanges': { // comments handlers 'reviewchange:accept': _.bind(this.onAcceptClick, this), 'reviewchange:reject': _.bind(this.onRejectClick, this), 'reviewchange:delete': _.bind(this.onDeleteClick, this), - 'reviewchange:preview': _.bind(this.onBtnPreviewClick, this) + 'reviewchange:preview': _.bind(this.onBtnPreviewClick, this), + 'lang:document': _.bind(this.onDocLanguage, this) } }); }, @@ -82,6 +86,7 @@ define([ this._state = {posx: -1000, posy: -1000, popoverVisible: false}; Common.NotificationCenter.on('reviewchanges:turn', this.onTurnPreview.bind(this)); + Common.NotificationCenter.on('spelling:turn', this.onTurnSpelling.bind(this)); Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); }, @@ -465,6 +470,14 @@ define([ } }, + onTurnSpelling: function (state) { + state = (state == 'on'); + this.view.turnSpelling(state); + + Common.localStorage.setItem("de-settings-spellcheck", state ? 1 : 0); + this.api.asc_setSpellCheck(state); + }, + createToolbarPanel: function() { return this.view.getPanel(); }, @@ -506,16 +519,49 @@ define([ } } + + if ( Common.localStorage.getBool("de-settings-spellcheck") ) + me.view.turnSpelling(true); }); } }, + applySettings: function(menu) { + this.view.turnSpelling( Common.localStorage.getBool("de-settings-spellcheck") ); + }, + synchronizeChanges: function() { if ( this.appConfig.canReview ) { this.view.markChanges( this.api.asc_HaveRevisionsChanges() ); } }, + setLanguages: function (array) { + this.langs = array; + }, + + onDocLanguage: function() { + var langs = _.map(this.langs, function(item){ + return { + displayValue: item.title, + value: item.tip, + code: item.code + } + }); + + var me = this; + (new DE.Views.Statusbar.LanguageDialog({ + languages: langs, + current: me.api.asc_getDefaultLanguage(), + handler: function(result, tip) { + if (result=='ok') { + var record = _.findWhere(langs, {'value':tip}); + record && me.api.asc_setDefaultLanguage(record.code); + } + } + })).show(); + }, + textInserted: 'Inserted:', textDeleted: 'Deleted:', textParaInserted: 'Paragraph Inserted ', diff --git a/apps/common/main/lib/view/ReviewChanges.js b/apps/common/main/lib/view/ReviewChanges.js index e33efd63b8..d64ab0ada8 100644 --- a/apps/common/main/lib/view/ReviewChanges.js +++ b/apps/common/main/lib/view/ReviewChanges.js @@ -466,6 +466,17 @@ define([ button.on('click', _click_turnpreview.bind(me)); Common.NotificationCenter.trigger('edit:complete', me); }); + + this.btnsSpelling.forEach(function(button) { + button.on('click', function (b, e) { + Common.NotificationCenter.trigger('spelling:turn', b.pressed ? 'on' : 'off'); + Common.NotificationCenter.trigger('edit:complete', me); + }); + }); + + this.btnDocLang.on('click', function (btn, e) { + me.fireEvent('lang:document', this); + }); } return { @@ -513,7 +524,18 @@ define([ }); this.btnsTurnReview = [this.btnTurnOn]; + this.btnSetSpelling = new Common.UI.Button({ + cls: 'btn-toolbar x-huge icon-top', + iconCls: 'btn-ic-docspell', + caption: this.txtSpelling, + enableToggle: true + }); + this.btnsSpelling = [this.btnSetSpelling]; + this.btnDocLang = new Common.UI.Button({ + cls: 'btn-toolbar x-huge icon-top', + iconCls: 'btn-ic-doclang', + caption: this.txtDocLang }); Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); @@ -584,6 +606,8 @@ define([ this.btnAccept.render(_html.find('#btn-change-accept')); this.btnReject.render(_html.find('#btn-change-reject')); this.btnTurnOn.render(_html.find('#btn-review-on')); + this.btnSetSpelling.render(_html.find('#slot-btn-spelling')); + this.btnDocLang.render(_html.find('#slot-set-lang')); return _html; }, @@ -617,6 +641,18 @@ define([ this.btnsTurnReview.push(button); + return button; + } else + if ( type == 'spelling' ) { + button = new Common.UI.Button({ + cls: 'btn-toolbar', + iconCls: 'btn-ic-docspell', + hintAnchor : 'top', + hint: this.tipSetSpelling, + enableToggle: true + }); + this.btnsSpelling.push(button); + return button; } }, @@ -642,6 +678,14 @@ define([ }, this); }, + turnSpelling: function (state) { + this.btnsSpelling.forEach(function(button) { + if ( button && button.pressed != state ) { + button.toggle(state, true); + } + }, this); + }, + textChangesOn: 'Preview changes', txtAccept: 'Accept', txtAcceptCurrent: 'Accept current Changes', diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 9d1c7d5530..af1a7cf67d 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1697,6 +1697,7 @@ define([ this.getApplication().getController('DocumentHolder').getView().setLanguages(langs); this.getApplication().getController('Statusbar').setLanguages(langs); + this.getApplication().getController('Common.Controllers.ReviewChanges').setLanguages(langs); }, onInsertTable: function() { diff --git a/apps/documenteditor/main/app/controller/Statusbar.js b/apps/documenteditor/main/app/controller/Statusbar.js index 89483c1ee9..2ac4a4c140 100644 --- a/apps/documenteditor/main/app/controller/Statusbar.js +++ b/apps/documenteditor/main/app/controller/Statusbar.js @@ -57,9 +57,6 @@ define([ initialize: function() { this.addListeners({ - 'FileMenu': { - 'settings:apply': _.bind(this.applySettings, this) - }, 'Statusbar': { 'langchanged': this.onLangMenu, 'zoom:value': function(value) { @@ -74,10 +71,8 @@ define([ return { 'click #btn-zoom-down': _.bind(this.zoomDocument,this,'down'), 'click #btn-zoom-up': _.bind(this.zoomDocument,this,'up'), - 'click #btn-doc-lang':_.bind(this.onBtnLanguage,this), 'click #btn-zoom-topage': _.bind(this.onBtnZoomTo, this, 'topage'), - 'click #btn-zoom-towidth': _.bind(this.onBtnZoomTo, this, 'towidth'), - 'click #btn-doc-spell': _.bind(this.onBtnSpelling, this) + 'click #btn-zoom-towidth': _.bind(this.onBtnZoomTo, this, 'towidth') }; }, @@ -98,6 +93,9 @@ define([ var review = DE.getController('Common.Controllers.ReviewChanges').getView(); me.btnTurnReview = review.getButton('turn', 'statusbar'); me.btnTurnReview.render( me.statusbar.$layout.find('#btn-doc-review') ); + + me.btnSpelling = review.getButton('spelling', 'statusbar'); + me.btnSpelling.render( me.statusbar.$layout.find('#btn-doc-spell') ); } else { me.statusbar.$el.find('.el-review').hide(); } @@ -227,48 +225,12 @@ define([ createDelayedElements: function() { this.statusbar.$el.css('z-index', ''); - - this.statusbar.btnSetSpelling.toggle(Common.localStorage.getBool("de-settings-spellcheck"), true); - }, - - onBtnLanguage: function() { - var langs = _.map(this.langs, function(item){ - return { - displayValue: item.title, - value: item.tip, - code: item.code - } - }); - - var me = this; - (new DE.Views.Statusbar.LanguageDialog({ - languages: langs, - current: me.api.asc_getDefaultLanguage(), - handler: function(result, tip) { - if (result=='ok') { - var record = _.findWhere(langs, {'value':tip}); - record && me.api.asc_setDefaultLanguage(record.code); - } - } - })).show(); }, onLangMenu: function(obj, langid, title) { this.api.put_TextPrLang(langid); }, - onBtnSpelling: function(d, b, e) { - var btn = this.statusbar.btnSetSpelling; - Common.localStorage.setItem("de-settings-spellcheck", btn.pressed ? 1 : 0); - this.api.asc_setSpellCheck(btn.pressed); - Common.NotificationCenter.trigger('edit:complete', this.statusbar); - }, - - applySettings: function(menu) { - var value = Common.localStorage.getItem("de-settings-spellcheck"); - this.statusbar.btnSetSpelling.toggle(value===null || parseInt(value) == 1, true); - }, - synchronizeChanges: function() { this.setStatusCaption(''); }, diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 348005e125..9945d1fb42 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -176,47 +176,7 @@ define([ }); Common.NotificationCenter.on('app:ready', me.onAppReady.bind(me)); - Common.NotificationCenter.on('app:face', function (config) { - if ( config.canReview ) { - var tab = {action: 'review', caption: 'Review'}; - var $panel = DE.getController('Common.Controllers.ReviewChanges').createToolbarPanel(); - - if ( $panel ) { - var button = new Common.UI.Button({ - cls: 'btn-toolbar x-huge icon-top', - iconCls: 'btn-ic-docspell', - caption: 'Spell checking', - enableToggle: true - }).render($panel.find('#slot-btn-spelling')); - button.on('click', function (e) { - console.log('spell checking button'); - }); - - button = new Common.UI.Button({ - cls: 'btn-toolbar x-huge icon-top', - iconCls: 'btn-ic-doclang', - caption: 'Language', - menu: new Common.UI.Menu({ - items: [ - { - caption: 'Content\'s language', - value: 'current' - }, { - caption: 'Document\'s language', - value: 'all' - } - ] - }) - - }).render($panel.find('#slot-set-lang')); - button.on('click', function (e) { - console.log('lang button'); - }); - - me.toolbar.addTab(tab, $panel, 3); - } - } - }); + Common.NotificationCenter.on('app:face', me.onAppShowed.bind(me)); }, onToolbarAfterRender: function(toolbar) { @@ -2778,6 +2738,18 @@ define([ Common.NotificationCenter.trigger('layout:changed', 'toolbar'); }, + onAppShowed: function (config) { + var me = this; + if ( config.canReview ) { + var tab = {action: 'review', caption: 'Review'}; + var $panel = DE.getController('Common.Controllers.ReviewChanges').createToolbarPanel(); + + if ( $panel ) { + me.toolbar.addTab(tab, $panel, 3); + } + } + }, + onAppReady: function (config) { var me = this; // me.setToolbarFolding(true); diff --git a/apps/documenteditor/main/app/template/StatusBar.template b/apps/documenteditor/main/app/template/StatusBar.template index baa6ef455d..3e0f4f0a50 100644 --- a/apps/documenteditor/main/app/template/StatusBar.template +++ b/apps/documenteditor/main/app/template/StatusBar.template @@ -19,8 +19,7 @@
- - + diff --git a/apps/documenteditor/main/app/view/Statusbar.js b/apps/documenteditor/main/app/view/Statusbar.js index b455d7c4c8..f1b2fd3ad8 100644 --- a/apps/documenteditor/main/app/view/Statusbar.js +++ b/apps/documenteditor/main/app/view/Statusbar.js @@ -85,8 +85,6 @@ define([ me.btnZoomToWidth.updateHint(me.tipFitWidth); me.btnZoomDown.updateHint(me.tipZoomOut + Common.Utils.String.platformKey('Ctrl+-')); me.btnZoomUp.updateHint(me.tipZoomIn + Common.Utils.String.platformKey('Ctrl++')); - me.btnDocLanguage.updateHint(me.tipSetDocLang); - me.btnSetSpelling.updateHint(me.tipSetSpelling); me.btnLanguage.updateHint(me.tipSetLang); me.btnLanguage.cmpEl.on({ @@ -230,16 +228,6 @@ define([ hintAnchor: 'top-right' }); - this.btnDocLanguage = new Common.UI.Button({ - hintAnchor: 'top', - disabled: true - }); - - this.btnSetSpelling = new Common.UI.Button({ - enableToggle: true, - hintAnchor: 'top' - }); - this.btnLanguage = new Common.UI.Button({ // el: panelLang, hintAnchor: 'top-left', @@ -312,8 +300,6 @@ define([ _btn_render(me.cntZoom, $('.cnt-zoom',me.$layout)); _btn_render(me.btnZoomDown, $('#btn-zoom-down', me.$layout)); _btn_render(me.btnZoomUp, $('#btn-zoom-up', me.$layout)); - _btn_render(me.btnDocLanguage, $('#btn-doc-lang', me.$layout)); - _btn_render(me.btnSetSpelling, $('#btn-doc-spell', me.$layout)); _btn_render(me.txtGoToPage, $('#status-goto-page', me.$layout)); var panelLang = $('.cnt-lang', me.$layout); @@ -370,7 +356,6 @@ define([ this.langMenu.doLayout(); if (this.langMenu.items.length>0) { this.btnLanguage.setDisabled(false); - this.btnDocLanguage.setDisabled(false); } }, @@ -402,7 +387,6 @@ define([ SetDisabled: function(disable) { var langs = this.langMenu.items.length>0; this.btnLanguage.setDisabled(disable || !langs); - this.btnDocLanguage.setDisabled(disable || !langs); }, pageIndexText : 'Page {0} of {1}', @@ -413,8 +397,6 @@ define([ tipZoomOut : 'Zoom Out', tipZoomFactor : 'Magnification', tipSetLang : 'Set Text Language', - tipSetDocLang : 'Set Document Language', - tipSetSpelling : 'Turn on spell checking option', txtPageNumInvalid : 'Page number invalid', textTrackChanges : 'Track Changes', textChangesPanel : 'Changes panel' diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 63197cca0b..431c3f5429 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -197,7 +197,11 @@ "Common.Views.ReviewChanges.txtPrev": "Previous", "Common.Views.ReviewChanges.txtNext": "Next", "Common.Views.ReviewChanges.txtTurnon": "Turn On", + "Common.Views.ReviewChanges.txtSpelling": "Spell checking", + "Common.Views.ReviewChanges.txtDocLang": "Language", "Common.Views.ReviewChanges.tipReview": "Review", + "Common.Views.ReviewChanges.tipSetDocLang": "Set Document Language", + "Common.Views.ReviewChanges.tipSetSpelling": "Spell checking", "DE.Controllers.LeftMenu.leavePageText": "All unsaved changes in this document will be lost.