[PE mobile] Insert links.

This commit is contained in:
Julia Radzhabova 2016-12-06 10:30:33 +03:00
parent cc4addb2ff
commit f382936baf
9 changed files with 630 additions and 21 deletions

View file

@ -150,8 +150,8 @@ require([
'AddContainer',
'AddTable',
'AddShape',
'AddImage'
// 'AddOther'
'AddImage',
'AddLink'
]
});
@ -215,8 +215,8 @@ require([
'presentationeditor/mobile/app/controller/add/AddContainer',
'presentationeditor/mobile/app/controller/add/AddTable',
'presentationeditor/mobile/app/controller/add/AddShape',
'presentationeditor/mobile/app/controller/add/AddImage'
// 'presentationeditor/mobile/app/controller/add/AddOther'
'presentationeditor/mobile/app/controller/add/AddImage',
'presentationeditor/mobile/app/controller/add/AddLink'
], function() {
app.start();

View file

@ -161,8 +161,8 @@ require([
'AddContainer',
'AddTable',
'AddShape',
'AddImage'
// 'AddOther'
'AddImage',
'AddLink'
]
});
@ -226,8 +226,8 @@ require([
'presentationeditor/mobile/app/controller/add/AddContainer',
'presentationeditor/mobile/app/controller/add/AddTable',
'presentationeditor/mobile/app/controller/add/AddShape',
'presentationeditor/mobile/app/controller/add/AddImage'
// 'presentationeditor/mobile/app/controller/add/AddOther'
'presentationeditor/mobile/app/controller/add/AddImage',
'presentationeditor/mobile/app/controller/add/AddLink'
], function() {
app.start();
});

View file

@ -47,6 +47,7 @@ define([
PE.Controllers.AddContainer = Backbone.Controller.extend(_.extend((function() {
// private
var _canAddHyperlink = false;
return {
models: [],
@ -59,6 +60,7 @@ define([
setApi: function(api) {
this.api = api;
this.api.asc_registerCallback('asc_onCanAddHyperlink', _.bind(this.onApiCanAddHyperlink, this));
},
onLaunch: function() {
@ -133,11 +135,14 @@ define([
.rootLayout()
});
addViews.push({
caption: me.textOther,
id: 'add-other',
layout: me._dummyEditController().getLayout()
});
if (_canAddHyperlink)
addViews.push({
caption: me.textLink,
id: 'add-link',
layout: PE.getController('AddLink')
.getView('AddLink')
.rootLayout()
});
return addViews;
},
@ -259,6 +264,10 @@ define([
});
}
$('.container-add .tab').single('show', function (e) {
Common.NotificationCenter.trigger('addcategory:show', e);
});
if (isAndroid) {
$$('.view.add-root-view.navbar-through').removeClass('navbar-through').addClass('navbar-fixed');
$$('.view.add-root-view .navbar').prependTo('.view.add-root-view > .pages > .page');
@ -271,11 +280,15 @@ define([
Common.NotificationCenter.trigger('addcontainer:show');
},
onApiCanAddHyperlink: function(value) {
_canAddHyperlink = value;
},
textSlide: 'Slide',
textTable: 'Table',
textShape: 'Shape',
textImage: 'Image',
textOther: 'Other'
textLink: 'Link'
}
})(), PE.Controllers.AddContainer || {}))
});

View file

@ -0,0 +1,284 @@
/*
*
* (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
*
*/
/**
* AddLink.js
* Presentation Editor
*
* Created by Julia Radzhabova on 12/01/16
* Copyright (c) 2016 Ascensio System SIA. All rights reserved.
*
*/
define([
'core',
'presentationeditor/mobile/app/view/add/AddLink'
], function (core) {
'use strict';
PE.Controllers.AddLink = Backbone.Controller.extend(_.extend((function() {
var _linkObject = undefined,
c_oHyperlinkType = {
InternalLink:0,
WebLink: 1
},
c_oSlideLink = {
Next: 0,
Previouse: 1,
Last: 2,
First: 3,
Num: 4
},
_linkType = c_oHyperlinkType.WebLink,
_slideLink = 0,
_slideNum = 0,
_slidesCount = 0,
_isDisplayChanged = false;
return {
models: [],
collections: [],
views: [
'AddLink'
],
initialize: function () {
Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this));
Common.NotificationCenter.on('addcategory:show', _.bind(this.categoryShow, this));
this.addListeners({
'AddLink': {
'page:show' : this.onPageShow
}
});
var me = this;
uiApp.onPageBack('addlink-type addlink-slidenumber', function (page) {
me.initSettings();
});
},
setApi: function (api) {
var me = this;
me.api = api;
},
onLaunch: function () {
this.createView('AddLink').render();
},
initEvents: function () {
var me = this;
$('#add-link-insert').single('click', _.buffered(me.onInsertLink, 100, me));
},
categoryShow: function (e) {
var $target = $(e.currentTarget);
if ($target && $target.prop('id') === 'add-link') {
var text = this.api.can_AddHyperlink();
if (text !== false) {
_linkObject = new Asc.CHyperlinkProperty();
_linkObject.put_Text(text);
}
this.initSettings();
}
},
initSettings: function (pageId) {
var me = this;
if (pageId == '#addlink-type') {
$('#page-addlink-type input').val([_linkType]);
} else if (pageId == '#addlink-slidenumber') {
_slidesCount = me.api.getCountPages();
$('#page-addlink-slidenumber input').val([_slideLink]);
$('#addlink-slide-number .item-after label').text(_slideNum+1);
} else if (_linkObject) {
var text = _linkObject.get_Text();
$('#add-link-display input').val((text!==null) ? text : me.textDefault);
$('#add-link-display').toggleClass('disabled',text===null);
$('#add-link-type .item-after').text((_linkType==c_oHyperlinkType.WebLink) ? me.textExternalLink : me.textInternalLink);
$('#add-link-url')[(_linkType==c_oHyperlinkType.WebLink) ? 'show' : 'hide']();
$('#add-link-number')[(_linkType==c_oHyperlinkType.WebLink) ? 'hide' : 'show']();
if (_linkType==c_oHyperlinkType.WebLink) {
_.delay(function () {
$('.page[data-page=addlink-link] input[type=url]').focus();
}, 1000);
} else {
var slidename = '';
switch (_slideLink) {
case 0:
slidename = me.textNext;
break;
case 1:
slidename = me.textPrev;
break;
case 2:
slidename = me.textFirst;
break;
case 3:
slidename = me.textLast;
break;
case 4:
slidename = me.textSlide + ' ' + (_slideNum+1);
break;
}
$('#add-link-number .item-after').text(slidename);
}
$('#add-link-insert').toggleClass('disabled', (_linkType==c_oHyperlinkType.WebLink) && _.isEmpty($('#add-link-url input').val()));
}
},
onPageShow: function (view, pageId) {
var me = this;
$('#page-addlink-type li').single('click', _.buffered(me.onLinkType, 100, me));
$('#page-addlink-slidenumber li').single('click', _.buffered(me.onSlideLink, 100, me));
$('#addlink-slide-number .button').single('click',_.buffered(me.onSlideNumber, 100, me));
$('#add-link-display input[type="text"]').single('input', _.bind(function(e) {
_isDisplayChanged = true;
}, this));
me.initSettings(pageId);
},
// Handlers
onInsertLink: function (e) {
var me = this,
display = $('#add-link-display input').val(),
tip = $('#add-link-tip input').val(),
props = new Asc.CHyperlinkProperty(),
def_display = '';
if (_linkType==c_oHyperlinkType.WebLink) {
var url = $('#add-link-url input').val(),
urltype = me.api.asc_getUrlType($.trim(url)),
isEmail = (urltype == 2);
if (urltype < 1) {
uiApp.alert(me.txtNotUrl);
return;
}
url = url.replace(/^\s+|\s+$/g,'');
if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) )
url = (isEmail ? 'mailto:' : 'http://' ) + url;
url = url.replace(new RegExp("%20",'g')," ");
props.put_Value( url );
props.put_ToolTip(tip);
def_display = url;
} else {
var url = "ppaction://hlink";
var slidetip = '';
switch (_slideLink) {
case 0:
url = url + "showjump?jump=nextslide";
slidetip = this.textNext;
break;
case 1:
url = url + "showjump?jump=previousslide";
slidetip = this.textPrev;
break;
case 2:
url = url + "showjump?jump=firstslide";
slidetip = this.textFirst;
break;
case 3:
url = url + "showjump?jump=lastslide";
slidetip = this.textLast;
break;
case 4:
url = url + "sldjumpslide" + _slideNum;
slidetip = this.textSlide + ' ' + (_slideNum+1);
break;
}
props.put_Value( url );
props.put_ToolTip(_.isEmpty(tip) ? slidetip : tip);
def_display = slidetip;
}
if (!$('#add-link-display').hasClass('disabled') && (_isDisplayChanged || _.isEmpty(display))) {
props.put_Text(_.isEmpty(display) ? def_display : display);
} else
props.put_Text(null);
me.api.add_Hyperlink(props);
PE.getController('AddContainer').hideModal();
},
onLinkType: function (e) {
var $target = $(e.currentTarget).find('input');
if ($target && this.api) {
_linkType = parseFloat($target.prop('value'));
}
},
onSlideLink: function (e) {
var $target = $(e.currentTarget).find('input');
if ($target && this.api) {
_slideLink = parseFloat($target.prop('value'));
}
},
onSlideNumber: function (e) {
var $button = $(e.currentTarget),
slide = _slideNum;
if ($button.hasClass('decrement')) {
slide = Math.max(0, --slide);
} else {
slide = Math.min(_slidesCount-1, ++slide);
}
_slideNum = slide;
$('#addlink-slide-number .item-after label').text(slide+1);
},
txtNotUrl: 'This field should be a URL in the format \"http://www.example.com\"',
textDefault: 'Selected text',
textNext: 'Next Slide',
textPrev: 'Previous Slide',
textFirst: 'First Slide',
textLast: 'Last Slide',
textSlide: 'Slide',
textExternalLink: 'External Link',
textInternalLink: 'Slide in this Presentation'
}
})(), PE.Controllers.AddLink || {}))
});

