(function ($) { 'use strict'; window.FontAwesomeConfig = { autoReplaceSvg: false }; $('.apm-unread').each(function () { var tr = $(this).parent().parent(); tr.find('td').each(function () { $(this).css('color', '#dc3545'); }) }); $.fn.serializeFormJSON = function () { var o = {}, a = this.serializeArray(); $.each(a, function () { if (o[this.name]) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; }; $.fn.goToNormal = function() { $('html, body').animate({ scrollTop: this.offset().top - 200 + 'px' }, 'normal'); return this; // for chaining... } $.fn.aysModal = function(action){ let $this = $(this); var current_popup_id_attr = $this.attr('id'); var current_popup_id = ""; var current_popup_class = ""; if (current_popup_id_attr && current_popup_id_attr != "") { current_popup_id = "overlay-" + current_popup_id_attr; current_popup_class = "." + current_popup_id; } switch(action){ case 'hide': $(this).find('.ays-modal-content').css('animation-name', 'zoomOut'); var removeIframe = $this.find('.ays-modal-body iframe'); if ( removeIframe.length > 0 ) { $this.find('.ays-modal-body iframe').remove(); } setTimeout(function(){ $(document.body).removeClass('modal-open'); $(document).find('.ays-modal-backdrop'+ current_popup_class).remove(); $this.hide(); }, 250); break; case 'hide_remove_video': $(this).find('.ays-modal-content').css('animation-name', 'zoomOut'); $this.find('.ays-modal-body iframe').remove(); setTimeout(function(){ $(document.body).removeClass('modal-open'); $(document).find('.ays-modal-backdrop'+ current_popup_class).remove(); $this.hide(); }, 250); break; case 'show_flex': $this.css('display', 'flex'); $(this).find('.ays-modal-content').css('animation-name', 'zoomIn'); $(document).find('.modal-backdrop').remove(); $(document.body).append('
'); $(document.body).addClass('modal-open'); case 'show': default: $this.show(); $(this).find('.ays-modal-content').css('animation-name', 'zoomIn'); $(document).find('.modal-backdrop').remove(); $(document.body).append(''); $(document.body).addClass('modal-open'); break; } } $(document).find('.ays_poll_aysDropdown').aysDropdown(); $(document).find('[data-toggle="dropdown"]').dropdown(); $('[data-toggle="tooltip"]').tooltip(); // copy shortcode $(document).find('.ays-poll-copy-image').on('click', function(){ var _this = this; var input = $(_this).parent().find('input.ays-poll-shortcode-input'); var length = input.val().length; input[0].focus(); input[0].setSelectionRange(0, length); document.execCommand('copy'); $(_this).attr('data-original-title', pollLangObj.copied); $(_this).tooltip('show'); }); $(document).find('.ays-poll-copy-image').on('mouseleave', function(){ var _this = this; $(_this).attr('data-original-title', pollLangObj.clickForCopy); }); // Users limits if ($('#apm_limit_users').prop('checked')) { $('.if-limit-users ').fadeIn(); } $('#ays_enable_restriction_pass').on('change', function () { if ($(this).prop('checked')) { if(!$('#ays_enable_logged_users').prop('checked')) { $('#ays_enable_logged_users').trigger('click'); } } else { $('.if-users-roles').fadeOut(); } }); if ($('#ays_enable_logged_users').prop('checked')) { $('.if-logged-in').fadeIn(); } if ($('#ays_enable_restriction_pass').prop('checked')) { $('.if-users-roles').fadeIn(); } $('#ays_enable_logged_users').on('change', function () { if (!$(this).prop('checked')) { $('#ays_enable_restriction_pass').prop('checked', false); $('.if-users-roles').fadeOut(); } }); // Email notification if ($('#ays_notify_by_email_on').prop('checked')) { $('.if-notify-email').fadeIn(); } $('#ays_notify_by_email_on').on('change', function () { $('.if-notify-email').fadeToggle(); }); // Redirect after vote if ($('#ays_redirect_after_vote').prop('checked')) { $('.if-redirect-after-vote').fadeIn(); } $('#ays_redirect_after_vote').on('change', function () { $('.if-redirect-after-vote').fadeToggle(); }); // Answer Sound if ($('#ays_enable_asnwers_sound').prop('checked')) { $('.if_answer_sound').fadeIn(); } $('#ays_enable_asnwers_sound').on('change', function () { $('.if_answer_sound').fadeToggle(); }); //Hide results $('.if-ays-poll-hide-results').css("display", "flex").hide(); if ($('#ays-poll-hide-results').prop('checked')) { $('.if-ays-poll-hide-results').fadeIn(); } $('#ays-poll-hide-results').on('change', function () { // $('.if-ays-poll-hide-results').fadeToggle(); if ($('#ays-poll-hide-results').prop('checked')) { $('#ays-poll-allow-not-vote').prop('checked', false); } }); //Allow not to vote $('#ays-poll-allow-not-vote').on('change', function () { if ($('#ays-poll-allow-not-vote').prop('checked')) { $('#ays-poll-hide-results').prop('checked', false); $('.if-ays-poll-hide-results').fadeOut(); } }); //Loading effect $('.if-loading-gif').css("display", "flex").hide(); if ($('#ays-poll-load-effect').val() == 'load_gif') { $('.if-loading-gif').fadeIn(); } if ($('#ays-poll-load-effect').val() == 'message') { $('.if-loading-message').fadeIn(); } $('#ays-poll-load-effect').on('change', function () { var effect = $(this).val(); var sizeCont = $(document).find(".ays_load_gif_cont"); var sizeContLine = $(document).find(".ays_line_changeing"); if (effect == 'load_gif') { $('.if-loading-gif').fadeIn(); $('.if-loading-message').hide(); if(sizeCont.hasClass("display_none")){ sizeCont.removeClass("display_none"); } if(sizeContLine.hasClass("ays_hr_display_none")){ sizeContLine.removeClass("ays_hr_display_none"); } } else if(effect == 'message'){ $('.if-loading-message').fadeIn(); $('.if-loading-gif').hide(); } else { $('.if-loading-gif').fadeOut(); $('.if-loading-message').fadeOut(); if(!sizeCont.hasClass("display_none")){ sizeCont.addClass("display_none"); sizeContLine.addClass("ays_hr_display_none"); } if(!sizeContLine.hasClass("ays_hr_display_none")){ sizeContLine.addClass("ays_hr_display_none"); } } }); //User data form $(".ays-poll-sel-fields input[type='checkbox']").on('change', function () { var id = $(this).val(); if ($(this).prop('checked')) { $('#ays-poll-box-rfield-' + id).fadeIn(); } else { $('#ays-poll-box-rfield-' + id).find('input').prop('checked', false); $('#ays-poll-box-rfield-' + id).fadeOut(); } }); $(document).find('#ays_user_roles_poll').select2({ placeholder: 'Select role' }); $('.apm-cat-select2').select2({ placeholder: 'Select category' }); $('select.ays-select').not('.ays-select-search').select2({ minimumResultsForSearch: -1 }); $('.ays-select-search').select2(); $(document).on('click', 'a.add-question-image', function (e) { openMediaUploader(e, $(this)); }); $(document).on('click', 'a.add-bg-image', function (e) { openMediaUploaderBg(e, $(this)); }); $(document).on('click', 'a.add-logo-image', function (e) { openMediaUploaderLogo(e, $(this)); }); $(document).on('click', '.ays-remove-question-img', function () { $(this).parent().find('img#ays-poll-img').attr('src', ''); $(this).parent().find('input#ays-poll-image').val('').trigger('change'); $(this).parent().fadeOut(); $(document).find('.ays-field label a.add-question-image').text('Add Image'); $('.ays-poll-img').remove(); }); $(document).on('click', '.ays-remove-bg-img', function () { $('img#ays-poll-bg-img').attr('src', ''); $('input#ays-poll-bg-image').val('').trigger('change'); $('.ays-poll-bg-image-container').parent().fadeOut(300); $(this).parents(".form-group.row").find('a.add-bg-image').html('Add Image'); $('.box-apm').css('background-image', 'unset'); $('#ays-poll-background-image-options').fadeOut(300); if ($(document).find('#ays-enable-background-gradient').prop('checked')) { toggleBackgrounGradient(); } }); var themes = [ 'personal', { 'name': 'light', 'mainColor': '#0C6291', 'textColor': '#0C6291', 'buttonTextColor': '#FBFEF9', 'buttonBgColor': '#0C6291', 'iconColor': '#0C6291', 'bgColor': '#FBFEF9', 'answerBgColor': '#FBFEF9', 'titleBgColor': 'rgba(255,255,255,0)', 'borderColor': '#0C6291', }, { 'name': 'dark', 'mainColor': '#FBFEF9', 'textColor': '#FBFEF9', 'buttonTextColor': '#222222', 'buttonBgColor': '#FBFEF9', 'iconColor': '#FBFEF9', 'bgColor': '#222222', 'answerBgColor': '#222222', 'titleBgColor': 'rgba(255,255,255,0)', 'borderColor': '#FBFEF9', }, { 'name': 'minimal', 'mainColor': '#7a7a7a', 'textColor': '#424242', 'buttonTextColor': '#424242', 'buttonBgColor': 'rgba(0,0,0,0)', 'iconColor': '#999A9C', 'bgColor' : 'rgba(0,0,0,0)', 'answerBgColor': 'rgba(0,0,0,0)', 'titleBgColor': 'rgba(255,255,255,0)', 'borderColor': '#7a7a7a', }, ]; $(document).on('click', '.delete a[href]', function(){ return confirm('Do you want to delete?'); }); function ays_youtube_parser(url){ var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/; var match = url.match(regExp); return (match&&match[7].length==11)? match[7] : false; } function openMediaUploader(e, element) { e.preventDefault(); var aysUploader = wp.media({ title: 'Upload', button: { text: 'Upload' }, multiple: false }).on('select', function () { var attachment = aysUploader.state().get('selection').first().toJSON(); if (attachment.type != 'image') { return alert('Please load image file'); } element.text('Edit Image'); $('.ays-poll-question-image-container').fadeIn(); $('img#ays-poll-img').attr('src', attachment.url); $('input#ays-poll-image').val(attachment.url).trigger('change'); $('.apm-img-box').empty().fadeIn().append("Thank you!
','ays_result_message'); // Set alignment default value to center $(document).find('#apm-dir-center').prop('checked', true); } if (type != 'choosing') { $(document).find('.ays_poll_option_only_for_choosing_type').hide(); if (type != 'text') { $(document).find('.ays_poll_option_for_choosing_type.ays_poll_option_for_text_type').hide(); } } } function ays_tmce_setContent(content, editor_id, textarea_id) { if ( typeof editor_id == 'undefined' ) editor_id = wpActiveEditor; if ( typeof textarea_id == 'undefined' ) textarea_id = editor_id; if ( $(document).find('#wp-'+editor_id+'-wrap').hasClass('tmce-active') && tinyMCE && tinyMCE.get(editor_id) ) { return tinyMCE.get(editor_id).setContent(content); }else{ return $(document).find('#'+textarea_id).val(content); } } var pollType = $(document).find('#poll_choose_type_first').val(); $('.if-' + pollType).css('display', 'flex').find('select, input:not([type="hidden"]):not(.ays_redirect_active)').attr('data-required', true); $('.if-choosing').find('select, input:not([type="hidden"]):not(.ays_redirect_active)').attr('data-required', false); $(document).find('#ays_poll_question_text_max_length').attr('data-required', false); $(document).find('#ays_poll_text_type_placeholder').attr('data-required', false); $(document).find('#ays_poll_text_type_width').attr('data-required', false); $('.ays_poll_type_image_div:not(.apm-pro-feature)').on('click', checkType); function livePrevToChoosing(type , countSel , rateType){ if (typeof countSel == 'undefined') { countSel = 0; } if (typeof rateType == 'undefined') { countSel = ''; } $(document).find('.box-apm').removeClass().addClass('box-apm '+type+'-poll'); var content = ''; var contText = ''; var checkAnsHover = $(document).find("#ays_answer_checker").val(); var cClass = ''; var contText = ''; switch(type){ case "choosing": $(document).find(".ays-answer-value").each(function(index){ var image = $(this).parents("tr").find(".ays-poll-answer-img").attr("src"); var imageContainer = ''; var labelContainerClass = ''; var imageTextClass = ''; if(image != ""){ imageContainer = ''+ pollLangObj.formMoreDetailed +' '+ pollLangObj.editPollPage +'.
'; swal({ title: '' + pollLangObj.greateJob + '', type: 'success', html: '' + pollLangObj.youCanUuseThisShortcode + '
', showCloseButton: true, focusConfirm: false, confirmButtonText: ' '+ pollLangObj.done, confirmButtonAriaLabel: pollLangObj.thumbsUpGreat, }); aysPollDeleteCookie('ays_poll_created_new'); } function aysPollDeleteCookie(name) { document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; } // Select default category for poll $(document).find("#ays_poll_default_type").select2(); // Check if submit button clicked for unsaved changes confirmation box var subButtons = '.button#ays-button-top, .button#ays-button-top-apply, .button#ays-button, .button#ays-button-apply, .button#ays-button-cat, .button#ays_submit, .button#ays_poll_cancel_top, .button#ays_poll_cancel'; $(document).on('click', subButtons ,function () { var $this = $(this); $this.addClass('ays-submit-button-clicked'); }); var aysUnsavedChanges = false; var formInputs = '#ays-poll-form .ays-poll-tab-content input, #ays-poll-form .ays-poll-tab-content select, ' + '#ays-poll-form .ays-poll-tab-content textarea, #ays-poll-category-form input, ' + '#ays-poll-category-form select, #ays-poll-category-form textarea, ' + '#ays-poll-general-settings-form input, #ays-poll-general-settings-form select, ' + '#ays-poll-general-settings-form textarea'; $(document).on('change input', formInputs, function() { aysUnsavedChanges = true; }); $(window).on('beforeunload', function(event) { var saveButtons = $(document).find('.button#ays-button-top, .button#ays-button-top-apply, .button#ays-button, .button#ays-button-apply, .button#ays-button-cat, .button#ays_submit, .button#ays_poll_cancel_top, .button#ays_poll_cancel'); var savingButtonsClicked = saveButtons.filter('.ays-submit-button-clicked').length > 0; if (aysUnsavedChanges && !savingButtonsClicked) { event.preventDefault(); event.returnValue = true; } }); $(document).find("#ays_poll_default_cat").select2({ multiple: true }); // Create and Delete rows in Answers table $(document).on("keydown" , "input[name='ays-poll-answers[]']" , function(event) { var $thisValue = $(this).val(); if (event.keyCode === 13) { if($(this).hasClass("ays_poll_enter_key")){ var editButton = $(document).find(".ays-click-once"); editButton.trigger("click"); event.preventDefault(); } else{ var nextInput = $(this).parents("tr").next().find("td.ays-choosing-answer-container input:nth-child(1)"); nextInput.focus(); var oldValue = nextInput.val(); nextInput.val(" "); nextInput.val(oldValue); } } else if(event.keyCode === 8 && $thisValue == ""){ var editButton = $(this).parents("tr").find("a.ays-delete-answer"); editButton.trigger("click"); event.preventDefault(); } }); var drawChartLink = $(document).find(".ays_poll_answer_chart_active"); if(drawChartLink.hasClass("nav-tab-active")){ google.charts.load('current', {packages: ['corechart', 'bar']}); google.charts.setOnLoadCallback(drawBasic); } $(document).find(".ays_poll_answer_chart_active").on("click" , function(){ google.charts.load('current', {packages: ['corechart', 'bar']}); google.charts.setOnLoadCallback(drawBasic); }); // Write poll title immediately $(document).find('#ays-poll-title').on('input', function(e){ var pollTitleVal = $(this).val(); var pollTitle = aysPollstripHTML( pollTitleVal ); $(document).find('.ays_poll_title_in_top').html( pollTitle ); }); function aysPollstripHTML( dirtyString ) { var container = document.createElement('div'); var text = document.createTextNode(dirtyString); container.appendChild(text); return container.innerHTML; // innerHTML will be a xss safe string } // var theme_Ids = $('.apm-themes-row').attr('data-themeid'); if ($('#ays_poll_show_answers_icon').prop('checked') && theme_Ids != 3) { if ($('input[name="ays_poll_answer_icon"]:checked').prop('checked')) { var iconVal = $('input[name="ays_poll_answer_icon"]:checked').val(); $('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); $('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); $('.ays_label_poll').addClass('ays_poll_answer_icon_'+iconVal); }else{ $('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); $('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); } }else{ $('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); $('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); } // Answer Icon $('#ays_poll_show_answers_icon').change(function () { var themeIds = $('.apm-themes-row').attr('data-themeid'); if ($('#ays_poll_show_answers_icon').prop('checked')) { switch(parseInt(themeIds)){ case 3: $('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); $('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); break; default: var icons_val = $('input[name="ays_poll_answer_icon"]:checked').val(); $('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); $('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); $('.ays_label_poll').addClass('ays_poll_answer_icon_'+icons_val); break; } }else{ $('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); $('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); } }); $('.ays_poll_answ_icon').change(function () { if ($(this).prop('checked')) { var themesIds = $('.apm-themes-row').attr('data-themeid'); switch(parseInt(themesIds)){ case 3: $('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); $('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); break; default: var icon_val = $(this).val(); $('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); $('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); $('.ays_label_poll').addClass('ays_poll_answer_icon_'+icon_val); } }else{ $('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); $('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); } }); $(document).find('strong.ays-poll-shortcode-box').on('mouseleave', function(){ var _this = $(this); _this.attr( 'data-original-title', pollLangObj.clickForCopy ); }); // $(document).find("#ays_poll_buttons_size").select2({ // minimumResultsForSearch: -1 // }); // Button styles start // Size change $(document).find("#ays_poll_buttons_size").on("change" , function(){ var buttonsSize = $(document).find('#ays_poll_buttons_size').val(); var buttonsFontSize, buttonsLeftRightPadding, buttonsTopBottomPadding, buttonsBorderRadius; switch(buttonsSize){ case "small": buttonsFontSize = 14; buttonsLeftRightPadding = 14; buttonsTopBottomPadding = 7; buttonsBorderRadius = 3; break; case "large": buttonsFontSize = 20; buttonsLeftRightPadding = 30; buttonsTopBottomPadding = 13; buttonsBorderRadius = 3; break; default: buttonsFontSize = 17; buttonsLeftRightPadding = 20; buttonsTopBottomPadding = 10; buttonsBorderRadius = 3; break; } $(document).find('#ays_poll_buttons_font_size').val(buttonsFontSize); $(document).find('#ays_poll_buttons_left_right_padding').val(buttonsLeftRightPadding); $(document).find('#ays_poll_buttons_top_bottom_padding').val(buttonsTopBottomPadding); $(document).find('#ays_poll_buttons_border_radius').val(buttonsBorderRadius); $(document).find('input[type="button"].ays-poll-btn').css({ 'font-size' : buttonsFontSize + 'px', 'padding' : buttonsTopBottomPadding+'px '+ buttonsLeftRightPadding+'px', 'border-radius' : buttonsBorderRadius + 'px' }); }); // Buttons font size $(document).find("#ays_poll_buttons_font_size").on("change" , function(){ var buttonFontSize = $(this).val(); $(document).find('input[type="button"].ays-poll-btn').css('font-size', buttonFontSize + 'px'); }); $('.ays_buttons_padding').on('change', function () { var top_bottom = $(document).find('#ays_poll_buttons_top_bottom_padding').val(); var left_top = $(document).find('#ays_poll_buttons_left_right_padding').val(); $(document).find('input[type="button"].ays-poll-btn').css('padding', top_bottom + 'px ' + left_top +'px'); }); $('#ays_poll_buttons_width').on('change', function () { var buttons_width = $(document).find('#ays_poll_buttons_width').val(); if(buttons_width == ''){ buttons_width = 'auto'; }else{ buttons_width = buttons_width + 'px'; } $(document).find('input[type="button"].ays-poll-btn').css('width', buttons_width); }); $('#ays_poll_buttons_border_radius').on('change', function () { var val = $(this).val(); $(document).find('input[type="button"].ays-poll-btn').css('border-radius', val + 'px'); }); function checkHr(type , pollType) { var typeChecker = $(document).find(".ays_hr_on"); var textTypeChecker = $(document).find(".ays_hr_on_text"); var rangeType = $('#type_range').prop('checked'); if(!type){ typeChecker.hide(); } else{ typeChecker.show(); } if(pollType == "text"){ textTypeChecker.show(); } else{ textTypeChecker.hide(); } if(rangeType){ $(document).find(".ays_hr_check").hide(); } else{ $(document).find(".ays_hr_check").show(); } } function check_allow_add_answers_show_up() { var aa_show = $(document).find('input[type="checkbox"]#ays_poll_allow_add_answers'); let requireAdminApprovalCbState = $(document).find('input[type="checkbox"]#ays_poll_allow_answer_require').prop('checked'); if(!requireAdminApprovalCbState){ $(document).find('.ays_show_user_added').hide(); $(document).find('.ays_show_user_added_hid').each(function () { $(this).parent('.ays-sortable-answers').find('.ays_show_user_added').prop('checked', false); // $(this).val(0); }); }else{ $(document).find('.ays_show_user_added').show(); $(document).find('.ays_show_user_added_hid').each(function () { // $(this).val(1); // $(this).prop('checked', true); $(this).parent('.ays-sortable-answers').find('.ays_show_user_added').val(1); }); } } function toggleOptionsAccordion(arrowBtn) { var arrowSvg = arrowBtn.find('svg'); var accordionMainContainer = arrowBtn.parents('.ays-poll-accordion-options-main-container'); var accordionBody = accordionMainContainer.find('.ays-poll-accordion-body'); arrowSvg.toggleClass('ays-poll-accordion-arrow-active'); accordionBody.slideToggle(); } $(document).find('input[type="checkbox"]#ays_poll_allow_add_answers').on('change', function(e){ if($(this).prop('checked') == false){ // $(document).find('.allow_add_answers_not_show_up').hide(); // $(document).find('.allow_add_answers_not_show_up .ays_toggle_target').hide(250); $(document).find('#ays_poll_allow_answer_require').removeAttr('checked'); check_allow_add_answers_show_up(); }else{ $(document).find('.allow_add_answers_not_show_up').show(); check_allow_add_answers_show_up(); } }); $(document).find('input[type="checkbox"]#ays_poll_allow_answer_require').on('change', function(e){ check_allow_add_answers_show_up(); }); // Options accordion effect start $(document).on('click', '.ays-poll-accordion-header', function() { toggleOptionsAccordion($(this)); }); // Options accordion effect end $(document).find('input[type="checkbox"].ays_show_user_added').on('change', function(e){ let selectAllCb = $(document).find('input[type="checkbox"]#ays_poll_require_approve_select_all'); if($(this).prop('checked') == true){ $(this).parent().find('.ays_show_user_added_hid').val(1); var isAllChecked = 0; var allShowUserAddedCbArr = $(document).find('input[type="checkbox"].ays_show_user_added'); for (i = 0; i < allShowUserAddedCbArr.length; i++) { if(allShowUserAddedCbArr.eq(i).prop('checked')) { isAllChecked++; } } if (isAllChecked === allShowUserAddedCbArr.length && selectAllCb.prop('checked') === false) { selectAllCb.prop('checked', true); } }else{ $(this).parent().find('.ays_show_user_added_hid').val(0); if (selectAllCb.prop('checked')) { selectAllCb.prop('checked', false); } } }); $(document).find("#ays_poll_require_approve_select_all").on("change" , function(){ if($(this).prop('checked') == false){ $(document).find('.ays_show_user_added').each(function () { $(this).parent('.ays-sortable-answers').find('.ays_show_user_added').prop('checked', false); $(this).val(0); $(this).prop('checked' , false); $(document).find('.ays_show_user_added_hid').val(0); }); }else{ $(document).find('.ays_show_user_added').each(function () { $(this).val(1); $(this).prop('checked', true); $(this).parent('.ays-sortable-answers').find('.ays_show_user_added').val(1); $(document).find('.ays_show_user_added_hid').val(1); }); } }); // Add answer image (Choosing type) start $(document).on('click', 'label.ays-label a.ays-poll-add-answer-image', function (e) { openAnswerMediaUploader(e, $(this)); }); // Select Image function openAnswerMediaUploader(e, element) { e.preventDefault(); var addButton = element; var aysUploader = wp.media({ title: 'Upload', button: { text: 'Upload' }, library: { type: 'image' }, multiple: false }).on('select', function () { var attachment = aysUploader.state().get('selection').first().toJSON(); addButton.parents().eq(1).find('.ays-poll-add-answer-image').parent().css('display', 'none'); addButton.parents('td').find('.ays-poll-answer-image-container').fadeIn(); addButton.parents('td').find('img.ays-poll-answer-img').attr('src', attachment.url); addButton.parents('tr').find('input.ays-poll-answer-image-path').val(attachment.url).trigger("change"); if(addButton.hasClass('ays-poll-add-answer-image')){ addButton.parents('td').find('img').attr('src', attachment.url); addButton.parents('tr').find('input.ays-poll-answer-image').val(attachment.url); } }).open(); return false; } // Remove Image $(document).on('click', '.ays-poll-remove-answer-img', function () { var $this = $(this); $this.parent().fadeOut(); if($this.parent().hasClass('ays-poll-answer-image-container')){ setTimeout(function(){ $this.parents().eq(1).find('.ays-poll-add-answer-image').show(); $this.parents('td').find('.ays-poll-add-answer-image').parent().css('display', 'block'); $this.parents('td').find('.ays-poll-add-answer-image').css('display', 'inline-block'); $this.parent().find('img.ays-poll-answer-img').attr('src', ''); $this.parent().find('input.ays-poll-answer-image').val(''); $this.parent().find('input.ays-poll-answer-image-path').val('').trigger("change"); },300); } }); // Grid view type PRO $(document).find("#ays_answers_grid_column").on("change" , function(){ var $this = $(this); if($this.val() != 2){ $this.val(2); window.open("https://ays-pro.com/wordpress/poll-maker", '_blank'); } }); $(document).on('change', '.ays-poll-answer-image-path', function(){ livePrevToChoosing('choosing'); $(document).find('#ays-poll-border-side').trigger('change'); $(document).find('#ays_answers_view').trigger('change'); }); $(document).find(".ays-poll-text-types-type").on("change" , function(){ var $this = $(this); var textType = $this.val(); livePrevToChoosing("text" , 0 , textType); }); // Add answer image (Choosing type) end // Poll Responsive tabs start if($(document).find('.ays-top-menu').width() <= $(document).find('div.ays-top-tab-wrapper').width()){ $(document).find('.ays_menu_left').css('display', 'flex'); $(document).find('.ays_menu_right').css('display', 'flex'); } $(window).resize(function(){ if($(document).find('.ays-top-menu').width() < $(document).find('div.ays-top-tab-wrapper').width()){ $(document).find('.ays_menu_left').css('display', 'flex'); $(document).find('.ays_menu_right').css('display', 'flex'); }else{ $(document).find('.ays_menu_left').css('display', 'none'); $(document).find('.ays_menu_right').css('display', 'none'); $(document).find('div.ays-top-tab-wrapper').css('transform', 'translate(0px)'); } }); var menuItemWidths0 = []; var menuItemWidths = []; $(document).find('.ays-top-tab-wrapper .nav-tab').each(function(){ var $this = $(this); menuItemWidths0.push($this.outerWidth()); }); for(var i = 0; i < menuItemWidths0.length; i+=2){ if(menuItemWidths0.length <= i+1){ menuItemWidths.push(menuItemWidths0[i]); }else{ menuItemWidths.push(menuItemWidths0[i]+menuItemWidths0[i+1]); } } var menuItemWidth = 0; for(var i = 0; i < menuItemWidths.length; i++){ menuItemWidth += menuItemWidths[i]; } menuItemWidth = menuItemWidth / menuItemWidths.length; $(document).on('click', '.ays_menu_left', function(){ var scroll = parseInt($(this).attr('data-scroll')); scroll -= menuItemWidth; if(scroll < 0){ scroll = 0; } $(document).find('div.ays-top-tab-wrapper').css('transform', 'translate(-'+scroll+'px)'); $(this).attr('data-scroll', scroll); $(document).find('.ays_menu_right').attr('data-scroll', scroll); }); $(document).on('click', '.ays_menu_right', function(){ var scroll = parseInt($(this).attr('data-scroll')); var howTranslate = $(document).find('div.ays-top-tab-wrapper').width() - $(document).find('.ays-top-menu').width(); howTranslate += 7; if(scroll == -1){ scroll = menuItemWidth; } scroll += menuItemWidth; if(scroll > howTranslate){ scroll = Math.abs(howTranslate); } $(document).find('div.ays-top-tab-wrapper').css('transform', 'translate(-'+scroll+'px)'); $(this).attr('data-scroll', scroll); $(document).find('.ays_menu_left').attr('data-scroll', scroll); }); // Poll Responsive tabs end var checkCountdownIsExists = $(document).find('#ays-poll-maker-countdown-main-container'); // var checkCountdownIsExists = $(document).find('#ays-poll-countdown-main-container'); if ( checkCountdownIsExists.length > 0 ) { var second = 1000, minute = second * 60, hour = minute * 60, day = hour * 24; // var pollCountdownEndTime = pollLangObj.pollBannerDate; // var pollCountdownEndTime = "DEC 09, 2024 23:59:59"; var pollCountdownEndTime = "JAN 7, 2025 23:59:59"; var countDown_new = new Date(pollCountdownEndTime).getTime(); if ( isNaN(countDown_new) || isFinite(countDown_new) == false ) { var AYS_POLL_MILLISECONDS = 3 * day; var countdownStartDate = new Date(Date.now() + AYS_POLL_MILLISECONDS); var pollCountdownEndTime = countdownStartDate.aysPollCustomFormat( "#YYYY#-#MM#-#DD# #hhhh#:#mm#:#ss#" ); var countDown_new = new Date(pollCountdownEndTime).getTime(); } aysPollBannerCountdown(); var y = setInterval(function() { var now = new Date().getTime(); var distance_new = countDown_new - now; aysPollBannerCountdown(); var countDownDays = document.getElementById("ays-poll-countdown-days"); var countDownHours = document.getElementById("ays-poll-countdown-hours"); var countDownMinutes = document.getElementById("ays-poll-countdown-minutes"); var countDownSeconds = document.getElementById("ays-poll-countdown-seconds"); if(countDownDays !== null || countDownHours !== null || countDownMinutes !== null || countDownSeconds !== null){ var countDownDays_innerText = Math.floor(distance_new / (day)); var countDownHours_innerText = Math.floor((distance_new % (day)) / (hour)); var countDownMinutes_innerText = Math.floor((distance_new % (hour)) / (minute)); var countDownSeconds_innerText = Math.floor((distance_new % (minute)) / second); if( isNaN(countDownDays_innerText) || isNaN(countDownHours_innerText) || isNaN(countDownMinutes_innerText) || isNaN(countDownSeconds_innerText) ){ var headline = document.getElementById("ays-poll-countdown-headline"), countdown = document.getElementById("ays-poll-countdown"), content = document.getElementById("ays-poll-countdown-content"); // headline.innerText = "Sale is over!"; countdown.style.display = "none"; content.style.display = "block"; clearInterval(y); } else { countDownDays.innerText = countDownDays_innerText; countDownHours.innerText = countDownHours_innerText; countDownMinutes.innerText = countDownMinutes_innerText; countDownSeconds.innerText = countDownSeconds_innerText; } } //do something later when date is reached if (distance_new < 0) { var headline = document.getElementById("ays-poll-countdown-headline"), countdown = document.getElementById("ays-poll-countdown"), content = document.getElementById("ays-poll-countdown-content"); // headline.innerText = "Sale is over!"; countdown.style.display = "none"; content.style.display = "block"; clearInterval(y); } }, 1000); } function aysPollBannerCountdown(){ var now = new Date().getTime(); var distance_new = countDown_new - now; var countDownDays = document.getElementById("ays-poll-countdown-days"); var countDownHours = document.getElementById("ays-poll-countdown-hours"); var countDownMinutes = document.getElementById("ays-poll-countdown-minutes"); var countDownSeconds = document.getElementById("ays-poll-countdown-seconds"); if((countDownDays !== null || countDownHours !== null || countDownMinutes !== null || countDownSeconds !== null) && distance_new > 0){ var countDownDays_innerText = Math.floor(distance_new / (day)); var countDownHours_innerText = Math.floor((distance_new % (day)) / (hour)); var countDownMinutes_innerText = Math.floor((distance_new % (hour)) / (minute)); var countDownSeconds_innerText = Math.floor((distance_new % (minute)) / second); if( isNaN(countDownDays_innerText) || isNaN(countDownHours_innerText) || isNaN(countDownMinutes_innerText) || isNaN(countDownSeconds_innerText) ){ var headline = document.getElementById("ays-poll-countdown-headline"), countdown = document.getElementById("ays-poll-countdown"), content = document.getElementById("ays-poll-countdown-content"); // headline.innerText = "Sale is over!"; countdown.style.display = "none"; content.style.display = "block"; // clearInterval(y); } else { countDownDays.innerText = countDownDays_innerText; countDownHours.innerText = countDownHours_innerText; countDownMinutes.innerText = countDownMinutes_innerText; countDownSeconds.innerText = countDownSeconds_innerText; } // countDownDays.innerText = Math.floor(distance_new / (day)).toLocaleString(undefined,{minimumIntegerDigits: 2})+" : ", // countDownHours.innerText = Math.floor((distance_new % (day)) / (hour)).toLocaleString(undefined,{minimumIntegerDigits: 2})+" : ", // countDownMinutes.innerText = Math.floor((distance_new % (hour)) / (minute)).toLocaleString(undefined,{minimumIntegerDigits: 2})+" : ", // countDownSeconds.innerText = Math.floor((distance_new % (minute)) / second).toLocaleString(undefined,{minimumIntegerDigits: 2}); } } $(document).on('click', '#ays-polls-next-button, #ays-polls-prev-button, .ays-poll-next-prev-button-class', function(e){ e.preventDefault(); var message = $(this).data('message'); var confirm = window.confirm( message ); if(confirm === true){ window.location.replace($(this).attr('href')); } }); // CHOOSE POLL TYPE FROM MODAL START $(document).find('.ays_poll_layer_box_blocks label.ays-poll-dblclick-layer:not(.ays-poll-type-pro-feature)').on('dblclick',function(){ $(this).parents('.ays_poll_layer_container').find('.ays_poll_select_button_layer input.ays_poll_layer_button').trigger('click'); }); $(document).find('.ays-poll-content-type').on('change',function(){ $(this).parents('.ays_poll_layer_container').find('.ays_poll_select_button_layer input.ays_poll_layer_button').prop('disabled',false).attr("data-type" , $(this).val()); $(document).find('#poll_choose_type').val($(this).val()); }); $(document).find('.ays_poll_layer_button').on('click',function(){ $('.ays_poll_layer_container').css({'position':'unset' , 'display':'none'}); $(document).find('.ays-poll-show-result-chart-google').prop("checked", true); checkType($(this).attr("data-type")); }) // CHOOSE POLL TYPE FROM MODAL END $(document).find('.ays-poll-open-polls-list').on('click', function(e){ $(this).parents(".ays-poll-subtitle-main-box").find(".ays-poll-polls-data").toggle('fast'); }); $(document).find(".ays-poll-go-to-polls").on("click" , function(e){ e.preventDefault(); var confirmRedirect = window.confirm(pollLangObj.areYouSure); if(confirmRedirect){ window.location = $(this).attr("href"); } }); $(document).find('#ays_poll_reset_to_default').on('click', function (e) { e.preventDefault(); var themeId = $(document).find('.ays-poll-theme-item.apm_active_theme').next('input').val(); $(document).find('.apm-themes-row').attr('data-themeId',themeId); if ($(document).find('#ays_poll_show_answers_icon').prop('checked')) { switch(parseInt(themeId)){ case 3: $(document).find('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); $(document).find('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); break; default: var iconsVal = $('input[name="ays_poll_answer_icon"]:checked').val(); $(document).find('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); $(document).find('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); $(document).find('.ays_label_poll').addClass('ays_poll_answer_icon_'+iconsVal); break; } }else{ $(document).find('.ays_label_poll').removeClass('ays_poll_answer_icon_checkbox'); $(document).find('.ays_label_poll').removeClass('ays_poll_answer_icon_radio'); } answerStyleChange(themeId); textColorChange({ color: themes[themeId].textColor }); buttonTextColorChange({ color: themes[themeId].buttonTextColor }); buttonBgColorChange({ color: themes[themeId].buttonBgColor }); mainColorChange({ color: themes[themeId].mainColor }); bgColorChange({ color: themes[themeId].bgColor }); answerBgColorChange({ color: themes[themeId].answerBgColor }); titleBgColorChange({ color: themes[themeId].titleBgColor }); iconColorChange({ color: themes[themeId].iconColor }); borderColorChange({ color: themes[themeId].borderColor }); $(document).find('#ays-poll-text-color').parent().parent().prev().css({ 'background-color': themes[themeId].textColor }); $(document).find('#ays-poll-text-color').val(themes[themeId].textColor); $(document).find('#ays-poll-button-text-color').parent().parent().prev().css({ 'color': themes[themeId].buttonTextColor }); $(document).find('#ays-poll-button-text-color').val(themes[themeId].buttonTextColor); $(document).find('#ays-poll-button-bg-color').parent().parent().prev().css({ 'background-color': themes[themeId].buttonBgColor }); $(document).find('#ays-poll-button-bg-color').val(themes[themeId].buttonBgColor); $(document).find('#ays-poll-main-color').parent().parent().prev().css({ 'background-color': themes[themeId].mainColor }); $(document).find('#ays-poll-main-color').val(themes[themeId].mainColor); $(document).find('#ays-poll-bg-color').parent().parent().prev().css({ 'background-color': themes[themeId].bgColor }); $(document).find('#ays-poll-bg-color').val(themes[themeId].bgColor); $(document).find('#ays-poll-answer-bg-color').parent().parent().prev().css({ 'background-color': themes[themeId].answerBgColor }); $(document).find('#ays-poll-answer-bg-color').val(themes[themeId].answerBgColor); $(document).find('#ays-poll-title-bg-color').parent().parent().prev().css({ 'background-color': themes[themeId].titleBgColor }); $(document).find('#ays-poll-title-bg-color').val(themes[themeId].titleBgColor); $(document).find('#ays-poll-icon-color').parent().parent().prev().css({ 'background-color': themes[themeId].iconColor }); $(document).find('#ays-poll-icon-color').val(themes[themeId].iconColor); $(document).find('input#ays-poll-bg-image').val(''); $(document).find('#ays-poll-bg-img').attr('src', '').change(); $(document).find('.ays-poll-bg-image-container').hide().change(); $(document).find('#ays-poll-background-image-options').hide().change(); $(document).find('.add-bg-image.button').text('Add Image'); $(document).find('.add-bg-image.button').show().change(); $(document).find('.box-apm.choosing-poll').css('background-image', ''); $(document).find('#ays_poll_bg_image_position').val('center center').change(); $(document).find("#ays_poll_bg_img_in_finish_page").prop('checked' , false).change(); if(themeId == 3){ $(document).find('#ays-poll-border-side').val('none').change(); }else{ $(document).find('#ays-poll-border-side').val('all_sides').change(); } $(document).find('input#ays_answer_font_size').val('16').change(); $(document).find('input#ays_poll_answer_font_size_mobile').val('16').change(); $(document).find('input#ays_poll_answer_img_height').val('150').change(); $(document).find('input#ays_poll_answer_image_height_for_mobile').val('150').change(); $(document).find('input#ays_poll_answer_image_border_radius').val('0').change(); $(document).find('#ays_poll_image_background_size').val('cover').change(); $(document).find('input#ays_poll_answers_padding').val('10').change(); $(document).find('input#ays_poll_answers_margin').val('10').change(); $(document).find('input#ays_poll_answer_border_radius').val('0').change(); $(document).find("#ays_poll_show_answers_icon").prop('checked' , false).change(); $(document).find('#ays_answers_view').val('list').change(); $(document).find("#ays_poll_answers_box_shadow_enable").prop('checked' , false).change(); $(document).find('input#ays_poll_title_font_size').val('20').change(); $(document).find('input#ays_poll_title_font_size_mobile').val('20').change(); $(document).find('#ays_poll_title_alignment').val('center').change(); $(document).find('#ays_poll_title_alignment_mobile').val('center').change(); $(document).find("#ays_poll_enable_title_text_shadow").prop('checked' , false).change(); $(document).find('input#ays-poll-icon-size').val('24').change(); $(document).find('input#ays-poll-width').val('0').change(); $(document).find('input#ays_poll_width_for_mobile').val('0').change(); $(document).find('input#ays_poll_min_height').val('').change(); $(document).find('#ays-poll-border-style').val('ridge').change(); $(document).find('input#ays-poll-border-radius').val('0').change(); $(document).find('input#ays-poll-border-width').val('2').change(); $(document).find("#ays_poll_enable_box_shadow").prop('checked' , false).change(); $(document).find("#ays-enable-background-gradient").prop('checked' , false).change(); $(document).find('input#ays_questions_font_size').val('16').change(); $(document).find('input#ays_poll_answers_font_size_mobile').val('16').change(); $(document).find('input#ays_poll_question_image_height').val('').change(); $(document).find('#ays_poll_question_image_object_fit').val('cover').change(); $(document).find('input#ays_poll_mobile_max_width').val('').change(); $(document).find('#ays_poll_buttons_size').val('medium').change(); $(document).find('input#ays_poll_buttons_font_size').val('17').change(); $(document).find('input#ays_poll_buttons_mobile_font_size').val('17').change(); $(document).find('input#ays_poll_buttons_left_right_padding').val('20').change(); $(document).find('input#ays_poll_buttons_top_bottom_padding').val('10').change(); $(document).find('input#ays_poll_buttons_border_radius').val('3').change(); $(document).find('input#ays_poll_buttons_width').val('').change(); $(document).find("#ays_disable_answer_hover").prop('checked' , false).change(); $(document).find(".add-logo-remove-image.button").trigger('click'); $(document).find('input#ays_poll_custom_class').val('').change(); setTimeout(function(){ if($(document).find('#ays_custom_css').length > 0){ if(wp.codeEditor){ $(document).find('#ays_custom_css').next('.CodeMirror').remove(); $(document).find('#ays_custom_css').val(''); wp.codeEditor.initialize($(document).find('#ays_custom_css'), cm_settings); } } }, 100); $(document).find("#tab2").goToNormal(); }); $(document).on('mouseover', '.ays-dashicons', function(){ var allRateStars = $(document).find('.ays-dashicons'); var index = allRateStars.index(this); allRateStars.removeClass('ays-dashicons-star-filled').addClass('ays-dashicons-star-empty'); for (var i = 0; i <= index; i++) { allRateStars.eq(i).removeClass('ays-dashicons-star-empty').addClass('ays-dashicons-star-filled'); } }); $(document).on('mouseleave', '.ays-rated-link', function(){ $(document).find('.ays-dashicons').removeClass('ays-dashicons-star-filled').addClass('ays-dashicons-star-empty'); }); var aysPollListTables = $(document).find('#wpcontent #wpbody div.wrap.ays-poll-list-table'); if ( aysPollListTables.length > 0) { var listTableClass = ""; var searchBox = ""; if( aysPollListTables.hasClass('ays_polls_list_table') ){ listTableClass = 'ays_polls_list_table'; searchBox = 'poll-maker-ays-search-input'; } else if( aysPollListTables.hasClass('ays_poll_categories_list_table') ){ listTableClass = 'ays_poll_categories_list_table'; searchBox = 'poll-maker-ays-search-input'; } else if( aysPollListTables.hasClass('ays_poll_results_list_table') ){ listTableClass = 'ays_poll_results_list_table'; searchBox = 'poll-maker-ays-search-input'; } if( listTableClass != "" && searchBox != "" ){ ays_poll_search_box_pagination(listTableClass, searchBox); } } // Select message vars galleries page | Start $(document).find('.ays-poll-message-vars-icon').on('click', function(e){ $(this).parents(".ays-poll-message-vars-box").find(".ays-poll-message-vars-data").toggle('fast'); }); $(document).on( "click" , function(e){ if($(e.target).closest('.ays-poll-message-vars-box').length != 0){ } else{ $(document).find(".ays-poll-message-vars-box .ays-poll-message-vars-data").hide('fast'); } }); $(document).find('.ays-poll-message-vars-each-data').on('click', function(e){ var _this = $(this); var parent = _this.parents('.ays-poll-desc-message-vars-parent'); var textarea = parent.find('textarea.ays-textarea'); var textareaID = textarea.attr('id'); var messageVar = _this.find(".ays-poll-message-vars-each-var").val(); if ( parent.find("#wp-"+ textareaID +"-wrap").hasClass("tmce-active") ){ window.tinyMCE.get(textareaID).setContent( window.tinyMCE.get(textareaID).getContent() + messageVar + " " ); }else{ $(document).find('#'+textareaID).append( " " + messageVar + " "); } }); /* Select message vars galleries page | End */ // Check poll result as read start $(document).find('.ays-show-results').on('click', function (e) { $(document).find('#ays-results-modal').fadeIn(); $(document).find('div.ays-poll-preloader').css('display', 'flex'); var $this = $(this); var readStatus = $this.parents('tr').find("td .unread-result-badge"); $('li.toplevel_page_poll-maker-ays .apm-badge.badge-danger').each(function () { var $unreadCounter = $(this); if ($unreadCounter.text() != 0) { if(readStatus.hasClass('unread-result')){ var counter = +$unreadCounter.text(); counter--; if(counter == 0){ $unreadCounter.hide(); } $unreadCounter.text(counter); } } else{ $unreadCounter.hide(); } }); if(readStatus.hasClass('unread-result')){ readStatus.removeClass('unread-result'); } $(this).css('font-weight' , 'normal'); $(this).parent().css('font-weight' , 'normal'); $(this).parent().siblings().css('font-weight' , 'normal'); var result = $(this).data('result'); var action = 'apm_show_results'; var wp_nonce = $(document).find('#poll_maker_ajax_show_details_report_nonce').val(); $.ajax({ url: poll.ajax, dataType: 'json', method: "post", data: { result: result, action: action, _ajax_nonce: wp_nonce, is_details: 1 }, success: function(response) { if (response.status === true) { $('table#ays-results-table').html(response.rows); $(document).find('div.ays-poll-preloader').css('display', 'none'); } } }); e.preventDefault(); }); // Check poll result as read end // Close results popup start $(document).find('#ays-close-results').on('click', function () { $(document).find('#ays-results-modal').fadeOut(); }); // Close results popup end // Pro features start $(document).on('click', '.pro_features_popup', function(e){ e.preventDefault(); var _this = $(this); var popupModal = $(document).find('#pro-features-popup-modal'); var popupModal_title = _this.find('.pro-features-popup-title'); var popupModal_title_text = popupModal_title.text(); var popupModal_content = _this.find('.pro-features-popup-content').html(); var popupModal_video_link = _this.find('.pro-features-popup-content').attr("data-link"); var popupModal_button = _this.find('.pro-features-popup-button'); var popupModal_button_text = popupModal_button.text(); var popupModal_button_link = popupModal_button.attr("data-link"); var leftSection = popupModal.find('.ays-modal-body .pro-features-popup-modal-left-section'); var rightSection = popupModal.find('.ays-modal-body .pro-features-popup-modal-right-section'); rightSection.find('.pro-features-popup-modal-right-box-title').text(popupModal_title_text); rightSection.find('.pro-features-popup-modal-right-box-content').html(popupModal_content); rightSection.find('.pro-features-popup-modal-right-box-content').html(popupModal_content); rightSection.find('.pro-features-popup-modal-right-box-link').text(popupModal_button_text); rightSection.find('.pro-features-popup-modal-right-box-link').attr("href", popupModal_button_link); if ( typeof popupModal_video_link != "undefined" && popupModal_video_link != "") { var videoID = ays_youtube_parser(popupModal_video_link); var iframeHTML = ''; leftSection.html(iframeHTML); } popupModal.aysModal('show_flex'); }); $(document).on('click', '.ays-poll-new-watch-video-button-box, .ays-poll-center-big-watch-video-button-box', function(e){ e.preventDefault(); if( $(this).hasClass('ays-poll-center-big-watch-video-button-box') ){ var _this = $(this).parent().parent().find('.pro_features.pro_features_popup'); } else { var _this = $(this).parent().find('.pro_features.pro_features_popup'); } var popupModal = $(document).find('#pro-features-popup-modal'); var popupModal_title = _this.find('.pro-features-popup-title'); var popupModal_title_text = popupModal_title.text(); var popupModal_content = _this.find('.pro-features-popup-content').html(); var popupModal_video_link = _this.find('.pro-features-popup-content').attr("data-link"); var popupModal_button = _this.find('.pro-features-popup-button'); var popupModal_button_text = popupModal_button.text(); var popupModal_button_link = popupModal_button.attr("data-link"); var leftSection = popupModal.find('.ays-modal-body .pro-features-popup-modal-left-section'); var rightSection = popupModal.find('.ays-modal-body .pro-features-popup-modal-right-section'); rightSection.find('.pro-features-popup-modal-right-box-title').text(popupModal_title_text); rightSection.find('.pro-features-popup-modal-right-box-content').html(popupModal_content); rightSection.find('.pro-features-popup-modal-right-box-content').html(popupModal_content); rightSection.find('.pro-features-popup-modal-right-box-link').text(popupModal_button_text); rightSection.find('.pro-features-popup-modal-right-box-link').attr("href", popupModal_button_link); if ( typeof popupModal_video_link != "undefined" && popupModal_video_link != "") { var videoID = ays_youtube_parser(popupModal_video_link); var iframeHTML = ''; leftSection.html(iframeHTML); } popupModal.aysModal('show_flex'); }); $(document).find('.ays-close-pro-popup').on('click', function () { $(this).parents('.ays-modal').aysModal('hide_remove_video'); }); // // Pro features end })(jQuery); function selectElementContents(el) { if (window.getSelection && document.createRange) { var _this = jQuery(document).find('strong.ays-poll-shortcode-box'); var text = el.textContent; var textField = document.createElement('textarea'); textField.innerText = text; document.body.appendChild(textField); textField.select(); document.execCommand('copy'); textField.remove(); var sel = window.getSelection(); var range = document.createRange(); range.selectNodeContents(el); sel.removeAllRanges(); sel.addRange(range); _this.attr( "data-original-title", pollLangObj.copied ); _this.attr( "title", pollLangObj.copied ); _this.tooltip("show"); } else if (document.selection && document.body.createTextRange) { var textRange = document.body.createTextRange(); textRange.moveToElementText(el); textRange.select(); } } Date.prototype.aysPollCustomFormat = function( formatString){ var YYYY,YY,MMMM,MMM,MM,M,DDDD,DDD,DD,D,hhhh,hhh,hh,h,mm,m,ss,s,ampm,AMPM,dMod,th; YY = ((YYYY=this.getFullYear())+"").slice(-2); MM = (M=this.getMonth()+1)<10?('0'+M):M; MMM = (MMMM=["January","February","March","April","May","June","July","August","September","October","November","December"][M-1]).substring(0,3); DD = (D=this.getDate())<10?('0'+D):D; DDD = (DDDD=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][this.getDay()]).substring(0,3); th=(D>=10&&D<=20)?'th':((dMod=D%10)==1)?'st':(dMod==2)?'nd':(dMod==3)?'rd':'th'; formatString = formatString.replace("#YYYY#",YYYY).replace("#YY#",YY).replace("#MMMM#",MMMM).replace("#MMM#",MMM).replace("#MM#",MM).replace("#M#",M).replace("#DDDD#",DDDD).replace("#DDD#",DDD).replace("#DD#",DD).replace("#D#",D).replace("#th#",th); h=(hhh=this.getHours()); if (h==0) h=24; if (h>12) h-=12; hh = h<10?('0'+h):h; hhhh = hhh<10?('0'+hhh):hhh; AMPM=(ampm=hhh<12?'am':'pm').toUpperCase(); mm=(m=this.getMinutes())<10?('0'+m):m; ss=(s=this.getSeconds())<10?('0'+s):s; return formatString.replace("#hhhh#",hhhh).replace("#hhh#",hhh).replace("#hh#",hh).replace("#h#",h).replace("#mm#",mm).replace("#m#",m).replace("#ss#",ss).replace("#s#",s).replace("#ampm#",ampm).replace("#AMPM#",AMPM); // token: description: example: // #YYYY# 4-digit year 1999 // #YY# 2-digit year 99 // #MMMM# full month name February // #MMM# 3-letter month name Feb // #MM# 2-digit month number 02 // #M# month number 2 // #DDDD# full weekday name Wednesday // #DDD# 3-letter weekday name Wed // #DD# 2-digit day number 09 // #D# day number 9 // #th# day ordinal suffix nd // #hhhh# 2-digit 24-based hour 17 // #hhh# military/24-based hour 17 // #hh# 2-digit hour 05 // #h# hour 5 // #mm# 2-digit minute 07 // #m# minute 7 // #ss# 2-digit second 09 // #s# second 9 // #ampm# "am" or "pm" pm // #AMPM# "AM" or "PM" PM }; function drawBasic() { if(typeof pollAnswerChartObj != "undefined"){ var data = google.visualization.arrayToDataTable(pollAnswerChartObj.answerData); var rowCount = data.getNumberOfRows(); var multiply; if(rowCount < 8){ multiply = 40; } else{ multiply = 30; } var chartAreaHeight = rowCount * multiply; var chartHeight = chartAreaHeight + 80; /* === Old type === */ // var options = { // title: pollAnswerChartObj.pollTitle, // width: '100%', // fontSize: 15, // height: chartHeight, // chartArea: { // width: '75%', // height: '80%' // }, // hAxis: { // minValue: 0 // } // }; /* === New type === */ var options = { title: pollAnswerChartObj.pollTitle, width: '100%', height: chartHeight, fontSize: 15, chartArea: { width: '50%', height: '80%' }, hAxis: { minValue: 0 }, annotations: { alwaysOutside: true }, bars: 'horizontal', bar: { groupWidth: "50%" } }; var chart = new google.visualization.BarChart(document.getElementById('ays_poll_answer_chart')); // remove error // google.visualization.events.(chart, 'error', function (googleError) { // google.visualization.errors.removeError(googleError.id); // }); chart.draw(data, options); resizeChart(chart, data, options); } } function resizeChart(chart, data, options){ //create trigger to resizeEnd event jQuery(window).resize(function() { if(this.resizeTO) clearTimeout(this.resizeTO); this.resizeTO = setTimeout(function() { jQuery(this).trigger('resizeEnd'); }, 100); }); //redraw graph when window resize is completed jQuery(window).on('resizeEnd', function() { chart.draw(data, options); }); }