[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 () {
Common.NotificationCenter.on('editcontainer:show', _.bind(this.initEvents, this));
this.addListeners({
'EditHyperlink': {
'page:show' : this.onPageShow
}
});
},
setApi: function (api) {
@ -84,33 +90,60 @@ define([
me.initSettings();
},
onPageShow: function (view, pageId) {
var me = this;
initSettings: function () {
var me = this,
cellInfo = me.api.asc_getCellInfo(),
linkInfo = cellInfo.asc_getHyperlink(),
sheetCount = me.api.asc_getWorksheetsCount(),
isLock = cellInfo.asc_getFlags().asc_getLockText(),
me.initSettings(pageId);
},
initSettings: function (pageId) {
var me = this;
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,
sheets = [];
template = '';
while (++i < sheetCount) {
if (!me.api.asc_isWorksheetHidden(i)) {
sheets.push(Common.Utils.String.format('<option value="{0}">{1}</option>', me.api.asc_getWorksheetName(i), me.api.asc_getWorksheetName(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 {
$('#edit-link-sheet select').html(sheets.join(''));
var cellInfo = me.api.asc_getCellInfo(),
linkInfo = cellInfo.asc_getHyperlink(),
isLock = cellInfo.asc_getFlags().asc_getLockText();
$('#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);
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');
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);
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());
@ -131,33 +164,31 @@ define([
$('#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
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-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-edit').toggleClass('disabled', _.isEmpty(requireInput.val()));
$('#edit-link-type .item-after').text((this.linkType == Asc.c_oAscHyperlinkType.RangeLink) ? this.textInternalLink : this.textExternalLink);
},
onEdit: function () {
var me = this,
linkProps = new Asc.asc_CHyperlink(),
defaultDisplay = "",
$type = $('#edit-link-type select'),
$sheet = $('#edit-link-sheet select'),
sheet = this.linkSheet,
$range = $('#edit-link-range input'),
$link = $('#edit-link-link input'),
$display = $('#edit-link-display input'),
$tip = $('#edit-link-tip input'),
type = parseInt($type.val());
type = parseInt(this.linkType);
linkProps.asc_setType(type);
@ -173,9 +204,9 @@ define([
return;
}
linkProps.asc_setSheet($sheet.val());
linkProps.asc_setSheet(sheet);
linkProps.asc_setRange(range);
defaultDisplay = $sheet.val() + '!' + range;
defaultDisplay = sheet + '!' + range;
} else {
var url = $link.val().replace(/^\s+|\s+$/g,'');

View file

@ -3,11 +3,7 @@
<div class="list-block">
<ul>
<li>
<a id="edit-link-type" class="item-link smart-select" data-back-on-select="true">
<select name="edit-link-type">
<option value="1" selected><%= scope.textExternalLink %></option>
<option value="2"><%= scope.textInternalLink %></option>
</select>
<a id="edit-link-type" class="item-link" data-page="#edit-link-type-view">
<div class="item-content">
<div class="item-inner">
<div class="item-title"><%= scope.textLinkType %></div>
@ -17,8 +13,7 @@
</a>
</li>
<li>
<a id="edit-link-sheet" class="item-link smart-select" data-back-on-select="true">
<select name="edit-link-sheet"></select>
<a id="edit-link-sheet" class="item-link" data-page="#edit-link-sheet-view">
<div class="item-content">
<div class="item-inner">
<div class="item-title"><%= scope.textSheet %></div>
@ -93,3 +88,61 @@
<% } %>
</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>

View file

@ -64,11 +64,14 @@ define([
_editCellController = SSE.getController('EditHyperlink');
Common.NotificationCenter.on('editcontainer:show', _.bind(this.initEvents, this));
this.on('page:show', _.bind(this.updateItemHandlers, this));
},
initEvents: function () {
var me = this;
me.updateItemHandlers();
Common.Utils.addScrollIfNeed('#edit-link .pages', '#edit-link .page');
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',
textExternalLink: 'External Link',
textInternalLink: 'Internal Data Range',