jenkins-bot has submitted this change and it was merged.

Change subject: Make the tools pane sticky while scrolling
......................................................................


Make the tools pane sticky while scrolling

Change-Id: I91493abe944581d897f27a35c28ede1d559f98bf
---
M Resources.php
M modules/tools/ext.cx.tools.js
A modules/tools/styles/ext.cx.tools.less
3 files changed, 28 insertions(+), 0 deletions(-)

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



diff --git a/Resources.php b/Resources.php
index 426fba9..2e3e9ac 100644
--- a/Resources.php
+++ b/Resources.php
@@ -77,6 +77,9 @@
 
 $wgResourceModules['ext.cx.tool'] = array(
        'scripts' => 'tools/ext.cx.tools.js',
+       'styles' => array(
+               'tools/styles/ext.cx.tools.less',
+       ),
        'messages' => array(
                'cx-tools-instructions-title',
                'cx-tools-instructions-text1',
@@ -112,3 +115,4 @@
        'scripts' => 'eventlogging/ext.cx.eventlogging.js',
        'dependencies' => 'schema.ContentTranslation',
 ) + $resourcePaths;
+
diff --git a/modules/tools/ext.cx.tools.js b/modules/tools/ext.cx.tools.js
index 5ea2a31..91bfad0 100644
--- a/modules/tools/ext.cx.tools.js
+++ b/modules/tools/ext.cx.tools.js
@@ -20,6 +20,7 @@
                this.$container = $( element );
                this.options = $.extend( true, {}, $.fn.cxTools.defaults, 
options );
                this.init();
+               this.listen();
        }
 
        ContentTranslationTools.prototype.init = function () {
@@ -28,6 +29,10 @@
 
        ContentTranslationTools.prototype.render = function () {
                this.$container.append( this.helpMessage() );
+       };
+
+       ContentTranslationTools.prototype.listen = function () {
+               $( window ).scroll( $.proxy( this.scroll, this ) );
        };
 
        ContentTranslationTools.prototype.helpMessage = function () {
@@ -57,6 +62,18 @@
                return $content;
        };
 
+       ContentTranslationTools.prototype.scroll = function () {
+               var scrollTop = $( window ).scrollTop(),
+                       // Use the .prev() element as the reference 
point(anchor)
+                       offsetTop = this.$container.prev().offset().top;
+
+               if ( scrollTop > offsetTop ) {
+                       this.$container.addClass( 'sticky' );
+               } else if ( scrollTop <= offsetTop ) {
+                       this.$container.removeClass( 'sticky' );
+               }
+       };
+
        $.fn.cxTools = function ( options ) {
                return this.each( function () {
                        var $this = $( this ),
diff --git a/modules/tools/styles/ext.cx.tools.less 
b/modules/tools/styles/ext.cx.tools.less
new file mode 100644
index 0000000..3c52e48
--- /dev/null
+++ b/modules/tools/styles/ext.cx.tools.less
@@ -0,0 +1,7 @@
+@import "../../base/styles/grid/agora-grid";
+
+.sticky {
+       position: fixed;
+       top: 0;
+       right: 0;
+}
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I91493abe944581d897f27a35c28ede1d559f98bf
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: KartikMistry <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to