Santhosh has uploaded a new change for review.

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

Change subject: Simplify the ext.ca.dashboard module
......................................................................

Simplify the ext.ca.dashboard module

* Remove unused/unwanted plugin definition
* Remove unused/unwanted options argument
* Simplify the scroll handler

Change-Id: I09c345318962f2acdea716a0f78262a456c8782b
---
M modules/dashboard/ext.cx.dashboard.js
1 file changed, 10 insertions(+), 28 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/64/259464/1

diff --git a/modules/dashboard/ext.cx.dashboard.js 
b/modules/dashboard/ext.cx.dashboard.js
index 6e277d8..f348fab 100644
--- a/modules/dashboard/ext.cx.dashboard.js
+++ b/modules/dashboard/ext.cx.dashboard.js
@@ -13,9 +13,8 @@
         *
         * @class
         */
-       function CXDashboard( element, siteMapper, options ) {
+       function CXDashboard( element, siteMapper ) {
                this.$container = $( element );
-               this.options = $.extend( true, {}, $.fn.cxDashboard.defaults, 
options );
                this.siteMapper = siteMapper;
                this.$header = null;
                this.$sidebar = null;
@@ -27,7 +26,6 @@
                this.$sourceLanguageFilter = null;
                this.$targetLanguageFilter = null;
                this.$cta = null;
-               this.init();
        }
 
        CXDashboard.prototype.init = function () {
@@ -340,37 +338,21 @@
        };
 
        CXDashboard.prototype.scroll = function () {
-               var scrollTop = $( window ).scrollTop(),
-                       offsetTop = this.$dashboard.offset().top;
+               var scrollTop = $( window ).scrollTop();
 
-               if ( scrollTop > offsetTop ) {
+               if ( scrollTop > 0 ) {
                        this.$sidebar.addClass( 'sticky' );
-               } else if ( scrollTop <= offsetTop ) {
+               } else {
                        this.$sidebar.removeClass( 'sticky' );
                }
        };
 
-       $.fn.cxDashboard = function ( siteMapper, options ) {
-               return this.each( function () {
-                       var $this = $( this ),
-                               data = $this.data( 'cxdashboard' );
-
-                       if ( !data ) {
-                               $this.data( 'cx', ( data = new CXDashboard( 
this, siteMapper, options ) ) );
-                       }
-
-                       if ( typeof options === 'string' ) {
-                               data[ options ].call( $this );
-                       }
-               } );
-       };
-
-       $.fn.cxDashboard.defaults = {};
-
-       // Set the global siteMapper for code which we cannot inject it
-       mw.cx.siteMapper = new mw.cx.SiteMapper( mw.config.get( 
'wgContentTranslationSiteTemplates' ) );
-
        $( function () {
-               $( 'body' ).cxDashboard( mw.cx.siteMapper );
+               var dashboard;
+
+               // Set the global siteMapper for code which we cannot inject it
+               mw.cx.siteMapper = new mw.cx.SiteMapper( mw.config.get( 
'wgContentTranslationSiteTemplates' ) );
+               dashboard = new CXDashboard( document.body, mw.cx.siteMapper );
+               dashboard.init();
        } );
 }( jQuery, mediaWiki ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I09c345318962f2acdea716a0f78262a456c8782b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

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

Reply via email to