[SSE mobile] AddLink page moved to separate class

This commit is contained in:
Maxim Kadushkin 2017-01-11 13:50:34 +03:00
parent cc8843b75d
commit 64c1b76f2c
7 changed files with 576 additions and 320 deletions

View file

@ -136,6 +136,7 @@ require([
,'AddShape'
// ,'AddImage'
,'AddOther'
,'AddLink'
]
});
@ -207,6 +208,7 @@ require([
,'spreadsheeteditor/mobile/app/controller/add/AddShape'
// ,'spreadsheeteditor/mobile/app/controller/add/AddImage'
,'spreadsheeteditor/mobile/app/controller/add/AddOther'
,'spreadsheeteditor/mobile/app/controller/add/AddLink'
], function() {
app.start();
});

View file

@ -0,0 +1,223 @@
/*
*
* (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
*
* Created by Maxim.Kadushkin on 1/10/2017
* Copyright (c) 2016 Ascensio System SIA. All rights reserved.
*
*/
define([
'core',
'spreadsheeteditor/mobile/app/view/add/AddLink'
], function (core) {
'use strict';
SSE.Controllers.AddLink = Backbone.Controller.extend(_.extend((function() {
var cfgLink;
// Handlers
function onInsertLink (args) {
var link = new Asc.asc_CHyperlink();
if ( args.type == 'ext' ) {
var url = args.url,
urltype = this.api.asc_getUrlType($.trim(url)),
isEmail = (urltype == 2);
if (urltype < 1) {
uiApp.alert(this.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')," ");
link.asc_setType(Asc.c_oAscHyperlinkType.WebLink);
link.asc_setHyperlinkUrl(url);
display = url;
} else {
if ( !/^[A-Z]+[1-9]\d*:[A-Z]+[1-9]\d*$/.test(args.url) ||
!/^[A-Z]+[1-9]\d*$/.test(args.url) )
{
uiApp.alert(this.textInvalidRange);
return;
}
link.asc_setType(Asc.c_oAscHyperlinkType.RangeLink);
link.asc_setSheet(args.sheet);
link.asc_setRange(args.url);
var display = args.sheet + '!' + args.url;
}
link.asc_setText(args.text == null ? null : !!args.text ? args.text : display);
link.asc_setTooltip(args.tooltip);
this.api.asc_insertHyperlink(link);
SSE.getController('AddContainer').hideModal();
}
function onChangePanel (view, pageId) {
var me = this;
if (pageId == '#addother-change-linktype') {
view.optionLinkType( me.optsLink.type );
}
}
function onChangeLinkType (view, type) {
cfgLink.type = type;
view.optionLinkType( cfgLink.type, 'caption' );
}
function onChangeLinkSheet (view, index) {
}
function applyLocked(view) {
var _view = view || this.getView();
var cell = this.api.asc_getCellInfo(),
celltype = cell.asc_getFlags().asc_getSelectionType();
var allowinternal = (celltype!==Asc.c_oAscSelectionType.RangeImage && celltype!==Asc.c_oAscSelectionType.RangeShape &&
celltype!==Asc.c_oAscSelectionType.RangeShapeText && celltype!==Asc.c_oAscSelectionType.RangeChart &&
celltype!==Asc.c_oAscSelectionType.RangeChartText);
_view.optionDisplayText(cell.asc_getFlags().asc_getLockText() ? 'locked' : cell.asc_getText());
_view.optionAllowInternal(allowinternal);
allowinternal && _view.optionLinkType( cfgLink.type );
}
return {
models: [],
collections: [],
views: [
'AddLink'
],
initialize: function () {
Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this));
this.addListeners({
'AddLink': {
'panel:change' : onChangePanel.bind(this)
, 'link:insert': onInsertLink.bind(this)
, 'link:changetype': onChangeLinkType.bind(this)
, 'link:changesheet': onChangeLinkSheet.bind(this)
}
});
},
setApi: function (api) {
this.api = api;
},
onLaunch: function () {
this.createView('AddLink').render();
},
getView: function (name) {
return Backbone.Controller.prototype.getView.call(this, name ? name: 'AddLink');
},
initEvents: function (opts) {
var me = this;
var wsc = me.api.asc_getWorksheetsCount(), items = null;
var aws = me.api.asc_getActiveWorksheetIndex();
if (wsc > 0) {
items = [];
while ( !(--wsc < 0) ) {
if ( !this.api.asc_isWorksheetHidden(wsc) ) {
items.unshift({
value: wsc,
caption: me.api.asc_getWorksheetName(wsc),
active: wsc==aws
});
}
}
}
cfgLink = {
type: 'ext',
sheets: items
};
// uiApp.addView('#add-link', {
// dynamicNavbar: true
// });
_.defer(function () {
var view = me.getView().acceptWorksheets( items );
if ( opts ) {
if ( opts.panel === 'hyperlink' ) {
view.showPanel();
applyLocked.call(me, view);
}
}
});
},
showPage: function (navbar) {
var me = this;
var view = this.getView();
var rootView = SSE.getController('AddContainer').rootView;
view.showPage(rootView, navbar);
var cell = me.api.asc_getCellInfo(),
celltype = cell.asc_getFlags().asc_getSelectionType();
var allowinternal = (celltype!==Asc.c_oAscSelectionType.RangeImage && celltype!==Asc.c_oAscSelectionType.RangeShape &&
celltype!==Asc.c_oAscSelectionType.RangeShapeText && celltype!==Asc.c_oAscSelectionType.RangeChart &&
celltype!==Asc.c_oAscSelectionType.RangeChartText);
view.optionDisplayText(cell.asc_getFlags().asc_getLockText() ? 'locked' : cell.asc_getText());
view.optionAllowInternal(allowinternal);
allowinternal && view.optionLinkType( cfgLink.type );
view.fireEvent('page:show', [this, '#addlink']);
},
textInvalidRange : 'ERROR! Invalid cells range',
textEmptyImgUrl : 'You need to specify image URL.',
txtNotUrl : 'This field should be a URL in the format \"http://www.example.com\"'
}
})(), SSE.Controllers.AddLink || {}))
});

