diff --git a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js
index 65440c651..233adfac9 100644
--- a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js
+++ b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js
@@ -78,7 +78,7 @@ define([
'
',
'',
'',
'',
'',
@@ -98,6 +98,7 @@ define([
this.options.tpl = _.template(this.template)(this.options);
this.api = this.options.api;
this._originalProps = null;
+ this.linkType = c_oHyperlinkType.WebLink;
Common.UI.Window.prototype.initialize.call(this, this.options);
},
@@ -153,6 +154,12 @@ define([
maxLength : Asc.c_oAscMaxTooltipLength
});
+ me.internalList = new Common.UI.TreeView({
+ el: $('#id-dlg-hyperlink-list'),
+ store: new Common.UI.TreeViewStore(),
+ enableKeyEvents: false
+ });
+
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
$window.find('input').on('keypress', _.bind(this.onKeyPress, this));
me.externalPanel = $window.find('#id-external-link');
@@ -162,6 +169,81 @@ define([
ShowHideElem: function(value) {
this.externalPanel.toggleClass('hidden', value !== c_oHyperlinkType.WebLink);
this.internalPanel.toggleClass('hidden', value !== c_oHyperlinkType.InternalLink);
+ var store = this.internalList.store;
+ if (value==c_oHyperlinkType.InternalLink && store.length<1) {
+ var anchors = this.api.asc_GetHyperlinkAnchors(),
+ count = anchors.length,
+ prev_level = 0,
+ header_level = 0,
+ arr = [];
+ arr.push(new Common.UI.TreeViewModel({
+ name : this.txtBeginning,
+ level: 0,
+ index: 0,
+ hasParent: false,
+ isEmptyItem: false,
+ isNotHeader: true,
+ hasSubItems: false
+ }));
+ arr.push(new Common.UI.TreeViewModel({
+ name : this.txtHeadings,
+ level: 0,
+ index: 1,
+ hasParent: false,
+ isEmptyItem: false,
+ isNotHeader: false,
+ hasSubItems: false
+ }));
+
+ for (var i=0; iprev_level)
+ arr[arr.length-1].set('hasSubItems', true);
+ if (level<=header_level) {
+ header_level = level;
+ hasParent = false;
+ }
+ arr.push(new Common.UI.TreeViewModel({
+ name : anchor.asc_GetHeadingText(),
+ level: level,
+ index: i+2,
+ hasParent: hasParent
+ }));
+ prev_level = level;
+ }
+ }
+ arr.push(new Common.UI.TreeViewModel({
+ name : this.txtBookmarks,
+ level: 0,
+ index: arr.length,
+ hasParent: false,
+ isEmptyItem: false,
+ isNotHeader: false,
+ hasSubItems: false
+ }));
+
+ prev_level = 0;
+ for (var i=0; i0) {
+ props.put_Bookmark(rec[0].get('name'));
+ if (rec[0].get('index')==0)
+ props.put_TopOfDocument();
+ }
+ }
if (!me.inputDisplay.isDisabled() && ( this.isTextChanged || _.isEmpty(me.inputDisplay.getValue()))) {
if (_.isEmpty(me.inputDisplay.getValue()))
@@ -245,13 +350,17 @@ define([
_handleInput: function(state) {
if (this.options.handler) {
if (state == 'ok') {
- var checkurl = this.inputUrl.checkValidate(),
- checkdisp = this.inputDisplay.checkValidate();
- if (checkurl !== true) {
- this.inputUrl.cmpEl.find('input').focus();
- return;
+ if (this.linkType == c_oHyperlinkType.WebLink) {
+ if (this.inputUrl.checkValidate() !== true) {
+ this.inputUrl.cmpEl.find('input').focus();
+ return;
+ }
+ } else {
+ var rec = this.internalList.getSelectedRec();
+ if (rec.length<1 || rec[0].get('level')==0 && rec[0].get('index')>0)
+ return;
}
- if (checkdisp !== true) {
+ if (this.inputDisplay.checkValidate() !== true) {
this.inputDisplay.cmpEl.find('input').focus();
return;
}
@@ -273,6 +382,9 @@ define([
textDefault: 'Selected text',
textTitle: 'Hyperlink Settings',
textExternal: 'External Link',
- textInternal: 'Place in Document'
+ textInternal: 'Place in Document',
+ txtBeginning: 'Beginning of document',
+ txtHeadings: 'Headings',
+ txtBookmarks: 'Bookmarks'
}, DE.Views.HyperlinkSettingsDialog || {}))
});
\ No newline at end of file