[SSE mobile] Fix bug 37715

This commit is contained in:
Julia Svinareva 2020-01-23 09:31:23 +03:00 committed by Alexey Golubev
parent e35a0ab5b5
commit 596683d63e
3 changed files with 190 additions and 60 deletions

View file

@ -61,6 +61,12 @@ define([
initialize: function () { initialize: function () {
Common.NotificationCenter.on('editcontainer:show', _.bind(this.initEvents, this)); Common.NotificationCenter.on('editcontainer:show', _.bind(this.initEvents, this));
this.addListeners({
'EditHyperlink': {
'page:show' : this.onPageShow
}
});
}, },
setApi: function (api) { setApi: function (api) {
@ -84,80 +90,105 @@ define([
me.initSettings(); me.initSettings();
}, },
onPageShow: function (view, pageId) {
var me = this;
initSettings: function () { me.initSettings(pageId);
var me = this, },
cellInfo = me.api.asc_getCellInfo(),
linkInfo = cellInfo.asc_getHyperlink(),
sheetCount = me.api.asc_getWorksheetsCount(),
isLock = cellInfo.asc_getFlags().asc_getLockText(),
i = -1,
sheets = [];
while (++i < sheetCount) { initSettings: function (pageId) {
if (!me.api.asc_isWorksheetHidden(i)) { var me = this;
sheets.push(Common.Utils.String.format('<option value="{0}">{1}</option>', me.api.asc_getWorksheetName(i), me.api.asc_getWorksheetName(i)));
if ('#edit-link-type-view' == pageId) {
var $radioLinkType = $('.page[data-page=edit-link-type-view]').find('input:radio[name=link-type]');
$radioLinkType.val([me.linkType]);
$radioLinkType.single('change', _.bind(me.onTypeChange, me));
} else if ('#edit-link-sheet-view' == pageId) {
var sheetCount = me.api.asc_getWorksheetsCount(),
i = -1,
template = '';
while (++i < sheetCount) {
if (!me.api.asc_isWorksheetHidden(i)) {
template += '<li>' +
'<label class="label-radio item-content">' +
'<input type="radio" name="link-sheet" value="' + me.api.asc_getWorksheetName(i) + '">';
if (Common.SharedSettings.get('android')) {
template += '<div class="item-media"><i class="icon icon-form-radio"></i></div>';
}
template += '<div class="item-inner">' +
'<div class="item-title">' + me.api.asc_getWorksheetName(i) + '</div>' +
'</div>' +
'</label>' +
'</li>';
}
} }
$('.page[data-page="edit-link-sheet-view"] .page-content .list-block ul').html(_.template([template].join('')));
var $radioLinkSheet = $('.page[data-page=edit-link-sheet-view]').find('input:radio[name=link-sheet]');
$radioLinkSheet.val([me.linkSheet]);
$radioLinkSheet.single('change', _.bind(function (e) {
me.linkSheet = $(e.currentTarget).prop('value');
$('#edit-link-sheet .item-after').text(me.linkSheet);
}, me));
} else {
var cellInfo = me.api.asc_getCellInfo(),
linkInfo = cellInfo.asc_getHyperlink(),
isLock = cellInfo.asc_getFlags().asc_getLockText();
me.linkType = linkInfo.asc_getType();
$('#edit-link-type .item-after').text((me.linkType == Asc.c_oAscHyperlinkType.RangeLink) ? me.textInternalLink : me.textExternalLink);
$('#edit-link-sheet, #edit-link-range').css('display', (linkInfo.asc_getType() == Asc.c_oAscHyperlinkType.RangeLink) ? 'block' : 'none');
$('#edit-link-link').css('display', (linkInfo.asc_getType() != Asc.c_oAscHyperlinkType.RangeLink) ? 'block' : 'none');
me.currentSheet = me.api.asc_getWorksheetName(me.api.asc_getActiveWorksheetIndex());
me.linkSheet = (linkInfo.asc_getType() == Asc.c_oAscHyperlinkType.RangeLink) ? linkInfo.asc_getSheet() : me.currentSheet;
$('#edit-link-sheet .item-after').text(me.linkSheet);
$('#edit-link-range input').val(linkInfo.asc_getRange());
$('#edit-link-link input').val(linkInfo.asc_getHyperlinkUrl() ? linkInfo.asc_getHyperlinkUrl().replace(new RegExp(" ", 'g'), "%20") : '');
$('#edit-link-display input').val(isLock ? me.textDefault : linkInfo.asc_getText());
$('#edit-link-display input').toggleClass('disabled', isLock);
$('#edit-link-tip input').val(linkInfo.asc_getTooltip());
var focusInput = ((linkInfo.asc_getType() == Asc.c_oAscHyperlinkType.RangeLink) ? $('#edit-link-range input') : $('#edit-link-link input'));
$('#edit-link-edit').toggleClass('disabled', _.isEmpty(focusInput.val()));
$('#edit-link-link input, #edit-link-range input').single('input', _.bind(function (e) {
$('#edit-link-edit').toggleClass('disabled', _.isEmpty($(e.currentTarget).val()));
}, me));
$('#edit-link-edit').single('click', _.bind(me.onEdit, me));
$('#edit-link-remove').single('click', _.bind(me.onRemove, me));
} }
$('#edit-link-sheet select').html(sheets.join(''));
$('#edit-link-type select').val(linkInfo.asc_getType());
$('#edit-link-type .item-after').text((linkInfo.asc_getType() == Asc.c_oAscHyperlinkType.RangeLink) ? me.textInternalLink : me.textExternalLink);
$('#edit-link-sheet, #edit-link-range').css('display', (linkInfo.asc_getType() == Asc.c_oAscHyperlinkType.RangeLink) ? 'block' : 'none');
$('#edit-link-link').css('display', (linkInfo.asc_getType() != Asc.c_oAscHyperlinkType.RangeLink) ? 'block' : 'none');
var currentSheet = me.api.asc_getWorksheetName(me.api.asc_getActiveWorksheetIndex());
$('#edit-link-sheet select').val((linkInfo.asc_getType() == Asc.c_oAscHyperlinkType.RangeLink) ? linkInfo.asc_getSheet(): currentSheet);
$('#edit-link-sheet .item-after').text((linkInfo.asc_getType() == Asc.c_oAscHyperlinkType.RangeLink) ? linkInfo.asc_getSheet(): currentSheet);
$('#edit-link-range input').val(linkInfo.asc_getRange());
$('#edit-link-link input').val(linkInfo.asc_getHyperlinkUrl() ? linkInfo.asc_getHyperlinkUrl().replace(new RegExp(" ",'g'), "%20") : '');
$('#edit-link-display input').val(isLock ? me.textDefault : linkInfo.asc_getText());
$('#edit-link-display input').toggleClass('disabled', isLock);
$('#edit-link-tip input').val(linkInfo.asc_getTooltip());
var focusInput = ((linkInfo.asc_getType() == Asc.c_oAscHyperlinkType.RangeLink) ? $('#edit-link-range input') : $('#edit-link-link input'));
$('#edit-link-edit').toggleClass('disabled', _.isEmpty(focusInput.val()));
$('#edit-link-link input, #edit-link-range input').single('input', _.bind(function(e) {
$('#edit-link-edit').toggleClass('disabled', _.isEmpty($(e.currentTarget).val()));
}, me));
$('#edit-link-edit').single('click', _.bind(me.onEdit, me));
$('#edit-link-remove').single('click', _.bind(me.onRemove, me));
$('#edit-link-type select').single('change', _.bind(me.onTypeChange, me));
}, },
// Handlers // Handlers
onTypeChange: function (e) { onTypeChange: function (e) {
var val = parseInt($(e.currentTarget).val()); var val = parseInt($(e.currentTarget).prop('value'));
this.linkType = val;
$('#edit-link-sheet, #edit-link-range').css('display', (val == Asc.c_oAscHyperlinkType.RangeLink) ? 'block' : 'none'); $('#edit-link-sheet, #edit-link-range').css('display', (val == Asc.c_oAscHyperlinkType.RangeLink) ? 'block' : 'none');
$('#edit-link-link').css('display', (val != Asc.c_oAscHyperlinkType.RangeLink) ? 'block' : 'none'); $('#edit-link-link').css('display', (val != Asc.c_oAscHyperlinkType.RangeLink) ? 'block' : 'none');
var requireInput = (val == Asc.c_oAscHyperlinkType.RangeLink) ? $('#edit-link-range input') : $('#edit-link-link input'); $('#edit-link-type .item-after').text((this.linkType == Asc.c_oAscHyperlinkType.RangeLink) ? this.textInternalLink : this.textExternalLink);
$('#edit-link-edit').toggleClass('disabled', _.isEmpty(requireInput.val()));
}, },
onEdit: function () { onEdit: function () {
var me = this, var me = this,
linkProps = new Asc.asc_CHyperlink(), linkProps = new Asc.asc_CHyperlink(),
defaultDisplay = "", defaultDisplay = "",
$type = $('#edit-link-type select'), sheet = this.linkSheet,
$sheet = $('#edit-link-sheet select'),
$range = $('#edit-link-range input'), $range = $('#edit-link-range input'),
$link = $('#edit-link-link input'), $link = $('#edit-link-link input'),
$display = $('#edit-link-display input'), $display = $('#edit-link-display input'),
$tip = $('#edit-link-tip input'), $tip = $('#edit-link-tip input'),
type = parseInt($type.val()); type = parseInt(this.linkType);
linkProps.asc_setType(type); linkProps.asc_setType(type);
@ -173,9 +204,9 @@ define([
return; return;
} }
linkProps.asc_setSheet($sheet.val()); linkProps.asc_setSheet(sheet);
linkProps.asc_setRange(range); linkProps.asc_setRange(range);
defaultDisplay = $sheet.val() + '!' + range; defaultDisplay = sheet + '!' + range;
} else { } else {
var url = $link.val().replace(/^\s+|\s+$/g,''); var url = $link.val().replace(/^\s+|\s+$/g,'');

View file

@ -3,11 +3,7 @@
<div class="list-block"> <div class="list-block">
<ul> <ul>
<li> <li>
<a id="edit-link-type" class="item-link smart-select" data-back-on-select="true"> <a id="edit-link-type" class="item-link" data-page="#edit-link-type-view">
<select name="edit-link-type">
<option value="1" selected><%= scope.textExternalLink %></option>
<option value="2"><%= scope.textInternalLink %></option>
</select>
<div class="item-content"> <div class="item-content">
<div class="item-inner"> <div class="item-inner">
<div class="item-title"><%= scope.textLinkType %></div> <div class="item-title"><%= scope.textLinkType %></div>
@ -17,8 +13,7 @@
</a> </a>
</li> </li>
<li> <li>
<a id="edit-link-sheet" class="item-link smart-select" data-back-on-select="true"> <a id="edit-link-sheet" class="item-link" data-page="#edit-link-sheet-view">
<select name="edit-link-sheet"></select>
<div class="item-content"> <div class="item-content">
<div class="item-inner"> <div class="item-inner">
<div class="item-title"><%= scope.textSheet %></div> <div class="item-title"><%= scope.textSheet %></div>
@ -92,4 +87,62 @@
</ul> </ul>
<% } %> <% } %>
</div> </div>
</div>
<div id="edit-link-type-view">
<div class="navbar">
<div class="navbar-inner" data-page="edit-link-type-view">
<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 class="right"><% if (phone) { %><a href="#" class="link icon-only close-picker"><i class="icon icon-expand-down"></i></a><% } %></div>
</div>
</div>
<div class="page" data-page="edit-link-type-view">
<div class="page-content">
<div class="list-block">
<ul>
<li>
<label class="label-radio item-content">
<input type="radio" name="link-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="link-type" 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.textInternalLink %></div>
</div>
</label>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="edit-link-sheet-view">
<div class="navbar">
<div class="navbar-inner" data-page="edit-link-sheet-view">
<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.textSheet %></div>
<div class="right"><% if (phone) { %><a href="#" class="link icon-only close-picker"><i class="icon icon-expand-down"></i></a><% } %></div>
</div>
</div>
<div class="page" data-page="edit-link-sheet-view">
<div class="page-content">
<div class="list-block">
<ul>
</ul>
</div>
</div>
</div>
</div> </div>

View file

@ -64,11 +64,14 @@ define([
_editCellController = SSE.getController('EditHyperlink'); _editCellController = SSE.getController('EditHyperlink');
Common.NotificationCenter.on('editcontainer:show', _.bind(this.initEvents, this)); Common.NotificationCenter.on('editcontainer:show', _.bind(this.initEvents, this));
this.on('page:show', _.bind(this.updateItemHandlers, this));
}, },
initEvents: function () { initEvents: function () {
var me = this; var me = this;
me.updateItemHandlers();
Common.Utils.addScrollIfNeed('#edit-link .pages', '#edit-link .page'); Common.Utils.addScrollIfNeed('#edit-link .pages', '#edit-link .page');
me.initControls(); me.initControls();
}, },
@ -98,6 +101,49 @@ define([
// //
}, },
showPage: function (templateId, suspendEvent) {
var rootView = SSE.getController('EditContainer').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()
});
if (suspendEvent !== true) {
this.fireEvent('page:show', [this, templateId]);
}
}
},
onItemClick: function (e) {
var $target = $(e.currentTarget),
page = $target.data('page');
if (page && page.length > 0 ) {
this.showPage(page);
}
},
updateItemHandlers: function () {
var selectorsDynamicPage = [
'#edit-link'
].map(function (selector) {
return selector + ' a.item-link[data-page]';
}).join(', ');
Common.Utils.addScrollIfNeed('.page[data-page=edit-link-type]', '.page[data-page=edit-border-style] .page-content');
Common.Utils.addScrollIfNeed('.page[data-page=edit-link-sheet]', '.page[data-page=edit-cell-format] .page-content');
$(selectorsDynamicPage).single('click', _.bind(this.onItemClick, this));
},
textBack: 'Back', textBack: 'Back',
textExternalLink: 'External Link', textExternalLink: 'External Link',
textInternalLink: 'Internal Data Range', textInternalLink: 'Internal Data Range',