[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 ( function ( mw, $ ) { 2 'use strict'; 3 4 /** 5 * @event postEdit 6 * @member mw.hook 7 * @param {Object} [data] Optional data 8 * @param {string|jQuery|Array} [data.message] Message that listeners 9 * should use when displaying notifications. String for plain text, 10 * use array or jQuery object to pass actual nodes. 11 * @param {string|mw.user} [data.user=mw.user] User that made the edit. 12 */ 13 14 /** 15 * After the listener for #postEdit removes the notification. 16 * 17 * @event postEdit_afterRemoval 18 * @member mw.hook 19 */ 20 21 var config = mw.config.get( [ 'wgAction', 'wgCurRevisionId' ] ), 22 // This should match EditPage::POST_EDIT_COOKIE_KEY_PREFIX: 23 cookieKey = 'PostEditRevision' + config.wgCurRevisionId, 24 cookieVal = mw.cookie.get( cookieKey ), 25 $div, id; 26 27 function showConfirmation( data ) { 28 data = data || {}; 29 if ( data.message === undefined ) { 30 data.message = $.parseHTML( mw.message( 'postedit-confirmation-saved', data.user || mw.user ).escaped() ); 31 } 32 33 $div = $( 34 '<div class="postedit-container">' + 35 '<div class="postedit">' + 36 '<div class="postedit-icon postedit-icon-checkmark postedit-content"></div>' + 37 '<a href="#" class="postedit-close">×</a>' + 38 '</div>' + 39 '</div>' 40 ); 41 42 if ( typeof data.message === 'string' ) { 43 $div.find( '.postedit-content' ).text( data.message ); 44 } else if ( typeof data.message === 'object' ) { 45 $div.find( '.postedit-content' ).append( data.message ); 46 } 47 48 $div 49 .click( fadeOutConfirmation ) 50 .prependTo( 'body' ); 51 52 id = setTimeout( fadeOutConfirmation, 3000 ); 53 } 54 55 function fadeOutConfirmation() { 56 clearTimeout( id ); 57 $div.find( '.postedit' ).addClass( 'postedit postedit-faded' ); 58 setTimeout( removeConfirmation, 500 ); 59 60 return false; 61 } 62 63 function removeConfirmation() { 64 $div.remove(); 65 mw.hook( 'postEdit.afterRemoval' ).fire(); 66 } 67 68 mw.hook( 'postEdit' ).add( showConfirmation ); 69 70 if ( config.wgAction === 'view' && cookieVal ) { 71 mw.config.set( 'wgPostEdit', true ); 72 73 mw.hook( 'postEdit' ).fire( { 74 // The following messages can be used here: 75 // postedit-confirmation-saved 76 // postedit-confirmation-created 77 // postedit-confirmation-restored 78 'message': mw.msg( 79 'postedit-confirmation-' + cookieVal, 80 mw.user 81 ) 82 } ); 83 mw.cookie.set( cookieKey, null ); 84 } 85 86 } ( mediaWiki, jQuery ) );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |