Bmansurov has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/165896

Change subject: Scroll to top of the editor with keyboard keys
......................................................................

Scroll to top of the editor with keyboard keys

Bug: 69092
Change-Id: I2e8ee7be9d7c66aaec2b20d35dd484fbfa2f824c
---
M javascripts/modules/editor/EditorOverlay.js
1 file changed, 19 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/96/165896/1

diff --git a/javascripts/modules/editor/EditorOverlay.js 
b/javascripts/modules/editor/EditorOverlay.js
index 0fc6152..2caed91 100644
--- a/javascripts/modules/editor/EditorOverlay.js
+++ b/javascripts/modules/editor/EditorOverlay.js
@@ -8,7 +8,8 @@
                Section = M.require( 'Section' ),
                EditorApi = M.require( 'modules/editor/EditorApi' ),
                AbuseFilterPanel = M.require( 'modules/editor/AbuseFilterPanel' 
),
-               EditorOverlay;
+               EditorOverlay,
+               $window = $( window);
 
        /**
         * @class EditorOverlay
@@ -54,7 +55,23 @@
                                on( 'input', function() {
                                        self.api.setContent( 
self.$content.val() );
                                        self.$( '.continue, .submit' ).prop( 
'disabled', false );
-                               } );
+                               } )
+                               .on( 'keydown', function( ev ) {
+                                       var keyCode = ev.which,
+                                               $overlayHeader = 
self.$el.find('.overlay-header-container');
+                                       // when up or left keys are pressed, 
make sure that the top of
+                                       // the editor is not covered by the 
overlay-header-container
+                                       if ( keyCode === 37 || keyCode == 38 ) {
+                                               console.log('1', 
self.$content.outerHeight(true) - self.$content.height());
+                                               console.log('2', 
$window.scrollTop());
+                                               console.log('3', 
$overlayHeader.outerHeight( true ));
+                                               if ( $window.scrollTop() - 
(self.$content.outerHeight(true) - self.$content.height()) <
+                                                       
$overlayHeader.outerHeight( true )
+                                               ) {
+                                                       $window.scrollTop ( 0 );
+                                               }
+                                       }
+                               });
                        if ( options.isAnon ) {
                                this.$anonWarning = this.$( '.anonwarning' );
                                this._showAnonWarning( options );

-- 
To view, visit https://gerrit.wikimedia.org/r/165896
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e8ee7be9d7c66aaec2b20d35dd484fbfa2f824c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <bmansu...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to