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