\
" + et_pb_new_template_options.modal_text + "
\
\
\
\
\
\
\
\
" + cats_selector + " \
\
\
\
\
\
\
\
";
$( 'body' ).append( $modal );
return false;
} );
$( 'body' ).on( 'click', '.et_pb_prompt_dont_proceed', function() {
$( this ).closest( '.et_pb_modal_overlay' ).remove();
} );
$( 'body' ).on( 'change', '#new_template_type', function() {
var selected_type = $( this ).val();
if ( 'module' === selected_type || 'fullwidth_module' === selected_type ) {
$( '.et_module_tabs_options' ).css( 'display', 'block' );
} else {
$( '.et_module_tabs_options' ).css( 'display', 'none' );
}
} );
$( 'body' ).on( 'click', '.et_pb_create_template:not(.clicked_button)', function() {
var $this_button = $( this ),
$this_form = $this_button.closest( '.et_pb_prompt_modal' ),
template_name = $this_form.find( '#et_pb_new_template_name' ).val();
if ( '' === template_name ) {
$this_form.find( '#et_pb_new_template_name' ).focus();
} else {
var template_shortcode = '',
layout_scope = $this_form.find( $( '#et_pb_template_global' ) ).is( ':checked' ) ? 'global' : 'not_global',
layout_type = $this_form.find( '#new_template_type' ).val(),
module_width = 'regular',
template_built_for_post_type = '',
selected_tabs = '',
selected_cats = '',
new_cat = $this_form.find( '#et_pb_new_cat_name' ).val();
if ( 'module' === layout_type || 'fullwidth_module' === layout_type ) {
if ( ! $( '.et_module_tabs_options input' ).is( ':checked' ) ) {
$( '.et_pb_error_message_save_template' ).css( "display", "block" );
return;
} else {
selected_tabs = '';
$( '.et_module_tabs_options input' ).each( function() {
var this_input = $( this );
if ( this_input.is( ':checked' ) ) {
selected_tabs += '' !== selected_tabs ? ',' + this_input.val() : this_input.val();
}
});
selected_tabs = 'general,advanced,css' === selected_tabs ? 'all' : selected_tabs;
}
}
if ( $( '.layout_cats_container input' ).is( ':checked' ) ) {
$( '.layout_cats_container input' ).each( function() {
var this_input = $( this );
if ( this_input.is( ':checked' ) ) {
selected_cats += '' !== selected_cats ? ',' + this_input.val() : this_input.val();
}
});
}
switch ( layout_type ) {
case 'row' :
template_shortcode = '[et_pb_row template_type="row"][/et_pb_row]';
break;
case 'section' :
template_shortcode = '[et_pb_section template_type="section"][et_pb_row][/et_pb_row][/et_pb_section]';
break;
case 'module' :
template_shortcode = '[et_pb_module_placeholder selected_tabs="' + selected_tabs + '"]';
break;
case 'fullwidth_module' :
template_shortcode = '[et_pb_fullwidth_module_placeholder selected_tabs="' + selected_tabs + '"]';
module_width = 'fullwidth';
layout_type = 'module';
break;
case 'fullwidth_section' :
template_shortcode = '[et_pb_section template_type="section" fullwidth="on"][/et_pb_section]';
layout_type = 'section';
break;
case 'specialty_section' :
template_shortcode = '[et_pb_section template_type="section" specialty="on" skip_module="true" specialty_placeholder="true"][/et_pb_section]';
layout_type = 'section';
break;
}
$this_button.addClass( 'clicked_button' );
$this_button.closest( '.et_pb_prompt_buttons' ).find( '.spinner' ).addClass( 'et_pb_visible_spinner' );
$.ajax( {
type: "POST",
url: et_pb_new_template_options.ajaxurl,
dataType: 'json',
data:
{
action : 'et_pb_save_layout',
et_load_nonce : et_pb_new_template_options.et_load_nonce,
et_layout_name : template_name,
et_layout_built_for_post_type: template_built_for_post_type,
et_layout_content : template_shortcode,
et_layout_scope : layout_scope,
et_layout_type : layout_type,
et_module_width : module_width,
et_layout_cats : selected_cats,
et_layout_new_cat : new_cat
},
success: function( data ) {
window.location.href = decodeURIComponent( unescape( data.edit_link ) );
}
} );
}
} );
$( '#et_show_export_section' ).click( function() {
var this_link = $( this ),
margin_value = this_link.hasClass( 'et_pb_opened' ) ? '-100%' : '0';
$( '.et_pb_export_section' ).animate( { marginTop: margin_value }, 500 );
this_link.toggleClass( 'et_pb_opened' );
});
});
})(jQuery)