diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index ddbc934b8..6b779ee90 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2500,7 +2500,7 @@ define([ me.getApplication().getController('RightMenu').UpdateThemeColors(); }, 50); - !me.appOptions.isEditOle && setTimeout(function(){ + setTimeout(function(){ me.getApplication().getController('Toolbar').updateThemeColors(); }, 50); diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 4bc2781cd..9a6af6517 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -308,20 +308,45 @@ define([ toolbar.btnCopy.on('click', _.bind(this.onCopyPaste, this, true)); toolbar.btnPaste.on('click', _.bind(this.onCopyPaste, this, false)); toolbar.btnSearch.on('click', _.bind(this.onSearch, this)); - toolbar.btnSortDown.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Ascending)); - toolbar.btnSortUp.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending)); - toolbar.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this)); - toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this)); toolbar.btnInsertFormula.on('click', _.bind(this.onInsertFormulaMenu, this)); toolbar.btnInsertFormula.menu.on('item:click', _.bind(this.onInsertFormulaMenu, this)); - toolbar.btnDecDecimal.on('click', _.bind(this.onDecrement, this)); - toolbar.btnIncDecimal.on('click', _.bind(this.onIncrement, this)); toolbar.cmbNumberFormat.on('selected', _.bind(this.onNumberFormatSelect, this)); toolbar.cmbNumberFormat.on('show:before', _.bind(this.onNumberFormatOpenBefore, this, true)); if (toolbar.cmbNumberFormat.cmpEl) toolbar.cmbNumberFormat.cmpEl.on('click', '#id-toolbar-mnu-item-more-formats a', _.bind(this.onNumberFormatSelect, this)); + toolbar.btnWrap.on('click', _.bind(this.onWrap, this)); + toolbar.btnTextColor.on('click', _.bind(this.onTextColor, this)); + toolbar.btnTextColor.on('color:select', _.bind(this.onTextColorSelect, this)); + toolbar.btnTextColor.on('auto:select', _.bind(this.onAutoFontColor, this)); + toolbar.btnBackColor.on('click', _.bind(this.onBackColor, this)); + toolbar.btnBackColor.on('color:select', _.bind(this.onBackColorSelect, this)); + toolbar.btnBorders.on('click', _.bind(this.onBorders, this)); + if (toolbar.btnBorders.rendered) { + toolbar.btnBorders.menu.on('item:click', _.bind(this.onBordersMenu, this)); + toolbar.mnuBorderWidth.on('item:toggle', _.bind(this.onBordersWidth, this)); + toolbar.mnuBorderColorPicker.on('select', _.bind(this.onBordersColor, this)); + $('#id-toolbar-menu-auto-bordercolor').on('click', _.bind(this.onAutoBorderColor, this)); + } + toolbar.btnMerge.on('click', _.bind(this.onMergeCellsMenu, this, toolbar.btnMerge.menu, toolbar.btnMerge.menu.items[0])); + toolbar.btnMerge.menu.on('item:click', _.bind(this.onMergeCellsMenu, this)); + toolbar.btnTableTemplate.menu.on('show:after', _.bind(this.onTableTplMenuOpen, this)); toolbar.btnVisibleArea.menu.on('item:click', _.bind(this.onVisibleAreaMenu, this)); toolbar.btnVisibleAreaClose.on('click', _.bind(this.onVisibleAreaClose, this)); + toolbar.cmbFontName.on('selected', _.bind(this.onFontNameSelect, this)); + toolbar.cmbFontName.on('show:after', _.bind(this.onComboOpen, this, true)); + toolbar.cmbFontName.on('hide:after', _.bind(this.onHideMenus, this)); + toolbar.cmbFontName.on('combo:blur', _.bind(this.onComboBlur, this)); + toolbar.cmbFontName.on('combo:focusin', _.bind(this.onComboOpen, this, false)); + toolbar.cmbFontSize.on('selected', _.bind(this.onFontSizeSelect, this)); + toolbar.cmbFontSize.on('changed:before', _.bind(this.onFontSizeChanged, this, true)); + toolbar.cmbFontSize.on('changed:after', _.bind(this.onFontSizeChanged, this, false)); + toolbar.cmbFontSize.on('show:after', _.bind(this.onComboOpen, this, true)); + toolbar.cmbFontSize.on('hide:after', _.bind(this.onHideMenus, this)); + toolbar.cmbFontSize.on('combo:blur', _.bind(this.onComboBlur, this)); + toolbar.cmbFontSize.on('combo:focusin', _.bind(this.onComboOpen, this, false)); + toolbar.btnTextFormatting.menu.on('item:click', _.bind(this.onTextFormattingMenu, this)); + toolbar.btnHorizontalAlign.menu.on('item:click', _.bind(this.onHorizontalAlignMenu, this)); + toolbar.btnVerticalAlign.menu.on('item:click', _.bind(this.onVerticalAlignMenu, this)); } else { toolbar.btnPrint.on('click', _.bind(this.onPrint, this)); toolbar.btnPrint.on('disabled', _.bind(this.onBtnChangeState, this, 'print:disabled')); @@ -456,6 +481,8 @@ define([ this.api.asc_registerCallback('asc_onUnLockCFManager', _.bind(this.onUnLockCFManager, this)); this.api.asc_registerCallback('asc_onZoomChanged', _.bind(this.onApiZoomChange, this)); Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this)); + } else if (config.isEditOle) { + Common.NotificationCenter.on('fonts:change', _.bind(this.onApiChangeFont, this)); } else if (config.isRestrictedEdit) { this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChangedRestricted, this)); Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this)); @@ -1877,7 +1904,9 @@ define([ this.api.asc_registerCallback('asc_onUnLockDocumentProps', _.bind(this.onApiUnLockDocumentProps, this)); Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this)); } - + if ( this.appConfig.isEditOle ) { + this.api.asc_registerCallback('asc_onEditorSelectionChanged', _.bind(this.onApiEditorSelectionChanged_OleEditor, this)); + } if ( !this.appConfig.isEditMailMerge ) { this.applyFormulaSettings(); } @@ -2213,9 +2242,26 @@ define([ if ($('.asc-window.enable-key-events:visible').length>0) return; var toolbar = this.toolbar; - if (toolbar.mode.isEditDiagram || toolbar.mode.isEditMailMerge || toolbar.mode.isEditOle) { - is_cell_edited = (state == Asc.c_oAscCellEditorState.editStart); + if (toolbar.mode.isEditDiagram || toolbar.mode.isEditMailMerge) { + var is_cell_edited = (state == Asc.c_oAscCellEditorState.editStart); toolbar.lockToolbar(Common.enumLock.editCell, state == Asc.c_oAscCellEditorState.editStart, {array: [toolbar.btnDecDecimal,toolbar.btnIncDecimal,toolbar.cmbNumberFormat, toolbar.btnEditChartData, toolbar.btnEditChartType]}); + } else if (toolbar.mode.isEditOle) { + if (state == Asc.c_oAscCellEditorState.editStart || state == Asc.c_oAscCellEditorState.editEnd) { + var is_cell_edited = (state == Asc.c_oAscCellEditorState.editStart); + toolbar.lockToolbar(Common.enumLock.editCell, state == Asc.c_oAscCellEditorState.editStart, {array: [toolbar.cmbNumberFormat, toolbar.btnWrap, toolbar.btnMerge, toolbar.btnBackColor, + toolbar.btnBorders, toolbar.btnTableTemplate, toolbar.btnHorizontalAlign, toolbar.btnVerticalAlign], + merge: true, + clear: [Common.enumLock.editFormula, Common.enumLock.editText]}); + (is_cell_edited) ? Common.util.Shortcuts.suspendEvents('command+l, ctrl+l, command+shift+l, ctrl+shift+l') : + Common.util.Shortcuts.resumeEvents('command+l, ctrl+l, command+shift+l, ctrl+shift+l'); + } else { + if (state == Asc.c_oAscCellEditorState.editText) var is_text = true, is_formula = false; else + if (state == Asc.c_oAscCellEditorState.editFormula) is_text = !(is_formula = true); else + if (state == Asc.c_oAscCellEditorState.editEmptyCell) is_text = is_formula = false; + + toolbar.lockToolbar(Common.enumLock.editFormula, is_formula, { array: [toolbar.cmbFontName, toolbar.cmbFontSize, toolbar.btnTextFormatting, toolbar.btnTextColor]}); + toolbar.lockToolbar(Common.enumLock.editText, is_text, {array: [toolbar.btnInsertFormula]}); + } } else if (state == Asc.c_oAscCellEditorState.editStart || state == Asc.c_oAscCellEditorState.editEnd) { toolbar.lockToolbar(Common.enumLock.editCell, state == Asc.c_oAscCellEditorState.editStart, { @@ -3132,11 +3178,14 @@ define([ me.toolbar.lockToolbar(Common.enumLock.coAuthText, is_objLocked); + me._state.controlsdisabled.filters = is_image || is_mode_2; + return is_image; }; var selectionType = info.asc_getSelectionType(), xfs = info.asc_getXfs(), + toolbar = this.toolbar, coauth_disable = false, editOptionsDisabled = _disableEditOptions(selectionType, coauth_disable), val, need_disable = false; @@ -3145,24 +3194,238 @@ define([ if (selectionType == Asc.c_oAscSelectionType.RangeChart || selectionType == Asc.c_oAscSelectionType.RangeChartText) return; - if ( !me.toolbar.mode.isEditDiagram ) { - var filterInfo = info.asc_getAutoFilterInfo(); + Common.NotificationCenter.trigger('fonts:change', xfs); - val = filterInfo ? filterInfo.asc_getIsAutoFilter() : null; - if ( this._state.filter !== val ) { - me.toolbar.btnSetAutofilter.toggle(val===true, true); - this._state.filter = val; - } - - need_disable = this._state.controlsdisabled.filters || (val===null); - me.toolbar.lockToolbar(Common.enumLock.ruleFilter, need_disable, - { array: [me.toolbar.btnSetAutofilter, me.toolbar.btnSortDown, me.toolbar.btnSortUp] }); - - need_disable = this._state.controlsdisabled.filters || !filterInfo || (filterInfo.asc_getIsApplyAutoFilter()!==true); - me.toolbar.lockToolbar(Common.enumLock.ruleDelFilter, need_disable, {array: [me.toolbar.btnClearAutofilter]}); + /* read font size */ + var str_size = xfs.asc_getFontSize(); + if (this._state.fontsize !== str_size) { + toolbar.cmbFontSize.setValue((str_size !== undefined) ? str_size : ''); + this._state.fontsize = str_size; } - var val = xfs.asc_getNumFormatInfo(); + val = xfs.asc_getFontBold(); + if (this._state.bold !== val) { + toolbar.btnTextFormatting.menu.items[0].setChecked(val === true); + this._state.bold = val; + } + val = xfs.asc_getFontItalic(); + if (this._state.italic !== val) { + toolbar.btnTextFormatting.menu.items[1].setChecked(val === true); + this._state.italic = val; + } + val = xfs.asc_getFontUnderline(); + if (this._state.underline !== val) { + toolbar.btnTextFormatting.menu.items[2].setChecked(val === true); + this._state.underline = val; + } + val = xfs.asc_getFontStrikeout(); + if (this._state.strikeout !== val) { + toolbar.btnTextFormatting.menu.items[3].setChecked(val === true); + this._state.strikeout = val; + } + + val = xfs.asc_getFontSuperscript(); + if (this._state.superscript !== val) { + toolbar.btnTextFormatting.menu.items[4].setChecked(val === true); + this._state.superscript = val; + } + + val = xfs.asc_getFontSubscript(); + if (this._state.subscript !== val) { + toolbar.btnTextFormatting.menu.items[5].setChecked(val === true); + this._state.subscript = val; + } + + /* read font color */ + var clr, + color, + fontColorPicker = toolbar.mnuTextColorPicker, + paragraphColorPicker = toolbar.mnuBackColorPicker; + + if (!fontColorPicker.isDummy) { + color = xfs.asc_getFontColor(); + if (color) { + if (color.get_auto()) { + if (this._state.clrtext !== 'auto') { + fontColorPicker.clearSelection(); + toolbar.btnTextColor.setAutoColor(true); + this._state.clrtext = 'auto'; + } + } else { + if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { + clr = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value() }; + } else { + clr = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); + } + var type1 = typeof(clr), + type2 = typeof(this._state.clrtext); + if ( (this._state.clrtext == 'auto') || (type1 !== type2) || (type1=='object' && + (clr.effectValue!==this._state.clrtext.effectValue || this._state.clrtext.color.indexOf(clr.color)<0)) || + (type1!='object' && this._state.clrtext!==undefined && this._state.clrtext.indexOf(clr)<0 )) { + + toolbar.btnTextColor.setAutoColor(false); + if (_.isObject(clr)) { + var isselected = false; + for (var i = 0; i < 10; i++) { + if (Common.Utils.ThemeColor.ThemeValues[i] == clr.effectValue) { + fontColorPicker.select(clr, true); + isselected = true; + break; + } + } + if (!isselected) fontColorPicker.clearSelection(); + } else { + fontColorPicker.select(clr, true); + } + this._state.clrtext = clr; + } + } + } + this._state.clrtext_asccolor = color; + } + + /* read cell background color */ + if (!paragraphColorPicker.isDummy) { + color = xfs.asc_getFillColor(); + if (color && !color.get_auto()) { + if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { + clr = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value() }; + } else { + clr = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); + } + } else { + clr = 'transparent'; + } + + type1 = typeof(clr); + type2 = typeof(this._state.clrback); + if ( (type1 !== type2) || (type1=='object' && + (clr.effectValue!==this._state.clrback.effectValue || this._state.clrback.color.indexOf(clr.color)<0)) || + (type1!='object' && this._state.clrback!==undefined && this._state.clrback.indexOf(clr)<0 )) { + + if (_.isObject(clr)) { + var isselected = false; + for (i = 0; i < 10; i++) { + if (Common.Utils.ThemeColor.ThemeValues[i] == clr.effectValue) { + paragraphColorPicker.select(clr, true); + isselected = true; + break; + } + } + if (!isselected) paragraphColorPicker.clearSelection(); + } else { + paragraphColorPicker.select(clr, true); + } + this._state.clrback = clr; + } + this._state.clrshd_asccolor = color; + } + + var filterInfo = info.asc_getAutoFilterInfo(), + formatTableInfo = info.asc_getFormatTableInfo(); + + /* read cell horizontal align */ + + var fontparam = xfs.asc_getHorAlign(); + if (this._state.pralign !== fontparam) { + this._state.pralign = fontparam; + + var index = -1, align; + switch (fontparam) { + case AscCommon.align_Left: index = 0; align = 'btn-align-left'; break; + case AscCommon.align_Center: index = 1; align = 'btn-align-center'; break; + case AscCommon.align_Right: index = 2; align = 'btn-align-right'; break; + case AscCommon.align_Justify: index = 3; align = 'btn-align-just'; break; + default: index = -255; align = 'btn-align-left'; break; + } + if (!(index < 0)) { + toolbar.btnHorizontalAlign.menu.items[index].setChecked(true); + } else if (index == -255) { + toolbar.btnHorizontalAlign.menu.clearAll(); + } + if ( toolbar.btnHorizontalAlign.rendered && toolbar.btnHorizontalAlign.$icon ) { + toolbar.btnHorizontalAlign.$icon.removeClass(toolbar.btnHorizontalAlign.options.icls).addClass(align); + toolbar.btnHorizontalAlign.options.icls = align; + } + } + + // read cell vertical align + fontparam = xfs.asc_getVertAlign(); + + if (this._state.valign !== fontparam) { + this._state.valign = fontparam; + + index = -1; align = ''; + switch (fontparam) { + case Asc.c_oAscVAlign.Top: index = 0; align = 'btn-align-top'; break; + case Asc.c_oAscVAlign.Center: index = 1; align = 'btn-align-middle'; break; + case Asc.c_oAscVAlign.Bottom: index = 2; align = 'btn-align-bottom'; break; + } + if (!(index < 0)) { + toolbar.btnVerticalAlign.menu.items[index].setChecked(true); + } else if (index == -255) { + toolbar.btnVerticalAlign.menu.clearAll(); + } + if ( toolbar.btnVerticalAlign.rendered && toolbar.btnVerticalAlign.$icon ) { + toolbar.btnVerticalAlign.$icon.removeClass(toolbar.btnVerticalAlign.options.icls).addClass(align); + toolbar.btnVerticalAlign.options.icls = align; + } + } + + need_disable = this._state.controlsdisabled.filters || formatTableInfo!==null || filterInfo && filterInfo.asc_getIsAutoFilter()===null; + toolbar.lockToolbar(Common.enumLock.ruleMerge, need_disable, {array:[toolbar.btnMerge]}); + + val = info.asc_getMerge(); + if (this._state.merge !== val) { + toolbar.btnMerge.toggle(val===Asc.c_oAscMergeOptions.Merge, true); + this._state.merge = val; + } + + /* read cell text wrapping */ + if (!toolbar.btnWrap.isDisabled()) { + val = xfs.asc_getWrapText(); + if (this._state.wrap !== val) { + toolbar.btnWrap.toggle(val===true, true); + this._state.wrap = val; + } + } + + val = (filterInfo) ? filterInfo.asc_getIsAutoFilter() : null; + this._state.filter = val; + need_disable = this._state.controlsdisabled.filters || (val===null); + toolbar.lockToolbar(Common.enumLock.ruleFilter, need_disable, { array: [toolbar.btnTableTemplate] }); + + val = (formatTableInfo) ? formatTableInfo.asc_getTableStyleName() : null; + if (this._state.tablestylename !== val && this.toolbar.mnuTableTemplatePicker) { + val = this.toolbar.mnuTableTemplatePicker.store.findWhere({name: val}); + if (val) { + this.toolbar.mnuTableTemplatePicker.selectRecord(val); + this._state.tablestylename = val.get('name'); + } else { + toolbar.mnuTableTemplatePicker.deselectAll(); + this._state.tablestylename = null; + } + } + + var old_name = this._state.tablename; + this._state.tablename = (formatTableInfo) ? formatTableInfo.asc_getTableName() : undefined; + + var old_applied = this._state.filterapplied; + this._state.filterapplied = this._state.filter && filterInfo.asc_getIsApplyAutoFilter(); + + if (this._state.tablename !== old_name || this._state.filterapplied !== old_applied) + this.getApplication().getController('Statusbar').onApiFilterInfo(!need_disable); + + this._state.multiselect = info.asc_getMultiselect(); + toolbar.lockToolbar(Common.enumLock.multiselect, this._state.multiselect, { array: [toolbar.btnTableTemplate]}); + + this._state.inpivot = !!info.asc_getPivotTableInfo(); + toolbar.lockToolbar(Common.enumLock.editPivot, this._state.inpivot, { array: [toolbar.btnMerge]}); + + need_disable = !this.appConfig.canModifyFilter; + toolbar.lockToolbar(Common.enumLock.cantModifyFilter, need_disable, { array: [toolbar.btnTableTemplate]}); + + val = xfs.asc_getNumFormatInfo(); if ( val ) { this._state.numformat = xfs.asc_getNumFormat(); this._state.numformatinfo = val; @@ -3174,6 +3437,104 @@ define([ } }, + onApiEditorSelectionChanged_OleEditor: function(fontobj) { + if (!this.editMode || $('.asc-window.enable-key-events:visible').length>0) return; + + var toolbar = this.toolbar, + val; + + /* read font name */ + Common.NotificationCenter.trigger('fonts:change', fontobj); + + /* read font params */ + val = fontobj.asc_getFontBold(); + if (this._state.bold !== val) { + toolbar.btnTextFormatting.menu.items[0].setChecked(val === true); + this._state.bold = val; + } + val = fontobj.asc_getFontItalic(); + if (this._state.italic !== val) { + toolbar.btnTextFormatting.menu.items[1](val === true); + this._state.italic = val; + } + val = fontobj.asc_getFontUnderline(); + if (this._state.underline !== val) { + toolbar.btnTextFormatting.menu.items[2](val === true); + this._state.underline = val; + } + val = fontobj.asc_getFontStrikeout(); + if (this._state.strikeout !== val) { + toolbar.btnTextFormatting.menu.items[3](val === true); + this._state.strikeout = val; + } + + val = fontobj.asc_getFontSubscript(); + if (this._state.subscript !== val) { + toolbar.btnTextFormatting.menu.items[4](val === true); + this._state.subscript = val; + } + + val = fontobj.asc_getFontSuperscript(); + if (this._state.superscript !== val) { + toolbar.btnTextFormatting.menu.items[5](val === true); + this._state.superscript = val; + } + + /* read font size */ + var str_size = fontobj.asc_getFontSize(); + if (this._state.fontsize !== str_size) { + toolbar.cmbFontSize.setValue((str_size!==undefined) ? str_size : ''); + this._state.fontsize = str_size; + } + + /* read font color */ + var clr, + color, + fontColorPicker = this.toolbar.mnuTextColorPicker; + + if (!fontColorPicker.isDummy) { + color = fontobj.asc_getFontColor(); + if (color) { + if (color.get_auto()) { + if (this._state.clrtext !== 'auto') { + fontColorPicker.clearSelection(); + this.toolbar.btnTextColor.setAutoColor(true); + this._state.clrtext = 'auto'; + } + } else { + if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) { + clr = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value() }; + } else { + clr = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); + } + var type1 = typeof(clr), + type2 = typeof(this._state.clrtext); + if ( (this._state.clrtext == 'auto') || (type1 !== type2) || (type1=='object' && + (clr.effectValue!==this._state.clrtext.effectValue || this._state.clrtext.color.indexOf(clr.color)<0)) || + (type1!='object' && this._state.clrtext!==undefined && this._state.clrtext.indexOf(clr)<0 )) { + + this.toolbar.btnTextColor.setAutoColor(false); + if (_.isObject(clr)) { + var isselected = false; + for (var i = 0; i < 10; i++) { + if (Common.Utils.ThemeColor.ThemeValues[i] == clr.effectValue) { + fontColorPicker.select(clr, true); + isselected = true; + break; + } + } + if (!isselected) fontColorPicker.clearSelection(); + } else { + fontColorPicker.select(clr, true); + } + this._state.clrtext = clr; + } + } + } + this._state.clrtext_asccolor = color; + } + }, + onApiStyleChange: function() { this.toolbar.btnCopyStyle.toggle(false, true); this.modeAlwaysSetStyle = false; @@ -4247,6 +4608,61 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, + onTextFormattingMenu: function(menu, item) { + if (this.api) { + switch (item.value) { + case 'bold': + this._state.bold = undefined; + this.api.asc_setCellBold(item.checked); + break; + case 'italic': + this._state.italic = undefined; + this.api.asc_setCellItalic(item.checked); + break; + case 'underline': + this._state.underline = undefined; + this.api.asc_setCellUnderline(item.checked); + break; + case 'strikeout': + this._state.strikeout = undefined; + this.api.asc_setCellStrikeout(item.checked); + break; + case 'subscript': + this._state.subscript = undefined; + this.api.asc_setCellSubscript(item.checked); + break; + case 'superscript': + this._state.superscript = undefined; + this.api.asc_setCellSuperscript(item.checked); + break; + } + } + + Common.NotificationCenter.trigger('edit:complete', this.toolbar); + Common.component.Analytics.trackEvent('ToolBar', 'Text Formatting'); + }, + + onHorizontalAlignMenu: function(menu, item) { + this._state.pralign = undefined; + if (this.api) { + this.api.asc_setCellAlign(!item.checked ? null : item.value); + this.toolbar.btnWrap.allowDepress = !(item.value == AscCommon.align_Justify); + } + + Common.NotificationCenter.trigger('edit:complete', this.toolbar); + Common.component.Analytics.trackEvent('ToolBar', 'Horizontal align'); + }, + + onVerticalAlignMenu: function(menu, item) { + this._state.valign = undefined; + if (this.api) { + this.api.asc_setCellVertAlign(!item.checked ? Asc.c_oAscVAlign.Bottom : item.value); + } + + Common.NotificationCenter.trigger('edit:complete', this.toolbar); + Common.component.Analytics.trackEvent('ToolBar', 'Vertical align'); + }, + textEmptyImgUrl : 'You need to specify image URL.', warnMergeLostData : 'Operation can destroy data in the selected cells.
Continue?', textWarning : 'Warning', diff --git a/apps/spreadsheeteditor/main/app/template/Toolbar.template b/apps/spreadsheeteditor/main/app/template/Toolbar.template index 5b9a230d8..502449a0e 100644 --- a/apps/spreadsheeteditor/main/app/template/Toolbar.template +++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template @@ -31,7 +31,7 @@
- + diff --git a/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template b/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template index 6d16013bd..eca22316b 100644 --- a/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template +++ b/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template @@ -78,41 +78,51 @@
- - - + + +
+
+
+ + + + +
+
+
+
+
+ + + + +
+
+
+
+
+ + + +
+
+
+
+
+ +
+
+
-
-
- - -
-
-
-
-
- - -
-
-
-
-
- - - -
-
-
@@ -121,8 +131,8 @@
- - + +
diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 006b73d2c..105471fd6 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -262,25 +262,6 @@ define([ ] }), dataHint: '1', - dataHintDirection: 'bottom', - dataHintOffset: 'big' - }); - - me.btnDecDecimal = new Common.UI.Button({ - id : 'id-toolbar-btn-decdecimal', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-decdecimal', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.editVisibleArea], - dataHint : '1', - dataHintDirection: 'bottom' - }); - - me.btnIncDecimal = new Common.UI.Button({ - id : 'id-toolbar-btn-incdecimal', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-incdecimal', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.editVisibleArea], - dataHint : '1', dataHintDirection: 'bottom' }); @@ -305,11 +286,38 @@ define([ editable : false, data : me.numFormatData, dataHint : '1', - dataHintDirection: 'bottom', - dataHintOffset: 'big' + dataHintDirection: 'bottom' + }); + } + if ( config.isEditMailMerge || config.isEditOle ) { + me.btnSearch = new Common.UI.Button({ + id : 'id-toolbar-btn-search', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-menu-search', + lock : [_set.lostConnect], + dataHint : '1', + dataHintDirection: 'bottom' }); } if ( config.isEditDiagram ) { + me.btnDecDecimal = new Common.UI.Button({ + id : 'id-toolbar-btn-decdecimal', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-decdecimal', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.editVisibleArea], + dataHint : '1', + dataHintDirection: 'bottom' + }); + + me.btnIncDecimal = new Common.UI.Button({ + id : 'id-toolbar-btn-incdecimal', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-incdecimal', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.editVisibleArea], + dataHint : '1', + dataHintDirection: 'bottom' + }); + me.btnEditChart = new Common.UI.Button({ id : 'id-toolbar-rtn-edit-chart', cls : 'btn-toolbar btn-text-default auto', @@ -317,8 +325,7 @@ define([ lock : [_set.lostConnect], style : 'min-width: 120px;', dataHint : '1', - dataHintDirection: 'bottom', - dataHintOffset: 'big' + dataHintDirection: 'bottom' }); me.btnEditChartData = new Common.UI.Button({ @@ -344,16 +351,7 @@ define([ dataHintOffset: 'medium' }); } - if ( config.isEditMailMerge || config.isEditOle ) { - me.btnSearch = new Common.UI.Button({ - id : 'id-toolbar-btn-search', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-menu-search', - lock : [_set.lostConnect], - dataHint : '1', - dataHintDirection: 'bottom' - }); - + if ( config.isEditMailMerge) { me.btnSortDown = new Common.UI.Button({ id : 'id-toolbar-btn-sort-down', cls : 'btn-toolbar', @@ -392,6 +390,310 @@ define([ }); } if ( config.isEditOle ) { + me.cmbFontSize = new Common.UI.ComboBox({ + cls : 'input-group-nr', + menuStyle : 'min-width: 55px;', + hint : me.tipFontSize, + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.editVisibleArea], + data : [ + { value: 8, displayValue: "8" }, + { value: 9, displayValue: "9" }, + { value: 10, displayValue: "10" }, + { value: 11, displayValue: "11" }, + { value: 12, displayValue: "12" }, + { value: 14, displayValue: "14" }, + { value: 16, displayValue: "16" }, + { value: 18, displayValue: "18" }, + { value: 20, displayValue: "20" }, + { value: 22, displayValue: "22" }, + { value: 24, displayValue: "24" }, + { value: 26, displayValue: "26" }, + { value: 28, displayValue: "28" }, + { value: 36, displayValue: "36" }, + { value: 48, displayValue: "48" }, + { value: 72, displayValue: "72" }, + { value: 96, displayValue: "96" } + ], + dataHint: '1', + dataHintDirection: 'bottom' + }); + + me.cmbFontName = new Common.UI.ComboBoxFonts({ + cls : 'input-group-nr', + menuCls : 'scrollable-menu', + menuStyle : 'min-width: 325px;', + hint : me.tipFontName, + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.editVisibleArea], + store : new Common.Collections.Fonts(), + recent : 0, + dataHint: '1', + dataHintDirection: 'bottom' + }); + + me.btnWrap = new Common.UI.Button({ + id : 'id-toolbar-rtn-wrap', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-wrap', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set['FormatCells']], + enableToggle: true, + allowDepress: true, + dataHint : '1', + dataHintDirection: 'bottom' + }); + + me.btnMerge = new Common.UI.Button({ + id : 'id-toolbar-rtn-merge', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-merge-and-center', + enableToggle: true, + allowDepress: true, + split : true, + lock : [_set.editCell, _set.selShape, _set.selShapeText, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleMerge, _set.editPivot, _set.wsLock, _set.editVisibleArea], + menu : new Common.UI.Menu({ + items: [ + { + caption : me.txtMergeCenter, + iconCls : 'menu__icon btn-merge-and-center', + value : Asc.c_oAscMergeOptions.MergeCenter + }, + { + caption : me.txtMergeAcross, + iconCls : 'menu__icon btn-merge-across', + value : Asc.c_oAscMergeOptions.MergeAcross + }, + { + caption : me.txtMergeCells, + iconCls : 'menu__icon btn-merge-cells', + value : Asc.c_oAscMergeOptions.Merge + }, + { + caption : me.txtUnmerge, + iconCls : 'menu__icon btn-unmerge-cells', + value : Asc.c_oAscMergeOptions.None + } + ] + }), + dataHint : '1', + dataHintDirection: 'bottom' + }); + + me.mnuTextColorPicker = dummyCmp(); + me.btnTextColor = new Common.UI.ButtonColored({ + id : 'id-toolbar-btn-fontcolor', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-fontcolor', + split : true, + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormat, _set.editVisibleArea], + menu: true, + auto: true, + dataHint : '1', + dataHintDirection: 'bottom' + }); + + me.mnuBackColorPicker = dummyCmp(); + me.btnBackColor = new Common.UI.ButtonColored({ + id : 'id-toolbar-btn-fillparag', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-paracolor', + split : true, + lock : [_set.selImage, _set.editCell, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormatFill, _set.editVisibleArea], + transparent: true, + menu: true, + dataHint: '1', + dataHintDirection: 'bottom' + }); + + me.btnBorders = new Common.UI.Button({ + id : 'id-toolbar-btn-borders', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-border-out', + icls : 'btn-border-out', + borderId : 'outer', + borderswidth: Asc.c_oAscBorderStyles.Thin, + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set['FormatCells'], _set.editVisibleArea], + split : true, + menu : true, + dataHint : '1', + dataHintDirection: 'bottom' + }); + + me.btnTableTemplate = new Common.UI.Button({ + id : 'id-toolbar-btn-ttempl', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-menu-table', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.multiselect, _set.cantModifyFilter, _set.wsLock, _set.editVisibleArea], + menu : new Common.UI.Menu({ + items: [ + { template: _.template('
') } + ] + }), + dataHint : '1', + dataHintDirection: 'bottom' + }); + + me.btnTextFormatting = new Common.UI.Button({ + id : 'id-toolbar-btn-formatting', + cls : 'btn-toolbar no-caret', + iconCls : 'toolbar__icon more-vertical', + lock : [_set.selImage, _set.editFormula, _set.selRangeEdit, _set.selSlicer, _set.coAuth, _set.coAuthText, _set.lostConnect, _set.wsLockFormat, _set.editVisibleArea], + menu : new Common.UI.Menu({ + items: [ + { + caption : me.textBold, + iconCls : 'menu__icon btn-bold', + value : 'bold', + checkable : true, + checkmark : false, + allowDepress: true + }, + { + caption : me.textItalic, + iconCls : 'menu__icon btn-italic', + value : 'italic', + checkable : true, + checkmark : false, + allowDepress: true + }, + { + caption : me.textUnderline, + iconCls : 'menu__icon btn-underline', + value : 'underline', + checkable : true, + checkmark : false, + allowDepress: true + }, + { + caption : me.textStrikeout, + iconCls : 'menu__icon btn-strikeout', + value : 'strikeout', + checkable : true, + checkmark : false, + allowDepress: true + }, + { + caption : me.textSuperscript, + iconCls : 'menu__icon btn-superscript', + checkable : true, + checkmark : false, + allowDepress: true, + toggleGroup : 'textsubscriptgroup', + value : 'superscript' + }, + { + caption : me.textSubscript, + iconCls : 'menu__icon btn-subscript', + checkable : true, + checkmark : false, + allowDepress: true, + toggleGroup : 'textsubscriptgroup', + value : 'subscript' + } + ] + }), + dataHint : '1', + dataHintDirection: 'bottom' + }); + + me.btnHorizontalAlign = new Common.UI.Button({ + id: 'id-toolbar-btn-halign', + cls: 'btn-toolbar', + iconCls: 'toolbar__icon btn-align-left', + icls: 'btn-align-left', + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.wsLockFormat, _set.editVisibleArea], + menu: new Common.UI.Menu({ + items: [ + { + caption: me.tipAlignLeft, + iconCls: 'menu__icon btn-align-left', + icls: 'btn-align-left', + checkable: true, + checkmark: false, + allowDepress: true, + toggleGroup: 'halignGroup', + checked: true, + value: AscCommon.align_Left + }, + { + caption: me.tipAlignCenter, + iconCls: 'menu__icon btn-align-center', + icls: 'btn-align-center', + checkable: true, + checkmark: false, + allowDepress: true, + toggleGroup: 'halignGroup', + value: AscCommon.align_Center + }, + { + caption: me.tipAlignRight, + iconCls: 'menu__icon btn-align-right', + icls: 'btn-align-right', + checkable: true, + checkmark: false, + allowDepress: true, + toggleGroup: 'halignGroup', + value: AscCommon.align_Right + }, + { + caption: me.tipAlignJust, + iconCls: 'menu__icon btn-align-just', + icls: 'btn-align-just', + checkable: true, + checkmark: false, + allowDepress: true, + toggleGroup: 'halignGroup', + value: AscCommon.align_Justify + } + ] + }), + dataHint: '1', + dataHintDirection: 'bottom' + }); + + me.btnVerticalAlign = new Common.UI.Button({ + id: 'id-toolbar-btn-valign', + cls: 'btn-toolbar', + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selImage, _set.selSlicer, _set.lostConnect, _set.coAuth, _set.coAuthText, _set.wsLockFormat, _set.editVisibleArea], + iconCls: 'toolbar__icon btn-align-middle', + icls: 'btn-align-middle', + menu: new Common.UI.Menu({ + items: [ + { + caption: me.textAlignTop, + iconCls: 'menu__icon btn-align-top', + icls: 'btn-align-top', + checkable: true, + checkmark: false, + allowDepress: true, + toggleGroup: 'valignGroup', + value: Asc.c_oAscVAlign.Top + }, + { + caption: me.textAlignMiddle, + iconCls: 'menu__icon btn-align-middle', + icls: 'btn-align-middle', + checkable: true, + checkmark: false, + allowDepress: true, + toggleGroup: 'valignGroup', + value: Asc.c_oAscVAlign.Center, + checked: true + }, + { + caption: me.textAlignBottom, + iconCls: 'menu__icon btn-align-bottom', + icls: 'btn-align-bottom', + checkable: true, + checkmark: false, + allowDepress: true, + toggleGroup: 'valignGroup', + value: Asc.c_oAscVAlign.Bottom + } + ] + }), + dataHint: '1', + dataHintDirection: 'bottom' + }); + me.btnVisibleArea = new Common.UI.Button({ id : 'id-toolbar-btn-visible-area', cls : 'btn-toolbar btn-icon-default', @@ -416,8 +718,7 @@ define([ visible : false, // style : 'min-width: 120px;', dataHint : '1', - dataHintDirection: 'bottom', - dataHintOffset: 'big' + dataHintDirection: 'bottom' }); } @@ -1732,7 +2033,7 @@ define([ me.btnCopy, me.btnPaste, me.listStyles, me.btnPrint, /*me.btnSave,*/ me.btnClearStyle, me.btnCopyStyle, me.btnPageMargins, me.btnPageSize, me.btnPageOrient, me.btnPrintArea, me.btnPrintTitles, me.btnImgAlign, me.btnImgBackward, me.btnImgForward, me.btnImgGroup, me.btnScale, - me.chPrintGridlines, me.chPrintHeadings, me.btnVisibleArea, me.btnVisibleAreaClose + me.chPrintGridlines, me.chPrintHeadings, me.btnVisibleArea, me.btnVisibleAreaClose, me.btnTextFormatting, me.btnHorizontalAlign, me.btnVerticalAlign ]; _.each(me.lockControls.concat([me.btnSave]), function(cmp) { @@ -1949,6 +2250,9 @@ define([ _injectComponent('#slot-btn-condformat', this.btnCondFormat); _injectComponent('#slot-btn-visible-area', this.btnVisibleArea); _injectComponent('#slot-btn-visible-area-close', this.btnVisibleAreaClose); + _injectComponent('#slot-btn-formatting', this.btnTextFormatting); + _injectComponent('#slot-btn-halign', this.btnHorizontalAlign); + _injectComponent('#slot-btn-valign', this.btnVerticalAlign); this.btnsEditHeader = Common.Utils.injectButtons($host.find('.slot-editheader'), 'tlbtn-editheader-', 'toolbar__icon btn-editheader', this.capBtnInsHeader, [Common.enumLock.editCell, Common.enumLock.selRangeEdit, Common.enumLock.headerLock, Common.enumLock.lostConnect, Common.enumLock.coAuth], undefined, undefined, undefined, '1', 'bottom', 'small'); @@ -2027,6 +2331,9 @@ define([ _updateHint(this.btnScale, this.tipScale); _updateHint(this.btnCondFormat, this.tipCondFormat); _updateHint(this.btnVisibleArea, this.tipVisibleArea); + _updateHint(this.btnTextFormatting, this.tipTextFormatting); + _updateHint(this.btnHorizontalAlign, this.tipHAligh); + _updateHint(this.btnVerticalAlign, this.tipVAligh); this.btnsEditHeader.forEach(function (btn) { _updateHint(btn, me.tipEditHeader); }); @@ -2968,6 +3275,9 @@ define([ textHideVA: 'Hide Visible Area', textEditVA: 'Edit Visible Area', tipVisibleArea: 'Visible area', - textDone: 'Done' + textDone: 'Done', + tipTextFormatting: 'More text formatting tools', + tipHAligh: 'Horizontal Align', + tipVAligh: 'Vertical Align' }, SSE.Views.Toolbar || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 2f58f6848..f01b8bc32 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -3599,6 +3599,13 @@ "SSE.Views.Toolbar.txtTime": "Time", "SSE.Views.Toolbar.txtUnmerge": "Unmerge Cells", "SSE.Views.Toolbar.txtYen": "¥ Yen", + "SSE.Views.Toolbar.textHideVA": "Hide Visible Area", + "SSE.Views.Toolbar.textEditVA": "Edit Visible Area", + "SSE.Views.Toolbar.tipVisibleArea": "Visible area", + "SSE.Views.Toolbar.textDone": "Done", + "SSE.Views.Toolbar.tipTextFormatting": "More text formatting tools", + "SSE.Views.Toolbar.tipHAligh": "Horizontal Align", + "SSE.Views.Toolbar.tipVAligh": "Vertical Align", "SSE.Views.Top10FilterDialog.textType": "Show", "SSE.Views.Top10FilterDialog.txtBottom": "Bottom", "SSE.Views.Top10FilterDialog.txtBy": "by", diff --git a/apps/spreadsheeteditor/main/resources/less/toolbar.less b/apps/spreadsheeteditor/main/resources/less/toolbar.less index 7cab7037c..6c84ecc9e 100644 --- a/apps/spreadsheeteditor/main/resources/less/toolbar.less +++ b/apps/spreadsheeteditor/main/resources/less/toolbar.less @@ -13,6 +13,10 @@ .simple-bar { display: table; width: 100%; + + .separator.short { + margin-top: 1px; + } } .font-attr { @@ -113,10 +117,6 @@ border: @scaled-one-px-value solid @border-regular-control; } -#slot-field-fontname { - width: 127px; -} - #slot-field-fontsize { width: 45px; }