Línea 2: |
Línea 2: |
| * Guided Tour to test guided tour features. | | * Guided Tour to test guided tour features. |
| */ | | */ |
− | // Copy the next line into the start of your tour.
| + | (function (window, document, $, mw, gt) { |
− | ( function ( window, document, $, mw, gt ) { | |
| | | |
− | // Declare a variable for use later | + | // XXX (mattflaschen, 2012-01-02): See GuidedTourHooks.php |
− | var pageName = 'Help:Guided tours/guider', | + | var pageName = mw.config.get('wgGuidedTourHelpGuiderUrl'), |
− | tour;
| + | msgs = { |
| + | 'guidedtour-tour-nominatefordeletion-title': "Nominating content for deletion", |
| + | 'guidedtour-tour-nominatefordeletion-description': "This short interactive tutorial will show you how to nominate content for deletion at {{SITENAME}}.", |
| + | 'guidedtour-tour-nominatefordeletion-link-title': "Click this link", |
| + | 'guidedtour-tour-nominatefordeletion-link-description': "to start the deletion procedure for the current page." |
| + | }; |
| + | |
| | | |
− | tour = new gt.TourBuilder( { | + | // Again a crappy extension that does not support i18n!!! |
| + | switch (mw.config.get('wgUserLanguage').toLowerCase()) { |
| + | case 'de': |
| + | case 'de-at': |
| + | case 'de-ch': |
| + | case 'de-formal': |
| + | case 'gsw': |
| + | case 'als': |
| + | case 'bar': |
| + | $.extend(msgs, { |
| + | 'guidedtour-tour-nominatefordeletion-title': "Einen Löschantrag stellen", |
| + | 'guidedtour-tour-nominatefordeletion-description': "Diese kurze, interaktive Tour wird aufzeigen, wie Du Löschanträge für Inhalte auf {{SITENAME}} stellen kannst.", |
| + | 'guidedtour-tour-nominatefordeletion-link-title': "Klicke auf diesen Link", |
| + | 'guidedtour-tour-nominatefordeletion-link-description': "um die Löschprozedur für die aktuelle Seite zu starten." |
| + | }); |
| + | break; |
| + | } |
| + | mw.messages.set(msgs); |
| + | |
| + | gt.defineTour({ |
| /* | | /* |
| * This is the name of the tour. It must be lowercase, without any hyphen (-) or | | * This is the name of the tour. It must be lowercase, without any hyphen (-) or |
| * period (.) characters. | | * period (.) characters. |
| * | | * |
− | * The page where you save an on-wiki tour must be named | + | * If this is an on-wiki tour, it should match the MediaWiki page. For instance, |
− | * MediaWiki:Guidedtour-tour-{name}.js , in this example MediaWiki:Guidedtour-tour-mytest.js | + | * if this were on-wiki, it would be MediaWiki:Guidedtour-tour-test.js |
| + | * |
| + | * The IDs below should use the same name in the middle (e.g. gt-test-2). |
| */ | | */ |
− | name: 'mytest' | + | name: 'nominatefordeletion', |
− | } );
| |
− | | |
− | // Information defining each tour step
| |
| | | |
− | // This tour shows a central overlay at the start of the tour.
| + | isSinglePage: true, |
− | // Guiders appear in the center if another position is not specified.
| + | shouldLog: false, |
− | // To specify the first step of the tour, use .firstStep instead of .step
| |
− | tour.firstStep( {
| |
− | name: 'overlay', | |
− | // Note that for on-wiki tours, we use title and description with the actual text. | |
− | // The title appears in the title bar of the guider.
| |
− | title: 'Testing',
| |
| | | |
− | // The description appears in the body
| |
− | description: 'This is a test of the description. Lorem ipsum dolor sit!',
| |
− |
| |
− | // This specifies that there is an overlay behind the guider.
| |
− | overlay: true
| |
− | } )
| |
− | // This specifies the next step of the tour, and will automatically generate a next button.
| |
− | // 'callout' refers to the name used in the step immediately below. Although putting the steps
| |
− | // in a meaningful order is recommended, any step can be specified as next/back.
| |
− | .next( 'callout' );
| |
− |
| |
− | tour.step( {
| |
| /* | | /* |
− | * Callout of left menu | + | * This is a list of the tour steps, in order. |
| */ | | */ |
− | name: 'callout', | + | steps: [{ |
− | title: 'Test callouts', | + | /* |
− | description: 'This is the community portal page.',
| + | * Show overlay at start of tour |
| + | */ |
| + | titlemsg: 'guidedtour-tour-nominatefordeletion-title', |
| + | descriptionmsg: 'guidedtour-tour-nominatefordeletion-description', |
| + | onShow: function () { |
| + | if (!$('#p-tb').hasClass('expanded')) { |
| + | mw.log("Expanding"); |
| + | $('#p-tb-label').mousedown().click().mouseup(); |
| + | } |
| + | }, |
| + | overlay: true, |
| + | buttons: [{ |
| + | action: 'next', |
| + | onclick: function() { |
| + | console.log("Test Ok."); |
| + | } |
| + | }] |
| + | }, { |
| + | /* |
| + | * Callout of sidebar menu |
| + | */ |
| + | titlemsg: 'guidedtour-tour-nominatefordeletion-link-title', |
| + | descriptionmsg: 'guidedtour-tour-nominatefordeletion-link-description', |
| | | |
− | // This positions the guider next to a page element, in this
| + | // This positions the guider next to a page element, in this |
− | // case the portal link (which is "Community portal" on English
| + | // case the portal link (which is "Community portal" on English |
− | // Wikipedia, but varies by site).
| + | // Wikipedia, but varies by site). |
− | // The string is a jQuery selector. "#n-portal" means the HTML
| + | // The string is a jQuery selector. "#n-portal" means the HTML |
− | // element with this id attribute, and "a" means an a, or link,
| + | // element with this id attribute, and "a" means an a, or link, |
− | // element inside that.
| + | // element inside that. |
− | attachTo: '#n-portal a',
| + | attachTo: '#t-ajaxquickdelete', |
| | | |
− | // This means the guider shows to the right of the Community Portal link
| + | // This means the guider shows to the right of the Community Portal link |
− | position: 'right',
| + | position: 'right', |
− | } )
| |
− | .next( 'description' )
| |
− | // The 'back' property specifies that you can go back from this step, and where to go
| |
− | // if the back button is clicked.
| |
− | .back( 'overlay' );
| |
| | | |
− | tour.step( {
| + | buttons: [{ |
− | /*
| + | action: 'end' |
− | * Test out mediawiki description pages
| + | }] |
− | */
| + | }] |
− | name: 'description',
| + | }); |
− | title: 'Test MediaWiki description pages',
| |
− | | |
− | // Name of the page to parse
| |
− | description: pageName,
| |
− | | |
− | overlay: true,
| |
− | | |
− | // This means the wikitext for the description will be loaded from the
| |
− | // page name in the description field.
| |
− | onShow: gt.getPageAsDescription,
| |
− | | |
− | buttons: [ {
| |
− | // This makes a button which acts like a wikilink to 'Help:Guided tours/guider'
| |
− | action: 'wikiLink',
| |
− | page: pageName,
| |
− | name: 'Go to description page',
| |
− | // This specifies that the button takes you to the next step of a process,
| |
− | // which affects its appearance. | |
− | type: 'progressive'
| |
− | }, {
| |
− | // This makes the okay button on this step end the tour.
| |
− | action: 'end'
| |
− | } ] | |
− | } ) | |
− | .back( 'callout' );
| |
| | | |
− | // The following should be the last line of your tour.
| + | }(window, document, jQuery, mediaWiki, mediaWiki.guidedTour)); |
− | } ( window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) ); | |