[SE mobile] Chart settings, layout

This commit is contained in:
Alexander Yuzhin 2016-12-14 17:14:00 +03:00
parent bf9e024087
commit b0e635135f
16 changed files with 292 additions and 158 deletions

View file

@ -20,6 +20,7 @@
.active { .active {
position: relative; position: relative;
z-index: 1;
&::after { &::after {
content: ''; content: '';

View file

@ -17,6 +17,7 @@
.active { .active {
position: relative; position: relative;
z-index: 1;
&::after { &::after {
content: ''; content: '';

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -57,6 +57,7 @@ define([
_cellStyles = [], _cellStyles = [],
_fontInfo = {}, _fontInfo = {},
_borderInfo = {color: '000000', width: 'medium'}, _borderInfo = {color: '000000', width: 'medium'},
_styleSize = {width: 100, height: 50},
_isEdit = false; _isEdit = false;
function onApiLoadFonts(fonts, select) { function onApiLoadFonts(fonts, select) {
@ -86,8 +87,9 @@ define([
this.addListeners({ this.addListeners({
'EditCell': { 'EditCell': {
'page:show' : this.onPageShow, 'page:show' : this.onPageShow,
'font:click': this.onFontClick 'font:click' : this.onFontClick,
'style:click' : this.onStyleClick
} }
}); });
}, },
@ -96,6 +98,8 @@ define([
var me = this; var me = this;
me.api = api; me.api = api;
me.api.asc_setThumbnailStylesSizes(_styleSize.width, _styleSize.height);
me.api.asc_registerCallback('asc_onInitEditorFonts', _.bind(onApiLoadFonts, me)); me.api.asc_registerCallback('asc_onInitEditorFonts', _.bind(onApiLoadFonts, me));
me.api.asc_registerCallback('asc_onSelectionChanged', _.bind(me.onApiSelectionChanged, me)); me.api.asc_registerCallback('asc_onSelectionChanged', _.bind(me.onApiSelectionChanged, me));
me.api.asc_registerCallback('asc_onEditorSelectionChanged', _.bind(me.onApiEditorSelectionChanged, me)); me.api.asc_registerCallback('asc_onEditorSelectionChanged', _.bind(me.onApiEditorSelectionChanged, me));
@ -122,6 +126,8 @@ define([
me.initSettings(); me.initSettings();
}, },
onPageShow: function (view, pageId) { onPageShow: function (view, pageId) {
var me = this; var me = this;
@ -168,6 +174,10 @@ define([
return _cellInfo; return _cellInfo;
}, },
getStyleSize: function () {
return _styleSize;
},
initFontsPage: function () { initFontsPage: function () {
var me = this, var me = this,
displaySize = _fontInfo.size; displaySize = _fontInfo.size;
@ -321,6 +331,8 @@ define([
$('#fill-color .color-preview').css('background-color', '#' + (_.isObject(clr) ? clr.color : clr)); $('#fill-color .color-preview').css('background-color', '#' + (_.isObject(clr) ? clr.color : clr));
var styleName = cellInfo.asc_getStyleName();
$('#edit-cell .cell-styles li[data-type="' + styleName + '"]').addClass('active');
if (selectionType == Asc.c_oAscSelectionType.RangeChart || selectionType == Asc.c_oAscSelectionType.RangeChartText) { if (selectionType == Asc.c_oAscSelectionType.RangeChart || selectionType == Asc.c_oAscSelectionType.RangeChartText) {
return; return;
@ -365,6 +377,10 @@ define([
} }
}, },
onStyleClick: function (view, type) {
this.api.asc_setCellStyle(type);
},
onBold: function (e) { onBold: function (e) {
var pressed = this._toggleButton(e); var pressed = this._toggleButton(e);

View file

@ -220,6 +220,7 @@ define([
initLayoutPage: function () { initLayoutPage: function () {
var me = this, var me = this,
chartProperties = _chartObject.get_ChartProperties(), chartProperties = _chartObject.get_ChartProperties(),
chartType = chartProperties.getType(),
$layoutPage = $('.page[data-page=edit-chart-layout]'); $layoutPage = $('.page[data-page=edit-chart-layout]');
var setValue = function (id, value) { var setValue = function (id, value) {
@ -230,14 +231,74 @@ define([
$layoutPage.find('#' + id + ' .item-after').text(textValue); $layoutPage.find('#' + id + ' .item-after').text(textValue);
}; };
// Init legend position values
var dataLabelPos = [
{ value: Asc.c_oAscChartDataLabelsPos.none, displayValue: me.textNone },
{ value: Asc.c_oAscChartDataLabelsPos.ctr, displayValue: me.textCenter }
];
if (chartType == Asc.c_oAscChartTypeSettings.barNormal ||
chartType == Asc.c_oAscChartTypeSettings.hBarNormal) {
dataLabelPos.push(
{value: Asc.c_oAscChartDataLabelsPos.inBase, displayValue: me.textInnerBottom},
{value: Asc.c_oAscChartDataLabelsPos.inEnd, displayValue: me.textInnerTop},
{value: Asc.c_oAscChartDataLabelsPos.outEnd, displayValue: me.textOuterTop}
);
} else if ( chartType == Asc.c_oAscChartTypeSettings.barStacked ||
chartType == Asc.c_oAscChartTypeSettings.barStackedPer ||
chartType == Asc.c_oAscChartTypeSettings.hBarStacked ||
chartType == Asc.c_oAscChartTypeSettings.hBarStackedPer ) {
dataLabelPos.push(
{ value: Asc.c_oAscChartDataLabelsPos.inBase, displayValue: me.textInnerBottom },
{ value: Asc.c_oAscChartDataLabelsPos.inEnd, displayValue: me.textInnerTop }
);
} else if (chartType == Asc.c_oAscChartTypeSettings.lineNormal ||
chartType == Asc.c_oAscChartTypeSettings.lineStacked ||
chartType == Asc.c_oAscChartTypeSettings.lineStackedPer ||
chartType == Asc.c_oAscChartTypeSettings.stock ||
chartType == Asc.c_oAscChartTypeSettings.scatter) {
dataLabelPos.push(
{ value: Asc.c_oAscChartDataLabelsPos.l, displayValue: me.textLeft },
{ value: Asc.c_oAscChartDataLabelsPos.r, displayValue: me.textRight },
{ value: Asc.c_oAscChartDataLabelsPos.t, displayValue: me.textTop },
{ value: Asc.c_oAscChartDataLabelsPos.b, displayValue: me.textBottom }
);
} else if (chartType == Asc.c_oAscChartTypeSettings.pie ||
chartType == Asc.c_oAscChartTypeSettings.pie3d) {
dataLabelPos.push(
{value: Asc.c_oAscChartDataLabelsPos.bestFit, displayValue: me.textFit},
{value: Asc.c_oAscChartDataLabelsPos.inEnd, displayValue: me.textInnerTop},
{value: Asc.c_oAscChartDataLabelsPos.outEnd, displayValue: me.textOuterTop}
);
}
$layoutPage.find('select[name=chart-layout-data-labels]').html((function () {
var options = [];
_.each(dataLabelPos, function (position) {
options.push(Common.Utils.String.format('<option value="{0}">{1}</option>', position.value, position.displayValue));
});
return options.join('');
})());
setValue('chart-layout-title', chartProperties.getTitle()); setValue('chart-layout-title', chartProperties.getTitle());
setValue('chart-layout-legend', chartProperties.getLegendPos()); setValue('chart-layout-legend', chartProperties.getLegendPos());
setValue('chart-layout-axis-title-horizontal', chartProperties.getHorAxisLabel()); setValue('chart-layout-axis-title-horizontal', chartProperties.getHorAxisLabel());
setValue('chart-layout-axis-title-vertical', chartProperties.getVertAxisLabel()); setValue('chart-layout-axis-title-vertical', chartProperties.getVertAxisLabel());
setValue('chart-layout-gridlines-horizontal', chartProperties.getHorGridLines()); setValue('chart-layout-gridlines-horizontal', chartProperties.getHorGridLines());
setValue('chart-layout-gridlines-vertical', chartProperties.getDataLabelsPos()); setValue('chart-layout-gridlines-vertical', chartProperties.getVertGridLines());
setValue('chart-layout-data-labels', chartProperties.getDataLabelsPos() || Asc.c_oAscChartDataLabelsPos.none);
// TODO: Modify Data Labels position by chart type var disableSetting = (
chartType == Asc.c_oAscChartTypeSettings.pie ||
chartType == Asc.c_oAscChartTypeSettings.doughnut ||
chartType == Asc.c_oAscChartTypeSettings.pie3d
);
$('#chart-layout-axis-title-horizontal').toggleClass('disabled', disableSetting);
$('#chart-layout-axis-title-vertical').toggleClass('disabled', disableSetting);
$('#chart-layout-gridlines-horizontal').toggleClass('disabled', disableSetting);
$('#chart-layout-gridlines-vertical').toggleClass('disabled', disableSetting);
}, },
initReorderPage: function () { initReorderPage: function () {
@ -492,7 +553,88 @@ define([
return clr; return clr;
}, },
textChart: 'Chart' textChart: 'Chart',
textLayout: 'Layout',
textLegendPos: 'Legend',
textHorTitle: 'Horizontal Axis Title',
textVertTitle: 'Vertical Axis Title',
textDataLabels: 'Data Labels',
textSeparator: 'Data Labels Separator',
textSeriesName: 'Series Name',
textCategoryName: 'Category Name',
textValue: 'Value',
textAxisOptions: 'Axis Options',
textMinValue: 'Minimum Value',
textMaxValue: 'Maximum Value',
textAxisCrosses: 'Axis Crosses',
textUnits: 'Display Units',
textTickOptions: 'Tick Options',
textMajorType: 'Major Type',
textMinorType: 'Minor Type',
textLabelOptions: 'Label Options',
textLabelPos: 'Label Position',
textReverse: 'Values in reverse order',
textVertAxis: 'Vertical Axis',
textHorAxis: 'Horizontal Axis',
textMarksInterval: 'Interval between Marks',
textLabelDist: 'Axis Label Distance',
textLabelInterval: 'Interval between Labels',
textAxisPos: 'Axis Position',
textLeftOverlay: 'Left Overlay',
textRightOverlay: 'Right Overlay',
textOverlay: 'Overlay',
textNoOverlay: 'No Overlay',
textRotated: 'Rotated',
textHorizontal: 'Horizontal',
textInnerBottom: 'Inner Bottom',
textInnerTop: 'Inner Top',
textOuterTop: 'Outer Top',
textNone: 'None',
textCenter: 'Center',
textFixed: 'Fixed',
textAuto: 'Auto',
textCross: 'Cross',
textIn: 'In',
textOut: 'Out',
textLow: 'Low',
textHigh: 'High',
textNextToAxis: 'Next to axis',
textHundreds: 'Hundreds',
textThousands: 'Thousands',
textTenThousands: '10 000',
textHundredThousands: '100 000',
textMillions: 'Millions',
textTenMillions: '10 000 000',
textHundredMil: '100 000 000',
textBillions: 'Billions',
textTrillions: 'Trillions',
textCustom: 'Custom',
textManual: 'Manual',
textBetweenTickMarks: 'Between Tick Marks',
textOnTickMarks: 'On Tick Marks',
textHorGrid: 'Horizontal Gridlines',
textVertGrid: 'Vertical Gridlines',
textLines: 'Lines',
textMarkers: 'Markers',
textMajor: 'Major',
textMinor: 'Minor',
textMajorMinor: 'Major and Minor',
textStraight: 'Straight',
textSmooth: 'Smooth',
textType: 'Type',
textTypeData: 'Type & Data',
textStyle: 'Style',
errorMaxRows: 'ERROR! The maximum number of data series per chart is 255.',
errorStockChart: 'Incorrect row order. To build a stock chart place the data on the sheet in the following order:<br> opening price, max price, min price, closing price.',
textAxisSettings: 'Axis Settings',
textGridLines: 'Gridlines',
textShow: 'Show',
textHide: 'Hide',
textLeft: 'Left',
textRight: 'Right',
textTop: 'Top',
textBottom: 'Bottom',
textFit: 'Fit Width'
} }
})(), SSE.Controllers.EditChart || {})) })(), SSE.Controllers.EditChart || {}))
}); });

View file

@ -82,8 +82,7 @@
<div class="content-block-title">Cell Styles</div> <div class="content-block-title">Cell Styles</div>
<div class="list-block"> <div class="list-block">
<ul> <ul>
<li class="cell-styles"> <li class="cell-styles dataview">
<div class="item-content"></div>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -129,7 +129,7 @@
<div class="center sliding">Style</div> <div class="center sliding">Style</div>
<div class="right"><% if (phone) { %><a href="#" class="link icon-only close-picker"><i class="icon icon-expand-down"></i></a><% } %></div> <div class="right"><% if (phone) { %><a href="#" class="link icon-only close-picker"><i class="icon icon-expand-down"></i></a><% } %></div>
<% if (!android) { %> <% if (!android) { %>
<div class="subnavbar categories"> <div class="edit-chart-style subnavbar categories">
<div class="buttons-row"> <div class="buttons-row">
<a href="#tab-chart-type" class="button tab-link active">Type</a> <a href="#tab-chart-type" class="button tab-link active">Type</a>
<a href="#tab-chart-style" class="button tab-link">Style</a> <a href="#tab-chart-style" class="button tab-link">Style</a>
@ -140,7 +140,7 @@
<% } %> <% } %>
</div> </div>
<% if (android) { %> <% if (android) { %>
<div class="subnavbar categories" style="padding: 0;"> <div class="edit-chart-style subnavbar categories" style="padding: 0;">
<div class="toolbar tabbar" style="top: 0;"> <div class="toolbar tabbar" style="top: 0;">
<div data-page="index" class="toolbar-inner"> <div data-page="index" class="toolbar-inner">
<a href="#tab-chart-type" class="tab-link active">Type</a> <a href="#tab-chart-type" class="tab-link active">Type</a>
@ -349,10 +349,6 @@
<a id="chart-layout-data-labels" class="item-link smart-select" data-back-on-select="true"> <a id="chart-layout-data-labels" class="item-link smart-select" data-back-on-select="true">
<select name="chart-layout-data-labels"> <select name="chart-layout-data-labels">
<option value="0" selected>None</option> <option value="0" selected>None</option>
<option value="3">Center</option>
<option value="4">Inner Bottom</option>
<option value="5">Inner Top</option>
<option value="7">Outer Top</option>
</select> </select>
<div class="item-content"> <div class="item-content">
<div class="item-inner"> <div class="item-inner">

View file

@ -53,7 +53,7 @@ define([
SSE.Views.EditCell = Backbone.View.extend(_.extend((function() { SSE.Views.EditCell = Backbone.View.extend(_.extend((function() {
// private // private
var _fontsList, var _fontsList,
_editTextController; _editCellController;
return { return {
// el: '.view-main', // el: '.view-main',
@ -64,7 +64,7 @@ define([
}, },
initialize: function () { initialize: function () {
_editTextController = SSE.getController('EditCell'); _editCellController = SSE.getController('EditCell');
Common.NotificationCenter.on('editcontainer:show', _.bind(this.initEvents, this)); Common.NotificationCenter.on('editcontainer:show', _.bind(this.initEvents, this));
this.on('page:show', _.bind(this.updateItemHandlers, this)); this.on('page:show', _.bind(this.updateItemHandlers, this));
@ -108,10 +108,11 @@ define([
}, },
renderStyles: function (cellStyles) { renderStyles: function (cellStyles) {
var $styleContainer = $('.cell-styles .item-content'); var $styleContainer = $('#edit-cell .cell-styles');
if ($styleContainer.length > 0) { if ($styleContainer.length > 0) {
var columns = parseInt($styleContainer.width() / 70), // magic var styleSize = _editCellController.getStyleSize(),
columns = parseInt($styleContainer.width() / styleSize.width),
row = -1, row = -1,
styles = []; styles = [];
@ -128,21 +129,42 @@ define([
'<ul class="row">', '<ul class="row">',
'<% _.each(row, function(style) { %>', '<% _.each(row, function(style) { %>',
'<li data-type="<%= style.asc_getName() %>">', '<li data-type="<%= style.asc_getName() %>">',
'<img src="<%= style.asc_getImage() %>" width="50px" height="50px">', '<div class="thumb" style="background-image:url(<%= style.asc_getImage() %>); width: <%= styleSize.width %>px; height: <%= styleSize.height %>px;">',
'</li>', '</li>',
'<% }); %>', '<% }); %>',
'</ul>', '</ul>',
'<% }); %>' '<% }); %>'
].join(''), { ].join(''), {
styles: styles styles: styles,
styleSize: styleSize
}); });
$styleContainer.html(template); $styleContainer.html(template);
$('#edit-cell .cell-styles li').single('click', _.buffered(function (e) {
var $target = $(e.currentTarget),
type = $target.data('type');
$('#edit-cell .cell-styles li').removeClass('active');
$target.addClass('active');
this.fireEvent('style:click', [this, type]);
}, 100, this));
} }
}, },
updateItemHandlers: function () { updateItemHandlers: function () {
$('.container-edit a.item-link[data-page]').single('click', _.bind(this.onItemClick, this)); var selectorsDynamicPage = [
'#edit-cell',
'.page[data-page=edit-border-style]',
'.page[data-page=edit-cell-format]'
].map(function (selector) {
return selector + ' a.item-link[data-page]';
}).join(', ');
$(selectorsDynamicPage).single('click', _.bind(this.onItemClick, this));
// $('.container-edit a.item-link[data-page]').single('click', _.bind(this.onItemClick, this));
}, },
showPage: function (templateId, suspendEvent) { showPage: function (templateId, suspendEvent) {
@ -197,7 +219,7 @@ define([
items: SSE.getController('EditCell').getFonts(), items: SSE.getController('EditCell').getFonts(),
template: $template.html(), template: $template.html(),
onItemsAfterInsert: function (list, fragment) { onItemsAfterInsert: function (list, fragment) {
var fontInfo = _editTextController.getFontInfo(); var fontInfo = _editCellController.getFontInfo();
$('#font-list input[name=font-name]').val([fontInfo.name]); $('#font-list input[name=font-name]').val([fontInfo.name]);
$('#font-list li').single('click', _.buffered(function (e) { $('#font-list li').single('click', _.buffered(function (e) {

View file

@ -169,8 +169,16 @@ define([
}, },
updateItemHandlers: function () { updateItemHandlers: function () {
$('.container-edit a.item-link[data-page]').single('click', _.bind(this.onItemClick, this)); var selectorsDynamicPage = [
$('.subnavbar.categories a').single('click', function () { '#edit-chart',
'.page[data-page=edit-chart-style]'
].map(function (selector) {
return selector + ' a.item-link[data-page]';
}).join(', ');
$(selectorsDynamicPage).single('click', _.bind(this.onItemClick, this));
$('.edit-chart-style.subnavbar.categories a').single('click', function () {
$('.page[data-page=edit-chart-style]').find('.list-block.inputs-list').removeClass('inputs-list'); $('.page[data-page=edit-chart-style]').find('.list-block.inputs-list').removeClass('inputs-list');
}); });
}, },

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -141,41 +141,30 @@ input, textarea {
} }
} }
// Bullets and numbers // Cell style
.cell-styles.dataview {
.bullets, .active:after {
.numbers { right: 2px;
ul { bottom: 2px;
margin-top: 10px;
} }
li { .row {
width: 70px; padding: 5px;
height: 70px;
margin-right: 1px;
border: 1px solid #c4c4c4;
html.pixel-ratio-2 & {
border: 0.5px solid #c4c4c4;
}
html.pixel-ratio-3 & {
border: 0.33px solid #c4c4c4;
}
&.active { li {
// border: 1px solid @listBlockBorderColor;
} html.pixel-ratio-2 & {
border: 0.5px solid @listBlockBorderColor;
}
html.pixel-ratio-3 & {
border: 0.33px solid @listBlockBorderColor;
}
padding: 2px;
.thumb { .thumb {
width: 100%; width: 112px;
height: 100%; height: 38px;
background-color: @white; background-size: contain;
background-size: cover;
label {
width: 100%;
text-align: center;
position: absolute;
top: 34%;
} }
} }
} }

View file

@ -134,51 +134,31 @@ input, textarea {
} }
} }
// Bullets and numbers // Cell style
.cell-styles.dataview {
.bullets, .active:after {
.numbers { right: 2px;
ul { bottom: 2px;
margin-top: 10px;
} }
li { .row {
width: 70px; padding: 5px 0;
height: 70px;
margin-right: 1px;
border: 1px solid #c4c4c4;
html.pixel-ratio-2 & {
border: 0.5px solid #c4c4c4;
}
html.pixel-ratio-3 & {
border: 0.33px solid #c4c4c4;
}
&.active { li {
// border: 1px solid @listBlockBorderColor;
} html.pixel-ratio-2 & {
border: 0.5px solid @listBlockBorderColor;
}
html.pixel-ratio-3 & {
border: 0.33px solid @listBlockBorderColor;
}
padding: 2px;
.thumb { .thumb {
width: 100%; width: 112px;
height: 100%; height: 38px;
background-color: @white; background-size: contain;
background-size: cover;
label {
width: 100%;
text-align: center;
position: absolute;
top: 34%;
} }
} }
} }
} }
.phone {
.page.editor {
&.no-padding {
padding-top: 0;
transition: padding-top .2s ease-in;
}
}
}