";
}
}
break;
case "voting":
var emojiThumb;
var toUp = '';
var toDown = '';
if(rateType == "hand"){
toUp = 'thumbs-up';
toDown = 'thumbs-down';
}
else if(rateType == "emoji"){
toUp = 'smile';
toDown = 'frown';
}
var emojiThumb = new Array(
'',
''
);
for(var i = 0 ; i <= countSel ; i++){
content += "
";
content += ""
content += ""
content += "
";
}
break;
case "text":
var textType = rateType;
var textPlaceholder = $(document).find("#ays_poll_text_type_placeholder");
var textPlaceholderVal = textPlaceholder.val();
switch(textType){
case "short_text":
content += "
";
content += ""
content += ""
content += "
";
break;
case "paragraph":
content += "
";
content += ""
content += ""
content += "
";
break;
}
break;
}
$(document).find(".apm-answers").html(content);
}
function goToPro() {
window.open(
'https://ays-pro.com/wordpress/poll-maker/',
'_blank'
);
return false;
}
$(document).on('click', "[id|='select2'] li[id$='-pro']", goToPro);
$('.ays_poll_theme_image_div.apm-pro-feature').on('click', goToPro);
$('.apm-loader.apm-pro-feature').on('click', goToPro);
$('.apm-pro-feature-link').on('click', goToPro);
//**********************/
//LIVE PREVIEW
//*********************/
var themeId = $('.apm_active_theme+input').val() || 0;
$(document).find('#ays-poll-main-color').wpColorPicker({
defaultColor: themes[themeId].mainColor,
change: function(event, ui) {
$(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].mainColor});
mainColorChange(ui);
}
});
$(document).find('#ays-poll-text-color').wpColorPicker({
defaultColor: themes[themeId].textColor,
change: function(event, ui) {
$(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].textColor});
textColorChange(ui);
}
});
$(document).find('#ays-poll-button-text-color').wpColorPicker({
defaultColor: themes[themeId].buttonTextColor,
change: function(event, ui) {
$(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].buttonTextColor});
buttonTextColorChange(ui);
}
});
$(document).find('#ays-poll-button-bg-color').wpColorPicker({
defaultColor: themes[themeId].buttonBgColor,
change: function(event, ui) {
$(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].buttonBgColor});
buttonBgColorChange(ui);
}
});
$(document).find('#ays-poll-icon-color').wpColorPicker({
defaultColor: themes[themeId].iconColor,
change: function(event, ui) {
$(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].iconColor});
iconColorChange(ui);
}
});
$(document).find('#ays-poll-bg-color').wpColorPicker({
defaultColor: themes[themeId].bgColor,
change: function(event, ui) {
$(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].bgColor});
bgColorChange(ui);
}
});
$(document).find('#ays-poll-answer-bg-color').wpColorPicker({
defaultColor: themes[themeId].answerBgColor,
change: function(event, ui) {
$(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].answerBgColor});
answerBgColorChange(ui);
}
});
$(document).find('#ays-poll-answer-hover-color').wpColorPicker({
defaultColor: themes[themeId].answerHoverColor,
change: function(event, ui) {
$(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].answerHoverColor});
answerHoverColorChange(ui);
}
});
$(document).find('#ays-poll-title-bg-color').wpColorPicker({
defaultColor: themes[themeId].titleBgColor,
change: function(event, ui) {
$(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].titleBgColor});
titleBgColorChange(ui);
}
});
$(document).find('#ays-poll-box-shadow-color').wpColorPicker({
defaultColor: '#000000',
change: function(event, ui) {
boxShadowColorChange(ui);
}
});
$(document).find('#ays-background-gradient-color-1').wpColorPicker({
defaultColor: '#103251',
change: function(event, ui) {
toggleBackgrounGradient();
}
});
$(document).find('#ays-background-gradient-color-2').wpColorPicker({
defaultColor: '#607593',
change: function(event, ui) {
toggleBackgrounGradient();
}
});
$(document).find('#ays-poll-border-color').wpColorPicker({
defaultColor: '#0C6291',
change: function(event, ui) {
borderColorChange(ui);
}
});
$(document).find('#ays_poll_title_text_shadow_color').wpColorPicker({
defaultColor: 'rgba(255,255,255,0)',
change: function(event, ui) {
textShadowChange(ui);
}
});
$(document).find('.ays-title-text-shadow-coord-change').on('change', function(){
var color = $(document).find('#ays_poll_title_text_shadow_color').val();
textShadowChange(color);
});
$(document).find('#ays_poll_enable_title_text_shadow').on('change', function(){
var color = $(document).find('#ays_poll_title_text_shadow_color').val();
var checkedShadow = $(this).prop('checked');
if(checkedShadow){
textShadowChange(color);
}else{
$(document).find(".apm-title-box > h5").css("text-shadow" , "unset");
}
});
$(document).find('#ays_poll_answers_box_shadow_color').wpColorPicker({
defaultColor: '#0C6291',
change: function(event, ui) {
}
});
if($(document).find('#ays-poll-bg-image').val() != ''){
$('.box-apm').css('background-image', 'url('+ $(document).find('#ays-poll-bg-image').val() +')');
$('.box-apm').css('background-position', $(document).find('#ays-poll-bg-image-pos').val());
}
function mainColorChange(ui) {
var color = ui.color.toString();
document.documentElement.style.setProperty('--theme-main-color', color);
$('#ays-poll-main-color')
.attr('value', color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
function textColorChange(ui) {
var color = ui.color.toString();
document.documentElement.style.setProperty('--theme-text-color', color);
$('#ays-poll-text-color')
.attr('value', color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
function buttonTextColorChange(ui) {
var color = ui.color.toString();
$(document).find('input[type="button"].ays-poll-btn').css('color', color);
$('#ays-poll-button-text-color')
.attr('value', color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
function buttonBgColorChange(ui) {
var color = ui.color.toString();
$(document).find('input[type="button"].ays-poll-btn').css('background-color', color);
$('#ays-poll-button-bg-color')
.attr('value', color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
function iconColorChange(ui) {
var color = ui.color.toString();
document.documentElement.style.setProperty('--theme-icon-color', color);
$('#ays-poll-icon-color')
.attr('value', color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
function bgColorChange(ui) {
var color = ui.color.toString();
document.documentElement.style.setProperty('--theme-bg-color', color);
$('#ays-poll-bg-color')
.attr('value', color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
function borderColorChange(ui) {
var color = ui.color.toString();
$(document).find(".box-apm").css("border-color" , color);
$('#ays-poll-border-color')
.val(color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
function textShadowChange(ui , isChecked) {
if (typeof ui == 'object') {
var color = ui.color.toString();
}else{
var color = ui;
}
var x_offset = $(document).find('input#ays_poll_title_text_shadow_x_offset').val() + "px ";
var y_offset = $(document).find('input#ays_poll_title_text_shadow_y_offset').val() + "px ";
var z_offset = $(document).find('input#ays_poll_title_text_shadow_z_offset').val() + "px ";
var boxShadow = x_offset + y_offset + z_offset;
if($(document).find('#ays_poll_enable_title_text_shadow').prop("checked")){
$(document).find(".apm-title-box > h5").css("text-shadow" , boxShadow+" "+ color);
}
$('#ays_poll_title_text_shadow_color')
.val(color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
var answer_border_side = $(document).find('#ays-poll-border-side').val();
answerBorderSideChange(answer_border_side);
function answerBorderSideChange(side) {
var checked_answ = $(document).find( '#ays_poll_enable_answer_style').prop("checked");
if (side == 'none' || !checked_answ) {
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = 'none';
});
}else{
switch(side) {
case 'all_sides':
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = '1px solid';
});
break;
case 'top':
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = 'none';
$(this)[0].style.borderTop = '1px solid';
});
break;
case 'bottom':
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = 'none';
$(this)[0].style.borderBottom = '1px solid';
});
break;
case 'left':
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = 'none';
$(this)[0].style.borderLeft = '1px solid';
});
break;
case 'right':
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = 'none';
$(this)[0].style.borderRight = '1px solid';
});
break;
}
}
}
function answerStyleChange(theme_id) {
if (theme_id == 3) {
$('.box-apm').find('.apm-choosing').addClass('ays_poll_minimal_theme');
$('.box-apm').find('.btn.ays-poll-btn').addClass('ays_poll_minimal_theme_btn');
$('#ays_poll_enable_answer_style').prop('checked', false).trigger("change");
$('#ays_poll_answers_box_shadow_enable').prop('checked', false).trigger("change");
$('.ays_answer_style').hide();
answerBorderSideChange("none");
$('#ays-poll-border-width').val(0);
document.documentElement.style.setProperty('--poll-border-width', "0px");
}else{
$('.box-apm').find('.apm-choosing').removeClass('ays_poll_minimal_theme');
$('.box-apm').find('.btn.ays-poll-btn').removeClass('ays_poll_minimal_theme_btn');
$('#ays_poll_enable_answer_style').prop('checked' , true);
$('.ays_answer_style').show();
answerBorderSideChange("all_sides");
}
}
function answerBgColorChange(ui) {
if (typeof ui == 'object') {
var color = ui.color.toString();
}else{
var color = ui;
}
if (color == 'transparent' || !$(document).find('#ays_poll_enable_answer_style').prop("checked")) {
document.documentElement.style.setProperty('--theme-answer-bg-color', "initial");
}else{
document.documentElement.style.setProperty('--theme-answer-bg-color', color);
$('#ays-poll-answer-bg-color')
.attr('value', color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
}
function answerHoverColorChange(ui) {
if (typeof ui == 'object') {
var color = ui.color.toString();
} else {
var color = ui;
}
if (color == 'transparent' || !$(document).find('#ays_poll_enable_answer_style').prop("checked")) {
document.documentElement.style.setProperty('--theme-answer-hover-color', "initial");
} else {
document.documentElement.style.setProperty('--theme-answer-hover-color', color);
$('#ays-poll-answer-hover-color')
.attr('value', color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
}
function titleBgColorChange(ui) { //aray
var color = ui.color.toString();
document.documentElement.style.setProperty('--theme-title-bg-color', color);
$('#ays-poll-title-bg-color')
.attr('value', color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
function boxShadowColorChange(ui) {
if (typeof ui == 'object') {
var color = ui.color.toString();
}else{
var color = ui;
}
if (color == 'transparent' || !$(document).find('#ays_poll_enable_box_shadow').prop("checked")) {
document.documentElement.style.setProperty('--poll-box-shadow', "initial");
}else{
var x_offset = $(document).find('input#ays_poll_box_shadow_x_offset').val() + "px ";
var y_offset = $(document).find('input#ays_poll_box_shadow_y_offset').val() + "px ";
var z_offset = $(document).find('input#ays_poll_box_shadow_z_offset').val() + "px ";
var boxShadow = x_offset + y_offset + z_offset;
document.documentElement.style.setProperty('--poll-box-shadow', color + " " + boxShadow + " 1px");
$('#ays-poll-box-shadow-color')
.attr('value', color)
.parents('.wp-picker-container')
.find('.color-alpha').css('background-color', color);
}
}
/*
==========================================
Background Gradient
==========================================
*/
function toggleBackgrounGradient() {
if ($(document).find('#ays-enable-background-gradient').prop('checked') || $(document).find('input#ays-poll-bg-image').val() != '') {
if($(document).find('#ays_poll_gradient_direction').val() != '') {
var ays_poll_gradient_direction = $(document).find('#ays_poll_gradient_direction').val();
switch(ays_poll_gradient_direction) {
case "horizontal":
ays_poll_gradient_direction = "to right";
break;
case "diagonal_left_to_right":
ays_poll_gradient_direction = "to bottom right";
break;
case "diagonal_right_to_left":
ays_poll_gradient_direction = "to bottom left";
break;
default:
ays_poll_gradient_direction = "to bottom";
}
if($(document).find('input#ays-poll-bg-image').val() != ''){
return false;
}else{
$(document).find('.box-apm').css({'background-image': "linear-gradient(" + ays_poll_gradient_direction + ", " + $(document).find('input#ays-background-gradient-color-1').val() + ", " + $(document).find('input#ays-background-gradient-color-2').val()+")"
});
}
}
}
else{
$(document).find('.box-apm').css('background-image' , "unset");
return false;
}
}
var ays_poll_box_gradient_color1_picker = {
change: function (e) {
setTimeout(function () {
toggleBackgrounGradient();
}, 1);
}
};
var ays_poll_box_gradient_color2_picker = {
change: function (e) {
setTimeout(function () {
toggleBackgrounGradient();
}, 1);
}
};
function ays_poll_search_box_pagination(listTableClass, searchBox) {
if($(document).find( "." + listTableClass ).length) {
if($(document).find( "#" + searchBox ).length) {
var search_string = $(document).find("#" + searchBox).val();
if(search_string != "") {
$(document).find("."+ listTableClass +" .pagination-links a").each(function() {
if ( typeof this.href != "undefined" && this.href != "" ) {
if ( this.href.indexOf("&s=") < 0 ) {
this.href = this.href + "&s=" + search_string;
}
}
});
}
}
}
}
$(document).find('#ays_poll_gradient_direction').on('change', function () {
toggleBackgrounGradient();
});
$(document).find('#ays-background-gradient-color-1').wpColorPicker(ays_poll_box_gradient_color1_picker);
$(document).find('#ays-background-gradient-color-2').wpColorPicker(ays_poll_box_gradient_color2_picker);
toggleBackgrounGradient();
$(document).find('input#ays-enable-background-gradient').on('change', function () {
toggleBackgrounGradient();
});
$(document).on('click', '.ays-remove-poll-bg-img', function () {
$(document).find('.box-apm').css({'background-image': 'none'});
toggleBackgrounGradient();
});
$(document).find('#ays_poll_enable_answer_style').on('change', function () {
var checkboxProp = $(this).prop('checked');
var color = $(this).prop('checked') ? $(document).find('#ays-poll-answer-bg-color').val() : "transparent";
var hoverColor = $(this).prop('checked') ? $(document).find('#ays-poll-answer-hover-color').val() : "#0C6291";
var side = $(this).prop('checked') ? $(document).find('#ays-poll-border-side').val() : "none";
answerBgColorChange(color);
answerHoverColorChange(hoverColor);
answerBorderSideChange(side);
refreshLivePreview(checkboxProp);
});
$(document).find('#ays_poll_enable_box_shadow').on('change', function () {
var color = $(this).prop('checked') ? $(document).find('#ays-poll-box-shadow-color').val() : "transparent";
boxShadowColorChange(color);
});
$(document).find('input.ays-box-shadow-coord-change').on('change', function () {
var color = $(document).find('#ays-poll-box-shadow-color').val();
boxShadowColorChange(color);
});
$(document).find('#ays-enable-background-gradient').on('change', function () {
var color = $(this).prop('checked') ? $(document).find('#ays-background-gradient-color-1').val() : "transparent";
toggleBackgrounGradient(color);
});
$(document).find('#ays-enable-background-gradient').on('change', function () {
var color = $(this).prop('checked') ? $(document).find('#ays-background-gradient-color-2').val() : "transparent";
toggleBackgrounGradient(color);
});
$('#ays-poll-icon-size').on('change', function () {
var val = (+$(this).val() > 10) ? $(this).val() : 10;
$(this).val(val);
var value = val + 'px';
document.documentElement.style.setProperty('--poll-icons-size', value);
});
$('#ays-poll-width').on('change', function () {
var val = +$(this).val();
if (val === 0) {
val = "100%";
} else {
val = (val > 249 ? val : 250) + "px";
}
document.documentElement.style.setProperty('--poll-width', val);
});
$('#ays-poll-btn-text').on('change', function () {
var val = $(this).val() !== '' ? $(this).val() : "Vote";
$('.ays-poll-btn').val(val)
});
$('#ays-poll-border-style').on('change', function () {
var val = $(this).val();
document.documentElement.style.setProperty('--poll-border-style', val);
});
$('#ays-poll-border-side').on('change', function () {
var val = $(this).val();
switch(val) {
case 'none':
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = 'none';
});
break;
case 'all_sides':
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = '1px solid';
});
break;
case 'top':
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = 'none';
$(this)[0].style.borderTop = '1px solid';
});
break;
case 'bottom':
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = 'none';
$(this)[0].style.borderBottom = '1px solid';
});
break;
case 'left':
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = 'none';
$(this)[0].style.borderLeft = '1px solid';
});
break;
case 'right':
$(document).find('.box-apm.choosing-poll label').each(function(){
$(this)[0].style.border = 'none';
$(this)[0].style.borderRight = '1px solid';
});
break;
}
});
$(document).on('click', 'a.add-poll-bg-music', function (e) {
openMusicMediaUploader(e, $(this));
});
$('#ays-poll-border-radius').on('change', function () {
var val = $(this).val();
var value = val + 'px';
document.documentElement.style.setProperty('--poll-border-radius', value);
});
$('#ays-poll-border-width').on('change', function () {
var val = $(this).val();
var value = val + 'px';
document.documentElement.style.setProperty('--poll-border-width', value);
});
$('#ays_custom_css').on('change', function () {
var val = $(this).val();
$('#apm-custom-css').html(val);
});
$('#show-title').on('change', function () {
$('.apm-title-box').fadeToggle();
});
$('#ays-poll-title').on('change', function () {
var val = $(this).val();
$('.apm-title-box h5').text(val);
});
var checkAnswerStyle = $(document).find("#ays_poll_enable_answer_style").prop("checked");
$(document).on('change', '.ays-poll-question-font-size,#ays_poll_question_image_height,#ays_answers_view,#ays_poll_answer_img_height,#ays_poll_answer_image_border_radius,#ays_poll_image_background_size,#ays_poll_answers_padding,#ays_poll_answers_margin,#ays_poll_title_font_size,#ays_poll_title_alignment,#ays_poll_text_type_placeholder,#ays_poll_question_image_object_fit,#ays_poll_answers_box_shadow_enable,#ays_poll_answers_box_shadow_color,#ays_poll_answer_border_radius,#ays_poll_answer_box_shadow_x_offset,#ays_poll_answer_box_shadow_y_offset,#ays_poll_answer_box_shadow_z_offset' , function () {
var checkAnswerStyleOnChange = $(document).find("#ays_poll_enable_answer_style").prop("checked");
refreshLivePreview(checkAnswerStyleOnChange);
});
//PRO features lightbox
$('.open-lightbox').on('click', function (e) {
e.preventDefault();
var image = $(this).attr('href');
$('html').addClass('no-scroll');
$('.ays-poll-row ').append('
');
});
$('body').on('click', '.lightbox-opened', function () {
$('html').removeClass('no-scroll');
$('.lightbox-opened').remove();
});
$(document).on('change', '.ays_toggle', function (e) {
var state = $(this).prop('checked');
if ($(this).hasClass('ays_toggle_slide')) {
switch (state) {
case true:
$(this).parent().find('.ays_toggle_target').slideDown(250);
if($(this).parent().find('.ays_toggle_target').hasClass("display_none")){
$(this).parent().find('.ays_toggle_target').removeClass("display_none");
}
break;
case false:
$(this).parent().find('.ays_toggle_target').slideUp(250);
break;
}
} else {
switch (state) {
case true:
$(this).parent().find('.ays_toggle_target').show(250);
break;
case false:
$(this).parent().find('.ays_toggle_target').hide(250);
break;
}
}
});
$(document).on('change', '.ays_toggle_checkbox', function (e) {
var state = $(this).prop('checked');
var parent = $(this).closest('.ays_toggle_parent');
if($(this).hasClass('ays_toggle_slide')){
switch (state) {
case true:
parent.find('.ays_toggle_target').slideDown(500);
break;
case false:
parent.find('.ays_toggle_target').slideUp(500);
break;
}
}else{
var targetEl = parent.find('.ays_toggle_target');
for (let i = 0; i 0) {
$('.unread-result-badge.unread-result').each(function () {
$(this).parent().parent().find('td').css('font-weight', 'bold')
})
}
//Each results
if ($('.ays_poll_unread').length > 0) {
$('.ays_poll_unread').each(function () {
$(this).parent().parent().find('td').css('font-weight', 'bold')
})
}
$('#ays_poll_show_timer').change(function () {
if ($(this).prop('checked')) {
$('.ays_show_time').show(250);
} else {
$('.ays_show_time').hide(250);
}
});
$('#show_result_btn_schedule').change(function () {
if ($(this).prop('checked')) {
$('.result_btn_see').show(250);
} else {
$('.result_btn_see').hide(250);
}
});
//info_form
$("#ays_poll_info_form").change(function () {
if ($(this).prop('checked')) {
$(this).parents(".form-group").find(".form-group").show(250);
} else {
$(this).parents(".form-group").find(".form-group").hide(250);
}
});
$('#ays_users_roles').select2();
$('#ays_user_roles').select2();
$('[data-toggle="tooltip"]').tooltip();
$(document).find('#ays-deactive, #ays-active, #ays_poll_change_creation_date').datetimepicker({
controlType: 'select',
oneLine: true,
dateFormat: "yy-mm-dd",
timeFormat: "HH:mm:ss"
});
// Codemirror
setTimeout(function(){
if($(document).find('#ays_custom_css').length > 0){
if(wp.codeEditor){
wp.codeEditor.initialize($(document).find('#ays_custom_css'), cm_settings);
}
}
}, 500);
$(document).find('a[href="#tab2"]').on('click', function (e) {
setTimeout(function(){
if($(document).find('#ays_custom_css').length > 0){
var ays_custom_css = $(document).find('#ays_custom_css').html();
if(wp.codeEditor){
$(document).find('#ays_custom_css').next('.CodeMirror').remove();
wp.codeEditor.initialize($(document).find('#ays_custom_css'), cm_settings);
$(document).find('#ays_custom_css').html(ays_custom_css).trigger('change');
}
}
}, 500);
});
var unread_result_parent = $(document).find(".unread-result").parent().parent();
if (unread_result_parent != undefined) {
unread_result_parent.css({"font-weight":"bold"});
}
$(document).find('input[type="checkbox"]#ays_redirect_after_submit').on('change', function(e){
var answerRedirectRow = $(document).find('#ays-answers-table .ays-answer-redirect-row');
if($(this).prop('checked') == false){
answerRedirectRow.addClass('ays_poll_display_none');
}else{
if (answerRedirectRow.hasClass('ays_poll_display_none')) {
answerRedirectRow.removeClass('ays_poll_display_none');
}
}
});
$(document).on('change' ,"#ays_disable_answer_hover", disable_answer_hover);
function disable_answer_hover(){
var checkLabelHover = $(document).find('label.ays_label_poll');
var checkCurrentHover = $(document).find("#ays_answer_checker");
if(checkLabelHover.hasClass('ays_enable_hover') && !checkLabelHover.hasClass('disable_hover')){
checkLabelHover.addClass('disable_hover');
checkLabelHover.removeClass('ays_enable_hover');
checkCurrentHover.val('disable_hover');
}else{
checkLabelHover.addClass('ays_enable_hover');
checkLabelHover.removeClass('disable_hover');
checkCurrentHover.val('ays_enable_hover');
}
}
$('#ays_add_postcat_for_poll').select2();
function openMusicMediaUploader(e, element) {
e.preventDefault();
var aysUploader = wp.media({
title: 'Upload music',
button: {
text: 'Upload'
},
library: {
type: 'audio'
},
multiple: false
}).on('select', function () {
var attachment = aysUploader.state().get('selection').first().toJSON();
element.next().attr('src', attachment.url);
element.parent().find('input.ays_poll_bg_music').val(attachment.url).trigger('change');
}).open();
return false;
}
$(document).find('#ays_poll_bg_image_position').on('change', function () {
var pollContainer = $(document).find('.box-apm ,.choosing-poll');
pollContainer.css({
'background-position': $(this).val()
});
});
$(document).find("#ays_answer_font_size,#ays_poll_answer_font_size_mobile").on("change" , function(){
var thisSize = parseInt($(this).val());
var detectType = $(this).data("device");
if(thisSize < 10){
thisSize = 10;
}
if(thisSize > 90){
thisSize = 90;
}
$(this).val(thisSize);
if(detectType != "mobile"){
$(document).find('.ays_label_font_size').css("font-size" , thisSize + "px");
$(document).find('.ays-poll-text-type-fields').css({ 'font-size': thisSize + "px" });
}
});
refreshLivePreview(checkAnswerStyle);
// function for Live Preview
function refreshLivePreview(checker){
// Defaults
var imageDefaultHeight = "150";
var imageDefaulObjFit = "cover";
var answerDefaultPadding = "10";
var answerDefaultGap = "10";
var answerDefaultFontSize = "16";
var answerDefaultFontSizeMobile = "16";
var titleDefaultFontSize = "20";
var answersBorderRadiusDefault = "0";
// Boxes
var imageBoxes = $(document).find('.box-apm .ays-poll-answer-image-live');
var answerLabelBoxes = $(document).find('.box-apm label.ays-poll-answer-more-options');
var answerMainBoxes = $(document).find('.box-apm .apm-choosing');
// Answer Font size
var answerFontSizeMain = $(document).find("#ays_answer_font_size");
var answerFontSize = answerFontSizeMain.val();
// Answer Font size mobile
var answerFontSizeMobileMain = $(document).find("#ays_poll_answer_font_size_mobile");
// Border color
var borderColor = $(document).find("#ays-poll-border-color").val();
// Image Height option
var imageHeight = $(document).find('#ays_poll_answer_img_height').val();
// Image border radius option
var imageBorderRadius = $(document).find('#ays_poll_answer_image_border_radius').val();
// Answer Image object-fit
var imageBgSizeSelect = $(document).find('#ays_poll_image_background_size');
var imageBgSizeVal = imageBgSizeSelect.val();
// Answer padding
var answersPadding = $(document).find('#ays_poll_answers_padding');
var answersPaddingVal = answersPadding.val();
// Answer Gap
var answersMargin = $(document).find('#ays_poll_answers_margin');
var answersMarginVal = answersMargin.val();
// Answer Border radius
var answersBorderRadiusMain = $(document).find('#ays_poll_answer_border_radius');
var answersBorderRadius = answersBorderRadiusMain.val();
// Question image height
var questionImageHeight = $(document).find("#ays_poll_question_image_height").val();
var questionHeight = questionImageHeight == "" ? "100%" : questionImageHeight+"px";
// Question image object-fit
var questionImageObjectFit = $(document).find("#ays_poll_question_image_object_fit").val();
$(document).find(".box-apm .apm-img-box .ays-poll-img").css({"object-fit" : questionImageObjectFit});
// Poll Answer view type
var viewType = $(document).find('#ays_answers_view').val();
var answersCont = $(document).find('.apm-answers');
var answersField = answersCont.find('.ays-poll-field');
var checkTextType = $(document).find('.box-apm.text-poll').length > 0 ? true : false;
// Title font size
var titleFontSizeBox = $(document).find("#ays_poll_title_font_size");
var titleFontSize = titleFontSizeBox.val();
// Poll text type placeholder
var textPlaceholder = $(document).find("#ays_poll_text_type_placeholder");
var textPlaceholderVal = textPlaceholder.val();
$(document).find('.ays-poll-text-type-fields').attr('placeholder' , textPlaceholderVal);
answersCont.find('.ays_label_poll').css({
'display': 'flex',
});
// Title alignment
var titleAlignment = $(document).find("#ays_poll_title_alignment").val();
if(parseInt(imageHeight) < 0){
imageHeight = 0;
$(document).find('#ays_poll_answer_img_height').val(imageHeight);
}
//
//
// Answer box shadow
var answersBoxShadow = $(document).find('#ays_poll_answers_box_shadow_enable').prop('checked');
var answersBoxShadowColor = $(document).find('#ays_poll_answers_box_shadow_color').val();
var answersBoxShadowXOffset = $(document).find('#ays_poll_answer_box_shadow_x_offset').val();
var answersBoxShadowYOffset = $(document).find('#ays_poll_answer_box_shadow_y_offset').val();
var answersBoxShadowZOffset = $(document).find('#ays_poll_answer_box_shadow_z_offset').val();
if(answersBoxShadow){
$(document).find('.ays-poll-answers .ays-field>label,.ays-poll-answers .ays-field >.ays_answer_live_label,label.ays_label_poll').css({
'box-shadow': answersBoxShadowXOffset+'px '+answersBoxShadowYOffset+'px '+answersBoxShadowZOffset+'px '+answersBoxShadowColor,
});
}else{
$(document).find('.ays-poll-answers .ays-field>label,.ays-poll-answers .ays-field >.ays_answer_live_label,label.ays_label_poll').css({
'box-shadow': 'none',
});
}
if(parseInt(answersPaddingVal) < 0){
answersPaddingVal = 0;
answersPadding.val(answersPaddingVal);
}
if(parseInt(answersMarginVal) <= 0){
answersMarginVal = 1;
answersMargin.val(answersMarginVal);
}
if(!checker){
imageBgSizeVal = imageDefaulObjFit;
answersPaddingVal = answerDefaultPadding;
imageHeight = imageDefaultHeight;
answersMarginVal = answerDefaultGap;
answerFontSize = answerDefaultFontSize;
answerFontSizeMain.val(answerDefaultFontSize);
answerFontSizeMobileMain.val(answerDefaultFontSize);
answersBorderRadius = answersBorderRadiusDefault;
answersBorderRadiusMain.val(answersBorderRadiusDefault);
}
// Image Changes
imageBoxes.css({
'height': imageHeight+'px',
'border-radius': imageBorderRadius+'px',
'object-fit': imageBgSizeVal
});
// Answer changes
answerLabelBoxes.css({
'padding': answersPaddingVal+'px'
});
answerMainBoxes.css({
'margin-bottom': answersMarginVal+'px'
});
// Question font size
var pattern = /Android|webOS|iPhone|iPad|Mac|Macintosh|iPod|BlackBerry|IEMobile|Opera Mini/i;
var questnionFontSize;
if( pattern.test(navigator.userAgent) ) {
questnionFontSize = $(document).find("#ays_poll_answers_font_size_mobile").val();
}
else{
questnionFontSize = $(document).find("#ays_poll_answers_font_size_pc").val();
}
$(document).find('.ays_question,.ays_question p').css({ 'font-size': questnionFontSize+"px" });
$(document).find('.ays_label_font_size').css("font-size" , answerFontSize + "px");
$(document).find('.box-apm').css("border-color" , borderColor);
$(document).find(".apm-img-box img.ays-poll-img").css({"height" : questionHeight});
$(document).find('.ays-poll-answers .ays-field>label,.ays-poll-answers .ays-field >.ays_answer_live_label,label.ays_label_poll').css({
'border-radius': +answersBorderRadius+"px",
});
if(titleFontSize < 0){
titleFontSize = 0;
titleFontSizeBox.val(0);
}
$(document).find('.apm-title-box h5').css({
"font-size" : titleFontSize + "px",
"text-align" : titleAlignment,
});
if(viewType == 'list'){
$(document).find('.grid_column_count').hide(250);
answersCont.removeClass('ays_poll_grid_view_container');
answersCont.addClass('ays_poll_list_view_container');
answersField.removeClass('ays_poll_grid_view_item');
answersField.addClass('ays_poll_list_view_item');
answersCont.find('.ays-poll-field.ays_poll_list_view_item').css({
'margin-right': 0,
});
answersCont.find('.ays-poll-answer-image-live').css({
'width': '220px',
});
answersCont.find('span.ays-poll-each-answer').css({
'width': 'initial',
'text-align': 'initial',
'display': 'initial',
});
answersCont.find('.ays_label_poll').css({
'align-items': 'center',
'flex-direction': 'row',
});
}else if(viewType == 'grid' && !checkTextType){
$(document).find('.grid_column_count').show(250);
answersCont.removeClass('ays_poll_list_view_container');
answersCont.addClass('ays_poll_grid_view_container');
answersField.removeClass('ays_poll_list_view_item');
answersField.addClass('ays_poll_grid_view_item');
answersCont.find('.ays-poll-answer-image-live').css({
'width': '100%',
});
answersCont.find('span.ays-poll-each-answer').css({
'width': '100%',
'text-align': 'center',
'display': 'inline-block',
});
var innerLabel = answersField.find("label.ays_poll_label_without_padding");
if(innerLabel.length > 0){
innerLabel.css({
'flex-direction': 'column',
});
}
}
}
var heart_interval = setInterval(function () {
$(document).find('.ays-poll-maker-wrapper i.ays_fa').toggleClass('ays_poll_pulse');
}, 1000);
$(document).on('change' , '.ays-answer-value', function(){
livePrevToChoosing("choosing");
var checkAnswerStyleOnChange = $(document).find("#ays_poll_enable_answer_style").prop("checked");
refreshLivePreview(checkAnswerStyleOnChange);
});
$('#ays_poll_info_form').on('change', function () {
var propCheck = $(this).prop("checked");
var allowCollect = $(document).find(".ays_toggle_target_inverse");
if(propCheck){
allowCollect.find('#ays_allow_collecting_logged_in_users_data').prop("checked" , false);
allowCollect.hide();
}
else{
if(allowCollect.hasClass("display_none")){
allowCollect.removeClass("display_none");
}
allowCollect.show();
}
$('.ays-poll-if-form-on').fadeToggle();
});
// Pro features
$(document).find('#ays_answers_border_color').wpColorPicker({
change: function(event, ui) {
}
});
$(document).find("#ays_see_result_show").on("change" , function(){
var checker = $(this).prop("checked");
var buttonsCont = $(document).find("#ays_poll_show_hide_button");
if(checker){
buttonsCont.show(200);
buttonsCont.css("display" , "flex");
}
else{
buttonsCont.hide(200);
}
});
$(document).find('.ays-poll-question-tab-all-filter-button-top, .ays-poll-question-tab-all-filter-button-bottom').on('click', function(e) {
e.preventDefault();
var $this = $(this);
var parent = $this.parents('.tablenav');
var searchForm = parent.parent();
var searchInput = searchForm.find('input#poll-maker-ays-search-input')
var searchValue = searchInput.val();
var html_name = '';
var top_or_bottom = 'top';
if ( parent.hasClass('bottom') ) {
top_or_bottom = 'bottom';
}
var catFilter = $(document).find('select[name="filterby-'+ top_or_bottom +'"]').val();
var authorFilter = $(document).find('select[name="filterbyauthor-'+ top_or_bottom +'"]').val();
var typeFilter = $(document).find('select[name="filterbytype-'+ top_or_bottom +'"]').val();
var link = location.href;
if (typeof catFilter != "undefined") {
link = catFilterForListTable(link, searchValue, {
what: 'filterby',
value: catFilter
});
}
if (typeof authorFilter != "undefined") {
link = catFilterForListTable(link, searchValue, {
what: 'filterbyauthor',
value: authorFilter
});
}
if (typeof typeFilter != "undefined") {
link = catFilterForListTable(link,searchValue, {
what: 'filterbytype',
value: typeFilter
});
}
document.location.href = link;
})
function catFilterForListTable(link, searchValue, options){
if( options.value != '' ){
options.value = "&" + options.what + "=" + options.value;
var linkModifiedStart = link.split('?')[0];
var linkModified = link.split('?')[1].split('&');
for(var i = 0; i < linkModified.length; i++){
if ( linkModified[i].split("=")[0] == "ays_result_tab" ) {
linkModified.splice(i, 1, "ays_result_tab=poststuff");
}
if(linkModified[i].split("=")[0] == options.what){
linkModified.splice(i, 1);
}
}
linkModified = linkModified.join('&');
if (typeof searchValue != 'undefined' && searchValue != '') {
linkModified = linkModified + "&s=" + searchValue;
}
return linkModifiedStart + "?" + linkModified + options.value;
}else{
var linkModifiedStart = link.split('?')[0];
var linkModified = link.split('?')[1].split('&');
for(var i = 0; i < linkModified.length; i++){
if(linkModified[i].split("=")[0] == options.what){
linkModified.splice(i, 1);
}
}
linkModified = linkModified.join('&');
if (typeof searchValue != 'undefined' && searchValue != '') {
linkModified = linkModified + "&s=" + searchValue;
}
return linkModifiedStart + "?" + linkModified;
}
}
$(document).find('input[type="submit"]#doaction, input[type="submit"]#doaction2').on('click', function(e) {
showConfirmationIfDelete(e);
})
$(document).find("input#poll-maker-ays-search-input + input#search-submit").on("click", function (e) {
var _this = $(this);
var parent = _this.parents('form');
var search_input = parent.find('input#poll-maker-ays-search-input');
var input_value = search_input.val();
var field = 's';
var flag = false;
var url = window.location.href;
if(url.indexOf('?' + field + '=') != -1){
flag = true;
}
else if(url.indexOf('&' + field + '=') != -1){
flag = true;
}
if (flag) {
if (typeof input_value != 'undefined' && input_value != "") {
e.preventDefault();
location.href=location.href.replace(/&s=([^&]$|[^&]*)/i, "&s="+input_value);
}
}
});
function showConfirmationIfDelete(e) {
var $el = $(e.target);
var elParent = $el.parent();
var actionSelect = elParent.find('select[name="action"]');
var action = actionSelect.val();
if (action === 'bulk-delete') {
e.preventDefault();
var confirmDelete = confirm('Are you sure you want to delete?');
if (confirmDelete) {
var form = $el.closest('form');
form.submit()
}
}
}
$(document).on('click', '.ays_polls_each_results_list_table th.manage-column a', function(e) {
var href = $(this).attr('href');
$(this).attr('href', href + '&ays_poll_tab_results=tab2');
})
$(document).on("click", "#ays-poll-dismiss-buttons-content .ays-button, #ays-poll-dismiss-buttons-content-helloween .ays-button-helloween", function(e){
e.preventDefault();
var $this = $(this);
var thisParent = $this.parents("#ays-poll-dismiss-buttons-content");
var mainParent = $this.parents("div.ays_poll_dicount_info");
var closeButton = mainParent.find("button.notice-dismiss");
var attr_plugin = $this.attr('data-plugin');
var wp_nonce = thisParent.find('#poll-maker-ays-sale-banner').val();
if(typeof wp_nonce == 'undefined'){
wp_nonce = $(document).find('#poll-maker-ays-sale-banner').val();
}
var data = {
action: 'ays_poll_dismiss_button',
_ajax_nonce: wp_nonce,
};
$.ajax({
url: poll.ajax,
method: 'post',
dataType: 'json',
data: data,
success: function (response) {
if( response.status ){
closeButton.trigger('click');
} else {
swal.fire({
type: 'info',
html: "