Skip to content

Commit

Permalink
Merge pull request #3023 from ONLYOFFICE/feature/page-color
Browse files Browse the repository at this point in the history
[DE] Set page color
  • Loading branch information
JuliaRadzhabova authored May 31, 2024
2 parents 176301e + 5ed2eb8 commit 57e509e
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 3 deletions.
52 changes: 50 additions & 2 deletions apps/documenteditor/main/app/controller/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ define([
$('#id-toolbar-menu-new-control-color').on('click', _.bind(this.onNewControlsColor, this));
toolbar.listStylesAdditionalMenuItem.on('click', this.onMenuSaveStyle.bind(this));
toolbar.btnPrint.menu && toolbar.btnPrint.menu.on('item:click', _.bind(this.onPrintMenu, this));
toolbar.btnPageColor.menu.on('show:after', _.bind(this.onPageColorShowAfter, this));
toolbar.btnPageColor.on('color:select', _.bind(this.onSelectPageColor, this));
toolbar.mnuPageNoFill.on('click', _.bind(this.onPageNoFillClick, this));
Common.NotificationCenter.on('leftmenu:save', _.bind(this.tryToSave, this));
this.onSetupCopyStyleButton();
this.onBtnChangeState('undo:disabled', toolbar.btnUndo, toolbar.btnUndo.isDisabled());
Expand Down Expand Up @@ -972,14 +975,16 @@ define([

onApiLockDocumentProps: function() {
if (this._state.lock_doc!==true) {
this.toolbar.lockToolbar(Common.enumLock.docPropsLock, true, {array: [this.toolbar.btnPageOrient, this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnColumns, this.toolbar.btnLineNumbers, this.toolbar.btnHyphenation]});
this.toolbar.lockToolbar(Common.enumLock.docPropsLock, true, {array: [this.toolbar.btnPageOrient, this.toolbar.btnPageSize, this.toolbar.btnPageMargins,
this.toolbar.btnColumns, this.toolbar.btnLineNumbers, this.toolbar.btnHyphenation, this.toolbar.btnPageColor]});
if (this._state.activated) this._state.lock_doc = true;
}
},

onApiUnLockDocumentProps: function() {
if (this._state.lock_doc!==false) {
this.toolbar.lockToolbar(Common.enumLock.docPropsLock, false, {array: [this.toolbar.btnPageOrient, this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnColumns, this.toolbar.btnLineNumbers, this.toolbar.btnHyphenation]});
this.toolbar.lockToolbar(Common.enumLock.docPropsLock, false, {array: [this.toolbar.btnPageOrient, this.toolbar.btnPageSize, this.toolbar.btnPageMargins,
this.toolbar.btnColumns, this.toolbar.btnLineNumbers, this.toolbar.btnHyphenation, this.toolbar.btnPageColor]});
if (this._state.activated) this._state.lock_doc = false;
}
},
Expand Down Expand Up @@ -1471,6 +1476,33 @@ define([
this.showSelectedBulletOnOpen(type, picker);
},

onPageColorShowAfter: function(menu, e) {
if (!(e && e.target===e.currentTarget))
return;

var picker = this.toolbar.mnuPageColorPicker,
color = this.api.asc_getPageColor();

this.toolbar.mnuPageNoFill.setChecked(!color, true);
picker.clearSelection();
if (color) {
color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME ?
color = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()} :
color = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b());

if ( typeof(color) == 'object' ) {
for (var i=0; i<10; i++) {
if ( Common.Utils.ThemeColor.ThemeValues[i] == color.effectValue ) {
picker.select(color,true);
break;
}
}
} else {
picker.select(color,true);
}
}
},

onApiUpdateListPatterns: function(data) {
if (!data) return;
this._listPatterns = [data.singleBullet, data.singleNumbering, data.multiLevel];
Expand Down Expand Up @@ -2785,6 +2817,20 @@ define([
Common.NotificationCenter.trigger('edit:complete', this);
},

onSelectPageColor: function(btn, color) {
if (this.api)
this.api.asc_putPageColor(Common.Utils.ThemeColor.getRgbColor(color));

Common.component.Analytics.trackEvent('ToolBar', 'Page Color');
},

onPageNoFillClick: function(item) {
if (this.api && item.checked)
this.api.asc_putPageColor(null);

Common.component.Analytics.trackEvent('ToolBar', 'Page Color');
},

eyedropperStart: function () {
if (this.toolbar.btnCopyStyle.pressed) {
this.toolbar.btnCopyStyle.toggle(false, true);
Expand Down Expand Up @@ -3238,6 +3284,8 @@ define([
this.onParagraphColor(this._state.clrshd_asccolor);
}
this._state.clrshd_asccolor = undefined;

updateColors(this.toolbar.mnuPageColorPicker, 1);
},

_onInitEditorStyles: function(styles) {
Expand Down
1 change: 1 addition & 0 deletions apps/documenteditor/main/app/template/Toolbar.template
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
<div class="separator long"></div>
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-watermark"></span>
<span class="btn-slot text x-huge" id="slot-btn-pagecolor"></span>
</div>
<div class="separator long"></div>
<div class="group">
Expand Down
33 changes: 32 additions & 1 deletion apps/documenteditor/main/app/view/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1572,8 +1572,29 @@ define([
dataHintOffset: 'small'
});

me.btnPageColor = new Common.UI.ButtonColored({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-page-color',
lock: [_set.docPropsLock, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.disableOnStart, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.viewMode],
caption: me.capBtnPageColor,
menu: true,
eyeDropper: false,
hideColorLine: true,
additionalItemsBefore: [
me.mnuPageNoFill = new Common.UI.MenuItem({
caption: me.strMenuNoFill,
style: Common.UI.isRTL() ? 'padding-right:20px;' : 'padding-left:20px;',
checkable: true
}),
{caption: '--'}
],
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});

me.toolbarControls.push(me.btnImgAlign,
me.btnImgGroup, me.btnImgForward, me.btnImgBackward, me.btnImgWrapping, me.btnWatermark);
me.btnImgGroup, me.btnImgForward, me.btnImgBackward, me.btnImgWrapping, me.btnWatermark, me.btnPageColor);

//
// Menus
Expand Down Expand Up @@ -2048,6 +2069,7 @@ define([
_injectComponent('#slot-spin-space-after', this.numSpacingAfter);
_injectComponent('#slot-lbl-space-before', this.lblSpacingBefore);
_injectComponent('#slot-lbl-space-after', this.lblSpacingAfter);
_injectComponent('#slot-btn-pagecolor', this.btnPageColor);

this.btnsPageBreak = Common.Utils.injectButtons($host.find('.btn-slot.btn-pagebreak'), '', 'toolbar__icon btn-pagebreak', this.capBtnInsPagebreak,
[Common.enumLock.paragraphLock, Common.enumLock.headerLock, Common.enumLock.richEditLock, Common.enumLock.plainEditLock, Common.enumLock.inEquation, Common.enumLock.richDelLock,
Expand Down Expand Up @@ -2450,6 +2472,8 @@ define([
this.btnCopyStyle.updateHint(this.tipCopyStyle + Common.Utils.String.platformKey('Alt+Ctrl+C'));
this.btnColorSchemas.updateHint(this.tipColorSchemas);
this.btnHyphenation.updateHint(this.tipHyphenation);
this.btnPageColor.updateHint(this.tipPageColor);


// set menus

Expand Down Expand Up @@ -3065,6 +3089,11 @@ define([
});
this.mnuHighlightControls.setInnerMenu([{menu: this.mnuControlsColorPicker, index: 2}]);
}

if (this.btnPageColor.cmpEl) {
this.btnPageColor.setMenu();
this.mnuPageColorPicker = this.btnPageColor.getPicker();
}
},

updateMetricUnit: function () {
Expand Down Expand Up @@ -3685,6 +3714,8 @@ define([
txtAutoText: 'Auto',
textEditMode: 'Edit PDF',
tipEditMode: 'Edit current file.<br>The page will be reloaded.',
capBtnPageColor: 'Page Color',
tipPageColor: 'Change page color'
}
})(), DE.Views.Toolbar || {}));
});
2 changes: 2 additions & 0 deletions apps/documenteditor/main/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3545,6 +3545,8 @@
"DE.Views.Toolbar.txtMarginAlign": "Align to margin",
"DE.Views.Toolbar.txtObjectsAlign": "Align selected objects",
"DE.Views.Toolbar.txtPageAlign": "Align to page",
"DE.Views.Toolbar.capBtnPageColor": "Page Color",
"DE.Views.Toolbar.tipPageColor": "Change page color",
"DE.Views.ViewTab.textAlwaysShowToolbar": "Always Show Toolbar",
"DE.Views.ViewTab.textDarkDocument": "Dark Document",
"DE.Views.ViewTab.textFitToPage": "Fit To Page",
Expand Down

0 comments on commit 57e509e

Please sign in to comment.