mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-16 20:58:28 +00:00
Merge "New topic tool: Show empty title warning only when focussing the description"
This commit is contained in:
commit
22bb9d9b42
|
@ -102,7 +102,7 @@ NewTopicController.prototype.setupReplyWidget = function ( replyWidget, data ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sectionTitle.connect( this, { change: 'onSectionTitleChange' } );
|
this.sectionTitle.connect( this, { change: 'onSectionTitleChange' } );
|
||||||
this.sectionTitle.$input.on( 'blur', this.onSectionTitleBlur.bind( this ) );
|
this.replyWidget.connect( this, { bodyFocus: 'onBodyFocus' } );
|
||||||
|
|
||||||
replyWidget.connect( this, {
|
replyWidget.connect( this, {
|
||||||
clear: 'clear',
|
clear: 'clear',
|
||||||
|
@ -247,19 +247,23 @@ NewTopicController.prototype.onSectionTitleChange = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle 'blur' events for the section title input.
|
* Handle 'focus' events for the description field (regardless of mode).
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
NewTopicController.prototype.onSectionTitleBlur = function () {
|
NewTopicController.prototype.onBodyFocus = function () {
|
||||||
var offsetBefore = this.replyWidget.$element.offset().top;
|
var offsetBefore = this.replyWidget.$element.offset().top;
|
||||||
|
var rootScrollable = OO.ui.Element.static.getRootScrollableElement( document.body );
|
||||||
|
var scrollBefore = rootScrollable.scrollTop;
|
||||||
|
|
||||||
this.checkSectionTitleValidity();
|
this.checkSectionTitleValidity();
|
||||||
|
|
||||||
var offsetChange = this.replyWidget.$element.offset().top - offsetBefore;
|
var offsetChange = this.replyWidget.$element.offset().top - offsetBefore;
|
||||||
// Ensure the rest of the widget doesn't move when the validation
|
// Ensure the rest of the widget doesn't move when the validation
|
||||||
// message is triggered by a blur. (T275923)
|
// message is triggered by a focus. (T275923)
|
||||||
window.scrollBy( 0, offsetChange );
|
// Browsers sometimes also scroll in response to focus events,
|
||||||
|
// so use the old scrollTop value for consistent results.
|
||||||
|
rootScrollable.scrollTop = scrollBefore + offsetChange;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,6 +45,7 @@ ReplyWidgetPlain.prototype.createReplyBodyWidget = function ( config ) {
|
||||||
textInput.$input.attr( 'aria-label', config.placeholder );
|
textInput.$input.attr( 'aria-label', config.placeholder );
|
||||||
// Fix jquery.ime position (T255191)
|
// Fix jquery.ime position (T255191)
|
||||||
textInput.$input.addClass( 'ime-position-inside' );
|
textInput.$input.addClass( 'ime-position-inside' );
|
||||||
|
|
||||||
return textInput;
|
return textInput;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,6 +90,7 @@ ReplyWidgetPlain.prototype.setup = function ( data ) {
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
this.replyBodyWidget.connect( this, { change: this.onInputChangeThrottled } );
|
this.replyBodyWidget.connect( this, { change: this.onInputChangeThrottled } );
|
||||||
|
this.replyBodyWidget.$input.on( 'focus', this.emit.bind( this, 'bodyFocus' ) );
|
||||||
|
|
||||||
this.replyBodyWidget.setValue( data.value || autosaveValue );
|
this.replyBodyWidget.setValue( data.value || autosaveValue );
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,10 @@ ReplyWidgetVisual.prototype.setup = function ( data ) {
|
||||||
this.replyBodyWidget.setDocument( htmlOrDoc );
|
this.replyBodyWidget.setDocument( htmlOrDoc );
|
||||||
|
|
||||||
target.once( 'surfaceReady', function () {
|
target.once( 'surfaceReady', function () {
|
||||||
|
target.getSurface().getView().connect( widget, {
|
||||||
|
focus: [ 'emit', 'bodyFocus' ]
|
||||||
|
} );
|
||||||
|
|
||||||
target.getSurface().getModel().setAutosaveDocId( widget.storagePrefix );
|
target.getSurface().getModel().setAutosaveDocId( widget.storagePrefix );
|
||||||
target.initAutosave();
|
target.initAutosave();
|
||||||
widget.afterSetup();
|
widget.afterSetup();
|
||||||
|
|
Loading…
Reference in a new issue