summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2016-10-23 07:55:20 -0400
committerAnthony G. Basile <blueness@gentoo.org>2016-10-23 07:55:20 -0400
commit12a3923fc98a3ee77593cc6cfe29e218245c4ec1 (patch)
tree1642119a9fcbb8ed0db3b9b6092e65053a7b03a0 /plugins/jetpack/_inc
parentUpdate plugin jetpack to 4.3.2 (diff)
downloadblogs-gentoo-12a3923fc98a3ee77593cc6cfe29e218245c4ec1.tar.gz
blogs-gentoo-12a3923fc98a3ee77593cc6cfe29e218245c4ec1.tar.bz2
blogs-gentoo-12a3923fc98a3ee77593cc6cfe29e218245c4ec1.zip
Correct update plugin jetpack to 4.3.2
Diffstat (limited to 'plugins/jetpack/_inc')
-rw-r--r--plugins/jetpack/_inc/jetpack.js256
-rw-r--r--plugins/jetpack/_inc/jp.js433
2 files changed, 0 insertions, 689 deletions
diff --git a/plugins/jetpack/_inc/jetpack.js b/plugins/jetpack/_inc/jetpack.js
deleted file mode 100644
index 4d636083..00000000
--- a/plugins/jetpack/_inc/jetpack.js
+++ /dev/null
@@ -1,256 +0,0 @@
-/* global jetpack: true, isRtl, jetpackL10n, userSettings, confirm */
-
-// ScrollTo Plugin 1.4.2 | Copyright (c) 2007-2009 Ariel Flesler | GPL/MIT License
-/* jshint ignore:start */
-;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
-/* jshint ignore:end */
-
-jetpack = {
- numModules: 0,
- container: null,
- arrow: null,
- linkClicked: null,
- resizeTimeout: null,
- resizeTimer: null,
- shadowTimer: null,
- statusText: null,
- isRTL: !( 'undefined' === typeof isRtl || !isRtl ),
- didDebug: false,
-
- init: function() {
- jetpack.numModules = jQuery( 'div.jetpack-module' ).not( '.placeholder' ).length;
- jetpack.container = jQuery( 'div.module-container' );
-
- jetpack.level_modules();
- jetpack.level_placeholders();
- jetpack.level_placeholders_on_resize();
-
- jQuery( 'a.more-info-link', 'div.jetpack-module' ).bind( 'click', function(e) {
- e.preventDefault();
- jetpack.hide_shadows();
-
- if ( jetpack.linkClicked && jetpack.linkClicked.parents( 'div.jetpack-module' ).attr( 'id' ) === jQuery(this).parents( 'div.jetpack-module' ).attr( 'id' ) ) {
- jetpack.close_learn_more( function() { jetpack.show_shadows(); } );
- } else {
- jetpack.linkClicked = jQuery(this);
- jetpack.insert_learn_more( jQuery(this).parents( 'div.jetpack-module' ), function() { jetpack.show_shadows(); } );
- jQuery( 'a.jetpack-deactivate-button' ).hide();
- jQuery( 'a.jetpack-configure-button' ).show();
- jetpack.linkClicked.parents( 'div.jetpack-module' ).children( '.jetpack-module-actions' ).children( 'a.jetpack-deactivate-button' ).show();
- jetpack.linkClicked.parents( 'div.jetpack-module' ).children( '.jetpack-module-actions' ).children( 'a.jetpack-configure-button' ).hide();
- }
- } );
-
- jQuery( window ).bind( 'resize', function() {
- jetpack.hide_shadows();
-
- clearTimeout( jetpack.shadowTimer );
- jetpack.shadowTimer = setTimeout( function() { jetpack.show_shadows(); }, 200 );
- });
-
- jQuery( 'a#jp-debug' ).bind( 'click', function(e) {
- e.preventDefault();
- if ( !jetpack.didDebug ) {
- jetpack.didDebug = true;
- jQuery( '#jetpack-configuration' ).load( this.href, function() {
- jQuery.scrollTo( 'max', 'fast' );
- } );
- }
-
- jetpack.toggle_debug();
- });
-
- jQuery( '#jp-disconnect a' ).click( function() {
- if ( confirm( jetpackL10n.ays_disconnect ) ) {
- jQuery( this ).addClass( 'clicked' ).css( {
- 'background-image': 'url( ' + userSettings.url + 'wp-includes/images/spinner-2x.gif )',
- 'background-position': '9px 5px',
- 'background-size': '16px 16px'
- } ).unbind( 'click' ).click( function() { return false; } );
- } else {
- return false;
- }
- } );
- jQuery( '#jp-unlink a' ).click( function() {
- if ( confirm( jetpackL10n.ays_unlink ) ) {
- jQuery( this ).css( {
- 'background-image': 'url( ' + userSettings.url + 'wp-includes/images/spinner-2x.gif )',
- 'background-position': '9px 5px',
- 'background-size': '16px 16px'
- } ).unbind( 'click' ).click( function() { return false; } );
- } else {
- return false;
- }
- } );
-
- jQuery( '#screen-meta, #screen-meta-links' ).wrapAll( '<div class="screen-meta-wrap" />' );
- },
-
- level_modules: function() {
- var max_height = 0;
-
- // Get the tallest module card and set them all to be that tall.
- jQuery( 'div.jetpack-module', 'div.module-container' ).each( function() {
- max_height = Math.max( max_height, jQuery(this).height() );
- } ).height( max_height );
- },
-
- level_placeholders: function() {
- jQuery( 'div.placeholder' ).show();
-
- var containerWidth = jetpack.container.width(),
- needed = 5 * parseInt( containerWidth / 242, 10 ) - jetpack.numModules;
-
- if ( jetpack.numModules * 242 > containerWidth ) {
- jQuery( 'div.placeholder' ).slice( needed ).hide();
- } else {
- jQuery( 'div.placeholder' ).hide();
- }
- },
-
- level_placeholders_on_resize: function() {
- jQuery( window ).bind( 'resize', function() {
- if ( jetpack.resizeTimer ) {
- return;
- }
-
- jetpack.resizeTimer = setTimeout( function() {
- jetpack.resizeTimer = false;
- jetpack.level_placeholders();
- jetpack.level_placeholders_on_resize();
- }, 100 );
- } );
- },
-
- insert_learn_more: function( card, callback ) {
- var perRow = parseInt( jetpack.container.width() / 242, 10 ),
- cardPosition = 0,
- cardRow = 0,
- learnMoreOffset = jetpack.isRTL ? 144 : 28;
-
- // Get the position of the card clicked.
- jQuery( 'div.jetpack-module', 'div.module-container' ).each( function( i, el ) {
- if ( jQuery(el).attr('id') === jQuery(card).attr('id') ) {
- cardPosition = i;
- }
- } );
-
- cardRow = 1 + parseInt( cardPosition / perRow, 10 );
-
- // Insert the more info box after the last item of the row.
- jQuery( 'div.jetpack-module', 'div.module-container' ).each( function( i, el ) {
- if ( i + 1 === ( perRow * cardRow ) ) {
- // More info box already exists.
- if ( jQuery( 'div.more-info' ).length ) {
- if ( jQuery( el ).next().hasClass( 'more-info' ) ) {
- jQuery( 'div.more-info div.jp-content' ).fadeOut( 100 );
- jetpack.learn_more_content( jQuery(card).attr( 'id' ) );
- jQuery( window ).scrollTo( ( jQuery( 'div.more-info' ).prev().offset().top ) - 70, 600, function() { if ( typeof callback === 'function' ) { callback.call( this ); } } );
- } else {
- jQuery( 'div.more-info div.jp-content' ).hide();
- jQuery( 'div.more-info' ).css( { height: '230px', minHeight: 0 } ).slideUp( 200, function() {
- var $this = jQuery(this);
- $this.detach().insertAfter( el );
- jQuery( 'div.more-info div.jp-content' ).hide();
- jetpack.learn_more_content( jQuery(card).attr( 'id' ) );
- $this.css( { height: '230px', minHeight: 0 } ).slideDown( 300, function() {
- $this.css( { height: 'auto', minHeight: '230px' } );
- } );
- jQuery( window ).scrollTo( ( $this.prev().offset().top ) - 70, 600, function() { if ( typeof callback === 'function' ) { callback.call( this ); } } );
- } );
- }
-
- // More info box does not exist.
- } else {
- // Insert the box.
- jQuery( el ).after( '<div id="message" class="more-info jetpack-message"><div class="arrow"></div><div class="jp-content"></div><div class="jp-close">&times;</div><div class="clear"></div></div>' );
-
- // Show the box
- jQuery( 'div.more-info' ).css( { height: '230px', minHeight: 0 } );
- jQuery( 'div.more-info', 'div.module-container' ).hide().slideDown( 400, function() {
- jQuery( 'div.more-info' ).css( { height: 'auto', minHeight: '230px' } );
- // Load the content and scroll to it
- jetpack.learn_more_content( jQuery(card).attr( 'id' ) );
- jQuery( window ).scrollTo( ( jQuery( 'div.more-info' ).prev().offset().top ) - 70, 600 );
-
- if ( typeof callback === 'function' ) { callback.call( this ); }
- } );
-
- jQuery( 'div.more-info' ).children( 'div.arrow' ).animate( { left: jQuery(card).offset().left - jetpack.container.offset().left + learnMoreOffset + 'px' }, 300 );
- }
- jQuery( 'div.more-info' ).children( 'div.arrow' ).animate( { left: jQuery(card).offset().left - jetpack.container.offset().left + learnMoreOffset + 'px' }, 300 );
-
- return;
- }
- } );
-
- // Listen for resize
- jQuery( window ).bind( 'resize', function() {
- jetpack.reposition_learn_more( card );
- jetpack.level_placeholders_on_resize();
- } );
-
- // Listen for close.
- jQuery( 'div.more-info div.jp-close' ).unbind( 'click' ).bind( 'click', function() {
- jetpack.close_learn_more();
- } );
- },
-
- reposition_learn_more: function( card ) {
- var perRow = parseInt( jetpack.container.width() / 242, 10 ),
- cardPosition = 0,
- cardRow;
-
- // Get the position of the card clicked.
- jQuery( 'div.jetpack-module', 'div.module-container' ).each( function( i, el ) {
- if ( jQuery(el).attr('id') === jQuery(card).attr('id') ) {
- cardPosition = i;
- }
- } );
-
- cardRow = 1 + parseInt( cardPosition / perRow, 10 );
-
- jQuery( 'div.jetpack-module', 'div.module-container' ).each( function( i, el ) {
- if ( i + 1 === ( perRow * cardRow ) ) {
- jQuery( 'div.more-info' ).detach().insertAfter( el );
- jQuery( 'div.more-info' ).children( 'div.arrow' ).css( { left: jQuery(card).offset().left - jetpack.container.offset().left + 28 + 'px' }, 300 );
- }
- } );
- },
-
- learn_more_content: function( module_id ) {
- var response = jQuery( '#jp-more-info-' + module_id ).html();
- jQuery( 'div.more-info div.jp-content' ).html( response ).hide().fadeIn( 300 );
- },
-
- close_learn_more: function( callback ) {
- jQuery( 'div.more-info div.jp-content' ).hide();
-
- jQuery( 'div.more-info' ).css( { height: '230px', minHeight: 0 } ).slideUp( 200, function() {
- jQuery( this ).remove();
- jQuery( 'a.jetpack-deactivate-button' ).hide();
- jetpack.linkClicked.parents( 'div.jetpack-module' ).children( '.jetpack-module-actions' ).children( 'a.jetpack-configure-button' ).show();
- jetpack.linkClicked = null;
-
- if ( typeof callback === 'function' ) { callback.call( this ); }
- } );
- },
-
- toggle_debug: function() {
- jQuery('div#jetpack-configuration').toggle( 0, function() {
- if ( jQuery( this ).is( ':visible' ) ) {
- jQuery.scrollTo( 'max', 'fast' );
- }
- } );
- },
-
- hide_shadows: function() {
- jQuery( 'div.jetpack-module, div.more-info' ).css( { '-webkit-box-shadow': 'none' } );
- },
-
- show_shadows: function() {
- jQuery( 'div.jetpack-module' ).css( { '-webkit-box-shadow': 'inset 0 1px 0 #fff, inset 0 0 20px rgba(0,0,0,0.05), 0 1px 2px rgba( 0,0,0,0.1 )' } );
- jQuery( 'div.more-info' ).css( { '-webkit-box-shadow': 'inset 0 0 20px rgba(0,0,0,0.05), 0 1px 2px rgba( 0,0,0,0.1 )' } );
- }
-};
-jQuery( function() { jetpack.init(); } );
diff --git a/plugins/jetpack/_inc/jp.js b/plugins/jetpack/_inc/jp.js
deleted file mode 100644
index 72499bb2..00000000
--- a/plugins/jetpack/_inc/jp.js
+++ /dev/null
@@ -1,433 +0,0 @@
-/* global wp, jetpackL10n, jQuery */
-
-(function( $, modules, currentVersion, jetpackL10n ) {
-
- ///////////////////////////////////////
- // INIT
- ///////////////////////////////////////
-
- var originPoint,
- data;
-
- $( document ).ready(function () {
-
- data = {
- 'jumpstartModules' : jetpackL10n.jumpstart_modules,
- 'jumpstartModSlug' : jetpackL10n.jumpstart_modules,
- 'jumpstartNonce' : jetpackL10n.activate_nonce,
- 'jumpstartStatsURLS' : jetpackL10n.jumpstart_stats_urls,
- 'nuxAdminStatsURLS' : jetpackL10n.admin_stats_urls,
- 'showJumpstart' : jetpackL10n.show_jumpstart,
- 'adminNonce' : jetpackL10n.admin_nonce
- };
-
- initEvents();
- loadModules( 'Performance-Security', 'mod-nux', '#nux-performance-security' );
- loadModules( 'Traffic', 'mod-nux', '#nux-traffic' );
- if('1' === data.showJumpstart) {
- loadModules( 'Jumpstart', 'mod-jumpstart', '#jp-config-list' );
- }
-
- /*
- We are listening to see if we need to refresh the data.
- We'd need to refresh the data only if the page is navigated to
- via the back or forward browser buttons. We do this so the
- browser cache isn't out of sync with the real data generated by the
- AJAX event.
- */
- onload = function() {
- if ( window.location.hash.substr( '#refresh' ) ) {
- refreshData();
- }
- };
-
- jumpStartAJAX();
- adminAJAX();
- });
-
- ///////////////////////////////////////
- // FUNCTIONS
- ///////////////////////////////////////
-
- function closeShadeToggle() {
- // Clicking outside modal, or close X closes modal
- $( '.shade, .modal .close' ).on( 'click', function () {
- $( '.shade, .modal' ).hide();
- $( '.manage-right' ).removeClass( 'show' );
- originPoint.focus();
- $( '.modal' )[0].removeAttribute( 'tabindex' );
- $( 'body' ).css( 'overflow', 'auto' );
- return false;
- });
-
- $( window ).on( 'keydown', function( e ) {
- // If pressing ESC close the modal
- if ( 27 === e.keyCode ) {
- $( '.shade, .modal' ).hide();
- $( '.manage-right' ).removeClass( 'show' );
- originPoint.focus();
- $( '.modal' )[0].removeAttribute( 'tabindex' );
- $( 'body' ).css( 'overflow', 'auto' );
- }
- });
- }
-
- function initEvents () {
- // Only show module table if Jumpstart isn't there
- if ( ! data.showJumpstart ) {
- $( '.nux-intro' ).show();
- }
-
- // Show preconfigured list of features to enable via "Jump-start"
- $( '.jp-config-list-btn' ).click(function(){
- $( '#jp-config-list' ).toggle();
- recalculateModuleHeights();
-
- //Log Jump Start event "learn more" in MC Stats
- new Image().src = data.jumpstartStatsURLS.learnmore;
- });
-
- // Hide the successful connection message after a little bit
- setTimeout( function(){
- jQuery( '.jetpack-message:not( .stay-visible, .jetpack-err )' ).hide( 600 );
- }, 6000);
-
- // Modal events
- $( document ).ready(function () {
- initModalEvents();
- });
-
- // Debounce the resize event
- var pauseResize = false;
- window.onresize = function() {
- if ( !pauseResize ) {
- pauseResize = true;
- recalculateModuleHeights();
- setTimeout(function () {
- pauseResize = false;
- }, 100 );
- }
- };
-
- // This function will track the number of clicks on the "See the other X Jetpack features"
- $( '.full-features-btn' ).click( function() {
- new Image().src = data.nuxAdminStatsURLS.learnmore+'-full-features-btn';
- });
- }
-
- function initModalEvents() {
- var $modal = $( '.modal' );
- $( '.module h3, .feature a, .configs a, .more-info, .feat h4' ).on( 'click keypress', function (e) {
- // Only show modal on enter when keypress recorded (accessibility)
- if ( e.keyCode && 13 !== e.keyCode ) {
- return;
- }
-
- e.preventDefault();
-
- $( '.shade' ).show();
-
- // Show loading message on init
- $modal.html( wp.template( 'modalLoading' )( {} ) ).fadeIn();
- // Load & populate with content
- var $this = $( this ).parent(),
- index = $this.data( 'index' ),
- name = $this.data( 'name' );
-
- $modal.empty().html( wp.template( 'modal' )( $.extend( modules[index], { name: name } ) ) );
- // Save the focused element, then shift focus to the modal window.
- originPoint = this;
- $modal[0].setAttribute( 'tabindex', '0' );
- $modal.focus();
-
- // Disallow scroll
- $( 'body' ).css( 'overflow', 'hidden' );
-
- closeShadeToggle();
-
- // Modal header links
- $( '.modal header li a.title' ).on( 'click', function () {
- $( '.modal header li a.title' ).removeClass( 'active' );
- $( this ).addClass( 'active' );
- return false;
- });
- });
- }
-
-
- /*
- Load Modules for a template
- @param string: The module tag you'd like to filter by
- @param string: The template name
- @param string: The target element to display the template
- */
- function loadModules( prop, template, location ) {
- // Mapping prior to sorting improves performance by over 50%
- var html = '',
- result = [],
- val = '',
- i,
- length,
- renderingmodules = [];
-
- // create the map
- for ( i = 0, length = modules.length; i < length; i++ ) {
- if( modules[i].feature.indexOf(prop) !== -1 ) {
- val = modules[i].name.toLowerCase();
- result.push( {
- index: i,
- value: val,
- order: modules[i].recommendation_order
- });
- }
- }
-
- // Sort modules by recommendation order
- result.sort(function( a, b ) {
- if (a.order === b.order ) {
- return 0;
- }
- return ( a.order < b.order ) ? -1 : 1;
- });
-
- // copy values in right order
- for ( i = 0, length = result.length; i < length; i++ ) {
- renderingmodules.push( modules[result[i].index] );
- renderingmodules[i].index = result[i].index; // make sure we set the index to the right order*/
- }
-
-
- // Render modules. Don't show active in Jumpstart.
- for ( i = 0; i < renderingmodules.length; i++ ) {
- if ( 'Jumpstart' === prop && ! renderingmodules[i].activated ) {
- html += wp.template( template )( renderingmodules[i] );
- } else if ( 'Jumpstart' !== prop ) {
- html += wp.template( template )( renderingmodules[i] );
- }
- }
-
- $( location ).append( html );
-
- // track Jump Start views
- if('Jumpstart' === prop) {
- new Image().src = data.jumpstartStatsURLS.viewed;
- }
-
- recalculateModuleHeights();
- initModalEvents();
- }
-
- function recalculateModuleHeights () {
- // Resize module heights based on screen resolution
- var module = $( '.jp-jumpstart, .module, .jp-support-column-left .widget-text' ),
- tallest = 0,
- thisHeight;
-
- // Remove heights
- module.css( 'height', 'auto' );
-
- // Determine new height
- module.each(function() {
-
- thisHeight = $( this ).outerHeight();
-
- if ( thisHeight > tallest ) {
- tallest = thisHeight;
- }
- });
-
- // Apply new height plus 20 pixels
- module.css( 'height', ( parseInt( tallest, 10 ) + 5 ) + 'px' );
- }
-
- /*
- Handles the jump start ajax requests.
-
- Dismissing the Jump Start area will set an option, so it will never be seen again
- Initiating Jump Start will activate all modules that are recommended and set a sharing options while doing so.
- For either request, if update_option has failed, look for an error in the console.
- @todo delete the "reset everything" call - meant for testing only.
- */
- function jumpStartAJAX() {
-
- // Will dismiss the Jump Start area, and set wp option in callback
- $( '.dismiss-jumpstart' ).click(function(){
- $( '#jump-start-area' ).hide( 600 );
-
- data.disableJumpStart = true;
- data.action = 'jetpack_jumpstart_ajax';
-
- $.post( jetpackL10n.ajaxurl, data, function (response) {
- // If there's no response, something bad happened
- if ( ! response ) {
- //console.log( 'Option "jetpack_dismiss_jumpstart" not updated.' );
- }
-
- window.location.hash = 'refresh';
- });
-
- $( '.nux-intro' ).show();
-
- // Log Jump Start event in MC Stats
- new Image().src = data.jumpstartStatsURLS.dismiss;
-
- return false;
- });
-
- // Activate all Jump-start modules
- $( '#jump-start' ).click(function () {
- var module, dataName, configURL, checkBox;
-
- $( '.jumpstart-spinner' ).show().css( 'display', 'block' );
- $( '#jump-start' ).hide();
- $( '.dismiss-jumpstart' ).hide();
-
- data.jumpStartActivate = 'jump-start-activate';
- data.action = 'jetpack_jumpstart_ajax';
-
- $( '#jp-config-list' ).hide();
-
- $.post( jetpackL10n.ajaxurl, data, function (response) {
- // If there's no response, option 'sharing-services' was not updated.
- if ( ! response ) {
- //console.log( 'Option "sharing-services" not updated. Either you already had sharing buttons enabled, or something is broken.' );
- }
-
- module = data.jumpstartModules;
-
- // Only target Jump Start modules
- _.each( module, function( mod ) {
- dataName = $( 'label[for="active-' + mod.module_slug + '"]' + '.plugin-action__label' );
- configURL = mod.configure_url;
- checkBox = $( 'input[id="active-' + mod.module_slug + '"]' );
-
- $( '#toggle-' + mod.module_slug ).addClass( 'activated' );
- dataName.html( 'ACTIVE' );
- $( checkBox ).prop( 'checked', true );
- });
-
- $( '.jumpstart-spinner, .jstart, #jumpstart-cta' ).hide();
- $( '.jumpstart-message' ).toggle();
- $( '#jump-start-area' ).delay( 5000 ).hide( 600 );
-
- // Log Jump Start event in MC Stats
- new Image().src = data.jumpstartStatsURLS.jumpstarted;
-
- $( '.nux-intro' ).show();
-
- window.location.hash = 'refresh';
- });
-
- return false;
- });
-
- /*
- RESET EVERYTHING (for testing only)
- @todo remove
- */
-
- $( '#jump-start-deactivate' ).click(function () {
- $( '.jumpstart-spinner' ).show();
-
- data.jumpStartDeactivate = 'jump-start-deactivate';
- data.action = 'jetpack_jumpstart_ajax';
-
- $.post( jetpackL10n.ajaxurl, data, function ( response ) {
- //$('#jumpstart-cta').html(response);
- $( '#deactivate-success' ).html( response );
- $( '.jumpstart-spinner' ).hide();
- window.location.hash = '';
-
- });
-
- return false;
- });
- }
-
- /*
- Handles the module activation ajax actions
- */
- function adminAJAX() {
- $( '.nux-in' ).on( 'keypress click', '.form-toggle', function( e ){
- if ( e.which !== 13 && e.type !== 'click' ) {
- return;
- }
- var thisElementId = e.target.id,
- thisLabel = $( 'label[for="' + thisElementId + '"]' + '.plugin-action__label'),
- index;
-
- data.action = 'jetpack_admin_ajax';
- data.thisModuleSlug = thisElementId.replace( 'active-', '' );
- data.toggleModule = 'nux-toggle-module';
-
- index = $( '#toggle-' + data.thisModuleSlug ).data( 'index' );
-
- thisLabel.hide();
- $( '.module-spinner-' + data.thisModuleSlug ).show();
-
- $.post( jetpackL10n.ajaxurl, data, function ( response ) {
- if ( 0 !== response ) {
-
- // Log NUX Admin event in MC Stats
- if( true === response.activated ){
- new Image().src = data.nuxAdminStatsURLS.enabled+','+'enabled-'+data.thisModuleSlug;
- }else{
- new Image().src = data.nuxAdminStatsURLS.deactivated+','+'deactivated-'+data.thisModuleSlug;
- }
-
- $( '.module-spinner-' + response.module ).hide();
-
- // This is a hacky way around not showing the config link when activated.
- response.noConfig = _.indexOf( [ 'photon', 'enhanced-distribution' ], response.module );
-
- // Preserves the modal index so it can be rendered properly after the data has changed
- response.index = index;
-
- $( '#toggle-' + response.module ).replaceWith( wp.template( 'mod-nux' )( response ) );
-
- // Refreshes the modal element data
- _.extend( _.findWhere( modules, { module: response.module } ), response );
-
- // Manual element alteration for Manage, since it's not part of the template
- if ( 'manage' === data.thisModuleSlug ) {
- if ( response.activated ) {
- $( '#manage-row .module-action' ).hide();
- $( '#manage-row' ).addClass( 'activated' );
- } else {
- thisLabel.show().html( 'INACTIVE' );
- $( '#manage-row' ).removeClass( 'activated' );
- }
-
- $( '.manage-cta-inactive' ).toggle();
- $( '.manage-cta-active' ).toggle();
- return;
- }
-
- initModalEvents();
- window.location.hash = 'refresh';
- }
-
- }, 'json' );
- });
- }
-
- /*
- This function will refresh any data elements that we've
- changed via AJAX. Necessary when page is visited via back/forward
- browsing.
- */
- function refreshData() {
- // Clean up
- $( '#nux-performance-security, #nux-traffic' ).empty();
- $( '#jump-start-area' ).hide();
- $( '.nux-intro' ).show();
-
- data.action = 'jetpack_admin_ajax_refresh';
- data.refreshData = 'refresh';
- $.post( jetpackL10n.ajaxurl, data, function ( response ) {
- modules = _.values( response );
- loadModules( 'Performance-Security', 'mod-nux', '#nux-performance-security' );
- loadModules( 'Traffic', 'mod-nux', '#nux-traffic' );
- }, 'json' );
- }
-})( jQuery, jetpackL10n.modules, jetpackL10n.currentVersion, jetpackL10n );