additional-css.js
59 lines
| 1 | ( function ( $ ) { |
| 2 | 'use strict'; |
| 3 | |
| 4 | var cssNudge = { |
| 5 | init: function () { |
| 6 | this.clickifyNavigateToButtons(); |
| 7 | }, |
| 8 | |
| 9 | clickifyNavigateToButtons: function () { |
| 10 | var navButton = document.querySelector( '.navigate-to' ); |
| 11 | if ( ! navButton ) { |
| 12 | return; |
| 13 | } |
| 14 | |
| 15 | navButton.addEventListener( 'click', function () { |
| 16 | // Get destination. |
| 17 | var destination = this.getAttribute( 'data-navigate-to-page' ); |
| 18 | |
| 19 | if ( ! destination ) { |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | // Fire Tracks click event. |
| 24 | window._tkq = window._tkq || []; |
| 25 | window._tkq.push( [ |
| 26 | 'recordEvent', |
| 27 | 'calypso_upgrade_nudge_cta_click', |
| 28 | { |
| 29 | cta_name: 'customizer_css', |
| 30 | }, |
| 31 | ] ); |
| 32 | |
| 33 | // Navigate to a different page. |
| 34 | if ( |
| 35 | window.location.search.match( /calypso=true/ ) && |
| 36 | window.parent.location !== window.location |
| 37 | ) { |
| 38 | // Calypso. |
| 39 | window.top.postMessage( |
| 40 | JSON.stringify( { |
| 41 | calypso: true, |
| 42 | command: 'navigateTo', |
| 43 | destination: destination, |
| 44 | } ), |
| 45 | '*' |
| 46 | ); |
| 47 | } else { |
| 48 | // Non-Calypso. |
| 49 | window.location = 'https://wordpress.com' + destination; |
| 50 | } |
| 51 | } ); |
| 52 | }, |
| 53 | }; |
| 54 | |
| 55 | $( document ).ready( function () { |
| 56 | cssNudge.init(); |
| 57 | } ); |
| 58 | } )( jQuery ); |
| 59 |