Edit File by line
/home/barbar84/public_h.../wp-conte.../themes/Divi/epanel/js
File: functions-init.js
/* <![CDATA[ */
[0] Fix | Delete
var clearpath = ePanelSettings.clearpath;
[1] Fix | Delete
[2] Fix | Delete
jQuery(document).ready(function($){
[3] Fix | Delete
var editors = [];
[4] Fix | Delete
[5] Fix | Delete
function addEditorInstance(codeEditor, $element, config) {
[6] Fix | Delete
if (!$element || $element.length === 0) {
[7] Fix | Delete
return;
[8] Fix | Delete
}
[9] Fix | Delete
var instance = codeEditor.initialize( $element , {
[10] Fix | Delete
codemirror: config,
[11] Fix | Delete
} );
[12] Fix | Delete
if (instance && instance.codemirror) {
[13] Fix | Delete
editors.push(instance.codemirror);
[14] Fix | Delete
}
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
// Use WP 4.9 CodeMirror Editor for Custom CSS
[18] Fix | Delete
var codeEditor = window.wp && window.wp.codeEditor;
[19] Fix | Delete
if (codeEditor && codeEditor.initialize && codeEditor.defaultSettings && codeEditor.defaultSettings.codemirror) {
[20] Fix | Delete
[21] Fix | Delete
// User ET CodeMirror theme
[22] Fix | Delete
var configCSS = $.extend({}, codeEditor.defaultSettings.codemirror, {
[23] Fix | Delete
theme: 'et',
[24] Fix | Delete
});
[25] Fix | Delete
var configHTML = $.extend({}, configCSS, {
[26] Fix | Delete
mode: 'htmlmixed',
[27] Fix | Delete
});
[28] Fix | Delete
[29] Fix | Delete
if ($('#divi_custom_css').length > 0) {
[30] Fix | Delete
// Divi Theme
[31] Fix | Delete
addEditorInstance(codeEditor, $('#divi_custom_css'), configCSS);
[32] Fix | Delete
addEditorInstance(codeEditor, $('#divi_integration_head'), configHTML);
[33] Fix | Delete
addEditorInstance(codeEditor, $('#divi_integration_body'), configHTML);
[34] Fix | Delete
addEditorInstance(codeEditor, $('#divi_integration_single_top'), configHTML);
[35] Fix | Delete
addEditorInstance(codeEditor, $('#divi_integration_single_bottom'), configHTML);
[36] Fix | Delete
} else if ($('#extra_custom_css').length > 0) {
[37] Fix | Delete
// Extra Theme
[38] Fix | Delete
addEditorInstance(codeEditor, $('#extra_custom_css'), configCSS);
[39] Fix | Delete
addEditorInstance(codeEditor, $('#extra_integration_head'), configHTML);
[40] Fix | Delete
addEditorInstance(codeEditor, $('#extra_integration_body'), configHTML);
[41] Fix | Delete
addEditorInstance(codeEditor, $('#extra_integration_single_top'), configHTML);
[42] Fix | Delete
addEditorInstance(codeEditor, $('#extra_integration_single_bottom'), configHTML);
[43] Fix | Delete
}
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
var $palette_inputs = $( '.et_color_palette_main_input' );
[47] Fix | Delete
[48] Fix | Delete
$('#epanel-content,#epanel-content > div').tabs({
[49] Fix | Delete
fx: {
[50] Fix | Delete
opacity: 'toggle',
[51] Fix | Delete
duration:'fast'
[52] Fix | Delete
},
[53] Fix | Delete
selected: 0,
[54] Fix | Delete
activate: function( event, ui ) {
[55] Fix | Delete
$epanel = $('#epanel');
[56] Fix | Delete
[57] Fix | Delete
if ( $epanel.hasClass('onload') ) {
[58] Fix | Delete
$epanel.removeClass('onload');
[59] Fix | Delete
}
[60] Fix | Delete
}
[61] Fix | Delete
});
[62] Fix | Delete
[63] Fix | Delete
$(".et-box-description").click(function(){
[64] Fix | Delete
var descheading = $(this).parent('.et-epanel-box').find(".et-box-title h3").html();
[65] Fix | Delete
var desctext = $(this).parent('.et-epanel-box').find(".et-box-title .et-box-descr").html();
[66] Fix | Delete
[67] Fix | Delete
$('body').append("<div id='custom-lbox'><div class='et-box-desc'><div class='et-box-desc-top'>"+ ePanelSettings.help_label +"</div><div class='et-box-desc-content'><h3>"+descheading+"</h3>"+desctext+"<div class='et-lightbox-close'></div> </div> <div class='et-box-desc-bottom'></div> </div></div>");
[68] Fix | Delete
[69] Fix | Delete
et_pb_center_modal( $( '.et-box-desc' ) );
[70] Fix | Delete
[71] Fix | Delete
$( '.et-lightbox-close' ).click( function() {
[72] Fix | Delete
et_pb_close_modal( $( '#custom-lbox' ) );
[73] Fix | Delete
});
[74] Fix | Delete
});
[75] Fix | Delete
[76] Fix | Delete
$(".et-defaults-button.epanel-reset").click(function(e) {
[77] Fix | Delete
e.preventDefault();
[78] Fix | Delete
$(".reset-popup-overlay, .defaults-hover").addClass('active');
[79] Fix | Delete
[80] Fix | Delete
et_pb_center_modal( $( '.defaults-hover' ) );
[81] Fix | Delete
});
[82] Fix | Delete
[83] Fix | Delete
$( '.no' ).click( function() {
[84] Fix | Delete
et_pb_close_modal( $( '.reset-popup-overlay' ), 'no_remove' );
[85] Fix | Delete
[86] Fix | Delete
//clean the modal classes when animation complete
[87] Fix | Delete
setTimeout( function() {
[88] Fix | Delete
$( '.reset-popup-overlay, .defaults-hover' ).removeClass( 'active et_pb_modal_closing' );
[89] Fix | Delete
}, 600 );
[90] Fix | Delete
});
[91] Fix | Delete
[92] Fix | Delete
// ":not([safari])" is desirable but not necessary selector
[93] Fix | Delete
// ":not([safari])" is desirable but not necessary selector
[94] Fix | Delete
$('#epanel input:checkbox:not([safari]):not(.yes_no_button)').checkbox();
[95] Fix | Delete
$('#epanel input[safari]:checkbox:not(.yes_no_button)').checkbox({cls:'jquery-safari-checkbox'});
[96] Fix | Delete
$('#epanel input:radio:not(.yes_no_button)').checkbox();
[97] Fix | Delete
[98] Fix | Delete
// Yes - No button UI
[99] Fix | Delete
$('.yes_no_button').each(function() {
[100] Fix | Delete
var $checkbox = $(this);
[101] Fix | Delete
var value = $checkbox.is(':checked');
[102] Fix | Delete
var state = value ? 'et_pb_on_state' : 'et_pb_off_state';
[103] Fix | Delete
var $template = $($('#epanel-yes-no-button-template').html()).find('.et_pb_yes_no_button').addClass(state);
[104] Fix | Delete
[105] Fix | Delete
$checkbox.hide().after($template);
[106] Fix | Delete
[107] Fix | Delete
if ( 'et_pb_static_css_file' === $checkbox.attr( 'id' ) ) {
[108] Fix | Delete
$checkbox
[109] Fix | Delete
.parent()
[110] Fix | Delete
.addClass( state )
[111] Fix | Delete
.next()
[112] Fix | Delete
.addClass( 'et_pb_clear_static_css' )
[113] Fix | Delete
.on( 'click', function() {
[114] Fix | Delete
epanel_clear_static_css( false, true );
[115] Fix | Delete
});
[116] Fix | Delete
[117] Fix | Delete
if ( ! value ) {
[118] Fix | Delete
$checkbox.parents('.et-epanel-box').next().hide();
[119] Fix | Delete
}
[120] Fix | Delete
}
[121] Fix | Delete
});
[122] Fix | Delete
[123] Fix | Delete
$('.et-box-content').on( 'click', '.et_pb_yes_no_button', function(e){
[124] Fix | Delete
e.preventDefault();
[125] Fix | Delete
// Fix for nested .et-box-content triggering checkboxes multiple times.
[126] Fix | Delete
e.stopPropagation();
[127] Fix | Delete
[128] Fix | Delete
var $click_area = $(this),
[129] Fix | Delete
$box_content = $click_area.closest('.et-box-content'),
[130] Fix | Delete
$checkbox = $box_content.find('input[type="checkbox"]'),
[131] Fix | Delete
$state = $box_content.find('.et_pb_yes_no_button');
[132] Fix | Delete
[133] Fix | Delete
if ( $state.parent().next().hasClass( 'et_pb_clear_static_css' ) ) {
[134] Fix | Delete
$state = $state.add( $state.parent() );
[135] Fix | Delete
[136] Fix | Delete
if ( $checkbox.is( ':checked' ) ) {
[137] Fix | Delete
$box_content.parent().next().hide();
[138] Fix | Delete
} else {
[139] Fix | Delete
$box_content.parent().next().show();
[140] Fix | Delete
}
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
$state.toggleClass('et_pb_on_state et_pb_off_state');
[144] Fix | Delete
[145] Fix | Delete
if ( $checkbox.is(':checked' ) ) {
[146] Fix | Delete
$checkbox.prop('checked', false);
[147] Fix | Delete
} else {
[148] Fix | Delete
$checkbox.prop('checked', true);
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
});
[152] Fix | Delete
[153] Fix | Delete
var $save_message = $("#epanel-ajax-saving");
[154] Fix | Delete
[155] Fix | Delete
$('#epanel-save-top').click(function(e){
[156] Fix | Delete
e.preventDefault();
[157] Fix | Delete
[158] Fix | Delete
$('#epanel-save').trigger('click');
[159] Fix | Delete
})
[160] Fix | Delete
[161] Fix | Delete
$('#epanel-save').click(function(){
[162] Fix | Delete
epanel_save( false, true );
[163] Fix | Delete
return false;
[164] Fix | Delete
});
[165] Fix | Delete
[166] Fix | Delete
function epanel_save( callback, message ) {
[167] Fix | Delete
[168] Fix | Delete
// If CodeMirror is used
[169] Fix | Delete
if (editors.length > 0) {
[170] Fix | Delete
$.each(editors, function(i, editor) {
[171] Fix | Delete
if (editor.save) {
[172] Fix | Delete
// Make sure we store changes into original textarea
[173] Fix | Delete
editor.save();
[174] Fix | Delete
}
[175] Fix | Delete
})
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
var options_fromform = $('#main_options_form').formSerialize(),
[179] Fix | Delete
add_nonce = '&_ajax_nonce='+ePanelSettings.epanel_nonce;
[180] Fix | Delete
[181] Fix | Delete
options_fromform += add_nonce;
[182] Fix | Delete
[183] Fix | Delete
$.ajax({
[184] Fix | Delete
type: "POST",
[185] Fix | Delete
url: ajaxurl,
[186] Fix | Delete
data: options_fromform,
[187] Fix | Delete
beforeSend: function ( xhr ){
[188] Fix | Delete
if ( message ) {
[189] Fix | Delete
$save_message.removeAttr('class').fadeIn('fast');
[190] Fix | Delete
}
[191] Fix | Delete
},
[192] Fix | Delete
success: function(response){
[193] Fix | Delete
if ( message ) {
[194] Fix | Delete
$save_message.addClass('success-animation');
[195] Fix | Delete
[196] Fix | Delete
setTimeout(function(){
[197] Fix | Delete
$save_message.fadeOut();
[198] Fix | Delete
},500);
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
if ( $.isFunction( callback ) ) {
[202] Fix | Delete
callback();
[203] Fix | Delete
}
[204] Fix | Delete
}
[205] Fix | Delete
});
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
function epanel_clear_static_css( callback, message ) {
[209] Fix | Delete
var data = {
[210] Fix | Delete
action: 'et_core_page_resource_clear',
[211] Fix | Delete
et_owner: 'all',
[212] Fix | Delete
et_post_id: 'all',
[213] Fix | Delete
clear_page_resources_nonce: ePanelSettings.et_core_nonces.clear_page_resources_nonce,
[214] Fix | Delete
};
[215] Fix | Delete
[216] Fix | Delete
$.ajax( {
[217] Fix | Delete
type: "POST",
[218] Fix | Delete
url: ajaxurl,
[219] Fix | Delete
data: data,
[220] Fix | Delete
beforeSend: function ( xhr ) {
[221] Fix | Delete
if ( message ) {
[222] Fix | Delete
$save_message.removeAttr( 'class' ).fadeIn( 'fast' );
[223] Fix | Delete
}
[224] Fix | Delete
},
[225] Fix | Delete
success: function ( response ) {
[226] Fix | Delete
if ( message ) {
[227] Fix | Delete
$save_message.addClass( 'success-animation' );
[228] Fix | Delete
[229] Fix | Delete
setTimeout( function () {
[230] Fix | Delete
$save_message.fadeOut();
[231] Fix | Delete
}, 500 );
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
if ( $.isFunction( callback ) ) {
[235] Fix | Delete
callback();
[236] Fix | Delete
}
[237] Fix | Delete
}
[238] Fix | Delete
} );
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
function et_pb_close_modal( $overlay, no_overlay_remove ) {
[242] Fix | Delete
var $modal_container = $overlay;
[243] Fix | Delete
[244] Fix | Delete
// add class to apply the closing animation to modal
[245] Fix | Delete
$modal_container.addClass( 'et_pb_modal_closing' );
[246] Fix | Delete
[247] Fix | Delete
//remove the modal with overlay when animation complete
[248] Fix | Delete
setTimeout( function() {
[249] Fix | Delete
if ( 'no_remove' !== no_overlay_remove ) {
[250] Fix | Delete
$modal_container.remove();
[251] Fix | Delete
}
[252] Fix | Delete
}, 600 );
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
if ( $palette_inputs.length ) {
[256] Fix | Delete
$palette_inputs.each( function() {
[257] Fix | Delete
var $this_input = $( this ),
[258] Fix | Delete
$palette_wrapper = $this_input.closest( '.et-box-content' ),
[259] Fix | Delete
$colorpalette_colorpickers = $palette_wrapper.find( '.input-colorpalette-colorpicker' ),
[260] Fix | Delete
colorpalette_colorpicker_index = 0,
[261] Fix | Delete
saved_palette = $this_input.val().split('|');
[262] Fix | Delete
[263] Fix | Delete
$colorpalette_colorpickers.each( function(){
[264] Fix | Delete
var $colorpalette_colorpicker = $(this),
[265] Fix | Delete
colorpalette_colorpicker_color = saved_palette[ colorpalette_colorpicker_index ];
[266] Fix | Delete
[267] Fix | Delete
$colorpalette_colorpicker.val( colorpalette_colorpicker_color ).wpColorPicker({
[268] Fix | Delete
hide : false,
[269] Fix | Delete
default : $(this).data( 'default-color' ),
[270] Fix | Delete
width: 313,
[271] Fix | Delete
palettes : false,
[272] Fix | Delete
change : function( event, ui ) {
[273] Fix | Delete
var $input = $(this);
[274] Fix | Delete
var data_index = $input.attr('data-index');
[275] Fix | Delete
var $preview = $palette_wrapper.find('.colorpalette-item-' + data_index + ' .color');
[276] Fix | Delete
var color = ui.color.toString();
[277] Fix | Delete
[278] Fix | Delete
$input.val( color );
[279] Fix | Delete
$preview.css({ 'backgroundColor' : color });
[280] Fix | Delete
saved_palette[ data_index - 1 ] = color;
[281] Fix | Delete
$this_input.val( saved_palette.join( '|' ) );
[282] Fix | Delete
}
[283] Fix | Delete
});
[284] Fix | Delete
[285] Fix | Delete
$colorpalette_colorpicker.trigger( 'change' );
[286] Fix | Delete
[287] Fix | Delete
colorpalette_colorpicker_index++;
[288] Fix | Delete
} );
[289] Fix | Delete
[290] Fix | Delete
$palette_wrapper.on( 'click', '.colorpalette-item', function(e){
[291] Fix | Delete
e.preventDefault();
[292] Fix | Delete
[293] Fix | Delete
var $colorpalette_item = $(this),
[294] Fix | Delete
data_index = $colorpalette_item.attr('data-index');
[295] Fix | Delete
[296] Fix | Delete
// Hide other colorpalette colorpicker
[297] Fix | Delete
$palette_wrapper.find( '.colorpalette-colorpicker' ).removeClass( 'active' );
[298] Fix | Delete
[299] Fix | Delete
// Display selected colorpalette colorpicker
[300] Fix | Delete
$palette_wrapper.find( '.colorpalette-colorpicker[data-index="' + data_index + '"]' ).addClass( 'active' );
[301] Fix | Delete
});
[302] Fix | Delete
});
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
if ( typeof etCore !== 'undefined' && typeof etCore.portability !== 'undefined' ) {
[306] Fix | Delete
// Portability integration.
[307] Fix | Delete
etCore.portability.save = function( callback ) {
[308] Fix | Delete
epanel_save( callback, false );
[309] Fix | Delete
}
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
function et_pb_center_modal( $modal ) {
[313] Fix | Delete
var modal_height = $modal.outerHeight(),
[314] Fix | Delete
modal_height_adjustment = 0 - ( modal_height / 2 );
[315] Fix | Delete
[316] Fix | Delete
$modal.css({
[317] Fix | Delete
top : '50%',
[318] Fix | Delete
bottom : 'auto',
[319] Fix | Delete
marginTop : modal_height_adjustment
[320] Fix | Delete
});
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
});
[324] Fix | Delete
/* ]]> */
[325] Fix | Delete
[326] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function