| @@ -285,8 +285,9 @@ | ||
| 285 | 285 | 'buttonBgColor': '#0C6291', |
| 286 | 286 | 'iconColor': '#0C6291', |
| 287 | 287 | 'bgColor': '#FBFEF9', |
| 288 | 288 | 'answerBgColor': '#FBFEF9', |
| 289 | + 'answerHoverColor': '#0C6291', | |
| 289 | 290 | 'titleBgColor': 'rgba(255,255,255,0)', |
| 290 | 291 | 'borderColor': '#0C6291', |
| 291 | 292 | }, |
| 292 | 293 | { |
| @@ -297,8 +298,9 @@ | ||
| 297 | 298 | 'buttonBgColor': '#FBFEF9', |
| 298 | 299 | 'iconColor': '#FBFEF9', |
| 299 | 300 | 'bgColor': '#222222', |
| 300 | 301 | 'answerBgColor': '#222222', |
| 302 | + 'answerHoverColor': '#FBFEF9', | |
| 301 | 303 | 'titleBgColor': 'rgba(255,255,255,0)', |
| 302 | 304 | 'borderColor': '#FBFEF9', |
| 303 | 305 | }, |
| 304 | 306 | { |
| @@ -309,8 +311,9 @@ | ||
| 309 | 311 | 'buttonBgColor': 'rgba(0,0,0,0)', |
| 310 | 312 | 'iconColor': '#999A9C', |
| 311 | 313 | 'bgColor' : 'rgba(0,0,0,0)', |
| 312 | 314 | 'answerBgColor': 'rgba(0,0,0,0)', |
| 315 | + 'answerHoverColor': '#7a7a7a', | |
| 313 | 316 | 'titleBgColor': 'rgba(255,255,255,0)', |
| 314 | 317 | 'borderColor': '#7a7a7a', |
| 315 | 318 | }, |
| 316 | 319 | ]; |
| @@ -618,8 +621,9 @@ | ||
| 618 | 621 | $(document).find('.nav-tab-wrapper a.nav-tab').on('click', function (e) { |
| 619 | 622 | var elemenetID = $(this).attr('href'); |
| 620 | 623 | var activeTab = $(this).attr('data-title'); |
| 621 | 624 | var activeTabData = $(this).attr('data-tab'); |
| 625 | + var $this = $(this); | |
| 622 | 626 | |
| 623 | 627 | $(document).find('.nav-tab-wrapper a.nav-tab').each(function () { |
| 624 | 628 | if ($(this).hasClass('nav-tab-active')) { |
| 625 | 629 | $(this).removeClass('nav-tab-active'); |
| @@ -624,9 +628,13 @@ | ||
| 624 | 628 | if ($(this).hasClass('nav-tab-active')) { |
| 625 | 629 | $(this).removeClass('nav-tab-active'); |
| 626 | 630 | } |
| 627 | 631 | }); |
| 628 | - $(this).addClass('nav-tab-active'); | |
| 632 | + | |
| 633 | + setTimeout(function() { | |
| 634 | + $this.addClass('nav-tab-active'); | |
| 635 | + }, 50); | |
| 636 | + | |
| 629 | 637 | $(document).find('.ays-poll-tab-content').each(function () { |
| 630 | 638 | $(this).css('display', 'none'); |
| 631 | 639 | }); |
| 632 | 640 | $('#ays_poll_active_tab').val(activeTab); |
| @@ -634,11 +642,13 @@ | ||
| 634 | 642 | $(document).find('#ays_poll_active_tab_results').val(activeTabData); |
| 635 | 643 | $('.ays-poll-tab-content' + elemenetID).css('display', 'block'); |
| 636 | 644 | e.preventDefault(); |
| 637 | 645 | }); |
| 646 | + | |
| 638 | 647 | $('.button-primary#ays-button').on('click', function () { |
| 639 | 648 | $('#ays_poll_active_tab').val("General"); |
| 640 | 649 | }); |
| 650 | + | |
| 641 | 651 | $('.button-primary#ays-button-top').on('click', function () { |
| 642 | 652 | $('#ays_poll_active_tab').val("General"); |
| 643 | 653 | }); |
| 644 | 654 | |
| @@ -726,47 +736,56 @@ | ||
| 726 | 736 | }); |
| 727 | 737 | borderColorChange({ |
| 728 | 738 | color: themes[themeId].borderColor |
| 729 | 739 | }); |
| 740 | + answerHoverColorChange({ | |
| 741 | + color: themes[themeId].answerHoverColor | |
| 742 | + }); | |
| 743 | + | |
| 744 | + $('#ays-poll-text-color').wpColorPicker('color', themes[themeId].textColor); | |
| 730 | 745 | $('#ays-poll-text-color').parent().parent().prev().css({ |
| 731 | 746 | 'background-color': themes[themeId].textColor |
| 732 | 747 | }); |
| 733 | - $('#ays-poll-text-color').val(themes[themeId].textColor); | |
| 734 | 748 | |
| 749 | + $('#ays-poll-button-text-color').wpColorPicker('color', themes[themeId].buttonTextColor); | |
| 735 | 750 | $('#ays-poll-button-text-color').parent().parent().prev().css({ |
| 736 | 751 | 'color': themes[themeId].buttonTextColor |
| 737 | 752 | }); |
| 753 | + | |
| 754 | + $('#ays-poll-button-bg-color').wpColorPicker('color', themes[themeId].buttonBgColor); | |
| 738 | 755 | $('#ays-poll-button-bg-color').parent().parent().prev().css({ |
| 739 | 756 | 'background-color': themes[themeId].buttonBgColor |
| 740 | 757 | }); |
| 741 | - $('#ays-poll-button-text-color').val(themes[themeId].buttonTextColor); | |
| 742 | - | |
| 743 | - $('#ays-poll-button-bg-color').val(themes[themeId].buttonBgColor); | |
| 744 | - | |
| 758 | + | |
| 759 | + $('#ays-poll-answer-hover-color').wpColorPicker('color', themes[themeId].answerHoverColor); | |
| 760 | + $('#ays-poll-answer-hover-color').closest('.wp-picker-input-wrap').prev().css({ | |
| 761 | + 'background-color': themes[themeId].answerHoverColor | |
| 762 | + }); | |
| 763 | + | |
| 764 | + $('#ays-poll-main-color').wpColorPicker('color', themes[themeId].mainColor); | |
| 745 | 765 | $('#ays-poll-main-color').parent().parent().prev().css({ |
| 746 | 766 | 'background-color': themes[themeId].mainColor |
| 747 | 767 | }); |
| 748 | - $('#ays-poll-main-color').val(themes[themeId].mainColor); | |
| 749 | 768 | |
| 769 | + $('#ays-poll-bg-color').wpColorPicker('color', themes[themeId].bgColor); | |
| 750 | 770 | $('#ays-poll-bg-color').parent().parent().prev().css({ |
| 751 | 771 | 'background-color': themes[themeId].bgColor |
| 752 | 772 | }); |
| 753 | - $('#ays-poll-bg-color').val(themes[themeId].bgColor); | |
| 754 | 773 | |
| 774 | + $('#ays-poll-answer-bg-color').wpColorPicker('color', themes[themeId].answerBgColor); | |
| 755 | 775 | $('#ays-poll-answer-bg-color').parent().parent().prev().css({ |
| 756 | 776 | 'background-color': themes[themeId].answerBgColor |
| 757 | 777 | }); |
| 758 | - $('#ays-poll-answer-bg-color').val(themes[themeId].answerBgColor); | |
| 759 | 778 | |
| 779 | + $('#ays-poll-title-bg-color').wpColorPicker('color', themes[themeId].titleBgColor); | |
| 760 | 780 | $('#ays-poll-title-bg-color').parent().parent().prev().css({ |
| 761 | 781 | 'background-color': themes[themeId].titleBgColor |
| 762 | 782 | }); |
| 763 | - $('#ays-poll-title-bg-color').val(themes[themeId].titleBgColor); | |
| 764 | 783 | |
| 784 | + $('#ays-poll-icon-color').wpColorPicker('color', themes[themeId].iconColor); | |
| 765 | 785 | $('#ays-poll-icon-color').parent().parent().prev().css({ |
| 766 | 786 | 'background-color': themes[themeId].iconColor |
| 767 | 787 | }); |
| 768 | - $('#ays-poll-icon-color').val(themes[themeId].iconColor); | |
| 769 | 788 | } |
| 770 | 789 | |
| 771 | 790 | //checkTheme(); |
| 772 | 791 | $('.ays_poll_theme_image_div:not(.apm-pro-feature)').on('click', checkTheme); |
| @@ -1013,8 +1032,15 @@ | ||
| 1013 | 1032 | $(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].answerBgColor}); |
| 1014 | 1033 | answerBgColorChange(ui); |
| 1015 | 1034 | } |
| 1016 | 1035 | }); |
| 1036 | + $(document).find('#ays-poll-answer-hover-color').wpColorPicker({ | |
| 1037 | + defaultColor: themes[themeId].answerHoverColor, | |
| 1038 | + change: function(event, ui) { | |
| 1039 | + $(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].answerHoverColor}); | |
| 1040 | + answerHoverColorChange(ui); | |
| 1041 | + } | |
| 1042 | + }); | |
| 1017 | 1043 | $(document).find('#ays-poll-title-bg-color').wpColorPicker({ |
| 1018 | 1044 | defaultColor: themes[themeId].titleBgColor, |
| 1019 | 1045 | change: function(event, ui) { |
| 1020 | 1046 | $(this).wpColorPicker({defaultColor: themes[$('.apm_active_theme+input').val()].titleBgColor}); |
| @@ -1245,8 +1271,26 @@ | ||
| 1245 | 1271 | } |
| 1246 | 1272 | |
| 1247 | 1273 | } |
| 1248 | 1274 | |
| 1275 | + function answerHoverColorChange(ui) { | |
| 1276 | + if (typeof ui == 'object') { | |
| 1277 | + var color = ui.color.toString(); | |
| 1278 | + } else { | |
| 1279 | + var color = ui; | |
| 1280 | + } | |
| 1281 | + | |
| 1282 | + if (color == 'transparent' || !$(document).find('#ays_poll_enable_answer_style').prop("checked")) { | |
| 1283 | + document.documentElement.style.setProperty('--theme-answer-hover-color', "initial"); | |
| 1284 | + } else { | |
| 1285 | + document.documentElement.style.setProperty('--theme-answer-hover-color', color); | |
| 1286 | + $('#ays-poll-answer-hover-color') | |
| 1287 | + .attr('value', color) | |
| 1288 | + .parents('.wp-picker-container') | |
| 1289 | + .find('.color-alpha').css('background-color', color); | |
| 1290 | + } | |
| 1291 | + } | |
| 1292 | + | |
| 1249 | 1293 | function titleBgColorChange(ui) { //aray |
| 1250 | 1294 | var color = ui.color.toString(); |
| 1251 | 1295 | document.documentElement.style.setProperty('--theme-title-bg-color', color); |
| 1252 | 1296 | $('#ays-poll-title-bg-color') |
| @@ -1368,10 +1412,12 @@ | ||
| 1368 | 1412 | |
| 1369 | 1413 | $(document).find('#ays_poll_enable_answer_style').on('change', function () { |
| 1370 | 1414 | var checkboxProp = $(this).prop('checked'); |
| 1371 | 1415 | var color = $(this).prop('checked') ? $(document).find('#ays-poll-answer-bg-color').val() : "transparent"; |
| 1416 | + var hoverColor = $(this).prop('checked') ? $(document).find('#ays-poll-answer-hover-color').val() : "#0C6291"; | |
| 1372 | 1417 | var side = $(this).prop('checked') ? $(document).find('#ays-poll-border-side').val() : "none"; |
| 1373 | 1418 | answerBgColorChange(color); |
| 1419 | + answerHoverColorChange(hoverColor); | |
| 1374 | 1420 | answerBorderSideChange(side); |
| 1375 | 1421 | refreshLivePreview(checkboxProp); |
| 1376 | 1422 | }); |
| 1377 | 1423 | |
| @@ -1492,9 +1538,9 @@ | ||
| 1492 | 1538 | var val = $(this).val(); |
| 1493 | 1539 | $('.apm-title-box h5').text(val); |
| 1494 | 1540 | }); |
| 1495 | 1541 | var checkAnswerStyle = $(document).find("#ays_poll_enable_answer_style").prop("checked"); |
| 1496 | - $(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 () { | |
| 1542 | + $(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_font_weight,#ays_poll_title_alignment,#ays_poll_title_text_transform,#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 () { | |
| 1497 | 1543 | var checkAnswerStyleOnChange = $(document).find("#ays_poll_enable_answer_style").prop("checked"); |
| 1498 | 1544 | refreshLivePreview(checkAnswerStyleOnChange); |
| 1499 | 1545 | }); |
| 1500 | 1546 | |
| @@ -1651,28 +1697,28 @@ | ||
| 1651 | 1697 | livePrevToChoosing('choosing'); |
| 1652 | 1698 | } |
| 1653 | 1699 | }); |
| 1654 | 1700 | |
| 1655 | - $(document).find('.poll-maker-challenge-cancel').on('click', function() { | |
| 1656 | - var challengeBox = $(this).closest('.poll-maker-challenge'); | |
| 1657 | - var wp_nonce = $(document).find('#poll_maker_ajax_challenge_cancel_nonce').val(); | |
| 1701 | + // $(document).find('.poll-maker-challenge-cancel').on('click', function() { | |
| 1702 | + // var challengeBox = $(this).closest('.poll-maker-challenge'); | |
| 1703 | + // var wp_nonce = $(document).find('#poll_maker_ajax_challenge_cancel_nonce').val(); | |
| 1658 | 1704 | |
| 1659 | - $.ajax({ | |
| 1660 | - url: poll.ajax, | |
| 1661 | - type: 'POST', | |
| 1662 | - data: { | |
| 1663 | - action: 'delete_challenge_box', | |
| 1664 | - _ajax_nonce: wp_nonce | |
| 1665 | - }, | |
| 1666 | - success: function(response) { | |
| 1667 | - var result = JSON.parse(response); | |
| 1705 | + // $.ajax({ | |
| 1706 | + // url: poll.ajax, | |
| 1707 | + // type: 'POST', | |
| 1708 | + // data: { | |
| 1709 | + // action: 'delete_challenge_box', | |
| 1710 | + // _ajax_nonce: wp_nonce | |
| 1711 | + // }, | |
| 1712 | + // success: function(response) { | |
| 1713 | + // var result = JSON.parse(response); | |
| 1668 | 1714 | |
| 1669 | - if (result.success) { | |
| 1670 | - challengeBox.remove(); | |
| 1671 | - } | |
| 1672 | - } | |
| 1673 | - }); | |
| 1674 | - }) | |
| 1715 | + // if (result.success) { | |
| 1716 | + // challengeBox.remove(); | |
| 1717 | + // } | |
| 1718 | + // } | |
| 1719 | + // }); | |
| 1720 | + // }) | |
| 1675 | 1721 | |
| 1676 | 1722 | $(document).find('#ays_poll_create_author').select2({ |
| 1677 | 1723 | placeholder: 'Select users', |
| 1678 | 1724 | minimumInputLength: 1, |
| @@ -1887,8 +1933,9 @@ | ||
| 1887 | 1933 | var answerDefaultGap = "10"; |
| 1888 | 1934 | var answerDefaultFontSize = "16"; |
| 1889 | 1935 | var answerDefaultFontSizeMobile = "16"; |
| 1890 | 1936 | var titleDefaultFontSize = "20"; |
| 1937 | + var titleDefaultFontWeight = "normal"; | |
| 1891 | 1938 | var answersBorderRadiusDefault = "0"; |
| 1892 | 1939 | |
| 1893 | 1940 | // Boxes |
| 1894 | 1941 | var imageBoxes = $(document).find('.box-apm .ays-poll-answer-image-live'); |
| @@ -1930,8 +1977,11 @@ | ||
| 1930 | 1977 | var checkTextType = $(document).find('.box-apm.text-poll').length > 0 ? true : false; |
| 1931 | 1978 | // Title font size |
| 1932 | 1979 | var titleFontSizeBox = $(document).find("#ays_poll_title_font_size"); |
| 1933 | 1980 | var titleFontSize = titleFontSizeBox.val(); |
| 1981 | + // Title font weight | |
| 1982 | + var titleFontWeightBox = $(document).find("#ays_poll_title_font_weight"); | |
| 1983 | + var titleFontWeight = titleFontWeightBox.val(); | |
| 1934 | 1984 | // Poll text type placeholder |
| 1935 | 1985 | var textPlaceholder = $(document).find("#ays_poll_text_type_placeholder"); |
| 1936 | 1986 | var textPlaceholderVal = textPlaceholder.val(); |
| 1937 | 1987 | $(document).find('.ays-poll-text-type-fields').attr('placeholder' , textPlaceholderVal); |
| @@ -1939,8 +1989,10 @@ | ||
| 1939 | 1989 | 'display': 'flex', |
| 1940 | 1990 | }); |
| 1941 | 1991 | // Title alignment |
| 1942 | 1992 | var titleAlignment = $(document).find("#ays_poll_title_alignment").val(); |
| 1993 | + // Title text transform | |
| 1994 | + var titleTextTransform = $(document).find("#ays_poll_title_text_transform").val(); | |
| 1943 | 1995 | |
| 1944 | 1996 | if(parseInt(imageHeight) < 0){ |
| 1945 | 1997 | imageHeight = 0; |
| 1946 | 1998 | $(document).find('#ays_poll_answer_img_height').val(imageHeight); |
| @@ -1982,8 +2034,10 @@ | ||
| 1982 | 2034 | answersMarginVal = answerDefaultGap; |
| 1983 | 2035 | answerFontSize = answerDefaultFontSize; |
| 1984 | 2036 | answerFontSizeMain.val(answerDefaultFontSize); |
| 1985 | 2037 | answerFontSizeMobileMain.val(answerDefaultFontSize); |
| 2038 | + titleFontWeight = titleDefaultFontWeight; | |
| 2039 | + titleFontWeightBox.val(titleDefaultFontWeight); | |
| 1986 | 2040 | answersBorderRadius = answersBorderRadiusDefault; |
| 1987 | 2041 | answersBorderRadiusMain.val(answersBorderRadiusDefault); |
| 1988 | 2042 | } |
| 1989 | 2043 | // Image Changes |
| @@ -2027,9 +2081,11 @@ | ||
| 2027 | 2081 | titleFontSizeBox.val(0); |
| 2028 | 2082 | } |
| 2029 | 2083 | $(document).find('.apm-title-box h5').css({ |
| 2030 | 2084 | "font-size" : titleFontSize + "px", |
| 2085 | + "font-weight" : titleFontWeight, | |
| 2031 | 2086 | "text-align" : titleAlignment, |
| 2087 | + "text-transform" : titleTextTransform, | |
| 2032 | 2088 | }); |
| 2033 | 2089 | if(viewType == 'list'){ |
| 2034 | 2090 | $(document).find('.grid_column_count').hide(250); |
| 2035 | 2091 | answersCont.removeClass('ays_poll_grid_view_container'); |
| @@ -2121,9 +2177,9 @@ | ||
| 2121 | 2177 | buttonsCont.hide(200); |
| 2122 | 2178 | } |
| 2123 | 2179 | }); |
| 2124 | 2180 | |
| 2125 | - $(document).find('.ays-poll-question-tab-all-filter-button-top, .ays-poll-question-tab-all-filter-button-bottom').on('click', function(e) { | |
| 2181 | + $(document).find('.ays-poll-question-tab-all-filter-button-top, .ays-poll-question-tab-all-filter-button-bottom, .description-filter-apply-top, .description-filter-apply-bottom').on('click', function(e) { | |
| 2126 | 2182 | e.preventDefault(); |
| 2127 | 2183 | var $this = $(this); |
| 2128 | 2184 | var parent = $this.parents('.tablenav'); |
| 2129 | 2185 | |
| @@ -2138,8 +2194,9 @@ | ||
| 2138 | 2194 | top_or_bottom = 'bottom'; |
| 2139 | 2195 | } |
| 2140 | 2196 | |
| 2141 | 2197 | var catFilter = $(document).find('select[name="filterby-'+ top_or_bottom +'"]').val(); |
| 2198 | + var catDescFilter = $(document).find('select[name="filterbyDescription-'+ top_or_bottom +'"]').val(); | |
| 2142 | 2199 | var authorFilter = $(document).find('select[name="filterbyauthor-'+ top_or_bottom +'"]').val(); |
| 2143 | 2200 | var typeFilter = $(document).find('select[name="filterbytype-'+ top_or_bottom +'"]').val(); |
| 2144 | 2201 | var link = location.href; |
| 2145 | 2202 | |
| @@ -2148,8 +2205,14 @@ | ||
| 2148 | 2205 | what: 'filterby', |
| 2149 | 2206 | value: catFilter |
| 2150 | 2207 | }); |
| 2151 | 2208 | } |
| 2209 | + if (typeof catDescFilter != "undefined") { | |
| 2210 | + link = catFilterForListTable(link, searchValue, { | |
| 2211 | + what: 'filterbyDescription', | |
| 2212 | + value: catDescFilter | |
| 2213 | + }); | |
| 2214 | + } | |
| 2152 | 2215 | if (typeof authorFilter != "undefined") { |
| 2153 | 2216 | link = catFilterForListTable(link, searchValue, { |
| 2154 | 2217 | what: 'filterbyauthor', |
| 2155 | 2218 | value: authorFilter |
| @@ -2172,10 +2235,11 @@ | ||
| 2172 | 2235 | for(var i = 0; i < linkModified.length; i++){ |
| 2173 | 2236 | if ( linkModified[i].split("=")[0] == "ays_result_tab" ) { |
| 2174 | 2237 | linkModified.splice(i, 1, "ays_result_tab=poststuff"); |
| 2175 | 2238 | } |
| 2176 | - if(linkModified[i].split("=")[0] == options.what){ | |
| 2239 | + if(linkModified[i].split("=")[0] == options.what || linkModified[i].split("=")[0] == 'paged'){ | |
| 2177 | 2240 | linkModified.splice(i, 1); |
| 2241 | + i--; | |
| 2178 | 2242 | } |
| 2179 | 2243 | } |
| 2180 | 2244 | linkModified = linkModified.join('&'); |
| 2181 | 2245 | if (typeof searchValue != 'undefined' && searchValue != '') { |
| @@ -2185,10 +2249,11 @@ | ||
| 2185 | 2249 | }else{ |
| 2186 | 2250 | var linkModifiedStart = link.split('?')[0]; |
| 2187 | 2251 | var linkModified = link.split('?')[1].split('&'); |
| 2188 | 2252 | for(var i = 0; i < linkModified.length; i++){ |
| 2189 | - if(linkModified[i].split("=")[0] == options.what){ | |
| 2253 | + if(linkModified[i].split("=")[0] == options.what || linkModified[i].split("=")[0] == 'paged'){ | |
| 2190 | 2254 | linkModified.splice(i, 1); |
| 2255 | + i--; | |
| 2191 | 2256 | } |
| 2192 | 2257 | } |
| 2193 | 2258 | linkModified = linkModified.join('&'); |
| 2194 | 2259 | if (typeof searchValue != 'undefined' && searchValue != '') { |
| @@ -2258,8 +2323,12 @@ | ||
| 2258 | 2323 | var closeButton = mainParent.find("button.notice-dismiss"); |
| 2259 | 2324 | var attr_plugin = $this.attr('data-plugin'); |
| 2260 | 2325 | var wp_nonce = thisParent.find('#poll-maker-ays-sale-banner').val(); |
| 2261 | 2326 | |
| 2327 | + if(typeof wp_nonce == 'undefined'){ | |
| 2328 | + wp_nonce = $(document).find('#poll-maker-ays-sale-banner').val(); | |
| 2329 | + } | |
| 2330 | + | |
| 2262 | 2331 | var data = { |
| 2263 | 2332 | action: 'ays_poll_dismiss_button', |
| 2264 | 2333 | _ajax_nonce: wp_nonce, |
| 2265 | 2334 | }; |
| @@ -2320,22 +2389,41 @@ | ||
| 2320 | 2389 | var createdNewPoll = aysPollGetCookie('ays_poll_created_new'); |
| 2321 | 2390 | if(createdNewPoll && createdNewPoll > 1){ |
| 2322 | 2391 | var url = new URL(window.location.href); |
| 2323 | 2392 | |
| 2393 | + var getCustomPostId = aysPollGetCookie('ays_poll_created_new_'+createdNewPoll+'_post_id'); | |
| 2394 | + | |
| 2395 | + var link = "#"; | |
| 2396 | + if(getCustomPostId){ | |
| 2397 | + link = getCustomPostId; | |
| 2398 | + } | |
| 2399 | + | |
| 2324 | 2400 | // Get a specific GET parameter by name |
| 2325 | 2401 | var parameterValue = url.searchParams.get("action"); |
| 2326 | - var htmlDefaultText = '<p style="margin-top:1rem;">'+ pollLangObj.formMoreDetailed +' <a href="admin.php?page=poll-maker&action=edit&id=' + createdNewPoll + '">'+ pollLangObj.editPollPage +'</a>.</p>'; | |
| 2402 | + var htmlDefaultText = '<p style="margin-top:1rem;">'+ pollLangObj.formMoreDetailed +' <a href="admin.php?page=poll-maker-ays&action=edit&poll=' + createdNewPoll + '">'+ pollLangObj.editPollPage +'</a>.</p>'; | |
| 2327 | 2403 | |
| 2404 | + var htmlContent = parameterValue && parameterValue == 'edit' ? '' : htmlDefaultText; | |
| 2405 | + | |
| 2406 | + var previewButtonSvgIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">'+ | |
| 2407 | + '<path d="M11.9999 7.21325C11.8231 7.21325 11.6535 7.28349 11.5285 7.40851C11.4035 7.53354 11.3333 7.70311 11.3333 7.87992V12.6666C11.3333 12.8434 11.263 13.013 11.138 13.138C11.013 13.263 10.8434 13.3333 10.6666 13.3333H3.33325C3.15644 13.3333 2.98687 13.263 2.86185 13.138C2.73682 13.013 2.66659 12.8434 2.66659 12.6666V5.33325C2.66659 5.15644 2.73682 4.98687 2.86185 4.86185C2.98687 4.73682 3.15644 4.66658 3.33325 4.66658H8.11992C8.29673 4.66658 8.4663 4.59635 8.59132 4.47132C8.71635 4.3463 8.78658 4.17673 8.78658 3.99992C8.78658 3.82311 8.71635 3.65354 8.59132 3.52851C8.4663 3.40349 8.29673 3.33325 8.11992 3.33325H3.33325C2.80282 3.33325 2.29411 3.54397 1.91904 3.91904C1.54397 4.29411 1.33325 4.80282 1.33325 5.33325V12.6666C1.33325 13.197 1.54397 13.7057 1.91904 14.0808C2.29411 14.4559 2.80282 14.6666 3.33325 14.6666H10.6666C11.197 14.6666 11.7057 14.4559 12.0808 14.0808C12.4559 13.7057 12.6666 13.197 12.6666 12.6666V7.87992C12.6666 7.70311 12.5963 7.53354 12.4713 7.40851C12.3463 7.28349 12.1767 7.21325 11.9999 7.21325ZM14.6133 1.74659C14.5456 1.58369 14.4162 1.45424 14.2533 1.38659C14.1731 1.35242 14.087 1.33431 13.9999 1.33325H9.99992C9.82311 1.33325 9.65354 1.40349 9.52851 1.52851C9.40349 1.65354 9.33325 1.82311 9.33325 1.99992C9.33325 2.17673 9.40349 2.3463 9.52851 2.47132C9.65354 2.59635 9.82311 2.66659 9.99992 2.66659H12.3933L5.52659 9.52658C5.4641 9.58856 5.4145 9.66229 5.38066 9.74353C5.34681 9.82477 5.32939 9.91191 5.32939 9.99992C5.32939 10.0879 5.34681 10.1751 5.38066 10.2563C5.4145 10.3375 5.4641 10.4113 5.52659 10.4733C5.58856 10.5357 5.66229 10.5853 5.74353 10.6192C5.82477 10.653 5.91191 10.6705 5.99992 10.6705C6.08793 10.6705 6.17506 10.653 6.2563 10.6192C6.33754 10.5853 6.41128 10.5357 6.47325 10.4733L13.3333 3.60659V5.99992C13.3333 6.17673 13.4035 6.3463 13.5285 6.47132C13.6535 6.59635 13.8231 6.66658 13.9999 6.66658C14.1767 6.66658 14.3463 6.59635 14.4713 6.47132C14.5963 6.3463 14.6666 6.17673 14.6666 5.99992V1.99992C14.6655 1.9128 14.6474 1.82673 14.6133 1.74659Z" fill="#007DCB"/>'+ | |
| 2408 | + '</svg>'; | |
| 2409 | + | |
| 2328 | 2410 | swal({ |
| 2329 | - title: '<strong>' + pollLangObj.greateJob + '</strong>', | |
| 2330 | - type: 'success', | |
| 2331 | - html: '<p>' + pollLangObj.youCanUuseThisShortcode + '</p><input type="text" id="ays-poll-create-new" onClick="this.setSelectionRange(0, this.value.length)" readonly value="[ays_poll id=\'' + createdNewPoll + '\']" />', | |
| 2411 | + title: '<strong class="ays-poll-maker-swal2-title">' + pollLangObj.greateJob + '</strong>', | |
| 2412 | + type: 'success', | |
| 2413 | + html: '<p class="ays-poll-maker-swal2-created-row">' + pollLangObj.youPollIsCreated + '</p><p clas="ays-poll-maker-swal2-content-text-row">' + pollLangObj.youCanUuseThisShortcode + '</p><input type="text" id="ays-poll-create-new" onClick="this.setSelectionRange(0, this.value.length)" readonly value="[ays_poll id=\'' + createdNewPoll + '\']" />' + htmlContent, | |
| 2414 | + showCancelButton: true, | |
| 2332 | 2415 | showCloseButton: true, |
| 2333 | 2416 | focusConfirm: false, |
| 2417 | + cancelButtonClass: "ays-poll-preview-popup-cancel-button", | |
| 2334 | 2418 | confirmButtonText: '<i class="ays_poll_fas ays_poll_fa_thumbs_up"></i> '+ pollLangObj.done, |
| 2335 | 2419 | confirmButtonAriaLabel: pollLangObj.thumbsUpGreat, |
| 2420 | + cancelButtonText: '<a href="'+ link +'" target="_blank">'+ pollLangObj.preivewPoll + ' ' + previewButtonSvgIcon +'</a>', | |
| 2421 | + cancelButtonAriaLabel: pollLangObj.thumbsUpGreat, | |
| 2422 | + | |
| 2336 | 2423 | }); |
| 2337 | 2424 | aysPollDeleteCookie('ays_poll_created_new'); |
| 2425 | + aysPollDeleteCookie('ays_poll_created_new_'+createdNewPoll+'_post_id'); | |
| 2338 | 2426 | } |
| 2339 | 2427 | |
| 2340 | 2428 | function aysPollDeleteCookie(name) { |
| 2341 | 2429 | document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; |
| @@ -2808,9 +2896,9 @@ | ||
| 2808 | 2896 | }); |
| 2809 | 2897 | $(document).on('click', '.ays_menu_right', function(){ |
| 2810 | 2898 | var scroll = parseInt($(this).attr('data-scroll')); |
| 2811 | 2899 | var howTranslate = $(document).find('div.ays-top-tab-wrapper').width() - $(document).find('.ays-top-menu').width(); |
| 2812 | - howTranslate += 7; | |
| 2900 | + howTranslate += 250; | |
| 2813 | 2901 | if(scroll == -1){ |
| 2814 | 2902 | scroll = menuItemWidth; |
| 2815 | 2903 | } |
| 2816 | 2904 | scroll += menuItemWidth; |
| @@ -2823,10 +2911,10 @@ | ||
| 2823 | 2911 | }); |
| 2824 | 2912 | // Poll Responsive tabs end |
| 2825 | 2913 | |
| 2826 | 2914 | |
| 2915 | + // var checkCountdownIsExists = $(document).find('#ays-poll-countdown-main-container'); | |
| 2827 | 2916 | var checkCountdownIsExists = $(document).find('#ays-poll-maker-countdown-main-container'); |
| 2828 | - // var checkCountdownIsExists = $(document).find('#ays-poll-countdown-main-container'); | |
| 2829 | 2917 | if ( checkCountdownIsExists.length > 0 ) { |
| 2830 | 2918 | var second = 1000, |
| 2831 | 2919 | minute = second * 60, |
| 2832 | 2920 | hour = minute * 60, |
| @@ -2831,11 +2919,10 @@ | ||
| 2831 | 2919 | minute = second * 60, |
| 2832 | 2920 | hour = minute * 60, |
| 2833 | 2921 | day = hour * 24; |
| 2834 | 2922 | |
| 2835 | - // var pollCountdownEndTime = pollLangObj.pollBannerDate; | |
| 2836 | - // var pollCountdownEndTime = "DEC 09, 2024 23:59:59"; | |
| 2837 | - var pollCountdownEndTime = "JAN 7, 2025 23:59:59"; | |
| 2923 | + // var pollCountdownEndTime = "DEC 05, 2025 23:59:59"; | |
| 2924 | + var pollCountdownEndTime = pollLangObj.pollBannerDate; | |
| 2838 | 2925 | var countDown_new = new Date(pollCountdownEndTime).getTime(); |
| 2839 | 2926 | if ( isNaN(countDown_new) || isFinite(countDown_new) == false ) { |
| 2840 | 2927 | var AYS_POLL_MILLISECONDS = 3 * day; |
| 2841 | 2928 | var countdownStartDate = new Date(Date.now() + AYS_POLL_MILLISECONDS); |
| @@ -2957,12 +3044,25 @@ | ||
| 2957 | 3044 | }); |
| 2958 | 3045 | |
| 2959 | 3046 | $(document).find('.ays_poll_layer_button').on('click',function(){ |
| 2960 | 3047 | $('.ays_poll_layer_container').css({'position':'unset' , 'display':'none'}); |
| 3048 | + $(document.body).removeClass('ays-poll-modal-open'); | |
| 2961 | 3049 | $(document).find('.ays-poll-show-result-chart-google').prop("checked", true); |
| 2962 | 3050 | |
| 2963 | 3051 | checkType($(this).attr("data-type")); |
| 3052 | + | |
| 3053 | + // var $checklistPanel = $(document).find('.ays-poll-checklist-panel'); | |
| 3054 | + // if ($checklistPanel.length > 0) { | |
| 3055 | + // $checklistPanel.show(); | |
| 3056 | + // } | |
| 2964 | 3057 | }) |
| 3058 | + | |
| 3059 | + // Add body class when modal is visible | |
| 3060 | + $(document).ready(function(){ | |
| 3061 | + if($('.ays_poll_layer_container').is(':visible')) { | |
| 3062 | + $(document.body).addClass('ays-poll-modal-open'); | |
| 3063 | + } | |
| 3064 | + }); | |
| 2965 | 3065 | // CHOOSE POLL TYPE FROM MODAL END |
| 2966 | 3066 | |
| 2967 | 3067 | $(document).find('.ays-poll-open-polls-list').on('click', function(e){ |
| 2968 | 3068 | $(this).parents(".ays-poll-subtitle-main-box").find(".ays-poll-polls-data").toggle('fast'); |
| @@ -3058,8 +3158,13 @@ | ||
| 3058 | 3158 | 'background-color': themes[themeId].answerBgColor |
| 3059 | 3159 | }); |
| 3060 | 3160 | $(document).find('#ays-poll-answer-bg-color').val(themes[themeId].answerBgColor); |
| 3061 | 3161 | |
| 3162 | + $(document).find('#ays-poll-answer-hover-color').closest('.wp-picker-input-wrap').prev().css({ | |
| 3163 | + 'background-color': themes[themeId].answerHoverColor | |
| 3164 | + }); | |
| 3165 | + $(document).find('#ays-poll-answer-hover-color').val(themes[themeId].answerHoverColor); | |
| 3166 | + | |
| 3062 | 3167 | $(document).find('#ays-poll-title-bg-color').parent().parent().prev().css({ |
| 3063 | 3168 | 'background-color': themes[themeId].titleBgColor |
| 3064 | 3169 | }); |
| 3065 | 3170 | $(document).find('#ays-poll-title-bg-color').val(themes[themeId].titleBgColor); |
| @@ -3100,10 +3205,13 @@ | ||
| 3100 | 3205 | $(document).find('#ays_answers_view').val('list').change(); |
| 3101 | 3206 | $(document).find("#ays_poll_answers_box_shadow_enable").prop('checked' , false).change(); |
| 3102 | 3207 | $(document).find('input#ays_poll_title_font_size').val('20').change(); |
| 3103 | 3208 | $(document).find('input#ays_poll_title_font_size_mobile').val('20').change(); |
| 3209 | + $(document).find('#ays_poll_title_font_weight').val('normal').change(); | |
| 3210 | + $(document).find('#ays_poll_title_font_weight_mobile').val('normal').change(); | |
| 3104 | 3211 | $(document).find('#ays_poll_title_alignment').val('center').change(); |
| 3105 | 3212 | $(document).find('#ays_poll_title_alignment_mobile').val('center').change(); |
| 3213 | + $(document).find('#ays_poll_title_text_transform').val('none').change(); | |
| 3106 | 3214 | $(document).find("#ays_poll_enable_title_text_shadow").prop('checked' , false).change(); |
| 3107 | 3215 | $(document).find('input#ays-poll-icon-size').val('24').change(); |
| 3108 | 3216 | $(document).find('input#ays-poll-width').val('0').change(); |
| 3109 | 3217 | $(document).find('input#ays_poll_width_for_mobile').val('0').change(); |
| @@ -3180,9 +3288,11 @@ | ||
| 3180 | 3288 | } |
| 3181 | 3289 | |
| 3182 | 3290 | // Select message vars galleries page | Start |
| 3183 | 3291 | $(document).find('.ays-poll-message-vars-icon').on('click', function(e){ |
| 3184 | - $(this).parents(".ays-poll-message-vars-box").find(".ays-poll-message-vars-data").toggle('fast'); | |
| 3292 | + var messageVarsBox = $(this).parents(".ays-poll-message-vars-box"); | |
| 3293 | + messageVarsBox.toggleClass("ays-poll-message-vars-open"); | |
| 3294 | + messageVarsBox.find(".ays-poll-message-vars-data").toggle('fast'); | |
| 3185 | 3295 | }); |
| 3186 | 3296 | |
| 3187 | 3297 | $(document).on( "click" , function(e){ |
| 3188 | 3298 | if($(e.target).closest('.ays-poll-message-vars-box').length != 0){ |
| @@ -3188,8 +3298,9 @@ | ||
| 3188 | 3298 | if($(e.target).closest('.ays-poll-message-vars-box').length != 0){ |
| 3189 | 3299 | } |
| 3190 | 3300 | else{ |
| 3191 | 3301 | $(document).find(".ays-poll-message-vars-box .ays-poll-message-vars-data").hide('fast'); |
| 3302 | + $(document).find(".ays-poll-message-vars-box").removeClass("ays-poll-message-vars-open"); | |
| 3192 | 3303 | } |
| 3193 | 3304 | }); |
| 3194 | 3305 | |
| 3195 | 3306 | $(document).find('.ays-poll-message-vars-each-data').on('click', function(e){ |
| @@ -3352,11 +3463,216 @@ | ||
| 3352 | 3463 | $(this).parents('.ays-modal').aysModal('hide_remove_video'); |
| 3353 | 3464 | }); |
| 3354 | 3465 | // // Pro features end |
| 3355 | 3466 | |
| 3467 | + $(document).on("click", ".ays-poll-cards-block .ays-poll-card__footer button.status-missing", function(e){ | |
| 3468 | + var $this = $(this); | |
| 3469 | + var thisParent = $this.parents(".ays-poll-cards-block"); | |
| 3470 | + | |
| 3471 | + $this.prop('disabled', true); | |
| 3472 | + $this.addClass('disabled'); | |
| 3473 | + | |
| 3474 | + var loader_html = '<i class="fa fa-spinner fa-spin" aria-hidden="true"></i>'; | |
| 3475 | + | |
| 3476 | + $this.html(loader_html); | |
| 3477 | + | |
| 3478 | + var attr_plugin = $this.attr('data-plugin'); | |
| 3479 | + var wp_nonce = thisParent.find('#ays_poll_ajax_install_plugin_nonce').val(); | |
| 3480 | + | |
| 3481 | + var data = { | |
| 3482 | + action: 'ays_poll_install_plugin', | |
| 3483 | + _ajax_nonce: wp_nonce, | |
| 3484 | + plugin: attr_plugin, | |
| 3485 | + type: 'plugin' | |
| 3486 | + }; | |
| 3487 | + | |
| 3488 | + $.ajax({ | |
| 3489 | + url: poll.ajax, | |
| 3490 | + method: 'post', | |
| 3491 | + dataType: 'json', | |
| 3492 | + data: data, | |
| 3493 | + success: function (response) { | |
| 3494 | + if (response.success) { | |
| 3495 | + swal.fire({ | |
| 3496 | + type: 'success', | |
| 3497 | + html: "<h4>"+ response['data']['msg'] +"</h4>" | |
| 3498 | + }).then( function(res) { | |
| 3499 | + if ( $this.hasClass('status-missing') ) { | |
| 3500 | + $this.removeClass('status-missing'); | |
| 3501 | + } | |
| 3502 | + $this.text(poll.activated); | |
| 3503 | + $this.addClass('status-active'); | |
| 3504 | + }); | |
| 3505 | + } | |
| 3506 | + else { | |
| 3507 | + swal.fire({ | |
| 3508 | + type: 'info', | |
| 3509 | + html: "<h4>"+ response['data'][0]['message'] +"</h4>" | |
| 3510 | + }).then( function(res) { | |
| 3511 | + $this.text(poll.errorMsg); | |
| 3512 | + }); | |
| 3513 | + } | |
| 3514 | + }, | |
| 3515 | + error: function(){ | |
| 3516 | + swal.fire({ | |
| 3517 | + type: 'info', | |
| 3518 | + html: "<h2>"+ poll.loadResource +"</h2><br><h6>"+ poll.somethingWentWrong +"</h6>" | |
| 3519 | + }).then( function(res) { | |
| 3520 | + $this.text(poll.errorMsg); | |
| 3521 | + }); | |
| 3522 | + } | |
| 3523 | + }); | |
| 3524 | + }); | |
| 3525 | + | |
| 3526 | + $(document).on("click", ".ays-poll-cards-block .ays-poll-card__footer button.status-installed", function(e){ | |
| 3527 | + var $this = $(this); | |
| 3528 | + var thisParent = $this.parents(".ays-poll-cards-block"); | |
| 3529 | + | |
| 3530 | + $this.prop('disabled', true); | |
| 3531 | + $this.addClass('disabled'); | |
| 3532 | + | |
| 3533 | + var loader_html = '<i class="fa fa-spinner fa-spin" aria-hidden="true"></i>'; | |
| 3534 | + | |
| 3535 | + $this.html(loader_html); | |
| 3536 | + | |
| 3537 | + var attr_plugin = $this.attr('data-plugin'); | |
| 3538 | + var wp_nonce = thisParent.find('#ays_poll_ajax_install_plugin_nonce').val(); | |
| 3539 | + | |
| 3540 | + var data = { | |
| 3541 | + action: 'ays_poll_activate_plugin', | |
| 3542 | + _ajax_nonce: wp_nonce, | |
| 3543 | + plugin: attr_plugin, | |
| 3544 | + type: 'plugin' | |
| 3545 | + }; | |
| 3546 | + | |
| 3547 | + $.ajax({ | |
| 3548 | + url: poll.ajax, | |
| 3549 | + method: 'post', | |
| 3550 | + dataType: 'json', | |
| 3551 | + data: data, | |
| 3552 | + success: function (response) { | |
| 3553 | + if( response.success ){ | |
| 3554 | + swal.fire({ | |
| 3555 | + type: 'success', | |
| 3556 | + html: "<h4>"+ response['data'] +"</h4>" | |
| 3557 | + }).then( function(res) { | |
| 3558 | + if ( $this.hasClass('status-installed') ) { | |
| 3559 | + $this.removeClass('status-installed'); | |
| 3560 | + } | |
| 3561 | + $this.text(poll.activated); | |
| 3562 | + $this.addClass('status-active disabled'); | |
| 3563 | + }); | |
| 3564 | + } else { | |
| 3565 | + swal.fire({ | |
| 3566 | + type: 'info', | |
| 3567 | + html: "<h4>"+ response['data'][0]['message'] +"</h4>" | |
| 3568 | + }); | |
| 3569 | + } | |
| 3570 | + }, | |
| 3571 | + error: function(){ | |
| 3572 | + swal.fire({ | |
| 3573 | + type: 'info', | |
| 3574 | + html: "<h2>"+ poll.loadResource +"</h2><br><h6>"+ poll.somethingWentWrong +"</h6>" | |
| 3575 | + }).then( function(res) { | |
| 3576 | + $this.text(poll.errorMsg); | |
| 3577 | + }); | |
| 3578 | + } | |
| 3579 | + }); | |
| 3580 | + }); | |
| 3581 | + | |
| 3582 | + // Replace image to YouTube embed video | |
| 3583 | + $(document).on('click', '.ays-poll-youtube-placeholder', function() { | |
| 3584 | + var videoId = $(this).data('video-id'); | |
| 3585 | + var iframe = $('<iframe>', { | |
| 3586 | + src: 'https://www.youtube.com/embed/' + videoId + '?autoplay=1', | |
| 3587 | + class: '', | |
| 3588 | + width: 560, | |
| 3589 | + height: 315, | |
| 3590 | + frameborder: 0, | |
| 3591 | + allow: 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture', | |
| 3592 | + allowfullscreen: true, | |
| 3593 | + }); | |
| 3594 | + $(this).replaceWith(iframe); | |
| 3595 | + }); | |
| 3596 | + | |
| 3356 | 3597 | })(jQuery); |
| 3357 | 3598 | |
| 3599 | +document.addEventListener("DOMContentLoaded", function() { | |
| 3600 | + var startDate = new Date("2025-09-21"); | |
| 3601 | + var endDate = new Date("2025-10-21"); | |
| 3602 | + var totalLicenses = 50; | |
| 3603 | + var progressionPattern = new Array(3, 2, 1, 4, 2, 3, 1, 2, 4, 3, 2, 1, 3, 2, 4, 1, 3, 2, 2, 3, 1, 2); | |
| 3604 | + function getCurrentProgress() { | |
| 3605 | + var today = new Date(); | |
| 3606 | + // today.setDate(today.getDate() + 1); | |
| 3607 | + var daysPassed = Math.floor((today - startDate) / (1000 * 60 * 60 * 24)); | |
| 3608 | + var usedLicenses = 0; | |
| 3609 | + for (var i = 0; i < Math.min(daysPassed, progressionPattern.length); i++) { | |
| 3610 | + usedLicenses += progressionPattern[i]; | |
| 3611 | + } | |
| 3612 | + return Math.min(usedLicenses, totalLicenses); | |
| 3613 | + } | |
| 3614 | + function updateProgress() { | |
| 3615 | + var usedLicenses = getCurrentProgress(); | |
| 3616 | + var remainingLicenses = totalLicenses - usedLicenses; | |
| 3617 | + var progressPercentage = (usedLicenses / totalLicenses) * 100; | |
| 3618 | + var remainingElement = document.getElementById("remaining-licenses"); | |
| 3619 | + var progressElement = document.getElementById("progress-fill"); | |
| 3620 | + if (remainingElement) remainingElement.textContent = remainingLicenses; | |
| 3621 | + if (progressElement) progressElement.style.width = progressPercentage + "%"; | |
| 3622 | + } | |
| 3623 | + updateProgress(); | |
| 3624 | +}); | |
| 3358 | 3625 | |
| 3626 | +// Copy to clipboard function | |
| 3627 | +function pollCopyToClipboard(text) { | |
| 3628 | + if (navigator.clipboard && window.isSecureContext) { | |
| 3629 | + navigator.clipboard.writeText(text).then(function() { | |
| 3630 | + pollShowCopyNotification(pollLangObj.successCopyCoupon); | |
| 3631 | + }).catch(function() { | |
| 3632 | + fallbackCopyTextToClipboard(text); | |
| 3633 | + }); | |
| 3634 | + } else { | |
| 3635 | + fallbackCopyTextToClipboard(text); | |
| 3636 | + } | |
| 3637 | +} | |
| 3638 | + | |
| 3639 | +function fallbackCopyTextToClipboard(text) { | |
| 3640 | + var textArea = document.createElement("textarea"); | |
| 3641 | + textArea.value = text; | |
| 3642 | + textArea.style.position = "fixed"; | |
| 3643 | + textArea.style.top = "-9999px"; | |
| 3644 | + textArea.style.left = "-9999px"; | |
| 3645 | + document.body.appendChild(textArea); | |
| 3646 | + textArea.focus(); | |
| 3647 | + textArea.select(); | |
| 3648 | + try { | |
| 3649 | + var successful = document.execCommand("copy"); | |
| 3650 | + if (successful) { | |
| 3651 | + pollShowCopyNotification(pollLangObj.successCopyCoupon); | |
| 3652 | + } else { | |
| 3653 | + pollShowCopyNotification(pollLangObj.failedCopyCoupon); | |
| 3654 | + } | |
| 3655 | + } catch (err) { | |
| 3656 | + pollShowCopyNotification(pollLangObj.failedCopyCoupon); | |
| 3657 | + } | |
| 3658 | + document.body.removeChild(textArea); | |
| 3659 | +} | |
| 3660 | + | |
| 3661 | +function pollShowCopyNotification(message) { | |
| 3662 | + var notification = document.createElement("div"); | |
| 3663 | + notification.className = "ays-poll-copy-notification show"; | |
| 3664 | + console.log(notification); | |
| 3665 | + notification.textContent = message; | |
| 3666 | + document.body.appendChild(notification); | |
| 3667 | + setTimeout(function() { | |
| 3668 | + notification.classList.remove("show"); | |
| 3669 | + setTimeout(function() { | |
| 3670 | + document.body.removeChild(notification); | |
| 3671 | + }, 300); | |
| 3672 | + }, 2000); | |
| 3673 | +} | |
| 3674 | + | |
| 3359 | 3675 | function selectElementContents(el) { |
| 3360 | 3676 | if (window.getSelection && document.createRange) { |
| 3361 | 3677 | var _this = jQuery(document).find('strong.ays-poll-shortcode-box'); |
| 3362 | 3678 | var text = el.textContent; |
| @@ -3498,5 +3814,33 @@ | ||
| 3498 | 3814 | //redraw graph when window resize is completed |
| 3499 | 3815 | jQuery(window).on('resizeEnd', function() { |
| 3500 | 3816 | chart.draw(data, options); |
| 3501 | 3817 | }); |
| 3502 | -} | |
| 3818 | +} | |
| 3819 | + | |
| 3820 | +function selectAndCopyElementContents(el) { | |
| 3821 | + if (window.getSelection && document.createRange) { | |
| 3822 | + var _this = jQuery(document).find('.ays-poll-copy-element-box'); | |
| 3823 | + | |
| 3824 | + var text = el.textContent; | |
| 3825 | + var textField = document.createElement('textarea'); | |
| 3826 | + | |
| 3827 | + textField.innerText = text; | |
| 3828 | + document.body.appendChild(textField); | |
| 3829 | + textField.select(); | |
| 3830 | + document.execCommand('copy'); | |
| 3831 | + textField.remove(); | |
| 3832 | + | |
| 3833 | + var selection = window.getSelection(); | |
| 3834 | + selection.setBaseAndExtent(el,0,el,1); | |
| 3835 | + | |
| 3836 | + _this.attr( "data-original-title", pollLangObj.copied ); | |
| 3837 | + _this.attr( "title", pollLangObj.copied ); | |
| 3838 | + | |
| 3839 | + _this.tooltip("show"); | |
| 3840 | + | |
| 3841 | + } else if (document.selection && document.body.createTextRange) { | |
| 3842 | + var textRange = document.body.createTextRange(); | |
| 3843 | + textRange.moveToElementText(el); | |
| 3844 | + textRange.select(); | |
| 3845 | + } | |
| 3846 | +} | |