PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 6.3.5
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v6.3.5
6.4.9 6.4.8 6.4.7 6.4.6 6.4.5 6.4.4 6.4.3 6.4.2 6.4.1 6.4.0 6.3.9 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 All 152 releases
poll-maker / admin / js / poll-maker-poll-quick-start.js

poll-maker-poll-quick-start.js in Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls 6.3.5, at admin/js/poll-maker-poll-quick-start.js

70 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($) {
2 $(document).ready(function () {
3
4 $(document).find('#ays_create_quick_poll').on('click', function () {
5 $('#ays-poll-quick-create').aysModal('show');
6 });
7
8 $(document).find('.ays-close-quick-create').on('click', hideModalContainer);
9 $(document).find('#ays-poll-quick-create').on('click', hideModalContainer);
10
11 $(document).find('#ays-poll-quick-create-content').on('click', function (e) {
12 e.stopPropagation();
13 });
14
15 $(document).keydown(function (e) {
16 // ESCAPE key pressed
17 if ($('.ays_poll_modal').css('display') != 'none' && e.keyCode == 27) {
18 hideModalContainer();
19 }
20 });
21
22 $(document).find('.quick_poll_answer_remove').on('click', function () {
23 var answerBoxesArr = $(document).find('.quick_poll_answer_box');
24 var answerBoxesAmount = answerBoxesArr.length;
25
26 if (answerBoxesAmount > 2) {
27 $(this).parent().remove();
28 } else {
29 swal.fire({
30 type: 'info',
31 html: '<h2>Sorry minimum count of answers should be 2</h2>'
32 });
33 }
34 })
35
36 $(document).find('.quick_poll_add_option').on('click', function () {
37 var answerBoxesArr = $(document).find('.quick_poll_answer_box');
38 var lastAnswerBox = answerBoxesArr.eq(answerBoxesArr.length - 1);
39 var lastInputID = lastAnswerBox.children('input').attr('data-id');
40
41 var clonedElement = lastAnswerBox.clone(true);
42 var clonedInputID = Number(lastInputID) + 1;
43 clonedElement.children('input').attr('data-id', clonedInputID);
44 clonedElement.children('input').val('');
45
46 clonedElement.insertBefore($(this));
47 })
48
49 $(document).find('#allow_multivote_switch').on('change', function () {
50 var multivoteSettingsDiv = $(document).find('.quick_poll_multivote_settings');
51 var multivoteSettingsInputArr = multivoteSettingsDiv.children();
52
53 if ($(this).is(':checked')) {
54 multivoteSettingsDiv.css('visibility', 'visible');
55 multivoteSettingsInputArr.css('visibility', 'visible');
56 } else {
57 multivoteSettingsInputArr.css('visibility', 'visible');
58 multivoteSettingsInputArr.css('visibility', 'hidden');
59 multivoteSettingsDiv.children().eq(0).val('');
60 multivoteSettingsDiv.children().eq(1).val('');
61 }
62 })
63
64 function hideModalContainer() {
65 $(document).find('.ays_poll_modal').aysModal('hide');
66 }
67
68 });
69 })(jQuery);
70