JGonera has uploaded a new change for review.
https://gerrit.wikimedia.org/r/97845
Change subject: Don't ask about abandoning edit if no changes present
......................................................................
Don't ask about abandoning edit if no changes present
Update micro.autosize in the process.
Bug: 57377
Change-Id: I4e1f3fb0dee6e1e39306d8114e9e0d72af667b36
---
M javascripts/externals/micro.autosize.js
M javascripts/modules/editorNew/EditorOverlay.js
2 files changed, 18 insertions(+), 19 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/45/97845/1
diff --git a/javascripts/externals/micro.autosize.js
b/javascripts/externals/micro.autosize.js
index 2066ee3..dc76d65 100644
--- a/javascripts/externals/micro.autosize.js
+++ b/javascripts/externals/micro.autosize.js
@@ -6,23 +6,24 @@
;(function($) {
var $window = $(window);
+ function resize() {
+ var $el = $(this), scrollTop;
+
+ if ($el.prop('scrollHeight')) {
+ scrollTop = $window.scrollTop();
+ $el.
+ css('height', 'auto').
+ // can't reuse prop('scrollHeight') because we need the current value
+ css('height', ($el.prop('scrollHeight') + 2) + 'px');
+ $window.scrollTop(scrollTop);
+ }
+ }
+
$.fn.microAutosize = function() {
- var $el = this;
-
- $el.on('input', function() {
- var scrollTop;
-
- if ($el.prop('scrollHeight')) {
- scrollTop = $window.scrollTop();
- $el.
- css('height', 'auto').
- // can't reuse prop('scrollHeight') because we need the current value
- css('height', ($el.prop('scrollHeight') + 2) + 'px');
- $window.scrollTop(scrollTop);
- }
- });
-
- return $el;
+ // setTimeout to let the textarea redraw if used just after val()
+ setTimeout($.proxy(resize, this), 0);
+ this.on('input', resize);
+ return this;
};
}(jQuery));
diff --git a/javascripts/modules/editorNew/EditorOverlay.js
b/javascripts/modules/editorNew/EditorOverlay.js
index 87fa661..9b91fea 100644
--- a/javascripts/modules/editorNew/EditorOverlay.js
+++ b/javascripts/modules/editorNew/EditorOverlay.js
@@ -78,7 +78,6 @@
this.$spinner = this.$( '.spinner' );
this.$preview = this.$( '.preview' );
this.$content = this.$( 'textarea' ).
- microAutosize().
on( 'input', function() {
self.api.setContent(
self.$content.val() );
self.$( '.continue, .submit' ).prop(
'disabled', false );
@@ -184,8 +183,7 @@
self.$content.
show().
val( content ).
- trigger( 'input' );
- self.$( '.continue, .submit' ).prop(
'disabled', true );
+ microAutosize();
self.$spinner.hide();
} ).
fail( function( error ) {
--
To view, visit https://gerrit.wikimedia.org/r/97845
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e1f3fb0dee6e1e39306d8114e9e0d72af667b36
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: JGonera <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits