Notification icon should not show NaN for persian Wikipedia
Bug: T172755 Change-Id: I2884c8daed3fe0e0d05c746ec6319956b7426957
This commit is contained in:
parent
8a82f30dab
commit
12b49a70ad
|
@ -365,6 +365,7 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin {
|
||||||
// Set user button to empty string by default
|
// Set user button to empty string by default
|
||||||
$tpl->set( 'secondaryButtonData', '' );
|
$tpl->set( 'secondaryButtonData', '' );
|
||||||
$notificationsTitle = '';
|
$notificationsTitle = '';
|
||||||
|
$count = 0;
|
||||||
$countLabel = '';
|
$countLabel = '';
|
||||||
$isZero = true;
|
$isZero = true;
|
||||||
$hasUnseen = false;
|
$hasUnseen = false;
|
||||||
|
@ -411,7 +412,8 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin {
|
||||||
'notificationIconClass' => MinervaUI::iconClass( 'notifications' ),
|
'notificationIconClass' => MinervaUI::iconClass( 'notifications' ),
|
||||||
'title' => $notificationsMsg,
|
'title' => $notificationsMsg,
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'notificationCount' => $countLabel,
|
'notificationCountRaw' => $count,
|
||||||
|
'notificationCountString' => $countLabel,
|
||||||
'isNotificationCountZero' => $isZero,
|
'isNotificationCountZero' => $isZero,
|
||||||
'hasNotifications' => $hasUnseen,
|
'hasNotifications' => $hasUnseen,
|
||||||
'hasUnseenNotifications' => $hasUnseen
|
'hasUnseenNotifications' => $hasUnseen
|
||||||
|
|
|
@ -32,4 +32,4 @@
|
||||||
{{>footer}}
|
{{>footer}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- v:8 -->
|
<!-- v:8.1 -->
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
class="notification-count user-button {{#hasUnseenNotifications}}notification-unseen{{/hasUnseenNotifications}}
|
class="notification-count user-button {{#hasUnseenNotifications}}notification-unseen{{/hasUnseenNotifications}}
|
||||||
{{#isNotificationCountZero}}zero{{/isNotificationCountZero}}">
|
{{#isNotificationCountZero}}zero{{/isNotificationCountZero}}">
|
||||||
<div class="circle">
|
<div class="circle">
|
||||||
<span>
|
<span data-notification-count="{{notificationCountRaw}}">
|
||||||
{{notificationCount}}
|
{{notificationCountString}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
function NotificationBadge( options ) {
|
function NotificationBadge( options ) {
|
||||||
var $el,
|
var $el,
|
||||||
|
count = 0,
|
||||||
el = options.el;
|
el = options.el;
|
||||||
|
|
||||||
if ( el ) {
|
if ( el ) {
|
||||||
|
@ -22,11 +23,12 @@
|
||||||
options.hasNotifications = options.hasUnseenNotifications;
|
options.hasNotifications = options.hasUnseenNotifications;
|
||||||
options.title = $el.find( 'a' ).attr( 'title' );
|
options.title = $el.find( 'a' ).attr( 'title' );
|
||||||
options.url = $el.find( 'a' ).attr( 'href' );
|
options.url = $el.find( 'a' ).attr( 'href' );
|
||||||
options.notificationCount = parseInt( $el.find( 'span' ).text(), 10 );
|
count = Number( $el.find( 'span' ).data( 'notification-count' ) );
|
||||||
}
|
}
|
||||||
View.call( this, options );
|
View.call( this, options );
|
||||||
this.url = this.$el.find( 'a' ).attr( 'href' );
|
this.url = this.$el.find( 'a' ).attr( 'href' );
|
||||||
this._bindOverlayManager();
|
this._bindOverlayManager();
|
||||||
|
this.setCount( count );
|
||||||
}
|
}
|
||||||
|
|
||||||
OO.mfExtend( NotificationBadge, View, {
|
OO.mfExtend( NotificationBadge, View, {
|
||||||
|
@ -35,14 +37,14 @@
|
||||||
* @cfg {String} defaults.notificationIconClass e.g. mw-ui-icon for icon
|
* @cfg {String} defaults.notificationIconClass e.g. mw-ui-icon for icon
|
||||||
* @cfg {String} defaults.loadingIconHtml for spinner
|
* @cfg {String} defaults.loadingIconHtml for spinner
|
||||||
* @cfg {Boolean} defaults.hasUnseenNotifications whether the user has unseen notifications
|
* @cfg {Boolean} defaults.hasUnseenNotifications whether the user has unseen notifications
|
||||||
* @cfg {Number} defaults.notificationCount number of unread notifications
|
* @cfg {Number} defaults.notificationCountRaw number of unread notifications
|
||||||
*/
|
*/
|
||||||
defaults: {
|
defaults: {
|
||||||
notificationIconClass: notificationIcon.getClassName(),
|
notificationIconClass: notificationIcon.getClassName(),
|
||||||
loadingIconHtml: icons.spinner().toHtmlString(),
|
loadingIconHtml: icons.spinner().toHtmlString(),
|
||||||
hasNotifications: false,
|
hasNotifications: false,
|
||||||
hasUnseenNotifications: false,
|
hasUnseenNotifications: false,
|
||||||
notificationCount: 0
|
notificationCountRaw: 0
|
||||||
},
|
},
|
||||||
isBorderBox: false,
|
isBorderBox: false,
|
||||||
/**
|
/**
|
||||||
|
@ -126,7 +128,13 @@
|
||||||
* @param {Number} count
|
* @param {Number} count
|
||||||
*/
|
*/
|
||||||
setCount: function ( count ) {
|
setCount: function ( count ) {
|
||||||
this.options.notificationCount = count;
|
if ( count > 100 ) {
|
||||||
|
count = 100;
|
||||||
|
}
|
||||||
|
this.options.notificationCountRaw = count;
|
||||||
|
this.options.notificationCountString = mw.message( 'echo-badge-count',
|
||||||
|
mw.language.convertNumber( count )
|
||||||
|
).text();
|
||||||
this.options.isNotificationCountZero = count === 0;
|
this.options.isNotificationCountZero = count === 0;
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
|
|
|
@ -325,6 +325,9 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"skins.minerva.notifications.badge": {
|
"skins.minerva.notifications.badge": {
|
||||||
|
"messages": [
|
||||||
|
"echo-badge-count"
|
||||||
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"mediawiki.router",
|
"mediawiki.router",
|
||||||
"mobile.startup"
|
"mobile.startup"
|
||||||
|
|
|
@ -284,6 +284,7 @@ class SkinMinervaTest extends MediaWikiTestCase {
|
||||||
$title,
|
$title,
|
||||||
$notificationsMsg,
|
$notificationsMsg,
|
||||||
$notificationsTitle,
|
$notificationsTitle,
|
||||||
|
$count,
|
||||||
$countLabel,
|
$countLabel,
|
||||||
$isZero,
|
$isZero,
|
||||||
$hasUnseen
|
$hasUnseen
|
||||||
|
@ -294,7 +295,8 @@ class SkinMinervaTest extends MediaWikiTestCase {
|
||||||
'url' => SpecialPage::getTitleFor( $notificationsTitle )
|
'url' => SpecialPage::getTitleFor( $notificationsTitle )
|
||||||
->getLocalURL(
|
->getLocalURL(
|
||||||
[ 'returnto' => $title->getPrefixedText() ] ),
|
[ 'returnto' => $title->getPrefixedText() ] ),
|
||||||
'notificationCount' => $countLabel,
|
'notificationCountRaw' => $count,
|
||||||
|
'notificationCountString' => $countLabel,
|
||||||
'isNotificationCountZero' => $isZero,
|
'isNotificationCountZero' => $isZero,
|
||||||
'hasNotifications' => $hasUnseen,
|
'hasNotifications' => $hasUnseen,
|
||||||
'hasUnseenNotifications' => $hasUnseen
|
'hasUnseenNotifications' => $hasUnseen
|
||||||
|
@ -319,6 +321,7 @@ class SkinMinervaTest extends MediaWikiTestCase {
|
||||||
$title,
|
$title,
|
||||||
'Show my notifications',
|
'Show my notifications',
|
||||||
'Notifications',
|
'Notifications',
|
||||||
|
110,
|
||||||
'99+',
|
'99+',
|
||||||
false,
|
false,
|
||||||
true
|
true
|
||||||
|
@ -331,6 +334,7 @@ class SkinMinervaTest extends MediaWikiTestCase {
|
||||||
$title,
|
$title,
|
||||||
'Show my notifications',
|
'Show my notifications',
|
||||||
'Notifications',
|
'Notifications',
|
||||||
|
3,
|
||||||
'3',
|
'3',
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
|
@ -343,6 +347,7 @@ class SkinMinervaTest extends MediaWikiTestCase {
|
||||||
$title,
|
$title,
|
||||||
'Show my notifications',
|
'Show my notifications',
|
||||||
'Notifications',
|
'Notifications',
|
||||||
|
5,
|
||||||
'5',
|
'5',
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
|
@ -353,6 +358,7 @@ class SkinMinervaTest extends MediaWikiTestCase {
|
||||||
$title,
|
$title,
|
||||||
'Show my notifications',
|
'Show my notifications',
|
||||||
'Notifications',
|
'Notifications',
|
||||||
|
0,
|
||||||
'0',
|
'0',
|
||||||
true,
|
true,
|
||||||
false
|
false
|
||||||
|
@ -379,6 +385,7 @@ class SkinMinervaTest extends MediaWikiTestCase {
|
||||||
$title,
|
$title,
|
||||||
'You have new messages on your talk page',
|
'You have new messages on your talk page',
|
||||||
'Mytalk',
|
'Mytalk',
|
||||||
|
0,
|
||||||
'',
|
'',
|
||||||
true,
|
true,
|
||||||
false
|
false
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
overlayManager: this.OverlayManager,
|
overlayManager: this.OverlayManager,
|
||||||
hasNotifications: true,
|
hasNotifications: true,
|
||||||
hasUnseenNotifications: true,
|
hasUnseenNotifications: true,
|
||||||
notificationCount: 5
|
notificationCountRawRaw: 5
|
||||||
} );
|
} );
|
||||||
initialClassExpectationsMet = badge.$el.find( '.mw-ui-icon' ).length === 0 &&
|
initialClassExpectationsMet = badge.$el.find( '.mw-ui-icon' ).length === 0 &&
|
||||||
badge.$el.find( '.zero' ).length === 0;
|
badge.$el.find( '.zero' ).length === 0;
|
||||||
|
@ -23,11 +23,28 @@
|
||||||
badge.setCount( 0 );
|
badge.setCount( 0 );
|
||||||
assert.ok( initialClassExpectationsMet, 'No icon and no zero class' );
|
assert.ok( initialClassExpectationsMet, 'No icon and no zero class' );
|
||||||
assert.ok( badge.$el.find( '.zero' ).length === 1, 'A zero class is present on the badge' );
|
assert.ok( badge.$el.find( '.zero' ).length === 1, 'A zero class is present on the badge' );
|
||||||
|
badge.setCount( 105 );
|
||||||
|
assert.ok( badge.options.notificationCountRawRaw, 100,
|
||||||
|
'Number is capped to 100.' );
|
||||||
|
} );
|
||||||
|
|
||||||
|
QUnit.test( '#setCount (Eastern Arabic numerals)', function ( assert ) {
|
||||||
|
var badge = new NotificationBadge( {
|
||||||
|
overlayManager: this.OverlayManager,
|
||||||
|
el: $( '<div><a title="n" href="/" class="notification-unseen"><div class="circle"><span>۲</span></div></a></div>' )
|
||||||
|
} );
|
||||||
|
assert.ok( badge.options.notificationCountRawRaw, 2,
|
||||||
|
'Number is parsed from Eastern Arabic numerals' );
|
||||||
|
assert.ok( badge.options.notificationCountRawRawString, '۲',
|
||||||
|
'Number will be rendered in Eastern Arabic numerals' );
|
||||||
|
badge.setCount( 5 );
|
||||||
|
assert.ok( badge.options.notificationCountRawRawString, '۵',
|
||||||
|
'Number will be rendered in Eastern Arabic numerals' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( '#render [hasUnseenNotifications]', function ( assert ) {
|
QUnit.test( '#render [hasUnseenNotifications]', function ( assert ) {
|
||||||
var badge = new NotificationBadge( {
|
var badge = new NotificationBadge( {
|
||||||
notificationCount: 0,
|
notificationCountRawRaw: 0,
|
||||||
overlayManager: this.OverlayManager,
|
overlayManager: this.OverlayManager,
|
||||||
hasNotifications: false,
|
hasNotifications: false,
|
||||||
hasUnseenNotifications: false
|
hasUnseenNotifications: false
|
||||||
|
@ -37,7 +54,7 @@
|
||||||
|
|
||||||
QUnit.test( '#markAsSeen', function ( assert ) {
|
QUnit.test( '#markAsSeen', function ( assert ) {
|
||||||
var badge = new NotificationBadge( {
|
var badge = new NotificationBadge( {
|
||||||
notificationCount: 2,
|
notificationCountRawRaw: 2,
|
||||||
overlayManager: this.OverlayManager,
|
overlayManager: this.OverlayManager,
|
||||||
hasNotifications: true,
|
hasNotifications: true,
|
||||||
hasUnseenNotifications: true
|
hasUnseenNotifications: true
|
||||||
|
|
Loading…
Reference in New Issue