diff --git a/apps/common/main/lib/component/ColorPaletteExt.js b/apps/common/main/lib/component/ColorPaletteExt.js
new file mode 100644
index 000000000..e69a4abd6
--- /dev/null
+++ b/apps/common/main/lib/component/ColorPaletteExt.js
@@ -0,0 +1,245 @@
+/*
+ *
+ * (c) Copyright Ascensio System Limited 2010-2016
+ *
+ * This program is a free software product. You can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License (AGPL)
+ * version 3 as published by the Free Software Foundation. In accordance with
+ * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
+ * that Ascensio System SIA expressly excludes the warranty of non-infringement
+ * of any third-party rights.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
+ * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
+ *
+ * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
+ * EU, LV-1021.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of the Program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU AGPL version 3.
+ *
+ * Pursuant to Section 7(b) of the License you must retain the original Product
+ * logo when distributing the program. Pursuant to Section 7(e) we decline to
+ * grant you any rights under trademark law for use of our trademarks.
+ *
+ * All the Product's GUI elements, including illustrations and icon sets, as
+ * well as technical writing content are licensed under the terms of the
+ * Creative Commons Attribution-ShareAlike 4.0 International. See the License
+ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
+ *
+*/
+/**
+ * ColorPaletteExt.js
+ *
+ * Created by Julia Radzhabova on 07/21/15
+ * Copyright (c) 2014 Ascensio System SIA. All rights reserved.
+ *
+ */
+
+if (Common === undefined)
+ var Common = {};
+
+define([
+ 'common/main/lib/component/BaseView'
+], function () { 'use strict';
+
+ Common.UI.ColorPaletteExt = Common.UI.BaseView.extend({
+ options: {
+ dynamiccolors: 10,
+ allowReselect: true,
+ cls: '',
+ style: ''
+ },
+
+ template:
+ _.template([
+ '
',
+ '<% var me = this; %>',
+ '<% $(colors).each(function(num, item) { %>',
+ '<% if (me.isColor(item)) { %>',
+ '
',
+ ' ',
+ '
',
+ '<% } else if (me.isTransparent(item)) { %>',
+ '
',
+ ' ',
+ '
',
+ '<% } else if (me.isEffect(item)) { %>',
+ '
',
+ ' ',
+ '
',
+ '<% } %>',
+ '<% }); %>',
+ '
'].join('')),
+
+ colorRe: /(?:^|\s)color-(.{6})(?:\s|$)/,
+ selectedCls: 'selected',
+
+ initialize : function(options) {
+ Common.UI.BaseView.prototype.initialize.call(this, options);
+
+ this.id = this.options.id;
+ this.cls = this.options.cls;
+ this.style = this.options.style;
+ this.colors = this.options.colors || [];
+ this.value = this.options.value;
+
+ if (this.options.el)
+ this.render();
+
+ if (this.options.value)
+ this.select(this.options.value, true);
+ },
+
+ render: function (parentEl) {
+ var me = this;
+
+ if (!me.rendered) {
+ this.cmpEl = $(this.template({
+ id : this.id,
+ cls : this.cls,
+ style : this.style,
+ colors : this.colors
+ }));
+
+ if (parentEl) {
+ this.setElement(parentEl, false);
+ parentEl.html(this.cmpEl);
+ } else {
+ $(this.el).html(this.cmpEl);
+ }
+
+ this.cmpEl.on('click', _.bind(this.handleClick, this));
+ } else {
+ this.cmpEl = $(this.el);
+ }
+
+ me.rendered = true;
+ return this;
+ },
+
+ isColor: function(v) {
+ return typeof(v) == 'string' && (/[0-9A-F]{6}/).test(v);
+ },
+
+ isTransparent: function(v) {
+ return typeof(v) == 'string' && (v=='transparent');
+ },
+
+ isEffect: function(v) {
+ return (typeof(v) == 'object' && v.effectId !== undefined);
+ },
+
+ getColor: function() {
+ return this.value;
+ },
+
+ handleClick: function(e) {
+ var me = this;
+ var target = $(e.target).closest('div.palette-color-item');
+ var color, cmp;
+
+ if (target.length==0) return;
+
+ if (target.hasClass('color-transparent') ) {
+ $(me.el).find('div.' + me.selectedCls).removeClass(me.selectedCls);
+ target.addClass(me.selectedCls);
+ me.value = 'transparent';
+ me.trigger('select', me, 'transparent');
+ } else {
+ if (!/^[a-fA-F0-9]{6}$/.test(me.value) || _.indexOf(me.colors, me.value)<0 )
+ me.value = false;
+
+ $(me.el).find('div.' + me.selectedCls).removeClass(me.selectedCls);
+ target.addClass(me.selectedCls);
+
+ color = target[0].className.match(me.colorRe)[1];
+ if ( target.hasClass('palette-color-effect') ) {
+ var effectId = parseInt(target.attr('effectid'));
+ if (color) {
+ me.value = color.toUpperCase();
+ me.trigger('select', me, {color: color, effectId: effectId});
+ }
+ } else {
+ if (/#?[a-fA-F0-9]{6}/.test(color)) {
+ color = /#?([a-fA-F0-9]{6})/.exec(color)[1].toUpperCase();
+ me.value = color;
+ me.trigger('select', me, color);
+ }
+ }
+ }
+ },
+
+ select: function(color, suppressEvent) {
+ var el = $(this.el);
+ el.find('div.' + this.selectedCls).removeClass(this.selectedCls);
+
+ if (!color) return;
+
+ if (typeof(color) == 'object' ) {
+ var effectEl;
+ if (color.effectId !== undefined) {
+ effectEl = el.find('div[effectid="'+color.effectId+'"]').first();
+ if (effectEl.length>0) {
+ effectEl.addClass(this.selectedCls);
+ this.value = effectEl[0].className.match(this.colorRe)[1].toUpperCase();
+ } else
+ this.value = false;
+ } else if (color.effectValue !== undefined) {
+ effectEl = el.find('div[effectvalue="'+color.effectValue+'"].color-' + color.color.toUpperCase()).first();
+ if (effectEl.length>0) {
+ effectEl.addClass(this.selectedCls);
+ this.value = effectEl[0].className.match(this.colorRe)[1].toUpperCase();
+ } else
+ this.value = false;
+ }
+ } else {
+ if (/#?[a-fA-F0-9]{6}/.test(color)) {
+ color = /#?([a-fA-F0-9]{6})/.exec(color)[1].toUpperCase();
+ this.value = color;
+ }
+
+ if (/^[a-fA-F0-9]{6}|transparent$/.test(color) && _.indexOf(this.colors, color)>=0 ) {
+ if (_.indexOf(this.colors, this.value)<0) this.value = false;
+
+ if (color != this.value || this.options.allowReselect) {
+ (color == 'transparent') ? el.find('div.color-transparent').addClass(this.selectedCls) : el.find('div.palette-color.color-' + color).first().addClass(this.selectedCls);
+ this.value = color;
+ if (suppressEvent !== true) {
+ this.fireEvent('select', this, color);
+ }
+ }
+ } else {
+ var co = el.find('#'+color).first();
+ if (co.length==0)
+ co = el.find('div[color="'+color+'"]').first();
+ if (co.length>0) {
+ co.addClass(this.selectedCls);
+ this.value = color.toUpperCase();
+ }
+ }
+ }
+ },
+
+ updateColors: function(effectcolors) {
+ if (effectcolors===undefined) return;
+
+ this.colors = effectcolors;
+ this.cmpEl = $(this.template({
+ id : this.id,
+ cls : this.cls,
+ style : this.style,
+ colors : this.colors
+ }));
+ $(this.el).html(this.cmpEl);
+ this.cmpEl.on('click', _.bind(this.handleClick, this));
+ },
+
+ clearSelection: function(suppressEvent) {
+ $(this.el).find('div.' + this.selectedCls).removeClass(this.selectedCls);
+ this.value = undefined;
+ }
+ });
+});
\ No newline at end of file
diff --git a/apps/common/main/resources/less/asc-mixins.less b/apps/common/main/resources/less/asc-mixins.less
index 2b68ccbe3..69a4fcedc 100644
--- a/apps/common/main/resources/less/asc-mixins.less
+++ b/apps/common/main/resources/less/asc-mixins.less
@@ -138,7 +138,7 @@
@common-controls-width: 100px;
.img-commonctrl,
- .theme-colorpalette .color-transparent, .dropdown-menu li .checked:before, .input-error:before {
+ .theme-colorpalette .color-transparent, .palette-color-ext .color-transparent, .dropdown-menu li .checked:before, .input-error:before {
background: e(%("url(%s)",'@{common-image-path}/@{common-controls}')) no-repeat;
@media
diff --git a/apps/common/main/resources/less/colorpalette.less b/apps/common/main/resources/less/colorpalette.less
index eb32981c4..08cd85b7b 100644
--- a/apps/common/main/resources/less/colorpalette.less
+++ b/apps/common/main/resources/less/colorpalette.less
@@ -10,4 +10,46 @@
.box-shadow(0 0 0 1px @primary);
}
}
+}
+
+.palette-color-ext {
+ padding: 10px;
+ .palette-color-item {
+ padding: 0;
+ border: 1px solid #fff;
+ display: inline-block;
+ text-decoration: none;
+ -moz-outline: 0 none;
+ outline: 0 none;
+ cursor: pointer;
+ vertical-align: middle;
+
+ em {
+ border: none;
+ display: block;
+
+ span{
+ height: 12px;
+ width: 12px;
+ cursor: pointer;
+ display: block;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ }
+ }
+
+ &:hover, &.selected {
+ border-color: #000;
+ em span {
+ border-color: #fff;
+ }
+ }
+ }
+
+ .color-transparent {
+ background-position: @nocolor-offset-x @nocolor-offset-y;
+
+ em span {
+ border:solid 1px #C0C0C0;
+ }
+ }
}
\ No newline at end of file
diff --git a/apps/documenteditor/main/app/view/ImageSettingsAdvanced.js b/apps/documenteditor/main/app/view/ImageSettingsAdvanced.js
index ec0a330db..18a8f4065 100644
--- a/apps/documenteditor/main/app/view/ImageSettingsAdvanced.js
+++ b/apps/documenteditor/main/app/view/ImageSettingsAdvanced.js
@@ -98,6 +98,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat
this._nRatio = 1;
this._originalProps = this.options.imageProps;
+ this.sectionProps = this.options.sectionProps;
this.pageWidth = this.options.sectionProps ? this.options.sectionProps.get_W() : 210;
this.pageHeight = this.options.sectionProps ? this.options.sectionProps.get_H() : 297;
this._changedProps = null;
@@ -327,10 +328,10 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat
}, this));
this._arrHRelativePc = [
- {displayValue: this.textLeftMargin, value: Asc.c_oAscRelativeFromH.LeftMargin},
- {displayValue: this.textMargin, value: Asc.c_oAscRelativeFromH.Margin},
- {displayValue: this.textPage, value: Asc.c_oAscRelativeFromH.Page},
- {displayValue: this.textRightMargin, value: Asc.c_oAscRelativeFromH.RightMargin}
+ {displayValue: this.textLeftMargin, value: Asc.c_oAscRelativeFromH.LeftMargin, size: this.sectionProps.get_LeftMargin()},
+ {displayValue: this.textMargin, value: Asc.c_oAscRelativeFromH.Margin, size: this.sectionProps.get_W() - this.sectionProps.get_LeftMargin() - this.sectionProps.get_RightMargin()},
+ {displayValue: this.textPage, value: Asc.c_oAscRelativeFromH.Page, size: this.sectionProps.get_W()},
+ {displayValue: this.textRightMargin, value: Asc.c_oAscRelativeFromH.RightMargin, size: this.sectionProps.get_RightMargin()}
];
this.cmbWidthPc = new Common.UI.ComboBox({
@@ -345,10 +346,10 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat
this.cmbWidthPc.on('selected', _.bind(this.onCmbWidthPcSelect, this));
this._arrVRelativePc = [
- {displayValue: this.textMargin, value: Asc.c_oAscRelativeFromV.Margin},
- {displayValue: this.textBottomMargin, value: Asc.c_oAscRelativeFromV.BottomMargin},
- {displayValue: this.textPage, value: Asc.c_oAscRelativeFromV.Page},
- {displayValue: this.textTopMargin, value: Asc.c_oAscRelativeFromV.TopMargin}
+ {displayValue: this.textMargin, value: Asc.c_oAscRelativeFromV.Margin, size: this.sectionProps.get_H() - this.sectionProps.get_TopMargin() - this.sectionProps.get_BottomMargin()},
+ {displayValue: this.textBottomMargin, value: Asc.c_oAscRelativeFromV.BottomMargin, size: this.sectionProps.get_BottomMargin()},
+ {displayValue: this.textPage, value: Asc.c_oAscRelativeFromV.Page, size: this.sectionProps.get_H()},
+ {displayValue: this.textTopMargin, value: Asc.c_oAscRelativeFromV.TopMargin, size: this.sectionProps.get_TopMargin()}
];
this.cmbHeightPc = new Common.UI.ComboBox({
@@ -1265,6 +1266,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat
for (i=0; i0) {
+ filterObj.asc_setFilter(new Asc.ColorFilter());
+ filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.ColorFilter);
+
+ var colorFilter = filterObj.asc_getFilter();
+ colorFilter.asc_setCellColor((item.value==1) ? null : false);
+ colorFilter.asc_setCColor((item.value==1) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor);
+ } else {
+ filterObj.asc_setFilter(new Asc.CustomFilters());
+ filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.CustomFilters);
+
+ var customFilter = filterObj.asc_getFilter();
+ customFilter.asc_setCustomFilters([new Asc.CustomFilter()]);
+ customFilter.asc_setAnd(true);
+ var customFilters = customFilter.asc_getCustomFilters();
+ customFilters[0].asc_setOperator(Asc.c_oAscCustomAutoFilter.equals);
+// customFilters[0].asc_setVal('');
+ }
+
+ autoFilterObject.asc_setFilterObj(filterObj);
+ this.api.asc_applyAutoFilterByType(autoFilterObject);
+
+ Common.NotificationCenter.trigger('edit:complete', this.documentHolder);
+ Common.component.Analytics.trackEvent('DocumentHolder', 'Filter Cells');
+ }
+ },
+
+ onReapply: function() {
+ this.api.asc_reapplyAutoFilter(this.documentHolder.ssMenu.formatTableName);
+ },
+
onClear: function(menu, item) {
if (this.api) {
this.api.asc_emptyCells(item.value);
@@ -1181,6 +1218,8 @@ define([
formatTableInfo = cellinfo.asc_getFormatTableInfo(),
isintable = (formatTableInfo !== null);
documentHolder.ssMenu.formatTableName = (isintable) ? formatTableInfo.asc_getTableName() : null;
+ documentHolder.ssMenu.cellColor = cellinfo.asc_getFill().asc_getColor();
+ documentHolder.ssMenu.fontColor = cellinfo.asc_getFont().asc_getColor();
documentHolder.pmiInsertEntire.setVisible(isrowmenu||iscolmenu);
documentHolder.pmiInsertEntire.setCaption((isrowmenu) ? this.textInsertTop : this.textInsertLeft);
@@ -1190,7 +1229,10 @@ define([
documentHolder.pmiSelectTable.setVisible(iscellmenu && !iscelledit && isintable);
documentHolder.pmiInsertTable.setVisible(iscellmenu && !iscelledit && isintable);
documentHolder.pmiDeleteTable.setVisible(iscellmenu && !iscelledit && isintable);
- documentHolder.pmiSortCells.setVisible((iscellmenu||isallmenu||cansort) && !iscelledit && !isintable);
+ documentHolder.pmiSortCells.setVisible((iscellmenu||isallmenu||cansort) && !iscelledit);
+ documentHolder.pmiFilterCells.setVisible((iscellmenu||cansort) && !iscelledit);
+ documentHolder.pmiReapply.setVisible((iscellmenu||isallmenu||cansort) && !iscelledit);
+ documentHolder.ssMenu.items[12].setVisible((iscellmenu||isallmenu||cansort) && !iscelledit);
documentHolder.pmiInsFunction.setVisible(iscellmenu||insfunc);
documentHolder.pmiAddNamedRange.setVisible(iscellmenu && !iscelledit);
@@ -1218,7 +1260,7 @@ define([
documentHolder.pmiFreezePanes.setCaption(this.api.asc_getSheetViewSettings().asc_getIsFreezePane() ? documentHolder.textUnFreezePanes : documentHolder.textFreezePanes);
/** coauthoring begin **/
- documentHolder.ssMenu.items[13].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments);
+ documentHolder.ssMenu.items[16].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments);
documentHolder.pmiAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments);
/** coauthoring end **/
documentHolder.pmiCellMenuSeparator.setVisible(iscellmenu || isrowmenu || iscolmenu || isallmenu || insfunc);
@@ -1236,17 +1278,20 @@ define([
documentHolder.pmiClear.menu.items[3].setVisible(!this.permissions.isEditDiagram);
documentHolder.pmiClear.menu.items[4].setVisible(!this.permissions.isEditDiagram);
- var filterInfo = cellinfo.asc_getAutoFilterInfo();
- filterInfo = (filterInfo) ? filterInfo.asc_getIsApplyAutoFilter() : false;
- documentHolder.pmiInsertCells.menu.items[0].setDisabled(filterInfo);
- documentHolder.pmiDeleteCells.menu.items[0].setDisabled(filterInfo);
- documentHolder.pmiInsertCells.menu.items[1].setDisabled(filterInfo);
- documentHolder.pmiDeleteCells.menu.items[1].setDisabled(filterInfo);
+ var filterInfo = cellinfo.asc_getAutoFilterInfo(),
+ isApplyAutoFilter = (filterInfo) ? filterInfo.asc_getIsApplyAutoFilter() : false;
+ filterInfo = (filterInfo) ? filterInfo.asc_getIsAutoFilter() : null;
+ documentHolder.pmiInsertCells.menu.items[0].setDisabled(isApplyAutoFilter);
+ documentHolder.pmiDeleteCells.menu.items[0].setDisabled(isApplyAutoFilter);
+ documentHolder.pmiInsertCells.menu.items[1].setDisabled(isApplyAutoFilter);
+ documentHolder.pmiDeleteCells.menu.items[1].setDisabled(isApplyAutoFilter);
_.each(documentHolder.ssMenu.items, function(item) {
item.setDisabled(isCellLocked);
});
documentHolder.pmiCopy.setDisabled(false);
+ documentHolder.pmiSortCells.setDisabled(isCellLocked || (filterInfo==null));
+ documentHolder.pmiReapply.setDisabled(isCellLocked || (isApplyAutoFilter!==true));
if (showMenu) this.showPopupMenu(documentHolder.ssMenu, {}, event);
} else if (this.permissions.isEditDiagram && seltype == Asc.c_oAscSelectionType.RangeChartText) {
if (!showMenu && !documentHolder.textInShapeMenu.isVisible()) return;
diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js
index 2e75c44b3..27858127b 100644
--- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js
+++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js
@@ -206,10 +206,10 @@ define([
toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this));
toolbar.btnInsertText.menu.on('item:click', _.bind(this.onInsertTextClick, this));
toolbar.btnInsertShape.menu.on('hide:after', _.bind(this.onInsertShapeHide, this));
- toolbar.btnSortDown.on('click', _.bind(this.onSortType, this, 'ascending'));
- toolbar.btnSortUp.on('click', _.bind(this.onSortType, this, 'descending'));
- toolbar.mnuitemSortAZ.on('click', _.bind(this.onSortType, this, 'ascending'));
- toolbar.mnuitemSortZA.on('click', _.bind(this.onSortType, this, 'descending'));
+ 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.mnuitemSortAZ.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Ascending));
+ toolbar.mnuitemSortZA.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending));
toolbar.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this));
toolbar.mnuitemAutoFilter.on('click', _.bind(this.onAutoFilter, this));
toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this));
diff --git a/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js b/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js
index 851a7542b..303d7fbed 100644
--- a/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js
+++ b/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js
@@ -41,7 +41,8 @@
*/
define([
- 'common/main/lib/component/Window'
+ 'common/main/lib/component/Window',
+ 'common/main/lib/component/ColorPaletteExt'
], function () {
'use strict';
@@ -66,29 +67,22 @@ define([
this.template = options.template || [
'',
'
',
-
- '',
-
- '
',
-
- '
',
-
- '
',
-
+ '',
+ '
',
+ '
',
+ '
',
'
',
'
',
-
'',
-
'