"use strict"; var lepopup_sending = false; var lepopup_context_menu_object = null; var lepopup_properties_panel_object = null; var lepopup_form_pages = new Array(); var lepopup_form_page_active = null; var lepopup_form_elements = new Array(); var lepopup_form_last_id = 0; var lepopup_integration_last_id = 0; var lepopup_payment_gateway_last_id = 0; var lepopup_form_changed = false; var lepopup_css_tools = [{}]; var lepopup_font_weights = { '100' : 'Thin', '200' : 'Extra-light', '300' : 'Light', '400' : 'Normal', '500' : 'Medium', '600' : 'Demi-bold', '700' : 'Bold', '800' : 'Heavy', '900' : 'Black' }; function lepopup_cookies_reset(_button) { if (lepopup_sending) return false; var button_object = _button; jQuery(button_object).find("i").attr("class", "fas fa-spinner fa-spin"); jQuery(button_object).addClass("lepopup-button-disabled"); lepopup_sending = true; var post_data = {"action" : "lepopup-cookies-reset"}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { jQuery(button_object).find("i").attr("class", "fas fa-times"); jQuery(button_object).removeClass("lepopup-button-disabled"); try { var data = jQuery.parseJSON(return_data); if (data.status == "OK") { lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", "Something went wrong. We got unexpected server response."); } } catch(error) { lepopup_global_message_show("danger", "Something went wrong. We got unexpected server response."); } lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(button_object).find("i").attr("class", "fas fa-times"); jQuery(button_object).removeClass("lepopup-button-disabled"); lepopup_global_message_show("danger", "Something went wrong. We got unexpected server response."); lepopup_sending = false; } }); return false; } /* Dialog Popup - begin */ var lepopup_dialog_buttons_disable = false; function lepopup_dialog_open(_settings) { var settings = { width: 480, height: 210, title: lepopup_esc_html__('Confirm action'), close_enable: true, ok_enable: true, cancel_enable: true, ok_label: lepopup_esc_html__('Yes'), cancel_label: lepopup_esc_html__('Cancel'), echo_html: function() {this.html(lepopup_esc_html__('Do you really want to continue?')); this.show();}, ok_function: function() {lepopup_dialog_close();}, cancel_function: function() {lepopup_dialog_close();}, html: function(_html) {jQuery("#lepopup-dialog .lepopup-dialog-content-html").html(_html);}, show: function() {jQuery("#lepopup-dialog .lepopup-dialog-loading").fadeOut(300);} } var objects = [settings, _settings], settings = objects.reduce(function (r, o) { Object.keys(o).forEach(function (k) { r[k] = o[k]; }); return r; }, {}); lepopup_dialog_buttons_disable = false; jQuery("#lepopup-dialog .lepopup-dialog-loading").show(); jQuery("#lepopup-dialog .lepopup-dialog-title h3 label").html(settings.title); if (settings.close_enable) jQuery("#lepopup-dialog .lepopup-dialog-title a").show(); else jQuery("#lepopup-dialog .lepopup-dislog-title a").hide(); settings.echo_html(); var window_height = Math.min(2*parseInt((jQuery(window).height() - 100)/2, 10), settings.height); var window_width = Math.min(Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 880), 960), settings.width); jQuery("#lepopup-dialog").height(window_height); jQuery("#lepopup-dialog").width(window_width); jQuery("#lepopup-dialog .lepopup-dialog-inner").height(window_height); jQuery("#lepopup-dialog .lepopup-dialog-content").height(window_height - 104); jQuery("#lepopup-dialog .lepopup-dialog-button").off("click"); jQuery("#lepopup-dialog .lepopup-dialog-button").removeClass("lepopup-dialog-button-disabled"); if (settings.ok_enable) { jQuery("#lepopup-dialog .lepopup-dialog-button-ok").find("label").html(settings.ok_label); jQuery("#lepopup-dialog .lepopup-dialog-button-ok").on("click", function(e){ e.preventDefault(); if (!lepopup_dialog_buttons_disable && typeof settings.ok_function == "function") { settings.ok_function(); } }); jQuery("#lepopup-dialog .lepopup-dialog-button-ok").show(); } else jQuery("#lepopup-dialog .lepopup-dialog-button-ok").hide(); if (settings.cancel_enable) { jQuery("#lepopup-dialog .lepopup-dialog-button-cancel").find("label").html(settings.cancel_label); jQuery("#lepopup-dialog .lepopup-dialog-button-cancel").on("click", function(e){ e.preventDefault(); if (!lepopup_dialog_buttons_disable && typeof settings.cancel_function == "function") { settings.cancel_function(); } }); jQuery("#lepopup-dialog .lepopup-dialog-button-cancel").show(); } else jQuery("#lepopup-dialog .lepopup-dialog-button-cancel").hide(); jQuery("#lepopup-dialog-overlay").fadeIn(300); jQuery("#lepopup-dialog").css({ 'top': '50%', 'transform': 'translate(-50%, -50%) scale(1)', '-webkit-transform': 'translate(-50%, -50%) scale(1)' }); } function lepopup_dialog_close() { jQuery("#lepopup-dialog-overlay").fadeOut(300); jQuery("#lepopup-dialog").css({ 'transform': 'translate(-50%, -50%) scale(0)', '-webkit-transform': 'translate(-50%, -50%) scale(0)' }); setTimeout(function(){jQuery("#lepopup-dialog").css("top", "-3000px")}, 300); return false; } /* Dialog Popup - end */ /* Settings - begin */ function lepopup_settings_save(_button) { if (lepopup_sending) return false; lepopup_sending = true; var button_object = _button; jQuery(button_object).find("i").attr("class", "fas fa-spinner fa-spin"); jQuery(button_object).addClass("lepopup-button-disabled"); jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : jQuery(".lepopup-settings-form").serialize(), success : function(return_data) { jQuery(button_object).find("i").attr("class", "fas fa-check"); jQuery(button_object).removeClass("lepopup-button-disabled"); var data; try { if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { lepopup_global_message_show('success', data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(button_object).find("i").attr("class", "fas fa-check"); jQuery(button_object).removeClass("lepopup-button-disabled"); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } /* Settings - end */ /* Campaigns - begin */ function lepopup_campaign_save(_button) { if (lepopup_sending) return false; lepopup_sending = true; var button_object = _button; jQuery(button_object).find("i").attr("class", "fas fa-spinner fa-spin"); jQuery(button_object).addClass("lepopup-button-disabled"); jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : jQuery(".lepopup-campaign-properties-form").serialize(), success : function(return_data) { jQuery(button_object).find("i").attr("class", "fas fa-check"); jQuery(button_object).removeClass("lepopup-button-disabled"); var data; try { if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { lepopup_global_message_show('success', data.message); location.reload(true); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(button_object).find("i").attr("class", "fas fa-check"); jQuery(button_object).removeClass("lepopup-button-disabled"); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } function lepopup_campaigns_status_toggle(_object) { if (lepopup_sending) return false; lepopup_sending = true; var campaign_id = jQuery(_object).attr("data-id"); var campaign_status = jQuery(_object).attr("data-status"); var campaign_status_label = jQuery(_object).closest("tr").find("td.column-active").html(); var doing_label = jQuery(_object).attr("data-doing"); var do_label = jQuery(_object).html(); jQuery(_object).html(" "+doing_label); jQuery(_object).closest("tr").find(".row-actions").addClass("visible"); jQuery(_object).closest("tr").find("td.column-active").html(""); var post_data = {"action" : "lepopup-campaigns-status-toggle", "campaign-id" : campaign_id, "campaign-status" : campaign_status}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { jQuery(_object).html(do_label); try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(_object).html(data.campaign_action); jQuery(_object).attr("data-status", data.campaign_status); jQuery(_object).attr("data-doing", data.campaign_action_doing); if (data.campaign_status == "active") jQuery(_object).closest("tr").find(".lepopup-table-list-badge-status").html(""); else jQuery(_object).closest("tr").find(".lepopup-table-list-badge-status").html("Inactive"); lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { jQuery(_object).closest("tr").find("td.column-active").html(campaign_status_label); lepopup_global_message_show("danger", data.message); } else { jQuery(_object).closest("tr").find("td.column-active").html(campaign_status_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { jQuery(_object).closest("tr").find("td.column-active").html(campaign_status_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); jQuery(_object).html(do_label); jQuery(_object).closest("tr").find("td.column-active").html(campaign_status_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } function lepopup_campaigns_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__("Please confirm that you want to delete the campaign.", "lepopup")+"
"); this.show(); }, ok_label: 'Delete', ok_function: function(e){ _lepopup_campaigns_delete(_object); lepopup_dialog_close(); } }); return false; } function _lepopup_campaigns_delete(_object) { if (lepopup_sending) return false; lepopup_sending = true; var campaign_id = jQuery(_object).attr("data-id"); var doing_label = jQuery(_object).attr("data-doing"); var do_label = jQuery(_object).html(); jQuery(_object).html(" "+doing_label); jQuery(_object).closest("tr").find(".row-actions").addClass("visible"); var post_data = {"action" : "lepopup-campaigns-delete", "campaign-id" : campaign_id}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(_object).closest("tr").fadeOut(300, function(){ jQuery(_object).closest("tr").remove(); }); lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_object).html(do_label); jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); jQuery(_object).html(do_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } function lepopup_campaigns_stats_reset(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__("Please confirm that you want to reset campaign statistics.", "lepopup")+"
"); this.show(); }, ok_label: 'Reset', ok_function: function(e){ _lepopup_campaigns_stats_reset(_object); lepopup_dialog_close(); } }); return false; } function _lepopup_campaigns_stats_reset(_object) { if (lepopup_sending) return false; lepopup_sending = true; var campaign_id = jQuery(_object).attr("data-id"); var doing_label = jQuery(_object).attr("data-doing"); var do_label = jQuery(_object).html(); jQuery(_object).html(" "+doing_label); jQuery(_object).closest("tr").find(".row-actions").addClass("visible"); var post_data = {"action" : "lepopup-campaigns-stats-reset", "campaign-id" : campaign_id}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_object).html(do_label); jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); jQuery(_object).html(do_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } function lepopup_campaigns_resize() { if (lepopup_more_active) { var popup_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var popup_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 840); jQuery("#lepopup-more-using").height(popup_height); jQuery("#lepopup-more-using").width(popup_width); jQuery("#lepopup-more-using .lepopup-admin-popup-inner").height(popup_height); jQuery("#lepopup-more-using .lepopup-admin-popup-content").height(popup_height - 52); } if (lepopup_campaign_stats_active) { var popup_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var popup_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 840); jQuery("#lepopup-campaign-stats").height(popup_height); jQuery("#lepopup-campaign-stats").width(popup_width); jQuery("#lepopup-campaign-stats .lepopup-admin-popup-inner").height(popup_height); jQuery("#lepopup-campaign-stats .lepopup-admin-popup-content").height(popup_height - 52); } if (lepopup_campaign_properties_active) { var popup_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var popup_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 840); jQuery("#lepopup-campaign-properties").height(popup_height); jQuery("#lepopup-campaign-properties").width(popup_width); jQuery("#lepopup-campaign-properties .lepopup-admin-popup-inner").height(popup_height); jQuery("#lepopup-campaign-properties .lepopup-admin-popup-content").height(popup_height - 104); } } function lepopup_campaigns_ready() { lepopup_campaigns_resize(); jQuery(window).resize(function() { lepopup_campaigns_resize(); }); } /* Campaigns - end */ /* Form Editor - begin */ function lepopup_create() { var name = jQuery("#lepopup-create-name").val(); if (name.length < 1) name = lepopup_esc_html__("Untitled Popup"); lepopup_form_options["name"] = name; jQuery(".lepopup-admin-create-overlay").fadeOut(300); jQuery(".lepopup-admin-create").fadeOut(300); if (lepopup_gettingstarted_enable == "on") lepopup_gettingstarted("create-form", 0); return false; } function lepopup_save(_object) { if (lepopup_sending) return false; lepopup_sending = true; if (lepopup_element_properties_active) { lepopup_properties_panel_close(); } jQuery(_object).find("i").attr("class", "fas fa-spinner fa-spin"); var post_pages = new Array(); jQuery(".lepopup-pages-bar-item, .lepopup-pages-bar-item-confirmation").each(function(){ var page_id = jQuery(this).attr("data-id"); for (var i=0; i"); } _lepopup_init_elements("#lepopup-element-"+idx); } } } function lepopup_properties_panel_open(_object) { var idx; if (lepopup_element_properties_active) { if (jQuery(lepopup_element_properties_active).attr("id") == jQuery(_object).attr("id")) return; } if (lepopup_properties_panel_loading) return; lepopup_properties_panel_loading = true; clearTimeout(lepopup_rebuild_active_element_timer); jQuery(".lepopup-properties-panel-loading").fadeIn(300); if (lepopup_element_properties_active) { lepopup_properties_populate(); _lepopup_rebuild_active_element(); jQuery(".lepopup-element-selected").removeClass("lepopup-element-selected"); jQuery(".lepopup-layer-selected").removeClass("lepopup-layer-selected"); jQuery(".lepopup-properties-panel .lepopup-color").minicolors("destroy"); jQuery(".lepopup-properties-panel .lepopup-admin-popup-content-form").html(""); } lepopup_element_properties_target = ".lepopup-properties-panel"; lepopup_element_properties_active = _object; jQuery("body").animate({"left" : "-420px"}).addClass("lepopup-body-shifted"); jQuery(".lepopup-properties-panel").animate({"right" : "0px"}); jQuery(".lepopup-properties-panel-close").show(); jQuery(".lepopup-properties-panel-close").animate({"right" : "0px"}); jQuery(lepopup_element_properties_active).addClass("lepopup-element-selected"); idx = jQuery(lepopup_element_properties_active).attr("id"); if (idx) { idx = idx.replace("lepopup-element-", ""); jQuery(".lepopup-layers-list").find("li.lepopup-layer-"+idx).addClass("lepopup-layer-selected"); } setTimeout(function(){ _lepopup_properties_prepare(_object); jQuery(".lepopup-properties-panel-loading").fadeOut(300); lepopup_properties_panel_loading = false; }, 500); return false; } function lepopup_properties_panel_close() { clearTimeout(lepopup_rebuild_active_element_timer); jQuery("body").animate({"left" : "0px"}).removeClass("lepopup-body-shifted"); jQuery(".lepopup-properties-panel").animate({"right" : "-420px"}); jQuery(".lepopup-properties-panel-close").fadeOut(300); jQuery(".lepopup-properties-panel-close").animate({"right" : "-420px"}); if (!lepopup_properties_panel_loading) { lepopup_properties_populate(); _lepopup_rebuild_active_element(); } jQuery(".lepopup-element-selected").removeClass("lepopup-element-selected"); jQuery(".lepopup-layer-selected").removeClass("lepopup-layer-selected"); lepopup_element_properties_active = null; lepopup_element_properties_target = null; setTimeout(function() { jQuery(".lepopup-properties-panel .lepopup-color").minicolors("destroy"); jQuery(".lepopup-properties-panel .lepopup-admin-popup-content-form").html(""); }, 300); return false; } /* Properties Panel - end */ /* Element actions - begin */ function _lepopup_element_delete(_i) { if (lepopup_element_properties_active) { lepopup_properties_panel_close(); } if (lepopup_form_elements[_i] == null) return; lepopup_form_elements[_i] = null; _lepopup_layers_sync(lepopup_form_page_active); } function lepopup_element_delete(_object) { var i = jQuery(_object).attr("id"); i = i.replace("lepopup-element-", ""); if (lepopup_form_elements[i] == null) return false; lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to delete the element.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Delete'), ok_function: function(e) { _lepopup_element_delete(i); lepopup_build(); lepopup_dialog_close(); } }); return false; } function _lepopup_element_duplicate(_parent_id, _new_parent_id, _i) { if (lepopup_element_properties_active) { lepopup_properties_panel_close(); } if (lepopup_form_elements[_i] == null) return; var clone = Object.assign({}, lepopup_form_elements[_i]); var j = lepopup_form_elements.push(clone); lepopup_form_last_id++; lepopup_form_elements[j-1]["id"] = lepopup_form_last_id; lepopup_form_elements[j-1]["_parent"] = _new_parent_id; if (_parent_id != _new_parent_id) { lepopup_form_elements[j-1]["_seq"] = lepopup_form_last_id; } _lepopup_layers_sync(lepopup_form_page_active); } function lepopup_element_duplicate(_object, _page_num) { var i = jQuery(_object).attr("id"); i = i.replace("lepopup-element-", ""); if (lepopup_form_elements[i] == null) return false; lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to duplicate the element.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Duplicate'), ok_function: function(e){ if (lepopup_is_numeric(_page_num) && _page_num < lepopup_form_pages.length && lepopup_form_pages[_page_num] != null) { _lepopup_element_duplicate(lepopup_form_elements[i]['_parent'], lepopup_form_pages[_page_num]['id'], i); } else { _lepopup_element_duplicate(lepopup_form_elements[i]['_parent'], lepopup_form_elements[i]['_parent'], i); } lepopup_build(); lepopup_dialog_close(); } }); return false; } function _lepopup_element_move(_parent_id, _i) { if (lepopup_element_properties_active) { lepopup_properties_panel_close(); } if (lepopup_form_elements[_i] == null) return; lepopup_form_elements[_i]["_parent"] = _parent_id; lepopup_form_elements[_i]["_seq"] = lepopup_form_last_id; } function lepopup_element_move(_object, _page_num) { var i = jQuery(_object).attr("id"); i = i.replace("lepopup-element-", ""); if (lepopup_form_elements[i] == null) return false; lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to move the element to other page.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Move'), ok_function: function(e){ if (lepopup_is_numeric(_page_num) && _page_num < lepopup_form_pages.length && lepopup_form_pages[_page_num] != null) { _lepopup_element_move(lepopup_form_pages[_page_num]['id'], i); } lepopup_build(); lepopup_dialog_close(); } }); return false; } var lepopup_element_properties_active = null; var lepopup_element_properties_target = null; var lepopup_element_properties_data_changed = false; function _lepopup_properties_prepare(_object) { var properties, i, id, input_fields = new Array(); var html = "", tab_html = "", tooltip_html = ""; var sections_opened = 0; var icon_left, icon_right, options, options2, fonts, selected, temp; var type = jQuery(_object).attr("data-type"); if (typeof type == undefined || type == "") return false; if (type == "settings") { properties = lepopup_form_options; jQuery("#lepopup-element-properties").find(".lepopup-admin-popup-title h3").html(" "+lepopup_esc_html__("Popup Settings")); } else if (type == "page" || type == "page-confirmation") { id = jQuery(_object).closest("li").attr("data-id"); properties = null; for (var i=0; i "+lepopup_esc_html__("Page Settings")); } else { i = jQuery(_object).attr("id"); i = i.replace("lepopup-element-", ""); properties = lepopup_form_elements[i]; jQuery("#lepopup-element-properties").find(".lepopup-admin-popup-title h3").html(" "+lepopup_esc_html__("Element Properties")+" "+lepopup_escape_html(properties["name"])+""); } input_fields = lepopup_input_sort(); // Prepare editor state - begin for (var key in lepopup_meta[type]) { if (lepopup_meta[type].hasOwnProperty(key)) { tooltip_html = ""; if (lepopup_meta[type][key].hasOwnProperty('tooltip')) { tooltip_html = "
"+lepopup_meta[type][key]['tooltip']+"
"; } switch(lepopup_meta[type][key]['type']) { case 'tab': for (var j=0; j"+lepopup_meta[type][key]['label']+""; html += "
"; break; case 'sections': options = ""; for (var section_key in lepopup_meta[type][key]['sections']) { if (lepopup_meta[type][key]['sections'].hasOwnProperty(section_key)) { if (options == "") selected = "lepopup-section-active"; else selected = ""; options += " "+lepopup_escape_html(lepopup_meta[type][key]['sections'][section_key]['label'])+""; } } html += "

"+options+"

"; break; case 'section-start': html += "
"; sections_opened++; break; case 'section-end': if (sections_opened > 0) { html += "
"; sections_opened--; } break; case 'key-fields': options = ""; options2 = ""; temp = ""; if (input_fields.length > 0) { for (var j=0; j"; options2 += ""; temp = input_fields[j]['page-id']; } options += ""; options2 += ""; } options += ""; options2 += ""; } temp = "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'datetime-args': options = ""; for (var option_key in lepopup_meta[type][key]['date-format-options']) { if (lepopup_meta[type][key]['date-format-options'].hasOwnProperty(option_key)) { selected = ""; if (option_key == properties[key+"-date-format"]) selected = " selected='selected'"; options += ""+lepopup_escape_html(lepopup_meta[type][key]['date-format-options'][option_key])+""; } } temp = "
"; options = ""; for (var option_key in lepopup_meta[type][key]['time-format-options']) { if (lepopup_meta[type][key]['time-format-options'].hasOwnProperty(option_key)) { selected = ""; if (option_key == properties[key+"-time-format"]) selected = " selected='selected'"; options += ""+lepopup_escape_html(lepopup_meta[type][key]['time-format-options'][option_key])+""; } } temp += "
"; options = ""; for (var j=0; j<(lepopup_meta[type][key]['locale-options']).length; j++) { selected = ""; if (lepopup_meta[type][key]['locale-options'][j] == properties[key+"-locale"]) selected = " selected='selected'"; options += ""+lepopup_escape_html(lepopup_meta[type][key]['locale-options'][j])+""; } temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'color': html += "
"+tooltip_html+"
"; break; case 'two-colors': temp = ""; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'three-colors': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'four-colors': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'five-colors': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'width-height': temp = ""; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'top-left': temp = ""; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'two-numbers': temp = ""; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'three-numbers': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'four-numbers': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'number-string-number': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'block-width': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'imageselect-style': temp = ""; options = ""; for (var option_key in lepopup_meta[type][key]['options']) { if (lepopup_meta[type][key]['options'].hasOwnProperty(option_key)) { options += ""+lepopup_escape_html(lepopup_meta[type][key]['options'][option_key])+""; } } temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'local-imageselect-style': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'imageselect-mode': case 'tile-mode': temp = ""; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'popup-position': options = ""; options += "
"; options += "
"; options += "
"; options += "
"; options += "
"; options += "
"; options += "
"; options += "
"; options += "
"; options += "
"; options += "
"; html += "
"+tooltip_html+"
"+options+"
"; break; case 'animation': temp = ""; options = ""; for (var option_key in lepopup_animations_in) { if (lepopup_animations_in.hasOwnProperty(option_key)) { options += ""+lepopup_escape_html(lepopup_animations_in[option_key])+""; } } options2 = ""; for (var option_key in lepopup_animations_out) { if (lepopup_animations_out.hasOwnProperty(option_key)) { options2 += ""+lepopup_escape_html(lepopup_animations_out[option_key])+""; } } temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'overlay-animation': temp = ""; options = ""; for (var option_key in lepopup_animations_in) { if (lepopup_animations_in.hasOwnProperty(option_key)) { options += ""+lepopup_escape_html(lepopup_animations_in[option_key])+""; } } temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'text-style': temp = ""; options = ""; options += ""; for (var j=0; j"+lepopup_escape_html(lepopup_localfonts[j])+""; } options += ""; options += ""; for (var j=0; j"+lepopup_escape_html(lepopup_webfonts[j])+""; } options += ""; options2 = ""; if (!properties.hasOwnProperty(key+'-weight') || properties[key+'-weight'] == "") { if (properties.hasOwnProperty(key+'-bold') && properties[key+'-bold'] == "on") selected = '700'; else selected = 'inherit'; } else selected = properties[key+'-weight']; for (var option_key in lepopup_font_weights) { if (lepopup_font_weights.hasOwnProperty(option_key)) { options2 += ""+lepopup_escape_html(option_key + " - " + lepopup_font_weights[option_key])+""; } } temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'background-style': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += ""; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'border-style': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'global-tile-style': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'local-tile-style': temp = ""; temp += "
TinySmallMediumLargeHuge
"; temp += "
DefaultFull
"; temp += "
"; temp += "
2c3c4c6c
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'icon-style': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += ""; temp += ""; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'star-style': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'shadow': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'padding': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'align': temp = ""; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'checkbox-radio-style': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'local-checkbox-style': temp = ""; temp += "
"; temp += "
"; temp += "
2c3c4c6c
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'checkbox-view': options = ""; for (var j=0; j
"; } html += "
"+tooltip_html+"
"+options+"
"; break; case 'radio-view': options = ""; for (var j=0; j
"; } html += "
"+tooltip_html+"
"+options+"
"; break; case 'multiselect-style': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'description-position': temp = ""; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'description-style': temp = ""; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'units': html += "
"+tooltip_html+"
"; break; case 'id': html += "
"+tooltip_html+"
"; break; case 'text': html += "
"+tooltip_html+"
"; break; case 'integer': html += "
"+tooltip_html+"
"; break; case 'from': html += "
"+tooltip_html+"
"; break; case 'text-shortcodes': html += "
"+tooltip_html+"
"; break; case 'textarea-shortcodes': html += "
"+tooltip_html+"
"; break; case 'textarea': html += "
"+tooltip_html+"
"; break; case 'text-number': html += "
"+tooltip_html+"
"; break; case 'checkbox': selected = ""; if (properties[key] == "on") selected = " checked='checked'"; html += "
"+tooltip_html+"
"; break; case 'select': options = ""; for (var option_key in lepopup_meta[type][key]['options']) { if (lepopup_meta[type][key]['options'].hasOwnProperty(option_key)) { selected = ""; if (option_key == properties[key]) selected = " selected='selected'"; options += ""+lepopup_escape_html(lepopup_meta[type][key]['options'][option_key])+""; } } html += "
"+tooltip_html+"
"; break; case 'select-image': options = ""; for (var option_key in lepopup_meta[type][key]['options']) { if (lepopup_meta[type][key]['options'].hasOwnProperty(option_key)) { selected = ""; if (option_key == properties[key]) selected = " checked='checked'"; options += ""; } } html += "
"+tooltip_html+"
"+options+"
"; break; case 'mask': options = ""; for (var option_key in lepopup_meta[type][key]['preset-options']) { if (lepopup_meta[type][key]['preset-options'].hasOwnProperty(option_key)) { selected = ""; if (option_key == properties[key+"-preset"]) selected = " selected='selected'"; options += ""+lepopup_escape_html(lepopup_meta[type][key]['preset-options'][option_key])+""; } } temp = "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'radio-bar': options = ""; for (var option_key in lepopup_meta[type][key]['options']) { if (lepopup_meta[type][key]['options'].hasOwnProperty(option_key)) { selected = ""; if (option_key == properties[key]) selected = " checked='checked'"; options += ""; } } html += "
"+tooltip_html+"
"+options+"
"; break; case 'select-size': options = ""; for (var option_key in lepopup_meta[type][key]['options']) { if (lepopup_meta[type][key]['options'].hasOwnProperty(option_key)) { selected = ""; if (option_key == properties[key+"-size"]) { selected = " selected='selected'"; } options += ""+lepopup_escape_html(lepopup_meta[type][key]['options'][option_key])+""; } } temp = ""; temp += "
"; temp += ""; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'input-icons': temp = ""; icon_left = properties[key+"-left-icon"]; if (icon_left == "") icon_left = "lepopup-fa-noicon"; icon_right = properties[key+"-right-icon"]; if (icon_right == "") icon_right = "lepopup-fa-noicon"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'button-icons': temp = ""; icon_left = properties[key+"-left"]; if (icon_left == "") icon_left = "lepopup-fa-noicon"; icon_right = properties[key+"-right"]; if (icon_right == "") icon_right = "lepopup-fa-noicon"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'icon': temp = ""; icon_left = properties[key]; if (icon_left == "") icon_left = "lepopup-fa-noicon"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'css': html += "
"+tooltip_html+"
"; break; case 'confirmations': html += "
"+tooltip_html+"
"+lepopup_meta[type][key]['message']+"
"; break; case 'math-expressions': html += "
"+tooltip_html+"
"; break; case 'notifications': html += "
"+tooltip_html+"
"+lepopup_meta[type][key]['message']+"
"; break; case 'integrations': html += "
"+tooltip_html+"
"+lepopup_meta[type][key]['message']+"
"; if (lepopup_integration_providers.length == 0) { html += "
Activate at least one marketing/CRM system on Advanced Settings page.
"; } else { for (var provider_key in lepopup_integration_providers) { if (lepopup_integration_providers.hasOwnProperty(provider_key)) { html += ""; } } } html += "
"; break; case 'payment-gateways': html += "
"+tooltip_html+"
"+lepopup_meta[type][key]['message']+"
"; if (lepopup_payment_providers.length == 0) { html += "
Activate at least one payment provider on Advanced Settings page.
"; } else { for (var provider_key in lepopup_payment_providers) { if (lepopup_payment_providers.hasOwnProperty(provider_key)) { html += ""; } } } html += "
"; break; case 'validators': options = ""; for (var j=0; j "; } } html += "
"+tooltip_html+"
"+options+"
"; break; case 'filters': options = ""; for (var j=0; j "; } } html += "
"+tooltip_html+"
"+options+"
"; break; case 'error': html += "
"+tooltip_html+"
Default message: "+lepopup_escape_html(lepopup_meta[type][key]['value'])+"
"; break; case 'options': options = ""; for (var j=0; j
"+tooltip_html+"
Label
Value
"+options+"
"; break; case 'image-options': options = ""; for (var j=0; j
"; } html += "
"+tooltip_html+"
Image
Label
Value
"+options+"
"; break; case 'logic-rules': var input_ids = new Array(); for (var j=0; j 0) { temp = "
"; options = ""; for (var option_key in lepopup_meta[type][key]['actions']) { if (lepopup_meta[type][key]['actions'].hasOwnProperty(option_key)) { options += ""; } } temp += "
"; options = ""; for (var option_key in lepopup_meta[type][key]['operators']) { if (lepopup_meta[type][key]['operators'].hasOwnProperty(option_key)) { options += ""; } } temp += "
"; temp += "
"; options = ""; for (var j=0; j"; } else { temp = "
There are no elements available to use for logic rules.
"; } html += "
"+tooltip_html+"
"+temp+"
"; break; case 'colors': temp = ""; temp += "
"; temp += "
"; temp += "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'date': temp = "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'date-limit': options2 = ""; for (var j=0; j"+lepopup_escape_html(lepopup_form_elements[j]["id"]+" | "+lepopup_form_elements[j]["name"])+""; } } options = ""; for (var option_key in lepopup_meta[type][key]['type-values']) { if (lepopup_meta[type][key]['type-values'].hasOwnProperty(option_key)) { if (option_key != "field" || options2 != "") { options += ""; } } } temp = "
"; temp += ""; temp += ""; temp += ""; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'date-default': options = ""; for (var option_key in lepopup_meta[type][key]['type-values']) { if (lepopup_meta[type][key]['type-values'].hasOwnProperty(option_key)) { if (option_key != "field") { options += ""; } } } temp = "
"; temp += ""; temp += ""; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'time': temp = "
"; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'time-limit': options2 = ""; for (var j=0; j"+lepopup_escape_html(lepopup_form_elements[j]["id"]+" | "+lepopup_form_elements[j]["name"])+""; } } options = ""; for (var option_key in lepopup_meta[type][key]['type-values']) { if (lepopup_meta[type][key]['type-values'].hasOwnProperty(option_key)) { if (option_key != "field" || options2 != "") { options += ""; } } } temp = "
"; temp += ""; temp += ""; temp += "
"; html += "
"+tooltip_html+"
"+temp+"
"; break; case 'message': html += "
"+lepopup_meta[type][key]['message']+"
"; break; case 'hr': html += '
'; break; default: break; } } } for (var j=0; j lepopup_integration_last_id) lepopup_integration_last_id = properties["integrations"][j]['id']; lepopup_properties_integrations_add(properties["integrations"][j], j); } } if (properties.hasOwnProperty("payment-gateways") && Array.isArray(properties["payment-gateways"])) { for (var j=0; j lepopup_payment_gateway_last_id) lepopup_payment_gateway_last_id = properties["payment-gateways"][j]['id']; lepopup_properties_payment_gateways_add(properties["payment-gateways"][j], j); } } if (properties.hasOwnProperty("options")) { jQuery(".lepopup-properties-options-box").resizable({ grid: [5, 5], handles: "s" }); jQuery(".lepopup-properties-options-container").sortable({ items: ".lepopup-properties-options-item", forcePlaceholderSize: true, dropOnEmpty: true, placeholder: "lepopup-properties-options-item-placeholder", handle: ".lepopup-properties-options-item-handler", stop: function(event, ui) { lepopup_properties_change(); lepopup_element_properties_data_changed = true; } }); jQuery(".lepopup-properties-options-item").disableSelection(); } jQuery(".lepopup-properties-content .lepopup-date input").each(function(){ var object = this; var airdatepicker = jQuery(object).airdatepicker().data('airdatepicker'); airdatepicker.destroy(); jQuery(object).airdatepicker({ inline_popup : true, autoClose : true, timepicker : false, dateFormat : lepopup_form_options["datetime-args-date-format"] }); }); jQuery(".lepopup-properties-content .lepopup-date span").on("click", function(e){ e.preventDefault(); var input = jQuery(this).parent().children("input"); var airdatepicker = jQuery(input).airdatepicker().data('airdatepicker'); airdatepicker.show(); }); jQuery(".lepopup-properties-content .lepopup-time input").each(function(){ var object = this; var airdatepicker = jQuery(object).airdatepicker().data('airdatepicker'); airdatepicker.destroy(); jQuery(object).airdatepicker({ inline_popup : true, autoClose : true, timepicker : true, onlyTimepicker : true, timeFormat : lepopup_form_options["datetime-args-time-format"] }); }); jQuery(".lepopup-properties-content .lepopup-time span").on("click", function(e){ e.preventDefault(); var input = jQuery(this).parent().children("input"); var airdatepicker = jQuery(input).airdatepicker().data('airdatepicker'); airdatepicker.show(); }); jQuery("#lepopup-properties-tabs a").on("click", function(e){ e.preventDefault(); if (jQuery(this).hasClass("lepopup-tab-active")) return; var tab_set = jQuery(this).parent(); var active_tab = jQuery(tab_set).find(".lepopup-tab-active").attr("href"); jQuery(tab_set).find(".lepopup-tab-active").removeClass("lepopup-tab-active"); var tab = jQuery(this).attr("href"); jQuery(this).addClass("lepopup-tab-active"); jQuery(active_tab).fadeOut(300, function(){ jQuery(tab).fadeIn(300); }); }); jQuery(".lepopup-bar-options span").on("click", function(e){ var parent = jQuery(this).parent(); var value = jQuery(this).attr("data-value"); var current_value = jQuery(parent).find("input").val(); jQuery(parent).children("span").removeClass("lepopup-bar-option-selected"); if (current_value == value) { value = ""; jQuery(parent).find("input").val(value); } else { jQuery(this).addClass("lepopup-bar-option-selected"); jQuery(parent).find("input").val(value); } lepopup_properties_change(); if (jQuery(parent).find("input").attr("name") == "lepopup-label-style-position") { if (value == "left" || value == "right") jQuery("#lepopup-content-label-style-width").fadeIn(300); else jQuery("#lepopup-content-label-style-width").fadeOut(300); } }); jQuery(".lepopup-image-url span").on("click", function(e){ e.preventDefault(); var input = jQuery(this).parent().children("input"); var media_frame = wp.media({ title: 'Select Image', library: { type: 'image' }, multiple: false }); media_frame.on("select", function() { var attachment = media_frame.state().get("selection").first(); jQuery(input).val(attachment.attributes.url); lepopup_properties_change(); }); media_frame.open(); }); jQuery(".lepopup-sections").each(function(){ jQuery(this).find("a").on("click", function(e){ e.preventDefault(); if (jQuery(this).hasClass("lepopup-section-active")) return; var sections_set = jQuery(this).parent(); var active_section = jQuery(sections_set).find(".lepopup-section-active").attr("href"); jQuery(sections_set).find(".lepopup-section-active").removeClass("lepopup-section-active"); var section = jQuery(this).attr("href"); jQuery(this).addClass("lepopup-section-active"); if (jQuery(active_section).length > 0) { jQuery(active_section).fadeOut(300, function(){ jQuery(section).fadeIn(300); }); } else jQuery(section).fadeIn(300); }); jQuery(jQuery(this).find("a").first().attr("href")).show(); }); jQuery(".lepopup-color").minicolors({ format: 'rgb', opacity: true, change: function(value, opacity) { lepopup_properties_change(); } }); jQuery(".lepopup-slider").each(function(){ var input = jQuery(this).parent().children("input"); jQuery(this).slider({ min: parseInt(jQuery(this).attr("data-min"), 10), max: parseInt(jQuery(this).attr("data-max"), 10), step: parseInt(jQuery(this).attr("data-step"), 10), value: lepopup_is_numeric(jQuery(input).val()) ? parseInt(jQuery(input).val(), 10) : 4, create: function() { jQuery(this).find(".ui-slider-handle").text(jQuery(this).slider("value")); }, slide: function( event, ui ) { jQuery(this).find(".ui-slider-handle").text(ui.value); jQuery(input).val(ui.value); } }); }); jQuery(".lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); jQuery(".lepopup-properties-content-validators-allowed a[title], .lepopup-properties-content-filters-allowed a[title]").tooltipster({ maxWidth: 360, theme: "tooltipster-dark", side: "bottom" }); // jQuery(".lepopup-properties-content input").on("keyup", function(e){ // lepopup_properties_change(); // }); // jQuery(".lepopup-properties-content input, .lepopup-properties-content select").on("change", function(e){ // lepopup_properties_change(); // }); jQuery(".lepopup-properties-content input, .lepopup-properties-content textarea").on("input", function(e){ lepopup_properties_change(); }); jQuery(".lepopup-properties-content select").on("change", function(e){ lepopup_properties_change(); }); lepopup_properties_visible_conditions(_object); // Prepare editor state - end return false; } function lepopup_properties_open(_object) { if (lepopup_element_properties_active) { lepopup_properties_panel_close(); } lepopup_element_properties_target = "#lepopup-element-properties"; jQuery(lepopup_element_properties_target+" .lepopup-admin-popup-content-form").html(""); var window_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var window_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 880), 1080); jQuery("#lepopup-element-properties").height(window_height); jQuery("#lepopup-element-properties").width(window_width); jQuery("#lepopup-element-properties .lepopup-admin-popup-inner").height(window_height); jQuery("#lepopup-element-properties .lepopup-admin-popup-content").height(window_height - 104); jQuery("#lepopup-element-properties-overlay").fadeIn(300); jQuery("#lepopup-element-properties").fadeIn(300); lepopup_element_properties_active = _object; lepopup_element_properties_data_changed = false; jQuery("#lepopup-element-properties .lepopup-admin-popup-loading").show(); setTimeout(function(){ _lepopup_properties_prepare(_object); jQuery("#lepopup-element-properties .lepopup-admin-popup-loading").hide(); }, 500); return false; } function lepopup_properties_save() { jQuery(lepopup_element_properties_target+" .lepopup-admin-popup-buttons .lepopup-admin-button").find("i").attr("class", "fas fa-spin fa-spinner"); lepopup_properties_populate(); _lepopup_properties_close(); lepopup_build(); return false; } function lepopup_properties_populate() { var properties, logic, attachments, input, page_i, temp, id; if (lepopup_element_properties_active == null) return false; var type = jQuery(lepopup_element_properties_active).attr("data-type"); if (typeof type == undefined || type == "") return false; // jQuery(lepopup_element_properties_target+" .lepopup-admin-popup-buttons .lepopup-admin-button").find("i").attr("class", "fas fa-spin fa-spinner"); if (type == "settings") { properties = lepopup_form_options; } else if (type == "page" || type == "page-confirmation") { id = jQuery(lepopup_element_properties_active).closest("li").attr("data-id"); jQuery(lepopup_element_properties_active).closest("li").attr("data-name", jQuery("[name='lepopup-name']").val()); properties = null; for (var i=0; i 1) { jQuery(input).each(function(){ if (jQuery(this).is(":checked")) { properties[key] = jQuery(this).val(); return false; } }); } else if (input.length > 0) { if (jQuery(input).is(":checked")) properties[key] = "on"; else properties[key] = jQuery(input).val(); } } } if (properties.hasOwnProperty("css")) { properties["css"] = new Array(); jQuery(".lepopup-properties-content-css .lepopup-properties-sub-item").each(function() { (properties["css"]).push({"selector" : jQuery(this).find(".lepopup-properties-sub-item-body select").val(), "css" : jQuery(this).find(".lepopup-properties-sub-item-body textarea").val()}); }); } if (properties.hasOwnProperty("validators")) { properties["validators"] = new Array(); jQuery(".lepopup-properties-content-validators .lepopup-properties-sub-item").each(function() { var validator_type = jQuery(this).attr("data-type"); if (lepopup_validators.hasOwnProperty(validator_type)) { var validator = {"type" : validator_type, "properties" : {}}; for (var key in lepopup_validators[validator_type]["properties"]) { if (lepopup_validators[validator_type]["properties"].hasOwnProperty(key)) { if (jQuery(this).find("[name=lepopup-validators-"+key+"]").length > 0) { if (jQuery(this).find("[name=lepopup-validators-"+key+"]").is(":checked")) validator["properties"][key] = "on"; else validator["properties"][key] = jQuery(this).find("[name=lepopup-validators-"+key+"]").val(); } } } (properties["validators"]).push(validator); } }); } if (properties.hasOwnProperty("filters")) { properties["filters"] = new Array(); jQuery(".lepopup-properties-content-filters .lepopup-properties-sub-item").each(function() { var filter_type = jQuery(this).attr("data-type"); if (lepopup_filters.hasOwnProperty(filter_type)) { var filter = {"type" : filter_type, "properties" : {}}; for (var key in lepopup_filters[filter_type]["properties"]) { if (lepopup_filters[filter_type]["properties"].hasOwnProperty(key)) { if (jQuery(this).find("[name=lepopup-filters-"+key+"]").length > 0) { if (jQuery(this).find("[name=lepopup-filters-"+key+"]").is(":checked")) filter["properties"][key] = "on"; else filter["properties"][key] = jQuery(this).find("[name=lepopup-filters-"+key+"]").val(); } } } (properties["filters"]).push(filter); } }); } if (properties.hasOwnProperty("options")) { properties["options"] = new Array(); jQuery(".lepopup-properties-options-container .lepopup-properties-options-item").each(function() { var selected = "off"; if (jQuery(this).hasClass("lepopup-properties-options-item-default")) selected = "on"; (properties["options"]).push({"default" : selected, "label" : jQuery(this).find(".lepopup-properties-options-label").val(), "value" : jQuery(this).find(".lepopup-properties-options-value").val(), "image" : jQuery(this).find(".lepopup-properties-options-image").val()}); }); } if (properties.hasOwnProperty("confirmations")) { properties["confirmations"] = new Array(); jQuery(".lepopup-properties-content-confirmations .lepopup-properties-sub-item").each(function() { logic = { "action" : jQuery(this).find("[name='lepopup-confirmations-logic-action']").val(), "operator" : jQuery(this).find("[name='lepopup-confirmations-logic-operator']").val(), "rules" : new Array() }; jQuery(this).find(".lepopup-properties-logic-rule").each(function() { (logic["rules"]).push({"field" : parseInt(jQuery(this).find(".lepopup-properties-logic-rule-field").val(), 10), "rule" : jQuery(this).find(".lepopup-properties-logic-rule-rule").val(), "token" : jQuery(this).find(".lepopup-properties-logic-rule-token").val()}); }); (properties["confirmations"]).push({ "name" : jQuery(this).find("[name='lepopup-confirmations-name']").val(), "type" : jQuery(this).find("[name='lepopup-confirmations-type']").val(), "form" : jQuery(this).find("[name='lepopup-confirmations-form']").val(), "url" : jQuery(this).find("[name='lepopup-confirmations-url']").val(), "delay" : jQuery(this).find("[name='lepopup-confirmations-delay']").val(), "payment-gateway" : jQuery(this).find("[name='lepopup-confirmations-payment-gateway']").val(), "reset-form" : jQuery(this).find("[name='lepopup-confirmations-reset-form']").is(":checked") ? "on" : "off", "logic-enable" : jQuery(this).find("[name='lepopup-confirmations-logic-enable']").is(":checked") ? "on" : "off", "logic" : logic }); }); } if (properties.hasOwnProperty("notifications")) { properties["notifications"] = new Array(); jQuery(".lepopup-properties-content-notifications .lepopup-properties-sub-item").each(function() { logic = { "action" : jQuery(this).find("[name='lepopup-notifications-logic-action']").val(), "operator" : jQuery(this).find("[name='lepopup-notifications-logic-operator']").val(), "rules" : new Array() }; jQuery(this).find(".lepopup-properties-logic-rule").each(function() { (logic["rules"]).push({"field" : parseInt(jQuery(this).find(".lepopup-properties-logic-rule-field").val(), 10), "rule" : jQuery(this).find(".lepopup-properties-logic-rule-rule").val(), "token" : jQuery(this).find(".lepopup-properties-logic-rule-token").val()}); }); attachments = new Array(); jQuery(this).find(".lepopup-properties-attachment").each(function() { attachments.push({"source" : jQuery(this).find(".lepopup-properties-attachment-source").val(), "token" : jQuery(this).find(".lepopup-properties-attachment-token").val()}); }); (properties["notifications"]).push({ "name" : jQuery(this).find("[name='lepopup-notifications-name']").val(), "enabled" : jQuery(this).find("[name='lepopup-notifications-enabled']").is(":checked") ? "on" : "off", "action" : jQuery(this).find("[name='lepopup-notifications-action']").val(), "recipient-email" : jQuery(this).find("[name='lepopup-notifications-recipient-email']").val(), "subject" : jQuery(this).find("[name='lepopup-notifications-subject']").val(), "message" : jQuery(this).find("[name='lepopup-notifications-message']").val(), "attachments" : attachments, "reply-email" : jQuery(this).find("[name='lepopup-notifications-reply-email']").val(), "from-email" : jQuery(this).find("[name='lepopup-notifications-from-email']").val(), "from-name" : jQuery(this).find("[name='lepopup-notifications-from-name']").val(), "logic-enable" : jQuery(this).find("[name='lepopup-notifications-logic-enable']").is(":checked") ? "on" : "off", "logic" : logic }); }); } if (properties.hasOwnProperty("math-expressions")) { properties["math-expressions"] = new Array(); jQuery(".lepopup-properties-content-math-expressions .lepopup-properties-sub-item").each(function() { (properties["math-expressions"]).push({ "id" : jQuery(this).find("[name='lepopup-math-id']").val(), "name" : jQuery(this).find("[name='lepopup-math-name']").val(), "expression" : jQuery(this).find("[name='lepopup-math-expression']").val(), "decimal-digits" : parseInt(jQuery(this).find("[name='lepopup-math-decimal-digits']").val(), 10), "default" : jQuery(this).find("[name='lepopup-math-default']").val() }); }); } var integrations; if (properties.hasOwnProperty("integrations")) { integrations = new Array(); jQuery(".lepopup-properties-content-integrations .lepopup-properties-sub-item").each(function() { logic = { "action" : jQuery(this).find("[name='lepopup-integrations-logic-action']").val(), "operator" : jQuery(this).find("[name='lepopup-integrations-logic-operator']").val(), "rules" : new Array() }; jQuery(this).find(".lepopup-properties-logic-rule").each(function() { (logic["rules"]).push({"field" : parseInt(jQuery(this).find(".lepopup-properties-logic-rule-field").val(), 10), "rule" : jQuery(this).find(".lepopup-properties-logic-rule-rule").val(), "token" : jQuery(this).find(".lepopup-properties-logic-rule-token").val()}); }); var content = jQuery(this).find(".lepopup-integrations-content"); var data = {}; var idx = jQuery(this).find("[name='lepopup-integrations-idx']").val(); var data_loaded = jQuery(this).attr("data-loaded"); if (properties["integrations"][idx] !== void 0 && data_loaded == "off") { data = properties["integrations"][idx]["data"]; } else { jQuery(content).find("input, select, textarea").each(function(){ if (jQuery(this).attr("data-skip") == "on") return; if (jQuery(this).attr("data-custom") == "on") return; var input_type = jQuery(this).attr("type"); var name = jQuery(this).attr("name"); var include_empty = jQuery(this).attr("data-empty"); var name_parts = name.split(/(.*?)\[(.*?)\]/); if (name_parts.length > 2) { if (!data.hasOwnProperty(name_parts[1])) data[name_parts[1]] = {}; if (input_type == "checkbox") { if (jQuery(this).is(":checked")) (data[name_parts[1]])[name_parts[2]] = jQuery(this).val(); } else if (jQuery(this).val().length > 0 || include_empty == "on") (data[name_parts[1]])[name_parts[2]] = jQuery(this).val(); } else { if (input_type == "checkbox") { if (jQuery(this).is(":checked")) data[name_parts[0]] = "on"; else data[name_parts[0]] = "off"; } else if (jQuery(this).val().length > 0 || include_empty == "on") data[name_parts[0]] = jQuery(this).val(); } }); jQuery(content).find(".lepopup-integrations-custom").each(function(){ var name, value; var param_names = jQuery(this).attr("data-names"); var param_values = jQuery(this).attr("data-values"); var param_all = jQuery(this).attr("data-all"); if (param_all != "on") param_all = "off"; data[param_names] = new Array(); data[param_values] = new Array(); var names = jQuery(this).find("input.lepopup-integrations-custom-name"); var values = jQuery(this).find("input.lepopup-integrations-custom-value"); for (var j=0; j 0 && (value.length > 0 || param_all == "on")) { (data[param_names]).push(name); (data[param_values]).push(value); } } }); } integrations.push({ "name" : jQuery(this).find("[name='lepopup-integrations-name']").val(), "enabled" : jQuery(this).find("[name='lepopup-integrations-enabled']").is(":checked") ? "on" : "off", "action" : jQuery(this).find("[name='lepopup-integrations-action']").val(), "provider" : jQuery(this).find("[name='lepopup-integrations-provider']").val(), "data" : data, "logic-enable" : jQuery(this).find("[name='lepopup-integrations-logic-enable']").is(":checked") ? "on" : "off", "logic" : logic }); }); properties["integrations"] = integrations; } if (properties.hasOwnProperty("payment-gateways")) { integrations = new Array(); jQuery(".lepopup-properties-content-payment-gateways .lepopup-properties-sub-item").each(function() { var content = jQuery(this).find(".lepopup-payment-gateways-content"); var data = {}; var idx = jQuery(this).find("[name='lepopup-payment-gateways-idx']").val(); var data_loaded = jQuery(this).attr("data-loaded"); if (properties["payment-gateways"][idx] !== void 0 && data_loaded == "off") { data = properties["payment-gateways"][idx]["data"]; } else { jQuery(content).find("input, select, textarea").each(function(){ if (jQuery(this).attr("data-skip") == "on") return; var input_type = jQuery(this).attr("type"); var name = jQuery(this).attr("name"); if (name) { var name_parts = name.split(/(.*?)\[(.*?)\]/); if (name_parts.length > 2) { if (!data.hasOwnProperty(name_parts[1])) data[name_parts[1]] = {}; if (input_type == "checkbox") { if (jQuery(this).is(":checked")) (data[name_parts[1]])[name_parts[2]] = jQuery(this).val(); } else if (jQuery(this).val().length > 0) (data[name_parts[1]])[name_parts[2]] = jQuery(this).val(); } else { if (input_type == "checkbox") { if (jQuery(this).is(":checked")) data[name_parts[0]] = jQuery(this).val(); } else if (jQuery(this).val().length > 0) data[name_parts[0]] = jQuery(this).val(); } } }); } integrations.push({ "id" : jQuery(this).find("[name='lepopup-payment-gateways-id']").val(), "name" : jQuery(this).find("[name='lepopup-payment-gateways-name']").val(), "provider" : jQuery(this).find("[name='lepopup-payment-gateways-provider']").val(), "data" : data }); }); properties["payment-gateways"] = integrations; } if (properties.hasOwnProperty("logic")) { properties["logic"] = {}; if (jQuery("#lepopup-logic-action").length > 0) properties["logic"]["action"] = jQuery("#lepopup-logic-action").val(); else properties["logic"]["action"] = lepopup_meta[properties['type']]['logic']['values']['action']; if (jQuery("#lepopup-logic-operator").length > 0) properties["logic"]["operator"] = jQuery("#lepopup-logic-operator").val(); else properties["logic"]["operator"] = lepopup_meta[properties['type']]['logic']['values']['operator']; properties["logic"]["rules"] = new Array(); jQuery(".lepopup-properties-logic-rules .lepopup-properties-logic-rule").each(function() { (properties["logic"]["rules"]).push({"field" : parseInt(jQuery(this).find(".lepopup-properties-logic-rule-field").val(), 10), "rule" : jQuery(this).find(".lepopup-properties-logic-rule-rule").val(), "token" : jQuery(this).find(".lepopup-properties-logic-rule-token").val()}); }); } if (type == "settings") { lepopup_form_options = properties; } else if (type == "page" || type == "page-confirmation") { lepopup_form_pages[page_i] = properties; jQuery(".lepopup-pages-bar-item, .lepopup-pages-bar-item-confirmation").each(function(){ var page_id = jQuery(this).attr("data-id"); if (page_id == properties['id']) jQuery(this).find("label").text(properties['name']); }); } else { lepopup_form_elements[i] = properties; } lepopup_form_changed = true; } function lepopup_properties_close() { if (lepopup_element_properties_data_changed) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__("Seems you didn't save changes. Are you sure, you want to close Properties?", "lepopup")+"
"); this.show(); }, ok_label: 'Close Properties', ok_function: function(e){ _lepopup_properties_close(); lepopup_dialog_close(); } }); } else _lepopup_properties_close(); return false; } function _lepopup_properties_close() { lepopup_element_properties_data_changed = false; lepopup_element_properties_active = null; jQuery("#lepopup-element-properties-overlay").fadeOut(300); jQuery("#lepopup-element-properties").fadeOut(300, function() { jQuery(lepopup_element_properties_target+" .lepopup-color").minicolors("destroy"); jQuery(lepopup_element_properties_target+" .lepopup-admin-popup-content-form").html(""); jQuery(lepopup_element_properties_target+" .lepopup-admin-popup-buttons .lepopup-admin-button").find("i").attr("class", "fas fa-check"); lepopup_element_properties_target = null; jQuery("body").removeClass("lepopup-static"); }); } var lepopup_rebuild_active_element_timer = null; function lepopup_properties_change() { if (lepopup_element_properties_active == null) return false; if (jQuery(lepopup_element_properties_active).hasClass("lepopup-element")) { clearTimeout(lepopup_rebuild_active_element_timer); lepopup_rebuild_active_element_timer = setTimeout(function(){ lepopup_properties_populate(); _lepopup_rebuild_active_element(); jQuery(lepopup_element_properties_active).addClass("lepopup-element-selected"); }, 1000); } lepopup_element_properties_data_changed = true; lepopup_properties_visible_conditions(lepopup_element_properties_active); return false; } function lepopup_properties_visible_conditions(_object) { var type = jQuery(_object).attr("data-type"); var input; if (typeof type == undefined || type == "") return false; var visible, value = ""; for (var key in lepopup_meta[type]) { if (lepopup_meta[type].hasOwnProperty(key)) { if (lepopup_meta[type][key].hasOwnProperty('visible')) { visible = false; for (var condition_key in lepopup_meta[type][key]['visible']) { if (lepopup_meta[type][key]['visible'].hasOwnProperty(condition_key)) { input = jQuery("[name='lepopup-"+condition_key+"']"); if (input.length > 1) { jQuery(input).each(function(){ if (jQuery(this).is(":checked")) { value = jQuery(this).val(); return false; } }); } else if (jQuery(input).is(":checked")) value = "on"; else value = jQuery(input).val(); if (Array.isArray(lepopup_meta[type][key]['visible'][condition_key])) { if (jQuery.inArray(value, lepopup_meta[type][key]['visible'][condition_key]) != -1) visible = true; } else if (value == lepopup_meta[type][key]['visible'][condition_key]) visible = true; } } if (visible) jQuery(".lepopup-properties-item[data-id='"+key+"']").fadeIn(300); else jQuery(".lepopup-properties-item[data-id='"+key+"']").fadeOut(300); } } } } function lepopup_properties_mask_preset_changed(_object) { var preset = jQuery(_object).val(); var mask_object = jQuery(_object).closest(".lepopup-properties-content").find("input"); if (preset == "custom") { jQuery(mask_object).removeAttr("readonly"); jQuery(mask_object).focus(); } else { jQuery(mask_object).val(preset); jQuery(mask_object).attr("readonly", "readonly"); } return false; } function lepopup_properties_options_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to delete the item.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Delete'), ok_function: function(e) { jQuery(_object).closest(".lepopup-properties-options-item").fadeOut(300, function(){ jQuery(this).remove(); }); lepopup_properties_change(); lepopup_element_properties_data_changed = true; lepopup_dialog_close(); } }); return false; } function lepopup_properties_options_copy(_object) { var option = jQuery(_object).closest(".lepopup-properties-options-item").clone(); jQuery(option).removeClass("lepopup-properties-options-item-default"); jQuery(_object).closest(".lepopup-properties-options-item").after(option); jQuery(option).find(".lepopup-image-url span").on("click", function(e){ e.preventDefault(); var input = jQuery(this).parent().children("input"); var media_frame = wp.media({ title: 'Select Image', library: { type: 'image' }, multiple: false }); media_frame.on("select", function() { var attachment = media_frame.state().get("selection").first(); jQuery(input).val(attachment.attributes.url); }); media_frame.open(); }); jQuery(".lepopup-properties-options-box input").off("input"); jQuery(".lepopup-properties-options-box input").on("input", function(e){ lepopup_properties_change(); lepopup_element_properties_data_changed = true; }); lepopup_properties_change(); lepopup_element_properties_data_changed = true; return false; } function lepopup_properties_options_default(_object) { var multi = jQuery(_object).closest(".lepopup-properties-options-container").attr("data-multi"); var option = jQuery(_object).closest(".lepopup-properties-options-item"); if (jQuery(option).hasClass("lepopup-properties-options-item-default")) { jQuery(option).removeClass("lepopup-properties-options-item-default"); } else { if (multi != "on") jQuery(_object).closest(".lepopup-properties-options-container").find(".lepopup-properties-options-item").removeClass("lepopup-properties-options-item-default"); jQuery(option).addClass("lepopup-properties-options-item-default"); } lepopup_properties_change(); lepopup_element_properties_data_changed = true; return false; } function lepopup_properties_options_new(_object) { var option; if (_object != null) { option = jQuery(_object).closest(".lepopup-properties-options-item").clone(); jQuery(option).removeClass("lepopup-properties-options-item-default"); jQuery(option).find("input").val(""); jQuery(_object).closest(".lepopup-properties-options-item").after(option); } else { //option = jQuery(".lepopup-properties-options-container .lepopup-properties-options-item").first().clone(); //jQuery(option).removeClass("lepopup-properties-options-item-default"); //jQuery(option).find("input").val(""); if (jQuery(".lepopup-properties-options-container").closest(".lepopup-properties-content").hasClass("lepopup-properties-image-options-table")) { option = lepopup_properties_options_item_get("", "", "", false); } else { option = lepopup_properties_options_item_get(null, "", "", false); } jQuery(".lepopup-properties-options-container").append(option); } jQuery(option).find(".lepopup-image-url span").on("click", function(e){ e.preventDefault(); var input = jQuery(this).parent().children("input"); var media_frame = wp.media({ title: 'Select Image', library: { type: 'image' }, multiple: false }); media_frame.on("select", function() { var attachment = media_frame.state().get("selection").first(); jQuery(input).val(attachment.attributes.url); lepopup_properties_change(); }); media_frame.open(); }); jQuery(".lepopup-properties-options-box input").off("input"); jQuery(".lepopup-properties-options-box input").on("input", function(e){ lepopup_properties_change(); lepopup_element_properties_data_changed = true; }); lepopup_properties_change(); lepopup_element_properties_data_changed = true; return false; } function lepopup_properties_options_item_get(_image, _label, _value, _selected) { var html, selected = ""; if (_selected) selected = " lepopup-properties-options-item-default"; html = "
"+(_image != null ? "
" : "")+"
"; return html; } function lepopup_properties_imageselect_mode_set(_object) { var value = jQuery(_object).val(); var options = jQuery(_object).closest(".lepopup-properties-item").parent().find(".lepopup-properties-options-container"); if (value == 'radio') { jQuery(options).attr("data-multi", "off"); var first_selected = jQuery(options).find(".lepopup-properties-options-item-default").first(); jQuery(options).find(".lepopup-properties-options-item").removeClass("lepopup-properties-options-item-default"); if (first_selected.length > 0) jQuery(first_selected).addClass("lepopup-properties-options-item-default"); } else { jQuery(options).attr("data-multi", "on"); } } function lepopup_properties_css_add(_type, _values) { var extra_class = "", html = "", tools = ""; if (lepopup_meta[_type].hasOwnProperty("css")) { if (_values == null) { extra_class = " lepopup-properties-sub-item-new"; lepopup_element_properties_data_changed = true; } else extra_class = " lepopup-properties-sub-item-exist"; html += "
"+tools+"
"; if (_values == null) jQuery(".lepopup-properties-content-css .lepopup-properties-sub-item-body").slideUp(300); jQuery(".lepopup-properties-content-css").append(html); if (_values != null) { jQuery(".lepopup-properties-content-css .lepopup-properties-sub-item:last").find(".lepopup-properties-sub-item-body select").val(_values["selector"]); if (_values["selector"] == "") jQuery(".lepopup-properties-content-css .lepopup-properties-sub-item:last").find(".lepopup-properties-sub-item-header label").html(""); else jQuery(".lepopup-properties-content-css .lepopup-properties-sub-item:last").find(".lepopup-properties-sub-item-header label").html(jQuery(".lepopup-properties-content-css .lepopup-properties-sub-item:last").find(".lepopup-properties-sub-item-body select option:selected").text()); jQuery(".lepopup-properties-content-css .lepopup-properties-sub-item:last").find(".lepopup-properties-sub-item-body textarea").val(_values["css"]); } else { jQuery(".lepopup-properties-sub-item-new textarea").on("input", function(e){ lepopup_properties_change(); }); jQuery(".lepopup-properties-sub-item-new select").on("change", function(e){ lepopup_properties_change(); }); } jQuery(".lepopup-properties-sub-item-new").slideDown(300); jQuery(".lepopup-properties-sub-item-new").removeClass("lepopup-properties-sub-item-new"); } return false; } function lepopup_properties_css_style_add(_object) { var value = jQuery(_object).closest(".lepopup-properties-content").find("textarea").val(); if (value != "") value += "\r\n"; value += jQuery(_object).attr("data-css"); jQuery(_object).closest(".lepopup-properties-content").find("textarea").val(value); lepopup_properties_change(); return false; } function lepopup_properties_css_selector_change(_object) { if (jQuery(_object).val() == "") jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-header label").html(""); else jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-header label").html(jQuery(_object).find("option:selected").text()); return false; } function lepopup_properties_css_details_toggle(_object) { jQuery(_object).closest(".lepopup-properties-sub-item").addClass("lepopup-freeze"); jQuery(".lepopup-properties-content-css .lepopup-properties-sub-item").each(function() { if (!jQuery(this).hasClass("lepopup-freeze")) jQuery(this).find(".lepopup-properties-sub-item-body").slideUp(300); }); jQuery(_object).closest(".lepopup-properties-sub-item").removeClass("lepopup-freeze"); jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-body").slideToggle(300); return false; } function lepopup_properties_css_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to delete the item.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Delete'), ok_function: function(e) { jQuery(_object).closest(".lepopup-properties-sub-item").slideUp(300, function() { jQuery(this).remove(); }); lepopup_properties_change(); lepopup_element_properties_data_changed = true; lepopup_dialog_close(); } }); return false; } function lepopup_properties_validators_add(_field_id, _type, _validator, _values) { var extra_class = "", html = "", tooltip_html, selected, options, property_value; var seq = 0, last; last = jQuery(".lepopup-properties-content-validators .lepopup-properties-sub-item").last(); if (jQuery(last).length) seq = parseInt(jQuery(last).attr("data-seq"), 10) + 1; if (lepopup_meta[_type].hasOwnProperty("validators") && lepopup_validators.hasOwnProperty(_validator)) { if (_values == null) { extra_class = " lepopup-properties-sub-item-new"; lepopup_element_properties_data_changed = true; } else extra_class = " lepopup-properties-sub-item-exist"; html += "
"; for (var key in lepopup_validators[_validator]["properties"]) { if (lepopup_validators[_validator]["properties"].hasOwnProperty(key)) { tooltip_html = ""; if (lepopup_validators[_validator]["properties"][key].hasOwnProperty('tooltip')) { tooltip_html = "
"+lepopup_validators[_validator]["properties"][key]['tooltip']+"
"; } property_value = ""; if (_values != null && _values.hasOwnProperty("properties") && _values["properties"].hasOwnProperty(key)) property_value = _values["properties"][key]; switch(lepopup_validators[_validator]["properties"][key]['type']) { case 'error': html += "
"+tooltip_html+"
Default message: "+lepopup_escape_html(lepopup_validators[_validator]["properties"][key]['value'])+"
"; break; case 'text': html += "
"+tooltip_html+"
"; break; case 'field': options = ""; for (var i=0; i"+lepopup_form_elements[i]['id']+" | "+lepopup_escape_html(lepopup_form_elements[i]['name'])+""; } } html += "
"+tooltip_html+"
"; break; case 'textarea': html += "
"+tooltip_html+"
"; break; case 'integer': html += "
"+tooltip_html+"
"; break; case 'checkbox': selected = ""; if (property_value == "on") selected = " checked='checked'"; html += "
"+tooltip_html+"
"; break; default: break; } } } html += "
"; if (_values == null) jQuery(".lepopup-properties-content-validators .lepopup-properties-sub-item-body").slideUp(300); jQuery(".lepopup-properties-content-validators").append(html); jQuery(".lepopup-properties-sub-item-new .lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); jQuery(".lepopup-properties-sub-item-new").slideDown(300); jQuery(".lepopup-properties-sub-item-new").removeClass("lepopup-properties-sub-item-new"); } return false; } function lepopup_properties_validators_details_toggle(_object) { jQuery(_object).closest(".lepopup-properties-sub-item").addClass("lepopup-freeze"); jQuery(".lepopup-properties-content-validators .lepopup-properties-sub-item").each(function() { if (!jQuery(this).hasClass("lepopup-freeze")) jQuery(this).find(".lepopup-properties-sub-item-body").slideUp(300); }); jQuery(_object).closest(".lepopup-properties-sub-item").removeClass("lepopup-freeze"); jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-body").slideToggle(300); return false; } function lepopup_properties_validators_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to delete the item.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Delete'), ok_function: function(e) { jQuery(_object).closest(".lepopup-properties-sub-item").slideUp(300, function() { jQuery(this).remove(); }); lepopup_element_properties_data_changed = true; lepopup_dialog_close(); } }); return false; } function lepopup_properties_integrations_constantcontact_apikey_changed(_object) { jQuery(_object).closest(".lepopup-properties-sub-item").find("input[name=token]").val(""); var token_link = jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-constantcontact-token-link"); jQuery(token_link).attr("href", jQuery(token_link).attr("data-href").replace("{api-key}", jQuery(_object).closest(".lepopup-properties-item").find("input").val())); } function lepopup_properties_integrations_name_changed(_object) { var label = jQuery(_object).val().substring(0,52)+(jQuery(_object).val().length > 52 ? "..." : ""); jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-header>label").text(label); return false; } function lepopup_properties_integrations_logic_enable_changed(_object) { var parent = jQuery(_object).closest(".lepopup-properties-sub-item"); if (jQuery(_object).is(":checked")) jQuery(parent).find(".lepopup-properties-item[data-id='logic']").fadeIn(300); else jQuery(parent).find(".lepopup-properties-item[data-id='logic']").fadeOut(300); return false; } function lepopup_integrations_ajax_options_selected(_object) { var item_id = jQuery(_object).attr("data-id"); var item_title = jQuery(_object).attr("data-title"); jQuery(_object).closest(".lepopup-integrations-ajax-options").find("input[type='text']").val(item_title); jQuery(_object).closest(".lepopup-integrations-ajax-options").find("input[type='hidden']").val(item_id); return false; } function lepopup_integrations_custom_add(_object) { var template = jQuery(_object).closest("table").find(".lepopup-integrations-custom-template"); if (jQuery(template).length > 0) { jQuery(template).before(""+jQuery(template).html()+""); } } function lepopup_integrations_ajax_options_focus(_object) { var item = jQuery(_object).closest(".lepopup-properties-sub-item"); var provider = jQuery(item).find("input[name='lepopup-integrations-provider']").val(); var field = jQuery(_object).attr("name"); var deps = {}; if (jQuery(_object).attr("data-deps")) { var deps_array = jQuery(_object).attr("data-deps").split(","); for (var i=0; i
"); } jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list i").show(); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list-data").hide(); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list").fadeIn(300); var default_error = jQuery(_object).attr("data-default-error"); if (typeof default_error === typeof undefined || default_error === false) default_error = 'Unexpected server response.'; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { var data; try { if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { var items_html = ""; for (var key in data.items) { if (data.items.hasOwnProperty(key)) { var title = lepopup_escape_html(key) + (data.items[key] == "" ? "" : " | " + lepopup_escape_html(data.items[key])); items_html += ""+title+""; } } if (Object.keys(data.items).length > 4) jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list").addClass("lepopup-vertical-scroll"); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list-data").html(items_html); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list i").hide(); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list-data").show(); } else if (data.status == "ERROR") { jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list-data").html('
'+data.message+'
'); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list i").hide(); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list-data").show(); } else { jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list-data").html("
"+default_error+"
"); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list i").hide(); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list-data").show(); } } catch(error) { jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list-data").html("
"+default_error+"
"); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list i").hide(); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list-data").show(); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list-data").html("
"+default_error+"
"); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list i").hide(); jQuery(_object).parent().find(".lepopup-integrations-ajax-options-list-data").show(); } }); } function lepopup_integrations_ajax_multiselect_scroll(_object) { if (jQuery(_object).attr("data-next-offset") == "-1") return; var content_height = jQuery(_object).prop('scrollHeight'); var position = jQuery(_object).scrollTop(); var height = jQuery(_object).height(); if (content_height - height - position < 20) { if (lepopup_sending) return false; lepopup_sending = true; var item = jQuery(_object).closest(".lepopup-properties-sub-item"); var provider = jQuery(item).find("input[name='lepopup-integrations-provider']").val(); var sub_action = jQuery(_object).attr("data-action"); var deps = {"offset" : parseInt(jQuery(_object).attr("data-next-offset"), 10)}; if (jQuery(_object).attr("data-deps")) { var deps_array = jQuery(_object).attr("data-deps").split(","); for (var i=0; i 0) { jQuery(template_object).before(""+jQuery(template_object).html()+""); } return false; } function lepopup_integrations_field_remove(_object) { var row = jQuery(_object).closest("tr"); jQuery(row).fadeOut(300, function() { jQuery(row).remove(); }); return false; }*/ function lepopup_properties_integrations_details_toggle(_object) { if (typeof _object == "undefined") return; var item = jQuery(_object).closest(".lepopup-properties-sub-item"); jQuery(item).addClass("lepopup-freeze"); jQuery(".lepopup-properties-content-integrations .lepopup-properties-sub-item").each(function() { if (!jQuery(this).hasClass("lepopup-freeze")) jQuery(this).find(".lepopup-properties-sub-item-body").slideUp(300); }); jQuery(item).removeClass("lepopup-freeze"); jQuery(item).find(".lepopup-properties-sub-item-body").slideToggle(300); if (jQuery(item).attr("data-loaded") != "on") { var provider = jQuery(item).find("input[name='lepopup-integrations-provider']").val(); if (lepopup_sending) return false; lepopup_sending = true; var post_data = { action: "lepopup-"+provider+"-settings-html" }; var idx = jQuery(item).find("input[name='lepopup-integrations-idx']").val(); if (idx >= 0 && idx <= lepopup_form_options["integrations"].length) { post_data["data"] = lepopup_encode64(JSON.stringify(lepopup_form_options["integrations"][idx]["data"])); } jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { var data; try { if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(item).attr("data-loaded", "on"); jQuery(item).find(".lepopup-integrations-content").html(data.html); jQuery(item).find(".lepopup-integrations-content .lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); jQuery(item).find(".lepopup-integrations-ajax-options input[type='text']").on("focus", function(){ lepopup_integrations_ajax_options_focus(this); }); jQuery(item).find(".lepopup-integrations-ajax-options input[type='text']").on("blur", function(){ jQuery(this).parent().find(".lepopup-integrations-ajax-options-list").fadeOut(300); }); jQuery(item).find(".lepopup-properties-sub-item-body-loading").hide(); jQuery(item).find(".lepopup-properties-sub-item-body-content").slideDown(300); } else if (data.status == "ERROR") { jQuery(item).find(".lepopup-properties-sub-item-body").slideUp(300); lepopup_global_message_show("danger", data.message); } else { jQuery(item).find(".lepopup-properties-sub-item-body").slideUp(300); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { jQuery(item).find(".lepopup-properties-sub-item-body").slideUp(300); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(item).find(".lepopup-properties-sub-item-body").slideUp(300); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); } return false; } function lepopup_properties_integrations_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to delete the item.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Delete'), ok_function: function(e) { jQuery(_object).closest(".lepopup-properties-sub-item").slideUp(300, function() { jQuery(this).remove(); }); lepopup_element_properties_data_changed = true; lepopup_dialog_close(); } }); return false; } function lepopup_properties_integrations_add(_values, _idx, _provider) { var extra_class = "", html = "", temp = "", property_value, enabled, logic_enable, logic_enable_id, provider = "", label = ""; if (typeof _provider != "undefined") { provider = _provider; label = (lepopup_integration_providers.hasOwnProperty(provider) ? lepopup_integration_providers[provider] : 'Integration'); } else if (typeof _values == "object") { provider = _values["provider"]; label = _values["name"]; } if (_values == null) { extra_class = " lepopup-properties-sub-item-new"; lepopup_element_properties_data_changed = true; } else extra_class = " lepopup-properties-sub-item-exist"; html += "
"; if (_values == null) jQuery(".lepopup-properties-content-integrations .lepopup-properties-sub-item-body").slideUp(300); jQuery(".lepopup-properties-content-integrations").append(html); jQuery(".lepopup-properties-sub-item-new .lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); lepopup_properties_integrations_name_changed(jQuery(".lepopup-properties-content-integrations .lepopup-properties-sub-item").last().find("[name='lepopup-integrations-name']")); if (jQuery(".lepopup-properties-sub-item-new").length > 0) lepopup_properties_integrations_details_toggle(jQuery(".lepopup-properties-sub-item-new").find(".lepopup-properties-sub-item-header-tools")); jQuery(".lepopup-properties-sub-item-new").removeClass("lepopup-properties-sub-item-new"); return false; } function lepopup_integrations_zapier_connect(_object) { if (lepopup_sending) return false; lepopup_sending = true; var item = jQuery(_object).closest(".lepopup-properties-sub-item"); var content = jQuery(item).find(".lepopup-integrations-custom"); var deps = {}; var fields = new Array(); var name; var names = jQuery(content).find("input.lepopup-integrations-custom-name"); for (var j=0; j 0) { fields.push(name); } } var post_data = { "action": "lepopup-zapier-connect", "webhook-url": lepopup_encode64(jQuery(item).find("[name='webhook-url']").val()), "fields": lepopup_encode64(JSON.stringify(fields)) }; jQuery(_object).find("i").attr("class", "fas fa-spinner fa-spin"); jQuery(_object).addClass("lepopup-button-disabled"); jQuery(_object).parent().find(".lepopup-integrations-ajax-inline").slideUp(300); jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { jQuery(_object).find("i").attr("class", "fas fa-download"); jQuery(_object).removeClass("lepopup-button-disabled"); var data; try { if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).find("i").attr("class", "fas fa-download"); jQuery(_object).removeClass("lepopup-button-disabled"); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); } function lepopup_properties_payment_gateways_details_toggle(_object) { if (typeof _object == "undefined") return; var item = jQuery(_object).closest(".lepopup-properties-sub-item"); jQuery(item).addClass("lepopup-freeze"); jQuery(".lepopup-properties-content-payment-gateways .lepopup-properties-sub-item").each(function() { if (!jQuery(this).hasClass("lepopup-freeze")) jQuery(this).find(".lepopup-properties-sub-item-body").slideUp(300); }); jQuery(item).removeClass("lepopup-freeze"); jQuery(item).find(".lepopup-properties-sub-item-body").slideToggle(300); if (jQuery(item).attr("data-loaded") != "on") { var provider = jQuery(item).find("input[name='lepopup-payment-gateways-provider']").val(); if (lepopup_sending) return false; lepopup_sending = true; var post_data = { action: "lepopup-"+provider+"-settings-html" }; var idx = jQuery(item).find("input[name='lepopup-payment-gateways-idx']").val(); if (idx >= 0 && idx <= lepopup_form_options["payment-gateways"].length) { post_data["data"] = lepopup_encode64(JSON.stringify(lepopup_form_options["payment-gateways"][idx]["data"])); } jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { var data; try { if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(item).attr("data-loaded", "on"); jQuery(item).find(".lepopup-payment-gateways-content").html(data.html); jQuery(item).find(".lepopup-payment-gateways-content .lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); jQuery(item).find(".lepopup-properties-sub-item-body-loading").hide(); jQuery(item).find(".lepopup-properties-sub-item-body-content").slideDown(300); } else if (data.status == "ERROR") { jQuery(item).find(".lepopup-properties-sub-item-body").slideUp(300); lepopup_global_message_show("danger", data.message); } else { jQuery(item).find(".lepopup-properties-sub-item-body").slideUp(300); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { jQuery(item).find(".lepopup-properties-sub-item-body").slideUp(300); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(item).find(".lepopup-properties-sub-item-body").slideUp(300); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); } return false; } function lepopup_properties_payment_gateways_name_changed(_object) { var label = jQuery(_object).val().substring(0,52)+(jQuery(_object).val().length > 52 ? "..." : ""); jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-header>label").text(label); lepopup_properties_payment_gateways_select_update(); return false; } function lepopup_properties_payment_gateways_select_update() { var payment_gateways = new Array(); jQuery(".lepopup-properties-content-payment-gateways .lepopup-properties-sub-item").each(function() { payment_gateways.push({"id" : jQuery(this).find("[name='lepopup-payment-gateways-id']").val(), "name" : jQuery(this).find("[name='lepopup-payment-gateways-name']").val()}); }); jQuery(".lepopup-payment-gateways-select").each(function(){ var value = jQuery(this).val(); var options = ""; for (var i=0; i"+lepopup_escape_html(payment_gateways[i]['name'])+""; } jQuery(this).html(options); }); } function lepopup_properties_payment_gateways_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to delete the item.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Delete'), ok_function: function(e) { jQuery(_object).closest(".lepopup-properties-sub-item").slideUp(300, function() { jQuery(this).remove(); lepopup_properties_payment_gateways_select_update(); }); lepopup_element_properties_data_changed = true; lepopup_dialog_close(); } }); return false; } function lepopup_properties_payment_gateways_add(_values, _idx, _provider) { var extra_class = "", html = "", property_value, enabled, provider = "", label = ""; if (typeof _provider != "undefined") { provider = _provider; label = (lepopup_payment_providers.hasOwnProperty(provider) ? lepopup_payment_providers[provider] : 'Payment Gateway'); } else if (typeof _values == "object") { provider = _values["provider"]; label = _values["name"]; } var label_beauty = label.substring(0,52)+(label.length > 52 ? "..." : ""); if (_values == null) { extra_class = " lepopup-properties-sub-item-new"; lepopup_element_properties_data_changed = true; } else extra_class = " lepopup-properties-sub-item-exist"; html += "
"; if (_values == null) jQuery(".lepopup-properties-content-payment-gateways .lepopup-properties-sub-item-body").slideUp(300); jQuery(".lepopup-properties-content-payment-gateways").append(html); jQuery(".lepopup-properties-sub-item-new .lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); if (_values == null) lepopup_properties_payment_gateways_select_update(); if (jQuery(".lepopup-properties-sub-item-new").length > 0) lepopup_properties_payment_gateways_details_toggle(jQuery(".lepopup-properties-sub-item-new").find(".lepopup-properties-sub-item-header-tools")); jQuery(".lepopup-properties-sub-item-new").removeClass("lepopup-properties-sub-item-new"); return false; } function lepopup_properties_notifications_name_changed(_object) { var label = jQuery(_object).val().substring(0,52)+(jQuery(_object).val().length > 52 ? "..." : ""); jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-header>label").text(label); return false; } function lepopup_properties_notifications_logic_enable_changed(_object) { var parent = jQuery(_object).closest(".lepopup-properties-sub-item"); if (jQuery(_object).is(":checked")) jQuery(parent).find(".lepopup-properties-item[data-id='logic']").fadeIn(300); else jQuery(parent).find(".lepopup-properties-item[data-id='logic']").fadeOut(300); return false; } function lepopup_properties_notifications_details_toggle(_object) { jQuery(_object).closest(".lepopup-properties-sub-item").addClass("lepopup-freeze"); jQuery(".lepopup-properties-content-notifications .lepopup-properties-sub-item").each(function() { if (!jQuery(this).hasClass("lepopup-freeze")) jQuery(this).find(".lepopup-properties-sub-item-body").slideUp(300); }); jQuery(_object).closest(".lepopup-properties-sub-item").removeClass("lepopup-freeze"); jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-body").slideToggle(300); return false; } function lepopup_properties_notifications_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to delete the item.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Delete'), ok_function: function(e) { jQuery(_object).closest(".lepopup-properties-sub-item").slideUp(300, function() { jQuery(this).remove(); }); lepopup_element_properties_data_changed = true; lepopup_dialog_close(); } }); return false; } function lepopup_properties_notifications_add(_values) { var extra_class = "", html = "", temp = "", tooltip_html, selected, property_value, enabled, logic_enable, logic_enable_id; var input_ids = new Array(); var file_ids = new Array(); for (var i=0; i
"; html += "
"+lepopup_notifications['name']['tooltip']+"
"; if (_values != null && _values.hasOwnProperty('enabled')) enabled = _values['enabled']; else enabled = lepopup_notifications['enabled']['value']; var enabled_id = lepopup_random_string(16); html += "
"+lepopup_notifications['enabled']['tooltip']+"
"; if (_values != null && _values.hasOwnProperty('action')) property_value = _values['action']; else property_value = lepopup_notifications['action']['value']; var options = ""; for (var option_key in lepopup_notifications['action']['options']) { if (lepopup_notifications['action']['options'].hasOwnProperty(option_key)) { options += ""; } } html += "
"+lepopup_notifications['action']['tooltip']+"
"; html += "
"+lepopup_notifications['recipient-email']['tooltip']+"
"; html += "
"+lepopup_notifications['subject']['tooltip']+"
"; var message_id = lepopup_random_string(16); html += "
"+lepopup_notifications['message']['tooltip']+"
"; if (_values != null && _values.hasOwnProperty('attachments')) property_value = _values['attachments']; else property_value = lepopup_notifications['attachments']['value']; options = ""; for (var j=0; j
"+lepopup_notifications['attachments']['tooltip']+"
"+options+"
"; html += "
"+lepopup_notifications['reply-email']['tooltip']+"
"; html += "
"+lepopup_notifications['from']['tooltip']+"
"; if (_values != null && _values.hasOwnProperty('logic-enable')) logic_enable = _values['logic-enable']; else logic_enable = lepopup_notifications['logic-enable']['value']; logic_enable_id = lepopup_random_string(16); html += "
"+lepopup_notifications['logic-enable']['tooltip']+"
"; if (_values != null && _values.hasOwnProperty('logic')) property_value = _values['logic']; else property_value = lepopup_notifications['logic']['value']; if (input_ids.length > 0) { temp = "
"; options = ""; for (var option_key in lepopup_notifications['logic']['actions']) { if (lepopup_notifications['logic']['actions'].hasOwnProperty(option_key)) { options += ""; } } temp += "
"; options = ""; for (var option_key in lepopup_notifications['logic']['operators']) { if (lepopup_notifications['logic']['operators'].hasOwnProperty(option_key)) { options += ""; } } temp += "
"; temp += "
"; options = ""; for (var j=0; j"; } else { temp = "
There are no elements available to use for logic rules.
"; } html += ""; html += ""; if (_values == null) jQuery(".lepopup-properties-content-notifications .lepopup-properties-sub-item-body").slideUp(300); jQuery(".lepopup-properties-content-notifications").append(html); jQuery(".lepopup-properties-sub-item-new .lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); lepopup_properties_notifications_name_changed(jQuery(".lepopup-properties-content-notifications .lepopup-properties-sub-item").last().find("[name='lepopup-notifications-name']")); jQuery(".lepopup-properties-sub-item-new").slideDown(300); jQuery(".lepopup-properties-sub-item-new").removeClass("lepopup-properties-sub-item-new"); return false; } function lepopup_properties_math_name_changed(_object) { var label = jQuery(_object).val().substring(0,52)+(jQuery(_object).val().length > 52 ? "..." : ""); jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-header>label").text(label); return false; } function lepopup_properties_math_details_toggle(_object) { jQuery(_object).closest(".lepopup-properties-sub-item").addClass("lepopup-freeze"); jQuery(".lepopup-properties-content-math-expressions .lepopup-properties-sub-item").each(function() { if (!jQuery(this).hasClass("lepopup-freeze")) jQuery(this).find(".lepopup-properties-sub-item-body").slideUp(300); }); jQuery(_object).closest(".lepopup-properties-sub-item").removeClass("lepopup-freeze"); jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-body").slideToggle(300); return false; } function lepopup_properties_math_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to delete the item.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Delete'), ok_function: function(e) { jQuery(_object).closest(".lepopup-properties-sub-item").slideUp(300, function() { jQuery(this).remove(); jQuery(".lepopup-shortcode-selector-list-input").remove(); }); lepopup_element_properties_data_changed = true; lepopup_dialog_close(); } }); return false; } function lepopup_properties_math_add(_values) { var extra_class = "", html = "", tooltip_html, property_value; if (_values == null) { extra_class = " lepopup-properties-sub-item-new"; lepopup_element_properties_data_changed = true; } else extra_class = " lepopup-properties-sub-item-exist"; html += "
"; if (_values != null && _values.hasOwnProperty('id')) property_value = _values['id']; else { lepopup_form_last_id++; property_value = lepopup_form_last_id; } html += "
"+lepopup_math_expressions_meta['id']['tooltip']+"
"; html += "
"+lepopup_math_expressions_meta['name']['tooltip']+"
"; html += "
"+lepopup_math_expressions_meta['expression']['tooltip']+"
"; html += "
"+lepopup_math_expressions_meta['default']['tooltip']+"
"; if (_values != null && _values.hasOwnProperty('decimal-digits')) property_value = _values['decimal-digits']; else property_value = lepopup_math_expressions_meta['decimal-digits']['value']; html += "
"+lepopup_math_expressions_meta['decimal-digits']['tooltip']+"
"; html += "
"; if (_values == null) jQuery(".lepopup-properties-content-math-expressions .lepopup-properties-sub-item-body").slideUp(300); jQuery(".lepopup-properties-content-math-expressions").append(html); jQuery(".lepopup-properties-sub-item-new .lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); lepopup_properties_math_name_changed(jQuery(".lepopup-properties-content-math-expressions .lepopup-properties-sub-item").last().find("[name='lepopup-math-name']")); jQuery(".lepopup-properties-sub-item-new").slideDown(300); jQuery(".lepopup-properties-sub-item-new").removeClass("lepopup-properties-sub-item-new"); jQuery(".lepopup-shortcode-selector-list-input").remove(); return false; } function lepopup_properties_confirmations_name_changed(_object) { var label = jQuery(_object).val().substring(0,52)+(jQuery(_object).val().length > 52 ? "..." : ""); jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-header>label").text(label); return false; } function lepopup_properties_confirmations_logic_enable_changed(_object) { var parent = jQuery(_object).closest(".lepopup-properties-sub-item"); if (jQuery(_object).is(":checked")) jQuery(parent).find(".lepopup-properties-item[data-id='logic']").fadeIn(300); else jQuery(parent).find(".lepopup-properties-item[data-id='logic']").fadeOut(300); return false; } function lepopup_properties_confirmations_type_changed(_object) { var parent = jQuery(_object).closest(".lepopup-properties-sub-item"); switch (jQuery(_object).val()) { case 'close': jQuery(parent).find(".lepopup-properties-item[data-id='form']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='url']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='delay']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='payment-gateway']").hide(); break; case 'page': jQuery(parent).find(".lepopup-properties-item[data-id='form']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='url']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='delay']").show(); jQuery(parent).find(".lepopup-properties-item[data-id='payment-gateway']").hide(); break; case 'form': jQuery(parent).find(".lepopup-properties-item[data-id='form']").show(); jQuery(parent).find(".lepopup-properties-item[data-id='url']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='delay']").show(); jQuery(parent).find(".lepopup-properties-item[data-id='payment-gateway']").hide(); break; case 'page-redirect': jQuery(parent).find(".lepopup-properties-item[data-id='form']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='url']").show(); jQuery(parent).find(".lepopup-properties-item[data-id='delay']").show(); jQuery(parent).find(".lepopup-properties-item[data-id='payment-gateway']").hide(); break; case 'page-payment': jQuery(parent).find(".lepopup-properties-item[data-id='form']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='url']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='delay']").show(); jQuery(parent).find(".lepopup-properties-item[data-id='payment-gateway']").show(); break; case 'redirect': jQuery(parent).find(".lepopup-properties-item[data-id='form']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='url']").show(); jQuery(parent).find(".lepopup-properties-item[data-id='delay']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='payment-gateway']").hide(); break; case 'payment': jQuery(parent).find(".lepopup-properties-item[data-id='form']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='url']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='delay']").hide(); jQuery(parent).find(".lepopup-properties-item[data-id='payment-gateway']").show(); break; default: break; } return false; } function lepopup_properties_confirmations_details_toggle(_object) { jQuery(_object).closest(".lepopup-properties-sub-item").addClass("lepopup-freeze"); jQuery(".lepopup-properties-content-confirmations .lepopup-properties-sub-item").each(function() { if (!jQuery(this).hasClass("lepopup-freeze")) jQuery(this).find(".lepopup-properties-sub-item-body").slideUp(300); }); jQuery(_object).closest(".lepopup-properties-sub-item").removeClass("lepopup-freeze"); jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-body").slideToggle(300); return false; } function lepopup_properties_confirmations_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to delete the item.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Delete'), ok_function: function(e) { jQuery(_object).closest(".lepopup-properties-sub-item").slideUp(300, function() { jQuery(this).remove(); }); lepopup_element_properties_data_changed = true; lepopup_dialog_close(); } }); return false; } function lepopup_properties_confirmations_add(_values) { var extra_class = "", html = "", temp = "", tooltip_html, selected, property_value, logic_enable, logic_enable_id; if (_values == null) { extra_class = " lepopup-properties-sub-item-new"; lepopup_element_properties_data_changed = true; } else extra_class = " lepopup-properties-sub-item-exist"; html += "
"; html += "
"+lepopup_confirmations['name']['tooltip']+"
"; var options = ""; if (_values != null && _values.hasOwnProperty('type')) property_value = _values['type']; else property_value = lepopup_confirmations['type']['value']; for (var option_key in lepopup_confirmations['type']['options']) { if (lepopup_confirmations['type']['options'].hasOwnProperty(option_key)) { selected = ""; if (option_key == property_value) selected = " selected='selected'"; options += ""+lepopup_escape_html(lepopup_confirmations['type']['options'][option_key])+""; } } html += "
"+lepopup_confirmations['type']['tooltip']+"
"; var message_id = lepopup_random_string(16); html += "
"+lepopup_confirmations['url']['tooltip']+"
"; html += "
"+lepopup_confirmations['delay']['tooltip']+"
"+(lepopup_confirmations['delay'].hasOwnProperty("unit") ? " "+lepopup_confirmations['delay']["unit"] : "")+"
"; property_value = (_values != null && _values.hasOwnProperty('payment-gateway') ? lepopup_escape_html(_values['payment-gateway']) : lepopup_escape_html(lepopup_confirmations['payment-gateway']['value'])); options = ""; for (var key in lepopup_form_options['payment-gateways']) { selected = ""; if (lepopup_form_options['payment-gateways'][key]['id'] == property_value) selected = " selected='selected'"; options += ""+lepopup_escape_html(lepopup_form_options['payment-gateways'][key]['name'])+""; } html += "
"+lepopup_confirmations['payment-gateway']['tooltip']+"
"; property_value = (_values != null && _values.hasOwnProperty('form') ? lepopup_escape_html(_values['form']) : lepopup_escape_html(lepopup_confirmations['form']['value'])); options = ""; for (var i=0; i"+lepopup_escape_html(lepopup_forms[i]['name']+" ("+lepopup_forms[i]['slug']+")")+""; } html += "
"+lepopup_confirmations['form']['tooltip']+"
"; var reset_form; if (_values != null && _values.hasOwnProperty('reset-form')) reset_form = _values['reset-form']; else reset_form = lepopup_confirmations['reset-form']['value']; var reset_form_id = lepopup_random_string(16); html += "
"+lepopup_confirmations['reset-form']['tooltip']+"
"; if (_values != null && _values.hasOwnProperty('logic-enable')) logic_enable = _values['logic-enable']; else logic_enable = lepopup_confirmations['logic-enable']['value']; logic_enable_id = lepopup_random_string(16); html += "
"+lepopup_confirmations['logic-enable']['tooltip']+"
"; if (_values != null && _values.hasOwnProperty('logic')) property_value = _values['logic']; else property_value = lepopup_confirmations['logic']['value']; var input_ids = new Array(); for (var i=0; i 0) { temp = "
"; options = ""; for (var option_key in lepopup_confirmations['logic']['actions']) { if (lepopup_confirmations['logic']['actions'].hasOwnProperty(option_key)) { options += ""; } } temp += "
"; options = ""; for (var option_key in lepopup_confirmations['logic']['operators']) { if (lepopup_confirmations['logic']['operators'].hasOwnProperty(option_key)) { options += ""; } } temp += "
"; temp += "
"; options = ""; for (var j=0; j"; } else { temp = "
There are no elements available to use for logic rules.
"; } html += ""; html += "
"; if (_values == null) jQuery(".lepopup-properties-content-confirmations .lepopup-properties-sub-item-body").slideUp(300); jQuery(".lepopup-properties-content-confirmations").append(html); jQuery(".lepopup-properties-sub-item-new .lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); lepopup_properties_confirmations_name_changed(jQuery(".lepopup-properties-content-confirmations .lepopup-properties-sub-item").last().find("[name='lepopup-confirmations-name']")); lepopup_properties_confirmations_type_changed(jQuery(".lepopup-properties-content-confirmations .lepopup-properties-sub-item").last().find("[name='lepopup-confirmations-type']")); jQuery(".lepopup-properties-sub-item-new").slideDown(300); jQuery(".lepopup-properties-sub-item-new").removeClass("lepopup-properties-sub-item-new"); return false; } function lepopup_properties_filters_add(_type, _filter, _values) { var extra_class = "", html = "", tooltip_html, selected, property_value = ""; var seq = 0, last; last = jQuery(".lepopup-properties-content-filters .lepopup-properties-sub-item").last(); if (jQuery(last).length) seq = parseInt(jQuery(last).attr("data-seq"), 10) + 1; if (lepopup_meta[_type].hasOwnProperty("filters") && lepopup_filters.hasOwnProperty(_filter)) { if (_values == null) { extra_class = " lepopup-properties-sub-item-new"; lepopup_element_properties_data_changed = true; } else extra_class = " lepopup-properties-sub-item-exist"; if (lepopup_filters[_filter].hasOwnProperty("properties")) property_value = ""; html += "
"+property_value+"
"; for (var key in lepopup_filters[_filter]["properties"]) { if (lepopup_filters[_filter]["properties"].hasOwnProperty(key)) { tooltip_html = ""; if (lepopup_filters[_filter]["properties"][key].hasOwnProperty('tooltip')) { tooltip_html = "
"+lepopup_filters[_filter]["properties"][key]['tooltip']+"
"; } property_value = ""; if (_values != null && _values.hasOwnProperty("properties") && _values["properties"].hasOwnProperty(key)) property_value = _values["properties"][key]; switch(lepopup_filters[_filter]["properties"][key]['type']) { case 'text': html += "
"+tooltip_html+"
"; break; case 'integer': html += "
"+tooltip_html+"
"; break; case 'checkbox': selected = ""; if (property_value == "on") selected = " checked='checked'"; html += "
"+tooltip_html+"
"; break; default: break; } } } html += "
"; if (_values == null) jQuery(".lepopup-properties-content-filters .lepopup-properties-sub-item-body").slideUp(300); jQuery(".lepopup-properties-content-filters").append(html); jQuery(".lepopup-properties-sub-item-new .lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); jQuery(".lepopup-properties-sub-item-new").slideDown(300); jQuery(".lepopup-properties-sub-item-new").removeClass("lepopup-properties-sub-item-new"); } return false; } function lepopup_properties_filters_details_toggle(_object) { jQuery(_object).closest(".lepopup-properties-sub-item").addClass("lepopup-freeze"); jQuery(".lepopup-properties-content-filters .lepopup-properties-sub-item").each(function() { if (!jQuery(this).hasClass("lepopup-freeze")) jQuery(this).find(".lepopup-properties-sub-item-body").slideUp(300); }); jQuery(_object).closest(".lepopup-properties-sub-item").removeClass("lepopup-freeze"); jQuery(_object).closest(".lepopup-properties-sub-item").find(".lepopup-properties-sub-item-body").slideToggle(300); return false; } function lepopup_properties_filters_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to delete the item.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Delete'), ok_function: function(e) { jQuery(_object).closest(".lepopup-properties-sub-item").slideUp(300, function() { jQuery(this).remove(); }); lepopup_element_properties_data_changed = true; lepopup_dialog_close(); } }); return false; } function lepopup_properties_logic_rule_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
"+lepopup_esc_html__('Please confirm that you want to delete the item.')+"
"); this.show(); }, ok_label: lepopup_esc_html__('Delete'), ok_function: function(e) { jQuery(_object).closest(".lepopup-properties-logic-rule").slideUp(300, function() { jQuery(this).remove(); }); lepopup_element_properties_data_changed = true; lepopup_dialog_close(); } }); return false; } function lepopup_properties_logic_rule_token_change(_object) { var rule = jQuery(_object).closest(".lepopup-properties-logic-rule"); var html = lepopup_properties_logic_rule_token_get(jQuery(rule).find(".lepopup-properties-logic-rule-field").val(), jQuery(rule).find(".lepopup-properties-logic-rule-rule").val(), ""); jQuery(rule).find(".lepopup-properties-logic-rule-token-container").html(html); return false; } function lepopup_properties_logic_rule_token_get(_field, _rule, _token) { var html = "", input = null, options = ""; for (var i=0; i"; else { if (_rule == 'is-empty' || _rule == 'is-not-empty') html = ""; else if (_rule == 'is' || _rule == 'is-not') { if (input.hasOwnProperty("options") && input["options"].length > 0) { for (var i=0; i"+lepopup_escape_html(input["options"][i]["label"])+""; } html = ""; } else html = ""; } else html = ""; } return html; } function lepopup_properties_logic_rule_get(_field_id, _field, _rule, _token) { var temp = "", html = "", field_options = "", rule_options = ""; var field_selected = null, rule_selected = null; var input_fields = lepopup_input_sort(); if (input_fields.length > 0) { for (var j=0; j"; temp = input_fields[j]['page-id']; } if (field_selected == null || _field == input_fields[j]['id']) field_selected = input_fields[j]['id']; field_options += ""; } field_options += ""; } for (var key in lepopup_logic_rules) { if (rule_selected == null || _rule == key) rule_selected = key; if (lepopup_logic_rules.hasOwnProperty(key)) { rule_options += ""; } } var field_token = lepopup_properties_logic_rule_token_get(field_selected, rule_selected, _token); html = "
"+field_token+"
"; return html; } function lepopup_properties_logic_rule_new(_object, _field_id) { var rule_html = lepopup_properties_logic_rule_get(_field_id, null, null, null); jQuery(_object).closest(".lepopup-properties-content").find(".lepopup-properties-logic-rules").append(rule_html); lepopup_element_properties_data_changed = true; return false; } function lepopup_properties_attachment_media(_object) { var input = jQuery(_object).parent().children("input"); var media_frame = wp.media({ title: 'Select Media', multiple: false }); media_frame.on("select", function() { var attachment = media_frame.state().get("selection").first(); jQuery(input).val(attachment.attributes.id+" | "+attachment.attributes.filename); }); media_frame.open(); } function lepopup_properties_attachment_delete(_object) { var attachment = jQuery(_object).closest(".lepopup-properties-attachment"); jQuery(attachment).slideUp(300, function(){jQuery(attachment).remove();}); lepopup_element_properties_data_changed = true; return false; } function lepopup_properties_attachment_token_change(_object) { var attachment = jQuery(_object).closest(".lepopup-properties-attachment"); var html = lepopup_properties_attachment_token_get(jQuery(attachment).find(".lepopup-properties-attachment-source").val(), ""); jQuery(attachment).find(".lepopup-properties-attachment-token-container").html(html); return false; } function lepopup_properties_attachment_token_get(_source, _token) { var html = "", input = null, options = ""; if (_source == "media-library") html = "
"; else if (_source == "file") html = ""; else { for (var i=0; i"+lepopup_form_elements[i]['id']+" | "+lepopup_escape_html(lepopup_form_elements[i]['name'])+""; } } if (options != "") html = ""; else html = "No form elements (files) found."; } return html; } function lepopup_properties_attachment_get(_source, _token) { var token = lepopup_properties_attachment_token_get(_source, _token); var html = "
"+token+"
"; return html; } function lepopup_properties_attachment_new(_object) { var attachment_html = lepopup_properties_attachment_get(null, null); jQuery(_object).closest(".lepopup-properties-content").find(".lepopup-properties-attachments").append(attachment_html); lepopup_element_properties_data_changed = true; return false; } var lepopup_shortcode_selector_setting = false; function lepopup_shortcode_selector_set(_object) { if (lepopup_shortcode_selector_setting) return; lepopup_shortcode_selector_setting = true; jQuery(".lepopup-shortcode-selector-list-input").find("li").show(); var disabled_groups_raw = jQuery(_object).attr("data-disabled-groups"); if (typeof disabled_groups_raw == typeof "string") { if (disabled_groups_raw.length > 0) { var disabled_groups = disabled_groups_raw.split(","); for (var j=0; j 0) jQuery(".lepopup-shortcode-selector-list-input").find("li.lepopup-shortcode-selector-list-item-"+disabled_groups[j]).hide(); } } } if (jQuery(_object).find(".lepopup-shortcode-selector-list-input").length > 0) { lepopup_shortcode_selector_setting = false; return; } if (jQuery(".lepopup-shortcode-selector-list-input").length > 0) { jQuery(".lepopup-shortcode-selector-list-input").appendTo(_object); lepopup_shortcode_selector_setting = false; return; } var html = lepopup_shortcode_selector_list_html("lepopup-shortcode-selector-list-input"); jQuery(_object).append(html); jQuery(_object).find(".lepopup-shortcode-selector-list-item").on("click", function(e){ var input = jQuery(this).closest(".lepopup-input-shortcode-selector, .lepopup-textarea-shortcode-selector").find("input, textarea"); var caret_pos = input[0].selectionStart; var current_value = jQuery(input).val(); jQuery(input).val(current_value.substring(0, caret_pos) + jQuery(this).attr("data-code") + current_value.substring(caret_pos) ); }); lepopup_shortcode_selector_setting = false; return; } function lepopup_shortcode_selector_list_html(_class) { var type, items, label, id; var temp = "
  • Form values
  • "; for (var j=0; j"+lepopup_form_elements[j]['id']+" | "+lepopup_escape_html(lepopup_form_elements[j]['name'])+""; } } var math_from_window = false; if (lepopup_element_properties_active != null) { var type = jQuery(lepopup_element_properties_active).attr("data-type"); if (type == "settings") math_from_window = true; } if (math_from_window) { items = jQuery(".lepopup-properties-content-math-expressions .lepopup-properties-sub-item"); if (items.length > 0) { temp += "
  • Math expressions
  • "; jQuery(items).each(function() { label = jQuery(this).find("[name='lepopup-math-name']").val(); label = label.replace(new RegExp("}", 'g'), ")"); label = label.replace(new RegExp("{", 'g'), "("); id = jQuery(this).find("[name='lepopup-math-id']").val(); temp += "
  • "+id+" | "+jQuery(this).find("[name='lepopup-math-name']").val()+"
  • "; }); } } else { if (lepopup_form_options.hasOwnProperty("math-expressions")) { if (lepopup_form_options["math-expressions"].length > 0) { temp += "
  • Math expressions
  • "; for (var j=0; j"+lepopup_form_options["math-expressions"][j]['id']+" | "+lepopup_escape_html(lepopup_form_options["math-expressions"][j]['name'])+""; } } } } temp += "
  • General
  • All Form Data
  • Record ID
  • IP Address
  • User Agent
  • Date
  • Time
  • "+(typeof lepopup_uap_core != typeof undefined && lepopup_uap_core === true ? "" : "
  • WP User Login
  • WP User Email
  • ")+"
  • Current URL
  • Current Page Title
  • "; temp += "
