| 1 |
const mobile = require( 'mobile.startup' ); |
| 2 |
const drawers = require( './drawers.js' ); |
| 3 |
const CtaDrawer = mobile.CtaDrawer; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
function initRedlinksCta( $redLinks ) { |
| 25 |
$redLinks.on( 'click', function ( ev ) { |
| 26 |
const drawerOptions = { |
| 27 |
progressiveButton: { |
| 28 |
progressive: true, |
| 29 |
label: mw.msg( 'mobile-frontend-editor-redlink-create' ), |
| 30 |
href: $( this ).attr( 'href' ) |
| 31 |
}, |
| 32 |
actionAnchor: { |
| 33 |
progressive: true, |
| 34 |
label: mw.msg( 'mobile-frontend-editor-redlink-leave' ), |
| 35 |
additionalClassNames: 'cancel' |
| 36 |
}, |
| 37 |
onBeforeHide: drawers.discardDrawer, |
| 38 |
content: mw.msg( 'mobile-frontend-editor-redlink-explain' ) |
| 39 |
}, |
| 40 |
drawer = CtaDrawer( drawerOptions ); |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
ev.preventDefault(); |
| 45 |
ev.stopPropagation(); |
| 46 |
drawers.displayDrawer( drawer, { hideOnScroll: true } ); |
| 47 |
} ); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
function initWatchstarCta( $watchstar ) { |
| 57 |
let watchCtaDrawer; |
| 58 |
|
| 59 |
$watchstar.on( 'click', ( ev ) => { |
| 60 |
if ( !watchCtaDrawer ) { |
| 61 |
watchCtaDrawer = CtaDrawer( { |
| 62 |
content: mw.msg( 'minerva-watchlist-cta' ), |
| 63 |
queryParams: { |
| 64 |
notice: 'mobile-frontend-watchlist-purpose', |
| 65 |
campaign: 'mobile_watchPageActionCta', |
| 66 |
returntoquery: 'article_action=watch' |
| 67 |
}, |
| 68 |
onBeforeHide: drawers.discardDrawer, |
| 69 |
signupQueryParams: { |
| 70 |
notice: 'mobile-frontend-watchlist-signup-action' |
| 71 |
} |
| 72 |
} ); |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
if ( !watchCtaDrawer.$el[ 0 ].parentNode ) { |
| 78 |
drawers.displayDrawer( watchCtaDrawer, { hideOnScroll: true } ); |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
ev.preventDefault(); |
| 83 |
|
| 84 |
} ); |
| 85 |
} |
| 86 |
|
| 87 |
module.exports = { |
| 88 |
initWatchstarCta: initWatchstarCta, |
| 89 |
initRedlinksCta: initRedlinksCta |
| 90 |
}; |