MediaWiki:EditingNotificationBanner-spiderman.js

/* EditingNotificationBanner - edit more pages like this v1.1 by MtaÄ and Luqgreg require( [   'wikia.window',    'jquery',    'mw',    'wikia.tracker',    'BannerNotification' ], function ( window, $, mw, tracker, banner ) {    if ( window.EditingNotificationBannerLoaded ) {        return;    }    window.EditingNotificationBannerLoaded = true;    var config = mw.config.get( [ 'wgAction', 'wgPageName', 'wgUserName', 'wgUserLanguage' ] ),       track = tracker.buildTrackingFunction( { category: 'editing-notification-banner', action: tracker.ACTIONS.CLICK, trackingMethod: 'analytics' } ),       /* configure with your input */        message_article_names = 'Spider-Man:_Far_From_Home', /* requires 1 article name, unencoded, e.g. wgPageName value. must not contain apostrophes. */        only_show_on_these_articles = [ /* wgPageName values. must not contain apostrophes. */            'Editing_Notification_Banner/Trigger_Function',            'Spider_Man_Shows/Banner-Notifications',            'ToDo'        ],        /* build messages */        // TODO: Use mw.Message instead (?)        message_register_account = 'https://www.fandom.com/signin?redirect=' + encodeURI( window.location ) + '&uselang=' + config.wgUserLanguage;        message_text_user = 'Awesome job editing, ' + config.wgUserName + ' ! Many of the "' + message_article_names.replace(/_/g, " ") + '" pages can use your skills! Take a look, and see what you can do! '; //message_text_anon = 'Excellent edit! Would you like to be a full citizen of this community? Register an account here! '; message_text_anon = 'Excellent edit! Would you like to be a full citizen of this community? Register an account here! '; function AddTrackingOnClick( $element, label ) { $element.on( 'mousedown', function( e ) {           track( { browserEvent: e,               label: label } );       } );    }    function ShowBanner { var message = new banner( wgUserName === null ? message_text_anon : message_text_user, 'notify' ); message.show; message.$element.find('.wds-banner-notification__icon').html( ''); track( {           action: tracker.ACTIONS.IMPRESSION,            label: config.wgUserName === null ? 'editing-notification-banner-impressions-loggedout' : 'editing-notification-banner-impressions-loggedin'        } ); message.onClose( function {           track( { label: config.wgUserName === null ? 'editing-notification-banner-close-loggedout' : 'editing-notification-banner-close-loggedin' } );       } );        AddTrackingOnClick(            message.$element.find( '.editing-notification-banner-loggedin-suggestedpage' ),            'editing-notification-banner-clicked-suggestedpage-loggedin'        ); AddTrackingOnClick(           message.$element.find( '.editing-notification-banner-loggedout-helppage' ),            'editing-notification-banner-clicked-helppage-loggedout'        ); AddTrackingOnClick(           message.$element.find( '.editing-notification-banner-loggedout-registeraccount' ),            'editing-notification-banner-clicked-registeraccount-loggedout'        ); }   function EditingNotificationBanner { if ( config.wgAction !== 'view' /*|| ( only_show_on_these_articles.length && only_show_on_these_articles.indexOf( config.wgPageName ) === -1 )*/ ) { return; }       // NOTE: document.referrer points at ?action=edit after clicking on any link in the editor, no matter if the page was really edited or not, leading to false-positives if ( [ 'edit', 'submit' ].indexOf( mw.util.getParamValue( 'action', document.referrer ) ) !== -1 ) { ShowBanner; }       mw.hook( 've.activationComplete' ).add( function {            ve.trackSubscribe( 'mwedit.saveSuccess', ShowBanner );        } ); }   mw.loader.using( 'mediawiki.util', EditingNotificationBanner ); } );