From 0b18b030600e937cd0a7f851207176da1ff59084 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 19 Feb 2018 14:56:44 +0300 Subject: [PATCH] [DE] Add bookmarks. --- .../less/advanced-settings-window.less | 6 +- apps/common/main/resources/less/toolbar.less | 1 + .../main/app/controller/Links.js | 18 +- .../main/app/template/Toolbar.template | 1 + .../main/app/view/BookmarksDialog.js | 210 ++++++++++++++++++ apps/documenteditor/main/app/view/Links.js | 19 +- .../main/resources/less/rightmenu.less | 4 + 7 files changed, 255 insertions(+), 4 deletions(-) create mode 100644 apps/documenteditor/main/app/view/BookmarksDialog.js diff --git a/apps/common/main/resources/less/advanced-settings-window.less b/apps/common/main/resources/less/advanced-settings-window.less index 58375bb9e..42c801961 100644 --- a/apps/common/main/resources/less/advanced-settings-window.less +++ b/apps/common/main/resources/less/advanced-settings-window.less @@ -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; diff --git a/apps/common/main/resources/less/toolbar.less b/apps/common/main/resources/less/toolbar.less index 964fd49d2..96baf8e3f 100644 --- a/apps/common/main/resources/less/toolbar.less +++ b/apps/common/main/resources/less/toolbar.less @@ -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); diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 272074446..001b4fd64 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -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, @@ -306,6 +308,18 @@ define([ }, 50); break; } + }, + + onBookmarksClick: function(btn) { + var me = this; + (new DE.Views.BookmarksDialog({ + handler: function (result, settings) { + if (settings) { + } + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + }, + props: {} + })).show(); } }, DE.Controllers.Links || {})); diff --git a/apps/documenteditor/main/app/template/Toolbar.template b/apps/documenteditor/main/app/template/Toolbar.template index e1f406f59..75f5398ae 100644 --- a/apps/documenteditor/main/app/template/Toolbar.template +++ b/apps/documenteditor/main/app/template/Toolbar.template @@ -171,6 +171,7 @@
+
diff --git a/apps/documenteditor/main/app/view/BookmarksDialog.js b/apps/documenteditor/main/app/view/BookmarksDialog.js new file mode 100644 index 000000000..d2169905c --- /dev/null +++ b/apps/documenteditor/main/app/view/BookmarksDialog.js @@ -0,0 +1,210 @@ +/* + * + * (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: 340 + }, + + initialize : function(options) { + var me = this; + + _.extend(this.options, { + title: this.textTitle, + template: [ + '
', + '
', + '
', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '
', + '', + '
', + '
', + '', + '
', + '', + '
', + '
', + '
', + '
', + '
', + '', + '', + '
', + '
', + '
', + '
', + '' + ].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 : '' + }).on ('changing', function (input, value) { + }); + + 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.onRadioNameChange, this)); + + this.radioLocation = new Common.UI.RadioBox({ + el: $('#bookmarks-radio-location'), + labelText: this.textLocation, + name: 'asc-radio-bookmark-sort' + }); + // this.radioName.on('change', _.bind(this.onRadioNameChange, this)); + + this.bookmarksList = new Common.UI.ListView({ + el: $('#bookmarks-list', this.$window), + store: new Common.UI.DataViewStore() + }); + this.bookmarksList.store.comparator = function(rec) { + return (me.radioName.getValue() ? rec.get("name") : rec.get("location")); + }; + // this.bookmarksList.on('item:dblclick', _.bind(this.onDblClickFunction, 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') + }); + this.$window.find('#bookmarks-btn-add').on('click', _.bind(this.onDlgBtnClick, this)); + + this.btnGoto = new Common.UI.Button({ + el: $('#bookmarks-btn-goto') + }); + + this.btnDelete = new Common.UI.Button({ + el: $('#bookmarks-btn-delete') + }); + + this.afterRender(); + }, + + afterRender: function() { + this._setDefaults(this.props); + }, + + show: function() { + Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments); + }, + + _setDefaults: function (props) { + if (props) { + } + }, + + getSettings: function () { + return {}; + }, + + onDlgBtnClick: function(event) { + var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event; + if (state == 'add') { + this.handler && this.handler.call(this, state, (state == 'add') ? this.getSettings() : undefined); + } + + this.close(); + }, + + onPrimary: function() { + return true; + }, + + textTitle: 'Bookmarks', + textLocation: 'Location', + textBookmarkName: 'Bookmark name', + textSort: 'Sort by', + textName: 'Name', + textAdd: 'Add', + textGoto: 'Go to', + textDelete: 'Delete', + textClose: 'Close' + + }, DE.Views.BookmarksDialog || {})) +}); \ No newline at end of file diff --git a/apps/documenteditor/main/app/view/Links.js b/apps/documenteditor/main/app/view/Links.js index a40710f1f..6bb9f6525 100644 --- a/apps/documenteditor/main/app/view/Links.js +++ b/apps/documenteditor/main/app/view/Links.js @@ -91,6 +91,10 @@ define([ me.fireEvent('links:hyperlink'); }); }); + + this.btnBookmarks.on('click', function (b, e) { + me.fireEvent('links:bookmarks'); + }); } return { @@ -151,6 +155,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)); }, @@ -229,6 +242,8 @@ define([ btn.updateHint(me.tipInsertHyperlink + Common.Utils.String.platformKey('Ctrl+K')); }); + me.btnBookmarks.updateHint(me.tipBookmarks); + setEvents.call(me); }); }, @@ -267,7 +282,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 || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/resources/less/rightmenu.less b/apps/documenteditor/main/resources/less/rightmenu.less index 90b026654..12a2b1681 100644 --- a/apps/documenteditor/main/resources/less/rightmenu.less +++ b/apps/documenteditor/main/resources/less/rightmenu.less @@ -31,6 +31,10 @@ display: block; } + .padding-extra-small { + padding-bottom: 2px; + } + .padding-small { padding-bottom: 8px; }