[SSE mobile] added option "insert function"

This commit is contained in:
Maxim Kadushkin 2016-12-16 17:52:24 +03:00
parent 7da46250d7
commit 9de0c0e68d
13 changed files with 427 additions and 3 deletions

View file

@ -55,7 +55,7 @@ define(
//Extend jQuery functions
jQuery.fn.extend( {
single: function(types, selector, data, fn) {
return this.off(types, fn).on(types, selector, data, fn);
return this.off(types, selector, fn).on(types, selector, data, fn);
}
});

View file

@ -132,6 +132,7 @@ require([
// ,'EditHyperlink'
,'AddContainer'
,'AddChart'
,'AddFunction'
,'AddShape'
// ,'AddImage'
,'AddOther'
@ -202,6 +203,7 @@ require([
// ,'spreadsheeteditor/mobile/app/controller/edit/EditHyperlink'
,'spreadsheeteditor/mobile/app/controller/add/AddContainer'
,'spreadsheeteditor/mobile/app/controller/add/AddChart'
,'spreadsheeteditor/mobile/app/controller/add/AddFunction'
,'spreadsheeteditor/mobile/app/controller/add/AddShape'
// ,'spreadsheeteditor/mobile/app/controller/add/AddImage'
,'spreadsheeteditor/mobile/app/controller/add/AddOther'

View file

@ -115,7 +115,7 @@ define([
addViews.push({
caption: me.textFormula,
id: 'add-formula',
layout: me._dummyEditController().getLayout()
layout: SSE.getController('AddFunction').getView('AddFunction').rootLayout()
});
addViews.push({
@ -264,7 +264,7 @@ define([
},
textChart: 'Chart',
textFormula: 'Formula',
textFormula: 'Function',
textShape: 'Shape',
textOther: 'Other'
}

View file

@ -0,0 +1,128 @@
/*
*
* (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
*
*/
/**
* AddFunction.js
*
* Created by Maxim Kadushkin on 12/14/2016
* Copyright (c) 2016 Ascensio System SIA. All rights reserved.
*
*/
define([
'core',
'spreadsheeteditor/mobile/app/view/add/AddFunction',
'text!../../../resources/l10n/functions/en.json',
'text!../../../resources/l10n/functions/en_desc.json'
], function (core, view, fc, fd) {
'use strict';
SSE.Controllers.AddFunction = Backbone.Controller.extend(_.extend((function() {
return {
models: [],
collections: [],
views: [
'AddFunction'
],
initialize: function () {
Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this));
this.addListeners({
'AddFunction': {
'function:insert': this.onInsertFunction.bind(this),
'function:info': this.onFunctionInfo.bind(this)
}
});
},
setApi: function (api) {
this.api = api;
},
onLaunch: function () {
this.createView('AddFunction').render();
var me = this;
_.defer(function () {
me.api.asc_setLocalization(fc);
me.fillFunctions.call(me);
});
},
initEvents: function () {
},
fillFunctions: function() {
var functions = {};
var jsonDescr = JSON.parse(fd);
var grouparr = this.api.asc_getFormulasInfo();
for (var group of grouparr) {
var groupname = group.asc_getGroupName();
var funcarr = group.asc_getFormulasArray();
for (var func of funcarr) {
var _name = func.asc_getName();
functions[_name] = {
type: _name,
group: groupname,
caption: func.asc_getLocaleName(),
args: jsonDescr[_name].a || '',
descr: jsonDescr[_name].d || ''
};
}
}
this.getView('AddFunction').setFunctions(functions);
},
onInsertFunction: function (type) {
SSE.getController('AddContainer').hideModal();
this.api.asc_insertFormula(this.api.asc_getFormulaLocaleName(type), Asc.c_oAscPopUpSelectorType.Func, true);
},
onFunctionInfo: function (type) {
this.getView('AddFunction').openFunctionInfo(type);
},
txtDiagramTitle: 'Chart Title',
txtXAxis: 'X Axis',
txtYAxis: 'Y Axis',
txtSeries: 'Seria'
}
})(), SSE.Controllers.AddChart || {}))
});

View file

@ -0,0 +1,95 @@
<!-- Root view -->
<% if (view == 'root') { %>
<div id="add-function-root">
<div class="page-content">
<div class="list-block">
<ul>
<% _.each(quick, function(f) { %>
<li class="function">
<a data-func="<%= f.type %>" class="item-link no-indicator quick">
<div class="item-content">
<div class="item-inner">
<div class="item-title"><%= f.caption %></div>
<div class="item-after"><span class="info"></span></div>
</div>
</div>
</a>
</li>
<% }); %>
</ul>
</div>
<div class="list-block">
<ul class="groups">
<li class="item-divider">CATEGORIES</li>
<% for (var g in groups) { %>
<li>
<a data-type="<%= g %>" class="item-link group">
<div class="item-content">
<div class="item-inner">
<div class="item-title"><%= groups[g] %></div>
</div>
</div>
</a>
</li>
<% }; %>
<ul>
</div>
</div>
</div>
<% } %>
<!-- Category view -->
<% if (view == 'group') { %>
<div id="add-function-group">
<div class="navbar">
<div class="navbar-inner">
<div class="left sliding"><a href="#" class="back link"><i class="icon icon-back"></i><% if (!android) { %><span><%= textBack %></span><% } %></a></div>
<div class="center sliding"><%= groupname %></div>
</div>
</div>
<div class="page">
<div class="page-content">
<div class="list-block">
<ul>
<% _.each(functions, function(f) { %>
<li class="function">
<a data-func="<%= f.type %>" class="item-link no-indicator">
<div class="item-content">
<div class="item-inner">
<div class="item-title"><%= f.caption %></div>
<div class="item-after"><span class="info"></span></div>
</div>
</div>
</a>
</li>
<% }); %>
</ul>
</div>
</div>
</div>
</div>
<% } %>
<!-- Description view -->
<% if (view == 'info') { %>
<div id="add-function-info">
<div class="navbar">
<div class="navbar-inner">
<div class="left sliding"><a href="#" class="back link"><i class="icon icon-back"></i><% if (!android) { %><span><%= textBack %></span><% } %></a></div>
<div class="center sliding"><%= caption %></div>
</div>
</div>
<div class="page">
<div class="page-content">
<div class="content-block">
<div class="content-block-inner">
<h3><%= args %></h3>
<p><%= descr %></p>
</div>
</div>
</div>
</div>
</div>
<% } %>

View file

@ -0,0 +1,187 @@
/*
*
* (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
*
*/
/**
* AddFunction.js
*
* Created by Maxim Kadushkin on 12/14/2016
* Copyright (c) 2016 Ascensio System SIA. All rights reserved.
*
*/
define([
'text!spreadsheeteditor/mobile/app/template/AddFunction.template',
'backbone'
], function (addTemplate, Backbone) {
'use strict';
SSE.Views.AddFunction = Backbone.View.extend(_.extend((function() {
var _openView = function (viewid, args) {
var rootView = SSE.getController('AddContainer').rootView;
if ( rootView ) {
var _params = {
android : Common.SharedSettings.get('android'),
phone : Common.SharedSettings.get('phone'),
view : viewid,
textBack : 'Back'
};
_.extend(_params, args);
var $content = $('<div/>').append(_.template(this.template, _params));
// Android fix for navigation
if (Framework7.prototype.device.android) {
$content.find('.page').append($content.find('.navbar'));
}
rootView.router.load({
content: $content.html()
});
}
};
return {
// el: '.view-main',
template: addTemplate,
events: {
},
initialize: function () {
Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this));
},
initEvents: function () {
var me = this;
$('.settings').single('click', '.function .info', this.onFunctionInfoClick.bind(this))
.single('click', '.function > a', this.onFunctionClick.bind(this));
$('.groups a.group').single('click', this.onGroupClick.bind(this));
me.initControls();
},
// Render layout
render: function () {
var quickFunctions = [
{caption: 'SUM', type: 'SUM'},
{caption: 'MIN', type: 'MIN'},
{caption: 'MAX', type: 'MAX'},
{caption: 'COUNT', type: 'COUNT'}
];
this.groups = {
'DateAndTime': this.sCatDateAndTime,
'Engineering': this.sCatEngineering,
'TextAndData': this.sCatTextAndData,
'Statistical': this.sCatStatistical,
'Financial': this.sCatFinancial,
'Mathematic': this.sCatMathematic,
'LookupAndReference': this.sCatLookupAndReference,
'Information': this.sCatInformation,
'Logical': this.sCatLogical
};
this.layout = $('<div/>').append(_.template(this.template, {
android : Common.SharedSettings.get('android'),
phone : Common.SharedSettings.get('phone'),
quick : quickFunctions,
groups : this.groups,
view : 'root'
}));
return this;
},
setFunctions: function (arr) {
this.functions = arr;
},
rootLayout: function () {
if (this.layout) {
return this.layout.find('#add-function-root').html();
}
return '';
},
initControls: function () {
//
},
onFunctionClick: function (e) {
if ( !/\.info/.test(e.target) )
this.fireEvent('function:insert', [$(e.target).data('func')]);
},
onFunctionInfoClick: function(e) {
e.stopPropagation();
var type = $(e.target).parents('.item-link').data('func');
this.fireEvent('function:info', [type]);
},
onGroupClick: function (e) {
var group = $(e.target).parents('.group').data('type');
var items = [];
for (var k in this.functions) {
if (this.functions[k].group == group)
items.push(this.functions[k]);
}
_openView.call(this, 'group', {
groupname : this.groups[group],
functions : items
});
},
openFunctionInfo: function (type) {
_openView.call(this, 'info', this.functions[type]);
},
sCatLogical: 'Logical',
// sCatCube: 'Cube',
// sCatDatabase: 'Database',
sCatDateAndTime: 'Date and time',
sCatEngineering: 'Engineering',
sCatFinancial: 'Financial',
sCatInformation: 'Information',
sCatLookupAndReference: 'Lookup and Reference',
sCatMathematic: 'Math and trigonometry',
sCatStatistical: 'Statistical',
sCatTextAndData: 'Text and data'
}
})(), SSE.Views.AddFunction || {}));
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

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

File diff suppressed because one or more lines are too long

View file

@ -29,3 +29,10 @@
flex-direction: row;
align-items: stretch;
}
.info {
width: 22px;
height: 22px;
background-image: url(../img/docinfo.png);
background-size: contain;
}