View file

@ -108,11 +108,6 @@ define([
var me = this,
editors = [];
// TODO: Debug only
// editors.push(me._emptyEditController());
// return editors;
if (_settings.length < 0) {
editors.push(me._emptyEditController());
} else {

View file

@ -0,0 +1,171 @@
<!-- Root view -->
<div id="addlink-root-view">
<div class="list-block">
<ul>
<li>
<div id="add-link-type" class="item-content item-link">
<div class="item-inner">
<div class="item-title"><%= scope.textLinkType %></div>
<div class="item-after"><%= scope.textExternalLink %></div>
</div>
</div>
</li>
<li>
<div id="add-link-url" class="item-content">
<div class="item-inner">
<div class="item-title label"><%= scope.textLink %></div>
<div class="item-input">
<input type="url" placeholder="<%= scope.textLink %>">
</div>
</div>
</div>
</li>
<li>
<div id="add-link-number" class="item-content item-link">
<div class="item-inner">
<div class="item-title label"><%= scope.textLinkSlide %></div>
<div class="item-after"><%= scope.textNext %></div>
</div>
</div>
</li>
<li>
<div id="add-link-display" class="item-content">
<div class="item-inner">
<div class="item-title label"><%= scope.textDisplay %></div>
<div class="item-input">
<input type="text" placeholder="<%= scope.textDisplay %>">
</div>
</div>
</div>
</li>
<li>
<div id="add-link-tip" class="item-content">
<div class="item-inner">
<div class="item-title label"><%= scope.textTip %></div>
<div class="item-input">
<input type="text" placeholder="<%= scope.textTip %>">
</div>
</div>
</div>
</li>
</ul>
</div>
<div class="list-block disabled" id="add-link-insert">
<% if (android) { %>
<a href="#" class="button button-fill button-raised" style="margin: 20px 16px;"><%= scope.textInsert %></a>
<% } else { %>
<ul>
<li>
<a href="#" class="list-button item-link"><%= scope.textInsert %></a>
</li>
</ul>
<% } %>
</div>
</div>
<!-- Link Type view -->
<div id="addlink-type">
<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><%= scope.textBack %></span><% } %></a></div>
<div class="center sliding"><%= scope.textLinkType %></div>
</div>
</div>
<div class="page" id="page-addlink-type" data-page="addlink-type">
<div class="page-content">
<div class="list-block">
<ul>
<li>
<label class="label-radio item-content">
<input type="radio" name="addlink-type" value="1">
<% if (android) { %><div class="item-media"><i class="icon icon-form-radio"></i></div><% } %>
<div class="item-inner">
<div class="item-title"><%= scope.textExternalLink %></div>
</div>
</label>
</li>
<li>
<label class="label-radio item-content">
<input type="radio" name="addlink-type" value="0">
<% if (android) { %><div class="item-media"><i class="icon icon-form-radio"></i></div><% } %>
<div class="item-inner">
<div class="item-title"><%= scope.textInternalLink %></div>
</div>
</label>
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Slide Number view -->
<div id="addlink-slidenumber">
<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><%= scope.textBack %></span><% } %></a></div>
<div class="center sliding"><%= scope.textLinkSlide %></div>
</div>
</div>
<div class="page" id="page-addlink-slidenumber" data-page="addlink-slidenumber">
<div class="page-content">
<div class="list-block">
<ul>
<li>
<label class="label-radio item-content">
<input type="radio" name="addlink-slide" value="0">
<% if (android) { %><div class="item-media"><i class="icon icon-form-radio"></i></div><% } %>
<div class="item-inner">
<div class="item-title"><%= scope.textNext %></div>
</div>
</label>
</li>
<li>
<label class="label-radio item-content">
<input type="radio" name="addlink-slide" value="1">
<% if (android) { %><div class="item-media"><i class="icon icon-form-radio"></i></div><% } %>
<div class="item-inner">
<div class="item-title"><%= scope.textPrev %></div>
</div>
</label>
</li>
<li>
<label class="label-radio item-content">
<input type="radio" name="addlink-slide" value="2">
<% if (android) { %><div class="item-media"><i class="icon icon-form-radio"></i></div><% } %>
<div class="item-inner">
<div class="item-title"><%= scope.textFirst %></div>
</div>
</label>
</li>
<li>
<label class="label-radio item-content">
<input type="radio" name="addlink-slide" value="3">
<% if (android) { %><div class="item-media"><i class="icon icon-form-radio"></i></div><% } %>
<div class="item-inner">
<div class="item-title"><%= scope.textLast %></div>
</div>
</label>
</li>
<li id="addlink-slide-number">
<label class="label-radio item-content">
<input type="radio" name="addlink-slide" value="4">
<% if (android) { %><div class="item-media"><i class="icon icon-form-radio"></i></div><% } %>
<div class="item-inner">
<div class="item-title"><%= scope.textNumber %></div>
<div class="item-after splitter">
<% if (!android) { %><label></label><% } %>
<p class="buttons-row">
<span class="button decrement"><% if (android) { %><i class="icon icon-expand-down"></i><% } else { %>-<% } %></span>
<% if (android) { %><label></label><% } %>
<span class="button increment"><% if (android) { %><i class="icon icon-expand-up"></i><% } else { %>+<% } %></span>
</p>
</div>
</div>
</label>
</li>
</ul>
</div>
</div>
</div>
</div>

View file

@ -180,7 +180,7 @@
<!-- Style options view -->
<div id="edit-table-style-options-view">
<div class="navbar">
<div class="navbar-inner" data-page="edit-table-style-options">
<div class="navbar-inner">
<div class="left sliding"><a href="#" class="back link"><i class="icon icon-back"></i><% if (!android) { %><span><%= scope.textBack %></span><% } %></a></div>
<div class="center sliding"><%= scope.textOptions %></div>
<div class="right"><% if (phone) { %><a href="#" class="link icon-only close-picker"><i class="icon icon-expand-down"></i></a><% } %></div>

View file

@ -259,7 +259,7 @@
</div>
<div class="list-block">
<ul>
<li id="letter-spacing" id="letter-spacing">
<li id="letter-spacing">
<div class="item-content">
<div class="item-inner">
<div class="item-title"><%= scope.textLetterSpacing %></div>

View file

@ -0,0 +1,146 @@
/*
*
* (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
*
*/
/**
* AddLink.js
* Presentation Editor
*
* Created by Julia Radzhabova on 12/01/16
* Copyright (c) 2016 Ascensio System SIA. All rights reserved.
*
*/
define([
'text!presentationeditor/mobile/app/template/AddLink.template',
'jquery',
'underscore',
'backbone'
], function (addTemplate, $, _, Backbone) {
'use strict';
PE.Views.AddLink = 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));
},
initEvents: function () {
var me = this;
$('#add-link-number').single('click', _.bind(me.showPageNumber, me));
$('#add-link-type').single('click', _.bind(me.showLinkType, me));
me.initControls();
},
// Render layout
render: function () {
this.layout = $('<div/>').append(this.template({
android : Common.SharedSettings.get('android'),
phone : Common.SharedSettings.get('phone'),
scope : this
}));
return this;
},
rootLayout: function () {
if (this.layout) {
return this.layout
.find('#addlink-root-view')
.html();
}
return '';
},
initControls: function () {
//
},
showPage: function (templateId) {
var rootView = PE.getController('AddContainer').rootView;
if (rootView && this.layout) {
var $content = this.layout.find(templateId);
// Android fix for navigation
if (Framework7.prototype.device.android) {
$content.find('.page').append($content.find('.navbar'));
}
rootView.router.load({
content: $content.html()
});
this.fireEvent('page:show', [this, templateId]);
}
},
showLinkType: function () {
this.showPage('#addlink-type');
},
showPageNumber: function () {
this.showPage('#addlink-slidenumber');
},
textLinkType: 'Link Type',
textExternalLink: 'External Link',
textInternalLink: 'Slide in this Presentation',
textLink: 'Link',
textLinkSlide: 'Link to',
textBack: 'Back',
textAddLink: 'Add Link',
textDisplay: 'Display',
textTip: 'Screen Tip',
textInsert: 'Insert',
textNext: 'Next Slide',
textPrev: 'Previous Slide',
textFirst: 'First Slide',
textLast: 'Last Slide',
textNumber: 'Slide Number'
}
})(), PE.Views.AddLink || {}))
});