[PE mobile] Add shapes.

This commit is contained in:
Julia Radzhabova 2016-11-28 17:47:55 +03:00
parent 8754588b0a
commit 02230651af
8 changed files with 391 additions and 67 deletions

View file

@ -147,9 +147,9 @@ require([
'EditShape', 'EditShape',
// 'EditChart', // 'EditChart',
// 'EditHyperlink', // 'EditHyperlink',
'AddContainer' 'AddContainer',
// 'AddTable', // 'AddTable',
// 'AddShape', 'AddShape'
// 'AddImage', // 'AddImage',
// 'AddOther' // 'AddOther'
] ]
@ -212,9 +212,9 @@ require([
'presentationeditor/mobile/app/controller/edit/EditShape', 'presentationeditor/mobile/app/controller/edit/EditShape',
// 'presentationeditor/mobile/app/controller/edit/EditChart', // 'presentationeditor/mobile/app/controller/edit/EditChart',
// 'presentationeditor/mobile/app/controller/edit/EditHyperlink', // 'presentationeditor/mobile/app/controller/edit/EditHyperlink',
'presentationeditor/mobile/app/controller/add/AddContainer' 'presentationeditor/mobile/app/controller/add/AddContainer',
// 'presentationeditor/mobile/app/controller/add/AddTable', // 'presentationeditor/mobile/app/controller/add/AddTable',
// 'presentationeditor/mobile/app/controller/add/AddShape', 'presentationeditor/mobile/app/controller/add/AddShape'
// 'presentationeditor/mobile/app/controller/add/AddImage', // 'presentationeditor/mobile/app/controller/add/AddImage',
// 'presentationeditor/mobile/app/controller/add/AddOther' // 'presentationeditor/mobile/app/controller/add/AddOther'

View file

@ -155,12 +155,12 @@ require([
// 'EditParagraph' // 'EditParagraph'
// 'EditTable', // 'EditTable',
// 'EditImage', // 'EditImage',
'EditShape' 'EditShape',
// 'EditChart', // 'EditChart',
// 'EditHyperlink', // 'EditHyperlink',
// 'AddContainer', 'AddContainer',
// 'AddTable', // 'AddTable',
// 'AddShape', 'AddShape'
// 'AddImage', // 'AddImage',
// 'AddOther' // 'AddOther'
] ]
@ -220,12 +220,12 @@ require([
// 'presentationeditor/mobile/app/controller/edit/EditParagraph' // 'presentationeditor/mobile/app/controller/edit/EditParagraph'
// 'presentationeditor/mobile/app/controller/edit/EditTable', // 'presentationeditor/mobile/app/controller/edit/EditTable',
// 'presentationeditor/mobile/app/controller/edit/EditImage', // 'presentationeditor/mobile/app/controller/edit/EditImage',
'presentationeditor/mobile/app/controller/edit/EditShape' 'presentationeditor/mobile/app/controller/edit/EditShape',
// 'presentationeditor/mobile/app/controller/edit/EditChart', // 'presentationeditor/mobile/app/controller/edit/EditChart',
// 'presentationeditor/mobile/app/controller/edit/EditHyperlink', // 'presentationeditor/mobile/app/controller/edit/EditHyperlink',
// 'presentationeditor/mobile/app/controller/add/AddContainer', 'presentationeditor/mobile/app/controller/add/AddContainer',
// 'presentationeditor/mobile/app/controller/add/AddTable', // 'presentationeditor/mobile/app/controller/add/AddTable',
// 'presentationeditor/mobile/app/controller/add/AddShape', 'presentationeditor/mobile/app/controller/add/AddShape'
// 'presentationeditor/mobile/app/controller/add/AddImage', // 'presentationeditor/mobile/app/controller/add/AddImage',
// 'presentationeditor/mobile/app/controller/add/AddOther' // 'presentationeditor/mobile/app/controller/add/AddOther'
], function() { ], function() {

View file

@ -118,7 +118,9 @@ define([
addViews.push({ addViews.push({
caption: me.textShape, caption: me.textShape,
id: 'add-shape', id: 'add-shape',
layout: me._dummyEditController().getLayout() layout: PE.getController('AddShape')
.getView('AddShape')
.rootLayout()
}); });
addViews.push({ addViews.push({

View file

@ -0,0 +1,232 @@
/*
*
* (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
*
*/
/**
* AddShape.js
* Presentation Editor
*
* Created by Julia Radzhabova on 11/28/16
* Copyright (c) 2016 Ascensio System SIA. All rights reserved.
*
*/
define([
'core',
'presentationeditor/mobile/app/view/add/AddShape'
], function (core) {
'use strict';
PE.Controllers.AddShape = Backbone.Controller.extend(_.extend((function() {
var _styles = [];
return {
models: [],
collections: [],
views: [
'AddShape'
],
initialize: function () {
Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this));
// Fill shapes
function randomColor() {
return '#' + Math.floor(Math.random()*16777215).toString(16);
}
_styles = [
{
title: 'Text',
thumb: 'shape-01.svg',
type: 'textRect'
},
{
title: 'Line',
thumb: 'shape-02.svg',
type: 'line'
},
{
title: 'Line with arrow',
thumb: 'shape-03.svg',
type: 'lineWithArrow'
},
{
title: 'Line with two arrows',
thumb: 'shape-04.svg',
type: 'lineWithTwoArrows'
},
{
title: 'Rect',
thumb: 'shape-05.svg',
type: 'rect'
},
{
title: 'Hexagon',
thumb: 'shape-06.svg',
type: 'hexagon'
},
{
title: 'Round rect',
thumb: 'shape-07.svg',
type: 'roundRect'
},
{
title: 'Ellipse',
thumb: 'shape-08.svg',
type: 'ellipse'
},
{
title: 'Triangle',
thumb: 'shape-09.svg',
type: 'triangle'
},
{
title: 'Triangle',
thumb: 'shape-10.svg',
type: 'rtTriangle'
},
{
title: 'Trapezoid',
thumb: 'shape-11.svg',
type: 'trapezoid'
},
{
title: 'Diamond',
thumb: 'shape-12.svg',
type: 'diamond'
},
{
title: 'Right arrow',
thumb: 'shape-13.svg',
type: 'rightArrow'
},
{
title: 'Left-right arrow',
thumb: 'shape-14.svg',
type: 'leftRightArrow'
},
{
title: 'Left arrow callout',
thumb: 'shape-15.svg',
type: 'leftArrowCallout'
},
{
title: 'Right arrow callout',
thumb: 'shape-16.svg',
type: 'rightArrowCallout'
},
{
title: 'Flow chart off page connector',
thumb: 'shape-17.svg',
type: 'flowChartOffpageConnector'
},
{
title: 'Heart',
thumb: 'shape-18.svg',
type: 'heart'
},
{
title: 'Math minus',
thumb: 'shape-19.svg',
type: 'mathMinus'
},
{
title: 'Math plus',
thumb: 'shape-20.svg',
type: 'mathPlus'
},
{
title: 'Parallelogram',
thumb: 'shape-21.svg',
type: 'parallelogram'
},
{
title: 'Wedge rect callout',
thumb: 'shape-22.svg',
type: 'wedgeRectCallout'
},
{
title: 'Wedge ellipse callout',
thumb: 'shape-23.svg',
type: 'wedgeEllipseCallout'
},
{
title: 'Cloud callout',
thumb: 'shape-24.svg',
type: 'cloudCallout'
}
];
var elementsInRow = 4;
var groups = _.chain(_styles).groupBy(function(element, index){
return Math.floor(index/elementsInRow);
}).toArray().value();
Common.SharedSettings.set('shapes', groups);
Common.NotificationCenter.trigger('shapes:load', groups);
},
setApi: function (api) {
this.api = api;
},
onLaunch: function () {
this.createView('AddShape').render();
},
initEvents: function () {
var me = this;
$('#add-shape li').single('click', _.buffered(me.onShapeClick, 100, me));
},
onShapeClick: function (e) {
var me = this,
$target = $(e.currentTarget);
if ($target && me.api) {
me.api.AddShapeOnCurrentPage($target.data('type'));
}
PE.getController('AddContainer').hideModal();
},
// Public
getStyles: function () {
return _styles;
}
}
})(), PE.Controllers.AddShape || {}))
});

View file

@ -0,0 +1,14 @@
<!-- Root view -->
<div id="add-shapes-root">
<div class="page-content dataview shapes">
<% _.each(shapes, function(row) { %>
<ul class="row">
<% _.each(row, function(shape) { %>
<li data-type="<%= shape.type %>">
<div class="thumb" style="-webkit-mask-image:url('../mobile/resources/img/shapes/<%= shape.thumb %>')"></div>
</li>
<% }); %>
</ul>
<% }); %>
</div>
</div>

View file

@ -0,0 +1,98 @@
/*
*
* (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
*
*/
/**
* AddShape.js
* Presentation Editor
*
* Created by Julia Radzhabova on 11/28/16
* Copyright (c) 2016 Ascensio System SIA. All rights reserved.
*
*/
define([
'text!presentationeditor/mobile/app/template/AddShape.template',
'jquery',
'underscore',
'backbone'
], function (addTemplate, $, _, Backbone) {
'use strict';
PE.Views.AddShape = Backbone.View.extend(_.extend((function() {
// private
return {
// el: '.view-main',
template: _.template(addTemplate),
events: {
},
initialize: function () {
Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this));
Common.NotificationCenter.on('shapes:load', _.bind(this.render, this));
},
initEvents: function () {
this.initControls();
},
// Render layout
render: function () {
this.layout = $('<div/>').append(this.template({
android : Common.SharedSettings.get('android'),
phone : Common.SharedSettings.get('phone'),
shapes : Common.SharedSettings.get('shapes')
}));
return this;
},
rootLayout: function () {
if (this.layout) {
return this.layout
.find('#add-shapes-root')
.html();
}
return '';
},
initControls: function () {
//
}
}
})(), PE.Views.AddShape || {}))
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long