[SSE] Header/footer: check before apply options

This commit is contained in:
Julia Radzhabova 2019-07-25 14:43:52 +03:00
parent dbd8ee98be
commit 51a369e22b
2 changed files with 73 additions and 10 deletions

View file

@ -179,8 +179,17 @@ define([
}); });
this.chFirstPage.on('change', _.bind(function(field, newValue, oldValue, eOpts){ this.chFirstPage.on('change', _.bind(function(field, newValue, oldValue, eOpts){
var checked = (field.getValue()=='checked'); var checked = (field.getValue()=='checked');
if (this.HFObject) var id = (this.HFObject) ? this.HFObject.setDifferentFirst(checked) : null;
this.HFObject.setDifferentFirst(checked); if (id) {
var me = this;
this.showError(function() {
field.setValue(!checked, true);
_.delay(function(){
me.onCanvasClick(id);
},50);
});
return;
}
this.btnFirst.setVisible(checked); this.btnFirst.setVisible(checked);
if (!checked && this.btnFirst.isActive()) if (!checked && this.btnFirst.isActive())
@ -193,8 +202,17 @@ define([
}); });
this.chOddPage.on('change', _.bind(function(field, newValue, oldValue, eOpts){ this.chOddPage.on('change', _.bind(function(field, newValue, oldValue, eOpts){
var checked = (field.getValue()=='checked'); var checked = (field.getValue()=='checked');
if (this.HFObject) var id = (this.HFObject) ? this.HFObject.setDifferentOddEven(checked) : null;
this.HFObject.setDifferentOddEven(checked); if (id) {
var me = this;
this.showError(function() {
field.setValue(!checked, true);
_.delay(function(){
me.onCanvasClick(id);
},50);
});
return;
}
this.btnOdd.setVisible(checked); this.btnOdd.setVisible(checked);
this.btnEven.setVisible(checked); this.btnEven.setVisible(checked);
@ -691,16 +709,33 @@ define([
}, },
_handleInput: function(state) { _handleInput: function(state) {
if (this.HFObject) {
var id = this.HFObject.destroy(state=='ok');
if (id) {
var me = this;
this.showError(function() {
_.delay(function(){
me.onCanvasClick(id);
},50);
});
return;
}
this.HFObject = null;
}
if (this.options.handler) { if (this.options.handler) {
this.options.handler.call(this, this, state); this.options.handler.call(this, this, state);
} }
if (this.HFObject) {
this.HFObject.destroy(state=='ok');
this.HFObject = null;
}
this.close(); this.close();
}, },
showError: function(callback) {
Common.UI.warning({
title: this.notcriticalErrorTitle,
msg : this.textMaxError,
callback: callback
});
},
scrollerUpdate: function() { scrollerUpdate: function() {
for (var name in this.scrollers) { for (var name in this.scrollers) {
this.scrollers[name] && this.scrollers[name].update(); this.scrollers[name] && this.scrollers[name].update();
@ -876,8 +911,34 @@ define([
}, },
onPageTypeToggle: function(type, btn, state) { onPageTypeToggle: function(type, btn, state) {
if (this._pagetype) return;
if (state && this.HFObject) { if (state && this.HFObject) {
this.HFObject.switchHeaderFooterType(type); var prev = this.HFObject.getPageType(),
id = this.HFObject.switchHeaderFooterType(type);
if (id) {
this._pagetype = true;
var me = this;
this.showError(function() {
switch (prev) {
case Asc.c_oAscHeaderFooterType.odd:
me.btnOdd.isVisible() ? me.btnOdd.toggle(true) : me.btnAll.toggle(true);
break;
case Asc.c_oAscHeaderFooterType.even:
me.btnEven.toggle(true);
break;
case Asc.c_oAscHeaderFooterType.first:
me.btnFirst.toggle(true);
break;
}
_.delay(function(){
me.onCanvasClick(id);
},50);
me._pagetype = false;
});
return;
}
this.scrollerScrollTop(); this.scrollerScrollTop();
this.onCanvasClick(this.currentCanvas, undefined, true); this.onCanvasClick(this.currentCanvas, undefined, true);
} }
@ -987,7 +1048,8 @@ define([
textFirst: 'First page', textFirst: 'First page',
textOdd: 'Odd page', textOdd: 'Odd page',
textEven: 'Even page', textEven: 'Even page',
textAll: 'All pages' textAll: 'All pages',
textMaxError: 'The text string you entered is too long. Reduce the number of characters used.'
}, SSE.Views.HeaderFooterDialog || {})) }, SSE.Views.HeaderFooterDialog || {}))
}); });

View file

@ -1662,6 +1662,7 @@
"SSE.Views.HeaderFooterDialog.textOdd": "Odd page", "SSE.Views.HeaderFooterDialog.textOdd": "Odd page",
"SSE.Views.HeaderFooterDialog.textEven": "Even page", "SSE.Views.HeaderFooterDialog.textEven": "Even page",
"SSE.Views.HeaderFooterDialog.textAll": "All pages", "SSE.Views.HeaderFooterDialog.textAll": "All pages",
"SSE.Views.HeaderFooterDialog.textMaxError": "The text string you entered is too long. Reduce the number of characters used.",
"SSE.Views.HyperlinkSettingsDialog.cancelButtonText": "Cancel", "SSE.Views.HyperlinkSettingsDialog.cancelButtonText": "Cancel",
"SSE.Views.HyperlinkSettingsDialog.strDisplay": "Display", "SSE.Views.HyperlinkSettingsDialog.strDisplay": "Display",
"SSE.Views.HyperlinkSettingsDialog.strLinkTo": "Link to", "SSE.Views.HyperlinkSettingsDialog.strLinkTo": "Link to",