New option.type to select a predefined style.
Default styles with colors:
* warn: yellow
* error: red
Other styles can be added.
Bug: T61099
Change-Id: I2d7305d9b62ebddc70e7f787e76e752b8b78d570
mw.notify( mw.msg( 'markedaspatrollednotify', title.toText() ) );
} else {
// This should never happen as errors should trigger fail
- mw.notify( mw.msg( 'markedaspatrollederrornotify' ) );
+ mw.notify( mw.msg( 'markedaspatrollederrornotify' ), { type: 'error' } );
}
} )
.fail( function ( error ) {
$patrolLinks.show();
if ( error === 'noautopatrol' ) {
// Can't patrol own
- mw.notify( mw.msg( 'markedaspatrollederror-noautopatrol' ) );
+ mw.notify( mw.msg( 'markedaspatrollederror-noautopatrol' ), { type: 'warn' } );
} else {
- mw.notify( mw.msg( 'markedaspatrollederrornotify' ) );
+ mw.notify( mw.msg( 'markedaspatrollederrornotify' ), { type: 'error' } );
}
} );
msg = mw.message( 'watcherrortext', link );
// Report to user about the error
- mw.notify( msg, { tag: 'watch-self' } );
+ mw.notify( msg, {
+ tag: 'watch-self',
+ type: 'error'
+ } );
} );
} );
} );
mw.notify( mw.msg( 'addedwatchtext-short', title ) );
} ).fail( function () {
$link.text( mw.msg( 'watch' ) );
- mw.notify( mw.msg( 'watcherrortext', title ) );
+ mw.notify( mw.msg( 'watcherrortext', title ), { type: 'error' } );
} );
} else {
$link.text( mw.msg( 'unwatching' ) );
mw.notify( mw.msg( 'removedwatchtext-short', title ) );
} ).fail( function () {
$link.text( mw.msg( 'unwatch' ) );
- mw.notify( mw.msg( 'watcherrortext', title ) );
+ mw.notify( mw.msg( 'watcherrortext', title ), { type: 'error' } );
} );
}
.mw-notification-title {
font-weight: bold;
}
+
+.mw-notification-type-warn {
+ border-color: #F5BE00; /* yellow */
+ background-color: #FFFFE8;
+}
+
+.mw-notification-type-error {
+ border-color: #EB3941; /* red */
+ background-color: #FFF8F8;
+}
}
}
+ if ( options.type ) {
+ // Sanitize options.type
+ options.type = options.type.replace( /[ _\-]+/g, '-' ).replace( /[^\-a-z0-9]+/ig, '' );
+ $notification.addClass( 'mw-notification-type-' + options.type );
+ }
+
if ( options.title ) {
$notificationTitle = $( '<div class="mw-notification-title"></div>' )
.text( options.title )
* - title:
* An optional title for the notification. Will be displayed above the
* content. Usually in bold.
+ *
+ * - type:
+ * An optional string for the type of the message used for styling:
+ * Examples: 'info', 'warn', 'error'.
*/
defaults: {
autoHide: true,
tag: false,
- title: undefined
+ title: undefined,
+ type: false
},
/**