2016-12-06 07:30:33 +00:00
|
|
|
/*
|
|
|
|
*
|
2019-01-17 13:05:03 +00:00
|
|
|
* (c) Copyright Ascensio System SIA 2010-2019
|
2016-12-06 07:30:33 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
2019-01-17 13:00:34 +00:00
|
|
|
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
|
|
|
* street, Riga, Latvia, EU, LV-1050.
|
2016-12-06 07:30:33 +00:00
|
|
|
*
|
|
|
|
* 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
|
2018-03-01 12:16:38 +00:00
|
|
|
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
|
2016-12-06 07:30:33 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
define([
|
|
|
|
'core',
|
|
|
|
'presentationeditor/mobile/app/view/add/AddLink'
|
|
|
|
], function (core) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
PE.Controllers.AddLink = Backbone.Controller.extend(_.extend((function() {
|
2016-12-06 14:38:35 +00:00
|
|
|
var c_oHyperlinkType = {
|
2016-12-06 07:30:33 +00:00
|
|
|
InternalLink:0,
|
|
|
|
WebLink: 1
|
|
|
|
},
|
|
|
|
c_oSlideLink = {
|
|
|
|
Next: 0,
|
|
|
|
Previouse: 1,
|
|
|
|
Last: 2,
|
|
|
|
First: 3,
|
|
|
|
Num: 4
|
|
|
|
},
|
2017-04-11 11:05:56 +00:00
|
|
|
_slidesCount = 0;
|
2016-12-06 07:30:33 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
2020-02-10 09:35:59 +00:00
|
|
|
|
|
|
|
this._linkType = c_oHyperlinkType.WebLink;
|
|
|
|
this._slideLink = 0;
|
|
|
|
this._slideNum = 0;
|
2016-12-06 07:30:33 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
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') {
|
2020-02-10 09:35:59 +00:00
|
|
|
this._linkType = c_oHyperlinkType.WebLink;
|
|
|
|
this._slideLink = this._slideNum = 0;
|
2016-12-06 07:30:33 +00:00
|
|
|
var text = this.api.can_AddHyperlink();
|
|
|
|
if (text !== false) {
|
2016-12-06 14:38:35 +00:00
|
|
|
$('#add-link-display input').val((text !== null) ? text : this.textDefault);
|
|
|
|
$('#add-link-display').toggleClass('disabled', text === null);
|
2016-12-06 07:30:33 +00:00
|
|
|
}
|
2016-12-06 14:38:35 +00:00
|
|
|
|
2016-12-06 07:30:33 +00:00
|
|
|
this.initSettings();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
initSettings: function (pageId) {
|
|
|
|
var me = this;
|
|
|
|
|
|
|
|
if (pageId == '#addlink-type') {
|
2020-02-10 09:35:59 +00:00
|
|
|
$('#page-addlink-type input').val([this._linkType]);
|
2016-12-06 07:30:33 +00:00
|
|
|
} else if (pageId == '#addlink-slidenumber') {
|
|
|
|
_slidesCount = me.api.getCountPages();
|
2020-02-10 09:35:59 +00:00
|
|
|
$('#page-addlink-slidenumber input').val([this._slideLink]);
|
|
|
|
$('#addlink-slide-number .item-after label').text(this._slideNum+1);
|
2016-12-06 14:38:35 +00:00
|
|
|
} else {
|
2020-02-10 09:35:59 +00:00
|
|
|
$('#add-link-type .item-after').text((this._linkType==c_oHyperlinkType.WebLink) ? me.textExternalLink : me.textInternalLink);
|
|
|
|
$('#add-link-url')[(this._linkType==c_oHyperlinkType.WebLink) ? 'show' : 'hide']();
|
|
|
|
$('#add-link-number')[(this._linkType==c_oHyperlinkType.WebLink) ? 'hide' : 'show']();
|
2016-12-06 07:30:33 +00:00
|
|
|
|
2020-02-10 09:35:59 +00:00
|
|
|
if (this._linkType==c_oHyperlinkType.WebLink) {
|
2016-12-13 13:32:06 +00:00
|
|
|
$('#add-link-url input[type=url]').single('input', _.bind(function(e) {
|
|
|
|
$('#add-link-insert').toggleClass('disabled', _.isEmpty($('#add-link-url input').val()));
|
|
|
|
}, this));
|
2016-12-06 07:30:33 +00:00
|
|
|
_.delay(function () {
|
2016-12-13 13:32:06 +00:00
|
|
|
$('#add-link-url input[type=url]').focus();
|
2016-12-06 07:30:33 +00:00
|
|
|
}, 1000);
|
|
|
|
} else {
|
|
|
|
var slidename = '';
|
2020-02-10 09:35:59 +00:00
|
|
|
switch (this._slideLink) {
|
2016-12-06 07:30:33 +00:00
|
|
|
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:
|
2020-02-10 09:35:59 +00:00
|
|
|
slidename = me.textSlide + ' ' + (this._slideNum+1);
|
2016-12-06 07:30:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
$('#add-link-number .item-after').text(slidename);
|
|
|
|
}
|
|
|
|
|
2020-02-10 09:35:59 +00:00
|
|
|
$('#add-link-insert').toggleClass('disabled', (this._linkType==c_oHyperlinkType.WebLink) && _.isEmpty($('#add-link-url input').val()));
|
2016-12-06 07:30:33 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
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));
|
|
|
|
me.initSettings(pageId);
|
|
|
|
},
|
|
|
|
|
|
|
|
// Handlers
|
|
|
|
|
|
|
|
onInsertLink: function (e) {
|
|
|
|
PE.getController('AddContainer').hideModal();
|
|
|
|
},
|
|
|
|
|
|
|
|
onLinkType: function (e) {
|
|
|
|
var $target = $(e.currentTarget).find('input');
|
|
|
|
|
|
|
|
if ($target && this.api) {
|
2020-02-10 09:35:59 +00:00
|
|
|
this._linkType = parseFloat($target.prop('value'));
|
2016-12-06 07:30:33 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onSlideLink: function (e) {
|
|
|
|
var $target = $(e.currentTarget).find('input');
|
|
|
|
|
|
|
|
if ($target && this.api) {
|
2020-02-10 09:35:59 +00:00
|
|
|
this._slideLink = parseFloat($target.prop('value'));
|
2016-12-06 07:30:33 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onSlideNumber: function (e) {
|
|
|
|
var $button = $(e.currentTarget),
|
2020-02-10 09:35:59 +00:00
|
|
|
slide = this._slideNum;
|
2016-12-06 07:30:33 +00:00
|
|
|
|
|
|
|
if ($button.hasClass('decrement')) {
|
|
|
|
slide = Math.max(0, --slide);
|
|
|
|
} else {
|
|
|
|
slide = Math.min(_slidesCount-1, ++slide);
|
|
|
|
}
|
2020-02-10 09:35:59 +00:00
|
|
|
this._slideNum = slide;
|
2016-12-06 07:30:33 +00:00
|
|
|
$('#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 || {}))
|
|
|
|
});
|