"; return temp; } /* Element actions - end */ /* Bulk Options - begin */ var lepopup_bulk_options_object = null; function lepopup_bulk_options_open(_object) { lepopup_bulk_options_object = jQuery(_object).closest(".lepopup-properties-item"); if (lepopup_bulk_options_object) { var window_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var window_width = Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 600); jQuery("#lepopup-bulk-options").height(window_height); jQuery("#lepopup-bulk-options").width(window_width); jQuery("#lepopup-bulk-options .lepopup-admin-popup-inner").height(window_height); jQuery("#lepopup-bulk-options .lepopup-admin-popup-content").height(window_height - 104); jQuery("#lepopup-bulk-options-overlay").fadeIn(300); jQuery("#lepopup-bulk-options").fadeIn(300); jQuery(".lepopup-bulk-editor textarea").val(""); } return false; } function lepopup_bulk_options_close() { lepopup_bulk_options_object = null; jQuery("#lepopup-bulk-options-overlay").fadeOut(300); jQuery("#lepopup-bulk-options").fadeOut(300); } function lepopup_bulk_category_add(_object) { var category = jQuery(_object).attr("data-category"); if (!category) return false; var value = jQuery(".lepopup-bulk-editor textarea").val(); if (category == "existing") { if (lepopup_bulk_options_object) { jQuery(lepopup_bulk_options_object).find(".lepopup-properties-options-item").each(function() { var option_label = jQuery(this).find('.lepopup-properties-options-label').val(); var option_value = jQuery(this).find('.lepopup-properties-options-value').val(); if (value != "") value += "\r\n"; if (option_label != option_value) value += option_label+"|"+option_value; else value += option_label; }); } } else { if (lepopup_predefined_options != null && lepopup_predefined_options.hasOwnProperty(category)) { for (var i=0; i 0) jQuery(".lepopup-pages-bar-item-confirmation").before("
  • "); else jQuery(".lepopup-pages-add").before("
  • "); if (jQuery(".lepopup-pages-bar-item").length == 1) jQuery(".lepopup-pages-bar-item").find(".lepopup-pages-bar-item-delete").addClass("lepopup-pages-bar-item-delete-disabled"); else jQuery(".lepopup-pages-bar-item").find(".lepopup-pages-bar-item-delete").removeClass("lepopup-pages-bar-item-delete-disabled"); jQuery(".lepopup-builder").append("
    "); if (lepopup_is_numeric(page["size-width"])) width = Math.min(parseInt(page["size-width"], 10), 1200); else width = 720; if (lepopup_is_numeric(page["size-height"])) height = Math.min(parseInt(page["size-height"], 10), 2400); else height = 540; jQuery("#lepopup-form-"+page['id']+" .lepopup-basic-frame").width(width); jQuery("#lepopup-form-"+page['id']+" .lepopup-basic-frame").height(height); _lepopup_init_basic_frame("#lepopup-form-"+page['id']+" .lepopup-basic-frame"); lepopup_update_progress(); } return false; } function _lepopup_pages_delete(_object) { var page_id = jQuery(_object).closest("li").attr("data-id"); for (var i=0; i"+lepopup_esc_html__("Please confirm that you want to delete the page and all sub-elements.", "lepopup")+""); this.show(); }, ok_label: 'Delete', ok_function: function(e) { _lepopup_pages_delete(_object); lepopup_dialog_close(); } }); return false; } function lepopup_pages_activate(_object) { var page_id = jQuery(_object).closest("li").attr("data-id"); if (lepopup_form_page_active == page_id) return false; if (lepopup_form_page_active != null && jQuery("#lepopup-form-"+lepopup_form_page_active).length > 0) { jQuery("#lepopup-form-"+lepopup_form_page_active).fadeOut(300, function(){jQuery("#lepopup-form-"+page_id).fadeIn(300);}); } else { jQuery("#lepopup-form-"+page_id).fadeIn(300); } lepopup_form_page_active = page_id; jQuery(".lepopup-pages-bar-item-active").removeClass("lepopup-pages-bar-item-active"); jQuery(".lepopup-pages-bar-item[data-id='"+page_id+"'], .lepopup-pages-bar-item-confirmation[data-id='"+page_id+"']").addClass("lepopup-pages-bar-item-active"); if (page_id == "confirmation") jQuery(".lepopup-toolbar-tool-input, .lepopup-toolbar-tool-submit").hide(); else jQuery(".lepopup-toolbar-tool-input, .lepopup-toolbar-tool-submit").show(); _lepopup_layers_sync(lepopup_form_page_active); return false; } function _lepopup_layers_sync(_page_id) { var adminbar_height; if (jQuery("#wpadminbar").length > 0) adminbar_height = parseInt(jQuery("#wpadminbar").height(), 10); else adminbar_height = 0; var idxs = new Array(); var seqs = new Array(); var layers_list = ""; for (var i=0; i seqs[j+1]) { sorted = seqs[j]; seqs[j] = seqs[j+1]; seqs[j+1] = sorted; sorted = idxs[j]; idxs[j] = idxs[j+1]; idxs[j+1] = sorted; } } if (sorted == -1) break; } for (var k=0; k"+(lepopup_form_elements[i]["name"] != "" ? lepopup_escape_html(lepopup_form_elements[i]["name"]) : "Untitled Element")+""; } } jQuery(".lepopup-layers-list").html(layers_list); jQuery(".lepopup-layers-list>li").on("mouseenter", function(e){ var id = jQuery(this).attr("data-idx"); jQuery(".lepopup-element-"+id).addClass("lepopup-element-hovered"); }); jQuery(".lepopup-layers-list>li").on("mouseleave", function(e){ var id = jQuery(this).attr("data-idx"); jQuery(".lepopup-element-"+id).removeClass("lepopup-element-hovered"); }); jQuery(".lepopup-layers-list>li").on("contextmenu", function(e) { e.preventDefault(); jQuery(".lepopup-context-menu").hide(); var id = jQuery(this).attr("data-idx"); lepopup_context_menu_object = jQuery(".lepopup-element-"+id); jQuery(".lepopup-context-menu").css({"top" : (e.pageY - adminbar_height), "left" : e.pageX}); jQuery(".lepopup-context-menu-multi-page").remove(); var li_duplicate_pages = new Array(); var li_move_pages = new Array(); for (var i=0; i"+lepopup_escape_html(lepopup_form_pages[i]["name"])+""); li_move_pages.push("
  • "+lepopup_escape_html(lepopup_form_pages[i]["name"])+"
  • "); } } if (li_duplicate_pages.length > 0) { jQuery(".lepopup-context-menu-last").after("
  • Duplicate to
      "+li_duplicate_pages.join("")+"
  • Move to
      "+li_move_pages.join("")+"
  • "); } jQuery(".lepopup-context-menu").addClass("lepopup-context-menu-high-priority"); jQuery(".lepopup-context-menu").show(); return false; }); jQuery(".lepopup-layers-list>li").on("click", function(e) { e.preventDefault(); jQuery(".lepopup-context-menu").hide(); var id = jQuery(this).attr("data-idx"); lepopup_properties_panel_object = jQuery(".lepopup-element-"+id); lepopup_properties_panel_open(lepopup_properties_panel_object); return false; }); if (lepopup_element_properties_active) { jQuery(lepopup_element_properties_active).addClass("lepopup-element-selected"); var idx = jQuery(lepopup_element_properties_active).attr("id"); if (idx) { idx = idx.replace("lepopup-element-", ""); jQuery(".lepopup-layers-list").find("li.lepopup-layer-"+idx).addClass("lepopup-layer-selected"); } } } /* Pages - end */ function _lepopup_build_hidden_list(_parent) { var html = ""; for (var i=0; i"+lepopup_escape_html(lepopup_form_elements[i]["name"])+""; } if (html != "") html = "
    "+html+"
    "; return html; } function _lepopup_build_children(_parent, _only_idx) { var adminbar_height = parseInt(jQuery("#wpadminbar").height(), 10); var resizable_handle = "all"; var html = "", style = "", global_html = "", text_style = ""; var webfonts = new Array(); var label, options, selected, icon, option, extra_class, style_attr, content, div; var properties = {}; var zindex_base = 500; var idxs = new Array(); var seqs = new Array(); for (var i=0; i seqs[j+1]) { sorted = seqs[j]; seqs[j] = seqs[j+1]; seqs[j+1] = sorted; sorted = idxs[j]; idxs[j] = idxs[j+1]; idxs[j+1] = sorted; } } if (sorted == -1) break; } for (var k=0; k"; options = ""; if (lepopup_form_elements[i]["icon-left-size"] != "") { options += "font-size:"+lepopup_form_elements[i]["icon-left-size"]+"px;"; } if (options != "") style += "#lepopup-element-"+i+" div.lepopup-input>i.lepopup-icon-left{"+options+"}"; } } if (lepopup_form_elements[i].hasOwnProperty("icon-right-icon")) { if (lepopup_form_elements[i]["icon-right-icon"] != "") { extra_class += " lepopup-icon-right"; icon += ""; options = ""; if (lepopup_form_elements[i]["icon-right-size"] != "") { options += "font-size:"+lepopup_form_elements[i]["icon-right-size"]+"px;"; } if (options != "") style += "#lepopup-element-"+i+" div.lepopup-input>i.lepopup-icon-right{"+options+"}"; } } if (lepopup_toolbar_tools.hasOwnProperty(lepopup_form_elements[i]["type"])) { switch(lepopup_form_elements[i]["type"]) { case "button": case "link-button": icon = ""; label = ""; if (lepopup_form_elements[i]["label"] != "") label = ""+lepopup_escape_html(lepopup_form_elements[i]["label"])+""; else style += "#lepopup-element-"+i+" a.lepopup-button i{margin:0!important;}"; if (lepopup_form_elements[i].hasOwnProperty("icon-left") && lepopup_form_elements[i]["icon-left"] != "") label = "" + label; if (lepopup_form_elements[i].hasOwnProperty("icon-right") && lepopup_form_elements[i]["icon-right"] != "") label += ""; properties['style-attr'] = ""; if (lepopup_form_elements[i].hasOwnProperty("colors-background") && lepopup_form_elements[i]["colors-background"] != "") properties['style-attr'] += "background-color:"+lepopup_form_elements[i]["colors-background"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-border") && lepopup_form_elements[i]["colors-border"] != "") properties['style-attr'] += "border-color:"+lepopup_form_elements[i]["colors-border"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-text") && lepopup_form_elements[i]["colors-text"] != "") properties['style-attr'] += "color:"+lepopup_form_elements[i]["colors-text"]+";"; if (properties['style-attr'] != "") style += "#lepopup-element-"+i+" .lepopup-button{"+properties['style-attr']+"}"; properties['style-attr'] = ""; if (lepopup_form_elements[i].hasOwnProperty("colors-hover-background") && lepopup_form_elements[i]["colors-hover-background"] != "") properties['style-attr'] += "background-color:"+lepopup_form_elements[i]["colors-hover-background"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-hover-border") && lepopup_form_elements[i]["colors-hover-border"] != "") properties['style-attr'] += "border-color:"+lepopup_form_elements[i]["colors-hover-border"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-hover-text") && lepopup_form_elements[i]["colors-hover-text"] != "") properties['style-attr'] += "color:"+lepopup_form_elements[i]["colors-hover-text"]+";"; if (properties['style-attr'] != "") style += "#lepopup-element-"+i+" .lepopup-button:hover{"+properties['style-attr']+"}"; properties['style-attr'] = ""; if (lepopup_form_elements[i].hasOwnProperty("colors-active-background") && lepopup_form_elements[i]["colors-active-background"] != "") properties['style-attr'] += "background-color:"+lepopup_form_elements[i]["colors-active-background"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-active-border") && lepopup_form_elements[i]["colors-active-border"] != "") properties['style-attr'] += "border-color:"+lepopup_form_elements[i]["colors-active-border"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-active-text") && lepopup_form_elements[i]["colors-active-text"] != "") properties['style-attr'] += "color:"+lepopup_form_elements[i]["colors-active-text"]+";"; if (properties['style-attr'] != "") style += "#lepopup-element-"+i+" .lepopup-button:active{"+properties['style-attr']+"}"; html += ""; break; case "email": case "text": style += "#lepopup-element-"+i+" div.lepopup-input .lepopup-icon-left, #lepopup-element-"+i+" div.lepopup-input .lepopup-icon-right {line-height:"+lepopup_escape_html(lepopup_form_elements[i]['size-height'])+"px;}"; html += "
    "+icon+"
    "; break; case "number": style += "#lepopup-element-"+i+" div.lepopup-input .lepopup-icon-left, #lepopup-element-"+i+" div.lepopup-input .lepopup-icon-right {line-height:"+lepopup_escape_html(lepopup_form_elements[i]['size-height'])+"px;}"; html += "
    "+icon+"
    "; break; case "numspinner": style += "#lepopup-element-"+i+" div.lepopup-input .lepopup-icon-left, #lepopup-element-"+i+" div.lepopup-input .lepopup-icon-right {line-height:"+lepopup_escape_html(lepopup_form_elements[i]['size-height'])+"px;}"; properties['value'] = parseFloat(lepopup_form_elements[i]["number-value2"]).toFixed(lepopup_form_elements[i]["decimal"]); html += "
    "; break; case "textarea": style += "#lepopup-element-"+i+" div.lepopup-input .lepopup-icon-left, #lepopup-element-"+i+" div.lepopup-input .lepopup-icon-right {line-height:"+lepopup_escape_html(lepopup_form_elements[i]['size-height'])+"px;}"; html += "
    "+icon+"
    "; break; case "select": options = ""; if (lepopup_form_elements[i]["please-select-option"] == "on") options += ""; for (var j=0; j"+lepopup_escape_html(lepopup_form_elements[i]["options"][j]["label"])+""; } html += "
    "; break; case "checkbox": style += "#lepopup-element-"+i+" div.lepopup-input{height:auto;line-height:1;}"; properties['checkbox-size'] = lepopup_form_options['checkbox-radio-style-size']; if (lepopup_form_elements[i]['checkbox-style-position'] == "") properties['checkbox-position'] = lepopup_form_options['checkbox-radio-style-position']; else properties['checkbox-position'] = lepopup_form_elements[i]['checkbox-style-position']; if (lepopup_form_elements[i]['checkbox-style-align'] == "") properties['checkbox-align'] = lepopup_form_options['checkbox-radio-style-align']; else properties['checkbox-align'] = lepopup_form_elements[i]['checkbox-style-align']; if (lepopup_form_elements[i]['checkbox-style-layout'] == "") properties['checkbox-layout'] = lepopup_form_options['checkbox-radio-style-layout']; else properties['checkbox-layout'] = lepopup_form_elements[i]['checkbox-style-layout']; extra_class = " lepopup-cr-layout-"+properties['checkbox-layout']+" lepopup-cr-layout-"+properties['checkbox-align']; for (var j=0; j"; if (properties['checkbox-position'] == "left") option += "
    "; else option = "
    " + option; options += "
    "+option+"
    "; } html += "
    "+options+"
    "; break; case "radio": style += "#lepopup-element-"+i+" div.lepopup-input{height:auto;line-height:1;}"; properties['radio-size'] = lepopup_form_options['checkbox-radio-style-size']; if (lepopup_form_elements[i]['radio-style-position'] == "") properties['radio-position'] = lepopup_form_options['checkbox-radio-style-position']; else properties['radio-position'] = lepopup_form_elements[i]['radio-style-position']; if (lepopup_form_elements[i]['radio-style-align'] == "") properties['radio-align'] = lepopup_form_options['checkbox-radio-style-align']; else properties['radio-align'] = lepopup_form_elements[i]['radio-style-align']; if (lepopup_form_elements[i]['radio-style-layout'] == "") properties['radio-layout'] = lepopup_form_options['checkbox-radio-style-layout']; else properties['radio-layout'] = lepopup_form_elements[i]['radio-style-layout']; extra_class = " lepopup-cr-layout-"+properties['radio-layout']+" lepopup-cr-layout-"+properties['radio-align']; for (var j=0; j"; if (properties['radio-position'] == "left") option += "
    "; else option = "
    " + option; options += "
    "+option+"
    "; } html += "
    "+options+"
    "; break; case "multiselect": style += "#lepopup-element-"+i+" div.lepopup-input{height:100%;line-height:1;}"; if (lepopup_form_elements[i]['align'] != "") properties['align'] = lepopup_form_elements[i]['align']; else if (lepopup_form_options['multiselect-style-align'] != "") properties['align'] = lepopup_form_options['multiselect-style-align']; else properties['align'] = 'left'; for (var j=0; j"; } html += "
    "+options+"
    "; break; case "imageselect": style += "#lepopup-element-"+i+" div.lepopup-input{width:100%;line-height:1;}"; properties['image-size'] = lepopup_form_elements[i]['image-style-size']; properties["image-width"] = lepopup_form_elements[i]['image-style-width']; if (!lepopup_is_numeric(properties["image-width"])) properties["image-width"] = 120; properties["image-height"] = lepopup_form_elements[i]['image-style-height']; if (!lepopup_is_numeric(properties["image-height"])) properties["image-height"] = 120; properties["label-height"] = lepopup_form_elements[i]['label-height']; if (!lepopup_is_numeric(properties["label-height"]) || lepopup_form_elements[i]['label-enable'] != "on") properties["label-height"] = 0; properties["image-width"] = parseInt(properties["image-width"], 10); properties["image-height"] = parseInt(properties["image-height"], 10); properties["label-height"] = parseInt(properties["label-height"], 10); if (lepopup_form_options.hasOwnProperty('imageselect-selected-scale') && lepopup_form_options['imageselect-selected-scale'] == "on") { var scale = 1.10; if (properties["image-width"] > 0 && properties["image-height"] > 0) scale = Math.min(parseFloat((properties["image-width"]+8)/properties["image-width"]), parseFloat((properties["image-height"]+8)/properties["image-height"])); style += "#lepopup-element-"+i+" div.lepopup-input .lepopup-imageselect:checked+label {transform: scale("+scale+");}"; } extra_class += ' lepopup-ta-'+lepopup_form_options['imageselect-style-align']+' lepopup-imageselect-'+lepopup_form_options['imageselect-style-effect']; style += "#lepopup-element-"+i+" div.lepopup-input .lepopup-imageselect+label {width:"+properties["image-width"]+"px;height:"+parseInt(properties["image-height"]+properties["label-height"], 10)+"px;}"; style += "#lepopup-element-"+i+" div.lepopup-input .lepopup-imageselect+label span.lepopup-imageselect-image {height:"+properties["image-height"]+"px;background-size:"+properties['image-size']+";}"; for (var j=0; j 0) { properties['image-label'] = ""+lepopup_escape_html(lepopup_form_elements[i]["options"][j]["label"])+""; } options += ""; } html += "
    "+options+"
    "; break; case "tile": style += "#lepopup-element-"+i+" div.lepopup-input{width:100%;line-height:1;}"; if (lepopup_form_elements[i].hasOwnProperty("tile-style-size") && lepopup_form_elements[i]['tile-style-size'] != "") properties['size'] = lepopup_form_elements[i]['tile-style-size']; else properties['size'] = lepopup_form_options['tile-style-size']; if (lepopup_form_elements[i].hasOwnProperty("tile-style-width") && lepopup_form_elements[i]['tile-style-width'] != "") properties['width'] = lepopup_form_elements[i]['tile-style-width']; else properties['width'] = lepopup_form_options['tile-style-width']; if (lepopup_form_elements[i].hasOwnProperty("tile-style-position") && lepopup_form_elements[i]['tile-style-position'] != "") properties['position'] = lepopup_form_elements[i]['tile-style-position']; else properties['position'] = lepopup_form_options['tile-style-position']; if (lepopup_form_elements[i].hasOwnProperty("tile-style-layout") && lepopup_form_elements[i]['tile-style-layout'] != "") properties['layout'] = lepopup_form_elements[i]['tile-style-layout']; else properties['layout'] = lepopup_form_options['tile-style-layout']; extra_class = " lepopup-tile-layout-"+properties['layout']+" lepopup-tile-layout-"+properties['position']+" lepopup-tile-transform-"+lepopup_form_options['tile-selected-transform']; for (var j=0; j"; options += "
    "+option+"
    "; } html += "
    "+options+"
    "; break; case "date": style += "#lepopup-element-"+i+" div.lepopup-input .lepopup-icon-left, #lepopup-element-"+i+" div.lepopup-input .lepopup-icon-right {line-height:"+lepopup_escape_html(lepopup_form_elements[i]['size-height'])+"px;}"; html += "
    "+icon+"
    "; break; case "time": style += "#lepopup-element-"+i+" div.lepopup-input .lepopup-icon-left, #lepopup-element-"+i+" div.lepopup-input .lepopup-icon-right {line-height:"+lepopup_escape_html(lepopup_form_elements[i]['size-height'])+"px;}"; html += "
    "+icon+"
    "; break; case "file": icon = ""; label = ""; if (lepopup_form_elements[i]["button-label"] != "") label = ""+lepopup_escape_html(lepopup_form_elements[i]["button-label"])+""; else style += "#lepopup-element-"+i+" a.lepopup-button i{margin:0!important;}"; if (lepopup_form_elements[i].hasOwnProperty("icon-left") && lepopup_form_elements[i]["icon-left"] != "") label = "" + label; if (lepopup_form_elements[i].hasOwnProperty("icon-right") && lepopup_form_elements[i]["icon-right"] != "") label += ""; properties['style-attr'] = ""; if (lepopup_form_elements[i].hasOwnProperty("colors-background") && lepopup_form_elements[i]["colors-background"] != "") properties['style-attr'] += "background-color:"+lepopup_form_elements[i]["colors-background"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-border") && lepopup_form_elements[i]["colors-border"] != "") properties['style-attr'] += "border-color:"+lepopup_form_elements[i]["colors-border"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-text") && lepopup_form_elements[i]["colors-text"] != "") properties['style-attr'] += "color:"+lepopup_form_elements[i]["colors-text"]+";"; if (properties['style-attr'] != "") style += "#lepopup-element-"+i+" .lepopup-button{"+properties['style-attr']+"}"; properties['style-attr'] = ""; if (lepopup_form_elements[i].hasOwnProperty("colors-hover-background") && lepopup_form_elements[i]["colors-hover-background"] != "") properties['style-attr'] += "background-color:"+lepopup_form_elements[i]["colors-hover-background"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-hover-border") && lepopup_form_elements[i]["colors-hover-border"] != "") properties['style-attr'] += "border-color:"+lepopup_form_elements[i]["colors-hover-border"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-hover-text") && lepopup_form_elements[i]["colors-hover-text"] != "") properties['style-attr'] += "color:"+lepopup_form_elements[i]["colors-hover-text"]+";"; if (properties['style-attr'] != "") style += "#lepopup-element-"+i+" .lepopup-button:hover{"+properties['style-attr']+"}"; properties['style-attr'] = ""; if (lepopup_form_elements[i].hasOwnProperty("colors-active-background") && lepopup_form_elements[i]["colors-active-background"] != "") properties['style-attr'] += "background-color:"+lepopup_form_elements[i]["colors-active-background"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-active-border") && lepopup_form_elements[i]["colors-active-border"] != "") properties['style-attr'] += "border-color:"+lepopup_form_elements[i]["colors-active-border"]+";"; if (lepopup_form_elements[i].hasOwnProperty("colors-active-text") && lepopup_form_elements[i]["colors-active-text"] != "") properties['style-attr'] += "color:"+lepopup_form_elements[i]["colors-active-text"]+";"; if (properties['style-attr'] != "") style += "#lepopup-element-"+i+" .lepopup-button:active{"+properties['style-attr']+"}"; html += ""; break; case "password": style += "#lepopup-element-"+i+" div.lepopup-input .lepopup-icon-left, #lepopup-element-"+i+" div.lepopup-input .lepopup-icon-right {line-height:"+lepopup_escape_html(lepopup_form_elements[i]['size-height'])+"px;}"; html += "
    "+icon+"
    "; break; case "signature": html += "
    "; break; case "rangeslider": style += "#lepopup-element-"+i+" div.lepopup-input{height:auto;line-height:1;}"; options = (lepopup_form_elements[i]["readonly"] == "on" ? "data-from-fixed='true' data-to-fixed='true'" : "")+" "+(lepopup_form_elements[i]["double"] == "on" ? "data-type='double'" : "data-type='single'")+" "+(lepopup_form_elements[i]["grid-enable"] == "on" ? "data-grid='true'" : "data-grid='false'")+" "+(lepopup_form_elements[i]["min-max-labels"] == "on" ? "data-hide-min-max='false'" : "data-hide-min-max='true'")+" data-skin='"+lepopup_form_options['rangeslider-skin']+"' data-min='"+lepopup_form_elements[i]["range-value1"]+"' data-max='"+lepopup_form_elements[i]["range-value2"]+"' data-step='"+lepopup_form_elements[i]["range-value3"]+"' data-from='"+lepopup_form_elements[i]["handle"]+"' data-to='"+lepopup_form_elements[i]["handle2"]+"' data-prefix='"+lepopup_form_elements[i]["prefix"]+"' data-postfix='"+lepopup_form_elements[i]["postfix"]+"'"; html += "
    "; break; case "star-rating": style += "#lepopup-element-"+i+" div.lepopup-input{height:auto;line-height:1;}"; if (lepopup_form_elements[i]['star-style-color-unrated'] != "") style += "#lepopup-element-"+i+" .lepopup-star-rating>label{color:"+lepopup_form_elements[i]['star-style-color-unrated']+" !important;}"; if (lepopup_form_elements[i]['star-style-color-rated'] != "") style += "#lepopup-element-"+i+" .lepopup-star-rating>input:checked~label, #lepopup-element-"+i+" .lepopup-star-rating:not(:checked)>label:hover, #lepopup-element-"+i+" .lepopup-star-rating:not(:checked)>label:hover~label{color:"+lepopup_form_elements[i]['star-style-color-rated']+" !important;}"; options = ""; for (var j=lepopup_form_elements[i]['total-stars']; j>0; j--) { options += ""; } extra_class = ""; if (lepopup_form_elements[i]['star-style-size'] != "") extra_class += " lepopup-star-rating-"+lepopup_form_elements[i]['star-style-size']; html += "
    "+options+"
    "; break; case "html": text_style = lepopup_build_style_text(lepopup_form_elements[i], "text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style_attr = text_style["style"]; style += "#lepopup-element-"+i+" *{"+style_attr+"}"; style_attr += lepopup_build_style_background(lepopup_form_elements[i], "background-style"); style_attr += lepopup_build_style_border(lepopup_form_elements[i], "border-style"); style_attr += lepopup_build_shadow(lepopup_form_elements[i], "shadow"); style += "#lepopup-element-"+i+"{"+style_attr+"}"; style_attr = lepopup_build_style_padding(lepopup_form_elements[i], "padding"); style += "#lepopup-element-"+i+" .lepopup-element-html-content {min-height:"+lepopup_escape_html(lepopup_form_elements[i]['size-height'])+"px;"+style_attr+"}"; content = lepopup_form_elements[i]["content"]; div = document.createElement('div'); div.innerHTML = content; content = div.innerHTML; content = content.replace("autoplay=1", ""); var script_regex = /)<[^<]*)*<\/script>/gi; while (script_regex.test(content)) { content = content.replace(script_regex, ""); } html += "
    "+content+"
    "; break; case "rectangle": style_attr = lepopup_build_style_background(lepopup_form_elements[i], "background-style"); style_attr += lepopup_build_style_border(lepopup_form_elements[i], "border-style"); style_attr += lepopup_build_shadow(lepopup_form_elements[i], "shadow"); style += "#lepopup-element-"+i+"{"+style_attr+"}"; style += "#lepopup-element-"+i+" .lepopup-element-html-content {min-height:"+lepopup_escape_html(lepopup_form_elements[i]['size-height'])+"px;}"; html += "
    "; break; case "close": if (lepopup_form_elements[i]['colors-color3'] != "") properties['shadow'] = "text-shadow:1px 1px 1px "+lepopup_escape_html(lepopup_form_elements[i]['colors-color3'])+";"; else properties['shadow'] = ""; if (lepopup_form_elements[i]['colors-color1'] != "") properties['main-color'] = "color:"+lepopup_escape_html(lepopup_form_elements[i]['colors-color1'])+";"; else properties['main-color'] = ""; if (lepopup_form_elements[i]['colors-color2'] != "") properties['hover-color'] = "color:"+lepopup_escape_html(lepopup_form_elements[i]['colors-color2'])+";"; else properties['hover-color'] = ""; style += "#lepopup-element-"+i+" span {font-size:"+lepopup_escape_html(lepopup_form_elements[i]['size-width'])+"px;"+properties['main-color']+properties['shadow']+"}"; style += "#lepopup-element-"+i+" span i {"+properties['main-color']+"}"; style += "#lepopup-element-"+i+" span:hover, #lepopup-element-"+i+" span:hover i {"+properties['hover-color']+"}"; if (lepopup_form_elements[i]['view'] == "fa-1") properties['view'] = ''; else if (lepopup_form_elements[i]['view'] == "fa-2") properties['view'] = ''; else if (lepopup_form_elements[i]['view'] == "fa-3") properties['view'] = ''; else properties['view'] = '×'; html += "
    "+properties["view"]+"
    "; break; case "fa-icon": if (lepopup_form_elements[i]['colors-color3'] != "") properties['shadow'] = "text-shadow:1px 1px 1px "+lepopup_escape_html(lepopup_form_elements[i]['colors-color3'])+";"; else properties['shadow'] = ""; if (lepopup_form_elements[i]['colors-color1'] != "") properties['main-color'] = "color:"+lepopup_escape_html(lepopup_form_elements[i]['colors-color1'])+";"; else properties['main-color'] = ""; if (lepopup_form_elements[i]['colors-color2'] != "") properties['hover-color'] = "color:"+lepopup_escape_html(lepopup_form_elements[i]['colors-color2'])+";"; else properties['hover-color'] = ""; style += "#lepopup-element-"+i+" span {font-size:"+lepopup_escape_html(lepopup_form_elements[i]['size-width'])+"px;"+properties['main-color']+properties['shadow']+"}"; style += "#lepopup-element-"+i+" span i {"+properties['main-color']+"}"; style += "#lepopup-element-"+i+" span:hover, #lepopup-element-"+i+" span:hover i {"+properties['hover-color']+"}"; html += "
    "; break; case "progress": properties["progress"] = _lepopup_update_progress(lepopup_form_elements[i]["_parent"]); html += "
    "+properties["progress"]+"
    "; break; default: break; } } if (lepopup_form_elements[i].hasOwnProperty("css") && lepopup_form_elements[i]["css"].length > 0) { if (lepopup_meta.hasOwnProperty(lepopup_form_elements[i]["type"]) && lepopup_meta[lepopup_form_elements[i]["type"]].hasOwnProperty("css")) { for (var j=0; j"+html; } return {"html" : global_html, "style" : "", "webfonts" : webfonts}; } function lepopup_build_style_text(_properties, _key) { var style = "", webfont = ""; var integer; if (_properties.hasOwnProperty(_key+"-family") && _properties[_key+"-family"] != "") { style += "font-family:'"+_properties[_key+"-family"]+"','arial';"; if (lepopup_localfonts.indexOf(_properties[_key+"-family"]) == -1) webfont = _properties[_key+"-family"]; } if (_properties.hasOwnProperty(_key+"-size")) { integer = parseInt(_properties[_key+"-size"], 10); if (integer >= 8 && integer <= 256) style += "font-size:"+integer+"px;"; } if (_properties.hasOwnProperty(_key+"-color") && _properties[_key+"-color"] != "") style += "color:"+_properties[_key+"-color"]+";"; if (!_properties.hasOwnProperty(_key+"-weight") || _properties[_key+"-weight"] == "") { if (_properties.hasOwnProperty(_key+"-bold") && _properties[_key+"-bold"] == "on") style += "font-weight:bold;"; else style += "font-weight:normal;"; } else if (_properties[_key+"-weight"] != "inherit") style += "font-weight:"+_properties[_key+"-weight"]+";"; if (_properties.hasOwnProperty(_key+"-italic") && _properties[_key+"-italic"] == "on") style += "font-style:italic;"; else style += "font-style:normal;"; if (_properties.hasOwnProperty(_key+"-underline") && _properties[_key+"-underline"] == "on") style += "text-decoration:underline;"; else style += "text-decoration:none;"; if (_properties.hasOwnProperty(_key+"-align") && _properties[_key+"-align"] != "") style += "text-align:"+_properties[_key+"-align"]+";"; return {"style" : style, "webfont" : webfont}; } function lepopup_build_style_background(_properties, _key) { var style = ""; var integer, hposition = "left", vposition = "top"; var direction = "to bottom", color1 = "transparent", color2 = "transparent"; if (_properties.hasOwnProperty(_key+"-color") && _properties[_key+"-color"] != "") color1 = _properties[_key+"-color"]; if (_properties.hasOwnProperty(_key+"-gradient") && _properties[_key+"-gradient"] == "2shades") { style += "background-color:"+color1+"; background-image:linear-gradient(to bottom,rgba(255,255,255,.05) 0,rgba(255,255,255,.05) 50%,rgba(0,0,0,.05) 51%,rgba(0,0,0,.05) 100%);"; } else if (_properties.hasOwnProperty(_key+"-gradient") && (_properties[_key+"-gradient"] == "horizontal" || _properties[_key+"-gradient"] == "vertical" || _properties[_key+"-gradient"] == "diagonal")) { if (_properties.hasOwnProperty(_key+"-color2") && _properties[_key+"-color2"] != "") color2 = _properties[_key+"-color2"]; if (_properties[_key+"-gradient"] == "horizontal") direction = "to right"; else if (_properties[_key+"-gradient"] == "diagonal") direction = "to bottom right"; style += "background-image:linear-gradient("+direction+","+color1+","+color2+");"; } else if (_properties.hasOwnProperty(_key+"-image") && _properties[_key+"-image"] != "") { style += "background-color:"+color1+"; background-image:url('"+_properties[_key+"-image"]+"');"; if (_properties.hasOwnProperty(_key+"-size") && _properties[_key+"-size"] != "") style += "background-size:"+_properties[_key+"-size"]+";"; if (_properties.hasOwnProperty(_key+"-repeat") && _properties[_key+"-repeat"] != "") style += "background-repeat:"+_properties[_key+"-repeat"]+";"; if (_properties.hasOwnProperty(_key+"-horizontal-position") && _properties[_key+"-horizontal-position"] != "") { switch (_properties[_key+"-horizontal-position"]) { case 'center': hposition = "center"; break; case 'right': hposition = "right"; break; default: hposition = "left"; break; } } if (_properties.hasOwnProperty(_key+"-vertical-position") && _properties[_key+"-vertical-position"] != "") { switch (_properties[_key+"-vertical-position"]) { case 'center': vposition = "center"; break; case 'bottom': vposition = "bottom"; break; default: vposition = "top"; break; } } style += "background-position: "+hposition+" "+vposition+";"; } else style += "background-color:"+color1+"; background-image:none;"; return style; } function lepopup_build_style_border(_properties, _key) { var style = ""; var integer; if (_properties.hasOwnProperty(_key+"-width")) { integer = parseInt(_properties[_key+"-width"], 10); if (integer >= 0 && integer <= 16) style += "border-width:"+integer+"px;"; } if (_properties.hasOwnProperty(_key+"-style") && _properties[_key+"-style"] != "") style += "border-style:"+_properties[_key+"-style"]+";"; if (_properties.hasOwnProperty(_key+"-color") && _properties[_key+"-color"] != "") style += "border-color:"+_properties[_key+"-color"]+";"; else style += "border-color:transparent;"; if (_properties.hasOwnProperty(_key+"-radius")) { if (_properties[_key+"-radius"] == "max") { style += "border-radius:800px;"; } else { integer = parseInt(_properties[_key+"-radius"], 10); if (integer >= 0 && integer <= 100) style += "border-radius:"+integer+"px;"; } } if (_properties.hasOwnProperty(_key+"-top") && _properties[_key+"-top"] != "on") style += "border-top:none !important;"; if (_properties.hasOwnProperty(_key+"-left") && _properties[_key+"-left"] != "on") style += "border-left:none !important;"; if (_properties.hasOwnProperty(_key+"-right") && _properties[_key+"-right"] != "on") style += "border-right:none !important;"; if (_properties.hasOwnProperty(_key+"-bottom") && _properties[_key+"-bottom"] != "on") style += "border-bottom:none !important;"; return style; } function lepopup_build_shadow(_properties, _key) { var style = "box-shadow:none;"; var color = "transparent"; var shadow_style = "regular"; if (_properties.hasOwnProperty(_key+"-size") && _properties[_key+"-size"] != "") { if (_properties.hasOwnProperty(_key+"-color") && _properties[_key+"-color"] != "") color = _properties[_key+"-color"]; if (_properties.hasOwnProperty(_key+"-style") && _properties[_key+"-style"] != "") shadow_style = _properties[_key+"-style"]; switch (shadow_style) { case 'solid': if (_properties[_key+"-size"] == "tiny") style = "box-shadow: 1px 1px 0px 0px "+color+";"; else if (_properties[_key+"-size"] == "small") style = "box-shadow: 2px 2px 0px 0px "+color+";"; else if (_properties[_key+"-size"] == "medium") style = "box-shadow: 4px 4px 0px 0px "+color+";"; else if (_properties[_key+"-size"] == "large") style = "box-shadow: 6px 6px 0px 0px "+color+";"; else if (_properties[_key+"-size"] == "huge") style = "box-shadow: 8px 8px 0px 0px "+color+";"; break; case 'inset': if (_properties[_key+"-size"] == "tiny") style = "box-shadow: inset 0px 0px 15px -9px "+color+";"; else if (_properties[_key+"-size"] == "small") style = "box-shadow: inset 0px 0px 15px -8px "+color+";"; else if (_properties[_key+"-size"] == "medium") style = "box-shadow: inset 0px 0px 15px -7px "+color+";"; else if (_properties[_key+"-size"] == "large") style = "box-shadow: inset 0px 0px 15px -6px "+color+";"; else if (_properties[_key+"-size"] == "huge") style = "box-shadow: inset 0px 0px 15px -5px "+color+";"; break; default: if (_properties[_key+"-size"] == "tiny") style = "box-shadow: 1px 1px 15px -9px "+color+";"; else if (_properties[_key+"-size"] == "small") style = "box-shadow: 1px 1px 15px -8px "+color+";"; else if (_properties[_key+"-size"] == "medium") style = "box-shadow: 1px 1px 15px -6px "+color+";"; else if (_properties[_key+"-size"] == "large") style = "box-shadow: 1px 1px 15px -3px "+color+";"; else if (_properties[_key+"-size"] == "huge") style = "box-shadow: 1px 1px 15px -0px "+color+";"; break; } } return style; } function lepopup_build_style_padding(_properties, _key) { var style = ""; var integer; if (_properties.hasOwnProperty(_key+"-top")) { integer = parseInt(_properties[_key+"-top"], 10); if (integer >= 0 && integer <= 300) style += "padding-top:"+integer+"px;"; } if (_properties.hasOwnProperty(_key+"-right")) { integer = parseInt(_properties[_key+"-right"], 10); if (integer >= 0 && integer <= 300) style += "padding-right:"+integer+"px;"; } if (_properties.hasOwnProperty(_key+"-bottom")) { integer = parseInt(_properties[_key+"-bottom"], 10); if (integer >= 0 && integer <= 300) style += "padding-bottom:"+integer+"px;"; } if (_properties.hasOwnProperty(_key+"-left")) { integer = parseInt(_properties[_key+"-left"], 10); if (integer >= 0 && integer <= 300) style += "padding-left:"+integer+"px;"; } return style; } function lepopup_update_progress() { jQuery(".lepopup-element-progress").each(function(){ var page = jQuery(this).closest(".lepopup-form").attr("_data-parent"); if (typeof page != typeof undefined) { var html = _lepopup_update_progress(page); jQuery(this).html(html); } }); } function _lepopup_update_progress(_page_id) { var html = ""; var page_name = ""; var pages = ".lepopup-pages-bar-item"; if (lepopup_form_options["progress-confirmation-enable"] == "on") pages += ",.lepopup-pages-bar-item-confirmation"; var total_pages = jQuery(pages).length; var idx = 0; jQuery(pages).each(function(){ var page_id = jQuery(this).attr("data-id"); if (page_id == _page_id) return false; idx++; }); var page = jQuery(".lepopup-pages-bar-item[data-id='"+_page_id+"'], .lepopup-pages-bar-item-confirmation[data-id='"+_page_id+"']"); if (jQuery(page).length > 0) { if (lepopup_form_options["progress-type"] == 'progress-2') { html = "
      "; var i = 0; jQuery(pages).each(function() { page_name = jQuery(this).attr("data-name"); html += ""+(i+1)+""+(lepopup_form_options["progress-label-enable"] == "on" ? "" : "")+""; i++; }); html += "
    "; } else { page_name = jQuery(page).attr("data-name"); var width = parseInt(Math.round(100*(idx+1)/total_pages), 10); html = "
    "+width+"%
    "+(lepopup_form_options["progress-label-enable"] == "on" ? "" : "")+"
    "; } } return html; } function lepopup_build() { var adminbar_height; if (jQuery("#wpadminbar").length > 0) adminbar_height = parseInt(jQuery("#wpadminbar").height(), 10); else adminbar_height = 0; var text_style, style_attr, style = ""; var webfonts = new Array(); var width, height; jQuery(".lepopup-form .lepopup-elements").html(""); jQuery(".lepopup-form .lepopup-hidden-elements").html(""); jQuery(".lepopup-form").attr("class", jQuery(".lepopup-form").attr("class").replace(/\blepopup-form-icon-[a-z]+\b/g, "")); jQuery(".lepopup-form").addClass("lepopup-form-icon-"+lepopup_form_options["input-icon-position"]); if (lepopup_form_options["progress-enable"] == "on") { if (lepopup_form_options["progress-type"] == 'progress-2') { if (lepopup_form_options.hasOwnProperty("progress-color-color1") && lepopup_form_options['progress-color-color1'] != "") style += "ul.lepopup-progress-t2,ul.lepopup-progress-t2>li>span{background-color:"+lepopup_form_options['progress-color-color1']+";}ul.lepopup-progress-t2>li>label{color:"+lepopup_form_options['progress-color-color1']+";}"; if (lepopup_form_options.hasOwnProperty("progress-color-color2") && lepopup_form_options['progress-color-color2'] != "") style += "ul.lepopup-progress-t2>li.lepopup-progress-t2-active>span,ul.lepopup-progress-t2>li.lepopup-progress-t2-passed>span{background-color:"+lepopup_form_options['progress-color-color2']+";}"; if (lepopup_form_options.hasOwnProperty("progress-color-color3") && lepopup_form_options['progress-color-color3'] != "") style += "ul.lepopup-progress-t2>li>span{color:"+lepopup_form_options['progress-color-color3']+";}"; if (lepopup_form_options.hasOwnProperty("progress-color-color4") && lepopup_form_options['progress-color-color4'] != "") style += "ul.lepopup-progress-t2>li.lepopup-progress-t2-active>label{color:"+lepopup_form_options['progress-color-color4']+";}"; } else { if (lepopup_form_options.hasOwnProperty("progress-color-color1") && lepopup_form_options['progress-color-color1'] != "") style += "div.lepopup-progress-t1>div{background-color:"+lepopup_form_options['progress-color-color1']+";}"; if (lepopup_form_options.hasOwnProperty("progress-color-color2") && lepopup_form_options['progress-color-color2'] != "") style += "div.lepopup-progress-t1>div>div{background-color:"+lepopup_form_options['progress-color-color2']+";}"; if (lepopup_form_options.hasOwnProperty("progress-color-color3") && lepopup_form_options['progress-color-color3'] != "") style += "div.lepopup-progress-t1>div>div{color:"+lepopup_form_options['progress-color-color3']+";}"; if (lepopup_form_options.hasOwnProperty("progress-color-color4") && lepopup_form_options['progress-color-color4'] != "") style += "div.lepopup-progress-t1>label{color:"+lepopup_form_options['progress-color-color4']+";}"; } style += ".lepopup-progress{max-width:"+lepopup_form_options["max-width-value"]+lepopup_form_options["max-width-unit"]+";}"; } text_style = lepopup_build_style_text(lepopup_form_options, "text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style_attr = text_style["style"]; style += ".lepopup-form *, .lepopup-progress {"+style_attr+"}"; text_style = lepopup_build_style_text(lepopup_form_options, "input-text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style_attr = text_style["style"]; //style += ".lepopup-element div.lepopup-input div.lepopup-signature-box span i{"+style_attr+"}"; style_attr += lepopup_build_style_background(lepopup_form_options, "input-background-style"); style_attr += lepopup_build_style_border(lepopup_form_options, "input-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "input-shadow"); style += ".lepopup-element div.lepopup-input div.lepopup-signature-box,.lepopup-element div.lepopup-input div.lepopup-signature-box,.lepopup-element div.lepopup-input div.lepopup-multiselect,.lepopup-element div.lepopup-input input[type='text'],.lepopup-element div.lepopup-input input[type='email'],.lepopup-element div.lepopup-input input[type='password'],.lepopup-element div.lepopup-input select,.lepopup-element div.lepopup-input select option,.lepopup-element div.lepopup-input textarea{"+style_attr+"}"; style += ".lepopup-element div.lepopup-input ::placeholder{color:"+lepopup_form_options['input-text-style-color']+"; opacity: 0.9;}"; style += ".lepopup-element div.lepopup-input div.lepopup-multiselect::-webkit-scrollbar-thumb{background-color:"+lepopup_form_options["input-border-style-color"]+";}" if (lepopup_form_options["input-hover-inherit"] == "off") { text_style = lepopup_build_style_text(lepopup_form_options, "input-hover-text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style_attr = text_style["style"]; style_attr += lepopup_build_style_background(lepopup_form_options, "input-hover-background-style"); style_attr += lepopup_build_style_border(lepopup_form_options, "input-hover-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "input-hover-shadow"); style += ".lepopup-element div.lepopup-input input[type='text']:hover,.lepopup-element div.lepopup-input input[type='email']:hover,.lepopup-element div.lepopup-input input[type='password']:hover,.lepopup-element div.lepopup-input select:hover,.lepopup-element div.lepopup-input select:hover option,.lepopup-element div.lepopup-input textarea:hover{"+style_attr+"}"; } if (lepopup_form_options["input-focus-inherit"] == "off") { text_style = lepopup_build_style_text(lepopup_form_options, "input-focus-text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style_attr = text_style["style"]; style_attr += lepopup_build_style_background(lepopup_form_options, "input-focus-background-style"); style_attr += lepopup_build_style_border(lepopup_form_options, "input-focus-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "input-focus-shadow"); style += ".lepopup-element div.lepopup-input input[type='text']:focus,.lepopup-element div.lepopup-input input[type='email']:focus,.lepopup-element div.lepopup-input input[type='password']:focus,.lepopup-element div.lepopup-input select:focus,.lepopup-element div.lepopup-input select:focus option,.lepopup-element div.lepopup-input textarea:focus{"+style_attr+"}"; } style_attr = lepopup_build_style_border(lepopup_form_options, "imageselect-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "imageselect-shadow"); style += ".lepopup-element div.lepopup-input .lepopup-imageselect+label{"+style_attr+"}"; if (lepopup_form_options["imageselect-hover-inherit"] == "off") { style_attr = lepopup_build_style_border(lepopup_form_options, "imageselect-hover-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "imageselect-hover-shadow"); style += ".lepopup-element div.lepopup-input .lepopup-imageselect+label:hover{"+style_attr+"}"; } if (lepopup_form_options["imageselect-selected-inherit"] == "off") { style_attr = lepopup_build_style_border(lepopup_form_options, "imageselect-selected-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "imageselect-selected-shadow"); style += ".lepopup-element div.lepopup-input .lepopup-imageselect:checked+label{"+style_attr+"}"; } text_style = lepopup_build_style_text(lepopup_form_options, "imageselect-text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style += ".lepopup-element div.lepopup-input .lepopup-imageselect+label span.lepopup-imageselect-label{"+text_style["style"]+"}"; style_attr = ""; if (lepopup_form_options["input-icon-size"] != "") { style_attr += "font-size:"+lepopup_form_options["input-icon-size"]+"px;"; } if (lepopup_form_options["input-icon-color"] != "") { style_attr += "color:"+lepopup_form_options["input-icon-color"]+";"; } if (lepopup_form_options["input-icon-position"] != "outside") { if (lepopup_form_options["input-icon-background"] != "") { style_attr += "background:"+lepopup_form_options["input-icon-background"]+";"; } if (lepopup_form_options["input-icon-border"] != "") { style_attr += "border-color:"+lepopup_form_options["input-icon-border"]+";border-style:solid;"; if (lepopup_form_options.hasOwnProperty("input-border-style-width")) { integer = parseInt(lepopup_form_options["input-border-style-width"], 10); if (integer >= 0 && integer <= 16) style_attr += "border-width:"+integer+"px;"; } } if (lepopup_form_options.hasOwnProperty("input-border-style-radius")) { var integer = parseInt(lepopup_form_options["input-border-style-radius"], 10); if (integer >= 0 && integer <= 100) style_attr += "border-radius:"+integer+"px;"; } if (lepopup_form_options["input-icon-background"] != "" || lepopup_form_options["input-icon-border"] != "") { style += "div.lepopup-input.lepopup-icon-left input[type='text'], div.lepopup-input.lepopup-icon-left input[type='email'],div.lepopup-input.lepopup-icon-left input[type='password'],div.lepopup-input.lepopup-icon-left textarea {padding-left: 56px !important;}"; style += "div.lepopup-input.lepopup-icon-right input[type='text'], div.lepopup-input.lepopup-icon-right input[type='email'],div.lepopup-input.lepopup-icon-right input[type='password'],div.lepopup-input.lepopup-icon-right textarea {padding-right: 56px !important;}"; } } if (style_attr != "") { style += "div.lepopup-input>i.lepopup-icon-left, div.lepopup-input>i.lepopup-icon-right {"+style_attr+"}"; } text_style = lepopup_build_style_text(lepopup_form_options, "button-text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style_attr = text_style["style"]; style_attr += lepopup_build_style_background(lepopup_form_options, "button-background-style"); style_attr += lepopup_build_style_border(lepopup_form_options, "button-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "button-shadow"); style += ".lepopup-element .lepopup-button{"+style_attr+"}"; if (lepopup_form_options["button-hover-inherit"] == "off") { text_style = lepopup_build_style_text(lepopup_form_options, "button-hover-text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style_attr = text_style["style"]; style_attr += lepopup_build_style_background(lepopup_form_options, "button-hover-background-style"); style_attr += lepopup_build_style_border(lepopup_form_options, "button-hover-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "button-hover-shadow"); style += ".lepopup-element .lepopup-button:hover,.lepopup-element .lepopup-button:focus{"+style_attr+"}"; } if (lepopup_form_options["button-active-inherit"] == "off") { text_style = lepopup_build_style_text(lepopup_form_options, "button-active-text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style_attr = text_style["style"]; style_attr += lepopup_build_style_background(lepopup_form_options, "button-active-background-style"); style_attr += lepopup_build_style_border(lepopup_form_options, "button-active-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "button-active-shadow"); style += ".lepopup-element .lepopup-button:active{"+style_attr+"}"; } text_style = lepopup_build_style_text(lepopup_form_options, "tile-text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style_attr = text_style["style"]; style_attr += lepopup_build_style_background(lepopup_form_options, "tile-background-style"); style_attr += lepopup_build_style_border(lepopup_form_options, "tile-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "tile-shadow"); style += ".lepopup-element input[type='checkbox'].lepopup-tile+label,.lepopup-element input[type='radio'].lepopup-tile+label{"+style_attr+"}"; if (lepopup_form_options["tile-hover-inherit"] == "off") { text_style = lepopup_build_style_text(lepopup_form_options, "tile-hover-text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style_attr = text_style["style"]; style_attr += lepopup_build_style_background(lepopup_form_options, "tile-hover-background-style"); style_attr += lepopup_build_style_border(lepopup_form_options, "tile-hover-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "tile-hover-shadow"); style += ".lepopup-element input[type='checkbox'].lepopup-tile+label:hover,.lepopup-element input[type='radio'].lepopup-tile+label:hover{"+style_attr+"}"; } if (lepopup_form_options["tile-selected-inherit"] == "off") { text_style = lepopup_build_style_text(lepopup_form_options, "tile-selected-text-style"); if (text_style["webfont"] != "" && webfonts.indexOf(text_style["webfont"]) == -1) webfonts.push(text_style["webfont"]); style_attr = text_style["style"]; style_attr += lepopup_build_style_background(lepopup_form_options, "tile-selected-background-style"); style_attr += lepopup_build_style_border(lepopup_form_options, "tile-selected-border-style"); style_attr += lepopup_build_shadow(lepopup_form_options, "tile-selected-shadow"); style += ".lepopup-element input[type='checkbox'].lepopup-tile:checked+label,.lepopup-element input[type='radio'].lepopup-tile:checked+label{"+style_attr+"}"; } style_attr = ""; if (lepopup_form_options.hasOwnProperty("checkbox-radio-unchecked-color-color2") && lepopup_form_options["checkbox-radio-unchecked-color-color2"] != "") style_attr += "background-color:"+lepopup_form_options["checkbox-radio-unchecked-color-color2"]+";"; else style_attr += "background-color:transparent;"; style += ".lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-tgl:checked+label:after{"+style_attr+"}"; if (lepopup_form_options.hasOwnProperty("checkbox-radio-unchecked-color-color1") && lepopup_form_options["checkbox-radio-unchecked-color-color1"] != "") style_attr += "border-color:"+lepopup_form_options["checkbox-radio-unchecked-color-color1"]+";"; else style_attr += "border-color:transparent;"; if (lepopup_form_options.hasOwnProperty("checkbox-radio-unchecked-color-color3") && lepopup_form_options["checkbox-radio-unchecked-color-color3"] != "") style_attr += "color:"+lepopup_form_options["checkbox-radio-unchecked-color-color3"]+";"; else style_attr += "color:#ccc;"; style += ".lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-classic+label,.lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-fa-check+label,.lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-square+label,.lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-tgl+label{"+style_attr+"}"; style_attr = ""; if (lepopup_form_options.hasOwnProperty("checkbox-radio-unchecked-color-color3") && lepopup_form_options["checkbox-radio-unchecked-color-color3"] != "") style_attr += "background-color:"+lepopup_form_options["checkbox-radio-unchecked-color-color3"]+";"; else style_attr += "background-color:#ccc;"; style += ".lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-square:checked+label:after{"+style_attr+"}"; style += ".lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-tgl:checked+label,.lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-tgl+label:after{"+style_attr+"}"; if (lepopup_form_options["checkbox-radio-checked-inherit"] == "off") { style_attr = ""; if (lepopup_form_options.hasOwnProperty("checkbox-radio-checked-color-color2") && lepopup_form_options["checkbox-radio-checked-color-color2"] != "") style_attr += "background-color:"+lepopup_form_options["checkbox-radio-checked-color-color2"]+";"; else style_attr += "background-color:transparent;"; if (lepopup_form_options.hasOwnProperty("checkbox-radio-checked-color-color1") && lepopup_form_options["checkbox-radio-checked-color-color1"] != "") style_attr += "border-color:"+lepopup_form_options["checkbox-radio-checked-color-color1"]+";"; else style_attr += "border-color:transparent;"; if (lepopup_form_options.hasOwnProperty("checkbox-radio-checked-color-color3") && lepopup_form_options["checkbox-radio-checked-color-color3"] != "") style_attr += "color:"+lepopup_form_options["checkbox-radio-checked-color-color3"]+";"; else style_attr += "color:#ccc;"; style += ".lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-classic:checked+label,.lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-fa-check:checked+label,.lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-square:checked+label,.lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-tgl:checked+label{"+style_attr+"}"; style_attr = ""; if (lepopup_form_options.hasOwnProperty("checkbox-radio-checked-color-color3") && lepopup_form_options["checkbox-radio-checked-color-color3"] != "") style_attr += "background-color:"+lepopup_form_options["checkbox-radio-checked-color-color3"]+";"; else style_attr += "background-color:#ccc;"; style += ".lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-square:checked+label:after{"+style_attr+"}"; style += ".lepopup-element div.lepopup-input input[type='checkbox'].lepopup-checkbox-tgl:checked+label:after{"+style_attr+"}"; } style_attr = ""; if (lepopup_form_options.hasOwnProperty("checkbox-radio-unchecked-color-color2") && lepopup_form_options["checkbox-radio-unchecked-color-color2"] != "") style_attr += "background-color:"+lepopup_form_options["checkbox-radio-unchecked-color-color2"]+";"; else style_attr += "background-color:transparent;"; if (lepopup_form_options.hasOwnProperty("checkbox-radio-unchecked-color-color1") && lepopup_form_options["checkbox-radio-unchecked-color-color1"] != "") style_attr += "border-color:"+lepopup_form_options["checkbox-radio-unchecked-color-color1"]+";"; else style_attr += "border-color:transparent;"; if (lepopup_form_options.hasOwnProperty("checkbox-radio-unchecked-color-color3") && lepopup_form_options["checkbox-radio-unchecked-color-color3"] != "") style_attr += "color:"+lepopup_form_options["checkbox-radio-unchecked-color-color3"]+";"; else style_attr += "color:#ccc;"; style += ".lepopup-element div.lepopup-input input[type='radio'].lepopup-radio-classic+label,.lepopup-element div.lepopup-input input[type='radio'].lepopup-radio-fa-check+label,.lepopup-element div.lepopup-input input[type='radio'].lepopup-radio-dot+label{"+style_attr+"}"; style_attr = ""; if (lepopup_form_options.hasOwnProperty("checkbox-radio-unchecked-color-color3") && lepopup_form_options["checkbox-radio-unchecked-color-color3"] != "") style_attr += "background-color:"+lepopup_form_options["checkbox-radio-unchecked-color-color3"]+";"; else style_attr += "background-color:#ccc;"; style += ".lepopup-element div.lepopup-input input[type='radio'].lepopup-radio-dot:checked+label:after{"+style_attr+"}"; if (lepopup_form_options["checkbox-radio-checked-inherit"] == "off") { style_attr = ""; if (lepopup_form_options.hasOwnProperty("checkbox-radio-checked-color-color2") && lepopup_form_options["checkbox-radio-checked-color-color2"] != "") style_attr += "background-color:"+lepopup_form_options["checkbox-radio-checked-color-color2"]+";"; else style_attr += "background-color:transparent;"; if (lepopup_form_options.hasOwnProperty("checkbox-radio-checked-color-color1") && lepopup_form_options["checkbox-radio-checked-color-color1"] != "") style_attr += "border-color:"+lepopup_form_options["checkbox-radio-checked-color-color1"]+";"; else style_attr += "border-color:transparent;"; if (lepopup_form_options.hasOwnProperty("checkbox-radio-checked-color-color3") && lepopup_form_options["checkbox-radio-checked-color-color3"] != "") style_attr += "color:"+lepopup_form_options["checkbox-radio-checked-color-color3"]+";"; else style_attr += "color:#ccc;"; style += ".lepopup-element div.lepopup-input input[type='radio'].lepopup-radio-classic:checked+label,.lepopup-element div.lepopup-input input[type='radio'].lepopup-radio-fa-check:checked+label,.lepopup-element div.lepopup-input input[type='radio'].lepopup-radio-dot:checked+label{"+style_attr+"}"; style_attr = ""; if (lepopup_form_options.hasOwnProperty("checkbox-radio-checked-color-color3") && lepopup_form_options["checkbox-radio-checked-color-color3"] != "") style_attr += "background-color:"+lepopup_form_options["checkbox-radio-checked-color-color3"]+";"; else style_attr += "background-color:#ccc;"; style += ".lepopup-element div.lepopup-input input[type='radio'].lepopup-radio-dot:checked+label:after{"+style_attr+"}"; } style_attr = ""; if (lepopup_form_options.hasOwnProperty("multiselect-style-hover-background") && lepopup_form_options["multiselect-style-hover-background"] != "") style_attr += "background-color:"+lepopup_form_options['multiselect-style-hover-background']+";"; if (lepopup_form_options.hasOwnProperty("multiselect-style-hover-color") && lepopup_form_options["multiselect-style-hover-color"] != "") style_attr += "color:"+lepopup_form_options['multiselect-style-hover-color']+";"; if (style_attr != "") style += ".lepopup-element div.lepopup-input div.lepopup-multiselect>input[type='checkbox']+label:hover{"+style_attr+"}"; style_attr = ""; if (lepopup_form_options.hasOwnProperty("multiselect-style-selected-background") && lepopup_form_options["multiselect-style-selected-background"] != "") style_attr += "background-color:"+lepopup_form_options['multiselect-style-selected-background']+";"; if (lepopup_form_options.hasOwnProperty("multiselect-style-selected-color") && lepopup_form_options["multiselect-style-selected-color"] != "") style_attr += "color:"+lepopup_form_options['multiselect-style-selected-color']+";"; if (style_attr != "") style += ".lepopup-element div.lepopup-input div.lepopup-multiselect>input[type='checkbox']:checked+label{"+style_attr+"}"; if (typeof jQuery.fn.ionRangeSlider != typeof undefined && jQuery.fn.ionRangeSlider) { if (lepopup_form_options.hasOwnProperty("rangeslider-color-color1") && lepopup_form_options["rangeslider-color-color1"] != "") style += ".lepopup-element div.lepopup-input.lepopup-rangeslider .irs-line, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs-min, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs-max, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs-grid-pol{background-color:"+lepopup_form_options["rangeslider-color-color1"]+" !important;}"; if (lepopup_form_options.hasOwnProperty("rangeslider-color-color2") && lepopup_form_options["rangeslider-color-color2"] != "") style += ".lepopup-element div.lepopup-input.lepopup-rangeslider .irs-grid-text, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs-min, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs-max{color:"+lepopup_form_options["rangeslider-color-color2"]+" !important;}"; if (lepopup_form_options.hasOwnProperty("rangeslider-color-color3") && lepopup_form_options["rangeslider-color-color3"] != "") style += ".lepopup-element div.lepopup-input.lepopup-rangeslider .irs-bar{background-color:"+lepopup_form_options["rangeslider-color-color3"]+" !important;}"; if (lepopup_form_options.hasOwnProperty("rangeslider-color-color4") && lepopup_form_options["rangeslider-color-color4"] != "") { style += ".lepopup-element div.lepopup-input.lepopup-rangeslider .irs-single, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs-from, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs-to{background-color:"+lepopup_form_options["rangeslider-color-color4"]+" !important;}"; style += ".lepopup-element div.lepopup-input.lepopup-rangeslider .irs-single:before, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs-from:before, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs-to:before{border-top-color:"+lepopup_form_options["rangeslider-color-color4"]+" !important;}"; switch(lepopup_form_options["rangeslider-skin"]) { case 'sharp': style += ".lepopup-element div.lepopup-input.lepopup-rangeslider .irs--sharp .irs-handle, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs--sharp .irs-handle:hover, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs--sharp .irs-handle.state_hover{background-color:"+lepopup_form_options["rangeslider-color-color4"]+" !important;}"; style += ".lepopup-element div.lepopup-input.lepopup-rangeslider .irs--sharp .irs-handle > i:first-child, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs--sharp .irs-handle:hover > i:first-child, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs--sharp .irs-handle.state_hover > i:first-child{border-top-color:"+lepopup_form_options["rangeslider-color-color4"]+" !important;}"; break; case 'round': style += ".lepopup-element div.lepopup-input.lepopup-rangeslider .irs--round .irs-handle, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs--round .irs-handle:hover, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs--round .irs-handle.state_hover{border-color:"+lepopup_form_options["rangeslider-color-color4"]+" !important;}"; break; default: style += ".lepopup-element div.lepopup-input.lepopup-rangeslider .irs--flat .irs-handle > i:first-child, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs--flat .irs-handle:hover > i:first-child, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs--flat .irs-handle.state_hover > i:first-child{background-color:"+lepopup_form_options["rangeslider-color-color4"]+" !important;}"; break; } } if (lepopup_form_options.hasOwnProperty("rangeslider-color-color5") && lepopup_form_options["rangeslider-color-color5"] != "") { style += ".lepopup-element div.lepopup-input.lepopup-rangeslider .irs-single, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs-from, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs-to{color:"+lepopup_form_options["rangeslider-color-color5"]+" !important;}"; if (lepopup_form_options["rangeslider-skin"] == "round") { style += ".lepopup-element div.lepopup-input.lepopup-rangeslider .irs--round .irs-handle, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs--round .irs-handle:hover, .lepopup-element div.lepopup-input.lepopup-rangeslider .irs--round .irs-handle.state_hover{background-color:"+lepopup_form_options["rangeslider-color-color5"]+" !important;}"; } } } var output; for (var i=0; i"+output["style"]+""+output["html"]); webfonts = webfonts.concat(output["webfonts"]); output = _lepopup_build_hidden_list(lepopup_form_pages[i]['id']); jQuery("#lepopup-form-"+lepopup_form_pages[i]['id']+" .lepopup-hidden-elements").append(output); } } text_style = ""; for (var i=0; i"; } jQuery(".lepopup-form-global-style").html(text_style+""); jQuery(".lepopup-form").each(function(){ var id = jQuery(this).attr("id"); _lepopup_init_basic_frame("#"+id+" .lepopup-basic-frame"); _lepopup_init_elements("#"+id+" .lepopup-elements .lepopup-element"); }); jQuery(".lepopup-layers").draggable({ drag: function(event, ui) { var limit = jQuery(".lepopup-form-editor").width() - 320; if (limit >= 0 && ui.position.left > limit) { ui.position.left = limit; // } else if (ui.position.left < 0) { // ui.position.left = 0; } } }); jQuery(".lepopup-layers-list").sortable({ stop: function() { var list = jQuery(this).closest("ul"); var seq = 0; jQuery(this).find("li").each(function(){ var idx = jQuery(this).attr("data-idx"); if (lepopup_is_numeric(idx)) { idx = parseInt(idx, 10); if (lepopup_form_elements.length > idx && lepopup_form_elements[idx] != null) { lepopup_form_elements[idx]['_seq'] = seq; jQuery("#lepopup-element-"+idx).css({"z-index" : parseInt(500+seq, 10)}); seq++; } } }); } }); _lepopup_init_elements_contextmenu(".lepopup-element, .lepopup-hidden-element"); jQuery(".lepopup-hidden-element").on("click", function(e) { e.preventDefault(); if (lepopup_element_properties_active) { lepopup_properties_panel_open(this); } return false; }); } function _lepopup_init_basic_frame(_selector) { jQuery(_selector).resizable({ grid: [10, 10], minHeight: 80, minWidth: 80, resize: function() { var page_id = jQuery(this).parent().attr("_data-parent"); var width = parseInt(jQuery(this).outerWidth(), 10); var height = parseInt(jQuery(this).outerHeight(), 10); for (var i=0; i 0) adminbar_height = parseInt(jQuery("#wpadminbar").height(), 10); else adminbar_height = 0; jQuery(_selector).on("contextmenu", function(e) { e.preventDefault(); jQuery(".lepopup-context-menu").hide(); lepopup_context_menu_object = this; jQuery(".lepopup-context-menu").css({"top" : (e.pageY - adminbar_height), "left" : e.pageX}); jQuery(".lepopup-context-menu-multi-page").remove(); var li_duplicate_pages = new Array(); var li_move_pages = new Array(); for (var i=0; i"+lepopup_escape_html(lepopup_form_pages[i]["name"])+""); li_move_pages.push("
  • "+lepopup_escape_html(lepopup_form_pages[i]["name"])+"
  • "); } } if (li_duplicate_pages.length > 0) { jQuery(".lepopup-context-menu-last").after("
  • Duplicate to
      "+li_duplicate_pages.join("")+"
  • Move to
      "+li_move_pages.join("")+"
  • "); } jQuery(".lepopup-context-menu").removeClass("lepopup-context-menu-high-priority"); jQuery(".lepopup-context-menu").show(); return false; }); } function _lepopup_init_elements(_selector) { jQuery(_selector).draggable({ grid: [5, 5], cursor: "move", start: function() { }, drag: function() { var id = jQuery(this).attr("id"); id = id.replace("lepopup-element-", ""); var position = jQuery(this).position(); position.left = parseInt(position.left, 10); position.top = parseInt(position.top, 10); lepopup_form_elements[id]['position-top'] = position.top; lepopup_form_elements[id]['position-left'] = position.left; if (lepopup_element_properties_active) { var active_id = jQuery(lepopup_element_properties_active).attr("id"); if (active_id) { active_id = active_id.replace("lepopup-element-", ""); if (id == active_id) { jQuery(".lepopup-properties-panel [name='lepopup-position-top']").val(position.top); jQuery(".lepopup-properties-panel [name='lepopup-position-left']").val(position.left); } } } lepopup_form_changed = true; }, stop: function() { var id = jQuery(this).attr("id"); id = id.replace("lepopup-element-", ""); var position = jQuery(this).position(); position.left = parseInt(position.left, 10); position.top = parseInt(position.top, 10); lepopup_form_elements[id]['position-top'] = position.top; lepopup_form_elements[id]['position-left'] = position.left; if (lepopup_element_properties_active) { var active_id = jQuery(lepopup_element_properties_active).attr("id"); if (active_id) { active_id = active_id.replace("lepopup-element-", ""); if (id == active_id) { jQuery(".lepopup-properties-panel [name='lepopup-position-top']").val(position.top); jQuery(".lepopup-properties-panel [name='lepopup-position-left']").val(position.left); } } } lepopup_form_changed = true; } }); jQuery(_selector).each(function(){ jQuery(this).resizable({ grid: [5, 5], minHeight: parseInt(jQuery(this).attr("data-resizable-min-height"), 10), minWidth: parseInt(jQuery(this).attr("data-resizable-min-width"), 10), aspectRatio: jQuery(this).attr("data-resizable-ratio"), handles: jQuery(this).attr("data-resizable-handles"), start: function() { }, resize: function() { var id = jQuery(this).attr("id"); id = id.replace("lepopup-element-", ""); var update_panel = false; if (lepopup_element_properties_active) { var active_id = jQuery(lepopup_element_properties_active).attr("id"); if (active_id) { active_id = active_id.replace("lepopup-element-", ""); if (id == active_id) update_panel = true; } } var width = parseInt(jQuery(this).outerWidth(), 10); if (jQuery(this).attr("data-resizable-auto-height") == "on") { jQuery(this).height("auto"); lepopup_form_elements[id]['size-width'] = width; if (update_panel) { jQuery(".lepopup-properties-panel [name='lepopup-size-width']").val(width); } } else { var height = parseInt(jQuery(this).outerHeight(), 10); lepopup_form_elements[id]['size-width'] = width; lepopup_form_elements[id]['size-height'] = height; jQuery(this).find("i.lepopup-icon-left, i.lepopup-icon-right").css({"line-height" : height+"px"}); if (update_panel) { jQuery(".lepopup-properties-panel [name='lepopup-size-width']").val(width); jQuery(".lepopup-properties-panel [name='lepopup-size-height']").val(height); } } if ((lepopup_form_elements[id]['type'] == 'close' && jQuery(this).hasClass('lepopup-element-close')) || (lepopup_form_elements[id]['type'] == 'fa-icon' && jQuery(this).hasClass('lepopup-element-icon'))) { jQuery(this).find("span").css({"font-size" : width+"px"}); } if (lepopup_form_elements[id]['type'] == 'html' || lepopup_form_elements[id]['type'] == 'rectangle') { jQuery(this).find(".lepopup-element-html-content").css({"min-height" : height+"px"}); } lepopup_form_changed = true; }, stop: function() { var id = jQuery(this).attr("id"); id = id.replace("lepopup-element-", ""); var update_panel = false; if (lepopup_element_properties_active) { var active_id = jQuery(lepopup_element_properties_active).attr("id"); if (active_id) { active_id = active_id.replace("lepopup-element-", ""); if (id == active_id) update_panel = true; } } var width = parseInt(jQuery(this).outerWidth(), 10); if (jQuery(this).attr("data-resizable-auto-height") == "on") { jQuery(this).height("auto"); lepopup_form_elements[id]['size-width'] = width; if (update_panel) { jQuery(".lepopup-properties-panel [name='lepopup-size-width']").val(width); } } else { var height = parseInt(jQuery(this).outerHeight(), 10); lepopup_form_elements[id]['size-width'] = width; lepopup_form_elements[id]['size-height'] = height; jQuery(this).find("i.lepopup-icon-left, i.lepopup-icon-right").css({"line-height" : height+"px"}); if (update_panel) { jQuery(".lepopup-properties-panel [name='lepopup-size-width']").val(width); jQuery(".lepopup-properties-panel [name='lepopup-size-height']").val(height); } } if ((lepopup_form_elements[id]['type'] == 'close' && jQuery(this).hasClass('lepopup-element-close')) || (lepopup_form_elements[id]['type'] == 'fa-icon' && jQuery(this).hasClass('lepopup-element-icon'))) { jQuery(this).find("span").css({"font-size" : width+"px"}); } if (lepopup_form_elements[id]['type'] == 'html' || lepopup_form_elements[id]['type'] == 'rectangle') { jQuery(this).find(".lepopup-element-html-content").css({"min-height" : height+"px"}); } lepopup_form_changed = true; } }); }); jQuery(_selector).on("mouseenter", function(e){ var id = jQuery(this).attr("id"); id = id.replace("lepopup-element-", ""); jQuery(".lepopup-layer-"+id).addClass("lepopup-layer-hovered"); }); jQuery(_selector).on("mouseleave", function(e){ var id = jQuery(this).attr("id"); id = id.replace("lepopup-element-", ""); jQuery(".lepopup-layer-"+id).removeClass("lepopup-layer-hovered"); }); jQuery(_selector).on("click", function(e) { e.preventDefault(); if (lepopup_element_properties_active) { lepopup_properties_panel_open(this); } return false; }); if (typeof jQuery.fn.ionRangeSlider != typeof undefined && jQuery.fn.ionRangeSlider) jQuery(_selector).find("input.lepopup-rangeslider").ionRangeSlider(); _lepopup_init_elements_contextmenu(_selector); } function lepopup_log_resize() { if (lepopup_record_active) { var popup_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var popup_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 1080); jQuery("#lepopup-record-details").height(popup_height); jQuery("#lepopup-record-details").width(popup_width); jQuery("#lepopup-record-details .lepopup-admin-popup-inner").height(popup_height); jQuery("#lepopup-record-details .lepopup-admin-popup-content").height(popup_height - 52); } } function lepopup_log_ready() { lepopup_log_resize(); jQuery(window).resize(function() { lepopup_log_resize(); }); } function lepopup_forms_resize() { if (lepopup_more_active) { var popup_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var popup_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 840); jQuery("#lepopup-more-using").height(popup_height); jQuery("#lepopup-more-using").width(popup_width); jQuery("#lepopup-more-using .lepopup-admin-popup-inner").height(popup_height); jQuery("#lepopup-more-using .lepopup-admin-popup-content").height(popup_height - 52); } } function lepopup_forms_ready() { jQuery("span[title], a[title]").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom" }); lepopup_forms_resize(); jQuery(window).resize(function() { lepopup_forms_resize(); }); } function lepopup_form_resize() { var window_height = jQuery(window).height(); var adminbar_height = jQuery("#wpadminbar").height(); if (!lepopup_is_numeric(adminbar_height)) adminbar_height = 0; var toolbar_height = jQuery(".lepopup-toolbar").height(); var top_padding = 20; var header_height = jQuery(".lepopup-header").height(); //var builder_height = parseInt(window_height, 10) - parseInt(adminbar_height, 10) - parseInt(header_height, 10) - parseInt(toolbar_height, 10) - parseInt(top_padding, 10); var builder_height = parseInt(window_height, 10); var toolbars_height = jQuery(".lepopup-toolbars").height(); jQuery(".lepopup-builder").css({"min-height" : builder_height+"px"}); jQuery(".lepopup-form").css({"min-height" : parseInt(builder_height-20, 10)+"px"}); var builder_width = jQuery(".lepopup-builder").outerWidth(); jQuery(".lepopup-toolbars").css({"width" : builder_width+"px"}); if (lepopup_element_properties_active) { var popup_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var popup_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 880), 1080); jQuery("#lepopup-element-properties").height(popup_height); jQuery("#lepopup-element-properties").width(popup_width); jQuery("#lepopup-element-properties .lepopup-admin-popup-inner").height(popup_height); jQuery("#lepopup-element-properties .lepopup-admin-popup-content").height(popup_height - 104); } if (lepopup_bulk_options_object) { var popup_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var popup_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 880), 1080); jQuery("#lepopup-bulk-options").height(popup_height); jQuery("#lepopup-bulk-options").width(popup_width); jQuery("#lepopup-bulk-options .lepopup-admin-popup-inner").height(popup_height); jQuery("#lepopup-bulk-options .lepopup-admin-popup-content").height(popup_height - 104); } if (lepopup_record_active) { var popup_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var popup_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 1080); jQuery("#lepopup-record-details").height(popup_height); jQuery("#lepopup-record-details").width(popup_width); jQuery("#lepopup-record-details .lepopup-admin-popup-inner").height(popup_height); jQuery("#lepopup-record-details .lepopup-admin-popup-content").height(popup_height - 52); } if (lepopup_more_active) { var popup_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var popup_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 840); jQuery("#lepopup-more-using").height(popup_height); jQuery("#lepopup-more-using").width(popup_width); jQuery("#lepopup-more-using .lepopup-admin-popup-inner").height(popup_height); jQuery("#lepopup-more-using .lepopup-admin-popup-content").height(popup_height - 52); } } function lepopup_form_ready() { lepopup_form_resize(); jQuery(window).resize(function() { lepopup_form_resize(); }); jQuery(window).scroll(function(e) { return; var position = jQuery(window).scrollTop(); var adminbar_height = jQuery("#wpadminbar").height(); if (!lepopup_is_numeric(adminbar_height)) adminbar_height = 0; var offset = jQuery(".lepopup-builder").offset().top - adminbar_height; if (position > offset) { jQuery("html").addClass("lepopup-toolbars-fixed"); } else { jQuery("html").removeClass("lepopup-toolbars-fixed"); } }); for (var i=0; i lepopup_form_last_id) lepopup_form_last_id = parseInt(lepopup_form_pages_raw[i]['id'], 10); lepopup_form_pages.push(lepopup_form_pages_raw[i]); } } if (lepopup_form_options.hasOwnProperty("math-expressions") && Array.isArray(lepopup_form_options["math-expressions"])) { for (var i=0; i lepopup_form_last_id) lepopup_form_last_id = parseInt(lepopup_form_options["math-expressions"][i]['id'], 10); } } } if (lepopup_form_options.hasOwnProperty("payment-gateways") && Array.isArray(lepopup_form_options["payment-gateways"])) { for (var i=0; i lepopup_form_last_id) lepopup_form_last_id = parseInt(lepopup_form_options["payment-gateways"][i]['id'], 10); } } } var tmp; for (var i=0; i lepopup_form_last_id) lepopup_form_last_id = parseInt(tmp['id'], 10); lepopup_form_elements.push(tmp); } } if (jQuery(".lepopup-pages-bar-item").length == 1) jQuery(".lepopup-pages-bar-item").find(".lepopup-pages-bar-item-delete").addClass("lepopup-pages-bar-item-delete-disabled"); else jQuery(".lepopup-pages-bar-item").find(".lepopup-pages-bar-item-delete").removeClass("lepopup-pages-bar-item-delete-disabled"); lepopup_pages_activate(jQuery(".lepopup-pages-bar-item").first().find("label")); jQuery(".lepopup-toolbar-list>li>a[title]").tooltipster({ maxWidth: 360, theme: "tooltipster-dark lepopup-toolbar-tooltipster", side: "bottom" }); jQuery(".lepopup-toolbar-list li a").on("click", function(e) { e.preventDefault(); var type = jQuery(this).parent().attr("data-type"); if (typeof type == undefined || type == "") return false; if (lepopup_element_properties_active) { lepopup_properties_panel_close(); } if (lepopup_meta.hasOwnProperty(type)) { lepopup_form_last_id++; var element = {"type" : type, "resize" : "both", "height" : "auto", "_parent" : lepopup_form_page_active, "_seq" : lepopup_form_last_id, "id" : lepopup_form_last_id}; for (var key in lepopup_meta[type]) { if (lepopup_meta[type].hasOwnProperty(key)) { if (lepopup_meta[type][key].hasOwnProperty('value')) { if (typeof lepopup_meta[type][key]['value'] == 'object') { for (var option_key in lepopup_meta[type][key]['value']) { if (lepopup_meta[type][key]['value'].hasOwnProperty(option_key)) { element[key+"-"+option_key] = lepopup_meta[type][key]['value'][option_key]; } } } else element[key] = lepopup_meta[type][key]['value']; } else if (lepopup_meta[type][key].hasOwnProperty('values')) element[key] = lepopup_meta[type][key]['values']; } } lepopup_form_elements.push(element); lepopup_form_changed = true; lepopup_build(); _lepopup_layers_sync(lepopup_form_page_active); if (lepopup_gettingstarted_enable == "on" && lepopup_form_elements.length <= 2 && type != "hidden") lepopup_gettingstarted("element-properties", 0); } }); jQuery("body").append(''); jQuery("body").on("click", function(e) { jQuery(".lepopup-context-menu").hide(); }); jQuery(".lepopup-fa-selector-header input").on("keyup", function(e) { var needle = jQuery(this).val().toLowerCase(); if (needle == "") { jQuery(this).parent().parent().find(".lepopup-fa-selector-content span").show(); } else { var icons = jQuery(this).parent().parent().find(".lepopup-fa-selector-content"); jQuery(icons).find("span").each(function() { if (jQuery(this).attr("title").toLowerCase().indexOf(needle) === -1) jQuery(this).hide(); else jQuery(this).show(); }); } return false; }); jQuery(window).on('beforeunload', function(e){ if (lepopup_element_properties_data_changed || lepopup_form_changed) return 'Form changed!'; return; }); jQuery(".lepopup-pages-bar-items").sortable({ items: "li.lepopup-pages-bar-item", containment: "parent", forcePlaceholderSize: true, dropOnEmpty: true, placeholder: "lepopup-pages-bar-item-placeholder", start: function(event, ui) { jQuery(ui.helper).addClass("lepopup-pages-bar-item-helper"); jQuery(".lepopup-context-menu").hide(); }, stop: function(event, ui) { jQuery(".lepopup-pages-bar-item-helper").removeClass("lepopup-pages-bar-item-helper"); lepopup_update_progress(); } }); jQuery(".lepopup-pages-bar-items, .lepopup-pages-bar-items-confirmation").disableSelection(); jQuery(".lepopup-element").disableSelection(); lepopup_build(); } function lepopup_forms_status_toggle(_object) { if (lepopup_sending) return false; lepopup_sending = true; var form_id = jQuery(_object).attr("data-id"); var form_status = jQuery(_object).attr("data-status"); var form_status_label = jQuery(_object).closest("tr").find("td.column-active").html(); var doing_label = jQuery(_object).attr("data-doing"); var do_label = jQuery(_object).html(); jQuery(_object).html(" "+doing_label); jQuery(_object).closest("tr").find(".row-actions").addClass("visible"); jQuery(_object).closest("tr").find("td.column-active").html(""); var post_data = {"action" : "lepopup-forms-status-toggle", "form-id" : form_id, "form-status" : form_status}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { jQuery(_object).html(do_label); try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(_object).html(data.form_action); jQuery(_object).attr("data-status", data.form_status); jQuery(_object).attr("data-doing", data.form_action_doing); if (data.form_status == "active") jQuery(_object).closest("tr").find(".lepopup-table-list-badge-status").html(""); else jQuery(_object).closest("tr").find(".lepopup-table-list-badge-status").html("Inactive"); lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { jQuery(_object).closest("tr").find("td.column-active").html(form_status_label); lepopup_global_message_show("danger", data.message); } else { jQuery(_object).closest("tr").find("td.column-active").html(form_status_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { jQuery(_object).closest("tr").find("td.column-active").html(form_status_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); jQuery(_object).html(do_label); jQuery(_object).closest("tr").find("td.column-active").html(form_status_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } function lepopup_forms_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
    "+lepopup_esc_html__("Please confirm that you want to delete the form.", "lepopup")+"
    "); this.show(); }, ok_label: 'Delete', ok_function: function(e){ _lepopup_forms_delete(_object); lepopup_dialog_close(); } }); return false; } function _lepopup_forms_delete(_object) { if (lepopup_sending) return false; lepopup_sending = true; var form_id = jQuery(_object).attr("data-id"); var doing_label = jQuery(_object).attr("data-doing"); var do_label = jQuery(_object).html(); jQuery(_object).html(" "+doing_label); jQuery(_object).closest("tr").find(".row-actions").addClass("visible"); var post_data = {"action" : "lepopup-forms-delete", "form-id" : form_id}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(_object).closest("tr").fadeOut(300, function(){ jQuery(_object).closest("tr").remove(); }); lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_object).html(do_label); jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); jQuery(_object).html(do_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } function lepopup_forms_duplicate(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
    "+lepopup_esc_html__("Please confirm that you want to duplicate the form.", "lepopup")+"
    "); this.show(); }, ok_label: 'Duplicate', ok_function: function(e){ _lepopup_forms_duplicate(_object); lepopup_dialog_close(); } }); return false; } function _lepopup_forms_duplicate(_object) { if (lepopup_sending) return false; lepopup_sending = true; var form_id = jQuery(_object).attr("data-id"); var doing_label = jQuery(_object).attr("data-doing"); var do_label = jQuery(_object).html(); jQuery(_object).html(" "+doing_label); jQuery(_object).closest("tr").find(".row-actions").addClass("visible"); var post_data = {"action" : "lepopup-forms-duplicate", "form-id" : form_id}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { lepopup_global_message_show("success", data.message); location.reload(); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_object).html(do_label); jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); jQuery(_object).html(do_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } function lepopup_columns_toggle(_object) { var columns = {}; var json_columns = ""; if (typeof _object === 'string' || _object instanceof String) { json_columns = lepopup_read_cookie("lepopup-"+_object+"-columns"); if (json_columns != null) { try { columns = JSON.parse(json_columns); if (typeof columns == "object" && !jQuery.isEmptyObject(columns)) { jQuery("ul.lepopup-"+_object+"-columns input").each(function(){ var id = jQuery(this).attr("data-id"); if (columns.hasOwnProperty(id)) { if (columns[id] == "on") { jQuery(this).prop("checked", true); jQuery(".lepopup-column-"+id).show(); } else { jQuery(this).prop("checked", false); jQuery(".lepopup-column-"+id).hide(); } } }); lepopup_write_cookie("lepopup-"+_object+"-columns", json_columns, 365); } } catch(error) { console.log(error); } } } else { var columns_set = jQuery(_object).closest("ul"); if (columns_set) { jQuery(columns_set).find("input").each(function(){ var id = jQuery(this).attr("data-id"); if (jQuery(this).is(":checked")) { columns[id] = "on"; jQuery(".lepopup-column-"+id).show(); } else { columns[id] = "off"; jQuery(".lepopup-column-"+id).hide(); } }); lepopup_write_cookie("lepopup-"+jQuery(columns_set).attr("data-id")+"-columns", JSON.stringify(columns), 365); } } return false; } var lepopup_more_active = null; function lepopup_more_using_open(_object) { jQuery("#lepopup-more-using .lepopup-admin-popup-content-form").html(""); var window_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var window_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 840); jQuery("#lepopup-more-using").height(window_height); jQuery("#lepopup-more-using").width(window_width); jQuery("#lepopup-more-using .lepopup-admin-popup-inner").height(window_height); jQuery("#lepopup-more-using .lepopup-admin-popup-content").height(window_height - 52); jQuery("#lepopup-more-using-overlay").fadeIn(300); jQuery("#lepopup-more-using").fadeIn(300); jQuery("#lepopup-more-using .lepopup-admin-popup-title h3 span").html(""); jQuery("#lepopup-more-using .lepopup-admin-popup-loading").show(); lepopup_more_active = jQuery(_object).attr("data-id"); var mode = jQuery(_object).attr("data-mode"); //if (mode != "campaign" && mode != "tab") mode = "form"; var post_data = {"action" : "lepopup-"+mode+"-using", "item-id" : lepopup_more_active}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery("#lepopup-more-using .lepopup-admin-popup-content-form").html(data.html); jQuery("#lepopup-more-using .lepopup-admin-popup-title h3 span").html(data.form_name); jQuery("#lepopup-more-using .lepopup-admin-popup-loading").hide(); jQuery("#lepopup-more-using .lepopup-admin-popup-content-form span[title]").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom" }); } else if (data.status == "ERROR") { lepopup_more_using_close(); lepopup_global_message_show("danger", data.message); } else { lepopup_more_using_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_more_using_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { lepopup_more_using_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }); return false; } function lepopup_more_using_close() { jQuery("#lepopup-more-using-overlay").fadeOut(300); jQuery("#lepopup-more-using").fadeOut(300); lepopup_more_active = null; setTimeout(function(){jQuery("#lepopup-more-using .lepopup-admin-popup-content-form").html("");}, 1000); return false; } var lepopup_campaign_properties_active = null; function lepopup_campaign_properties_open(_campaign_id) { jQuery("#lepopup-campaign-properties .lepopup-admin-popup-content-form").html(""); var window_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var window_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 840); jQuery("#lepopup-campaign-properties").height(window_height); jQuery("#lepopup-campaign-properties").width(window_width); jQuery("#lepopup-campaign-properties .lepopup-admin-popup-inner").height(window_height); jQuery("#lepopup-campaign-properties .lepopup-admin-popup-content").height(window_height - 104); jQuery("#lepopup-campaign-properties-overlay").fadeIn(300); jQuery("#lepopup-campaign-properties").fadeIn(300); jQuery("#lepopup-campaign-properties .lepopup-admin-popup-title h3 span").html(""); jQuery("#lepopup-campaign-properties .lepopup-admin-popup-loading").show(); lepopup_campaign_properties_active = _campaign_id; var post_data = {"action" : "lepopup-campaign-properties", "campaign-id" : lepopup_campaign_properties_active}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery("#lepopup-campaign-properties .lepopup-admin-popup-content-form").html(data.html); jQuery("#lepopup-campaign-properties .lepopup-admin-popup-title h3 span").html(data.campaign_name); jQuery("#lepopup-campaign-properties .lepopup-admin-popup-loading").hide(); jQuery(".lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); } else if (data.status == "ERROR") { lepopup_campaign_properties_close(); lepopup_global_message_show("danger", data.message); } else { lepopup_campaign_properties_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_campaign_properties_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { lepopup_campaign_properties_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }); return false; } function lepopup_campaign_properties_close() { jQuery("#lepopup-campaign-properties-overlay").fadeOut(300); jQuery("#lepopup-campaign-properties").fadeOut(300); lepopup_campaign_properties_active = null; setTimeout(function(){jQuery("#lepopup-campaign-properties .lepopup-admin-popup-content-form").html("");}, 1000); return false; } var lepopup_campaign_stats_active = null; function lepopup_campaign_stats_open(_campaign_id) { if (lepopup_chart) lepopup_chart.destroy(); var window_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var window_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 840); jQuery("#lepopup-campaign-stats").height(window_height); jQuery("#lepopup-campaign-stats").width(window_width); jQuery("#lepopup-campaign-stats .lepopup-admin-popup-inner").height(window_height); jQuery("#lepopup-campaign-stats .lepopup-admin-popup-content").height(window_height - 52); jQuery("#lepopup-campaign-stats-overlay").fadeIn(300); jQuery("#lepopup-campaign-stats").fadeIn(300); jQuery("#lepopup-campaign-stats .lepopup-admin-popup-title h3 span").html(""); jQuery("#lepopup-campaign-stats .lepopup-admin-popup-loading").show(); lepopup_campaign_stats_active = _campaign_id; var post_data = {"action" : "lepopup-campaign-stats", "campaign-id" : lepopup_campaign_stats_active}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { var labels = new Array(); var impressions = new Array(); var submits = new Array(); var ctrs = new Array(); for (var key in data.data) { if (data.data.hasOwnProperty(key)) { labels.push(data.data[key]["label"]); impressions.push(data.data[key]["impressions"]); submits.push(data.data[key]["submits"]); ctrs.push(data.data[key]["ctrs"]); } } lepopup_chart = new Chart("lepopup-stats", { type: "bar", data: { labels: labels, datasets: [{ label: "Impressions", lineTension : 0, fill : false, data: impressions, backgroundColor: 'rgb(255, 99, 132)', borderColor: 'rgb(255, 99, 132)', borderWidth: 2, yAxisID: "left-y-axis" }, { label: "Submits", lineTension : 0, fill : false, data: submits, backgroundColor: 'rgb(255, 159, 64)', borderColor: 'rgb(255, 159, 64)', borderWidth: 2, yAxisID: "left-y-axis" }, { label: "CTR", lineTension : 0, fill : false, data: ctrs, backgroundColor: 'rgb(75, 192, 192)', borderColor: 'rgb(75, 192, 192)', borderWidth: 2, yAxisID: "right-y-axis" } ] }, options: { responsive: true, tooltips: { mode: 'index', intersect: false, callbacks: { label: function(tooltipItems, data) { console.log(data); console.log(tooltipItems); var label = data.datasets[tooltipItems.datasetIndex]["label"]+": "+tooltipItems.yLabel.toString(); if (tooltipItems.datasetIndex == 2) label += "%"; return label; } } }, scales: { yAxes: [{ ticks: { beginAtZero:true }, position: 'left', id : "left-y-axis" }, { ticks: { beginAtZero:true }, gridLines: { display: false }, position: 'right', id : "right-y-axis" }] } } }); jQuery("#lepopup-campaign-stats .lepopup-admin-popup-title h3 span").html(data.campaign_name); jQuery("#lepopup-campaign-stats .lepopup-admin-popup-loading").hide(); } else if (data.status == "ERROR") { lepopup_campaign_stats_close(); lepopup_global_message_show("danger", data.message); } else { lepopup_campaign_stats_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_campaign_stats_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { lepopup_campaign_stats_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }); return false; } function lepopup_campaign_stats_close() { jQuery("#lepopup-campaign-stats-overlay").fadeOut(300); jQuery("#lepopup-campaign-stats").fadeOut(300); lepopup_campaign_stats_active = null; setTimeout(function(){if (lepopup_chart) lepopup_chart.destroy();}, 1000); return false; } function lepopup_stats_reset(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
    "+lepopup_esc_html__("Please confirm that you want to reset form statistics.", "lepopup")+"
    "); this.show(); }, ok_label: 'Reset', ok_function: function(e){ _lepopup_stats_reset(_object); lepopup_dialog_close(); } }); return false; } function _lepopup_stats_reset(_object) { if (lepopup_sending) return false; lepopup_sending = true; var form_id = jQuery(_object).attr("data-id"); var doing_label = jQuery(_object).attr("data-doing"); var do_label = jQuery(_object).html(); jQuery(_object).html(" "+doing_label); jQuery(_object).closest("tr").find(".row-actions").addClass("visible"); var post_data = {"action" : "lepopup-stats-reset", "form-id" : form_id}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_object).html(do_label); jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); jQuery(_object).html(do_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } var lepopup_record_active = null; function lepopup_record_details_open(_object) { var href; jQuery("#lepopup-record-details .lepopup-admin-popup-content-form").html(""); var window_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var window_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 1080); jQuery("#lepopup-record-details").height(window_height); jQuery("#lepopup-record-details").width(window_width); jQuery("#lepopup-record-details .lepopup-admin-popup-inner").height(window_height); jQuery("#lepopup-record-details .lepopup-admin-popup-content").height(window_height - 52); jQuery("#lepopup-record-details-overlay").fadeIn(300); jQuery("#lepopup-record-details").fadeIn(300); jQuery("#lepopup-record-details .lepopup-admin-popup-title h3 span").html(""); jQuery("#lepopup-record-details .lepopup-admin-popup-loading").show(); lepopup_record_active = jQuery(_object).attr("data-id"); var pdf_button = jQuery("#lepopup-record-details .lepopup-admin-popup-title span.lepopup-export-pdf"); if (pdf_button.length > 0) { href = jQuery(pdf_button).attr("data-url"); href = href.replace(/{ID}/g, lepopup_record_active); jQuery(pdf_button).find("a").attr("href", href); } var print_button = jQuery("#lepopup-record-details .lepopup-admin-popup-title span.lepopup-print"); if (print_button.length > 0) { href = jQuery(print_button).attr("data-url"); href = href.replace(/{ID}/g, lepopup_record_active); jQuery(print_button).find("a").attr("href", href); } var post_data = {"action" : "lepopup-record-details", "record-id" : lepopup_record_active}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery("#lepopup-record-details .lepopup-admin-popup-content-form").html(data.html); jQuery("#lepopup-record-details .lepopup-admin-popup-title h3 span").html(data.form_name); jQuery("#lepopup-record-details .lepopup-admin-popup-loading").hide(); } else if (data.status == "ERROR") { lepopup_record_details_close(); lepopup_global_message_show("danger", data.message); } else { lepopup_record_details_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_record_details_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { lepopup_record_details_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }); return false; } function lepopup_record_details_close() { jQuery("#lepopup-record-details-overlay").fadeOut(300); jQuery("#lepopup-record-details").fadeOut(300); lepopup_record_active = null; setTimeout(function(){jQuery("#lepopup-record-details .lepopup-admin-popup-content-form").html("");}, 1000); return false; } function lepopup_records_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
    "+lepopup_esc_html__("Please confirm that you want to delete the record.", "lepopup")+"
    "); this.show(); }, ok_label: 'Delete', ok_function: function(e){ _lepopup_records_delete(_object); lepopup_dialog_close(); } }); return false; } function _lepopup_records_delete(_object) { if (lepopup_sending) return false; lepopup_sending = true; var record_id = jQuery(_object).attr("data-id"); var doing_label = jQuery(_object).attr("data-doing"); var do_label = jQuery(_object).html(); jQuery(_object).html(" "+doing_label); jQuery(_object).closest("tr").find(".row-actions").addClass("visible"); var post_data = {"action" : "lepopup-records-delete", "record-id" : record_id}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(_object).closest("tr").fadeOut(300, function(){ jQuery(_object).closest("tr").remove(); }); lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_object).html(do_label); jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); jQuery(_object).html(do_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } function lepopup_transaction_details_open(_object) { jQuery("#lepopup-record-details .lepopup-admin-popup-content-form").html(""); var window_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var window_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 1080); jQuery("#lepopup-record-details").height(window_height); jQuery("#lepopup-record-details").width(window_width); jQuery("#lepopup-record-details .lepopup-admin-popup-inner").height(window_height); jQuery("#lepopup-record-details .lepopup-admin-popup-content").height(window_height - 52); jQuery("#lepopup-record-details-overlay").fadeIn(300); jQuery("#lepopup-record-details").fadeIn(300); jQuery("#lepopup-record-details .lepopup-admin-popup-title h3 span").html(""); jQuery("#lepopup-record-details .lepopup-admin-popup-loading").show(); lepopup_record_active = jQuery(_object).attr("data-id"); var href; var pdf_button = jQuery("#lepopup-record-details .lepopup-admin-popup-title span.lepopup-export-pdf"); if (pdf_button.length > 0) { href = jQuery(pdf_button).attr("data-url"); href = href.replace(/{ID}/g, lepopup_record_active); jQuery(pdf_button).find("a").attr("href", href); } var print_button = jQuery("#lepopup-record-details .lepopup-admin-popup-title span.lepopup-print"); if (print_button.length > 0) { href = jQuery(print_button).attr("data-url"); href = href.replace(/{ID}/g, lepopup_record_active); jQuery(print_button).find("a").attr("href", href); } var post_data = {"action" : "lepopup-transaction-details", "transaction-id" : lepopup_record_active}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery("#lepopup-record-details .lepopup-admin-popup-content-form").html(data.html); jQuery("#lepopup-record-details .lepopup-admin-popup-loading").hide(); } else if (data.status == "ERROR") { lepopup_record_details_close(); lepopup_global_message_show("danger", data.message); } else { lepopup_record_details_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_record_details_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { lepopup_record_details_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }); return false; } function lepopup_transaction_details_close() { jQuery("#lepopup-record-details-overlay").fadeOut(300); jQuery("#lepopup-record-details").fadeOut(300); lepopup_record_active = null; setTimeout(function(){jQuery("#lepopup-record-details .lepopup-admin-popup-content-form").html("");}, 1000); } function lepopup_transactions_delete(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
    "+lepopup_esc_html__("Please confirm that you want to delete the transaction.", "lepopup")+"
    "); this.show(); }, ok_label: 'Delete', ok_function: function(e){ _lepopup_transactions_delete(_object); lepopup_dialog_close(); } }); return false; } function _lepopup_transactions_delete(_object) { if (lepopup_sending) return false; lepopup_sending = true; var record_id = jQuery(_object).attr("data-id"); var doing_label = jQuery(_object).attr("data-doing"); var do_label = jQuery(_object).html(); jQuery(_object).html(" "+doing_label); jQuery(_object).closest("tr").find(".row-actions").addClass("visible"); var post_data = {"action" : "lepopup-transactions-delete", "transaction-id" : record_id}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(_object).closest("tr").fadeOut(300, function(){ jQuery(_object).closest("tr").remove(); }); lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_object).html(do_label); jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).closest("tr").find(".row-actions").removeClass("visible"); jQuery(_object).html(do_label); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } function lepopup_field_analytics_load(_object) { if (lepopup_sending) return false; lepopup_sending = true; jQuery(_object).find("i").attr("class", "fas fa-spinner fa-spin"); jQuery(_object).addClass("lepopup-stats-button-disabled"); var post_data = {"action" : "lepopup-field-analytics-load", "form-id" : jQuery("#lepopup-stats-form").val(), "start-date" : jQuery("#lepopup-stats-date-start").val(), "end-date" : jQuery("#lepopup-stats-date-end").val(), "period" : (jQuery("#lepopup-stats-period").is(":checked") ? "on" : "off")}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { lepopup_field_analytics_build_charts(data.data); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_object).find("i").attr("class", "fas fa-check"); jQuery(_object).removeClass("lepopup-stats-button-disabled"); lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).find("i").attr("class", "fas fa-check"); jQuery(_object).removeClass("lepopup-stats-button-disabled"); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } function lepopup_field_analytics_ready() { var airdatepicker = jQuery("#lepopup-stats-date-start").airdatepicker().data('airdatepicker'); airdatepicker.destroy(); jQuery("#lepopup-stats-date-start").airdatepicker({ autoClose : true, timepicker : false, dateFormat : 'yyyy-mm-dd', onShow : function(inst, animationCompleted) { var max_date_string = jQuery("#lepopup-stats-date-end").val() ? jQuery("#lepopup-stats-date-end").val() : "2030-12-31"; inst.update('maxDate', new Date(max_date_string)); } }); airdatepicker = jQuery("#lepopup-stats-date-end").airdatepicker().data('airdatepicker'); airdatepicker.destroy(); jQuery("#lepopup-stats-date-end").airdatepicker({ autoClose : true, timepicker : false, dateFormat : 'yyyy-mm-dd', onShow : function(inst, animationCompleted) { var min_date_string = jQuery("#lepopup-stats-date-start").val() ? jQuery("#lepopup-stats-date-start").val() : "2018-01-01"; inst.update('minDate', new Date(min_date_string)); } }); jQuery("#lepopup-stats-period").on("change", function(e){ if (jQuery("#lepopup-stats-period").is(":checked")) { jQuery(".lepopup-stats-input-container").fadeIn(300); } else { jQuery(".lepopup-stats-input-container").fadeOut(300); } }); var data = JSON.parse(jQuery("#lepopup-field-analytics-initial-data").val()); if (jQuery("#lepopup-stats-form").val() != 0) lepopup_field_analytics_build_charts(data); } function lepopup_field_analytics_build_charts(_charts) { var colors = new Array( { backgroundColor: 'rgb(255, 99, 132, 0.7)', borderColor: 'rgb(255, 99, 132)', }, { backgroundColor: 'rgba(75, 192, 192, 0.7)', borderColor: 'rgb(75, 192, 192)', }, { backgroundColor: 'rgba(255, 205, 86, 0.7)', borderColor: 'rgb(255, 205, 86)', }, { backgroundColor: 'rgba(54, 162, 235, 0.7)', borderColor: 'rgb(54, 162, 235)', }, { backgroundColor: 'rgba(153, 102, 255, 0.7)', borderColor: 'rgb(153, 102, 255)', }, { backgroundColor: 'rgba(201, 203, 207, 0.7)', borderColor: 'rgb(201, 203, 207)', } ); if (_charts.length == 0) { jQuery(".lepopup-field-analytics-container").html("
    No data found.
    "); } else { var column1_height = 0, column2_height = 0, height = 0, chart_html = ""; var labels = new Array(); var values = new Array(); jQuery(".lepopup-field-analytics-container").html(""); if (_charts.length > 1) jQuery(".lepopup-field-analytics-container").html("
    "); else jQuery(".lepopup-field-analytics-container").html(""); for (var i=0; i<_charts.length; i++) { labels = new Array(); values = new Array(); for (var j=0; j<_charts[i]['chart'].length; j++) { if (_charts[i]['chart'][j]['label'].length > 24) labels.push(_charts[i]['chart'][j]['label'].substring(0, 20)+"..."); else labels.push(_charts[i]['chart'][j]['label']); values.push(parseInt(_charts[i]['chart'][j]['value'], 10)); } height = 128+24*labels.length; chart_html = "
    "; if (_charts.length > 1) { if (column1_height > column2_height) { jQuery("#lepopup-field-analytics-column2").append(chart_html); column2_height += height + 32; } else { jQuery("#lepopup-field-analytics-column1").append(chart_html); column1_height += height + 32; } } else jQuery(".lepopup-field-analytics-container").append(chart_html); jQuery("#lepopup-field-"+_charts[i]["form-id"]+"-"+_charts[i]["id"]).height(height); lepopup_chart = new Chart("lepopup-field-"+_charts[i]["form-id"]+"-"+_charts[i]["id"], { type: "horizontalBar", data: { labels: labels, datasets: [{ label: _charts[i]["title"], data: values, backgroundColor: colors[i%colors.length]["backgroundColor"], borderColor: colors[i%colors.length]["borderColor"], borderWidth: 1 }] }, options: { responsive: true, maintainAspectRatio: false, tooltips: { mode: 'index', intersect: false, }, legend: { display: false }, title: { display: true, text: _charts[i]["title"] }, scales: { yAxes: [{ maxBarThickness: 32 }], xAxes: [{ ticks: { beginAtZero:true } }], } } }); } } } function lepopup_stats_load(_object) { if (lepopup_sending) return false; lepopup_sending = true; jQuery(_object).find("i").attr("class", "fas fa-spinner fa-spin"); jQuery(_object).addClass("lepopup-stats-button-disabled"); var post_data = {"action" : "lepopup-stats-load", "form-id" : jQuery("#lepopup-stats-form").val(), "start-date" : jQuery("#lepopup-stats-date-start").val(), "end-date" : jQuery("#lepopup-stats-date-end").val()}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { var labels = new Array(); var impressions = new Array(); var submits = new Array(); var confirmed = new Array(); var payments = new Array(); for (var key in data.data) { if (data.data.hasOwnProperty(key)) { labels.push(data.data[key]["label"]); impressions.push(data.data[key]["impressions"]); confirmed.push(data.data[key]["confirmed"]); submits.push(data.data[key]["submits"]); payments.push(data.data[key]["payments"]); } } lepopup_stats_build_chart(labels, impressions, submits, confirmed, payments); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_object).find("i").attr("class", "fas fa-check"); jQuery(_object).removeClass("lepopup-stats-button-disabled"); lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_object).find("i").attr("class", "fas fa-check"); jQuery(_object).removeClass("lepopup-stats-button-disabled"); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } function lepopup_stats_ready() { var airdatepicker = jQuery("#lepopup-stats-date-start").airdatepicker().data('airdatepicker'); airdatepicker.destroy(); jQuery("#lepopup-stats-date-start").airdatepicker({ autoClose : true, timepicker : false, dateFormat : 'yyyy-mm-dd', onShow : function(inst, animationCompleted) { var max_date_string = jQuery("#lepopup-stats-date-end").val() ? jQuery("#lepopup-stats-date-end").val() : "2030-12-31"; inst.update('maxDate', new Date(max_date_string)); } }); airdatepicker = jQuery("#lepopup-stats-date-end").airdatepicker().data('airdatepicker'); airdatepicker.destroy(); jQuery("#lepopup-stats-date-end").airdatepicker({ autoClose : true, timepicker : false, dateFormat : 'yyyy-mm-dd', onShow : function(inst, animationCompleted) { var min_date_string = jQuery("#lepopup-stats-date-start").val() ? jQuery("#lepopup-stats-date-start").val() : "2018-01-01"; inst.update('minDate', new Date(min_date_string)); } }); var labels = new Array(); var impressions = new Array(); var submits = new Array(); var confirmed = new Array(); var payments = new Array(); var data = JSON.parse(jQuery("#lepopup-stats-initial-data").val()); for (var key in data) { if (data.hasOwnProperty(key)) { labels.push(data[key]["label"]); impressions.push(data[key]["impressions"]); submits.push(data[key]["submits"]); confirmed.push(data[key]["confirmed"]); payments.push(data[key]["payments"]); } } lepopup_stats_build_chart(labels, impressions, submits, confirmed, payments); } var lepopup_chart = null; function lepopup_stats_build_chart(_labels, _impressions, _submits, _confirmed, _payments) { if (lepopup_chart) lepopup_chart.destroy(); lepopup_chart = new Chart("lepopup-stats", { type: "line", data: { labels: _labels, datasets: [{ label: "Impressions", lineTension : 0, fill : false, data: _impressions, backgroundColor: 'rgb(255, 99, 132)', borderColor: 'rgb(255, 99, 132)', borderWidth: 2 }, { label: "Submits", lineTension : 0, fill : false, data: _submits, backgroundColor: 'rgb(255, 159, 64)', borderColor: 'rgb(255, 159, 64)', borderWidth: 2 }, { label: "Confirmed", lineTension : 0, fill : false, data: _confirmed, backgroundColor: 'rgb(75, 192, 192)', borderColor: 'rgb(75, 192, 192)', borderWidth: 2 }, { label: "Payments", lineTension : 0, fill : false, data: _payments, backgroundColor: 'rgb(204, 125, 188)', borderColor: 'rgb(204, 125, 188)', borderWidth: 2 } ] }, options: { responsive: true, tooltips: { mode: 'index', intersect: false, }, /* hover: { mode: 'nearest', intersect: true },*/ scales: { yAxes: [{ ticks: { beginAtZero:true } }] } } }); } function lepopup_record_field_empty(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
    "+lepopup_esc_html__('Please confirm that you want to empty this field.')+"
    "); this.show(); }, ok_label: lepopup_esc_html__('Empty Field'), ok_function: function(e) { _lepopup_record_field_empty(jQuery("#lepopup-dialog .lepopup-dialog-button-ok"), _object); } }); } function _lepopup_record_field_empty(_button, _object) { if (lepopup_sending) return false; lepopup_sending = true; var field_id = jQuery(_object).closest(".lepopup-record-details-table-value").attr("data-id"); var record_id = jQuery(_object).closest(".lepopup-record-details").attr("data-id"); var icon = jQuery(_button).find("i").attr("class"); jQuery(_button).find("i").attr("class", "fas fa-spinner fa-spin"); var post_data = {"action" : "lepopup-record-field-empty", "record-id" : record_id, "field-id" : field_id}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(_object).closest(".lepopup-record-details-table-value").find(".lepopup-record-field-value").text("-"); lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { console.log(error); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_button).find("i").attr("class", icon); lepopup_sending = false; lepopup_dialog_close(); }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_button).find("i").attr("class", icon); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; lepopup_dialog_close(); } }); return false; } function lepopup_record_field_remove(_object) { lepopup_dialog_open({ echo_html: function() { this.html("
    "+lepopup_esc_html__('Please confirm that you want to remove this field.')+"
    "); this.show(); }, ok_label: lepopup_esc_html__('Remove Field'), ok_function: function(e) { _lepopup_record_field_remove(jQuery("#lepopup-dialog .lepopup-dialog-button-ok"), _object); } }); } function _lepopup_record_field_remove(_button, _object) { if (lepopup_sending) return false; lepopup_sending = true; var field_id = jQuery(_object).closest(".lepopup-record-details-table-value").attr("data-id"); var record_id = jQuery(_object).closest(".lepopup-record-details").attr("data-id"); var icon = jQuery(_button).find("i").attr("class"); jQuery(_button).find("i").attr("class", "fas fa-spinner fa-spin"); var post_data = {"action" : "lepopup-record-field-remove", "record-id" : record_id, "field-id" : field_id}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(_object).closest("tr").fadeOut(300, function() { jQuery(_object).closest("tr").remove(); }); lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { console.log(error); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_button).find("i").attr("class", icon); lepopup_sending = false; lepopup_dialog_close(); }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_button).find("i").attr("class", icon); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; lepopup_dialog_close(); } }); return false; } function lepopup_record_field_load_editor(_button) { if (lepopup_sending) return false; lepopup_sending = true; var field_id = jQuery(_button).closest(".lepopup-record-details-table-value").attr("data-id"); var record_id = jQuery(_button).closest(".lepopup-record-details").attr("data-id"); var icon = jQuery(_button).find("i").attr("class"); jQuery(_button).find("i").attr("class", "fas fa-spinner fa-spin"); var post_data = {"action" : "lepopup-record-field-load-editor", "record-id" : record_id, "field-id" : field_id}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(_button).closest(".lepopup-record-details-table-value").find(".lepopup-record-field-value").fadeOut(300, function(){ jQuery(_button).closest(".lepopup-record-details-table-value").find(".lepopup-record-field-editor").html(data.html); jQuery(_button).closest(".lepopup-record-details-table-value").find(".lepopup-record-field-editor").fadeIn(300); }); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { console.log(error); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_button).find("i").attr("class", icon); lepopup_sending = false; lepopup_dialog_close(); }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_button).find("i").attr("class", icon); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; lepopup_dialog_close(); } }); return false; } function lepopup_record_field_cancel_editor(_button) { jQuery(_button).closest(".lepopup-record-details-table-value").find(".lepopup-record-field-editor").fadeOut(300, function(){ jQuery(_button).closest(".lepopup-record-details-table-value").find(".lepopup-record-field-value").fadeIn(300); jQuery(_button).closest(".lepopup-record-details-table-value").find(".lepopup-record-field-editor").html(""); }); } function lepopup_record_field_save(_button) { if (lepopup_sending) return false; lepopup_sending = true; var field_id = jQuery(_button).closest(".lepopup-record-details-table-value").attr("data-id"); var record_id = jQuery(_button).closest(".lepopup-record-details").attr("data-id"); var icon = jQuery(_button).find("i").attr("class"); jQuery(_button).find("i").attr("class", "fas fa-spinner fa-spin"); var post_data = {"action" : "lepopup-record-field-save", "record-id" : record_id, "field-id" : field_id, "value" : lepopup_encode64(jQuery(_button).closest(".lepopup-record-field-editor").find("textarea, input, select").serialize())}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery(_button).closest(".lepopup-record-details-table-value").find(".lepopup-record-field-editor").fadeOut(300, function(){ jQuery(_button).closest(".lepopup-record-details-table-value").find(".lepopup-record-field-value").html(data.html); jQuery(_button).closest(".lepopup-record-details-table-value").find(".lepopup-record-field-value").fadeIn(300); jQuery(_button).closest(".lepopup-record-details-table-value").find(".lepopup-record-field-editor").html(""); }); lepopup_global_message_show("success", data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { console.log(error); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } jQuery(_button).find("i").attr("class", icon); lepopup_sending = false; lepopup_dialog_close(); }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(_button).find("i").attr("class", icon); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; lepopup_dialog_close(); } }); return false; } /* Targeting - begin */ var lepopup_target_properties_active = null; var lepopup_target_loading = false; var lepopup_targets_deleted = []; var lepopup_targets_save_requested = false; function lepopup_tragets_ready() { jQuery(window).resize(function() { lepopup_targets_resize(); }); jQuery(".lepopup-targets-list").sortable({ connectWith: ".lepopup-targets-list", items: ".lepopup-targets-list-item", forcePlaceholderSize: true, dropOnEmpty: true, placeholder: "lepopup-targets-list-item-placeholder", start: function(event, ui) { jQuery(".lepopup-targets-list-item-animate").removeClass("lepopup-targets-list-item-animate"); }, over: function(event, ui) { lepopup_targets_switch_noitems(); }, out: function(event, ui) { lepopup_targets_switch_noitems(); }, stop: function(event, ui) { lepopup_targets_save_list(); } }); jQuery(".lepopup-targets-list-item").disableSelection(); } function lepopup_targets_switch_noitems() { if (jQuery("#lepopup-targets-list-passive .lepopup-targets-list-item-placeholder").length > 0 || jQuery("#lepopup-targets-list-passive .lepopup-targets-list-item:not(.ui-sortable-helper)").length > 0) { jQuery("#lepopup-targets-list-passive .lepopup-targets-noitems-message").hide(); } else { jQuery("#lepopup-targets-list-passive .lepopup-targets-noitems-message").show(); } if (jQuery("#lepopup-targets-list-active .lepopup-targets-list-item-placeholder").length > 0 || jQuery("#lepopup-targets-list-active .lepopup-targets-list-item:not(.ui-sortable-helper)").length > 0) { jQuery("#lepopup-targets-list-active .lepopup-targets-noitems-message").hide(); } else { jQuery("#lepopup-targets-list-active .lepopup-targets-noitems-message").show(); } } function lepopup_targets_resize() { if (lepopup_target_properties_active) { var popup_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var popup_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 960); jQuery("#lepopup-target-properties").height(popup_height); jQuery("#lepopup-target-properties").width(popup_width); jQuery("#lepopup-target-properties .lepopup-admin-popup-inner").height(popup_height); jQuery("#lepopup-target-properties .lepopup-admin-popup-content").height(popup_height - 104); } } function lepopup_target_delete(_event, _target_id) { lepopup_dialog_open({ echo_html: function() { this.html("
    "+lepopup_esc_html__("Please confirm that you want to delete the target.", "lepopup")+"
    "); this.show(); }, ok_label: 'Delete', ok_function: function(e){ jQuery("#lepopup-targets-list-item-"+_target_id).fadeOut(300, function() { jQuery("#lepopup-targets-list-item-"+_target_id).remove(); lepopup_targets_switch_noitems(); lepopup_targets_deleted.push(_target_id); lepopup_targets_save_list(); }); lepopup_dialog_close(); } }); return false; } function lepopup_targets_save_list() { if (lepopup_target_loading) { lepopup_targets_save_requested = true; return false; } lepopup_target_loading = true; lepopup_global_message_show("info", " Saving targets..."); clearTimeout(lepopup_global_message_timer); var post_data = {"action" : "lepopup-targets-save-list", "lepopup-event": jQuery("#lepopup-targets-event").val()}; var active = []; jQuery("#lepopup-targets-list-active .lepopup-targets-list-item").each(function() { var id = jQuery(this).attr("data-id"); active.push(parseInt(id, 10)); }); post_data["lepopup-targets-active"] = active.join(); post_data["lepopup-targets-deleted"] = lepopup_targets_deleted.join(); jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { lepopup_target_loading = false; try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); var status = data.status; if (lepopup_targets_save_requested) { lepopup_targets_save_requested = false; lepopup_targets_save_list(); return; } if (status == "OK") { lepopup_global_message_show("success", data.message); } else if (status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.", "lepopup")); } } catch(error) { if (lepopup_targets_save_requested) { lepopup_targets_save_requested = false; lepopup_targets_save_list(); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.", "lepopup")); } } }, error : function(XMLHttpRequest, textStatus, errorThrown) { lepopup_target_loading = false; if (lepopup_targets_save_requested) { lepopup_targets_save_requested = false; lepopup_targets_save_list(); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.", "lepopup")); } } }); return false; } function lepopup_target_properties_open(_event, _target_id) { lepopup_target_loading = true; jQuery("#lepopup-target-properties .lepopup-admin-popup-content-form").html(""); var window_height = 2*parseInt((jQuery(window).height() - 100)/2, 10); var window_width = Math.min(Math.max(2*parseInt((jQuery(window).width() - 300)/2, 10), 640), 960); jQuery("#lepopup-target-properties").height(window_height); jQuery("#lepopup-target-properties").width(window_width); jQuery("#lepopup-target-properties .lepopup-admin-popup-inner").height(window_height); jQuery("#lepopup-target-properties .lepopup-admin-popup-content").height(window_height - 104); jQuery("#lepopup-target-properties-overlay").fadeIn(300); jQuery("#lepopup-target-properties").fadeIn(300); jQuery("#lepopup-target-properties .lepopup-admin-popup-title h3 span").html(""); jQuery("#lepopup-target-properties .lepopup-admin-popup-loading").show(); lepopup_target_properties_active = _target_id; var post_data = {"action" : "lepopup-target-properties", "target-event" : _event, "target-id" : lepopup_target_properties_active}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { lepopup_target_loading = false; try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery("#lepopup-target-properties .lepopup-admin-popup-content-form").html(data.html); jQuery("#lepopup-target-properties .lepopup-admin-popup-title h3 span").html(data.target_name); jQuery("#lepopup-target-properties .lepopup-admin-popup-loading").hide(); jQuery("#lepopup-target-content-posts").scroll(function(e) { var content_height = jQuery(this).prop('scrollHeight'); var position = jQuery(this).scrollTop(); var height = jQuery(this).height(); if (content_height - height - position < 10) { lepopup_target_posts_load(false); } }); jQuery(".lepopup-target-period-date").airdatepicker({ inline_popup : true, autoClose : false, timepicker : true, dateFormat : "yyyy-mm-dd", timeFormat : "hh:ii", minDate : new Date() }); jQuery(".lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); } else if (data.status == "ERROR") { lepopup_target_properties_close(); lepopup_global_message_show("danger", data.message); } else { lepopup_target_properties_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_target_properties_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { lepopup_target_loading = false; lepopup_target_properties_close(); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }); return false; } function lepopup_target_properties_close() { jQuery("#lepopup-target-properties-overlay").fadeOut(300); jQuery("#lepopup-target-properties").fadeOut(300); lepopup_target_properties_active = null; setTimeout(function(){jQuery("#lepopup-target-properties .lepopup-admin-popup-content-form").html("");}, 1000); return false; } function lepopup_target_post_type_selected(_object) { if (lepopup_target_loading) return false; var post_type_id = jQuery(_object).val(); if (post_type_id == 'sitewide' || post_type_id == 'homepage') { jQuery("#lepopup-target-content-taxonomies").slideUp(300, function(){ jQuery("#lepopup-target-content-loading").hide(); jQuery("#lepopup-target-content-taxonomies").html(""); }); } else { jQuery("#lepopup-target-content-taxonomies").slideUp(300, function(){ jQuery("#lepopup-target-content-loading").fadeIn(300); }); lepopup_target_loading = true; jQuery("#lepopup-target-post-types").addClass("lepopup-target-disabled"); var post_data = {"action" : "lepopup-target-taxonomies", "lepopup-post-type" : post_type_id, "lepopup-event" : jQuery("#lepopup-targets-event").val()}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { jQuery("#lepopup-target-content-loading").hide(); jQuery("#lepopup-target-post-types").removeClass("lepopup-targets-disabled"); lepopup_target_loading = false; try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); var status = data.status; if (status == "OK") { jQuery("#lepopup-target-content-taxonomies").html(data.html); jQuery("#lepopup-target-content-taxonomies").fadeIn(300); jQuery("#lepopup-target-content-posts").scroll(function(e) { var content_height = jQuery(this).prop('scrollHeight'); var position = jQuery(this).scrollTop(); var height = jQuery(this).height(); if (content_height - height - position < 10) { lepopup_target_posts_load(false); } }); jQuery("#lepopup-target-content-taxonomies .lepopup-properties-tooltip .lepopup-tooltip-anchor").tooltipster({ contentAsHTML: true, maxWidth: 360, theme: "tooltipster-dark", side: "bottom", content: "Default", functionFormat: function(instance, helper, content){ return jQuery(helper.origin).parent().find('.lepopup-tooltip-content').html(); } }); } else if (status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { lepopup_target_loading = false; jQuery("#lepopup-target-content-loading").hide(); jQuery("#lepopup-target-post-types").removeClass("lepopup-targets-disabled"); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }); } return false; } function lepopup_target_taxonomy_selected(_object, _taxonomy) { if (lepopup_target_loading) return false; var load_posts = true; if (!jQuery(_object).is(":checked") && jQuery(_object).val() == "all") { load_posts = false; } if (load_posts) { lepopup_target_posts_load(true); } return false; } function lepopup_target_posts_load(_new) { if (lepopup_target_loading) return false; var offset = jQuery("#lepopup-target-next-offset").val(); if (!_new && offset == -1) return false; if (_new) { jQuery("#lepopup-target-content-posts").fadeOut(300, function(){ jQuery("#lepopup-target-content-posts").html('
    '); jQuery("#lepopup-target-content-posts").fadeIn(300); }); } else { jQuery("#lepopup-target-content-posts").append('
    '); } lepopup_target_loading = true; jQuery(".lepopup-target-taxonomies").addClass("lepopup-target-disabled-all"); jQuery("#lepopup-target-post-types").addClass("lepopup-target-disabled-all"); if (_new) jQuery("#lepopup-target-next-offset").val(0); var post_data = {"action" : "lepopup-target-posts", "lepopup-post-type" : jQuery("[name='lepopup-post-type']:checked").val(), 'lepopup-offset' : jQuery("#lepopup-target-next-offset").val(), "lepopup-posts-all" : (jQuery("#lepopup-target-post-all").is(":checked") ? "on" : "off")}; jQuery(".lepopup-target-taxonomies").find("input").each(function(){ var name = jQuery(this).attr("name"); if (name.indexOf("[]") > 0 && jQuery(this).is(":checked")) { name = name.replace("[]", ""); if (post_data.hasOwnProperty(name)) post_data[name].push(jQuery(this).val()); else post_data[name] = new Array(jQuery(this).val()); } }); if (jQuery("#lepopup-id").length) post_data['lepopup-id'] = jQuery("#lepopup-id").val(); jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { jQuery("#lepopup-target-posts-loading").remove(); jQuery(".lepopup-target-disabled-all").removeClass("lepopup-target-disabled-all"); if (_new) jQuery("#lepopup-target-content-posts").html(""); lepopup_target_loading = false; var data; try { var data = jQuery.parseJSON(return_data); var status = data.status; if (status == "OK") { jQuery("#lepopup-target-next-offset").val(data.next_offset); jQuery("#lepopup-target-content-posts").append(data.html); jQuery("#lepopup-target-content-posts").fadeIn(300); } else if (status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { lepopup_target_loading = false; jQuery("#lepopup-target-posts-loading").remove(); jQuery(".lepopup-target-disabled-all").removeClass(".lepopup-target-disabled-all"); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }); return false; } function lepopup_target_save(_button) { if (lepopup_sending) return false; lepopup_sending = true; var button_object = _button; jQuery(button_object).find("i").attr("class", "fas fa-spinner fa-spin"); jQuery(button_object).addClass("lepopup-button-disabled"); jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : jQuery(".lepopup-target-properties-form").serialize(), success : function(return_data) { jQuery(button_object).find("i").attr("class", "fas fa-check"); jQuery(button_object).removeClass("lepopup-button-disabled"); var data; try { if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { if (data.action == 'insert') { jQuery("#lepopup-targets-list-active").append(data.html); jQuery("#lepopup-targets-list-active").find(".lepopup-targets-noitems-message").hide(); } else { jQuery("#lepopup-targets-list-item-"+data.id).replaceWith(data.html); } jQuery("#lepopup-targets-list-item-"+data.id).addClass("lepopup-targets-list-item-animate"); lepopup_target_properties_close(); lepopup_global_message_show('success', data.message); } else if (data.status == "ERROR") { lepopup_global_message_show("danger", data.message); } else { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } lepopup_sending = false; }, error : function(XMLHttpRequest, textStatus, errorThrown) { jQuery(button_object).find("i").attr("class", "fas fa-check"); jQuery(button_object).removeClass("lepopup-button-disabled"); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); lepopup_sending = false; } }); return false; } var lepopup_target_onscroll_offset = ""; function lepopup_target_onscroll_units_changed() { var lepopup_tmp; if (jQuery("#lepopup-onscroll-unit-percents").is(":checked")) { lepopup_tmp = jQuery("#lepopup-onscroll-offset").val(); if (lepopup_target_onscroll_offset == "") lepopup_target_onscroll_offset = lepopup_tmp; if (lepopup_target_onscroll_offset > 100) lepopup_target_onscroll_offset = 100; jQuery("#lepopup-onscroll-offset").val(lepopup_target_onscroll_offset); lepopup_target_onscroll_offset = lepopup_tmp; } else { lepopup_tmp = jQuery("#lepopup-onscroll-offset").val(); if (lepopup_target_onscroll_offset != "") jQuery("#lepopup-onscroll-offset").val(lepopup_target_onscroll_offset); lepopup_target_onscroll_offset = lepopup_tmp; } } /* Targeting - end */ function lepopup_input_sort() { var input_fields = new Array(); var fields = new Array(); for (var i=0; i 0) input_fields = input_fields.concat(fields); } } return input_fields; } function _lepopup_input_sort(_parent, _page_id, _page_name) { var input_fields = new Array(); var fields = new Array(); var idxs = new Array(); var seqs = new Array(); for (var i=0; i seqs[j+1]) { sorted = seqs[j]; seqs[j] = seqs[j+1]; seqs[j+1] = sorted; sorted = idxs[j]; idxs[j] = idxs[j+1]; idxs[j+1] = sorted; } } if (sorted == -1) break; } for (var k=0; k "+jQuery("#lepopup-migrate-button").attr("data-loading")); var post_data = {"action" : "lepopup-migrate"}; jQuery.ajax({ type : "POST", url : lepopup_ajax_handler, data : post_data, success : function(return_data) { lepopup_sending = false; try { var data; if (typeof return_data == 'object') data = return_data; else data = jQuery.parseJSON(return_data); if (data.status == "OK") { jQuery("#lepopup-migrate-status-settings").html("100%"); jQuery("#lepopup-migrate-button").addClass("lepopup-intro-button-finished"); jQuery("#lepopup-migrate-button").html(jQuery("#lepopup-migrate-button").attr("data-done")); lepopup_global_message_show("success", lepopup_esc_html__("Migration completed.")); } else if (data.status == "CONTINUE") { if (data["data"]["settings"] == "done") jQuery("#lepopup-migrate-status-settings").html("100%"); else jQuery("#lepopup-migrate-status-settings").html("0%"); if (data["data"]["popups"]["total"] > 0) jQuery("#lepopup-migrate-status-popups").html(parseInt(100*parseInt(data["data"]["popups"]["done"], 10)/parseInt(data["data"]["popups"]["total"], 10), 10)+"%"); else jQuery("#lepopup-migrate-status-popups").html("0%"); if (data["data"]["campaigns"]["total"] > 0) jQuery("#lepopup-migrate-status-campaigns").html(parseInt(100*parseInt(data["data"]["campaigns"]["done"], 10)/parseInt(data["data"]["campaigns"]["total"], 10), 10)+"%"); else jQuery("#lepopup-migrate-status-campaigns").html("0%"); if (data["data"]["targets"]["total"] > 0) jQuery("#lepopup-migrate-status-targets").html(parseInt(100*parseInt(data["data"]["targets"]["done"], 10)/parseInt(data["data"]["targets"]["total"], 10), 10)+"%"); else jQuery("#lepopup-migrate-status-targets").html("0%"); if (data["data"]["records"]["total"] > 0) jQuery("#lepopup-migrate-status-records").html(parseInt(100*parseInt(data["data"]["records"]["done"], 10)/parseInt(data["data"]["records"]["total"], 10), 10)+"%"); else jQuery("#lepopup-migrate-status-records").html("0%"); if (data["data"]["tabs"]["total"] > 0) jQuery("#lepopup-migrate-status-tabs").html(parseInt(100*parseInt(data["data"]["tabs"]["done"], 10)/parseInt(data["data"]["tabs"]["total"], 10), 10)+"%"); else jQuery("#lepopup-migrate-status-tabs").html("0%"); if (data["data"]["downloads"]["total"] > 0) jQuery("#lepopup-migrate-status-downloads").html(parseInt(100*parseInt(data["data"]["downloads"]["done"], 10)/parseInt(data["data"]["downloads"]["total"], 10), 10)+"%"); else jQuery("#lepopup-migrate-status-downloads").html("0%"); lepopup_migrate(); } else if (data.status == "ERROR") { jQuery("#lepopup-migrate-button").removeClass("lepopup-intro-button-disabled"); jQuery("#lepopup-migrate-button").html(jQuery("#lepopup-migrate-button").attr("data-label")); lepopup_global_message_show("danger", data.message); } else { jQuery("#lepopup-migrate-button").removeClass("lepopup-intro-button-disabled"); jQuery("#lepopup-migrate-button").html(jQuery("#lepopup-migrate-button").attr("data-label")); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } } catch(error) { jQuery("#lepopup-migrate-button").removeClass("lepopup-intro-button-disabled"); jQuery("#lepopup-migrate-button").html(jQuery("#lepopup-migrate-button").attr("data-label")); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { lepopup_sending = false; jQuery("#lepopup-migrate-button").removeClass("lepopup-intro-button-disabled"); jQuery("#lepopup-migrate-button").html(jQuery("#lepopup-migrate-button").attr("data-label")); lepopup_global_message_show("danger", lepopup_esc_html__("Something went wrong. We got unexpected server response.")); } }); return false; } var lepopup_gettingstarted_steps = {}; function lepopup_gettingstarted(_screen, _step) { var screen_cookie = lepopup_read_cookie("lepopup-gettingstarted-"+_screen); if (screen_cookie == "off") return; if (jQuery(".lepopup-gettingstarted-overlay").length < 1) { jQuery("body").append("
    "); jQuery(".lepopup-gettingstarted-overlay").fadeIn(1000); } if (lepopup_gettingstarted_steps.hasOwnProperty(_screen) && _step < lepopup_gettingstarted_steps[_screen].length) { jQuery(".lepopup-gettingstarted-highlight").removeClass("lepopup-gettingstarted-highlight"); jQuery(".lepopup-gettingstarted-bubble").remove(); jQuery(lepopup_gettingstarted_steps[_screen][_step]["selector"]).addClass("lepopup-gettingstarted-highlight"); var html = "

    "+lepopup_gettingstarted_steps[_screen][_step]["text"]+"

    Got it!
    "; jQuery(".lepopup-gettingstarted-highlight").append(html); jQuery(".lepopup-gettingstarted-bubble").fadeIn(300); } else { jQuery(".lepopup-gettingstarted-overlay").fadeOut(300, function() { jQuery(".lepopup-gettingstarted-overlay").remove(); }); jQuery(".lepopup-gettingstarted-bubble").fadeOut(300, function() { jQuery(".lepopup-gettingstarted-bubble").remove(); }); jQuery(".lepopup-gettingstarted-highlight").removeClass("lepopup-gettingstarted-highlight"); lepopup_write_cookie("lepopup-gettingstarted-"+_screen, "off", 365); } } function lepopup_email_validator_changed(_object) { var value = jQuery(_object).val(); jQuery(".lepopup-email-validator-options").hide(); jQuery(".lepopup-email-validator-"+value).fadeIn(200); return false; } function lepopup_geoip_service_changed(_object) { var value = jQuery(_object).val(); jQuery(".lepopup-geoip-service-options").hide(); jQuery(".lepopup-geoip-service-"+value).fadeIn(200); return false; } var lepopup_global_message_timer; function lepopup_global_message_show(_type, _message) { clearTimeout(lepopup_global_message_timer); jQuery("#lepopup-global-message").fadeOut(300, function() { jQuery("#lepopup-global-message").attr("class", ""); jQuery("#lepopup-global-message").addClass("lepopup-global-message-"+_type).html(_message); jQuery("#lepopup-global-message").fadeIn(300); lepopup_global_message_timer = setTimeout(function(){jQuery("#lepopup-global-message").fadeOut(300);}, 5000); }); } function lepopup_escape_html(_text) { if (typeof _text != typeof "string") return _text; if (!_text) return ""; var map = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; return _text.replace(/[&<>"']/g, function(m) { return map[m]; }); } function lepopup_is_numeric(_text) { return !isNaN(parseInt(_text)) && isFinite(_text); } function lepopup_random_string(_length) { var length, text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; if (typeof _length == "undefined") length = 16; else length = _length; for (var i=0; i 127) && (c < 2048)) { output += String.fromCharCode((c >> 6) | 192); output += String.fromCharCode((c & 63) | 128); } else { output += String.fromCharCode((c >> 12) | 224); output += String.fromCharCode(((c >> 6) & 63) | 128); output += String.fromCharCode((c & 63) | 128); } } return output; } function lepopup_encode64(input) { var keyString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = lepopup_utf8encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + keyString.charAt(enc1) + keyString.charAt(enc2) + keyString.charAt(enc3) + keyString.charAt(enc4); } return output; } function lepopup_utf8decode(input) { var string = ""; var i = 0; var c = 0, c1 = 0, c2 = 0; while ( i < input.length ) { c = input.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if ((c > 191) && (c < 224)) { c2 = input.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = input.charCodeAt(i+1); c3 = input.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } function lepopup_decode64(input) { var keyString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = keyString.indexOf(input.charAt(i++)); enc2 = keyString.indexOf(input.charAt(i++)); enc3 = keyString.indexOf(input.charAt(i++)); enc4 = keyString.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } output = lepopup_utf8decode(output); return output; } function lepopup_esc_html__(_string) { var string; if (typeof lepopup_translations == typeof {} && lepopup_translations.hasOwnProperty(_string)) { string = lepopup_translations[_string]; if (string.length == 0) string = _string; } else string = _string; return lepopup_escape_html(string); } function lepopup_read_cookie(key) { var pairs = document.cookie.split("; "); for (var i = 0, pair; pair = pairs[i] && pairs[i].split("="); i++) { if (pair[0] === key) return pair[1] || ""; } return null; } function lepopup_write_cookie(key, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = key+"="+value+expires+"; path=/"; }