Created
August 12, 2012 17:10
-
-
Save dantman/3333040 to your computer and use it in GitHub Desktop.
MediaWiki Notification System Intro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var time = 0; | |
[ | |
[ 0, 'This is the new notification system.' ], | |
[ 6, 'As you can see it has autohide just like the previous one.' ], | |
[ 6, 'And clicking on a message will also hide it just like before.' ], | |
[ 6, 'But this time arround.' ], | |
[ 1, 'We support multiple messages.' ], | |
[ 2, 'Any sane number of them, really.' ], | |
[ 6, 'Auto-hide is good and all. But frankly sometimes you just HAVE to have a notification stick around.' ], | |
[ 1, 'This one uses { autoHide: false }', { autoHide: false } ], | |
[ 1, 'Naturally you can close this one with a click.' ], | |
[ 6, '*click*' ], | |
[ 0.8, function() { mw.notification.$area.children('.mw-notification-noautohide').click(); } ], | |
[ 6, 'We have tagged notifications.' ], | |
[ 1, 'Like this', { autoHide: false, tag: 'tagged' } ], | |
[ 1, 'When another notification with the same tag comes in.' ], | |
[ 1, 'It replaces the tagged notification.', { tag: 'tagged' } ], | |
[ 5, 'This is useful for things like watchlist notifications.' ], | |
[ 0.4, function() { $( '#ca-watch a, #ca-unwatch a' ).click(); } ], | |
[ 2, 'When you press the button again it replaces the watchlist notification.' ], | |
[ 0.4, function() { $( '#ca-watch a, #ca-unwatch a' ).click(); } ], | |
[ 3, 'Why did I call it { tag: ... } ?' ], | |
[ 0.8, $( '<p>That idea came from W3C\'s <a href="http://www.w3.org/TR/notifications/">Web Notifications</a> standard.</p>' ) ], | |
[ 6, 'I know that supporting multiple messages can be problematic when a pile of messages show up on the screen.' ], | |
[ 2, 'So the notification system has a tiny bit of flood protection.' ], | |
[ 1, 'autoHide only works for the first few notifications. All the later notifications have to wait for the first ones to hide before they can start counting down.' ], | |
[ 6, '*flood*' ], | |
[ 0, '*flood*' ], | |
[ 0, '*flood*' ], | |
[ 0, '*flood*' ], | |
[ 0, '*flood*' ], | |
[ 0, '*flood*' ], | |
[ 0, '*flood*' ], | |
[ 0, '*flood*' ], | |
[ 0, '*flood*' ], | |
[ 6*3, 'Coming soon to a Gerrit patchset near you.' ] | |
].forEach( function( rule ) { | |
time += rule[0]; | |
function doit() { | |
if ( $.isFunction( rule[1] ) ) { | |
rule[1](); | |
} else { | |
mw.util.notify( rule[1], rule[2] ); | |
} | |
} | |
if ( time == 0 ) { | |
doit(); | |
} else { | |
setTimeout( doit, time * 1000 ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment