Add massive collection of CSS, JavaScript and theme assets that were previously excluded: **CSS Files (681 total):** - HVAC plugin-specific styles (hvac-*.css): 34 files including dashboard, certificates, registration, mobile nav, accessibility fixes, animations, and welcome popup - Theme framework files (Astra, builder systems, layouts): 200+ files - Plugin compatibility styles (WooCommerce, WPForms, Elementor, Contact Form 7): 150+ files - WordPress core and editor styles: 50+ files - Responsive and RTL language support: 200+ files **JavaScript Files (400+ total):** - HVAC plugin functionality (hvac-*.js): 27 files including menu systems, dashboard enhancements, profile sharing, mobile responsive features, accessibility, and animations - Framework and library files: jQuery plugins, GSAP, AOS, Swiper, Chart.js, Lottie, Isotope - Plugin compatibility scripts: WPForms, WooCommerce, Elementor, Contact Form 7, LifterLMS - WordPress core functionality: customizer, admin, block editor compatibility - Third-party integrations: Stripe, SMTP, analytics, search functionality **Assets:** - Certificate background images and logos - Comprehensive theme styling infrastructure - Mobile-responsive design systems - Cross-browser compatibility assets - Performance-optimized minified versions **Updated .gitignore:** - Fixed asset directory whitelisting patterns to properly include CSS/JS/images - Added proper directory structure recognition (!/assets/css/, !/assets/js/, etc.) - Maintains security by excluding sensitive files while including essential assets This commit provides the complete frontend infrastructure needed for: - Full theme functionality and styling - Plugin feature implementations - Mobile responsiveness and accessibility - Cross-browser compatibility - Performance optimization - Developer workflow support
286 lines
6.5 KiB
JavaScript
286 lines
6.5 KiB
JavaScript
/* global WPForms, WPFormsBuilder, wpforms_challenge_admin, WPFormsFormEmbedWizard */
|
|
/**
|
|
* WPForms Challenge function.
|
|
*
|
|
* @since 1.5.0
|
|
* @since 1.6.2 Challenge v2
|
|
*/
|
|
'use strict';
|
|
|
|
var WPFormsChallenge = window.WPFormsChallenge || {};
|
|
|
|
WPFormsChallenge.builder = window.WPFormsChallenge.builder || ( function( document, window, $ ) {
|
|
|
|
/**
|
|
* Public functions and properties.
|
|
*
|
|
* @since 1.5.0
|
|
*
|
|
* @type {object}
|
|
*/
|
|
var app = {
|
|
|
|
/**
|
|
* Start the engine.
|
|
*
|
|
* @since 1.5.0
|
|
*/
|
|
init: function() {
|
|
|
|
$( app.ready );
|
|
$( window ).on( 'load', function() {
|
|
|
|
// in case of jQuery 3.+ we need to wait for an `ready` event first.
|
|
if ( typeof $.ready.then === 'function' ) {
|
|
$.ready.then( app.load );
|
|
} else {
|
|
app.load();
|
|
}
|
|
} );
|
|
},
|
|
|
|
/**
|
|
* Document ready.
|
|
*
|
|
* @since 1.5.0
|
|
*/
|
|
ready: function() {
|
|
|
|
app.setup();
|
|
app.events();
|
|
},
|
|
|
|
/**
|
|
* Window load.
|
|
*
|
|
* @since 1.5.0
|
|
*/
|
|
load: function() {
|
|
|
|
if ( [ 'started', 'paused' ].indexOf( wpforms_challenge_admin.option.status ) > -1 ) {
|
|
WPFormsChallenge.core.updateTooltipUI();
|
|
}
|
|
|
|
$( '.wpforms-challenge' ).show();
|
|
},
|
|
|
|
/**
|
|
* Initial setup.
|
|
*
|
|
* @since 1.5.0
|
|
*/
|
|
setup: function() {
|
|
if ( wpforms_challenge_admin.option.status === 'inited' ) {
|
|
WPFormsChallenge.core.clearLocalStorage();
|
|
app.showWelcomePopup();
|
|
}
|
|
|
|
app.initTooltips();
|
|
|
|
$( '#wpforms-embed' ).addClass( 'wpforms-disabled' );
|
|
|
|
$( document ).on( 'wpformsWizardPopupClose', app.enableEmbed );
|
|
},
|
|
|
|
/**
|
|
* Register JS events.
|
|
*
|
|
* @since 1.5.0
|
|
*/
|
|
events: function() {
|
|
|
|
// Start the Challenge.
|
|
$( '#wpforms-challenge-welcome-builder-popup' ).on( 'click', 'button', app.startChallenge );
|
|
|
|
// Step 1.
|
|
$( '.wpforms-challenge-step1-done' ).on( 'click', function() {
|
|
WPFormsChallenge.core.stepCompleted( 1 );
|
|
} );
|
|
|
|
$( '#wpforms-builder' )
|
|
|
|
// Register select template event when the setup panel is ready.
|
|
.on( 'wpformsBuilderSetupReady', function() {
|
|
app.eventSelectTemplate();
|
|
} )
|
|
|
|
// Restore tooltips when switching builder panels/sections.
|
|
.on( 'wpformsPanelSwitch wpformsPanelSectionSwitch wpformsBuilderPanelLoaded', function() {
|
|
WPFormsChallenge.core.updateTooltipUI();
|
|
} );
|
|
|
|
// Step 3 - Add fields.
|
|
$( '.wpforms-challenge-step3-done' ).on( 'click', app.gotoNotificationStep );
|
|
|
|
// Step 4 - Notifications.
|
|
$( document ).on( 'click', '.wpforms-challenge-step4-done', app.showEmbedPopup );
|
|
|
|
// Tooltipster ready.
|
|
$.tooltipster.on( 'ready', app.tooltipsterReady );
|
|
|
|
// Move to step 3 if challenge is forced and exisiting form is opened.
|
|
$( document ).on( 'wpformsBuilderReady', function() {
|
|
if ( $( '.wpforms-panel-fields-button' ).hasClass( 'active' ) && WPFormsChallenge.core.loadStep() <= 2 ) {
|
|
WPFormsChallenge.core.stepCompleted( 1 );
|
|
WPFormsChallenge.core.stepCompleted( 2 );
|
|
}
|
|
} );
|
|
},
|
|
|
|
/**
|
|
* Initialize tooltips.
|
|
*
|
|
* @since 1.9.3
|
|
*/
|
|
initTooltips() {
|
|
const tooltipAnchors = [
|
|
'#wpforms-setup-name',
|
|
'.wpforms-setup-title .wpforms-setup-title-after',
|
|
'#add-fields a i',
|
|
'#wpforms-builder-settings-notifications-title',
|
|
];
|
|
|
|
$.each( tooltipAnchors, function( i, anchor ) {
|
|
WPFormsChallenge.core.initTooltips( i + 1, anchor, null );
|
|
} );
|
|
},
|
|
|
|
/**
|
|
* Register select template event.
|
|
*
|
|
* @since 1.6.8
|
|
*/
|
|
eventSelectTemplate: function() {
|
|
|
|
$( '#wpforms-panel-setup' )
|
|
|
|
// Step 2 - Select the Form template.
|
|
.off( 'click', '.wpforms-template-select' ) // Intercept Form Builder's form template selection and apply own logic.
|
|
.on( 'click', '.wpforms-template-select', function( e ) {
|
|
app.builderTemplateSelect( this, e );
|
|
} );
|
|
},
|
|
|
|
/**
|
|
* Start the Challenge.
|
|
*
|
|
* @since 1.6.2
|
|
*/
|
|
startChallenge: function() {
|
|
|
|
WPFormsChallenge.admin.saveChallengeOption( { status: 'started' } );
|
|
WPFormsChallenge.core.initListUI( 'started' );
|
|
$( '.wpforms-challenge-popup-container' ).fadeOut( function() {
|
|
$( '#wpforms-challenge-welcome-builder-popup' ).hide();
|
|
} );
|
|
WPFormsChallenge.core.timer.run( WPFormsChallenge.core.timer.initialSecondsLeft );
|
|
WPFormsChallenge.core.updateTooltipUI();
|
|
},
|
|
|
|
/**
|
|
* Go to Step.
|
|
*
|
|
* @since 1.6.2
|
|
* @since 1.7.5 Deprecated.
|
|
*
|
|
* @param {number|string} step Last saved step.
|
|
*/
|
|
gotoStep: function( step ) {
|
|
console.warn( 'WARNING! Function "WPFormsChallenge.builder.gotoStep()" has been deprecated.' );
|
|
},
|
|
|
|
/**
|
|
* Save the second step before a template is selected.
|
|
*
|
|
* @since 1.5.0
|
|
*
|
|
* @param {string} el Element selector.
|
|
* @param {object} e Event.
|
|
*/
|
|
builderTemplateSelect: function( el, e ) {
|
|
|
|
WPFormsChallenge.core.resumeChallengeAndExec( e, function() {
|
|
|
|
WPFormsChallenge.core.stepCompleted( 2 )
|
|
.done( WPForms.Admin.Builder.Setup.selectTemplate.bind( el, e ) );
|
|
} );
|
|
},
|
|
|
|
/**
|
|
* Tooltipster ready event callback.
|
|
*
|
|
* @since 1.6.2
|
|
*
|
|
* @param {object} e Event object.
|
|
*/
|
|
tooltipsterReady: function( e ) {
|
|
|
|
var step = $( e.origin ).data( 'wpforms-challenge-step' );
|
|
var formId = $( '#wpforms-builder-form' ).data( 'id' );
|
|
|
|
step = parseInt( step, 10 ) || 0;
|
|
formId = parseInt( formId, 10 ) || 0;
|
|
|
|
// Save challenge form ID right after it's created.
|
|
if ( 3 === step && formId > 0 ) {
|
|
WPFormsChallenge.admin.saveChallengeOption( { form_id: formId } ); // eslint-disable-line camelcase
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Display 'Welcome to the Form Builder' popup.
|
|
*
|
|
* @since 1.6.2
|
|
*/
|
|
showWelcomePopup: function() {
|
|
|
|
$( '#wpforms-challenge-welcome-builder-popup' ).show();
|
|
$( '.wpforms-challenge-popup-container' ).fadeIn();
|
|
},
|
|
|
|
/**
|
|
* Go to Notification step.
|
|
*
|
|
* @since 1.7.5
|
|
*
|
|
* @param {object} e Event object.
|
|
*/
|
|
gotoNotificationStep: function( e ) {
|
|
|
|
WPFormsChallenge.core.stepCompleted( 3 ).done( function() {
|
|
|
|
WPFormsBuilder.panelSwitch( 'settings' );
|
|
WPFormsBuilder.panelSectionSwitch( $( '.wpforms-panel .wpforms-panel-sidebar-section-notifications' ) );
|
|
} );
|
|
},
|
|
|
|
/**
|
|
* Display 'Embed in a Page' popup.
|
|
*
|
|
* @since 1.6.2
|
|
*/
|
|
showEmbedPopup: function() {
|
|
|
|
WPFormsChallenge.core.stepCompleted( 4 ).done(
|
|
WPFormsFormEmbedWizard.openPopup
|
|
);
|
|
},
|
|
|
|
/**
|
|
* Enable Embed button when Embed popup is closed.
|
|
*
|
|
* @since 1.7.4
|
|
*/
|
|
enableEmbed: function() {
|
|
|
|
$( '#wpforms-embed' ).removeClass( 'wpforms-disabled' );
|
|
},
|
|
};
|
|
|
|
// Provide access to public functions/properties.
|
|
return app;
|
|
|
|
}( document, window, jQuery ) );
|
|
|
|
// Initialize.
|
|
WPFormsChallenge.builder.init();
|