diff --git a/apps/common/main/lib/component/ColorButton.js b/apps/common/main/lib/component/ColorButton.js index d4903fb22e..f15ca52efa 100644 --- a/apps/common/main/lib/component/ColorButton.js +++ b/apps/common/main/lib/component/ColorButton.js @@ -72,6 +72,7 @@ define([ (this.options.effects!==undefined) && (config['effects'] = this.options.effects); (this.options.colorHints!==undefined) && (config['colorHints'] = this.options.colorHints); (this.options.paletteCls!==undefined) && (config['cls'] = this.options.paletteCls); + (this.options.storageSuffix!==undefined) && (config['storageSuffix'] = this.options.storageSuffix); this.colorPicker = new Common.UI.ThemeColorPalette(config); this.colorPicker.on('select', _.bind(this.onColorSelect, this)); diff --git a/apps/common/main/lib/util/LocalStorage.js b/apps/common/main/lib/util/LocalStorage.js index cfe170c47d..ef9024ef71 100644 --- a/apps/common/main/lib/util/LocalStorage.js +++ b/apps/common/main/lib/util/LocalStorage.js @@ -99,6 +99,11 @@ define(['gateway'], function () { return (value!==null) ? (parseInt(value) != 0) : defValue; }; + var _getItemAsInt = function (name, defValue) { + var value = _getItem(name); + return (value!==null) ? parseInt(value) : defValue || 0; + }; + var _getItemExists = function (name) { var value = _getItem(name); return value !== null; @@ -125,6 +130,7 @@ define(['gateway'], function () { _storeName = name; }, getItem: _getItem, + getItemAsInt: _getItemAsInt, getBool: _getItemAsBool, setBool: _setItemAsBool, setItem: _setItem, diff --git a/apps/pdfeditor/main/app/controller/Toolbar.js b/apps/pdfeditor/main/app/controller/Toolbar.js index 35ed14d0c4..d5daae1bdd 100644 --- a/apps/pdfeditor/main/app/controller/Toolbar.js +++ b/apps/pdfeditor/main/app/controller/Toolbar.js @@ -258,23 +258,27 @@ define([ }, - onCreateAnnotBar: function(btnStrikeout, mnuStrikeoutColorPicker, btnUnderline, mnuUnderlineColorPicker, btnHighlight, mnuHighlightColorPicker) { + onCreateAnnotBar: function(btnStrikeout, btnUnderline, btnHighlight) { var toolbar = this.toolbar; - btnStrikeout.currentColor = toolbar.btnStrikeout.currentColor; - btnStrikeout.setColor(btnStrikeout.currentColor); - btnStrikeout.toggle(toolbar.btnStrikeout.pressed, true); + toolbar.btnsStrikeout.push(btnStrikeout); + btnStrikeout.toggle(toolbar.btnStrikeout.pressed, true); + btnStrikeout.setColor(toolbar.btnStrikeout.currentColor); + var mnuStrikeoutColorPicker = toolbar.createPen(btnStrikeout, 'strikeout', true); toolbar.mnusStrikeoutColorPicker.push(mnuStrikeoutColorPicker); - btnUnderline.currentColor = toolbar.btnUnderline.currentColor; - btnUnderline.setColor(btnUnderline.currentColor); - btnUnderline.toggle(toolbar.btnUnderline.pressed, true); + toolbar.btnsUnderline.push(btnUnderline); + btnUnderline.toggle(toolbar.btnUnderline.pressed, true); + btnUnderline.setColor(toolbar.btnUnderline.currentColor); + var mnuUnderlineColorPicker = toolbar.createPen(btnUnderline, 'underline', true); toolbar.mnusUnderlineColorPicker.push(mnuUnderlineColorPicker); - btnHighlight.currentColor = toolbar.btnHighlight.currentColor; - btnHighlight.setColor(btnHighlight.currentColor); - btnHighlight.toggle(toolbar.btnHighlight.pressed, true); + toolbar.btnsHighlight.push(btnHighlight); + btnHighlight.toggle(toolbar.btnHighlight.pressed, true); + btnHighlight.setColor(toolbar.btnHighlight.currentColor); + var mnuHighlightColorPicker = toolbar.createPen(btnHighlight, 'highlight', true); toolbar.mnusHighlightColorPicker.push(mnuHighlightColorPicker); + btnStrikeout.on('click', _.bind(this.onBtnStrikeout, this)); mnuStrikeoutColorPicker.on('select', _.bind(this.onSelectStrikeoutColor, this)); btnUnderline.on('click', _.bind(this.onBtnUnderline, this)); @@ -937,7 +941,7 @@ define([ var r = strcolor[0] + strcolor[1], g = strcolor[2] + strcolor[3], b = strcolor[4] + strcolor[5]; - me.api.SetMarkerFormat(me.toolbar.btnStrikeout.options.type, true, 100, parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)); + me.api.SetMarkerFormat(me.toolbar.btnStrikeout.options.type, true, Common.Utils.InternalSettings.get("pdfe-annot-opacity-strikeout") , parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)); // me.toolbar.mnuStrikeoutTransparent.setChecked(false, true); } Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnStrikeout); @@ -997,7 +1001,7 @@ define([ var r = strcolor[0] + strcolor[1], g = strcolor[2] + strcolor[3], b = strcolor[4] + strcolor[5]; - me.api.SetMarkerFormat(me.toolbar.btnUnderline.options.type, true, 100, parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)); + me.api.SetMarkerFormat(me.toolbar.btnUnderline.options.type, true, Common.Utils.InternalSettings.get("pdfe-annot-opacity-underline"), parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)); // me.toolbar.mnuUnderlineTransparent.setChecked(false, true); } Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnUnderline); @@ -1057,7 +1061,7 @@ define([ var r = strcolor[0] + strcolor[1], g = strcolor[2] + strcolor[3], b = strcolor[4] + strcolor[5]; - me.api.SetMarkerFormat(me.toolbar.btnHighlight.options.type, true, 100, parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)); + me.api.SetMarkerFormat(me.toolbar.btnHighlight.options.type, true, Common.Utils.InternalSettings.get("pdfe-annot-opacity-highlight"), parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)); // me.toolbar.mnuHighlightTransparent.setChecked(false, true); } Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnHighlight); diff --git a/apps/pdfeditor/main/app/view/DocumentHolderExt.js b/apps/pdfeditor/main/app/view/DocumentHolderExt.js index b2290fbe70..67fad382b8 100644 --- a/apps/pdfeditor/main/app/view/DocumentHolderExt.js +++ b/apps/pdfeditor/main/app/view/DocumentHolderExt.js @@ -1491,6 +1491,12 @@ define([], function () { colorLine: false, colors: config.colors, color: '3D8A44', + additionalItemsAfter: [ + new Common.UI.MenuItem({ + template: _.template('
'), + stopPropagation: true + }) + ], dynamiccolors: config.dynamiccolors, themecolors: config.themecolors, effects: config.effects, @@ -1502,9 +1508,6 @@ define([], function () { type: AscPDF.ANNOTATIONS_TYPES.Underline }); annotBarBtns.push(this.btnUnderline); - this.btnUnderline.setMenu(); - this.mnuUnderlineColorPicker = this.btnUnderline.getPicker(); - this.btnUnderline.currentColor = this.btnUnderline.color; this.btnStrikeout = new Common.UI.ButtonColored({ parentEl: $('#annot-bar-strikeout', container), @@ -1517,6 +1520,12 @@ define([], function () { colorLine: false, colors: config.colors, color: 'D43230', + additionalItemsAfter: [ + new Common.UI.MenuItem({ + template: _.template('
'), + stopPropagation: true + }) + ], dynamiccolors: config.dynamiccolors, themecolors: config.themecolors, effects: config.effects, @@ -1528,9 +1537,6 @@ define([], function () { type: AscPDF.ANNOTATIONS_TYPES.Strikeout }); annotBarBtns.push(this.btnStrikeout); - this.btnStrikeout.setMenu(); - this.mnuStrikeoutColorPicker = this.btnStrikeout.getPicker(); - this.btnStrikeout.currentColor = this.btnStrikeout.color; this.btnHighlight = new Common.UI.ButtonColored({ parentEl: $('#annot-bar-highlight', container), @@ -1540,6 +1546,12 @@ define([], function () { allowDepress: true, split: true, menu: true, + additionalItemsAfter: [ + new Common.UI.MenuItem({ + template: _.template('
'), + stopPropagation: true + }) + ], colors: [ 'FFFC54', '72F54A', '74F9FD', 'EB51F7', 'A900F9', 'EF8B3A', '7272FF', 'FF63A4', '1DFF92', '03DA18', '249B01', 'C504D2', '0633D1', 'FFF7A0', 'FF0303', 'FFFFFF', 'D3D3D4', '969696', '606060', '000000' @@ -1556,9 +1568,6 @@ define([], function () { type: AscPDF.ANNOTATIONS_TYPES.Highlight }); annotBarBtns.push(this.btnHighlight); - this.btnHighlight.setMenu(); - this.mnuHighlightColorPicker = this.btnHighlight.getPicker(); - this.btnHighlight.currentColor = this.btnHighlight.color; this.btnEditText = new Common.UI.Button({ parentEl: $('#annot-bar-edit-text', container), @@ -1568,7 +1577,7 @@ define([], function () { hint: this.tipRecognize }); annotBarBtns.push(this.btnEditText); - this.fireEvent('annotbar:create', [this.btnStrikeout, this.mnuStrikeoutColorPicker, this.btnUnderline, this.mnuUnderlineColorPicker, this.btnHighlight, this.mnuHighlightColorPicker]); + this.fireEvent('annotbar:create', [this.btnStrikeout, this.btnUnderline, this.btnHighlight]); return container; }; diff --git a/apps/pdfeditor/main/app/view/Toolbar.js b/apps/pdfeditor/main/app/view/Toolbar.js index ec6ab807b7..6273a6259f 100644 --- a/apps/pdfeditor/main/app/view/Toolbar.js +++ b/apps/pdfeditor/main/app/view/Toolbar.js @@ -318,6 +318,7 @@ define([ this.paragraphControls.push(this.btnTextHighlightColor); arr.push(this.btnTextHighlightColor); + var colorsconfig = Common.UI.simpleColorsConfig; this.btnFontColor = new Common.UI.ButtonColored({ id: 'id-toolbar-btn-fontcolor', cls: 'btn-toolbar', @@ -325,11 +326,17 @@ define([ lock: [_set.paragraphLock, _set.lostConnect, _set.noTextSelected, _set.shapeLock, _set.disableOnStart], split: true, menu: true, - eyeDropper: true, + colors: colorsconfig.colors, + color: '000000', + dynamiccolors: colorsconfig.dynamiccolors, + themecolors: colorsconfig.themecolors, + effects: colorsconfig.effects, + columns: colorsconfig.columns, + paletteCls: colorsconfig.cls, + paletteWidth: colorsconfig.paletteWidth, dataHint: '1', dataHintDirection: 'bottom', - dataHintOffset: '0, -16', - penOptions: {color: '000000'} + dataHintOffset: '0, -16' }); this.paragraphControls.push(this.btnFontColor); arr.push(this.btnFontColor); @@ -882,6 +889,7 @@ define([ }); this.toolbarControls.push(this.chShowComments); + var colorsconfig = Common.UI.simpleColorsConfig; this.btnStrikeout = new Common.UI.ButtonColored({ id: 'id-toolbar-btn-strikeout', cls: 'btn-toolbar', @@ -892,10 +900,24 @@ define([ split: true, menu: true, colorLine: false, + additionalItemsAfter: [ + new Common.UI.MenuItem({ + template: _.template('
'), + stopPropagation: true + }) + ], + colors: colorsconfig.colors, + color: 'D43230', + dynamiccolors: colorsconfig.dynamiccolors, + themecolors: colorsconfig.themecolors, + effects: colorsconfig.effects, + columns: colorsconfig.columns, + paletteCls: colorsconfig.cls, + paletteWidth: colorsconfig.paletteWidth, + storageSuffix: '-draw', dataHint: '1', dataHintDirection: 'top', dataHintOffset: '0, -16', - penOptions: {color: 'D43230'}, type: AscPDF.ANNOTATIONS_TYPES.Strikeout }); this.btnsStrikeout = [this.btnStrikeout]; @@ -910,10 +932,24 @@ define([ split: true, menu: true, colorLine: false, + additionalItemsAfter: [ + new Common.UI.MenuItem({ + template: _.template('
'), + stopPropagation: true + }) + ], + colors: colorsconfig.colors, + color: '3D8A44', + dynamiccolors: colorsconfig.dynamiccolors, + themecolors: colorsconfig.themecolors, + effects: colorsconfig.effects, + columns: colorsconfig.columns, + paletteCls: colorsconfig.cls, + paletteWidth: colorsconfig.paletteWidth, + storageSuffix: '-draw', dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: '0, -16', - penOptions: {color: '3D8A44'}, type: AscPDF.ANNOTATIONS_TYPES.Underline }); this.btnsUnderline = [this.btnUnderline]; @@ -927,14 +963,28 @@ define([ allowDepress: true, split: true, menu: true, + additionalItemsAfter: [ + new Common.UI.MenuItem({ + template: _.template('
'), + stopPropagation: true + }) + ], + colors: [ + 'FFFC54', '72F54A', '74F9FD', 'EB51F7', 'A900F9', 'EF8B3A', '7272FF', 'FF63A4', '1DFF92', '03DA18', + '249B01', 'C504D2', '0633D1', 'FFF7A0', 'FF0303', 'FFFFFF', 'D3D3D4', '969696', '606060', '000000' + ], + color: 'FFFC54', + dynamiccolors: colorsconfig.dynamiccolors, + themecolors: colorsconfig.themecolors, + effects: colorsconfig.effects, + columns: colorsconfig.columns, + paletteCls: colorsconfig.cls, + paletteWidth: colorsconfig.paletteWidth, + storageSuffix: '-draw', type: AscPDF.ANNOTATIONS_TYPES.Highlight, dataHint: '1', dataHintDirection: 'top', - dataHintOffset: '0, -16', - penOptions: {color: 'FFFC54', colors: [ - 'FFFC54', '72F54A', '74F9FD', 'EB51F7', 'A900F9', 'EF8B3A', '7272FF', 'FF63A4', '1DFF92', '03DA18', - '249B01', 'C504D2', '0633D1', 'FFF7A0', 'FF0303', 'FFFFFF', 'D3D3D4', '969696', '606060', '000000' - ]} + dataHintOffset: '0, -16' }); this.btnsHighlight = [this.btnHighlight]; @@ -1383,49 +1433,53 @@ define([ return $host; }, - createPen: function(button, id, transparent, storage) { - var mnu; - button.setMenu(new Common.UI.Menu({ - cls: 'shifted-left', - style: 'min-width: 100px;', - items: [ - {template: _.template('
')}, - {caption: '--'}, - { - id: 'id-toolbar-menu-' + id + '-color-new', - template: _.template('' + button.textNewColor + '') - }, - {caption: '--', visible: !!transparent}, - mnu = new Common.UI.MenuItem({ - caption: this.strMenuNoFill, - checkable: true, - visible: !!transparent, - style: 'padding-left:20px;padding-right:20px;' - }) - ] - }), true); - button.currentColor = button.options.penOptions.color; - button.setColor(button.currentColor); - var config = Common.UI.simpleColorsConfig; - var picker = new Common.UI.ThemeColorPalette({ - el: $('#id-toolbar-menu-' + id), - colors: button.options.penOptions.colors || config.colors, - value: button.currentColor, - dynamiccolors: config.dynamiccolors, - themecolors: config.themecolors, - effects: config.effects, - columns: config.columns, - cls: config.cls, - outerMenu: {menu: button.menu, index: 0, focusOnShow: true}, - storageSuffix: storage || '' + createPen: function(button, id, opacity) { + var me = this; + button.setMenu(); + button.currentColor = button.color; + if (opacity) { + var onShowAfter = function(menu) { + if (button.sizePicker) { + button.sizePicker.setValue(Common.Utils.InternalSettings.get("pdfe-annot-opacity-" + id) + '%'); + } else { + button.sizePicker = me.createOpacityPicker(id, menu.cmpEl.find('.custom-scale')); + } + }; + button.menu.on('show:after', onShowAfter); + } + + return button.getPicker(); + }, + + createOpacityPicker: function(id, el) { + var sizePicker = new Common.UI.UpDownPicker({ + el: el, + caption: this.txtOpacity, + minWidth: 40 }); - button.setPicker(picker); - picker.on('select', _.bind(button.onColorSelect, button)); - button.menu.setInnerMenu([{menu: picker, index: 0}]); - button.menu.cmpEl.find('#id-toolbar-menu-' + id + '-color-new').on('click', function() { - picker.addNewColor(button.currentColor); + sizePicker.on('click', function (direction) { + var val = Common.Utils.InternalSettings.get("pdfe-annot-opacity-" + id); + if (direction === 'up') { + if (val % 10 > 0.1) { + val = Math.ceil(val / 10) * 10; + } else { + val += 10; + } + val = Math.min(100, val); + } else { + if (val % 10 > 0.1) { + val = Math.floor(val / 10) * 10; + } else { + val -= 10 + } + val = Math.max(0, val); + } + this.setValue(val + '%'); + Common.Utils.InternalSettings.set("pdfe-annot-opacity-" + id, val); + Common.localStorage.setItem("pdfe-annot-opacity-" + id, val); }); - return [picker, mnu]; + sizePicker.setValue(Common.Utils.InternalSettings.get("pdfe-annot-opacity-" + id) + '%'); + return sizePicker; }, onAppReady: function (config) { @@ -1460,22 +1514,19 @@ define([ })); } if (me.btnStrikeout && me.btnStrikeout.menu) { - var arr = me.createPen(me.btnStrikeout, 'strikeout', false, '-draw'); - me.mnuStrikeoutColorPicker = arr[0]; + Common.Utils.InternalSettings.set("pdfe-annot-opacity-strikeout", Common.localStorage.getItemAsInt("pdfe-annot-opacity-strikeout", 100)); + me.mnuStrikeoutColorPicker = me.createPen(me.btnStrikeout, 'strikeout', true); me.mnusStrikeoutColorPicker = [me.mnuStrikeoutColorPicker]; - // me.mnuStrikeoutTransparent = arr[1]; } if (me.btnUnderline && me.btnUnderline.menu) { - var arr = me.createPen(me.btnUnderline, 'underline', false, '-draw'); - me.mnuUnderlineColorPicker = arr[0]; + Common.Utils.InternalSettings.set("pdfe-annot-opacity-underline", Common.localStorage.getItemAsInt("pdfe-annot-opacity-underline", 100)); + me.mnuUnderlineColorPicker = me.createPen(me.btnUnderline, 'underline', true); me.mnusUnderlineColorPicker = [me.mnuUnderlineColorPicker]; - // me.mnuUnderlineTransparent = arr[1]; } if (me.btnHighlight && me.btnHighlight.menu) { - var arr = me.createPen(me.btnHighlight, 'highlight', false, '-draw'); - me.mnuHighlightColorPicker = arr[0]; + Common.Utils.InternalSettings.set("pdfe-annot-opacity-highlight", Common.localStorage.getItemAsInt("pdfe-annot-opacity-highlight", 50)); + me.mnuHighlightColorPicker = me.createPen(me.btnHighlight, 'highlight', true); me.mnusHighlightColorPicker = [me.mnuHighlightColorPicker]; - // me.mnuHighlightTransparent = arr[1]; } if (me.btnTextComment) { @@ -1695,9 +1746,7 @@ define([ this.btnTextHighlightColor.menu.setInnerMenu([{menu: this.mnuTextHighlightColorPicker, index: 0}]); } if (this.btnFontColor && this.btnFontColor.menu) { - var arr = this.createPen(this.btnFontColor, 'font'); - this.mnuFontColorPicker = arr[0]; - this.mnuFontTransparent = arr[1]; + this.mnuFontColorPicker = this.createPen(this.btnFontColor, 'font'); } }, diff --git a/apps/pdfeditor/main/locale/en.json b/apps/pdfeditor/main/locale/en.json index ba72b82cc1..a399a1f1b0 100644 --- a/apps/pdfeditor/main/locale/en.json +++ b/apps/pdfeditor/main/locale/en.json @@ -2017,6 +2017,7 @@ "PDFE.Views.Toolbar.txtRotatePageRight": "Rotate page right", "PDFE.Views.Toolbar.txtRotateRight": "Rotate right", "PDFE.Views.Toolbar.txtUngroup": "Ungroup", + "PDFE.Views.Toolbar.txtOpacity": "Opacity", "PDFE.Views.ViewTab.textAlwaysShowToolbar": "Always Show Toolbar", "PDFE.Views.ViewTab.textDarkDocument": "Dark Document", "PDFE.Views.ViewTab.textFill": "Fill",