diff --git a/resources/skins.minerva.notifications.badge/NotificationBadge.js b/resources/skins.minerva.notifications.badge/NotificationBadge.js index 87293c4..18f67b3 100644 --- a/resources/skins.minerva.notifications.badge/NotificationBadge.js +++ b/resources/skins.minerva.notifications.badge/NotificationBadge.js @@ -14,7 +14,7 @@ */ function NotificationBadge( options ) { var $el, - count = 0, + count = options.notificationCountRaw || 0, el = options.el; if ( el ) { @@ -26,7 +26,7 @@ count = Number( $el.find( 'span' ).data( 'notification-count' ) ); } View.call( this, options ); - this.url = this.$el.find( 'a' ).attr( 'href' ); + this.url = options.url; this._bindOverlayManager(); this.setCount( count ); } diff --git a/tests/qunit/skins.minerva.notifications.badge/test_NotificationBadge.js b/tests/qunit/skins.minerva.notifications.badge/test_NotificationBadge.js index ae17500..9f08a08 100644 --- a/tests/qunit/skins.minerva.notifications.badge/test_NotificationBadge.js +++ b/tests/qunit/skins.minerva.notifications.badge/test_NotificationBadge.js @@ -15,7 +15,7 @@ overlayManager: this.OverlayManager, hasNotifications: true, hasUnseenNotifications: true, - notificationCountRawRaw: 5 + notificationCountRaw: 5 } ); initialClassExpectationsMet = badge.$el.find( '.mw-ui-icon' ).length === 0 && badge.$el.find( '.zero' ).length === 0; @@ -24,27 +24,27 @@ 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' ); badge.setCount( 105 ); - assert.ok( badge.options.notificationCountRawRaw, 100, + assert.ok( badge.options.notificationCountRaw, 100, 'Number is capped to 100.' ); } ); QUnit.test( '#setCount (Eastern Arabic numerals)', function ( assert ) { var badge = new NotificationBadge( { overlayManager: this.OverlayManager, - el: $( '
۲
' ) + el: $( '
۲
' ) } ); - assert.ok( badge.options.notificationCountRawRaw, 2, + assert.ok( badge.options.notificationCountRaw, 2, 'Number is parsed from Eastern Arabic numerals' ); - assert.ok( badge.options.notificationCountRawRawString, '۲', + assert.ok( badge.options.notificationCountString, '۲', 'Number will be rendered in Eastern Arabic numerals' ); badge.setCount( 5 ); - assert.ok( badge.options.notificationCountRawRawString, '۵', + assert.ok( badge.options.notificationCountString, '۵', 'Number will be rendered in Eastern Arabic numerals' ); } ); QUnit.test( '#render [hasUnseenNotifications]', function ( assert ) { var badge = new NotificationBadge( { - notificationCountRawRaw: 0, + notificationCountRaw: 0, overlayManager: this.OverlayManager, hasNotifications: false, hasUnseenNotifications: false @@ -54,7 +54,7 @@ QUnit.test( '#markAsSeen', function ( assert ) { var badge = new NotificationBadge( { - notificationCountRawRaw: 2, + notificationCountRaw: 2, overlayManager: this.OverlayManager, hasNotifications: true, hasUnseenNotifications: true