diff --git a/apps/common/main/lib/component/TreeView.js b/apps/common/main/lib/component/TreeView.js index d8b645e2c..8f32ea245 100644 --- a/apps/common/main/lib/component/TreeView.js +++ b/apps/common/main/lib/component/TreeView.js @@ -264,6 +264,22 @@ define([ expandToLevel: function(expandLevel) { this.store.expandToLevel(expandLevel); this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible}); + }, + + expandRecord: function(record) { + if (record) { + record.set('isExpanded', true); + this.store.expandSubItems(record); + this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible}); + } + }, + + collapseRecord: function(record) { + if (record) { + record.set('isExpanded', false); + this.store.collapseSubItems(record); + this.scroller.update({minScrollbarLength: 40, alwaysVisibleY: this.scrollAlwaysVisible}); + } } } })()); diff --git a/apps/common/main/resources/less/asc-mixins.less b/apps/common/main/resources/less/asc-mixins.less index 8540da251..dc4eda888 100644 --- a/apps/common/main/resources/less/asc-mixins.less +++ b/apps/common/main/resources/less/asc-mixins.less @@ -98,7 +98,7 @@ .button-otherstates-icon(@icon-class, @icon-size) { .btn { &:active, &.active { - &:not(:disabled):not(.disabed) { + &:not(:disabled):not(.disabled) { > .@{icon-class} { @iconsize: -1*@icon-size; diff --git a/apps/common/main/resources/less/input.less b/apps/common/main/resources/less/input.less index ee527b6ab..86e89185a 100644 --- a/apps/common/main/resources/less/input.less +++ b/apps/common/main/resources/less/input.less @@ -47,20 +47,20 @@ position: relative; } - &.error { - input { - border-color: @brand-danger; - } - - .input-error { - display: block; - } - } - &.form-control:focus, .form-control:focus { border-color: @gray-darker; } + + &.error { + input:not([disabled]) { + border-color: @brand-danger; + } + + input:not([disabled]) + .input-error { + display: block; + } + } } input:required:focus:invalid, diff --git a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js index 0d7f8c0c2..c0a739ef5 100644 --- a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js @@ -67,19 +67,22 @@ define([ }, options || {}); this.template = [ - '
', + '
', '
', '', '', '
', '', '', '
', '', @@ -134,6 +137,16 @@ define([ return (urltype>0) ? true : me.txtNotUrl; } }); + me.inputUrl._input.on('input', function (e) { + me.isInputFirstChange && me.inputUrl.showError(); + me.isInputFirstChange = false; + var val = $(e.target).val(); + if (me.isAutoUpdate) { + me.inputDisplay.setValue(val); + me.isTextChanged = true; + } + me.btnOk.setDisabled($.trim(val)==''); + }); me.inputDisplay = new Common.UI.InputField({ el : $('#id-dlg-hyperlink-display'), @@ -143,6 +156,9 @@ define([ }).on('changed:after', function() { me.isTextChanged = true; }); + me.inputDisplay._input.on('input', function (e) { + me.isAutoUpdate = ($(e.target).val()==''); + }); me.inputTip = new Common.UI.InputField({ el : $('#id-dlg-hyperlink-tip'), @@ -194,6 +210,7 @@ define([ hasParent: false, isEmptyItem: false, isNotHeader: false, + type: Asc.c_oAscHyperlinkAnchor.Heading, hasSubItems: false })); @@ -226,6 +243,7 @@ define([ hasParent: false, isEmptyItem: false, isNotHeader: false, + type: Asc.c_oAscHyperlinkAnchor.Bookmark, hasSubItems: false })); @@ -247,20 +265,33 @@ define([ } } store.reset(arr); + this.internalList.collapseAll(); } var rec = this.internalList.getSelectedRec(); this.btnOk.setDisabled(!rec || rec.get('level')==0 && rec.get('index')>0); - } else - this.btnOk.setDisabled(false); + this.btnOk.setDisabled($.trim(this.inputUrl.getValue())==''); }, onLinkTypeClick: function(type, btn, event) { this.ShowHideElem(type); + if (this.isAutoUpdate) { + if (type==c_oHyperlinkType.InternalLink) { + var rec = this.internalList.getSelectedRec(); + this.inputDisplay.setValue(rec && (rec.get('level') || rec.get('index')==0)? rec.get('name') : ''); + } else { + this.inputDisplay.setValue(this.inputUrl.getValue()); + } + this.isTextChanged = true; + } }, onSelectItem: function(picker, item, record, e){ this.btnOk.setDisabled(record.get('level')==0 && record.get('index')>0); + if (this.isAutoUpdate) { + this.inputDisplay.setValue((record.get('level') || record.get('index')==0) ? record.get('name') : ''); + this.isTextChanged = true; + } }, show: function() { @@ -288,24 +319,31 @@ define([ } else { me.inputUrl.setValue(''); } + this.btnOk.setDisabled($.trim(this.inputUrl.getValue())==''); } else { 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) + var rec = this.internalList.store.findWhere({type: Asc.c_oAscHyperlinkAnchor.Heading, headingParagraph: props.get_Heading() }); + if (rec) { + this.internalList.expandRecord(this.internalList.store.at(1)); this.internalList.scrollToRecord(this.internalList.selectRecord(rec)); + } } else { var rec = this.internalList.store.findWhere({type: Asc.c_oAscHyperlinkAnchor.Bookmark, name: bookmark}); - if (rec) + if (rec) { + this.internalList.expandRecord(this.internalList.store.findWhere({type: Asc.c_oAscHyperlinkAnchor.Bookmark, level: 0})); this.internalList.scrollToRecord(this.internalList.selectRecord(rec)); + } } + var rec = this.internalList.getSelectedRec(); + this.btnOk.setDisabled(!rec || rec.get('level')==0 && rec.get('index')>0); } if (props.get_Text() !== null) { me.inputDisplay.setValue(props.get_Text()); me.inputDisplay.setDisabled(false); + me.isAutoUpdate = (me.inputDisplay.getValue()=='' || type == c_oHyperlinkType.WebLink && me.inputUrl.getValue()==me.inputDisplay.getValue()); } else { me.inputDisplay.setValue(this.textDefault); me.inputDisplay.setDisabled(true); @@ -321,9 +359,10 @@ define([ getSettings: function () { var me = this, props = new Asc.CHyperlinkProperty(), - display = ''; + display = '', + type = this.btnExternal.isActive() ? c_oHyperlinkType.WebLink : c_oHyperlinkType.InternalLink; - if (this.btnExternal.isActive()) {//WebLink + if (type==c_oHyperlinkType.WebLink) {//WebLink var url = $.trim(me.inputUrl.getValue()); if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) ) @@ -346,8 +385,8 @@ define([ } } - if (!me.inputDisplay.isDisabled() && ( this.isTextChanged || _.isEmpty(me.inputDisplay.getValue()))) { - if (_.isEmpty(me.inputDisplay.getValue())) + if (!me.inputDisplay.isDisabled() && ( me.isTextChanged || _.isEmpty(me.inputDisplay.getValue()))) { + if (_.isEmpty(me.inputDisplay.getValue()) || type==c_oHyperlinkType.WebLink && me.isAutoUpdate) me.inputDisplay.setValue(display); props.put_Text(me.inputDisplay.getValue()); } else { @@ -374,6 +413,7 @@ define([ if (state == 'ok') { if (this.btnExternal.isActive()) {//WebLink if (this.inputUrl.checkValidate() !== true) { + this.isInputFirstChange = true; this.inputUrl.cmpEl.find('input').focus(); return; } diff --git a/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js b/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js index 47fe2fda7..b06c3a42f 100644 --- a/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js @@ -50,9 +50,8 @@ var c_oHyperlinkType = { define([ 'common/main/lib/util/utils', 'common/main/lib/component/InputField', - 'common/main/lib/component/ComboBox', - 'common/main/lib/component/RadioBox', - 'common/main/lib/component/Window' + 'common/main/lib/component/Window', + 'common/main/lib/component/TreeView' ], function () { 'use strict'; PE.Views.HyperlinkSettingsDialog = Common.UI.Window.extend(_.extend({ @@ -70,7 +69,7 @@ define([ }, options || {}); this.template = [ - '
', + '
', '
', '', '', @@ -81,13 +80,11 @@ define([ '
', '', '
', - '