Merge pull request #81 from ONLYOFFICE/feature/bookmarks
Feature/bookmarks
This commit is contained in:
commit
b402ac5b89
|
@ -36,12 +36,16 @@
|
|||
}
|
||||
|
||||
.footer {
|
||||
padding-top: 15px;
|
||||
padding: 15px 15px 0;
|
||||
|
||||
&.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&.right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
&.justify {
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
|
|
|
@ -512,6 +512,12 @@
|
|||
border: 1px solid @input-border;
|
||||
.border-radius(@border-radius-small);
|
||||
|
||||
&.auto {
|
||||
width: auto;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
&:hover:not(.disabled),
|
||||
.over:not(.disabled) {
|
||||
background-color: @secondary !important;
|
||||
|
@ -520,6 +526,7 @@
|
|||
&:active:not(.disabled),
|
||||
&.active:not(.disabled) {
|
||||
background-color: @primary !important;
|
||||
border-color: @primary;
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
|
|
@ -311,3 +311,4 @@
|
|||
.button-normal-icon(~'x-huge .btn-contents', 53, @toolbar-big-icon-size);
|
||||
.button-normal-icon(btn-controls, 54, @toolbar-big-icon-size);
|
||||
.button-normal-icon(~'x-huge .btn-select-pivot', 55, @toolbar-big-icon-size);
|
||||
.button-normal-icon(~'x-huge .btn-bookmarks', 56, @toolbar-big-icon-size);
|
||||
|
|
|
@ -44,7 +44,8 @@ define([
|
|||
'documenteditor/main/app/view/Links',
|
||||
'documenteditor/main/app/view/NoteSettingsDialog',
|
||||
'documenteditor/main/app/view/HyperlinkSettingsDialog',
|
||||
'documenteditor/main/app/view/TableOfContentsSettings'
|
||||
'documenteditor/main/app/view/TableOfContentsSettings',
|
||||
'documenteditor/main/app/view/BookmarksDialog'
|
||||
], function () {
|
||||
'use strict';
|
||||
|
||||
|
@ -64,7 +65,8 @@ define([
|
|||
'links:contents': this.onTableContents,
|
||||
'links:update': this.onTableContentsUpdate,
|
||||
'links:notes': this.onNotesClick,
|
||||
'links:hyperlink': this.onHyperlinkClick
|
||||
'links:hyperlink': this.onHyperlinkClick,
|
||||
'links:bookmarks': this.onBookmarksClick
|
||||
},
|
||||
'DocumentHolder': {
|
||||
'links:contents': this.onTableContents,
|
||||
|
@ -311,6 +313,19 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onBookmarksClick: function(btn) {
|
||||
var me = this;
|
||||
(new DE.Views.BookmarksDialog({
|
||||
api: me.api,
|
||||
props: me.api.asc_GetBookmarksManager(),
|
||||
handler: function (result, settings) {
|
||||
if (settings) {
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
||||
}
|
||||
})).show();
|
||||
},
|
||||
|
||||
onShowContentControlsActions: function(action, x, y) {
|
||||
var menu = (action==1) ? this.view.contentsUpdateMenu : this.view.contentsMenu,
|
||||
documentHolderView = this.getApplication().getController('DocumentHolder').documentHolder,
|
||||
|
|
|
@ -171,6 +171,7 @@
|
|||
<div class="separator long"></div>
|
||||
<div class="group">
|
||||
<span class="btn-slot text x-huge slot-inshyperlink"></span>
|
||||
<span class="btn-slot text x-huge" id="slot-btn-bookmarks"></span>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
|
303
apps/documenteditor/main/app/view/BookmarksDialog.js
Normal file
303
apps/documenteditor/main/app/view/BookmarksDialog.js
Normal file
|
@ -0,0 +1,303 @@
|
|||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* BookmarksDialog.js.js
|
||||
*
|
||||
* Created by Julia Radzhabova on 15.02.2018
|
||||
* Copyright (c) 2017 Ascensio System SIA. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
define([
|
||||
'common/main/lib/util/utils',
|
||||
'common/main/lib/component/ListView',
|
||||
'common/main/lib/component/InputField',
|
||||
'common/main/lib/component/Button',
|
||||
'common/main/lib/component/RadioBox',
|
||||
'common/main/lib/view/AdvancedSettingsWindow'
|
||||
], function () { 'use strict';
|
||||
|
||||
DE.Views.BookmarksDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({
|
||||
options: {
|
||||
contentWidth: 300,
|
||||
height: 360
|
||||
},
|
||||
|
||||
initialize : function(options) {
|
||||
var me = this;
|
||||
|
||||
_.extend(this.options, {
|
||||
title: this.textTitle,
|
||||
template: [
|
||||
'<div class="box" style="height:' + (me.options.height - 85) + 'px;">',
|
||||
'<div class="content-panel" style="padding: 0 5px;"><div class="inner-content">',
|
||||
'<div class="settings-panel active">',
|
||||
'<table cols="1" style="width: 100%;">',
|
||||
'<tr>',
|
||||
'<td class="padding-extra-small">',
|
||||
'<label class="input-label">', me.textBookmarkName, '</label>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td class="padding-large">',
|
||||
'<div id="bookmarks-txt-name" style="display:inline-block;vertical-align: top;margin-right: 10px;"></div>',
|
||||
'<button type="button" result="add" class="btn btn-text-default" id="bookmarks-btn-add" style="vertical-align: top;">', me.textAdd,'</button>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td class="padding-extra-small">',
|
||||
'<label class="header" style="margin-right: 10px;">', me.textSort,'</label>',
|
||||
'<div id="bookmarks-radio-name" style="display: inline-block; margin-right: 10px;"></div>',
|
||||
'<div id="bookmarks-radio-location" style="display: inline-block;"></div>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td class="padding-small">',
|
||||
'<div id="bookmarks-list" style="width:100%; height: 130px;"></div>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td class="padding-large">',
|
||||
'<button type="button" class="btn btn-text-default" id="bookmarks-btn-goto" style="margin-right: 10px;">', me.textGoto,'</button>',
|
||||
'<button type="button" class="btn btn-text-default" id="bookmarks-btn-delete" style="">', me.textDelete,'</button>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td>',
|
||||
'<div id="bookmarks-checkbox-hidden"></div>',
|
||||
'</td>',
|
||||
'</tr>',
|
||||
'</table>',
|
||||
'</div></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="footer right">',
|
||||
'<button class="btn normal dlg-btn" result="cancel" style="width: 86px;">' + me.textClose + '</button>',
|
||||
'</div>'
|
||||
].join('')
|
||||
}, options);
|
||||
|
||||
this.api = options.api;
|
||||
this.handler = options.handler;
|
||||
this.props = options.props;
|
||||
|
||||
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
Common.Views.AdvancedSettingsWindow.prototype.render.call(this);
|
||||
var me = this;
|
||||
|
||||
this.txtName = new Common.UI.InputField({
|
||||
el : $('#bookmarks-txt-name'),
|
||||
allowBlank : true,
|
||||
validateOnChange: true,
|
||||
validateOnBlur: false,
|
||||
style : 'width: 195px;',
|
||||
value : '',
|
||||
maxLength: 40
|
||||
}).on('changing', _.bind(this.onNameChanging, this));
|
||||
|
||||
this.radioName = new Common.UI.RadioBox({
|
||||
el: $('#bookmarks-radio-name'),
|
||||
labelText: this.textName,
|
||||
name: 'asc-radio-bookmark-sort',
|
||||
checked: true
|
||||
});
|
||||
this.radioName.on('change', _.bind(this.onRadioSort, this));
|
||||
|
||||
this.radioLocation = new Common.UI.RadioBox({
|
||||
el: $('#bookmarks-radio-location'),
|
||||
labelText: this.textLocation,
|
||||
name: 'asc-radio-bookmark-sort'
|
||||
});
|
||||
this.radioLocation.on('change', _.bind(this.onRadioSort, this));
|
||||
|
||||
this.bookmarksList = new Common.UI.ListView({
|
||||
el: $('#bookmarks-list', this.$window),
|
||||
store: new Common.UI.DataViewStore(),
|
||||
itemTemplate: _.template('<div id="<%= id %>" class="list-item" style="pointer-events:none;"><%= value %></div>')
|
||||
});
|
||||
this.bookmarksList.store.comparator = function(rec) {
|
||||
return (me.radioName.getValue() ? rec.get("value") : rec.get("location"));
|
||||
};
|
||||
this.bookmarksList.on('item:dblclick', _.bind(this.onDblClickBookmark, this));
|
||||
this.bookmarksList.on('entervalue', _.bind(this.onPrimary, this));
|
||||
this.bookmarksList.on('item:select', _.bind(this.onSelectBookmark, this));
|
||||
|
||||
this.btnAdd = new Common.UI.Button({
|
||||
el: $('#bookmarks-btn-add'),
|
||||
disabled: true
|
||||
});
|
||||
this.$window.find('#bookmarks-btn-add').on('click', _.bind(this.onDlgBtnClick, this));
|
||||
|
||||
this.btnGoto = new Common.UI.Button({
|
||||
el: $('#bookmarks-btn-goto'),
|
||||
disabled: true
|
||||
});
|
||||
this.btnGoto.on('click', _.bind(this.gotoBookmark, this));
|
||||
|
||||
this.btnDelete = new Common.UI.Button({
|
||||
el: $('#bookmarks-btn-delete'),
|
||||
disabled: true
|
||||
});
|
||||
this.btnDelete.on('click', _.bind(this.deleteBookmark, this));
|
||||
|
||||
this.chHidden = new Common.UI.CheckBox({
|
||||
el: $('#bookmarks-checkbox-hidden'),
|
||||
labelText: this.textHidden,
|
||||
value: Common.Utils.InternalSettings.get("de-bookmarks-hidden") || false
|
||||
});
|
||||
this.chHidden.on('change', _.bind(this.onChangeHidden, this));
|
||||
|
||||
this.afterRender();
|
||||
},
|
||||
|
||||
afterRender: function() {
|
||||
this._setDefaults(this.props);
|
||||
},
|
||||
|
||||
show: function() {
|
||||
Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments);
|
||||
},
|
||||
|
||||
close: function() {
|
||||
Common.Views.AdvancedSettingsWindow.prototype.close.apply(this, arguments);
|
||||
Common.Utils.InternalSettings.set("de-bookmarks-hidden", this.chHidden.getValue()=='checked');
|
||||
},
|
||||
|
||||
_setDefaults: function (props) {
|
||||
this.refreshBookmarks();
|
||||
this.bookmarksList.scrollToRecord(this.bookmarksList.selectByIndex(0));
|
||||
},
|
||||
|
||||
getSettings: function () {
|
||||
return {};
|
||||
},
|
||||
|
||||
onDlgBtnClick: function(event) {
|
||||
var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event;
|
||||
if (state == 'add') {
|
||||
this.props.asc_AddBookmark(this.txtName.getValue());
|
||||
}
|
||||
|
||||
this.close();
|
||||
},
|
||||
|
||||
onPrimary: function() {
|
||||
return true;
|
||||
},
|
||||
|
||||
refreshBookmarks: function() {
|
||||
if (this.props) {
|
||||
var store = this.bookmarksList.store,
|
||||
count = this.props.asc_GetCount(),
|
||||
showHidden = this.chHidden.getValue()=='checked',
|
||||
arr = [];
|
||||
for (var i=0; i<count; i++) {
|
||||
var name = this.props.asc_GetName(i);
|
||||
if (!this.props.asc_IsInternalUseBookmark(name) && (showHidden || !this.props.asc_IsHiddenBookmark(name))) {
|
||||
var rec = new Common.UI.DataViewModel();
|
||||
rec.set({
|
||||
value: name,
|
||||
location: i
|
||||
});
|
||||
arr.push(rec);
|
||||
}
|
||||
}
|
||||
store.reset(arr, {silent: false});
|
||||
}
|
||||
},
|
||||
|
||||
onSelectBookmark: function(listView, itemView, record) {
|
||||
var value = record.get('value');
|
||||
this.txtName.setValue(value);
|
||||
this.btnAdd.setDisabled(false);
|
||||
this.btnGoto.setDisabled(false);
|
||||
this.btnDelete.setDisabled(false);
|
||||
},
|
||||
|
||||
gotoBookmark: function(btn, eOpts){
|
||||
var rec = this.bookmarksList.getSelectedRec();
|
||||
if (rec.length>0) {
|
||||
this.props.asc_GoToBookmark(rec[0].get('value'));
|
||||
}
|
||||
},
|
||||
|
||||
onDblClickBookmark: function(listView, itemView, record) {
|
||||
this.props.asc_GoToBookmark(record.get('value'));
|
||||
},
|
||||
|
||||
deleteBookmark: function(btn, eOpts){
|
||||
var rec = this.bookmarksList.getSelectedRec();
|
||||
if (rec.length>0) {
|
||||
this.props.asc_RemoveBookmark(rec[0].get('value'));
|
||||
var store = this.bookmarksList.store;
|
||||
var idx = _.indexOf(store.models, rec[0]);
|
||||
store.remove(rec[0]);
|
||||
}
|
||||
},
|
||||
|
||||
onRadioSort: function(field, newValue, eOpts) {
|
||||
if (newValue) {
|
||||
this.bookmarksList.store.sort();
|
||||
this.bookmarksList.onResetItems();
|
||||
}
|
||||
},
|
||||
|
||||
onChangeHidden: function(field, newValue, oldValue, eOpts){
|
||||
this.refreshBookmarks();
|
||||
},
|
||||
|
||||
onNameChanging: function (input, value) {
|
||||
var exist = this.props.asc_HaveBookmark(value);
|
||||
this.bookmarksList.deselectAll();
|
||||
this.btnAdd.setDisabled(!this.props.asc_CheckNewBookmarkName(value) && !exist);
|
||||
this.btnGoto.setDisabled(!exist);
|
||||
this.btnDelete.setDisabled(!exist);
|
||||
},
|
||||
|
||||
textTitle: 'Bookmarks',
|
||||
textLocation: 'Location',
|
||||
textBookmarkName: 'Bookmark name',
|
||||
textSort: 'Sort by',
|
||||
textName: 'Name',
|
||||
textAdd: 'Add',
|
||||
textGoto: 'Go to',
|
||||
textDelete: 'Delete',
|
||||
textClose: 'Close',
|
||||
textHidden: 'Hidden bookmarks'
|
||||
|
||||
}, DE.Views.BookmarksDialog || {}))
|
||||
});
|
|
@ -42,6 +42,11 @@
|
|||
if (Common === undefined)
|
||||
var Common = {};
|
||||
|
||||
var c_oHyperlinkType = {
|
||||
InternalLink:0,
|
||||
WebLink: 1
|
||||
};
|
||||
|
||||
define([
|
||||
'common/main/lib/util/utils',
|
||||
'common/main/lib/component/InputField',
|
||||
|
@ -61,11 +66,20 @@ define([
|
|||
}, options || {});
|
||||
|
||||
this.template = [
|
||||
'<div class="box">',
|
||||
'<div class="input-row">',
|
||||
'<label>' + this.textUrl + ' *</label>',
|
||||
'<div class="box" style="height: 260px;">',
|
||||
'<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.textExternal,'</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.textInternal,'</button>',
|
||||
'</div>',
|
||||
'<div id="id-external-link">',
|
||||
'<div class="input-row">',
|
||||
'<label>' + this.textUrl + ' *</label>',
|
||||
'</div>',
|
||||
'<div id="id-dlg-hyperlink-url" class="input-row" style="margin-bottom: 5px;"></div>',
|
||||
'</div>',
|
||||
'<div id="id-internal-link">',
|
||||
'<div id="id-dlg-hyperlink-list" style="width:100%; height: 130px;border: 1px solid #cfcfcf;"></div>',
|
||||
'</div>',
|
||||
'<div id="id-dlg-hyperlink-url" class="input-row" style="margin-bottom: 5px;"></div>',
|
||||
'<div class="input-row">',
|
||||
'<label>' + this.textDisplay + '</label>',
|
||||
'</div>',
|
||||
|
@ -84,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);
|
||||
},
|
||||
|
@ -94,6 +109,23 @@ define([
|
|||
var me = this,
|
||||
$window = this.getChild();
|
||||
|
||||
me.btnExternal = new Common.UI.Button({
|
||||
el: $('#id-dlg-hyperlink-external'),
|
||||
enableToggle: true,
|
||||
toggleGroup: 'hyperlink-type',
|
||||
allowDepress: false,
|
||||
pressed: true
|
||||
});
|
||||
me.btnExternal.on('click', _.bind(me.onLinkTypeClick, me, c_oHyperlinkType.WebLink));
|
||||
|
||||
me.btnInternal = new Common.UI.Button({
|
||||
el: $('#id-dlg-hyperlink-internal'),
|
||||
enableToggle: true,
|
||||
toggleGroup: 'hyperlink-type',
|
||||
allowDepress: false
|
||||
});
|
||||
me.btnInternal.on('click', _.bind(me.onLinkTypeClick, me, c_oHyperlinkType.InternalLink));
|
||||
|
||||
me.inputUrl = new Common.UI.InputField({
|
||||
el : $('#id-dlg-hyperlink-url'),
|
||||
allowBlank : false,
|
||||
|
@ -122,8 +154,119 @@ define([
|
|||
maxLength : Asc.c_oAscMaxTooltipLength
|
||||
});
|
||||
|
||||
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.btnOk = new Common.UI.Button({
|
||||
el: $window.find('.primary')
|
||||
});
|
||||
|
||||
$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');
|
||||
me.internalPanel = $window.find('#id-internal-link');
|
||||
},
|
||||
|
||||
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) {
|
||||
if (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; i<count; i++) {
|
||||
var anchor = anchors[i],
|
||||
level = anchors[i].asc_GetHeadingLevel(),
|
||||
hasParent = true;
|
||||
if (anchor.asc_GetType()== Asc.c_oAscHyperlinkAnchor.Heading){
|
||||
if (level>prev_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,
|
||||
type: Asc.c_oAscHyperlinkAnchor.Heading,
|
||||
headingParagraph: anchor.asc_GetHeadingParagraph()
|
||||
}));
|
||||
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; i<count; i++) {
|
||||
var anchor = anchors[i],
|
||||
hasParent = true;
|
||||
if (anchor.asc_GetType()== Asc.c_oAscHyperlinkAnchor.Bookmark){
|
||||
if (prev_level<1)
|
||||
arr[arr.length-1].set('hasSubItems', true);
|
||||
arr.push(new Common.UI.TreeViewModel({
|
||||
name : anchor.asc_GetBookmarkName(),
|
||||
level: 1,
|
||||
index: arr.length,
|
||||
hasParent: false,
|
||||
type: Asc.c_oAscHyperlinkAnchor.Bookmark
|
||||
}));
|
||||
prev_level = 1;
|
||||
}
|
||||
}
|
||||
store.reset(arr);
|
||||
}
|
||||
var rec = this.internalList.getSelectedRec();
|
||||
this.btnOk.setDisabled(rec.length<1 || rec[0].get('level')==0 && rec[0].get('index')>0);
|
||||
|
||||
} else
|
||||
this.btnOk.setDisabled(false);
|
||||
|
||||
this.linkType = value;
|
||||
},
|
||||
|
||||
onLinkTypeClick: function(type, btn, event) {
|
||||
this.ShowHideElem(type);
|
||||
},
|
||||
|
||||
onSelectItem: function(picker, item, record, e){
|
||||
this.btnOk.setDisabled(record.get('level')==0 && record.get('index')>0);
|
||||
},
|
||||
|
||||
show: function() {
|
||||
|
@ -139,10 +282,31 @@ define([
|
|||
if (props) {
|
||||
var me = this;
|
||||
|
||||
if (props.get_Value()) {
|
||||
me.inputUrl.setValue(props.get_Value().replace(new RegExp(" ",'g'), "%20"));
|
||||
var bookmark = props.get_Bookmark(),
|
||||
type = (bookmark === null || bookmark=='') ? c_oHyperlinkType.WebLink : c_oHyperlinkType.InternalLink;
|
||||
|
||||
(type == c_oHyperlinkType.WebLink) ? me.btnExternal.toggle(true) : me.btnInternal.toggle(true);
|
||||
me.ShowHideElem(type);
|
||||
|
||||
if (type == c_oHyperlinkType.WebLink) {
|
||||
if (props.get_Value()) {
|
||||
me.inputUrl.setValue(props.get_Value().replace(new RegExp(" ",'g'), "%20"));
|
||||
} else {
|
||||
me.inputUrl.setValue('');
|
||||
}
|
||||
} else {
|
||||
me.inputUrl.setValue('');
|
||||
if (props.is_TopOfDocument())
|
||||
this.internalList.selectByIndex(0);
|
||||
else if (props.is_Heading()) {
|
||||
var heading = props.get_Heading(),
|
||||
rec = this.internalList.store.findWhere({type: Asc.c_oAscHyperlinkAnchor.Heading, headingParagraph: heading });
|
||||
if (rec)
|
||||
this.internalList.scrollToRecord(this.internalList.selectRecord(rec));
|
||||
} else {
|
||||
var rec = this.internalList.store.findWhere({type: Asc.c_oAscHyperlinkAnchor.Bookmark, name: bookmark});
|
||||
if (rec)
|
||||
this.internalList.scrollToRecord(this.internalList.selectRecord(rec));
|
||||
}
|
||||
}
|
||||
|
||||
if (props.get_Text() !== null) {
|
||||
|
@ -163,17 +327,34 @@ define([
|
|||
getSettings: function () {
|
||||
var me = this,
|
||||
props = new Asc.CHyperlinkProperty(),
|
||||
url = $.trim(me.inputUrl.getValue());
|
||||
display = '';
|
||||
|
||||
if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) )
|
||||
url = ( (me.isEmail) ? 'mailto:' : 'http://' ) + url;
|
||||
if (this.linkType == c_oHyperlinkType.WebLink) {
|
||||
var url = $.trim(me.inputUrl.getValue());
|
||||
|
||||
url = url.replace(new RegExp("%20",'g')," ");
|
||||
props.put_Value(url);
|
||||
if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) )
|
||||
url = ( (me.isEmail) ? 'mailto:' : 'http://' ) + url;
|
||||
|
||||
url = url.replace(new RegExp("%20",'g')," ");
|
||||
props.put_Value(url);
|
||||
props.put_Bookmark(null);
|
||||
display = url;
|
||||
} else {
|
||||
var rec = this.internalList.getSelectedRec();
|
||||
if (rec.length>0) {
|
||||
props.put_Bookmark(rec[0].get('name'));
|
||||
if (rec[0].get('index')==0)
|
||||
props.put_TopOfDocument();
|
||||
var para = rec[0].get('headingParagraph');
|
||||
if (para)
|
||||
props.put_Heading(para);
|
||||
display = rec[0].get('name');
|
||||
}
|
||||
}
|
||||
|
||||
if (!me.inputDisplay.isDisabled() && ( this.isTextChanged || _.isEmpty(me.inputDisplay.getValue()))) {
|
||||
if (_.isEmpty(me.inputDisplay.getValue()))
|
||||
me.inputDisplay.setValue(url);
|
||||
me.inputDisplay.setValue(display);
|
||||
props.put_Text(me.inputDisplay.getValue());
|
||||
} else {
|
||||
props.put_Text(null);
|
||||
|
@ -199,13 +380,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;
|
||||
}
|
||||
|
@ -225,6 +410,11 @@ define([
|
|||
txtNotUrl: 'This field should be a URL in the format \"http://www.example.com\"',
|
||||
textTooltip: 'ScreenTip text',
|
||||
textDefault: 'Selected text',
|
||||
textTitle: 'Hyperlink Settings'
|
||||
textTitle: 'Hyperlink Settings',
|
||||
textExternal: 'External Link',
|
||||
textInternal: 'Place in Document',
|
||||
txtBeginning: 'Beginning of document',
|
||||
txtHeadings: 'Headings',
|
||||
txtBookmarks: 'Bookmarks'
|
||||
}, DE.Views.HyperlinkSettingsDialog || {}))
|
||||
});
|
|
@ -101,6 +101,10 @@ define([
|
|||
me.fireEvent('links:hyperlink');
|
||||
});
|
||||
});
|
||||
|
||||
this.btnBookmarks.on('click', function (b, e) {
|
||||
me.fireEvent('links:bookmarks');
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -161,6 +165,15 @@ define([
|
|||
_injectComponent('#slot-btn-contents-update', this.btnContentsUpdate);
|
||||
this.paragraphControls.push(this.btnContentsUpdate);
|
||||
|
||||
this.btnBookmarks = new Common.UI.Button({
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
iconCls: 'btn-bookmarks',
|
||||
caption: this.capBtnBookmarks,
|
||||
disabled: true
|
||||
});
|
||||
_injectComponent('#slot-btn-bookmarks', this.btnBookmarks);
|
||||
this.paragraphControls.push(this.btnBookmarks);
|
||||
|
||||
this._state = {disabled: false};
|
||||
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
|
||||
},
|
||||
|
@ -255,6 +268,8 @@ define([
|
|||
btn.updateHint(me.tipInsertHyperlink + Common.Utils.String.platformKey('Ctrl+K'));
|
||||
});
|
||||
|
||||
me.btnBookmarks.updateHint(me.tipBookmarks);
|
||||
|
||||
setEvents.call(me);
|
||||
});
|
||||
},
|
||||
|
@ -293,7 +308,9 @@ define([
|
|||
capBtnInsFootnote: 'Footnotes',
|
||||
confirmDeleteFootnotes: 'Do you want to delete all footnotes?',
|
||||
capBtnInsLink: 'Hyperlink',
|
||||
tipInsertHyperlink: 'Add Hyperlink'
|
||||
tipInsertHyperlink: 'Add Hyperlink',
|
||||
capBtnBookmarks: 'Bookmark',
|
||||
tipBookmarks: 'Create a bookmark'
|
||||
}
|
||||
}()), DE.Views.Links || {}));
|
||||
});
|
|
@ -779,6 +779,16 @@
|
|||
"DE.Controllers.Toolbar.txtSymbol_vdots": "Vertical ellipsis",
|
||||
"DE.Controllers.Toolbar.txtSymbol_xsi": "Xi",
|
||||
"DE.Controllers.Toolbar.txtSymbol_zeta": "Zeta",
|
||||
"DE.Views.BookmarksDialog.textTitle": "Bookmarks",
|
||||
"DE.Views.BookmarksDialog.textLocation": "Location",
|
||||
"DE.Views.BookmarksDialog.textBookmarkName": "Bookmark name",
|
||||
"DE.Views.BookmarksDialog.textSort": "Sort by",
|
||||
"DE.Views.BookmarksDialog.textName": "Name",
|
||||
"DE.Views.BookmarksDialog.textAdd": "Add",
|
||||
"DE.Views.BookmarksDialog.textGoto": "Go to",
|
||||
"DE.Views.BookmarksDialog.textDelete": "Delete",
|
||||
"DE.Views.BookmarksDialog.textClose": "Close",
|
||||
"DE.Views.BookmarksDialog.textHidden": "Hidden bookmarks",
|
||||
"DE.Views.ChartSettings.textAdvanced": "Show advanced settings",
|
||||
"DE.Views.ChartSettings.textArea": "Area",
|
||||
"DE.Views.ChartSettings.textBar": "Bar",
|
||||
|
@ -1169,6 +1179,11 @@
|
|||
"DE.Views.HyperlinkSettingsDialog.textUrl": "Link to",
|
||||
"DE.Views.HyperlinkSettingsDialog.txtEmpty": "This field is required",
|
||||
"DE.Views.HyperlinkSettingsDialog.txtNotUrl": "This field should be a URL in the \"http://www.example.com\" format",
|
||||
"DE.Views.HyperlinkSettingsDialog.textExternal": "External Link",
|
||||
"DE.Views.HyperlinkSettingsDialog.textInternal": "Place in Document",
|
||||
"DE.Views.HyperlinkSettingsDialog.txtBeginning": "Beginning of document",
|
||||
"DE.Views.HyperlinkSettingsDialog.txtHeadings": "Headings",
|
||||
"DE.Views.HyperlinkSettingsDialog.txtBookmarks": "Bookmarks",
|
||||
"DE.Views.ImageSettings.textAdvanced": "Show advanced settings",
|
||||
"DE.Views.ImageSettings.textEdit": "Edit",
|
||||
"DE.Views.ImageSettings.textEditObject": "Edit Object",
|
||||
|
@ -1283,6 +1298,8 @@
|
|||
"DE.Views.Links.tipContentsUpdate": "Refresh table of contents",
|
||||
"DE.Views.Links.tipInsertHyperlink": "Add hyperlink",
|
||||
"DE.Views.Links.tipNotes": "Insert or edit footnotes",
|
||||
"DE.Views.Links.capBtnBookmarks": "Bookmark",
|
||||
"DE.Views.Links.tipBookmarks": "Create a bookmark",
|
||||
"DE.Views.MailMergeEmailDlg.cancelButtonText": "Cancel",
|
||||
"DE.Views.MailMergeEmailDlg.filePlaceholder": "PDF",
|
||||
"DE.Views.MailMergeEmailDlg.okButtonText": "Send",
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
display: block;
|
||||
}
|
||||
|
||||
.padding-extra-small {
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.padding-small {
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue