diff --git a/apps/common/main/lib/component/Button.js b/apps/common/main/lib/component/Button.js index cc142495a2..3f251628c4 100644 --- a/apps/common/main/lib/component/Button.js +++ b/apps/common/main/lib/component/Button.js @@ -494,9 +494,10 @@ define([ }, setMenu: function (m) { - if (this.rendered && m && _.isObject(m) && _.isFunction(m.render)){ + if (m && _.isObject(m) && _.isFunction(m.render)){ this.menu = m; - this.menu.render(this.cmpEl); + if (this.rendered) + this.menu.render(this.cmpEl); } } }); diff --git a/apps/common/main/lib/component/ComboBox.js b/apps/common/main/lib/component/ComboBox.js index 35f3ca96fe..24e147e2f4 100644 --- a/apps/common/main/lib/component/ComboBox.js +++ b/apps/common/main/lib/component/ComboBox.js @@ -84,7 +84,8 @@ define([ menuCls : '', menuStyle : '', displayField: 'displayValue', - valueField : 'value' + valueField : 'value', + scrollAlwaysVisible: false }, template: _.template([ @@ -117,6 +118,7 @@ define([ this.store = me.options.store || new Common.UI.ComboBoxStore(); this.displayField = me.options.displayField; this.valueField = me.options.valueField; + this.scrollAlwaysVisible = me.options.scrollAlwaysVisible; me.rendered = me.options.rendered || false; this.lastValue = null; @@ -216,7 +218,8 @@ define([ el: $('.dropdown-menu', this.cmpEl), minScrollbarLength: 40, scrollYMarginOffset: 30, - includePadding: true + includePadding: true, + alwaysVisibleY: this.scrollAlwaysVisible }, this.options.scroller)); } @@ -239,7 +242,8 @@ define([ el: $('.dropdown-menu', this.cmpEl), minScrollbarLength: 40, scrollYMarginOffset: 30, - includePadding: true + includePadding: true, + alwaysVisibleY: this.scrollAlwaysVisible }, this.options.scroller)); } @@ -542,7 +546,8 @@ define([ el: $('.dropdown-menu', this.cmpEl), minScrollbarLength : 40, scrollYMarginOffset: 30, - includePadding : true + includePadding : true, + alwaysVisibleY: this.scrollAlwaysVisible }, this.options.scroller)); } } diff --git a/apps/common/main/lib/extend/Bootstrap.js b/apps/common/main/lib/extend/Bootstrap.js index c9afd2e375..68d393da6b 100755 --- a/apps/common/main/lib/extend/Bootstrap.js +++ b/apps/common/main/lib/extend/Bootstrap.js @@ -186,6 +186,16 @@ function getParent($this) { return $parent && $parent.length ? $parent : $this.parent(); } +function clearMenus() { + $('.dropdown-toggle').each(function (e) { + var $parent = ($(this)).parent(); + if (!$parent.hasClass('open')) return; + $parent.trigger(e = $.Event('hide.bs.dropdown')); + if (e.isDefaultPrevented()) return; + $parent.removeClass('open').trigger('hidden.bs.dropdown'); + }) +} + $(document) .off('keydown.bs.dropdown.data-api') .on('keydown.bs.dropdown.data-api', '[data-toggle=dropdown], [role=menu]' , onDropDownKeyDown); @@ -206,9 +216,8 @@ $(document) } function onDropDownClick(e) { - if ((e.which == 1 || e.which == undefined) && !!clickDefHandler) { - clickDefHandler(e); - } + if (e.which == 1 || e.which == undefined) + clearMenus(); } if (!!clickDefHandler) { diff --git a/apps/documenteditor/main/app/util/define.js b/apps/common/main/lib/util/define.js similarity index 99% rename from apps/documenteditor/main/app/util/define.js rename to apps/common/main/lib/util/define.js index 10d4746d89..3a8b65df95 100644 --- a/apps/documenteditor/main/app/util/define.js +++ b/apps/common/main/lib/util/define.js @@ -31,11 +31,15 @@ * */ +if (Common === undefined) { + var Common = {}; +} + define(function(){ 'use strict'; - DE.define = {}; + Common.define = {}; - DE.define.c_oAscMathMainType = { + Common.define.c_oAscMathMainType = { Symbol : 0x00, Fraction : 0x01, Script : 0x02, @@ -56,7 +60,7 @@ define(function(){ 'use strict'; // equations types - DE.define.c_oAscMathType = { + Common.define.c_oAscMathType = { Symbol_pm : 0x00000000, Symbol_infinity : 0x00000001, Symbol_equals : 0x00000002, diff --git a/apps/common/main/resources/less/header.less b/apps/common/main/resources/less/header.less index 16033b3220..457b1a24b1 100644 --- a/apps/common/main/resources/less/header.less +++ b/apps/common/main/resources/less/header.less @@ -87,7 +87,7 @@ display: inline-block; padding: 2px 8px; - &.renamed { + &.renamed:hover { background-color: @app-header-bg-color-dark; } } diff --git a/apps/common/main/resources/less/history.less b/apps/common/main/resources/less/history.less index 6b5e10621b..340c64b37b 100644 --- a/apps/common/main/resources/less/history.less +++ b/apps/common/main/resources/less/history.less @@ -5,7 +5,7 @@ #history-header { position: absolute; - height: 45px; + height: 53px; left: 0; top: 0; right: 0; @@ -14,7 +14,7 @@ #history-btn-back { height: 27px; - margin-top: 8px; + margin-top: 15px; padding-top: 4px; padding-left: 20px; font-size: 13px; @@ -52,7 +52,7 @@ #history-list { height: 100%; overflow: hidden; - padding: 45px 0; + padding: 53px 0 45px 0; .item { display: block; diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 45b04c8c6b..30626e67f9 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -122,7 +122,7 @@ define([ setApi: function(api) { this.api = api; this.api.asc_registerCallback('asc_onReplaceAll', _.bind(this.onApiTextReplaced, this)); - this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiServerDisconnect, this)); + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiServerDisconnect, this, true)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiServerDisconnect, this)); /** coauthoring begin **/ if (this.mode.canCoAuthoring) { @@ -446,7 +446,7 @@ define([ } }, - onApiServerDisconnect: function() { + onApiServerDisconnect: function(disableDownload) { this.mode.isEdit = false; this.leftMenu.close(); @@ -456,7 +456,7 @@ define([ /** coauthoring end **/ this.leftMenu.btnPlugins.setDisabled(true); - this.leftMenu.getMenu('file').setMode({isDisconnected: true}); + this.leftMenu.getMenu('file').setMode({isDisconnected: true, disableDownload: !!disableDownload}); if ( this.dlgSearch ) { this.leftMenu.btnSearch.toggle(false, true); this.dlgSearch['hide'](); diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index ce79881406..fda17c60e1 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -163,8 +163,10 @@ define([ $(document.body).on('blur', 'input, textarea', function(e) { if (!me.isModalShowed) { - if (!/area_id/.test(e.target.id) && $(e.target).parent().find(e.relatedTarget).length<1 /* When focus in combobox goes from input to it's menu button or menu items */ - || !e.relatedTarget) { + if (!e.relatedTarget || + !/area_id/.test(e.target.id) && $(e.target).parent().find(e.relatedTarget).length<1 /* Check if focus in combobox goes from input to it's menu button or menu items */ + && (e.relatedTarget.localName != 'input' || !/form-control/.test(e.relatedTarget.className)) /* Check if focus goes to text input with class "form-control" */ + && (e.relatedTarget.localName != 'textarea' || /area_id/.test(e.relatedTarget.id))) /* Check if focus goes to textarea, but not to "area_id" */ { me.api.asc_enableKeyEvents(true); if (/msg-reply/.test(e.target.className)) me.dontCloseDummyComment = false; @@ -421,39 +423,41 @@ define([ var changes = version.changes, change, i; if (changes && changes.length>0) { - arrVersions[arrVersions.length-1].set('changeid', changes.length-1); arrVersions[arrVersions.length-1].set('docIdPrev', docIdPrev); - arrVersions[arrVersions.length-1].set('hasChanges', changes.length>1); - for (i=changes.length-2; i>=0; i--) { - change = changes[i]; + if (!_.isEmpty(version.serverVersion) && version.serverVersion == this.appOptions.buildVersion) { + arrVersions[arrVersions.length-1].set('changeid', changes.length-1); + arrVersions[arrVersions.length-1].set('hasChanges', changes.length>1); + for (i=changes.length-2; i>=0; i--) { + change = changes[i]; - user = usersStore.findUser(change.user.id); - if (!user) { - user = new Common.Models.User({ - id : change.user.id, - username : change.user.name, - colorval : Asc.c_oAscArrUserColors[usersCnt], - color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++]) - }); - usersStore.add(user); + user = usersStore.findUser(change.user.id); + if (!user) { + user = new Common.Models.User({ + id : change.user.id, + username : change.user.name, + colorval : Asc.c_oAscArrUserColors[usersCnt], + color : this.generateUserColor(Asc.c_oAscArrUserColors[usersCnt++]) + }); + usersStore.add(user); + } + + arrVersions.push(new Common.Models.HistoryVersion({ + version: version.versionGroup, + revision: version.version, + changeid: i, + userid : change.user.id, + username : change.user.name, + usercolor: user.get('color'), + created: change.created, + docId: version.key, + docIdPrev: docIdPrev, + selected: false, + canRestore: this.appOptions.canHistoryRestore, + isRevision: false, + isVisible: true + })); + arrColors.push(user.get('colorval')); } - - arrVersions.push(new Common.Models.HistoryVersion({ - version: version.versionGroup, - revision: version.version, - changeid: i, - userid : change.user.id, - username : change.user.name, - usercolor: user.get('color'), - created: change.created, - docId: version.key, - docIdPrev: docIdPrev, - selected: false, - canRestore: this.appOptions.canHistoryRestore, - isRevision: false, - isVisible: true - })); - arrColors.push(user.get('colorval')); } } else if (ver==0 && versions.length==1) { arrVersions[arrVersions.length-1].set('docId', version.key + '1'); @@ -520,7 +524,11 @@ define([ toolbarView.btnInsertShape.toggle(false, false); toolbarView.btnInsertText.toggle(false, false); } - + if (this.appOptions.isEdit && toolbarView && toolbarView.btnHighlightColor.pressed && + ( !_.isObject(arguments[1]) || arguments[1].id !== 'id-toolbar-btn-highlight')) { + this.api.SetMarkerFormat(false); + toolbarView.btnHighlightColor.toggle(false, false); + } application.getController('DocumentHolder').getView('DocumentHolder').focus(); if (this.api) { @@ -872,12 +880,12 @@ define([ documentHolderController.getView('DocumentHolder').createDelayedElements(); me.loadLanguages(); - rightmenuController.createDelayedElements(); - var shapes = me.api.asc_getPropertyEditorShapes(); if (shapes) me.fillAutoShapes(shapes[0], shapes[1]); + rightmenuController.createDelayedElements(); + me.updateThemeColors(); toolbarController.activateControls(); if (me.needToUpdateVersion) @@ -948,6 +956,10 @@ define([ } this.permissions.review = (this.permissions.review === undefined) ? (this.permissions.edit !== false) : this.permissions.review; + + if (params.asc_getRights() !== Asc.c_oRights.Edit) + this.permissions.edit = this.permissions.review = false; + this.appOptions.canAnalytics = params.asc_getIsAnalyticsEnable(); this.appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success); this.appOptions.isLightVersion = params.asc_getIsLight(); @@ -972,6 +984,7 @@ define([ this.appOptions.canEditStyles = this.appOptions.canLicense && this.appOptions.canEdit; this.appOptions.canPrint = (this.permissions.print !== false); this.appOptions.canRename = !!this.permissions.rename; + this.appOptions.buildVersion = params.asc_getBuildVersion(); var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType); this.appOptions.canDownloadOrigin = !this.appOptions.nativeApp && this.permissions.download !== false && (type && typeof type[1] === 'string'); @@ -1195,7 +1208,7 @@ define([ break; case Asc.c_oAscError.ID.CoAuthoringDisconnect: - config.msg = (this.appOptions.isEdit) ? this.errorCoAuthoringDisconnect : this.errorViewerDisconnect; + config.msg = this.errorViewerDisconnect; break; case Asc.c_oAscError.ID.ConvertationPassword: @@ -1964,7 +1977,7 @@ define([ textNoLicenseTitle: 'ONLYOFFICE open source version', warnNoLicense: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.', textContactUs: 'Contact sales', - errorViewerDisconnect: 'Connection is lost. You can still view the document,
but will not be able to download until the connection is restored.', + errorViewerDisconnect: 'Connection is lost. You can still view the document,
but will not be able to download or print until the connection is restored.', warnLicenseExp: 'Your license has expired.
Please update your license and refresh the page.', titleLicenseExp: 'License expired', openErrorText: 'An error has occurred while opening the file', diff --git a/apps/documenteditor/main/app/controller/RightMenu.js b/apps/documenteditor/main/app/controller/RightMenu.js index 8508b08a19..c20fdca499 100644 --- a/apps/documenteditor/main/app/controller/RightMenu.js +++ b/apps/documenteditor/main/app/controller/RightMenu.js @@ -167,14 +167,15 @@ define([ this._settings[Common.Utils.documentSettingsType.MailMerge].locked = !can_add_table || in_equation; } - var lastactive = -1, currentactive, priorityactive = -1; + var lastactive = -1, currentactive, priorityactive = -1, + activePane = this.rightmenu.GetActivePane(); for (i=0; i0) { var open = Common.localStorage.getItem("de-hide-right-settings"); diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index c2f40c4ad8..a38741c385 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -46,8 +46,8 @@ define([ 'common/main/lib/view/CopyWarningDialog', 'common/main/lib/view/ImageFromUrlDialog', 'common/main/lib/view/InsertTableDialog', + 'common/main/lib/util/define', 'documenteditor/main/app/view/Toolbar', - 'documenteditor/main/app/util/define', 'documenteditor/main/app/view/HyperlinkSettingsDialog', 'documenteditor/main/app/view/DropcapSettingsAdvanced', 'documenteditor/main/app/view/MailMergeRecepients', @@ -304,7 +304,7 @@ define([ this.api.asc_registerCallback('asc_onMarkerFormatChanged', _.bind(this.onApiStartHighlight, this)); this.api.asc_registerCallback('asc_onTextHighLight', _.bind(this.onApiHighlightColor, this)); this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this)); - this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this)); + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiCoAuthoringDisconnect, this, true)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); this.api.asc_registerCallback('asc_onCanCopyCut', _.bind(this.onApiCanCopyCut, this)); this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onMathTypes, this)); @@ -2291,32 +2291,32 @@ define([ // [translate, count cells, scroll] - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.Symbol ] = [this.textSymbols, 11]; - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.Fraction ] = [this.textFraction, 4]; - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.Script ] = [this.textScript, 4]; - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.Radical ] = [this.textRadical, 4]; - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.Integral ] = [this.textIntegral, 3, true]; - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.LargeOperator] = [this.textLargeOperator, 5, true]; - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.Bracket ] = [this.textBracket, 4, true]; - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.Function ] = [this.textFunction, 3, true]; - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.Accent ] = [this.textAccent, 4]; - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.LimitLog ] = [this.textLimitAndLog, 3]; - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.Operator ] = [this.textOperator, 4]; - c_oAscMathMainTypeStrings[DE.define.c_oAscMathMainType.Matrix ] = [this.textMatrix, 4, true]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.Symbol ] = [this.textSymbols, 11]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.Fraction ] = [this.textFraction, 4]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.Script ] = [this.textScript, 4]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.Radical ] = [this.textRadical, 4]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.Integral ] = [this.textIntegral, 3, true]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.LargeOperator] = [this.textLargeOperator, 5, true]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.Bracket ] = [this.textBracket, 4, true]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.Function ] = [this.textFunction, 3, true]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.Accent ] = [this.textAccent, 4]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.LimitLog ] = [this.textLimitAndLog, 3]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.Operator ] = [this.textOperator, 4]; + c_oAscMathMainTypeStrings[Common.define.c_oAscMathMainType.Matrix ] = [this.textMatrix, 4, true]; // equations sub groups // equations types var translationTable = {}, name = '', translate = ''; - for (name in DE.define.c_oAscMathType) { - if (DE.define.c_oAscMathType.hasOwnProperty(name)) { + for (name in Common.define.c_oAscMathType) { + if (Common.define.c_oAscMathType.hasOwnProperty(name)) { var arr = name.split('_'); if (arr.length==2 && arr[0]=='Symbol') { translate = 'txt' + arr[0] + '_' + arr[1].toLocaleLowerCase(); } else translate = 'txt' + name; - translationTable[DE.define.c_oAscMathType[name]] = this[translate]; + translationTable[Common.define.c_oAscMathType[name]] = this[translate]; } } @@ -2554,7 +2554,7 @@ define([ me.api.SetMarkerFormat(true, true, parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)); } - Common.NotificationCenter.trigger('edit:complete', me.toolbar); + Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnHighlightColor); Common.component.Analytics.trackEvent('ToolBar', 'Highlight Color'); }, @@ -2592,8 +2592,8 @@ define([ }); }, - onApiCoAuthoringDisconnect: function() { - this.toolbar.setMode({isDisconnected:true}); + onApiCoAuthoringDisconnect: function(disableDownload) { + this.toolbar.setMode({isDisconnected:true, disableDownload: !!disableDownload}); this.editMode = false; }, diff --git a/apps/documenteditor/main/app/template/StatusBar.template b/apps/documenteditor/main/app/template/StatusBar.template index a2bc061a93..d46ad16581 100644 --- a/apps/documenteditor/main/app/template/StatusBar.template +++ b/apps/documenteditor/main/app/template/StatusBar.template @@ -1,7 +1,7 @@
- +