diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js index f47d839cf..7cb8cab20 100644 --- a/apps/common/Gateway.js +++ b/apps/common/Gateway.js @@ -232,6 +232,14 @@ Common.Gateway = new(function() { collaborativeChanges: function() { _postMessage({event: 'onCollaborativeChanges'}); }, + + requestRename: function(title) { + _postMessage({event: 'onRequestRename', data: title}); + }, + + metaChange: function(meta) { + _postMessage({event: 'onMetaChange', data: meta}); + }, on: function(event, handler){ var localHandler = function(event, data){ diff --git a/apps/common/main/lib/template/Header.template b/apps/common/main/lib/template/Header.template index 9bb4bd030..eb375f8e0 100644 --- a/apps/common/main/lib/template/Header.template +++ b/apps/common/main/lib/template/Header.template @@ -2,6 +2,6 @@
<%= headerCaption %>
-
<%= documentCaption %>
+
<%= documentCaption %>
<%= textBack %>
\ No newline at end of file diff --git a/apps/common/main/lib/view/About.js b/apps/common/main/lib/view/About.js index 393759a28..29e0789ac 100644 --- a/apps/common/main/lib/view/About.js +++ b/apps/common/main/lib/view/About.js @@ -52,7 +52,7 @@ define([ initialize: function(options) { Common.UI.BaseView.prototype.initialize.call(this,arguments); - this.txtVersionNum = '4.1'; + this.txtVersionNum = '4.2'; this.txtAscMail = 'support@onlyoffice.com'; this.txtAscTelNum = '+371 660-16425'; this.txtAscUrl = 'www.onlyoffice.com'; diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 126fe7c3f..2974c8971 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -46,7 +46,8 @@ Common.Views = Common.Views || {}; define([ 'backbone', 'text!common/main/lib/template/Header.template', - 'core' + 'core', + 'common/main/lib/view/RenameDialog' ], function (Backbone, headerTemplate) { 'use strict'; Common.Views.Header = Backbone.View.extend(_.extend({ @@ -165,7 +166,7 @@ define([ if (!value) value = ''; - var dc = $('#header-documentcaption'); + var dc = $('#header-documentcaption span'); if (dc) dc.html(Common.Utils.String.htmlEncode(value)); @@ -226,8 +227,36 @@ define([ $('#header-developer').toggleClass('hidden', !mode); }, + setCanRename: function(rename) { + var dc = $('#header-documentcaption span'); + if (rename) { + var me = this; + dc.tooltip({title: me.txtRename, placement: 'cursor'}); + dc.on('click', function(e) { + (new Common.Views.RenameDialog({ + filename: me.documentCaption, + handler: function(result, value) { + if (result == 'ok' && !_.isEmpty(value.trim()) && me.documentCaption !== value.trim()) { + Common.Gateway.requestRename(value); + } + Common.NotificationCenter.trigger('edit:complete', me); + } + })).show(dc.position().left-1, 20); + }); + } else { + var tip = dc.data('bs.tooltip'); + if (tip) { + tip.options.title = ''; + tip.setContent(); + } + dc.off('click'); + } + dc.css('cursor', rename ? 'pointer' : 'default'); + }, + textBack: 'Go to Documents', openNewTabText: 'Open in New Tab', - txtHeaderDeveloper: 'DEVELOPER MODE' + txtHeaderDeveloper: 'DEVELOPER MODE', + txtRename: 'Rename' }, Common.Views.Header || {})) }); diff --git a/apps/common/main/lib/view/RenameDialog.js b/apps/common/main/lib/view/RenameDialog.js new file mode 100644 index 000000000..59509069a --- /dev/null +++ b/apps/common/main/lib/view/RenameDialog.js @@ -0,0 +1,134 @@ +/* + * + * (c) Copyright Ascensio System Limited 2010-2016 + * + * 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 + * +*/ +/** + * RenameDialog.js + * + * Created by Julia Radzhabova on 9/23/16 + * Copyright (c) 2014 Ascensio System SIA. All rights reserved. + * + */ + +define([ + 'common/main/lib/component/Window' +], function () { 'use strict'; + + Common.Views.RenameDialog = Common.UI.Window.extend(_.extend({ + options: { + width: 330, + header: false, + cls: 'modal-dlg', + filename: '' + }, + + initialize : function(options) { + _.extend(this.options, options || {}); + + this.template = [ + '
', + '
', + '', + '
', + '
', + '
', + '' + ].join(''); + + this.options.tpl = _.template(this.template, this.options); + + Common.UI.Window.prototype.initialize.call(this, this.options); + }, + + render: function() { + Common.UI.Window.prototype.render.call(this); + + var me = this; + me.inputName = new Common.UI.InputField({ + el : $('#id-dlg-newname'), + style : 'width: 100%;', + validateOnBlur: false, + validation : function(value) { + return (/[\t*\+:\"<>?|\\\\/]/gim.test(value)) ? me.txtInvalidName + "*+:\"<>?|\/" : true; + } + }); + + var $window = this.getChild(); + $window.find('.btn').on('click', _.bind(this.onBtnClick, this)); + + me.inputNameEl = $window.find('input'); + me.inputNameEl.on('keypress', _.bind(this.onKeyPress, this)); + }, + + show: function() { + Common.UI.Window.prototype.show.apply(this, arguments); + + var me = this; + _.delay(function(){ + me.inputName.setValue(me.options.filename); + me.inputNameEl.focus().select(); + },100); + }, + + onKeyPress: function(event) { + if (event.keyCode == Common.UI.Keys.RETURN) { + this._handleInput('ok'); + } + }, + + onBtnClick: function(event) { + this._handleInput(event.currentTarget.attributes['result'].value); + }, + + _handleInput: function(state) { + if (this.options.handler) { + if (state == 'ok') { + if (this.inputName.checkValidate() !== true) { + this.inputNameEl.focus(); + return; + } + } + + this.options.handler.call(this, state, this.inputName.getValue()); + } + + this.close(); + }, + + textName : 'File name', + cancelButtonText: 'Cancel', + okButtonText : 'Ok', + txtInvalidName : 'The file name cannot contain any of the following characters: ' + }, Common.Views.RenameDialog || {})); +}); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 34d676abc..d102b7506 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -235,6 +235,19 @@ define([ this.showHistory(); } break; + case 'rename': + var me = this, + documentCaption = me.api.asc_getDocumentName(); + (new Common.Views.RenameDialog({ + filename: documentCaption, + handler: function(result, value) { + if (result == 'ok' && !_.isEmpty(value.trim()) && documentCaption !== value.trim()) { + Common.Gateway.requestRename(value); + } + Common.NotificationCenter.trigger('edit:complete', me); + } + })).show(); + break; default: close_menu = false; } diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index c83dece4a..61835263f 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -130,6 +130,7 @@ define([ this.api.asc_registerCallback('asc_onAdvancedOptions', _.bind(this.onAdvancedOptions, this)); this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this)); this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this)); + this.api.asc_registerCallback('asc_onMeta', _.bind(this.onMeta, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('goback', _.bind(this.goBack, this)); @@ -363,6 +364,7 @@ define([ }); } else { this.api.asc_coAuthoringDisconnect(); + this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false); this.getApplication().getController('LeftMenu').getView('LeftMenu').showHistory(); this.disableEditing(true); var versions = opts.data.history, @@ -969,6 +971,7 @@ define([ this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); this.appOptions.canEditStyles = this.appOptions.canLicense && this.appOptions.canEdit; this.appOptions.canPrint = (this.permissions.print !== false); + this.appOptions.canRename = !!this.permissions.rename; var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType); this.appOptions.canDownloadOrigin = !this.appOptions.nativeApp && this.permissions.download !== false && (type && typeof type[1] === 'string'); @@ -976,11 +979,13 @@ define([ this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; + var headerView = this.getApplication().getController('Viewport').getView('Common.Views.Header'); this.appOptions.canBranding = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object'); if (this.appOptions.canBranding) - this.getApplication().getController('Viewport').getView('Common.Views.Header').setBranding(this.editorConfig.customization); + headerView.setBranding(this.editorConfig.customization); - params.asc_getTrial() && this.getApplication().getController('Viewport').getView('Common.Views.Header').setDeveloperMode(true); + params.asc_getTrial() && headerView.setDeveloperMode(true); + this.appOptions.canRename && headerView.setCanRename(true); this.applyModeCommonElements(); this.applyModeEditorElements(); @@ -1276,6 +1281,8 @@ define([ onCoAuthoringDisconnect: function() { this.getApplication().getController('Viewport').getView('Viewport').setMode({isDisconnected:true}); + this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false); + this.appOptions.canRename = false; this._state.isDisconnected = true; }, @@ -1706,6 +1713,17 @@ define([ this.updateWindowTitle(true); }, + onMeta: function(meta) { + var app = this.getApplication(), + filemenu = app.getController('LeftMenu').getView('LeftMenu').getMenu('file'); + app.getController('Viewport').getView('Common.Views.Header').setDocumentCaption(meta.title); + this.updateWindowTitle(true); + this.document.title = meta.title; + filemenu.loadDocument({doc:this.document}); + filemenu.panels['info'].updateInfo(this.document); + Common.Gateway.metaChange(meta); + }, + onPrint: function() { if (!this.appOptions.canPrint) return; diff --git a/apps/documenteditor/main/app/template/FileMenu.template b/apps/documenteditor/main/app/template/FileMenu.template index 7ae80e486..d1ed92b31 100644 --- a/apps/documenteditor/main/app/template/FileMenu.template +++ b/apps/documenteditor/main/app/template/FileMenu.template @@ -7,6 +7,7 @@
  • +
  • diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index ff406b26e..a72af2cb7 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -121,6 +121,12 @@ define([ caption : this.btnPrintCaption, canFocused: false }), + new Common.UI.MenuItem({ + el : $('#fm-btn-rename',this.el), + action : 'rename', + caption : this.btnRenameCaption, + canFocused: false + }), new Common.UI.MenuItem({ el : $('#fm-btn-recent',this.el), action : 'recent', @@ -208,9 +214,10 @@ define([ applyMode: function() { this.items[5][this.mode.canPrint?'show':'hide'](); - this.items[6][this.mode.canOpenRecent?'show':'hide'](); - this.items[7][this.mode.canCreateNew?'show':'hide'](); - this.items[7].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); + this.items[6][(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); + this.items[7][this.mode.canOpenRecent?'show':'hide'](); + this.items[8][this.mode.canCreateNew?'show':'hide'](); + this.items[8].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); this.items[3][((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide'](); this.items[4][((this.mode.canDownload || this.mode.canDownloadOrigin) && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); @@ -219,7 +226,7 @@ define([ this.items[1][this.mode.isEdit?'show':'hide'](); this.items[2][!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide'](); - this.items[9][(!this.mode.isOffline && !this.mode.isReviewOnly && this.document&&this.document.info && + this.items[10][(!this.mode.isOffline && !this.mode.isReviewOnly && this.document&&this.document.info && (this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length))?'show':'hide'](); @@ -232,7 +239,7 @@ define([ if ( this.mode.canCreateNew ) { if (this.mode.templates && this.mode.templates.length) { - $('a',this.items[7].$el).text(this.btnCreateNewCaption + '...'); + $('a',this.items[8].$el).text(this.btnCreateNewCaption + '...'); this.panels['new'] = ((new DE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates})).render()); } } @@ -254,8 +261,8 @@ define([ this.panels['help'].setLangConfig(this.mode.lang); - this.items[10][this.mode.canUseHistory?'show':'hide'](); - this.items[10].setDisabled(this.mode.isDisconnected); + this.items[11][this.mode.canUseHistory?'show':'hide'](); + this.items[11].setDisabled(this.mode.isDisconnected); }, setMode: function(mode, delay) { @@ -263,6 +270,7 @@ define([ this.mode.canEdit = this.mode.isEdit = false; this.mode.canOpenRecent = this.mode.canCreateNew = false; this.mode.isDisconnected = mode.isDisconnected; + this.mode.canRename = false; } else { this.mode = mode; } @@ -303,6 +311,7 @@ define([ SetDisabled: function(disable) { this.items[1][(disable || !this.mode.isEdit)?'hide':'show'](); + this.items[6][(disable || !this.mode.canRename || this.mode.isDesktopApp) ?'hide':'show'](); }, btnSaveCaption : 'Save', @@ -319,6 +328,7 @@ define([ btnSettingsCaption : 'Advanced Settings...', btnHistoryCaption : 'Versions History', btnSaveAsCaption : 'Save as', - textDownload : 'Download' + textDownload : 'Download', + btnRenameCaption : 'Rename...' }, DE.Views.FileMenu || {})); }); diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 6f73a68a4..c83ec7369 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -437,8 +437,8 @@ define([ textAutoRecover: 'Autorecover', strAutoRecover: 'Turn on autorecover', txtInch: 'Inch', - txtFitPage: 'Fit Page', - txtFitWidth: 'Fit Width' + txtFitPage: 'Fit to Page', + txtFitWidth: 'Fit to Width' }, DE.Views.FileMenuPanels.Settings || {})); DE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({ diff --git a/apps/documenteditor/main/app/view/Statusbar.js b/apps/documenteditor/main/app/view/Statusbar.js index 4ad9c77c0..bd37a476b 100644 --- a/apps/documenteditor/main/app/view/Statusbar.js +++ b/apps/documenteditor/main/app/view/Statusbar.js @@ -506,8 +506,8 @@ define([ tipUsers : 'Document is currently being edited by several users.', tipMoreUsers : 'and %1 users.', tipShowUsers : 'To see all users click the icon below.', - tipFitPage : 'Fit Page', - tipFitWidth : 'Fit Width', + tipFitPage : 'Fit to Page', + tipFitWidth : 'Fit to Width', tipZoomIn : 'Zoom In', tipZoomOut : 'Zoom Out', tipZoomFactor : 'Magnification', diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index ed0159705..e5a255952 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -1834,8 +1834,8 @@ define([ textHideTitleBar: 'Hide Title Bar', textHideStatusBar: 'Hide Status Bar', textHideLines: 'Hide Rulers', - textFitPage: 'Fit Page', - textFitWidth: 'Fit Width', + textFitPage: 'Fit to Page', + textFitWidth: 'Fit to Width', textZoom: 'Zoom', mniEditDropCap: 'Drop Cap Settings', textNone: 'None', diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 4ceed9b62..d0863b14c 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -142,6 +142,7 @@ "Common.Views.Header.openNewTabText": "Open in New Tab", "Common.Views.Header.textBack": "Go to Documents", "Common.Views.Header.txtHeaderDeveloper": "DEVELOPER MODE", + "Common.Views.Header.txtRename": "Rename", "Common.Views.History.textHistoryHeader": "Back to Document", "Common.Views.History.textRestore": "Restore", "Common.Views.ImageFromUrlDialog.cancelButtonText": "Cancel", @@ -167,6 +168,10 @@ "Common.Views.Plugins.strPlugins": "Plugins", "Common.Views.Plugins.textLoading": "Loading", "Common.Views.Plugins.textStart": "Start", + "Common.Views.RenameDialog.cancelButtonText": "Cancel", + "Common.Views.RenameDialog.okButtonText": "Ok", + "Common.Views.RenameDialog.textName": "File name", + "Common.Views.RenameDialog.txtInvalidName": "The file name cannot contain any of the following characters: ", "Common.Views.ReviewChanges.txtAccept": "Accept", "Common.Views.ReviewChanges.txtAcceptAll": "Accept All Changes", "Common.Views.ReviewChanges.txtAcceptCurrent": "Accept Current Change", @@ -870,6 +875,7 @@ "DE.Views.FileMenu.btnInfoCaption": "Document Info...", "DE.Views.FileMenu.btnPrintCaption": "Print", "DE.Views.FileMenu.btnRecentFilesCaption": "Open Recent...", + "DE.Views.FileMenu.btnRenameCaption": "Rename...", "DE.Views.FileMenu.btnReturnCaption": "Back to Document", "DE.Views.FileMenu.btnRightsCaption": "Access Rights...", "DE.Views.FileMenu.btnSaveAsCaption": "Save as", @@ -936,8 +942,6 @@ "DE.Views.FileMenuPanels.Settings.txtPt": "Point", "DE.Views.FileMenuPanels.Settings.txtSpellCheck": "Spell Checking", "DE.Views.FileMenuPanels.Settings.txtWin": "as Windows", - "DE.Views.FileMenuPanels.Settings.txtFitPage": "Fit Page", - "DE.Views.FileMenuPanels.Settings.txtFitWidth": "Fit Width", "DE.Views.HeaderFooterSettings.textBottomCenter": "Bottom Center", "DE.Views.HeaderFooterSettings.textBottomLeft": "Bottom Left", "DE.Views.HeaderFooterSettings.textBottomRight": "Bottom Right", diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index 134c6021a..f8794b990 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -196,6 +196,19 @@ define([ if ( isopts ) close_menu = false; else this.onCreateNew(undefined, 'blank'); break; + case 'rename': + var me = this, + documentCaption = me.api.asc_getDocumentName(); + (new Common.Views.RenameDialog({ + filename: documentCaption, + handler: function(result, value) { + if (result == 'ok' && !_.isEmpty(value.trim()) && documentCaption !== value.trim()) { + Common.Gateway.requestRename(value); + } + Common.NotificationCenter.trigger('edit:complete', me); + } + })).show(); + break; default: close_menu = false; } diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 7c3cbc395..eeda5f90e 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -121,6 +121,7 @@ define([ this.api.asc_registerCallback('asc_onDocumentUpdateVersion', _.bind(this.onUpdateVersion, this)); this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this)); this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this)); + this.api.asc_registerCallback('asc_onMeta', _.bind(this.onMeta, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('goback', _.bind(this.goBack, this)); @@ -738,14 +739,17 @@ define([ this.appOptions.canComments = this.appOptions.canLicense && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false); this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); this.appOptions.canPrint = (this.permissions.print !== false); + this.appOptions.canRename = !!this.permissions.rename; this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; + var headerView = this.getApplication().getController('Viewport').getView('Common.Views.Header'); this.appOptions.canBranding = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object'); if (this.appOptions.canBranding) - this.getApplication().getController('Viewport').getView('Common.Views.Header').setBranding(this.editorConfig.customization); + headerView.setBranding(this.editorConfig.customization); - params.asc_getTrial() && this.getApplication().getController('Viewport').getView('Common.Views.Header').setDeveloperMode(true); + params.asc_getTrial() && headerView.setDeveloperMode(true); + this.appOptions.canRename && headerView.setCanRename(true); this.applyModeCommonElements(); this.applyModeEditorElements(); @@ -1030,6 +1034,8 @@ define([ onCoAuthoringDisconnect: function() { // TODO: Disable all except 'Download As' and 'Print' this.getApplication().getController('Viewport').getView('Viewport').setMode({isDisconnected:true}); + this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false); + this.appOptions.canRename = false; this._state.isDisconnected = true; // this.getFileMenu().setMode({isDisconnected:true}); }, @@ -1464,6 +1470,17 @@ define([ this.updateWindowTitle(true); }, + onMeta: function(meta) { + var app = this.getApplication(), + filemenu = app.getController('LeftMenu').getView('LeftMenu').getMenu('file'); + app.getController('Viewport').getView('Common.Views.Header').setDocumentCaption(meta.title); + this.updateWindowTitle(true); + this.document.title = meta.title; + filemenu.loadDocument({doc:this.document}); + filemenu.panels['info'].updateInfo(this.document); + Common.Gateway.metaChange(meta); + }, + onPrint: function() { if (!this.appOptions.canPrint) return; diff --git a/apps/presentationeditor/main/app/template/FileMenu.template b/apps/presentationeditor/main/app/template/FileMenu.template index 14b6ae939..53e645328 100644 --- a/apps/presentationeditor/main/app/template/FileMenu.template +++ b/apps/presentationeditor/main/app/template/FileMenu.template @@ -7,6 +7,7 @@
  • +
  • diff --git a/apps/presentationeditor/main/app/view/FileMenu.js b/apps/presentationeditor/main/app/view/FileMenu.js index 3a22ac9b8..5a1b07935 100644 --- a/apps/presentationeditor/main/app/view/FileMenu.js +++ b/apps/presentationeditor/main/app/view/FileMenu.js @@ -124,6 +124,12 @@ define([ caption : this.btnPrintCaption, canFocused: false }), + new Common.UI.MenuItem({ + el : $('#fm-btn-rename',this.el), + action : 'rename', + caption : this.btnRenameCaption, + canFocused: false + }), new Common.UI.MenuItem({ el : $('#fm-btn-recent',this.el), action : 'recent', @@ -205,9 +211,10 @@ define([ applyMode: function() { this.items[5][this.mode.canPrint?'show':'hide'](); - this.items[6][this.mode.canOpenRecent?'show':'hide'](); - this.items[7][this.mode.canCreateNew?'show':'hide'](); - this.items[7].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); + this.items[6][(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); + this.items[7][this.mode.canOpenRecent?'show':'hide'](); + this.items[8][this.mode.canCreateNew?'show':'hide'](); + this.items[8].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); this.items[3][(this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide'](); this.items[4][(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); @@ -217,7 +224,7 @@ define([ this.items[1][this.mode.isEdit?'show':'hide'](); this.items[2][!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide'](); - this.items[9][(!this.mode.isOffline && this.document&&this.document.info&&(this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || + this.items[10][(!this.mode.isOffline && this.document&&this.document.info&&(this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length))?'show':'hide'](); this.mode.canBack ? this.$el.find('#fm-btn-back').show().prev().show() : @@ -229,7 +236,7 @@ define([ if ( this.mode.canCreateNew ) { if (this.mode.templates && this.mode.templates.length) { - $('a',this.items[7].$el).text(this.btnCreateNewCaption + '...'); + $('a',this.items[8].$el).text(this.btnCreateNewCaption + '...'); this.panels['new'] = ((new PE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates})).render()); } } @@ -251,6 +258,7 @@ define([ if (mode.isDisconnected) { this.mode.canEdit = this.mode.isEdit = false; this.mode.canOpenRecent = this.mode.canCreateNew = false; + this.mode.canRename = false; } else { this.mode = mode; } @@ -315,6 +323,7 @@ define([ btnToEditCaption : 'Edit Document', btnBackCaption : 'Go to Documents', btnSettingsCaption : 'Advanced Settings...', - btnSaveAsCaption : 'Save as' + btnSaveAsCaption : 'Save as', + btnRenameCaption : 'Rename...' }, PE.Views.FileMenu || {})); }); diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 03a5b0e0b..ce72e24fc 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -81,6 +81,7 @@ "Common.Views.Header.openNewTabText": "Open in New Tab", "Common.Views.Header.textBack": "Go to Documents", "Common.Views.Header.txtHeaderDeveloper": "DEVELOPER MODE", + "Common.Views.Header.txtRename": "Rename", "Common.Views.ImageFromUrlDialog.cancelButtonText": "Cancel", "Common.Views.ImageFromUrlDialog.okButtonText": "OK", "Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:", @@ -98,14 +99,16 @@ "Common.Views.Plugins.strPlugins": "Plugins", "Common.Views.Plugins.textLoading": "Loading", "Common.Views.Plugins.textStart": "Start", + "Common.Views.RenameDialog.cancelButtonText": "Cancel", + "Common.Views.RenameDialog.okButtonText": "Ok", + "Common.Views.RenameDialog.textName": "File name", + "Common.Views.RenameDialog.txtInvalidName": "The file name cannot contain any of the following characters: ", "PE.Controllers.LeftMenu.newDocumentTitle": "Unnamed presentation", "PE.Controllers.LeftMenu.requestEditRightsText": "Requesting editing rights...", "PE.Controllers.LeftMenu.textNoTextFound": "The data you have been searching for could not be found. Please adjust your search options.", "PE.Controllers.Main.applyChangesTextText": "Loading data...", "PE.Controllers.Main.applyChangesTitleText": "Loading Data", "del_PE.Controllers.Main.convertationErrorText": "Conversion failed.", - "PE.Controllers.Main.openErrorText": "An error has occurred while opening the file", - "PE.Controllers.Main.saveErrorText": "An error has occurred while saving the file", "PE.Controllers.Main.convertationTimeoutText": "Conversion timeout exceeded.", "PE.Controllers.Main.criticalErrorExtText": "Press \"OK\" to return to document list.", "PE.Controllers.Main.criticalErrorTitle": "Error", @@ -341,6 +344,7 @@ "PE.Views.FileMenu.btnInfoCaption": "Presentation Info...", "PE.Views.FileMenu.btnPrintCaption": "Print", "PE.Views.FileMenu.btnRecentFilesCaption": "Open Recent...", + "PE.Views.FileMenu.btnRenameCaption": "Rename...", "PE.Views.FileMenu.btnReturnCaption": "Back to Presentation", "PE.Views.FileMenu.btnRightsCaption": "Access Rights...", "PE.Views.FileMenu.btnSaveAsCaption": "Save as", diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 9fa4d3598..e5482dcbc 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -205,6 +205,19 @@ define([ if ( isopts ) close_menu = false; else this.onCreateNew(undefined, 'blank'); break; + case 'rename': + var me = this, + documentCaption = me.api.asc_getDocumentName(); + (new Common.Views.RenameDialog({ + filename: documentCaption, + handler: function(result, value) { + if (result == 'ok' && !_.isEmpty(value.trim()) && documentCaption !== value.trim()) { + Common.Gateway.requestRename(value); + } + Common.NotificationCenter.trigger('edit:complete', me); + } + })).show(); + break; default: close_menu = false; } diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 4e7b35645..c6e57cea0 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -121,6 +121,7 @@ define([ this.api.asc_registerCallback('asc_onDocumentUpdateVersion', _.bind(this.onUpdateVersion, this)); this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this)); this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this)); + this.api.asc_registerCallback('asc_onMeta', _.bind(this.onMeta, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('goback', _.bind(this.goBack, this)); Common.NotificationCenter.on('namedrange:locked', _.bind(this.onNamedRangeLocked, this)); @@ -758,12 +759,14 @@ define([ /** coauthoring end **/ this.appOptions.canComments = this.appOptions.canLicense && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false); this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false); + this.appOptions.canRename = !!this.permissions.rename; this.appOptions.canBranding = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object'); if (this.appOptions.canBranding) this.headerView.setBranding(this.editorConfig.customization); params.asc_getTrial() && this.headerView.setDeveloperMode(true); + this.appOptions.canRename && this.headerView.setCanRename(true); } this.appOptions.canRequestEditRights = this.editorConfig.canRequestEditRights; @@ -1183,7 +1186,9 @@ define([ onCoAuthoringDisconnect: function() { this.getApplication().getController('Viewport').getView('Viewport').setMode({isDisconnected:true}); - this._state.isDisconnected = true; + this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false); + this.appOptions.canRename = false; + this._state.isDisconnected = true; }, showTips: function(strings) { @@ -1699,6 +1704,17 @@ define([ this.updateWindowTitle(this.api.asc_isDocumentModified(), true); }, + onMeta: function(meta) { + var app = this.getApplication(), + filemenu = app.getController('LeftMenu').getView('LeftMenu').getMenu('file'); + app.getController('Viewport').getView('Common.Views.Header').setDocumentCaption(meta.title); + this.updateWindowTitle(true); + this.appOptions.spreadsheet.title = meta.title; + filemenu.loadDocument({doc:this.appOptions.spreadsheet}); + filemenu.panels['info'].updateInfo(this.appOptions.spreadsheet); + Common.Gateway.metaChange(meta); + }, + onPrint: function() { if (!this.appOptions.canPrint) return; Common.NotificationCenter.trigger('print', this); diff --git a/apps/spreadsheeteditor/main/app/template/FileMenu.template b/apps/spreadsheeteditor/main/app/template/FileMenu.template index 14b6ae939..53e645328 100644 --- a/apps/spreadsheeteditor/main/app/template/FileMenu.template +++ b/apps/spreadsheeteditor/main/app/template/FileMenu.template @@ -7,6 +7,7 @@
  • +
  • diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index e66a24df5..5772c7d6c 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -111,6 +111,12 @@ define([ caption : this.btnPrintCaption, canFocused: false }), + new Common.UI.MenuItem({ + el : $('#fm-btn-rename',this.el), + action : 'rename', + caption : this.btnRenameCaption, + canFocused: false + }), new Common.UI.MenuItem({ el : $('#fm-btn-recent',this.el), action : 'recent', @@ -191,9 +197,10 @@ define([ applyMode: function() { this.items[5][this.mode.canPrint?'show':'hide'](); - this.items[6][this.mode.canOpenRecent?'show':'hide'](); - this.items[7][this.mode.canCreateNew?'show':'hide'](); - this.items[7].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); + this.items[6][(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); + this.items[7][this.mode.canOpenRecent?'show':'hide'](); + this.items[8][this.mode.canCreateNew?'show':'hide'](); + this.items[8].$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); this.items[3][(this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide'](); this.items[4][(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide'](); @@ -202,11 +209,11 @@ define([ this.items[1][this.mode.isEdit?'show':'hide'](); this.items[2][!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide'](); - this.items[9][(!this.mode.isOffline && this.document&&this.document.info&&(this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || + this.items[10][(!this.mode.isOffline && this.document&&this.document.info&&(this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 || this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length))?'show':'hide'](); - this.items[10][this.mode.isEdit?'show':'hide'](); - this.items[10].$el.find('+.devider')[this.mode.isEdit?'show':'hide'](); + this.items[11][this.mode.isEdit?'show':'hide'](); + this.items[11].$el.find('+.devider')[this.mode.isEdit?'show':'hide'](); this.mode.canBack ? this.$el.find('#fm-btn-back').show().prev().show() : this.$el.find('#fm-btn-back').hide().prev().hide(); @@ -217,7 +224,7 @@ define([ if ( this.mode.canCreateNew ) { if (this.mode.templates && this.mode.templates.length) { - $('a',this.items[7].$el).text(this.btnCreateNewCaption + '...'); + $('a',this.items[8].$el).text(this.btnCreateNewCaption + '...'); this.panels['new'] = ((new SSE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates})).render()); } } @@ -235,6 +242,7 @@ define([ if (mode.isDisconnected) { this.mode.canEdit = this.mode.isEdit = false; this.mode.canOpenRecent = this.mode.canCreateNew = false; + this.mode.canRename = false; } else { this.mode = mode; } @@ -291,6 +299,7 @@ define([ btnToEditCaption : 'Edit Document', btnBackCaption : 'Go to Documents', btnSettingsCaption : 'Advanced Settings...', - btnSaveAsCaption : 'Save as' + btnSaveAsCaption : 'Save as', + btnRenameCaption : 'Rename...' }, SSE.Views.FileMenu || {})); }); diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index e3ac7c0bd..4c6fb82fe 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -75,6 +75,7 @@ "Common.Views.Header.openNewTabText": "Open in New Tab", "Common.Views.Header.textBack": "Go to Documents", "Common.Views.Header.txtHeaderDeveloper": "DEVELOPER MODE", + "Common.Views.Header.txtRename": "Rename", "Common.Views.ImageFromUrlDialog.cancelButtonText": "Cancel", "Common.Views.ImageFromUrlDialog.okButtonText": "OK", "Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:", @@ -93,6 +94,10 @@ "Common.Views.Plugins.strPlugins": "Plugins", "Common.Views.Plugins.textLoading": "Loading", "Common.Views.Plugins.textStart": "Start", + "Common.Views.RenameDialog.cancelButtonText": "Cancel", + "Common.Views.RenameDialog.okButtonText": "Ok", + "Common.Views.RenameDialog.textName": "File name", + "Common.Views.RenameDialog.txtInvalidName": "The file name cannot contain any of the following characters: ", "SSE.Controllers.DocumentHolder.errorInvalidLink": "The link reference does not exist. Please correct the link or delete it.", "SSE.Controllers.DocumentHolder.guestText": "Guest", "SSE.Controllers.DocumentHolder.notcriticalErrorTitle": "Warning", @@ -527,6 +532,7 @@ "SSE.Views.FileMenu.btnInfoCaption": "Spreadsheet Info...", "SSE.Views.FileMenu.btnPrintCaption": "Print", "SSE.Views.FileMenu.btnRecentFilesCaption": "Open Recent...", + "SSE.Views.FileMenu.btnRenameCaption": "Rename...", "SSE.Views.FileMenu.btnReturnCaption": "Back to Spreadsheet", "SSE.Views.FileMenu.btnRightsCaption": "Access Rights...", "SSE.Views.FileMenu.btnSaveAsCaption": "Save as",