diff --git a/apps/common/main/lib/view/Header.js b/apps/common/main/lib/view/Header.js index 21081a00bb..ed500c209e 100644 --- a/apps/common/main/lib/view/Header.js +++ b/apps/common/main/lib/view/Header.js @@ -204,10 +204,9 @@ define([ } function onAppShowed(config) { - //config.isCrypted =true; //delete fore merge! + // config.isCrypted =true; //delete fore merge! if ( this.labelDocName ) { if ( config.isCrypted ) { - this.labelDocName.attr({'style':'text-align: left;'}); this.labelDocName.before( '
' + '' + @@ -215,14 +214,21 @@ define([ this.imgCrypted = this.labelDocName.parent().find('.crypted'); } + var $parent = this.labelDocName.parent(); if (!config.isEdit || !config.customization || !config.customization.compactHeader) { - var $parent = this.labelDocName.parent(); var _left_width = $parent.position().left, _right_width = $parent.next().outerWidth(); if ( _left_width < _right_width ) - this.labelDocName.parent().css('padding-left', _right_width - _left_width); - else this.labelDocName.parent().css('padding-right', _left_width - _right_width); + $parent.css('padding-left', Math.max(2, _right_width - _left_width)); + else + $parent.css('padding-right', Math.max(2, _left_width - _right_width)); + } + + if (!(config.customization && config.customization.toolbarHideFileName) && (!config.isEdit || config.customization && config.customization.compactHeader)) { + var basis = parseFloat($parent.css('padding-left') || 0) + parseFloat($parent.css('padding-right') || 0) + parseInt(this.labelDocName.css('min-width') || 50); // 2px - box-shadow + $parent.css('flex-basis', Math.ceil(basis) + 'px'); + $parent.closest('.extra.right').css('flex-basis', Math.ceil(basis) + $parent.next().outerWidth() + 'px'); } } } @@ -343,6 +349,7 @@ define([ me.withoutExt = true; _.delay(function(){ me.setDocTile(name); + me.labelDocName.select(); },100); } @@ -352,8 +359,8 @@ define([ var name = me.labelDocName.val(); if ( e.keyCode == Common.UI.Keys.RETURN ) { name = name.trim(); - me.isSaveDocName =true; if ( !_.isEmpty(name) && me.cutDocName(me.documentCaption) !== name ) { + me.isSaveDocName =true; if ( /[\t*\+:\"<>?|\\\\/]/gim.test(name) ) { _.defer(function() { Common.UI.error({ @@ -378,14 +385,15 @@ define([ } } else { - Common.NotificationCenter.trigger('edit:complete', me); } } else if ( e.keyCode == Common.UI.Keys.ESC ) { Common.NotificationCenter.trigger('edit:complete', this); } else { - me.labelDocName.attr('size', name.length + me.fileExtention.length > 10 ? name.length + me.fileExtention.length : 10); + _.delay(function(){ + me.setDocTile(); + },10); } } @@ -658,10 +666,6 @@ define([ this.isModified && (value += '*'); if ( this.labelDocName ) { this.setDocTile( value ); - // this.labelDocName.attr('size', value.length); - //this.setCanRename(this.options.canRename); - - //this.setCanRename(true); } return value; }, @@ -707,7 +711,6 @@ define([ setCanRename: function (rename) { //rename = true; //comment out for merge - var me = this; me.options.canRename = rename; if ( me.labelDocName ) { @@ -723,6 +726,7 @@ define([ 'focus': onFocusDocName.bind(this), 'blur': function (e) { me.imgCrypted && me.imgCrypted.attr('hidden', false); + label[0].selectionStart = label[0].selectionEnd = 0; if(!me.isSaveDocName) { me.withoutExt = false; me.setDocTile(me.documentCaption); @@ -731,7 +735,8 @@ define([ 'paste': function (e) { setTimeout(function() { var name = me.cutDocName(me.labelDocName.val()); - me.setDocTile(name); }); + me.setDocTile(name); + }); } }); @@ -754,11 +759,26 @@ define([ return (name.substring(idx) == this.fileExtention) ? name.substring(0, idx) : name ; }, - setDocTile: function(name){ - this.labelDocName.val(name); - var ln = this.withoutExt ? this.fileExtention.length : 0; - this.labelDocName.attr('size', name.length + ln > 10 ? name.length + ln : 10); + setDocTile: function(name){ + if(name) + this.labelDocName.val(name); + else + name = this.labelDocName.val(); + var width = this.getTextWidth(name); + (width>=0) && this.labelDocName.width(width); + }, + + getTextWidth: function(text) { + if (!this._testCanvas ) { + var font = (this.labelDocName.css('font-size') + ' ' + this.labelDocName.css('font-family')).trim(); + if (font) { + var canvas = document.createElement("canvas"); + this._testCanvas = canvas.getContext('2d'); + this._testCanvas.font = font; + } + } + return this._testCanvas ? this._testCanvas.measureText(text).width : -1; }, setUserName: function(name) { diff --git a/apps/common/main/resources/less/header.less b/apps/common/main/resources/less/header.less index 5bd584d653..aff75f7632 100644 --- a/apps/common/main/resources/less/header.less +++ b/apps/common/main/resources/less/header.less @@ -51,6 +51,8 @@ &.right { flex-grow: 1; + flex-shrink: 0; + overflow: hidden; } .status-label { @@ -94,6 +96,9 @@ flex-grow: 1; display: flex; justify-content: center; + padding: 4px 2px; + overflow: hidden; + flex-shrink: 0; } #rib-doc-name { @@ -102,13 +107,20 @@ overflow: hidden; min-width: 50px; text-align: center; - color: @text-toolbar-header-ie; color: @text-toolbar-header; background-color: transparent; border: 0 none; + padding: 1px 5px; cursor: default; - line-height: 32px; + line-height: 24px; + + &:hover,&:focus { + box-shadow: 0 0 0 1px @highlight-header-button-hover-ie; + box-shadow: 0 0 0 1px @highlight-header-button-hover; + border-radius: 1px; + cursor: text; + } } #rib-save-status { @@ -487,6 +499,7 @@ display: flex; justify-content: center; overflow: hidden; + padding: 4px 2px; } #title-doc-name { @@ -495,10 +508,21 @@ overflow: hidden; text-align: center; font-size: 12px; - line-height: 28px; + line-height: 24px; + padding: 1px 5px; background-color: transparent; border: 0 none; cursor: default; + + &:hover,&:focus{ + box-shadow: 0 0 0 1px @highlight-header-button-hover-ie; + box-shadow: 0 0 0 1px @highlight-header-button-hover; + /*border:@highlight-header-button-hover-ie solid 1px; + border:@highlight-header-button-hover solid 1px;*/ + border-radius: 1px; + cursor: text; + } + } .lr-separator { @@ -510,7 +534,7 @@ .inner-box-icon.crypted { width: 20px; position: relative; - + margin-right: 1px; > svg { position: absolute; width: 20px; diff --git a/apps/common/main/resources/less/toolbar.less b/apps/common/main/resources/less/toolbar.less index 2f90adc502..87c5615048 100644 --- a/apps/common/main/resources/less/toolbar.less +++ b/apps/common/main/resources/less/toolbar.less @@ -60,6 +60,7 @@ position: relative; overflow: hidden; display: flex; + flex-shrink: 1; > ul { padding: 4px 0 0; @@ -544,6 +545,10 @@ #rib-doc-name { color: @text-normal-ie; color: @text-normal; + &:hover,&:focus { + box-shadow: 0 0 0 1px @highlight-button-hover-ie; + box-shadow: 0 0 0 1px @highlight-button-hover; + } } &.editor-native-color { @@ -555,7 +560,7 @@ } &.style-skip-docname .toolbar { - #box-doc-name > label { + #box-doc-name > input { display: none; } } diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index cc29c19098..137b3afe60 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -473,6 +473,9 @@ define([ docInfo.put_Lang(this.editorConfig.lang); docInfo.put_Mode(this.editorConfig.mode); + if (this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.mode!==undefined) + docInfo.put_CoEditingMode(this.editorConfig.coEditing.mode); + var enable = !this.editorConfig.customization || (this.editorConfig.customization.macros!==false); docInfo.asc_putIsEnabledMacroses(!!enable); enable = !this.editorConfig.customization || (this.editorConfig.customization.plugins!==false); @@ -1564,9 +1567,8 @@ define([ Common.NotificationCenter.on('comments:showdummy', _.bind(this.onShowDummyComment, this)); // change = true by default in editor - this.appOptions.canLiveView = !!params.asc_getLiveViewerSupport() && (this.editorConfig.mode === 'view') && !isPDFViewer; // viewer: change=false when no flag canLiveViewer (i.g. old license), change=true by default when canLiveViewer==true this.appOptions.canChangeCoAuthoring = this.appOptions.isEdit && this.appOptions.canCoAuthoring && !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.change===false) || - this.appOptions.canLiveView && !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.change===false); + !this.appOptions.isEdit && !this.appOptions.isRestrictedEdit && (this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.change===true) ; this.loadCoAuthSettings(); this.applyModeCommonElements(); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 9f12663c80..cca7e3d99b 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -430,10 +430,8 @@ define([ docInfo.put_Lang(this.editorConfig.lang); docInfo.put_Mode(this.editorConfig.mode); - var coEditMode = !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object') ? 'fast' : // fast by default - this.editorConfig.mode === 'view' && this.editorConfig.coEditing.change!==false ? 'fast' : // if can change mode in viewer - set fast for using live viewer - this.editorConfig.coEditing.mode || 'fast'; - docInfo.put_CoEditingMode(coEditMode); + if (this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.mode!==undefined) + docInfo.put_CoEditingMode(this.editorConfig.coEditing.mode); var enable = !this.editorConfig.customization || (this.editorConfig.customization.macros!==false); docInfo.asc_putIsEnabledMacroses(!!enable); @@ -1210,9 +1208,8 @@ define([ this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features, this.appOptions.canBrandingExt); // change = true by default in editor - this.appOptions.canLiveView = !!params.asc_getLiveViewerSupport() && (this.editorConfig.mode === 'view'); // viewer: change=false when no flag canLiveViewer (i.g. old license), change=true by default when canLiveViewer==true this.appOptions.canChangeCoAuthoring = this.appOptions.isEdit && this.appOptions.canCoAuthoring && !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.change===false) || - this.appOptions.canLiveView && !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.change===false); + !this.appOptions.isEdit && !this.appOptions.isRestrictedEdit && (this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.change===true) ; this.loadCoAuthSettings(); this.applyModeCommonElements(); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 3cbd72ca06..8598335bdf 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -504,10 +504,8 @@ define([ docInfo.put_Lang(this.editorConfig.lang); docInfo.put_Mode(this.editorConfig.mode); - var coEditMode = !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object') ? 'fast' : // fast by default - this.editorConfig.mode === 'view' && this.editorConfig.coEditing.change!==false ? 'fast' : // if can change mode in viewer - set fast for using live viewer - this.editorConfig.coEditing.mode || 'fast'; - docInfo.put_CoEditingMode(coEditMode); + if (this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.mode!==undefined) + docInfo.put_CoEditingMode(this.editorConfig.coEditing.mode); var enable = !this.editorConfig.customization || (this.editorConfig.customization.macros!==false); docInfo.asc_putIsEnabledMacroses(!!enable); @@ -1297,11 +1295,10 @@ define([ this.appOptions.canHelp = !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.help===false); this.appOptions.isRestrictedEdit = !this.appOptions.isEdit && this.appOptions.canComments; - // change = true by default in editor - this.appOptions.canLiveView = !!params.asc_getLiveViewerSupport() && (this.editorConfig.mode === 'view'); // viewer: change=false when no flag canLiveViewer (i.g. old license), change=true by default when canLiveViewer==true + // change = true by default in editor, change = false by default in viewer this.appOptions.canChangeCoAuthoring = this.appOptions.isEdit && !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle) && this.appOptions.canCoAuthoring && - !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.change===false) || - this.appOptions.canLiveView && !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.change===false); + !(this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.change===false) || + !this.appOptions.isEdit && !this.appOptions.isRestrictedEdit && (this.editorConfig.coEditing && typeof this.editorConfig.coEditing == 'object' && this.editorConfig.coEditing.change===true) ; if (!this.appOptions.isEditDiagram && !this.appOptions.isEditMailMerge && !this.appOptions.isEditOle) { this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);