芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/jobs.socialdigiinnovator.com/wp-content/themes/jobify/js/app/app.js
/** * Functionality specific to Jobify * * Provides helper functions to enhance the theme experience. */ var Jobify = {} Jobify.App = ( function($) { var currentPopup; function fixedHeader() { $window = $(window); var offsetHeader = function() { var $body = $( 'body' ); if ( ! $body.hasClass( 'fixed-header' ) ) { return; } var $header = $( '#masthead' ); var headerHeight = $header.outerHeight(); var headerOffset = 0; if ( $body.hasClass( 'admin-bar' ) ) { headerOffset = $( '#wpadminbar' ).outerHeight(); } if ( $window.outerWidth() < 1200 ) { $body.css( 'padding-top', 0 ); $header.css( 'top', 0 ); return; } $header.css( 'top', headerOffset ); $body.css( 'padding-top', headerHeight ); } offsetHeader(); $window.resize(function() { offsetHeader(); }); } function mobileMenu() { $( '.js-primary-menu-toggle' ).click(function(e){ e.preventDefault(); $( '.js-primary-menu-toggle' ).toggleClass( 'primary-menu-toggle--opened' ); $( '.site-primary-navigation' ).toggleClass( 'site-primary-navigation--open' ); }); var resizeWindow = function() { if ( ! $( '.primary-menu-toggle' ).is( ':visible' ) ) { $( '.site-primary-navigation' ).removeClass( 'site-primary-navigation--open' ); } } resizeWindow(); $(window).resize(function() { resizeWindow(); }); } function equalHeights( elements ) { var tallest = 0; $.each( elements, function(key, elements) { $.each( elements, function() { if ( $(this).outerHeight() > tallest ) { tallest = $(this).outerHeight(); } }); $(elements).css( 'height', tallest ); if ( $(window).width() < 992 ) { $(elements).css( 'height', 'auto' ); } tallest = 0; }); } function initSelects() { var avoid = [ '.country_select', '.state_select', '.feedFormField', '.job-manager-category-dropdown[multiple]', '.job-manager-multiselect', '#search_categories', '.search_region', '.comment-form-rating #rating', '.iti-mobile-select', '#job_region' ]; $( 'select' ).each(function() { if ( $(this).parent().hasClass( 'select' ) ) { return; } if ( $(this).is( avoid.join( ',' ) ) ) { return; } var existingClass = null; if ( $(this).attr( 'class' ) ) { var existingClass = $(this).attr( 'class' ).split(' ')[0]; } $(this) .wrap( '
' ); }); // For categories $("#search_categories").select2({ placeholder: "Choose a category…", allowClear: true }); // For region $("#job_region").select2({ placeholder: "Choose a region…", allowClear: true }); } function initEqualHeight() { var equalHeighters = [ $( '.footer-widget' ), $( '.jobify_widget_jobs_spotlight .single-job-spotlight' ) ]; equalHeights( equalHeighters ); $(window).resize(function() { equalHeights( equalHeighters ); }); } function initPopups() { $( 'body' ).on( 'click', '.popup-trigger-ajax', function(e) { e.preventDefault(); var get_class_list = $(this).attr( 'class' ); get_class_list = get_class_list.replace( 'popup-trigger-ajax', '' ); Jobify.App.popup({ items: { src: $(this).attr( 'href' ), type: 'ajax' }, callbacks: { parseAjax: function(mfpResponse) { mfpResponse.data = '
' + '
' + $(mfpResponse.data).find( '.page-title' ).text() + '
' + $(mfpResponse.data).find('article.hentry').html() + '
'; }, ajaxContentAdded: function() { $( 'body' ).trigger( 'popup-trigger-ajax' ); initForms(); } } }); }); $( 'body' ).on( 'click', '.popup-trigger', function(e) { e.preventDefault(); Jobify.App.popup({ items: { src: $(this).attr( 'href' ) } }); }); } function initForms() { initSelects(); $(document).on( 'submit', '.modal form.login, .modal form.register', function(e) { var form = $(this); var error = false; var base = $(this).serialize(); var button = $(this).find( '[type=submit]' ); var data = base + '&' + button.attr("name") + "=" + button.val(); var request = $.ajax({ url: jobifySettings.homeurl, data: data, type: 'POST', cache: false, async: false }).done(function(response) { form.find( $( '.woocommerce-error' ) ).remove(); var $response = $( '#ajax-response' ); var html = $.parseHTML(response); $response.append(html); error = $response.find( $( '.woocommerce-error' ) ); if ( error.length > 0 ) { form.prepend( error.clone() ); $response.html(''); e.preventDefault(); } }); }); } function resizeChosen() { $( '.chosen-container' ).each(function() { $(this).attr( 'style', 'width: 100%' ); }); } return { init : function() { fixedHeader(); mobileMenu(); initSelects(); initEqualHeight(); initPopups(); initForms(); $( 'div.job_listings' ).on( 'updated_results', function() { initSelects(); }); $( '.bookmark-notice' ).on( 'click', function(e) { e.preventDefault(); $.magnificPopup.open({ type: 'inline', fixedContentPos: false, verticalFit: false, fixedBgPos: true, overflowY: 'scroll', items: { src: '
' + '
' + $(this).text() + '
' + $( '.wp-job-manager-bookmarks-form' ).prop( 'outerHTML' ) + '
' } }); }); $(window).on( 'resize', resizeChosen ); resizeChosen(); // Geo My WP Association $( '.search_jobs' ).each(function() { $gjm_use = $(this).find( 'input[name="gjm_use"]' ); if ( ! $gjm_use.length ) { return; } $(this).addClass( 'gjm_use' ); }); }, popup : function( args ) { return $.magnificPopup.open( $.extend( args, { type : 'inline', fixedContentPos : false, tClose: jobifySettings.i18n.magnific.tClose, tLoading: jobifySettings.i18n.magnific.tLoading, ajax: { tError: jobifySettings.i18n.magnific.tError }, zoom: { enabled: true } } ) ); }, /** * Check if we are on a mobile device (or any size smaller than 980). * Called once initially, and each time the page is resized. */ isMobile : function( width ) { var isMobile = false; var width = 1180; if ( $(window).width() <= width ) isMobile = true; return isMobile; } } } )(jQuery); (function($){ jQuery("form#submit-job-form input").removeAttr("maxlength"); jQuery("form#submit-job-form").validate({ ignore: [], rules: { job_description: { required: !0, custom: function(value, element) { tinymce.triggerSave(), console.log("value", jQuery("#job_description").val()), "" == jQuery("#job_description").val() ? (jQuery("html, body").animate({ scrollTop: jQuery("#wp-job_description-editor-container").offset().top }, 2e3), jQuery("#wp-job_description-editor-container").addClass("error")) : jQuery("#wp-job_description-editor-container").removeClass("error"); } }, job_region: { required: !0 }, "job_category[]": { required: !0 } }, messages: { job_description: { required: "Please Fill Job Description!!" }, job_region: { required: "Please select the field!!" }, "job_category[]": { required: "Please select atleast one!!" } } }); })(jQuery); (jQuery), function() { updateContainer(); window.onresize = function() { updateContainer(); }; function updateContainer() { if ( document.getElementById('job-manager-alerts') && this.innerWidth < 768 ) { document.getElementById('main').setAttribute('style','flex: 0 0 100%; max-width: 100%' ); document.getElementById('secondary').setAttribute('style','flex: 0 0 100%; max-width: 100%' ); } else { document.getElementById('main').setAttribute('style','' ); document.getElementById('secondary').setAttribute('style','' ); } } } jQuery( document ).ready(function($) { Jobify.App.init(); $('#search_category_dropdown').select2(); });