[MediaWiki-commits] [Gerrit] mediawiki/core[master]: RCFilters UI: Scroll the capsule to the top of the screen

2017-02-24 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/339794 )

Change subject: RCFilters UI: Scroll the capsule to the top of the screen
..


RCFilters UI: Scroll the capsule to the top of the screen

When the popup shows up, scroll the capsule widget to the top of
the screen.

Change-Id: I5366a8a0918bda0aabe1c97db252278c36a89347
---
M 
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js
1 file changed, 28 insertions(+), 1 deletion(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git 
a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js
 
b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js
index 50b7d15..2bd2f0e 100644
--- 
a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js
+++ 
b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js
@@ -11,6 +11,8 @@
 * @param {OO.ui.InputWidget} filterInput A filter input that focuses 
the capsule widget
 * @param {Object} config Configuration object
 * @cfg {jQuery} [$overlay] A jQuery object serving as overlay for 
popups
+* @cfg {number} [topScrollOffset=10] When scrolling the entire widget 
to the top, leave this
+*  much space (in pixels) above the widget.
 */
mw.rcfilters.ui.FilterCapsuleMultiselectWidget = function 
MwRcfiltersUiFilterCapsuleMultiselectWidget( controller, model, filterInput, 
config ) {
var title = new OO.ui.LabelWidget( {
@@ -29,8 +31,9 @@
 
this.controller = controller;
this.model = model;
-
this.filterInput = filterInput;
+
+   this.topScrollOffset = config.topScrollOffset || 10;
 
this.resetButton = new OO.ui.ButtonWidget( {
icon: 'trash',
@@ -51,6 +54,8 @@
itemUpdate: 'onModelItemUpdate',
highlightChange: 'onModelHighlightChange'
} );
+   this.popup.connect( this, { toggle: 'onPopupToggle' } );
+
// Add the filterInput as trigger
this.filterInput.$input
.on( 'focus', this.focus.bind( this ) );
@@ -163,6 +168,28 @@
};
 
/**
+* Respond to popup toggle event
+*
+* @param {boolean} isVisible Popup is visible
+*/
+   mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.onPopupToggle 
= function ( isVisible ) {
+   if ( isVisible ) {
+   this.scrollToTop();
+   }
+   };
+
+   /**
+* Scroll the capsule to the top of the screen
+*/
+   mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.scrollToTop = 
function () {
+   var container = 
OO.ui.Element.static.getClosestScrollableContainer( this.$element[ 0 ], 'y' );
+
+   $( container ).animate( {
+   scrollTop: this.$element.offset().top - 
this.topScrollOffset
+   } );
+   };
+
+   /**
 * Reevaluate the restore state for the widget between setting to 
defaults and clearing all filters
 */

mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.reevaluateResetRestoreState
 = function () {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5366a8a0918bda0aabe1c97db252278c36a89347
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo 
Gerrit-Reviewer: Catrope 
Gerrit-Reviewer: Jack Phoenix 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: RCFilters UI: Scroll the capsule to the top of the screen

2017-02-24 Thread Mooeypoo (Code Review)
Mooeypoo has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/339794 )

Change subject: RCFilters UI: Scroll the capsule to the top of the screen
..

RCFilters UI: Scroll the capsule to the top of the screen

When the popup shows up, scroll the capsule widget to the top of
the screen.

Change-Id: I5366a8a0918bda0aabe1c97db252278c36a89347
---
M 
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js
1 file changed, 28 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/94/339794/1

diff --git 
a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js
 
b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js
index 50b7d15..eab70dd 100644
--- 
a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js
+++ 
b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js
@@ -11,6 +11,8 @@
 * @param {OO.ui.InputWidget} filterInput A filter input that focuses 
the capsule widget
 * @param {Object} config Configuration object
 * @cfg {jQuery} [$overlay] A jQuery object serving as overlay for 
popups
+* @cfg {number} [topScrollOffset] An offset from the top of the 
scrollable container, when
+*  scrolling the entire capsule to the top.
 */
mw.rcfilters.ui.FilterCapsuleMultiselectWidget = function 
MwRcfiltersUiFilterCapsuleMultiselectWidget( controller, model, filterInput, 
config ) {
var title = new OO.ui.LabelWidget( {
@@ -29,8 +31,9 @@
 
this.controller = controller;
this.model = model;
-
this.filterInput = filterInput;
+
+   this.topScrollOffset = config.topScrollOffset || 10;
 
this.resetButton = new OO.ui.ButtonWidget( {
icon: 'trash',
@@ -51,6 +54,8 @@
itemUpdate: 'onModelItemUpdate',
highlightChange: 'onModelHighlightChange'
} );
+   this.popup.connect( this, { toggle: 'onPopupToggle' } );
+
// Add the filterInput as trigger
this.filterInput.$input
.on( 'focus', this.focus.bind( this ) );
@@ -163,6 +168,28 @@
};
 
/**
+* Respond to popup toggle event
+*
+* @param {boolean} isVisible Popup is visible
+*/
+   mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.onPopupToggle 
= function ( isVisible ) {
+   if ( isVisible ) {
+   this.scrollToTop();
+   }
+   };
+
+   /**
+* Scroll the capsule to the top of the screen
+*/
+   mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.scrollToTop = 
function () {
+   var container = 
OO.ui.Element.static.getClosestScrollableContainer( this.$element[ 0 ], 'y' );
+
+   $( container ).animate( {
+   scrollTop: this.$element.offset().top - 
this.topScrollOffset
+   } );
+   };
+
+   /**
 * Reevaluate the restore state for the widget between setting to 
defaults and clearing all filters
 */

mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.reevaluateResetRestoreState
 = function () {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5366a8a0918bda0aabe1c97db252278c36a89347
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo 

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