View file

@ -59,12 +59,9 @@ define([
this.addListeners({
'AddOther': {
'page:show' : this.onPageShow
, 'link:insert': this.onInsertLink
, 'image:insert': this.onInsertImage
, 'insert:sort': this.onInsertSort
, 'insert:filter': this.onInsertFilter
, 'link:changetype': this.onChangeLinkType
, 'link:changesheet': this.onChangeLinkSheet
}
});
},
@ -82,113 +79,19 @@ define([
},
initEvents: function () {
var me = this;
var wc = me.api.asc_getWorksheetsCount(), items = null;
if (wc > 0) {
items = [];
while ( !(--wc < 0) ) {
if ( !this.api.asc_isWorksheetHidden(wc) ) {
items.unshift({
value: wc,
caption: me.api.asc_getWorksheetName(wc)
});
}
}
}
this.optsLink = {
type: 'ext',
sheets: items
};
_.defer(function () {
me.getView('AddOther')
.acceptWorksheets( items )
.setActiveWorksheet( me.api.asc_getActiveWorksheetIndex(),
me.api.asc_getWorksheetName(me.api.asc_getActiveWorksheetIndex()) );
});
},
onPageShow: function (view, pageId) {
var me = this;
if (pageId == '#addother-link') {
var cell = me.api.asc_getCellInfo(),
celltype = cell.asc_getFlags().asc_getSelectionType();
var allowinternal = (celltype!==Asc.c_oAscSelectionType.RangeImage && celltype!==Asc.c_oAscSelectionType.RangeShape &&
celltype!==Asc.c_oAscSelectionType.RangeShapeText && celltype!==Asc.c_oAscSelectionType.RangeChart &&
celltype!==Asc.c_oAscSelectionType.RangeChartText);
view.optionDisplayText(cell.asc_getFlags().asc_getLockText() ? 'locked' : cell.asc_getText());
view.optionAllowInternal(allowinternal);
allowinternal && view.optionLinkType( this.optsLink.type );
} else
if (pageId == '#addother-sort') {
var filterInfo = this.api.asc_getCellInfo().asc_getAutoFilterInfo();
var filterInfo = me.api.asc_getCellInfo().asc_getAutoFilterInfo();
view.optionAutofilter( filterInfo ? filterInfo.asc_getIsAutoFilter() : null)
} else
if (pageId == '#addother-change-linktype') {
view.optionLinkType( this.optsLink.type );
}
},
// Handlers
onInsertLink: function (args) {
var link = new Asc.asc_CHyperlink();
if ( args.type == 'ext' ) {
var url = args.url,
urltype = this.api.asc_getUrlType($.trim(url)),
isEmail = (urltype == 2);
if (urltype < 1) {
uiApp.alert(this.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')," ");
link.asc_setType(Asc.c_oAscHyperlinkType.WebLink);
link.asc_setHyperlinkUrl(url);
display = url;
} else {
if ( !/^[A-Z]+[1-9]\d*:[A-Z]+[1-9]\d*$/.test(args.url) ||
!/^[A-Z]+[1-9]\d*$/.test(args.url) )
{
uiApp.alert(this.textInvalidRange);
return;
}
link.asc_setType(Asc.c_oAscHyperlinkType.RangeLink);
link.asc_setSheet(args.sheet);
link.asc_setRange(args.url);
var display = args.sheet + '!' + args.url;
}
link.asc_setText(args.text == null ? null : !!args.text ? args.text : display);
link.asc_setTooltip(args.tooltip);
this.api.asc_insertHyperlink(link);
SSE.getController('AddContainer').hideModal();
},
onChangeLinkType: function (view, type) {
this.optsLink.type = type;
view.optionLinkType( this.optsLink.type, 'caption' );
},
onChangeLinkSheet: function (view, index) {
},
onInsertImage: function (args) {
SSE.getController('AddContainer').hideModal();

View file

@ -0,0 +1,94 @@
<!-- Link view -->
<div id="addlink-root-view">
<div class="page" data-page="add-link">
<div class="page-content">
<div class="list-block">
<ul>
<li>
<a id="add-link-type" class="item-link smart-select">
<select name="linktype">
<option value="ext"><%= scope.textExternalLink %></option>
<option value="int"><%= scope.textInternalLink %></option>
</select>
<div class="item-content">
<div class="item-inner">
<div class="item-title label"><%= scope.textLinkType %></div>
<div class="item-after"><%= scope.textExternalLink %></div>
</div>
</div>
</a>
</li>
<li>
<a id="add-link-sheet" class="item-link smart-select">
<select>
</select>
<div class="item-content">
<div class="item-inner">
<div class="item-title label"><%= scope.textSheet %></div>
<div class="item-after">Sheet 5</div>
</div>
</div>
</a>
</li>
<div id="add-link-range" class="item-content">
<div class="item-inner">
<div class="item-title label"><%= scope.textRange %></div>
<div class="item-after">
<div class="item-input">
<input type="text" class="field right range" placeholder="<%= scope.textRequired %>">
</div>
</div>
</div>
</div>
<li>
<div id="add-link-url" class="item-content">
<div class="item-inner">
<div class="item-title label"><%= scope.textLink %></div>
<div class="item-after">
<div class="item-input">
<input type="url" class="field right" placeholder="<%= scope.textRequired %>">
</div>
</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-after">
<div class="item-input">
<input type="text" class="field right">
</div>
</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-after">
<div class="item-input">
<input type="text" class="field right">
</div>
</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>
</div>
</div>

View file

@ -42,101 +42,6 @@
</div>
</div>
<!-- Link view -->
<div id="addother-link">
<div class="page" data-page="addother-link">
<div class="page-content">
<div class="list-block">
<ul>
<li>
<a id="add-link-type" class="item-link smart-select">
<select name="linktype">
<option value="ext"><%= scope.textExternalLink %></option>
<option value="int"><%= scope.textInternalLink %></option>
</select>
<div class="item-content">
<div class="item-inner">
<div class="item-title label"><%= scope.textLinkType %></div>
<div class="item-after"><%= scope.textExternalLink %></div>
</div>
</div>
</a>
</li>
<li>
<a id="add-link-sheet" class="item-link smart-select">
<select>
</select>
<div class="item-content">
<div class="item-inner">
<div class="item-title label"><%= scope.textSheet %></div>
<div class="item-after">Sheet 5</div>
</div>
</div>
</a>
</li>
<div id="add-link-range" class="item-content">
<div class="item-inner">
<div class="item-title label"><%= scope.textRange %></div>
<div class="item-after">
<div class="item-input">
<input type="text" class="field right range" placeholder="<%= scope.textRequired %>">
</div>
</div>
</div>
</div>
<li>
<div id="add-link-url" class="item-content">
<div class="item-inner">
<div class="item-title label"><%= scope.textLink %></div>
<div class="item-after">
<div class="item-input">
<input type="url" class="field right" placeholder="<%= scope.textRequired %>">
</div>
</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-after">
<div class="item-input">
<input type="text" class="field right">
</div>
</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-after">
<div class="item-input">
<input type="text" class="field right">
</div>
</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>
</div>
</div>
<!-- Add image view -->
<div id="addother-insimage">
<div class="page" data-page="addother-image">
@ -175,7 +80,7 @@
<!-- Url view -->
<div id="addother-imagefromurl">
<div class="page" id="addimage-url" data-page="addimage-url">
<div class="page" id="addimage-fromurl" data-page="addimage-url">
<div class="page-content">
<div class="content-block-title"><%= scope.textAddress %></div>
<div class="list-block">

View file

@ -0,0 +1,252 @@
/*
*
* (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
*
* Created by Maxim.Kadushkin on 1/10/2017
* Copyright (c) 2016 Ascensio System SIA. All rights reserved.
*
*/
define([
'text!spreadsheeteditor/mobile/app/template/AddLink.template',
'backbone'
], function (addTemplate, Backbone) {
'use strict';
SSE.Views.AddLink = Backbone.View.extend(_.extend((function() {
// private
var cfgLink = {
type : 'ext',
internal : {}
};
var clickInsertLink = function (e) {
var $view = $('.settings');
var type = cfgLink.type;
var $text = $view.find('#add-link-display input');
this.fireEvent('link:insert', [{
type : type,
sheet : type == 'ext' ? undefined : cfgLink.internal.sheet.index,
url : $view.find(type == 'ext' ? '#add-link-url input' : '#add-link-range input').val(),
text : $text.is(':disabled') ? null : $text.val(),
tooltip : $view.find('#add-link-tip input').val()
}]);
};
function initEvents() {
var me = this;
var $view = $('.settings');
$('.page[data-page=add-link]').find('input[type=url], input.range')
.single('input', function(e) {
$view.find('#add-link-insert').toggleClass('disabled', _.isEmpty($(e.target).val()));
});
_.delay(function () {
$view.find('.page[data-page=addother-link] input[type=url]').focus();
}, 1000);
$view.find('#add-link-insert').single('click', _.buffered(clickInsertLink, 100, this));
$view.find('#add-link-type select').single('change', function (e) {
me.fireEvent('link:changetype', [me, $(e.currentTarget).val()]);
});
$view.find('#add-link-sheet select').single('change', function (e) {
var index = $(e.currentTarget).val(),
caption = $(e.currentTarget[e.currentTarget.selectedIndex]).text();
cfgLink.internal = { sheet: {index: index, caption: caption}};
// me.fireEvent('link:changesheet', [me, $(e.currentTarget).val()]);
}).val(cfgLink.internal.sheet.index);
}
return {
// el: '.view-main',
template: _.template(addTemplate),
events: {},
initialize: function () {
// Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this));
},
initEvents: function () {
var me = this;
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 () {
return this.layout ?
this.layout.find('#addlink-root-view').html() : '';
},
initControls: function () {
//
},
showPage: function (root, navbar) {
if (root && this.layout) {
var $content = this.layout;
// Android fix for navigation
if (Framework7.prototype.device.android) {
var html = $content.html() + navbar;
} else {
html = navbar + $content.html();
}
root.router.load({
content: html
});
initEvents.call(this);
}
},
showPanel: function () {
initEvents.call(this);
},
optionLinkType: function (type, opts) {
cfgLink.type = type;
var $view = $('.settings');
if ( !(opts == 'caption') ) {
$view.find('#add-link-type select').val(type);
$view.find('#add-link-type .item-after').html(
type == 'int' ? this.textInternalLink : this.textExternalLink );
}
var $btnInsertLink = $view.find('#add-link-insert');
if ( type == 'int' ) {
$view.find('#add-link-url').hide();
$view.find('#add-link-sheet').show()
.find('.item-after').html(cfgLink.internal.sheet.caption);
$view.find('#add-link-range').show();
$btnInsertLink.toggleClass('disabled', _.isEmpty($view.find('#add-link-range input').val()));
} else {
$view.find('#add-link-url').show();
$view.find('#add-link-sheet').hide();
$view.find('#add-link-range').hide();
$btnInsertLink.toggleClass('disabled', _.isEmpty($view.find('#add-link-url input').val()));
}
},
optionAllowInternal: function(allow) {
var $view = $('.settings');
if ( allow )
$view.find('#add-link-type').show();
else {
this.optionLinkType('ext');
$view.find('#add-link-type').hide();
}
},
optionDisplayText: function (text) {
var $view = $('.settings');
var disabled = text == 'locked';
disabled && (text = ' ');
$view.find('#add-link-display input').prop('disabled', disabled).val(text);
$view.find('#add-link-display .label').toggleClass('disabled', disabled);
},
acceptWorksheets: function (sheets) {
this.worksheets = sheets;
var tpl = '<% _.each(worksheets, function(item){ %>' +
'<option value="<%= item.value %>"><%= item.caption %></option>' +
'<% }) %>';
this.layout.find('#add-link-sheet select').html(
_.template(tpl, {
worksheets: sheets
})
);
var active = _.findWhere(sheets, {active:true});
if ( active )
this.setActiveWorksheet(active.value, active.caption);
return this;
},
setActiveWorksheet: function (index, caption) {
cfgLink.internal = { sheet: {index: index, caption: caption}};
var $view = $('.settings');
// $view.find('#add-link-sheet .item-after').html(this.link.internal.sheet.caption);
$view.find('#add-link-sheet select').val(index);
$view.find('#add-link-sheet .item-after').text(caption);
return this;
},
getTitle: function () {
return this.textAddLink;
},
textLink: 'Link',
textAddLink: 'Add Link',
textDisplay: 'Display',
textTip: 'Screen Tip',
textInsert: 'Insert',
textLinkSettings: 'Link Settings',
textAddress: 'Address',
textLinkType: 'Link Type',
textExternalLink: 'External Link',
textInternalLink: 'Internal Data Range',
textSheet: 'Sheet',
textRange: 'Range',
textRequired: 'Required'
}
})(), SSE.Views.AddLink || {}))
});

View file

@ -108,7 +108,6 @@ define([
$page.find('#add-other-link').single('click', _.bind(me.showInsertLink, me));
$page.find('#add-other-sort').single('click', _.bind(me.showSortPage, me));
this.link = {type:'ext', internal:{}};
me.initControls();
},
@ -170,29 +169,7 @@ define([
},
showInsertLink: function () {
this.showPage('#addother-link');
var me = this;
var $view = $('.settings');
$('.page[data-page=addother-link]').find('input[type=url], input.range')
.single('input', function(e) {
$view.find('#add-link-insert').toggleClass('disabled', _.isEmpty($(e.target).val()));
});
_.delay(function () {
$view.find('.page[data-page=addother-link] input[type=url]').focus();
}, 1000);
$view.find('#add-link-insert').single('click', _.buffered(this.clickInsertLink, 100, this));
$view.find('#add-link-type select').single('change', function (e) {
me.fireEvent('link:changetype', [me, $(e.currentTarget).val()]);
});
$view.find('#add-link-sheet select').single('change', function (e) {
var index = $(e.currentTarget).val(),
caption = $(e.currentTarget[e.currentTarget.selectedIndex]).text();
me.link.internal = { sheet: {index: index, caption: caption}};
me.fireEvent('link:changesheet', [me, $(e.currentTarget).val()]);
}).val(me.link.internal.sheet.index);
SSE.getController('AddLink').showPage(getNavigation.call(this, '#addlink'));
},
showSortPage: function (e) {
@ -207,20 +184,6 @@ define([
});
},
clickInsertLink: function (e) {
var $view = $('.settings');
var type = this.link.type;
var $text = $view.find('#add-link-display input');
this.fireEvent('link:insert', [{
type : type,
sheet : type == 'ext' ? undefined : this.link.internal.sheet.index,
url : $view.find(type == 'ext' ? '#add-link-url input' : '#add-link-range input').val(),
text : $text.is(':disabled') ? null : $text.val(),
tooltip : $view.find('#add-link-tip input').val()
}]);
},
showImageFromUrl: function () {
this.showPage('#addother-imagefromurl');
@ -233,7 +196,7 @@ define([
}, 100, me));
var $btnInsert = $('#addimage-insert');
$('#addimage-url input[type=url]').single('input', function (e) {
$('#addimage-fromurl input[type=url]').single('input', function (e) {
$btnInsert.toggleClass('disabled', _.isEmpty($(e.currentTarget).val()));
});
@ -244,102 +207,16 @@ define([
$('.settings #other-chb-insfilter input:checkbox').prop('checked', checked);
},
optionLinkType: function (type, opts) {
this.link.type = type;
var $view = $('.settings');
if ( !(opts == 'caption') ) {
$view.find('#add-link-type select').val(type);
$view.find('#add-link-type .item-after').html(
type == 'int' ? this.textInternalLink : this.textExternalLink );
}
var $btnInsertLink = $view.find('#add-link-insert');
if ( type == 'int' ) {
$view.find('#add-link-url').hide();
$view.find('#add-link-sheet').show()
.find('.item-after').html(this.link.internal.sheet.caption);
$view.find('#add-link-range').show();
$btnInsertLink.toggleClass('disabled', _.isEmpty($view.find('#add-link-range input').val()));
} else {
$view.find('#add-link-url').show();
$view.find('#add-link-sheet').hide();
$view.find('#add-link-range').hide();
$btnInsertLink.toggleClass('disabled', _.isEmpty($view.find('#add-link-url input').val()));
}
},
optionAllowInternal: function(allow) {
var $view = $('.settings');
if ( allow )
$view.find('#add-link-type').show();
else {
this.optionLinkType('ext');
$view.find('#add-link-type').hide();
}
},
optionDisplayText: function (text) {
var $view = $('.settings');
var disabled = text == 'locked';
disabled && (text = ' ');
$view.find('#add-link-display input').prop('disabled', disabled).val(text);
$view.find('#add-link-display .label').toggleClass('disabled', disabled);
},
acceptWorksheets: function (sheets) {
this.worksheets = sheets;
var tpl = '<% _.each(worksheets, function(item){ %>' +
'<option value="<%= item.value %>"><%= item.caption %></option>' +
'<% }) %>';
this.layout.find('#add-link-sheet select').html(
_.template(tpl, {
worksheets: sheets
})
);
return this;
},
setActiveWorksheet: function (index, caption) {
this.link.internal = { sheet: {index: index, caption: caption}};
var $view = $('.settings');
// $view.find('#add-link-sheet .item-after').html(this.link.internal.sheet.caption);
$view.find('#add-link-sheet select').val(index);
$view.find('#add-link-sheet .item-after').text(caption);
return this;
},
textInsertImage: 'Insert Image',
textSort: 'Sort and Filter',
textLink: 'Link',
textBack: 'Back',
textAddLink: 'Add Link',
textDisplay: 'Display',
textTip: 'Screen Tip',
textInsert: 'Insert',
textFromLibrary: 'Picture from Library',
textFromURL: 'Picture from URL',
textLinkSettings: 'Link Settings',
textAddress: 'Address',
textImageURL: 'Image URL',
textFilter: 'Filter',
textLinkType: 'Link Type',
textExternalLink: 'External Link',
textInternalLink: 'Internal Data Range',
textSheet: 'Sheet',
textRange: 'Range',
textRequired: 'Required'
textFilter: 'Filter'
}
})(), SSE.Views.AddOther || {}))
});