From 653f3860c4ea025760c904bc4319a54ed1adf5c6 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 7 Dec 2022 17:19:09 +0300 Subject: [PATCH 1/2] For Bug 40224 --- .../main/app/template/StatusBar.template | 3 + .../documenteditor/main/app/view/Statusbar.js | 90 +++++++++++++++++- apps/documenteditor/main/locale/en.json | 6 ++ apps/documenteditor/main/locale/ru.json | 6 ++ .../img/toolbar/1.25x/word-count.png | Bin 0 -> 239 bytes .../resources/img/toolbar/1.5x/word-count.png | Bin 0 -> 248 bytes .../img/toolbar/1.75x/word-count.png | Bin 0 -> 291 bytes .../resources/img/toolbar/1x/word-count.png | Bin 0 -> 167 bytes .../resources/img/toolbar/2x/word-count.png | Bin 0 -> 248 bytes 9 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 apps/documenteditor/main/resources/img/toolbar/1.25x/word-count.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/1.5x/word-count.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/1.75x/word-count.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/1x/word-count.png create mode 100644 apps/documenteditor/main/resources/img/toolbar/2x/word-count.png diff --git a/apps/documenteditor/main/app/template/StatusBar.template b/apps/documenteditor/main/app/template/StatusBar.template index 15fffff40..ecf9c9bde 100644 --- a/apps/documenteditor/main/app/template/StatusBar.template +++ b/apps/documenteditor/main/app/template/StatusBar.template @@ -7,6 +7,9 @@
+
+
+
diff --git a/apps/documenteditor/main/app/view/Statusbar.js b/apps/documenteditor/main/app/view/Statusbar.js index 072bc49c4..d6f3f662e 100644 --- a/apps/documenteditor/main/app/view/Statusbar.js +++ b/apps/documenteditor/main/app/view/Statusbar.js @@ -161,6 +161,8 @@ define([ me.fireEvent('zoom:value', [item.value]); }); + me.btnDocInfo.menu.on('show:after', _.bind(this.onDocInfoShow, this)); + me.onChangeProtectDocument(); } @@ -289,6 +291,36 @@ define([ } }); + var template = _.template( + // '' + + '
' + + '
<%= caption %>
' + + '
<%= options.value%>
' + + '
' + // '
' + ); + + this.btnDocInfo = new Common.UI.Button({ + cls : 'btn-toolbar no-caret', + caption : this.txtWordCount, + iconCls: 'toolbar__icon word-count', + hintAnchor : 'top-left', + dataHint : '0', + dataHintDirection: 'top', + menu: new Common.UI.Menu({ + style: 'margin-top:-5px;', + menuAlign: 'bl-tl', + itemTemplate: template, + items: [ + { caption: this.txtPages, value: 0 }, + { caption: this.txtParagraphs, value: 0 }, + { caption: this.txtWords, value: 0 }, + { caption: this.txtSymbols, value: 0 }, + { caption: this.txtSpaces, value: 0 } + ] + }) + }); + var promise = new Promise(function (accept, reject) { accept(); }); @@ -320,6 +352,7 @@ define([ me.btnLanguage.setMenu(me.langMenu); me.langMenu.prevTip = 'en'; } + me.btnDocInfo.render($('#slot-status-btn-info', me.$layout)); if (config.canUseSelectHandTools) { _btn_render(me.btnSelectTool, $('#btn-select-tool', me.$layout)); @@ -341,11 +374,14 @@ define([ if (this.api) { this.api.asc_registerCallback('asc_onCountPages', _.bind(_onCountPages, this)); this.api.asc_registerCallback('asc_onCurrentPage', _.bind(_onCurrentPage, this)); + this.api.asc_registerCallback('asc_onGetDocInfoStart', _.bind(this.onGetDocInfoStart, this)); + this.api.asc_registerCallback('asc_onGetDocInfoStop', _.bind(this.onGetDocInfoEnd, this)); + this.api.asc_registerCallback('asc_onDocInfo', _.bind(this.onDocInfo, this)); + this.api.asc_registerCallback('asc_onGetDocInfoEnd', _.bind(this.onGetDocInfoEnd, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); Common.NotificationCenter.on('protect:doclock', _.bind(this.onChangeProtectDocument, this)); } - return this; }, @@ -428,6 +464,50 @@ define([ } }, + onDocInfoShow: function() { + this.api && this.api.startGetDocInfo(); + }, + + onGetDocInfoStart: function() { + this.infoObj = {PageCount: 0, WordsCount: 0, ParagraphCount: 0, SymbolsCount: 0, SymbolsWSCount:0}; + }, + + onDocInfo: function(obj) { + if (obj && this.btnDocInfo && this.btnDocInfo.menu) { + if (obj.get_PageCount()>-1) + this.btnDocInfo.menu.items[0].options.value = obj.get_PageCount(); + if (obj.get_ParagraphCount()>-1) + this.btnDocInfo.menu.items[1].options.value = obj.get_ParagraphCount(); + if (obj.get_WordsCount()>-1) + this.btnDocInfo.menu.items[2].options.value = obj.get_WordsCount(); + if (obj.get_SymbolsCount()>-1) + this.btnDocInfo.menu.items[3].options.value = obj.get_SymbolsCount(); + if (obj.get_SymbolsWSCount()>-1) + this.btnDocInfo.menu.items[4].options.value = obj.get_SymbolsWSCount(); + if (!this.timerDocInfo) { // start timer for filling info + var me = this; + this.timerDocInfo = setInterval(function(){ + me.fillDocInfo(); + }, 300); + this.fillDocInfo(); + } + } + }, + + onGetDocInfoEnd: function() { + clearInterval(this.timerDocInfo); + this.timerDocInfo = undefined; + this.fillDocInfo(); + }, + + fillDocInfo: function() { + if (!this.btnDocInfo || !this.btnDocInfo.menu || !this.btnDocInfo.menu.isVisible()) return; + + this.btnDocInfo.menu.items.forEach(function(item){ + $(item.el).html(item.template({id: item.id, caption : item.caption, options : item.options})); + }); + }, + onApiCoAuthoringDisconnect: function() { this.setMode({isDisconnected:true}); this.SetDisabled(true); @@ -445,7 +525,13 @@ define([ textTrackChanges : 'Track Changes', textChangesPanel : 'Changes panel', tipSelectTool : 'Select tool', - tipHandTool : 'Hand tool' + tipHandTool : 'Hand tool', + txtWordCount: 'Word count', + txtPages: 'Pages', + txtWords: 'Words', + txtParagraphs: 'Paragraphs', + txtSymbols: 'Symbols', + txtSpaces: 'Symbols with spaces' }, DE.Views.Statusbar || {})); } ); \ No newline at end of file diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 1568d33e0..9411c70e9 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -2731,6 +2731,12 @@ "DE.Views.Statusbar.tipZoomIn": "Zoom in", "DE.Views.Statusbar.tipZoomOut": "Zoom out", "DE.Views.Statusbar.txtPageNumInvalid": "Page number invalid", + "DE.Views.Statusbar.txtWordCount": "Word count", + "DE.Views.Statusbar.txtPages": "Pages", + "DE.Views.Statusbar.txtWords": "Words", + "DE.Views.Statusbar.txtParagraphs": "Paragraphs", + "DE.Views.Statusbar.txtSymbols": "Symbols", + "DE.Views.Statusbar.txtSpaces": "Symbols with spaces", "DE.Views.StyleTitleDialog.textHeader": "Create new style", "DE.Views.StyleTitleDialog.textNextStyle": "Next paragraph style", "DE.Views.StyleTitleDialog.textTitle": "Title", diff --git a/apps/documenteditor/main/locale/ru.json b/apps/documenteditor/main/locale/ru.json index 1bb1485f9..b07265c31 100644 --- a/apps/documenteditor/main/locale/ru.json +++ b/apps/documenteditor/main/locale/ru.json @@ -2730,6 +2730,12 @@ "DE.Views.Statusbar.tipZoomIn": "Увеличить", "DE.Views.Statusbar.tipZoomOut": "Уменьшить", "DE.Views.Statusbar.txtPageNumInvalid": "Неправильный номер страницы", + "DE.Views.Statusbar.txtWordCount": "Количество слов", + "DE.Views.Statusbar.txtPages": "Страницы", + "DE.Views.Statusbar.txtWords": "Слова", + "DE.Views.Statusbar.txtParagraphs": "Абзацы", + "DE.Views.Statusbar.txtSymbols": "Символы", + "DE.Views.Statusbar.txtSpaces": "Символы с пробелами", "DE.Views.StyleTitleDialog.textHeader": "Создание нового стиля", "DE.Views.StyleTitleDialog.textNextStyle": "Стиль следующего абзаца", "DE.Views.StyleTitleDialog.textTitle": "Название", diff --git a/apps/documenteditor/main/resources/img/toolbar/1.25x/word-count.png b/apps/documenteditor/main/resources/img/toolbar/1.25x/word-count.png new file mode 100644 index 0000000000000000000000000000000000000000..2f1cbdd08035004969dd9b6a827895273390ce7b GIT binary patch literal 239 zcmVX1^@s6b5wmq0002CNkl!y7NP~F zqcwj3V)RpDBR*1#9r{-!RTDwkTW%y-jpX{Vt--LWM+&|*7*_U( p_A?}*(E=m6G0jNGelKhGr>hk;s_yxd?7EwX2H#Ff0Y;j0000F!Z>JyRZBY<#)om5h zIM}y^`Gte^W)|<8tu4)pH&bOKH%s65-oew{`2Is!+XCXYp{6 zZ_CPGb5kysb8cR`jqAwme1SCYT+xp0(cGIw5>>>HUJROXWot@e3z)Ssq*1u$@Rp>Y zic_HzRy%&+z1;Ot^__K|=h~mYf>`%mpSEYyf;B&Cisno;*ctT9__0pwL>sx}tMY66 nUSE4`*qSs|h#lzU{SSC;cWV}Q?|Kse^fiO0tDnm{r-UW|Wo~&b literal 0 HcmV?d00001 diff --git a/apps/documenteditor/main/resources/img/toolbar/1x/word-count.png b/apps/documenteditor/main/resources/img/toolbar/1x/word-count.png new file mode 100644 index 0000000000000000000000000000000000000000..5744e02840e3a122a07f9d458deb0b29dd88fad4 GIT binary patch literal 167 zcmeAS@N?(olHy`uVBq!ia0vp^8bB<F#S6atgyu`lmN98+xTPeeiJ)7@w zExFY^AuC_BV4u!`xeFQmmcQeA@FjpjaLyZrrrV_kC*#@}W~AsJjz3Vii{Z-|x%>$g S0h@p}GkCiCxvXF!Z)Y6jYBk_t`TP0F z`Kj!3+UsghMkTV@?DUZE5#N;yRJTE|`t#@e1!ols7#kTFwiu{3IYdb?JgC;aV||C+ ziwP(e5T;cA-uaJT$&`)&BgJWfdsIJoox7)4==30fR u92b;y76_i6%6g42Tz^A}9neuLo-urxm2&B0q53@_kHOQ`&t;ucLK6V_?q5Ct literal 0 HcmV?d00001 From 806d8d47ae8ae769ede5b9a7476d600580da8ad6 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 7 Dec 2022 17:39:55 +0300 Subject: [PATCH 2/2] Fix styles --- apps/documenteditor/main/app/template/StatusBar.template | 3 ++- apps/documenteditor/main/resources/less/statusbar.less | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/documenteditor/main/app/template/StatusBar.template b/apps/documenteditor/main/app/template/StatusBar.template index ecf9c9bde..18bd8e80d 100644 --- a/apps/documenteditor/main/app/template/StatusBar.template +++ b/apps/documenteditor/main/app/template/StatusBar.template @@ -7,8 +7,9 @@
+
-
+
diff --git a/apps/documenteditor/main/resources/less/statusbar.less b/apps/documenteditor/main/resources/less/statusbar.less index b59016d5d..287a43168 100644 --- a/apps/documenteditor/main/resources/less/statusbar.less +++ b/apps/documenteditor/main/resources/less/statusbar.less @@ -66,7 +66,8 @@ } } - #btn-cnt-lang { + #btn-cnt-lang, + #slot-status-btn-info { button { font-weight: 700; }