mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-09-25 11:17:49 +00:00
Merge "Add .jshintrc"
This commit is contained in:
commit
aa315ebd90
31
.jshintrc
Normal file
31
.jshintrc
Normal file
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
/* Common */
|
||||
|
||||
// Enforcing
|
||||
"camelcase": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonew": true,
|
||||
"quotmark": "single",
|
||||
"trailing": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
// Legacy
|
||||
"onevar": true,
|
||||
|
||||
/* Local */
|
||||
|
||||
// Environment
|
||||
"browser": true,
|
||||
|
||||
"predef": [
|
||||
"jQuery",
|
||||
"QUnit",
|
||||
"mediaWiki"
|
||||
]
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
( function ( $, mw ) {
|
||||
/*global alert */
|
||||
'use strict';
|
||||
|
||||
mw.echo = {
|
||||
|
@ -12,8 +13,7 @@
|
|||
* reload the page.
|
||||
*/
|
||||
'dismiss': function( notification ) {
|
||||
var _this = this,
|
||||
$notification = $( notification ),
|
||||
var $notification = $( notification ),
|
||||
eventCategory = $notification.attr( 'data-notification-category' ),
|
||||
prefName = '',
|
||||
prefs = [],
|
||||
|
@ -26,21 +26,21 @@
|
|||
}
|
||||
} );
|
||||
prefRequest = {
|
||||
'action': 'options',
|
||||
'change': prefs.join( '|' ),
|
||||
'token': mw.echo.optionsToken,
|
||||
'format': 'json'
|
||||
};
|
||||
action: 'options',
|
||||
change: prefs.join( '|' ),
|
||||
token: mw.echo.optionsToken,
|
||||
format: 'json'
|
||||
};
|
||||
$.ajax( {
|
||||
type: 'post',
|
||||
url: mw.util.wikiScript( 'api' ),
|
||||
data: prefRequest,
|
||||
dataType: 'json',
|
||||
success: function( data ) {
|
||||
success: function () {
|
||||
// If we're on the Notifications archive page, just refresh the page
|
||||
if ( mw.config.get( 'wgCanonicalNamespace' ) === 'Special'
|
||||
&& mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Notifications' )
|
||||
{
|
||||
if ( mw.config.get( 'wgCanonicalNamespace' ) === 'Special' &&
|
||||
mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Notifications'
|
||||
) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
eventCategory = $notification.attr( 'data-notification-category' );
|
||||
|
@ -59,8 +59,10 @@
|
|||
* First we have to retrieve the options token.
|
||||
*/
|
||||
'setOptionsToken': function( callback, notification ) {
|
||||
var _this = this;
|
||||
var tokenRequest = {
|
||||
var tokenRequest,
|
||||
_this = this;
|
||||
|
||||
tokenRequest = {
|
||||
'action': 'tokens',
|
||||
'type' : 'options',
|
||||
'format': 'json'
|
||||
|
@ -74,7 +76,7 @@
|
|||
data: tokenRequest,
|
||||
dataType: 'json',
|
||||
success: function( data ) {
|
||||
if ( typeof data.tokens.optionstoken === 'undefined' ) {
|
||||
if ( data.tokens.optionstoken === undefined ) {
|
||||
alert( mw.msg( 'echo-error-token' ) );
|
||||
} else {
|
||||
_this.optionsToken = data.tokens.optionstoken;
|
||||
|
@ -111,11 +113,12 @@
|
|||
'setUpDismissability' : function( notification ) {
|
||||
var $dismissButton,
|
||||
$cancelButton,
|
||||
$closebox,
|
||||
_this = this,
|
||||
$notification = $( notification );
|
||||
|
||||
// Add dismiss box
|
||||
var $closebox = $( '<div/>' )
|
||||
$closebox = $( '<div/>' )
|
||||
.addClass( 'mw-echo-close-box' )
|
||||
.css( 'display', 'none' )
|
||||
.click( function() {
|
||||
|
@ -129,7 +132,7 @@
|
|||
.addClass( 'mw-echo-dismiss-button' )
|
||||
.addClass( 'ui-button-blue' )
|
||||
.button( {
|
||||
icons: { primary: "ui-icon-closethick" }
|
||||
icons: { primary: 'ui-icon-closethick' }
|
||||
} )
|
||||
.click( function () {
|
||||
_this.setOptionsToken( _this.dismiss, $notification );
|
||||
|
|
|
@ -22,19 +22,21 @@
|
|||
.badge( newCount, true, true );
|
||||
}
|
||||
|
||||
mw.echo.overlay.notification_count = newCount;
|
||||
mw.echo.overlay.notificationCount = newCount;
|
||||
},
|
||||
|
||||
'configuration' : mw.config.get( 'wgEchoOverlayConfiguration' ),
|
||||
|
||||
'buildOverlay' : function( callback ) {
|
||||
var $overlay = $( '<div></div>' ).addClass( 'mw-echo-overlay' ),
|
||||
var notificationLimit,
|
||||
$overlay = $( '<div></div>' ).addClass( 'mw-echo-overlay' ),
|
||||
$link = $( '#pt-notifications a' ),
|
||||
$prefLink = $( '#pt-preferences a' ),
|
||||
count = 0;
|
||||
var Api = new mw.Api();
|
||||
count = 0,
|
||||
Api = new mw.Api();
|
||||
|
||||
// Set notification limit based on height of the window
|
||||
var notificationLimit = Math.floor( ( $( window ).height() - 134 ) / 90 );
|
||||
notificationLimit = Math.floor( ( $( window ).height() - 134 ) / 90 );
|
||||
|
||||
if ( notificationLimit < 1 ) {
|
||||
notificationLimit = 1;
|
||||
|
@ -55,12 +57,13 @@
|
|||
unreadTotalCount = result.query.notifications.count,
|
||||
$title = $( '<div class="mw-echo-overlay-title"></div>' ),
|
||||
$ul = $( '<ul class="mw-echo-notifications"></ul>' ),
|
||||
titleText = '';
|
||||
titleText = '',
|
||||
$overlayFooter;
|
||||
|
||||
$ul.css( 'max-height', notificationLimit * 95 + 'px' );
|
||||
$.each( notifications.index, function( index, id ) {
|
||||
var data = notifications.list[id];
|
||||
var $li = $( '<li></li>' )
|
||||
var data = notifications.list[id],
|
||||
$li = $( '<li></li>' )
|
||||
.data( 'details', data )
|
||||
.data( 'id', id )
|
||||
.attr( 'data-notification-category', data.category )
|
||||
|
@ -96,7 +99,7 @@
|
|||
$ul.appendTo( $overlay );
|
||||
}
|
||||
|
||||
var $overlayFooter = $( '<div/>' )
|
||||
$overlayFooter = $( '<div/>' )
|
||||
.attr( 'id', 'mw-echo-overlay-footer' );
|
||||
|
||||
// add link to notifications archive
|
||||
|
@ -143,10 +146,10 @@
|
|||
}
|
||||
};
|
||||
|
||||
mw.echo.overlay.notification_count = mw.echo.overlay.configuration['notification-count'];
|
||||
mw.echo.overlay.notificationCount = mw.echo.overlay.configuration['notification-count'];
|
||||
|
||||
$( function() {
|
||||
mw.echo.overlay.updateCount( mw.echo.overlay.notification_count );
|
||||
mw.echo.overlay.updateCount( mw.echo.overlay.notificationCount );
|
||||
|
||||
var $link = $( '#pt-notifications a' );
|
||||
if ( ! $link.length ) {
|
||||
|
@ -154,8 +157,10 @@
|
|||
}
|
||||
|
||||
$link.click( function( e ) {
|
||||
var $target, $overlay;
|
||||
|
||||
e.preventDefault();
|
||||
var $target = $( e.target );
|
||||
$target = $( e.target );
|
||||
// If the user clicked on the overlay or any child,
|
||||
// ignore the click
|
||||
if ( $target.hasClass( 'mw-echo-overlay' ) ||
|
||||
|
@ -164,7 +169,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
var $overlay = $( '.mw-echo-overlay' );
|
||||
$overlay = $( '.mw-echo-overlay' );
|
||||
|
||||
if ( $overlay.length ) {
|
||||
$overlay.fadeOut( 'fast',
|
||||
|
@ -172,7 +177,7 @@
|
|||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$overlay = mw.echo.overlay.buildOverlay(
|
||||
function( $overlay ) {
|
||||
$overlay
|
||||
|
|
|
@ -161,7 +161,7 @@
|
|||
},
|
||||
|
||||
'onSuccess': function() {
|
||||
if ( this.moreData == '0' ) {
|
||||
if ( this.moreData === '0' ) {
|
||||
$( '#mw-echo-more' ).hide();
|
||||
}
|
||||
this.processing = false;
|
||||
|
|
Loading…
Reference in a new issue