[DE] processed buttons [Document Language], [Spell checking]
This commit is contained in:
parent
4a44c1f344
commit
375b2e400f
|
@ -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: '<b>Inserted:</b>',
|
||||
textDeleted: '<b>Deleted:</b>',
|
||||
textParaInserted: '<b>Paragraph Inserted</b> ',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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('');
|
||||
},
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
<div class="caret up img-commonctrl" />
|
||||
</div>
|
||||
</div>
|
||||
<button id="btn-doc-lang" type="button" class="btn small btn-toolbar el-edit"><span class="icon btn-ic-doclang"> </span></button>
|
||||
<button id="btn-doc-spell" type="button" class="btn small btn-toolbar el-edit"><span class="icon btn-ic-docspell"> </span></button>
|
||||
<span id="btn-doc-spell" class="el-edit"></span>
|
||||
<div class="separator short el-edit"></div>
|
||||
<div id="btn-doc-review" class="el-edit el-review" style="display: inline-block;"></div>
|
||||
<div class="separator short el-edit el-review"></div>
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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.<br> Click \"Cancel\" then \"Save\" to save them. Click \"OK\" to discard all the unsaved changes.",
|
||||
"DE.Controllers.LeftMenu.newDocumentTitle": "Unnamed document",
|
||||
"DE.Controllers.LeftMenu.notcriticalErrorTitle": "Warning",
|
||||
|
@ -1298,13 +1302,9 @@
|
|||
"DE.Views.Statusbar.LanguageDialog.btnOk": "Ok",
|
||||
"DE.Views.Statusbar.LanguageDialog.labelSelect": "Select document language",
|
||||
"DE.Views.Statusbar.pageIndexText": "Page {0} of {1}",
|
||||
"DE.Views.Statusbar.textChangesPanel": "Changes Panel",
|
||||
"DE.Views.Statusbar.textTrackChanges": "Track Changes",
|
||||
"DE.Views.Statusbar.tipFitPage": "Fit to Page",
|
||||
"DE.Views.Statusbar.tipFitWidth": "Fit to Width",
|
||||
"DE.Views.Statusbar.tipSetDocLang": "Set Document Language",
|
||||
"DE.Views.Statusbar.tipSetLang": "Set Text Language",
|
||||
"DE.Views.Statusbar.tipSetSpelling": "Spell checking",
|
||||
"DE.Views.Statusbar.tipZoomFactor": "Magnification",
|
||||
"DE.Views.Statusbar.tipZoomIn": "Zoom In",
|
||||
"DE.Views.Statusbar.tipZoomOut": "Zoom Out",
|
||||
|
|
Loading…
Reference in a new issue