Santhosh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/154249
Change subject: Header: Simplify the class, merge the seperate header.render
file
......................................................................
Header: Simplify the class, merge the seperate header.render file
Header plugin is in manageable size and it does not make sense to split
to two files.
Change-Id: I63b47a8eb2fde5b820b1f41758d7dc58ca413ad8
---
M Resources.php
M modules/header/ext.cx.header.js
D modules/header/ext.cx.header.render.js
3 files changed, 53 insertions(+), 71 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/49/154249/1
diff --git a/Resources.php b/Resources.php
index cc5bb07..6ca2298 100644
--- a/Resources.php
+++ b/Resources.php
@@ -48,7 +48,6 @@
$wgResourceModules['ext.cx.header'] = array(
'scripts' => array(
'header/ext.cx.header.js',
- 'header/ext.cx.header.render.js',
),
'styles' => array(
'header/styles/ext.cx.header.less',
diff --git a/modules/header/ext.cx.header.js b/modules/header/ext.cx.header.js
index fb3b728..9110d21 100644
--- a/modules/header/ext.cx.header.js
+++ b/modules/header/ext.cx.header.js
@@ -1,5 +1,5 @@
/**
- * ContentTranslation Tools
+ * ContentTranslation Translation view header
* A tool that allows editors to translate pages from one language
* to another with the help of machine translation and other translation tools
*
@@ -16,10 +16,9 @@
*
* @class
*/
- function ContentTranslationHeader( element, options ) {
+ function ContentTranslationHeader( element ) {
this.$container = $( element );
this.$publishButton = null;
- this.options = $.extend( true, {}, $.fn.cxHeader.defaults,
options );
this.init();
}
@@ -143,23 +142,66 @@
mw.hook( 'mw.cx.translation.ready' ).add( $.proxy(
this.checkTargetTitle, this ) );
};
- $.fn.cxHeader = function ( options ) {
+ /**
+ * Render the header
+ */
+ ContentTranslationHeader.prototype.render = function () {
+ var $logo, $userDetails, $headerBar,
+ $translationCenterLink, $translationCenter;
+
+ $logo = $( '<div>' ).addClass( 'cx-header__logo' );
+
+ this.$userName = $( '<a>' )
+ .addClass( 'cx-header__user-details__user-name' )
+ .attr( {
+ href: mw.util.getUrl( 'User:' +
mw.user.getName() ),
+ target: '_blank'
+ } )
+ .text( mw.user.getName() );
+
+ $userDetails = $( '<div>' )
+ .addClass( 'cx-header__user-details' )
+ .append( this.$userName );
+
+ this.$publishButton = $( '<button>' )
+ .addClass( 'cx-header__publish publish mw-ui-button
mw-ui-constructive' )
+ .prop( 'disabled', true )
+ .text( mw.msg( 'cx-publish-button' ) );
+
+ $translationCenterLink = $( '<a>' )
+ .text( mw.msg( 'cx-header-translation-center' ) )
+ .attr( 'href', '#' );
+
+ $translationCenter = $( '<div>' )
+ .addClass( 'cx-header__translation-center' )
+ .append( $translationCenterLink );
+
+ $headerBar = $( '<div>' )
+ .addClass( 'cx-header__bar' )
+ .append( $translationCenter, this.$publishButton );
+
+ this.$infoBar = $( '<div>' )
+ .addClass( 'cx-header__infobar' )
+ .append( $( '<span>' ).addClass( 'text' ) )
+ .append( $( '<span>' ).addClass( 'remove' ) )
+ .hide();
+
+ this.$container
+ .addClass( 'cx-header' )
+ .append( $logo, $userDetails, $headerBar, this.$infoBar
);
+ };
+
+ $.fn.cxHeader = function () {
return this.each( function () {
var $this = $( this ),
data = $this.data( 'cxHeader' );
if ( !data ) {
$this.data(
- 'cxHeader', ( data = new
ContentTranslationHeader( this, options ) )
+ 'cxHeader', ( data = new
ContentTranslationHeader( this ) )
);
- }
-
- if ( typeof options === 'string' ) {
- data[ options ].call( $this );
}
} );
};
- mw.cx.ContentTranslationHeader = ContentTranslationHeader;
- $.fn.cxHeader.defaults = {};
}( jQuery, mediaWiki ) );
diff --git a/modules/header/ext.cx.header.render.js
b/modules/header/ext.cx.header.render.js
deleted file mode 100644
index d13d5d4..0000000
--- a/modules/header/ext.cx.header.render.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * ContentTranslation Tools
- * A tool that allows editors to translate pages from one language
- * to another with the help of machine translation and other translation tools
- *
- * @file
- * @ingroup Extensions
- * @copyright See AUTHORS.txt
- * @license GPL-2.0+
- */
-( function ( $, mw ) {
- 'use strict';
-
- mw.cx.ContentTranslationHeader.prototype.render = function () {
- var $logo, $userDetails, $headerBar,
- $translationCenterLink, $translationCenter;
-
- $logo = $( '<div>' ).addClass( 'cx-header__logo' );
-
- this.$userName = $( '<a>' )
- .addClass( 'cx-header__user-details__user-name' )
- .attr( {
- href: mw.util.getUrl( 'User:' +
mw.user.getName() ),
- target: '_blank'
- } )
- .text( mw.user.getName() );
-
- $userDetails = $( '<div>' )
- .addClass( 'cx-header__user-details' )
- .append( this.$userName );
-
- this.$publishButton = $( '<button>' )
- .addClass( 'cx-header__publish publish mw-ui-button
mw-ui-constructive' )
- .prop( 'disabled', true )
- .text( mw.msg( 'cx-publish-button' ) );
-
- $translationCenterLink = $( '<a>' )
- .text( mw.msg( 'cx-header-translation-center' ) )
- .attr( 'href', '#' );
-
- $translationCenter = $( '<div>' )
- .addClass( 'cx-header__translation-center' )
- .append( $translationCenterLink );
-
- $headerBar = $( '<div>' )
- .addClass( 'cx-header__bar' )
- .append( $translationCenter, this.$publishButton );
-
- this.$infoBar = $( '<div>' )
- .addClass( 'cx-header__infobar' )
- .append( $( '<span>' ).addClass( 'text' ) )
- .append( $( '<span>' ).addClass( 'remove' ) )
- .hide();
-
- this.$container
- .addClass( 'cx-header' )
- .append( $logo, $userDetails, $headerBar, this.$infoBar
);
- };
-}( jQuery, mediaWiki ) );
--
To view, visit https://gerrit.wikimedia.org/r/154249
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I63b47a8eb2fde5b820b1f41758d7dc58ca413ad8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits