From 64c1b76f2c3742fb214ea12f877b5daf7d1f7afe Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 11 Jan 2017 13:50:34 +0300 Subject: [PATCH] [SSE mobile] AddLink page moved to separate class --- apps/spreadsheeteditor/mobile/app-dev.js | 2 + .../mobile/app/controller/add/AddLink.js | 223 ++++++++++++++++ .../mobile/app/controller/add/AddOther.js | 99 +------ .../mobile/app/template/AddLink.template | 94 +++++++ .../mobile/app/template/AddOther.template | 97 +------ .../mobile/app/view/add/AddLink.js | 252 ++++++++++++++++++ .../mobile/app/view/add/AddOther.js | 129 +-------- 7 files changed, 576 insertions(+), 320 deletions(-) create mode 100644 apps/spreadsheeteditor/mobile/app/controller/add/AddLink.js create mode 100644 apps/spreadsheeteditor/mobile/app/template/AddLink.template create mode 100644 apps/spreadsheeteditor/mobile/app/view/add/AddLink.js diff --git a/apps/spreadsheeteditor/mobile/app-dev.js b/apps/spreadsheeteditor/mobile/app-dev.js index 0ecfd0618..e1b9f3798 100644 --- a/apps/spreadsheeteditor/mobile/app-dev.js +++ b/apps/spreadsheeteditor/mobile/app-dev.js @@ -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(); }); diff --git a/apps/spreadsheeteditor/mobile/app/controller/add/AddLink.js b/apps/spreadsheeteditor/mobile/app/controller/add/AddLink.js new file mode 100644 index 000000000..9eb2da3d6 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/app/controller/add/AddLink.js @@ -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 || {})) +}); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/app/controller/add/AddOther.js b/apps/spreadsheeteditor/mobile/app/controller/add/AddOther.js index 7037d1cb4..45c5cbc6c 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/add/AddOther.js +++ b/apps/spreadsheeteditor/mobile/app/controller/add/AddOther.js @@ -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(); diff --git a/apps/spreadsheeteditor/mobile/app/template/AddLink.template b/apps/spreadsheeteditor/mobile/app/template/AddLink.template new file mode 100644 index 000000000..5fe379ec6 --- /dev/null +++ b/apps/spreadsheeteditor/mobile/app/template/AddLink.template @@ -0,0 +1,94 @@ + + diff --git a/apps/spreadsheeteditor/mobile/app/template/AddOther.template b/apps/spreadsheeteditor/mobile/app/template/AddOther.template index 0b781d1e4..b3f467468 100644 --- a/apps/spreadsheeteditor/mobile/app/template/AddOther.template +++ b/apps/spreadsheeteditor/mobile/app/template/AddOther.template @@ -42,101 +42,6 @@ - - -
@@ -175,7 +80,7 @@
-
+
<%= scope.textAddress %>
diff --git a/apps/spreadsheeteditor/mobile/app/view/add/AddLink.js b/apps/spreadsheeteditor/mobile/app/view/add/AddLink.js new file mode 100644 index 000000000..cd2624dfe --- /dev/null +++ b/apps/spreadsheeteditor/mobile/app/view/add/AddLink.js @@ -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 = $('
').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){ %>' + + '' + + '<% }) %>'; + + 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 || {})) +}); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/app/view/add/AddOther.js b/apps/spreadsheeteditor/mobile/app/view/add/AddOther.js index fd11f0ef3..f06a4269c 100644 --- a/apps/spreadsheeteditor/mobile/app/view/add/AddOther.js +++ b/apps/spreadsheeteditor/mobile/app/view/add/AddOther.js @@ -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){ %>' + - '' + - '<% }) %>'; - - 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 || {})) }); \ No newline at end of file