[PE] Change adding internal link

This commit is contained in:
Julia Radzhabova 2020-03-06 15:52:48 +03:00
parent 0598d3a61a
commit b1269c3677

View file

@ -50,9 +50,8 @@ var c_oHyperlinkType = {
define([
'common/main/lib/util/utils',
'common/main/lib/component/InputField',
'common/main/lib/component/ComboBox',
'common/main/lib/component/RadioBox',
'common/main/lib/component/Window'
'common/main/lib/component/Window',
'common/main/lib/component/TreeView'
], function () { 'use strict';
PE.Views.HyperlinkSettingsDialog = Common.UI.Window.extend(_.extend({
@ -70,7 +69,7 @@ define([
}, options || {});
this.template = [
'<div class="box" style="height: 250px;">',
'<div class="box" style="height: 263px;">',
'<div class="input-row" style="margin-bottom: 10px;">',
'<button type="button" class="btn btn-text-default auto" id="id-dlg-hyperlink-external" style="border-top-right-radius: 0;border-bottom-right-radius: 0;">', this.textExternalLink,'</button>',
'<button type="button" class="btn btn-text-default auto" id="id-dlg-hyperlink-internal" style="border-top-left-radius: 0;border-bottom-left-radius: 0;">', this.textInternalLink,'</button>',
@ -81,13 +80,11 @@ define([
'</div>',
'<div id="id-dlg-hyperlink-url" class="input-row" style="margin-bottom: 5px;"></div>',
'</div>',
'<div id="id-internal-link" class="hidden" style="margin-top: 15px;">',
'<div id="id-dlg-hyperlink-radio-next" style="display: block;margin-bottom: 5px;"></div>',
'<div id="id-dlg-hyperlink-radio-prev" style="display: block;margin-bottom: 5px;"></div>',
'<div id="id-dlg-hyperlink-radio-first" style="display: block;margin-bottom: 5px;"></div>',
'<div id="id-dlg-hyperlink-radio-last" style="display: block;margin-bottom: 5px;"></div>',
'<div id="id-dlg-hyperlink-radio-slide" style="display: inline-block;margin-bottom: 5px;margin-right: 10px;"></div>',
'<div id="id-dlg-hyperlink-slide" style="display: inline-block;margin-bottom: 10px;"></div>',
'<div id="id-internal-link" class="hidden">',
'<div class="input-row">',
'<label>' + this.strLinkTo + ' *</label>',
'</div>',
'<div id="id-dlg-hyperlink-list" style="width:100%; height: 115px;border: 1px solid #cfcfcf;"></div>',
'</div>',
'<div class="input-row">',
'<label>' + this.strDisplay + '</label>',
@ -142,6 +139,9 @@ define([
return (urltype>0) ? true : me.txtNotUrl;
}
});
me.inputUrl._input.on('input', function (e) {
me.btnOk.setDisabled($.trim($(e.target).val())=='');
});
me.inputDisplay = new Common.UI.InputField({
el : $('#id-dlg-hyperlink-display'),
@ -158,59 +158,72 @@ define([
maxLength : Asc.c_oAscMaxTooltipLength
});
me.radioNext = new Common.UI.RadioBox({
el: $('#id-dlg-hyperlink-radio-next'),
labelText: this.txtNext,
name: 'asc-radio-slide',
checked: true
});
// me.radioNext = new Common.UI.RadioBox({
// el: $('#id-dlg-hyperlink-radio-next'),
// labelText: this.txtNext,
// name: 'asc-radio-slide',
// checked: true
// });
//
// me.radioPrev = new Common.UI.RadioBox({
// el: $('#id-dlg-hyperlink-radio-prev'),
// labelText: this.txtPrev,
// name: 'asc-radio-slide'
// });
//
// me.radioFirst = new Common.UI.RadioBox({
// el: $('#id-dlg-hyperlink-radio-first'),
// labelText: this.txtFirst,
// name: 'asc-radio-slide'
// });
//
// me.radioLast = new Common.UI.RadioBox({
// el: $('#id-dlg-hyperlink-radio-last'),
// labelText: this.txtLast,
// name: 'asc-radio-slide'
// });
//
// me.radioSlide = new Common.UI.RadioBox({
// el: $('#id-dlg-hyperlink-radio-slide'),
// labelText: this.txtSlide,
// name: 'asc-radio-slide'
// });
//
// me.cmbSlides = new Common.UI.ComboBox({
// el: $('#id-dlg-hyperlink-slide'),
// cls: 'input-group-nr',
// style: 'width: 50px;',
// menuStyle: 'min-width: 50px; max-height: 200px;',
// data: this.slides
// });
// me.cmbSlides.setValue(0);
// me.cmbSlides.on('selected', _.bind(function(combo, record) {
// me.radioSlide.setValue(true);
// }, me))
// .on('changed:after', _.bind(function(combo, record) {
// me.radioSlide.setValue(true);
// if (record.value>me.slides.length)
// combo.setValue(me.slides.length-1);
// else if (record.value<1)
// combo.setValue(0);
// else
// combo.setValue(record.value-1);
// }, me));
me.radioPrev = new Common.UI.RadioBox({
el: $('#id-dlg-hyperlink-radio-prev'),
labelText: this.txtPrev,
name: 'asc-radio-slide'
me.internalList = new Common.UI.TreeView({
el: $('#id-dlg-hyperlink-list'),
store: new Common.UI.TreeViewStore(),
enableKeyEvents: true
});
me.internalList.on('item:select', _.bind(this.onSelectItem, this));
me.radioFirst = new Common.UI.RadioBox({
el: $('#id-dlg-hyperlink-radio-first'),
labelText: this.txtFirst,
name: 'asc-radio-slide'
me.btnOk = new Common.UI.Button({
el: $window.find('.primary'),
disabled: true
});
me.radioLast = new Common.UI.RadioBox({
el: $('#id-dlg-hyperlink-radio-last'),
labelText: this.txtLast,
name: 'asc-radio-slide'
});
me.radioSlide = new Common.UI.RadioBox({
el: $('#id-dlg-hyperlink-radio-slide'),
labelText: this.txtSlide,
name: 'asc-radio-slide'
});
me.cmbSlides = new Common.UI.ComboBox({
el: $('#id-dlg-hyperlink-slide'),
cls: 'input-group-nr',
style: 'width: 50px;',
menuStyle: 'min-width: 50px; max-height: 200px;',
data: this.slides
});
me.cmbSlides.setValue(0);
me.cmbSlides.on('selected', _.bind(function(combo, record) {
me.radioSlide.setValue(true);
}, me))
.on('changed:after', _.bind(function(combo, record) {
me.radioSlide.setValue(true);
if (record.value>me.slides.length)
combo.setValue(me.slides.length-1);
else if (record.value<1)
combo.setValue(0);
else
combo.setValue(record.value-1);
}, me));
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
me.internalList.on('entervalue', _.bind(me.onPrimary, me));
me.externalPanel = $window.find('#id-external-link');
me.internalPanel = $window.find('#id-internal-link');
},
@ -249,21 +262,10 @@ define([
var url = "ppaction://hlink";
var tip = '';
var txttip = me.inputTip.getValue();
if (this.radioSlide.getValue()) {
url = url + "sldjumpslide" + (this.cmbSlides.getValue());
tip = this.txtSlide + ' ' + (this.cmbSlides.getValue()+1);
} else if (this.radioFirst.getValue()) {
url = url + "showjump?jump=firstslide";
tip = this.txtFirst;
} else if (this.radioLast.getValue()) {
url = url + "showjump?jump=lastslide";
tip = this.txtLast;
} else if (this.radioNext.getValue()) {
url = url + "showjump?jump=nextslide";
tip = this.txtNext;
} else if (this.radioPrev.getValue()) {
url = url + "showjump?jump=previousslide";
tip = this.txtPrev;
var rec = this.internalList.getSelectedRec();
if (rec) {
url = url + rec.get('type');
tip = rec.get('tiptext');
}
props.put_Value( url );
props.put_ToolTip(_.isEmpty(txttip) ? tip : txttip);
@ -323,6 +325,11 @@ define([
ShowHideElem: function(value) {
this.externalPanel.toggleClass('hidden', value !== c_oHyperlinkType.WebLink);
this.internalPanel.toggleClass('hidden', value !== c_oHyperlinkType.InternalLink);
if (value==c_oHyperlinkType.InternalLink) {
var rec = this.internalList.getSelectedRec();
this.btnOk.setDisabled(!rec || rec.get('index')==4);
} else
this.btnOk.setDisabled($.trim(this.inputUrl.getValue())=='');
},
onLinkTypeClick: function(type, btn, event) {
@ -333,35 +340,85 @@ define([
if (url===null || url===undefined || url=='' )
return c_oHyperlinkType.WebLink;
var store = this.internalList.store;
var indAction = url.indexOf("ppaction://hlink");
if (0 == indAction)
{
if (url == "ppaction://hlinkshowjump?jump=firstslide")
{
this.radioFirst.setValue(true);
}
else if (url == "ppaction://hlinkshowjump?jump=lastslide")
{
this.radioLast.setValue(true);
}
else if (url == "ppaction://hlinkshowjump?jump=nextslide")
{
this.radioNext.setValue(true);
}
else if (url == "ppaction://hlinkshowjump?jump=previousslide")
{
this.radioPrev.setValue(true);
}
else
{
this.radioSlide.setValue(true);
var mask = "ppaction://hlinksldjumpslide";
var indSlide = url.indexOf(mask);
if (0 == indSlide)
{
var slideNum = parseInt(url.substring(mask.length));
if (slideNum >= 0 && slideNum < this.slides.length)
this.cmbSlides.setValue(slideNum);
if (store.length<1) {
var arr = [], i = 0;
arr.push(new Common.UI.TreeViewModel({
name : this.txtFirst,
level: 0,
index: i++,
hasParent: false,
isEmptyItem: false,
isNotHeader: true,
hasSubItems: false,
type: "showjump?jump=firstslide",
tiptext: this.txtFirst,
selected: url == "ppaction://hlinkshowjump?jump=firstslide"
}));
arr.push(new Common.UI.TreeViewModel({
name : this.txtLast,
level: 0,
index: i++,
hasParent: false,
isEmptyItem: false,
isNotHeader: true,
hasSubItems: false,
type: "showjump?jump=lastslide",
tiptext: this.txtLast,
selected: url == "ppaction://hlinkshowjump?jump=lastslide"
}));
arr.push(new Common.UI.TreeViewModel({
name : this.txtNext,
level: 0,
index: i++,
hasParent: false,
isEmptyItem: false,
isNotHeader: true,
hasSubItems: false,
type: "showjump?jump=nextslide",
tiptext: this.txtNext,
selected: url == "ppaction://hlinkshowjump?jump=nextslide"
}));
arr.push(new Common.UI.TreeViewModel({
name : this.txtPrev,
level: 0,
index: i++,
hasParent: false,
isEmptyItem: false,
isNotHeader: true,
hasSubItems: false,
type: "showjump?jump=previousslide",
tiptext: this.txtPrev,
selected: url == "ppaction://hlinkshowjump?jump=previousslide"
}));
arr.push(new Common.UI.TreeViewModel({
name : this.textSlides,
level: 0,
index: i++,
hasParent: false,
isEmptyItem: false,
isNotHeader: true,
hasSubItems: this.api.getCountPages()>0
}));
var mask = "ppaction://hlinksldjumpslide",
indSlide = url.indexOf(mask),
slideNum = (0 == indSlide) ? parseInt(url.substring(mask.length)) : -1;
for (var i=0; i<this.api.getCountPages(); i++) {
arr.push(new Common.UI.TreeViewModel({
name : this.txtSlide + ' ' + (i+1),
level: 1,
index: arr.length,
hasParent: false,
isEmptyItem: false,
isNotHeader: true,
hasSubItems: false,
type: 'sldjumpslide' + i,
tiptext: this.txtSlide + ' ' + (i+1),
selected: i==slideNum
}));
}
}
return c_oHyperlinkType.InternalLink;
@ -371,8 +428,12 @@ define([
}
},
onSelectItem: function(picker, item, record, e){
this.btnOk.setDisabled(record.get('index')==4);
},
textTitle: 'Hyperlink Settings',
textInternalLink: 'Slide In This Presentation',
textInternalLink: 'Place in Document',
textExternalLink: 'External Link',
textEmptyLink: 'Enter link here',
textEmptyDesc: 'Enter caption here',
@ -388,6 +449,7 @@ define([
txtPrev: 'Previous Slide',
txtFirst: 'First Slide',
txtLast: 'Last Slide',
textDefault: 'Selected text'
textDefault: 'Selected text',
textSlides: 'Slides'
}, PE.Views.HyperlinkSettingsDialog || {}))
});