Changeset 2622618
- Timestamp:
- 11/01/2021 06:06:35 AM (4 years ago)
- Location:
- quiz-cat/trunk
- Files:
-
- 15 edited
-
includes/block.js (modified) (2 diffs)
-
includes/editor/editor.js (modified) (6 diffs)
-
includes/editor/editor.min.js (modified) (1 diff)
-
includes/editor/editor.php (modified) (9 diffs)
-
includes/functions.php (modified) (2 diffs)
-
includes/post-type.php (modified) (2 diffs)
-
includes/quiz/quiz.js (modified) (1 diff)
-
includes/quiz/quiz.min.js (modified) (1 diff)
-
includes/quiz/quiz.php (modified) (4 diffs)
-
quizcat.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
readmes/business.txt (modified) (2 diffs)
-
readmes/elite.txt (modified) (2 diffs)
-
readmes/free.txt (modified) (2 diffs)
-
readmes/personal.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
quiz-cat/trunk/includes/block.js
r2566881 r2622618 18 18 BlockControls, 19 19 { 20 key: ' controls'20 key: 'qc-controls' 21 21 }, 22 22 createElement( … … 50 50 ), 51 51 createElement( wp.serverSideRender, { 52 key: ' ssr',52 key: 'qc_ssr', 53 53 block: 'quiz-cat/gutenblock', 54 54 attributes: props.attributes, -
quiz-cat/trunk/includes/editor/editor.js
r2566881 r2622618 159 159 $(this).addClass('nav-tab-active').blur() 160 160 161 $('#fca_qc_description_meta_box, #fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box, #fca_qc_questions_meta_box, #fca_qc_add_result_meta_box, #fca_qc_personality_questions_meta_box, #fca_qc_add_personality_result_meta_box, #fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_ custom_css_meta_box').hide()161 $('#fca_qc_description_meta_box, #fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box, #fca_qc_questions_meta_box, #fca_qc_add_result_meta_box, #fca_qc_personality_questions_meta_box, #fca_qc_add_personality_result_meta_box, #fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_translations_meta_box, #fca_qc_custom_css_meta_box').hide() 162 162 $('#fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_email_optin_meta_box').show() 163 163 … … 168 168 $(this).addClass('nav-tab-active').blur() 169 169 170 $('#fca_qc_description_meta_box, #fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box, #fca_qc_questions_meta_box, #fca_qc_add_result_meta_box, #fca_qc_personality_questions_meta_box, #fca_qc_add_personality_result_meta_box, #fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_ email_optin_meta_box').hide()170 $('#fca_qc_description_meta_box, #fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box, #fca_qc_questions_meta_box, #fca_qc_add_result_meta_box, #fca_qc_personality_questions_meta_box, #fca_qc_add_personality_result_meta_box, #fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_translations_meta_box, #fca_qc_email_optin_meta_box').hide() 171 171 $('#fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_custom_css_meta_box').show() 172 172 … … 185 185 }) 186 186 187 $('#translations-nav').click(function(){ 188 $('.nav-tab-active').removeClass('nav-tab-active') 189 $(this).addClass('nav-tab-active').blur() 190 191 $('#fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_email_optin_meta_box, #fca_qc_description_meta_box, #fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box, #fca_qc_questions_meta_box, #fca_qc_add_result_meta_box, #fca_qc_personality_questions_meta_box, #fca_qc_add_personality_result_meta_box, #fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_custom_css_meta_box').hide() 192 $('#fca_qc_translations_meta_box').show() 193 194 }) 195 187 196 //THE ADD QUESTION BUTTON 188 197 $( '#fca_qc_add_question_btn' ).click(function() { … … 262 271 var $ = jQuery 263 272 264 $('#fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_email_optin_meta_box, #fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_ custom_css_meta_box').hide()273 $('#fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_email_optin_meta_box, #fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_translations_meta_box, #fca_qc_custom_css_meta_box').hide() 265 274 $('#fca_qc_description_meta_box, #fca_qc_quiz_type_meta_box').show() 266 275 … … 597 606 //DRAG AND DROP SUPPORT 598 607 var dragCheck = false; 608 var screen_y = 0 599 609 function add_drag_and_drop_sort() { 600 610 var $ = jQuery 601 611 612 // fix moving screen glitch on drag 613 $( '.fca_qc_sortable_questions, .fca_qc_sortable_results' ).on( 'mouseover', function(){ 614 screen_y = window.scrollY 615 }) 616 602 617 $( '.fca_qc_sortable_results, .fca_qc_sortable_questions, .fca_qc_question_input_div' ).sortable({ 603 618 revert: true, 604 619 cancel: ':input,button, .fca-wysiwyg-html', 605 start: function(){ 620 start: function( e ){ 621 window.scrollTo( 0, screen_y ) 606 622 // On drag set that flag to true 607 623 dragCheck = true 608 624 }, 609 stop: function( ){625 stop: function( ){ 610 626 // On stop of dragging reset the flag back to false 611 627 dragCheck = false 612 628 //REDRAW WYSIWYG CAUSE IT BREAKS DRAG 613 fca_attach_wysiwyg() 614 } 615 616 }) 617 629 if( $( this ).hasClass( 'fca_qc_sortable_results' ) ){ 630 fca_attach_wysiwyg() 631 } 632 } 633 634 }) 635 618 636 $( '.fca_qc_sortable_results' ).unbind( 'sortupdate' ) 619 637 $( '.fca_qc_sortable_results' ).on( 'sortupdate', function( event, ui ) { … … 621 639 }) 622 640 641 623 642 $( '.fca_qc_sortable_questions' ).unbind( 'sortupdate' ) 624 643 $( '.fca_qc_sortable_questions' ).on( 'sortupdate', function( event, ui ) { 625 644 setQuestionNumbers( $(this) ) 626 627 645 }) 628 646 -
quiz-cat/trunk/includes/editor/editor.min.js
r2566881 r2622618 1 function selectQuiz(_){var a=jQuery;a("#fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_email_optin_meta_box, #fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_ custom_css_meta_box").hide(),a("#fca_qc_description_meta_box, #fca_qc_quiz_type_meta_box").show(),"mc"===_&&(a("#fca_qc_quiz_type").val(_),a("#fca_qc_quiz_type_meta_box").hide(),a("#fca_qc_add_personality_result_meta_box, #fca_qc_personality_questions_meta_box").hide(),a("#fca_qc_answer_mode_tr").show(),a("#fca_qc_questions_meta_box, #fca_qc_add_result_meta_box").show(),a("#fca_qc_hints_toggle_tr").show(),a("#fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box").hide()),"pt"===_&&(a("#fca_qc_quiz_type").val(_),a("#fca_qc_quiz_type_meta_box").hide(),a("#fca_qc_questions_meta_box, #fca_qc_add_result_meta_box").hide(),a("#fca_qc_answer_mode_tr").hide(),a("#fca_qc_add_personality_result_meta_box, #fca_qc_personality_questions_meta_box").show(),a("#fca_qc_hints_toggle_tr").hide(),a("#fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box").hide()),"wq"===_&&(a("#fca_qc_quiz_type").val(_),a("#fca_qc_quiz_type_meta_box").hide(),a("#fca_qc_add_personality_result_meta_box, #fca_qc_personality_questions_meta_box").hide(),a("#fca_qc_questions_meta_box, #fca_qc_add_result_meta_box").hide(),a("#fca_qc_answer_mode_tr").hide(),a("#fca_qc_hints_toggle_tr").hide(),a("#fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box").show())}function attach_add_answer_button_handlers_free(){var _=jQuery;_(".fca_qc_add_answer_btn").unbind("click"),_(".fca_qc_add_answer_btn").click(function(){var a=parseInt(_(this).siblings(".fca_qc_answer_input_div").length+1),e=parseInt(_(this).closest(".fca_qc_question_item").attr("id").replace(/[^0-9.]/g,"")),t=fcaQcAdminData.answerDiv.replace(/{{ANSWER_NUMBER}}/g,a);t=(t=t.replace(/{{QUESTION_NUMBER}}/g,e)).replace(/{{ID}}/g,fca_qc_new_GUID()),_(this).before(t),attach_delete_button_handlers(),attach_image_upload_handlers()})}function attach_delete_button_handlers(){var _=jQuery;_(".fca_qc_delete_icon").unbind("click"),_(".fca_qc_delete_icon_confirm").click(function(){_(this).closest("."+_(this).data("target")).remove(),_(this.parentNode).hasClass("fca_qc_personality_result_item")?add_result_personality_result_text_handlers():setScoreRanges()}),_(".fca_qc_delete_icon_cancel").click(function(){_(this).hide().siblings(".fca_qc_delete_icon").hide(),_(this).siblings(".fca_qc_delete_button").show()}),_(".fca_qc_delete_button").click(function(){_(this).siblings(".fca_qc_delete_icon").show(),_(this).hide()})}function add_result_heading_text_handlers(){var _=jQuery;_(".fca_qc_quiz_result").unbind("keyup"),_(".fca_qc_quiz_result").keyup(function(){_(this).closest(".fca_qc_result_input_div").siblings(".fca_qc_result_label").children(".fca_qc_result_score_title").html(_(this).val())}),setScoreRanges()}function add_question_heading_text_handlers(){var _=jQuery;_(".fca_qc_question_text").unbind("keyup"),_(".fca_qc_question_text").keyup(function(){_(this).closest(".fca_qc_question_input_div").prev().children(".fca_qc_quiz_heading_text").html(_(this).val())})}function add_question_and_result_click_toggles(){var _=jQuery;_(".fca_qc_question_item, .fca_qc_result_item").unbind("click"),_(".fca_qc_question_item").click(function(a){var e=_(a.target).hasClass("fca_qc_delete_icon");!1!==dragCheck||e||(_(".fca_qc_question_input_div").not(_(this).find(".fca_qc_question_input_div")).hide(),_(this).find(".fca_qc_question_input_div").toggle("fast"))}),_(".fca_qc_result_item").click(function(a){var e=_(a.target).hasClass("fca_qc_delete_icon");!1!==dragCheck||e||(_(".fca_qc_result_input_div").not(_(this).find(".fca_qc_result_input_div")).hide(),_(this).find(".fca_qc_result_input_div").toggle("fast"))}),_(".fca_qc_question_input_div, .fca_qc_result_input_div, .fca_qc_delete_icon").bind("click",function(_){_.stopPropagation()})}function fca_qc_save_question_json(_){var a=jQuery;a("#editor-nav").click();var e=[],t=a(".fca_qc_question_item:visible");a(t).each(function(){correctAnswer=1,answer=1,a(this).find(".fca_qc_answer_input_div").each(function(){if("Correct Answer"===a(this).find(".fca_qc_answer_header").text()){correctAnswer=answer;fcaQcAdminData.answerDiv.replace(/{{CORRECT_ANSWER}}/g,correctAnswer)}answer+=1});var _=[];a(this).find(".fca_qc_answer_input_div").each(function(){_.push({answer:a(this).find(".fca_qc_question_texta").val(),img:a(this).find(".fca_qc_image_input").val(),id:a(this).find(".fca_qc_id").val(),points:a(this).find(".fca_qc_weighted_question_points").val(),hint:a(this).find(".fca_qc_hint_tr .fca_qc_question_texta").val(),results:a(this).find(".fca_qc_multiselect").val()})}),e.push({question:a(this).find(".fca_qc_question_text").val(),img:a(this).find(".fca_qc_image_input").val(),correct:correctAnswer,id:a(this).find(".fca_qc_id").val(),answers:_})}),a("#fca_qc_questions_json").val(JSON.stringify(e))}function fca_qc_save_result_json(_){var a=jQuery,e=[];a(".fca_qc_result_item:visible").each(function(){e.push({title:a(this).find(".fca_qc_quiz_result").val(),desc:a(this).find(".fca-wysiwyg-html").val(),img:a(this).find(".fca_qc_image").attr("src"),min:a(this).find(".fca_qc_result_min").val(),max:a(this).find(".fca_qc_result_max").val(),url:a(this).find(".fca_qc_url_input").val(),tags:a(this).find(".fca_qc_results_tags").val(),groups:a(this).find(".fca_qc_mailchimp_groups").val(),id:a(this).find(".fca_qc_id").val()})}),a("#fca_qc_results_json").val(JSON.stringify(e))}function setScoreRanges(){var _=jQuery,a=_(".fca_qc_question_item:visible").length,e=_(".fca_qc_result_item:visible").length;if("wq"===_("#fca_qc_quiz_type").val()){var t=[];_(".fca_qc_question_item:visible").each(function(){var a=0;_(this).find(".fca_qc_weighted_question_points").each(function(){Number(_(this).val())>a&&(a=_(this).val())}),t.push(a)}),a=t.reduce(function(_,a){return Number(_)+Number(a)})}var c=a%e;_(".fca_qc_result_item:visible").each(function(t,i){var s=0;if(t>0&&(s=1+Number(_(i).prev().find(".fca_qc_result_max").val())),c)if(t<=c)n=s+Math.floor(a/e);else n=s-1+Math.floor(a/e);else var n=(t+1)*Math.floor(a/e);_(i).find(".fca_qc_result_min").val(s),_(i).find(".fca_qc_result_max").val(n);var o=s+"-"+n+" "+fcaQcAdminData.points_string+": ";s===n&&(o=s+" "+fcaQcAdminData.points_string+": "),s>n&&(o=fcaQcAdminData.unused_string),_(i).find(".fca_qc_result_score_value").html(o)})}function setQuestionNumbers(_){var a=jQuery,e=1;_.find(".fca_qc_question_item").each(function(){a(this).find(".fca_qc_quiz_heading_question_number").html(fcaQcAdminData.question_string+" "+e+": "),e+=1})}function attach_image_upload_handlers(){var _=jQuery;_(".fca_qc_quiz_image_upload_btn, .fca_qc_image, .fca_qc_quiz_image_change_btn").unbind("click"),_(".fca_qc_quiz_image_upload_btn, .fca_qc_image, .fca_qc_quiz_image_change_btn").click(function(a){a.preventDefault();var e=_(this);_(this).hasClass("fca_qc_quiz_image_change_btn")?e=_(this.parentNode).siblings(".fca_qc_quiz_image_upload_btn"):_(this).hasClass("fca_qc_image")&&(e=_(this).siblings(".fca_qc_quiz_image_upload_btn"));var t=wp.media({frame:"post",title:fcaQcAdminData.selectImage_string,multiple:!1}).open().on("insert",function(){var _=t.state().get("selection").first(),a=t.state().display(_).toJSON(),c=(_=_.toJSON()).sizes[a.size].url;c&&(e.siblings(".fca_qc_image_input").attr("value",c),e.siblings(".fca_qc_image").attr("src",c),e.siblings(".fca_qc_image_hover_controls").find(".fca_qc_quiz_image_change_btn").show(),e.siblings(".fca_qc_image_hover_controls").find(".fca_qc_quiz_image_revert_btn").show()),e.hide()})}),_(".fca_qc_quiz_image_revert_btn").unbind("click"),_(".fca_qc_quiz_image_revert_btn").click(function(a){_(this.parentNode).siblings(".fca_qc_image_input").attr("value",""),_(this.parentNode).siblings(".fca_qc_image").attr("src",""),_(this.parentNode).siblings(".fca_qc_quiz_image_upload_btn").show(),_(this).hide(),_(this).siblings(".fca_qc_quiz_image_upload_btn").hide()})}function add_drag_and_drop_sort(){var _=jQuery;_(".fca_qc_sortable_results, .fca_qc_sortable_questions, .fca_qc_question_input_div").sortable({revert:!0,cancel:":input,button, .fca-wysiwyg-html",start:function(){dragCheck=!0},stop:function(){dragCheck=!1,fca_attach_wysiwyg()}}),_(".fca_qc_sortable_results").unbind("sortupdate"),_(".fca_qc_sortable_results").on("sortupdate",function(_,a){setScoreRanges()}),_(".fca_qc_sortable_questions").unbind("sortupdate"),_(".fca_qc_sortable_questions").on("sortupdate",function(a,e){setQuestionNumbers(_(this))})}function fca_qc_new_GUID(){var _=4294967296*Math.random()>>>0,a=4294967296*Math.random()>>>0,e=4294967296*Math.random()>>>0,t=4294967296*Math.random()>>>0;return fca_qc_hash_seed[255&_]+fca_qc_hash_seed[_>>8&255]+fca_qc_hash_seed[_>>16&255]+fca_qc_hash_seed[_>>24&255]+"-"+fca_qc_hash_seed[255&a]+fca_qc_hash_seed[a>>8&255]+"-"+fca_qc_hash_seed[a>>16&15|64]+fca_qc_hash_seed[a>>24&255]+"-"+fca_qc_hash_seed[63&e|128]+fca_qc_hash_seed[e>>8&255]+"-"+fca_qc_hash_seed[e>>16&255]+fca_qc_hash_seed[e>>24&255]+fca_qc_hash_seed[255&t]+fca_qc_hash_seed[t>>8&255]+fca_qc_hash_seed[t>>16&255]+fca_qc_hash_seed[t>>24&255]}function fca_qc_attach_radio_selects(){var _=jQuery;_(".qc_radio_input").change(function(){_(this).closest(".radio-toggle").children("label").removeClass("selected"),_(this).closest("label").addClass("selected")})}jQuery(document).ready(function(_){_(".meta-box-sortables").sortable({disabled:!0}),_(".postbox .hndle").css("cursor","pointer"),fca_qc_attach_radio_selects(),_(".fca_qc_custom_css").length>0&&wp.codeEditor.initialize(_(".fca_qc_custom_css"),fcaQcAdminData.code_editor);var a=_(".fca_qc_question_item").length,e=_(".fca_qc_result_item ").length;""===_("#post_name").val()&&_("#post_name").val(_("#post_ID").val()),0===_("#fca_qc_quiz_type_meta_box").length&&_("#fca_qc_questions_meta_box, #fca_qc_add_result_meta_box").show(),_(".onoffswitch-inner").each(function(){_(this).attr("data-content-on",fcaQcAdminData.on_string),_(this).attr("data-content-off",fcaQcAdminData.off_string)}),_(".fca_qc_question_input_div").length>1&&_(".fca_qc_question_input_div").hide(),_(".fca_qc_result_input_div").length>1&&_(".fca_qc_result_input_div").hide();var t='<button type="submit" class="button-primary" id="fca_qc_submit_button">'+fcaQcAdminData.save_string+"</buttton>",c='<button type="button" class="button-secondary" id="fca_qc_preview_button">'+fcaQcAdminData.preview_string+"</buttton>";_("#normal-sortables").append(t);var i="";_(".postbox .inside textarea, .fca_qc_input_wide, .fca_qc_text_input").each(function(_,a){i+=a.value}),_(".postbox .inside .onoffswitch-checkbox").each(function(_,a){i+=a.checked}),_(window).bind("beforeunload",function(a){var e="";if(_(".postbox .inside textarea, .fca_qc_input_wide, .fca_qc_text_input").each(function(_,a){e+=a.value}),_(".postbox .inside .onoffswitch-checkbox").each(function(_,a){e+=a.checked}),i!=e)return!0}),_("#fca_qc_submit_button").click(function(a){_(window).unbind("beforeunload");_(this).closest("form").removeAttr("target"),_("#fca_qc_quiz_preview_url").val("")}),_("#post").submit(function(a){fca_qc_save_question_json(_("#post")),fca_qc_save_result_json(_("#post"))}),_("#normal-sortables").append(c),_("#fca_qc_preview_button").click(function(a){a.preventDefault();var e=_(this).closest("form");e.prop("target","_blank"),fca_qc_save_question_json(e),fca_qc_save_result_json(e),e.submit()}),_("#submitdiv").hide(),_(".fca_qc_image").each(function(a){""!==_(this).attr("src")&&_(this).siblings(".fca_qc_quiz_image_upload_btn").hide()}),jQuery.widget.bridge("jQueryUITooltipFCAQC",jQuery.ui.tooltip),_(".fca_qc_tooltip").jQueryUITooltipFCAQC({position:{my:"left",at:"right+2"}}),_("#wpbody-content").show(),_("#fca-quiz-select-multiplechoice").click(function(_){selectQuiz("mc"),setScoreRanges()}),_("#fca-quiz-select-personality").click(function(_){selectQuiz("pt"),setScoreRanges()}),_("#fca-quiz-select-weighted").click(function(_){selectQuiz("wq"),setScoreRanges()}),_("#editor-nav").click(),_("#editor-nav").click(function(){_(".nav-tab-active").removeClass("nav-tab-active"),_(this).addClass("nav-tab-active").blur(),selectQuiz(_("#fca_qc_quiz_type").val())}).click(),_("#settings-nav").click(function(){_(".nav-tab-active").removeClass("nav-tab-active"),_(this).addClass("nav-tab-active").blur(),_("#fca_qc_description_meta_box, #fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box, #fca_qc_questions_meta_box, #fca_qc_add_result_meta_box, #fca_qc_personality_questions_meta_box, #fca_qc_add_personality_result_meta_box, #fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_custom_css_meta_box").hide(),_("#fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_email_optin_meta_box").show()}),_("#appearance-nav").click(function(){_(".nav-tab-active").removeClass("nav-tab-active"),_(this).addClass("nav-tab-active").blur(),_("#fca_qc_description_meta_box, #fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box, #fca_qc_questions_meta_box, #fca_qc_add_result_meta_box, #fca_qc_personality_questions_meta_box, #fca_qc_add_personality_result_meta_box, #fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_email_optin_meta_box").hide(),_("#fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_custom_css_meta_box").show(),"mc"===_("#fca_qc_quiz_type").val()?_(".fca_qc_hide_answers_input").each(function(){_(this).prop("checked")&&"hide"===_(this).val()?_("#fca_qc_rwpanel_appearance_meta_box").hide():_("#fca_qc_rwpanel_appearance_meta_box").show()}):_("#fca_qc_rwpanel_appearance_meta_box").hide()}),_("#fca_qc_add_question_btn").click(function(){a+=1,_(".fca_qc_question_input_div").hide();for(var e=fcaQcAdminData.questionDiv.replace(/{{QUESTION_NUMBER}}/g,a);-1!==e.indexOf("{{ID}}");)e=e.replace(/{{ID}}/,fca_qc_new_GUID());_(this).siblings(".fca_qc_sortable_questions").append(e),add_drag_and_drop_sort(),add_question_heading_text_handlers(),add_question_and_result_click_toggles(),attach_delete_button_handlers(),attach_image_upload_handlers(),attach_add_answer_button_handlers_free(),setScoreRanges(),setQuestionNumbers(_(this).siblings(".fca_qc_sortable_questions")),_("#fca_qc_explanations").change()}),_("#fca_qc_add_result_btn").click(function(){e+=1,_(".fca_qc_result_input_div").hide();var a=fcaQcAdminData.resultDiv.replace(/{{RESULT_NUMBER}}/g,e);a=a.replace(/{{ID}}/g,fca_qc_new_GUID()),_(this).siblings(".fca_qc_sortable_results").append(a),add_drag_and_drop_sort(),add_question_and_result_click_toggles(),attach_delete_button_handlers(),attach_image_upload_handlers(),add_result_heading_text_handlers(),setScoreRanges(),fca_attach_wysiwyg()}),_(".fca_qc_shortcode_input").click(function(_){this.select()}),_("#fca_qc_shortcode_label").click(function(a){_(".fca_qc_shortcode_input").select()}),_(".fca_qc_admin_label").click(function(a){_(this).next().focus()}),add_drag_and_drop_sort(),add_question_and_result_click_toggles(),add_question_heading_text_handlers(),add_result_heading_text_handlers(),attach_delete_button_handlers(),attach_add_answer_button_handlers_free(),setScoreRanges(),attach_image_upload_handlers()});for(var dragCheck=!1,fca_qc_hash_seed=[],i=0;i<256;i++)fca_qc_hash_seed[i]=(i<16?"0":"")+i.toString(16);1 function selectQuiz(_){var a=jQuery;a("#fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_email_optin_meta_box, #fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_translations_meta_box, #fca_qc_custom_css_meta_box").hide(),a("#fca_qc_description_meta_box, #fca_qc_quiz_type_meta_box").show(),"mc"===_&&(a("#fca_qc_quiz_type").val(_),a("#fca_qc_quiz_type_meta_box").hide(),a("#fca_qc_add_personality_result_meta_box, #fca_qc_personality_questions_meta_box").hide(),a("#fca_qc_answer_mode_tr").show(),a("#fca_qc_questions_meta_box, #fca_qc_add_result_meta_box").show(),a("#fca_qc_hints_toggle_tr").show(),a("#fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box").hide()),"pt"===_&&(a("#fca_qc_quiz_type").val(_),a("#fca_qc_quiz_type_meta_box").hide(),a("#fca_qc_questions_meta_box, #fca_qc_add_result_meta_box").hide(),a("#fca_qc_answer_mode_tr").hide(),a("#fca_qc_add_personality_result_meta_box, #fca_qc_personality_questions_meta_box").show(),a("#fca_qc_hints_toggle_tr").hide(),a("#fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box").hide()),"wq"===_&&(a("#fca_qc_quiz_type").val(_),a("#fca_qc_quiz_type_meta_box").hide(),a("#fca_qc_add_personality_result_meta_box, #fca_qc_personality_questions_meta_box").hide(),a("#fca_qc_questions_meta_box, #fca_qc_add_result_meta_box").hide(),a("#fca_qc_answer_mode_tr").hide(),a("#fca_qc_hints_toggle_tr").hide(),a("#fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box").show())}function attach_add_answer_button_handlers_free(){var _=jQuery;_(".fca_qc_add_answer_btn").unbind("click"),_(".fca_qc_add_answer_btn").click(function(){var a=parseInt(_(this).siblings(".fca_qc_answer_input_div").length+1),e=parseInt(_(this).closest(".fca_qc_question_item").attr("id").replace(/[^0-9.]/g,"")),t=fcaQcAdminData.answerDiv.replace(/{{ANSWER_NUMBER}}/g,a);t=(t=t.replace(/{{QUESTION_NUMBER}}/g,e)).replace(/{{ID}}/g,fca_qc_new_GUID()),_(this).before(t),attach_delete_button_handlers(),attach_image_upload_handlers()})}function attach_delete_button_handlers(){var _=jQuery;_(".fca_qc_delete_icon").unbind("click"),_(".fca_qc_delete_icon_confirm").click(function(){_(this).closest("."+_(this).data("target")).remove(),_(this.parentNode).hasClass("fca_qc_personality_result_item")?add_result_personality_result_text_handlers():setScoreRanges()}),_(".fca_qc_delete_icon_cancel").click(function(){_(this).hide().siblings(".fca_qc_delete_icon").hide(),_(this).siblings(".fca_qc_delete_button").show()}),_(".fca_qc_delete_button").click(function(){_(this).siblings(".fca_qc_delete_icon").show(),_(this).hide()})}function add_result_heading_text_handlers(){var _=jQuery;_(".fca_qc_quiz_result").unbind("keyup"),_(".fca_qc_quiz_result").keyup(function(){_(this).closest(".fca_qc_result_input_div").siblings(".fca_qc_result_label").children(".fca_qc_result_score_title").html(_(this).val())}),setScoreRanges()}function add_question_heading_text_handlers(){var _=jQuery;_(".fca_qc_question_text").unbind("keyup"),_(".fca_qc_question_text").keyup(function(){_(this).closest(".fca_qc_question_input_div").prev().children(".fca_qc_quiz_heading_text").html(_(this).val())})}function add_question_and_result_click_toggles(){var _=jQuery;_(".fca_qc_question_item, .fca_qc_result_item").unbind("click"),_(".fca_qc_question_item").click(function(a){var e=_(a.target).hasClass("fca_qc_delete_icon");!1!==dragCheck||e||(_(".fca_qc_question_input_div").not(_(this).find(".fca_qc_question_input_div")).hide(),_(this).find(".fca_qc_question_input_div").toggle("fast"))}),_(".fca_qc_result_item").click(function(a){var e=_(a.target).hasClass("fca_qc_delete_icon");!1!==dragCheck||e||(_(".fca_qc_result_input_div").not(_(this).find(".fca_qc_result_input_div")).hide(),_(this).find(".fca_qc_result_input_div").toggle("fast"))}),_(".fca_qc_question_input_div, .fca_qc_result_input_div, .fca_qc_delete_icon").bind("click",function(_){_.stopPropagation()})}function fca_qc_save_question_json(_){var a=jQuery;a("#editor-nav").click();var e=[],t=a(".fca_qc_question_item:visible");a(t).each(function(){correctAnswer=1,answer=1,a(this).find(".fca_qc_answer_input_div").each(function(){if("Correct Answer"===a(this).find(".fca_qc_answer_header").text()){correctAnswer=answer;fcaQcAdminData.answerDiv.replace(/{{CORRECT_ANSWER}}/g,correctAnswer)}answer+=1});var _=[];a(this).find(".fca_qc_answer_input_div").each(function(){_.push({answer:a(this).find(".fca_qc_question_texta").val(),img:a(this).find(".fca_qc_image_input").val(),id:a(this).find(".fca_qc_id").val(),points:a(this).find(".fca_qc_weighted_question_points").val(),hint:a(this).find(".fca_qc_hint_tr .fca_qc_question_texta").val(),results:a(this).find(".fca_qc_multiselect").val()})}),e.push({question:a(this).find(".fca_qc_question_text").val(),img:a(this).find(".fca_qc_image_input").val(),correct:correctAnswer,id:a(this).find(".fca_qc_id").val(),answers:_})}),a("#fca_qc_questions_json").val(JSON.stringify(e))}function fca_qc_save_result_json(_){var a=jQuery,e=[];a(".fca_qc_result_item:visible").each(function(){e.push({title:a(this).find(".fca_qc_quiz_result").val(),desc:a(this).find(".fca-wysiwyg-html").val(),img:a(this).find(".fca_qc_image").attr("src"),min:a(this).find(".fca_qc_result_min").val(),max:a(this).find(".fca_qc_result_max").val(),url:a(this).find(".fca_qc_url_input").val(),tags:a(this).find(".fca_qc_results_tags").val(),groups:a(this).find(".fca_qc_mailchimp_groups").val(),id:a(this).find(".fca_qc_id").val()})}),a("#fca_qc_results_json").val(JSON.stringify(e))}function setScoreRanges(){var _=jQuery,a=_(".fca_qc_question_item:visible").length,e=_(".fca_qc_result_item:visible").length;if("wq"===_("#fca_qc_quiz_type").val()){var t=[];_(".fca_qc_question_item:visible").each(function(){var a=0;_(this).find(".fca_qc_weighted_question_points").each(function(){Number(_(this).val())>a&&(a=_(this).val())}),t.push(a)}),a=t.reduce(function(_,a){return Number(_)+Number(a)})}var c=a%e;_(".fca_qc_result_item:visible").each(function(t,i){var s=0;if(t>0&&(s=1+Number(_(i).prev().find(".fca_qc_result_max").val())),c)if(t<=c)n=s+Math.floor(a/e);else n=s-1+Math.floor(a/e);else var n=(t+1)*Math.floor(a/e);_(i).find(".fca_qc_result_min").val(s),_(i).find(".fca_qc_result_max").val(n);var o=s+"-"+n+" "+fcaQcAdminData.points_string+": ";s===n&&(o=s+" "+fcaQcAdminData.points_string+": "),s>n&&(o=fcaQcAdminData.unused_string),_(i).find(".fca_qc_result_score_value").html(o)})}function setQuestionNumbers(_){var a=jQuery,e=1;_.find(".fca_qc_question_item").each(function(){a(this).find(".fca_qc_quiz_heading_question_number").html(fcaQcAdminData.question_string+" "+e+": "),e+=1})}function attach_image_upload_handlers(){var _=jQuery;_(".fca_qc_quiz_image_upload_btn, .fca_qc_image, .fca_qc_quiz_image_change_btn").unbind("click"),_(".fca_qc_quiz_image_upload_btn, .fca_qc_image, .fca_qc_quiz_image_change_btn").click(function(a){a.preventDefault();var e=_(this);_(this).hasClass("fca_qc_quiz_image_change_btn")?e=_(this.parentNode).siblings(".fca_qc_quiz_image_upload_btn"):_(this).hasClass("fca_qc_image")&&(e=_(this).siblings(".fca_qc_quiz_image_upload_btn"));var t=wp.media({frame:"post",title:fcaQcAdminData.selectImage_string,multiple:!1}).open().on("insert",function(){var _=t.state().get("selection").first(),a=t.state().display(_).toJSON(),c=(_=_.toJSON()).sizes[a.size].url;c&&(e.siblings(".fca_qc_image_input").attr("value",c),e.siblings(".fca_qc_image").attr("src",c),e.siblings(".fca_qc_image_hover_controls").find(".fca_qc_quiz_image_change_btn").show(),e.siblings(".fca_qc_image_hover_controls").find(".fca_qc_quiz_image_revert_btn").show()),e.hide()})}),_(".fca_qc_quiz_image_revert_btn").unbind("click"),_(".fca_qc_quiz_image_revert_btn").click(function(a){_(this.parentNode).siblings(".fca_qc_image_input").attr("value",""),_(this.parentNode).siblings(".fca_qc_image").attr("src",""),_(this.parentNode).siblings(".fca_qc_quiz_image_upload_btn").show(),_(this).hide(),_(this).siblings(".fca_qc_quiz_image_upload_btn").hide()})}function add_drag_and_drop_sort(){var _=jQuery;_(".fca_qc_sortable_questions, .fca_qc_sortable_results").on("mouseover",function(){screen_y=window.scrollY}),_(".fca_qc_sortable_results, .fca_qc_sortable_questions, .fca_qc_question_input_div").sortable({revert:!0,cancel:":input,button, .fca-wysiwyg-html",start:function(_){window.scrollTo(0,screen_y),dragCheck=!0},stop:function(){dragCheck=!1,_(this).hasClass("fca_qc_sortable_results")&&fca_attach_wysiwyg()}}),_(".fca_qc_sortable_results").unbind("sortupdate"),_(".fca_qc_sortable_results").on("sortupdate",function(_,a){setScoreRanges()}),_(".fca_qc_sortable_questions").unbind("sortupdate"),_(".fca_qc_sortable_questions").on("sortupdate",function(a,e){setQuestionNumbers(_(this))})}function fca_qc_new_GUID(){var _=4294967296*Math.random()>>>0,a=4294967296*Math.random()>>>0,e=4294967296*Math.random()>>>0,t=4294967296*Math.random()>>>0;return fca_qc_hash_seed[255&_]+fca_qc_hash_seed[_>>8&255]+fca_qc_hash_seed[_>>16&255]+fca_qc_hash_seed[_>>24&255]+"-"+fca_qc_hash_seed[255&a]+fca_qc_hash_seed[a>>8&255]+"-"+fca_qc_hash_seed[a>>16&15|64]+fca_qc_hash_seed[a>>24&255]+"-"+fca_qc_hash_seed[63&e|128]+fca_qc_hash_seed[e>>8&255]+"-"+fca_qc_hash_seed[e>>16&255]+fca_qc_hash_seed[e>>24&255]+fca_qc_hash_seed[255&t]+fca_qc_hash_seed[t>>8&255]+fca_qc_hash_seed[t>>16&255]+fca_qc_hash_seed[t>>24&255]}function fca_qc_attach_radio_selects(){var _=jQuery;_(".qc_radio_input").change(function(){_(this).closest(".radio-toggle").children("label").removeClass("selected"),_(this).closest("label").addClass("selected")})}jQuery(document).ready(function(_){_(".meta-box-sortables").sortable({disabled:!0}),_(".postbox .hndle").css("cursor","pointer"),fca_qc_attach_radio_selects(),_(".fca_qc_custom_css").length>0&&wp.codeEditor.initialize(_(".fca_qc_custom_css"),fcaQcAdminData.code_editor);var a=_(".fca_qc_question_item").length,e=_(".fca_qc_result_item ").length;""===_("#post_name").val()&&_("#post_name").val(_("#post_ID").val()),0===_("#fca_qc_quiz_type_meta_box").length&&_("#fca_qc_questions_meta_box, #fca_qc_add_result_meta_box").show(),_(".onoffswitch-inner").each(function(){_(this).attr("data-content-on",fcaQcAdminData.on_string),_(this).attr("data-content-off",fcaQcAdminData.off_string)}),_(".fca_qc_question_input_div").length>1&&_(".fca_qc_question_input_div").hide(),_(".fca_qc_result_input_div").length>1&&_(".fca_qc_result_input_div").hide();var t='<button type="submit" class="button-primary" id="fca_qc_submit_button">'+fcaQcAdminData.save_string+"</buttton>",c='<button type="button" class="button-secondary" id="fca_qc_preview_button">'+fcaQcAdminData.preview_string+"</buttton>";_("#normal-sortables").append(t);var i="";_(".postbox .inside textarea, .fca_qc_input_wide, .fca_qc_text_input").each(function(_,a){i+=a.value}),_(".postbox .inside .onoffswitch-checkbox").each(function(_,a){i+=a.checked}),_(window).bind("beforeunload",function(a){var e="";if(_(".postbox .inside textarea, .fca_qc_input_wide, .fca_qc_text_input").each(function(_,a){e+=a.value}),_(".postbox .inside .onoffswitch-checkbox").each(function(_,a){e+=a.checked}),i!=e)return!0}),_("#fca_qc_submit_button").click(function(a){_(window).unbind("beforeunload");_(this).closest("form").removeAttr("target"),_("#fca_qc_quiz_preview_url").val("")}),_("#post").submit(function(a){fca_qc_save_question_json(_("#post")),fca_qc_save_result_json(_("#post"))}),_("#normal-sortables").append(c),_("#fca_qc_preview_button").click(function(a){a.preventDefault();var e=_(this).closest("form");e.prop("target","_blank"),fca_qc_save_question_json(e),fca_qc_save_result_json(e),e.submit()}),_("#submitdiv").hide(),_(".fca_qc_image").each(function(a){""!==_(this).attr("src")&&_(this).siblings(".fca_qc_quiz_image_upload_btn").hide()}),jQuery.widget.bridge("jQueryUITooltipFCAQC",jQuery.ui.tooltip),_(".fca_qc_tooltip").jQueryUITooltipFCAQC({position:{my:"left",at:"right+2"}}),_("#wpbody-content").show(),_("#fca-quiz-select-multiplechoice").click(function(_){selectQuiz("mc"),setScoreRanges()}),_("#fca-quiz-select-personality").click(function(_){selectQuiz("pt"),setScoreRanges()}),_("#fca-quiz-select-weighted").click(function(_){selectQuiz("wq"),setScoreRanges()}),_("#editor-nav").click(),_("#editor-nav").click(function(){_(".nav-tab-active").removeClass("nav-tab-active"),_(this).addClass("nav-tab-active").blur(),selectQuiz(_("#fca_qc_quiz_type").val())}).click(),_("#settings-nav").click(function(){_(".nav-tab-active").removeClass("nav-tab-active"),_(this).addClass("nav-tab-active").blur(),_("#fca_qc_description_meta_box, #fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box, #fca_qc_questions_meta_box, #fca_qc_add_result_meta_box, #fca_qc_personality_questions_meta_box, #fca_qc_add_personality_result_meta_box, #fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_translations_meta_box, #fca_qc_custom_css_meta_box").hide(),_("#fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_email_optin_meta_box").show()}),_("#appearance-nav").click(function(){_(".nav-tab-active").removeClass("nav-tab-active"),_(this).addClass("nav-tab-active").blur(),_("#fca_qc_description_meta_box, #fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box, #fca_qc_questions_meta_box, #fca_qc_add_result_meta_box, #fca_qc_personality_questions_meta_box, #fca_qc_add_personality_result_meta_box, #fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_translations_meta_box, #fca_qc_email_optin_meta_box").hide(),_("#fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_custom_css_meta_box").show(),"mc"===_("#fca_qc_quiz_type").val()?_(".fca_qc_hide_answers_input").each(function(){_(this).prop("checked")&&"hide"===_(this).val()?_("#fca_qc_rwpanel_appearance_meta_box").hide():_("#fca_qc_rwpanel_appearance_meta_box").show()}):_("#fca_qc_rwpanel_appearance_meta_box").hide()}),_("#translations-nav").click(function(){_(".nav-tab-active").removeClass("nav-tab-active"),_(this).addClass("nav-tab-active").blur(),_("#fca_qc_quiz_settings_meta_box, #fca_qc_social_sharing_meta_box, #fca_qc_email_optin_meta_box, #fca_qc_description_meta_box, #fca_qc_weighted_questions_meta_box, #fca_qc_add_weighted_result_meta_box, #fca_qc_questions_meta_box, #fca_qc_add_result_meta_box, #fca_qc_personality_questions_meta_box, #fca_qc_add_personality_result_meta_box, #fca_qc_quiz_appearance_meta_box, #fca_qc_startbtn_appearance_meta_box, #fca_qc_answers_appearance_meta_box, #fca_qc_rwpanel_appearance_meta_box, #fca_qc_custom_css_meta_box").hide(),_("#fca_qc_translations_meta_box").show()}),_("#fca_qc_add_question_btn").click(function(){a+=1,_(".fca_qc_question_input_div").hide();for(var e=fcaQcAdminData.questionDiv.replace(/{{QUESTION_NUMBER}}/g,a);-1!==e.indexOf("{{ID}}");)e=e.replace(/{{ID}}/,fca_qc_new_GUID());_(this).siblings(".fca_qc_sortable_questions").append(e),add_drag_and_drop_sort(),add_question_heading_text_handlers(),add_question_and_result_click_toggles(),attach_delete_button_handlers(),attach_image_upload_handlers(),attach_add_answer_button_handlers_free(),setScoreRanges(),setQuestionNumbers(_(this).siblings(".fca_qc_sortable_questions")),_("#fca_qc_explanations").change()}),_("#fca_qc_add_result_btn").click(function(){e+=1,_(".fca_qc_result_input_div").hide();var a=fcaQcAdminData.resultDiv.replace(/{{RESULT_NUMBER}}/g,e);a=a.replace(/{{ID}}/g,fca_qc_new_GUID()),_(this).siblings(".fca_qc_sortable_results").append(a),add_drag_and_drop_sort(),add_question_and_result_click_toggles(),attach_delete_button_handlers(),attach_image_upload_handlers(),add_result_heading_text_handlers(),setScoreRanges(),fca_attach_wysiwyg()}),_(".fca_qc_shortcode_input").click(function(_){this.select()}),_("#fca_qc_shortcode_label").click(function(a){_(".fca_qc_shortcode_input").select()}),_(".fca_qc_admin_label").click(function(a){_(this).next().focus()}),add_drag_and_drop_sort(),add_question_and_result_click_toggles(),add_question_heading_text_handlers(),add_result_heading_text_handlers(),attach_delete_button_handlers(),attach_add_answer_button_handlers_free(),setScoreRanges(),attach_image_upload_handlers()});for(var dragCheck=!1,screen_y=0,fca_qc_hash_seed=[],i=0;i<256;i++)fca_qc_hash_seed[i]=(i<16?"0":"")+i.toString(16); -
quiz-cat/trunk/includes/editor/editor.php
r2418396 r2622618 73 73 $html .= '<a href="#" id="appearance-nav" class="nav-tab">' . __('Appearance', 'quiz-cat') . '</a>'; 74 74 } 75 $html .= '<a href="#" id="translations-nav" class="nav-tab">' . __('Translations', 'quiz-cat') . '</a>'; 75 76 $html .= '</h1>'; 76 77 … … 120 121 'default' 121 122 ); 122 123 123 124 add_meta_box( 124 125 'fca_qc_quiz_settings_meta_box', … … 129 130 'default' 130 131 ); 132 133 add_meta_box( 134 'fca_qc_translations_meta_box', 135 __( 'Translations', 'quiz-cat' ), 136 'fca_qc_render_translations_metabox', 137 null, 138 'normal', 139 'default' 140 ); 141 131 142 } 132 143 add_action( 'add_meta_boxes_fca_qc_quiz', 'fca_qc_add_custom_meta_boxes' ); … … 293 304 $results = get_post_meta ( $post->ID, 'quiz_cat_results', true ); 294 305 295 echo "<p class='fca_qc_quiz_instructions'>" . __('Add your results based on the number of correct answers. Drag to re-order. This is optional.', 'quiz-cat') . "</p>";306 echo "<p class='fca_qc_quiz_instructions'>" . __('Add your results based on the number of correct answers. This is optional. Drag to re-order.', 'quiz-cat') . "</p>"; 296 307 297 308 echo "<div class='fca_qc_sortable_results'>"; … … 486 497 } 487 498 499 function fca_qc_render_translations_metabox ( $post ) { 500 501 global $global_quiz_text_strings; 502 $translations = get_post_meta ( $post->ID, 'quiz_cat_translations', true ); 503 $text_strings = empty( $translations ) ? $global_quiz_text_strings : $translations; 504 505 echo "<table class='fca_qc_setting_table'>"; 506 507 forEach ( $text_strings as $key => $value ) { 508 509 echo "<tr class='fca_qc_translation_settings'>"; 510 511 echo "<th>"; 512 echo "<label class='fca_qc_admin_label fca_qc_admin_settings_label' for='fca_qc_" . $key . "_translation'>" . $global_quiz_text_strings[$key] . "</label>"; 513 echo "</th>"; 514 515 echo "<td>"; 516 echo "<input type='text' class='fca_qc_translation_title' name='fca_qc_" . $key . "_translation' value='$value'>"; 517 echo "</td>"; 518 519 echo "</tr>"; 520 521 } 522 523 echo "</table>"; 524 525 } 526 488 527 //RENDER THE QUIZ SETTINGS META BOX 489 528 function fca_qc_render_quiz_settings_meta_box( $post ) { … … 512 551 echo "<input type='text' class='fca_qc_input_wide fca_qc_shortcode_input' name='fca_qc_shortcode_input' value='$shortcode' readonly>"; 513 552 echo "</td>"; 514 echo "< tr>";553 echo "</tr>"; 515 554 echo "<tr>"; 516 555 echo "<th>"; … … 651 690 ) ); 652 691 653 654 692 //SAVING QUESTIONS 655 693 update_post_meta ( $post_id, 'quiz_cat_questions', fca_qc_kses_html( json_decode( stripslashes_deep( $_POST['fca_qc_questions_json'] ), true ) ) ); … … 658 696 update_post_meta ( $post_id, 'quiz_cat_results', fca_qc_kses_html( json_decode( stripslashes_deep( $_POST['fca_qc_results_json'] ), true ) ) ); 659 697 698 fca_qc_save_quiz_translations( $post_id ); 660 699 661 700 if ( function_exists ('fca_qc_save_appearance_settings') ) { … … 693 732 } 694 733 734 //SAVE TRANSLATIONS 735 function fca_qc_save_quiz_translations( $post_id ) { 736 737 global $global_quiz_text_strings; 738 $fields = $settings = array(); 739 740 forEach ( $global_quiz_text_strings as $key => $value ) { 741 $fields['fca_qc_' . $key . '_translation'] = $key; 742 } 743 744 forEach ( $fields as $key => $value ) { 745 $settings[$value] = empty ( $_POST[$key] ) ? $global_quiz_text_strings[$key] : fca_qc_sanitize_text( $_POST[$key] ); 746 } 747 748 update_post_meta ( $post_id, 'quiz_cat_translations', $settings ); 749 750 } 695 751 696 752 //PREVIEW -
quiz-cat/trunk/includes/functions.php
r2416916 r2622618 1 1 <?php 2 2 3 function fca_qc_share_string ( $quiz_id = 0, $quiz_text_strings = '', $result_title = '{{MY_QUIZ_RESULT}}' ) { 4 5 if ( empty ( $quiz_text_strings ) ) { 6 $quiz_text_strings = fca_qc_set_quiz_text_strings(); 7 } 8 3 function fca_qc_share_string ( $quiz_id = 0, $result_title = '{{MY_QUIZ_RESULT}}' ) { 4 5 $quiz_text_strings = fca_qc_set_quiz_text_strings( $quiz_id ); 9 6 $quiz_title = get_the_title( $quiz_id ); 10 7 return esc_attr( str_replace ( "'", "'", ( apply_filters( 'fca_qc_share_text', $quiz_text_strings['i_got'] . " \"$result_title\" - $quiz_title" ) ) ) ); … … 326 323 return false; 327 324 } 325 326 function fca_qc_get_quiz_type( $quiz_id ){ 327 328 global $post; 329 $settings = get_post_meta ( $post->ID, 'quiz_cat_settings', true ); 330 $quiz_type = empty ( $settings['quiz_type'] ) ? 'mc' : $settings['quiz_type']; 331 332 switch ( $quiz_type ) { 333 case 'pt': 334 return 'Personality Test'; 335 case 'wq': 336 return 'Weighted Quiz'; 337 default: 338 return 'Multiple Choice'; 339 340 break; 341 342 } 343 } 344 328 345 function fca_qc_show_gdpr_checkbox(){ 329 346 $gdpr_checkbox = get_option( 'fca_qc_gdpr_checkbox' ); -
quiz-cat/trunk/includes/post-type.php
r2416916 r2622618 83 83 $new_columns['title'] = _x('Quiz Name', 'column name', 'quiz-cat'); 84 84 $new_columns['shortcode'] = __('Shortcode', 'quiz-cat'); 85 if ( FCA_QC_PLUGIN_PACKAGE !== 'Free' ){ 86 $new_columns['type'] = __('Quiz Type', 'quiz-cat'); 87 } 85 88 $new_columns['date'] = _x('Date', 'column name', 'quiz-cat'); 86 89 … … 167 170 168 171 function fca_qc_manage_post_table_columns($column_name, $id) { 172 173 $quiz_type = fca_qc_get_quiz_type( $id ); 174 169 175 switch ($column_name) { 176 case 'type': 177 echo '<span>' . $quiz_type . '</span>'; 178 break; 179 170 180 case 'shortcode': 171 181 echo '<input type="text" style="max-width: 100%" readonly="readonly" onclick="this.select()" value="[quiz-cat id="'. $id . '"]"/>'; -
quiz-cat/trunk/includes/quiz/quiz.js
r2475292 r2622618 346 346 } 347 347 } 348 349 // scroll back to the top of the quiz 350 scrollQuizInToView( thisQuiz.selector ) 348 351 349 352 }) -
quiz-cat/trunk/includes/quiz/quiz.min.js
r2475292 r2622618 1 jQuery(document).ready(function($){function isIE(){var e=window.navigator.userAgent;if(e.indexOf("MSIE ")>0)return!0;return e.indexOf("Trident/")>0}function isOldAndroidVersion(){var e=navigator.userAgent.toLowerCase().match(/android\s([0-9\.]*)/);return!!e&&parseFloat(e[1])<5}function oldBrowserFix(e){$(e).find("#fca_qc_back_container").css("backface-visibility","visible"),$(e).find("#fca_qc_back_container").css("transform","none"),$(e).find("#fca_qc_back_container").hide(),isIE()&&(svg_square='<svg xmlns="http://www.w3.org/2000/svg" class="fca_qc_rectancle" width="26" height="26"><rect class="fca_qc_checkbox" width="26" height="26"></rect></svg>')}function loadQuizzes(){$(".fca_qc_quiz").each(function(index){var thisId=get_quiz_id(this);thisId&&(quizzes[thisId]=eval("quizData_"+thisId),quizzes[thisId].selector=this,default_img=quizzes[thisId].default_img)}),$.each(quizzes,function(e,t){quizzes[e].questions=quizzes[e].questions.filter(function(e){return 0!==e.answers.filter(function(e){return e.answer||e.img}).length})}),$.each(quizzes,function(e){"on"===quizzes[e].quiz_settings.shuffle_questions&&(quizzes[e].questions=shuffleArray(quizzes[e].questions))}),$.each(quizzes,function(e){"on"===quizzes[e].quiz_settings.autostart_quiz&&startQuiz(quizzes[e])})}function preloadImages(){$.each(quizzes,function(e,t){quizzes[e].questions[0]&&lazyLoadQuestion(quizzes[e].questions[0])})}function lazyLoadResults(e){e.hasOwnProperty("quiz_results")&&$.each(e.quiz_results,function(t){e.quiz_results[t].hasOwnProperty("img")&&lazyLoadImage(e.quiz_results[t].img)})}function lazyLoadImage(e){if(""!==e&&void 0!==e&&"string"==typeof e){(new Image).src=e}}function lazyLoadQuestion(e){e.hasOwnProperty("img")&&lazyLoadImage(e.img),e.hasOwnProperty("answers")&&$.each(e.answers,function(t){e.answers[t].hasOwnProperty("img")&&lazyLoadImage(e.answers[t].img)})}function startQuiz(e){usingOldBrowser&&oldBrowserFix(e.selector),fix_hover(e),e.currentQuestion=0,e.score=0,e.responses=[],e.questionCount=e.questions.length,""===e.quiz_settings.hide_answers?e.hideAnswers="after":"on"===e.quiz_settings.hide_answers?e.hideAnswers="end":e.hideAnswers=e.quiz_settings.hide_answers,$(e.selector).find(".fca_qc_quiz_title").hide(),$(e.selector).find(".fca_qc_quiz_description").hide(),$(e.selector).find(".fca_qc_quiz_description_img").hide(),$(e.selector).find(".fca_qc_start_button").hide(),$(e.selector).find(".fca_qc_quiz_div").show(),$(e.selector).find(".fca_qc_quiz_footer").show(),$(e.selector).find(".flip-container").show(),$(e.selector).find(".fca_qc_question_count").html("1/"+e.questionCount),showQuestion(e)}function get_quiz_id(e){var t=$(e).attr("id");return!!t&&t.replace(/\D+/g,"")}function showQuestion(e){if(e.quiz_settings.disable_scroll||"on"===e.quiz_settings.autostart_quiz&&0===e.currentQuestion||scrollQuizInToView(e.selector),e.currentQuestion<e.questionCount){$(e.selector).find(".fca_qc_question_count").html(e.currentQuestion+1+"/"+e.questionCount);var t=e.questions[e.currentQuestion].question;$(e.selector).find("#fca_qc_question").html(t),$(e.selector).find("#fca_qc_question_back").html(t);var s=e.questions[e.currentQuestion].img;if($(e.selector).find("#fca_qc_answer_container").find(".fca_qc_quiz_question_img").attr("src",s),$(e.selector).find("#fca_qc_back_container").find(".fca_qc_quiz_question_img").attr("src",s),$(e.selector).find("#fca_qc_answer_container").data("id",e.questions[e.currentQuestion].id),e.questions[e.currentQuestion].correct)i=e.questions[e.currentQuestion].correct-1;else var i=0;if("mc"===e.quiz_settings.quiz_type||""===e.quiz_settings.quiz_type)var n=e.questions[e.currentQuestion].answers[i];if("off"!==quizzes[e.quiz_id].quiz_settings.fixed_answers&&quizzes[e.quiz_id].quiz_settings.fixed_answers)c=e.questions[e.currentQuestion].answers;else var c=shuffleArray(e.questions[e.currentQuestion].answers);e.currentQuestion+1<e.questionCount?lazyLoadQuestion(e.questions[e.currentQuestion+1]):lazyLoadResults(e),$(e.selector).find(".fca_qc_answer_div").hide();for(var r=0;r<c.length;r++){var a=void 0!==c[r].img&&""!==c[r].img,o=void 0!==c[r].answer&&""!==c[r].answer;(a||o)&&("mc"!==e.quiz_settings.quiz_type&&""!==e.quiz_settings.quiz_type||c[r].answer!==n.answer||c[r].img!==n.img||(e.currentAnswer=$(e.selector).find(".fca_qc_answer_div").eq(r).attr("data-question")),"pt"!==e.quiz_settings.quiz_type&&"wq"!==e.quiz_settings.quiz_type||$(e.selector).find(".fca_qc_answer_div").eq(r).data("results",c[r].results),$(e.selector).find(".fca_qc_answer_div").eq(r).find(".fca_qc_quiz_answer_img").attr("src",c[r].img),$(e.selector).find(".fca_qc_answer_div").eq(r).find(".fca_qc_answer_span").html(svg_square+c[r].answer),$(e.selector).find(".fca_qc_answer_div").eq(r).data("id",c[r].id),$(e.selector).find(".fca_qc_answer_div").eq(r).show())}$(e.selector).find("#fca_qc_answer_container").waitForImages(function(){maybe_add_quarter_class(e.selector),scale_flip_box_question(e.selector)}),e.currentQuestion=e.currentQuestion+1}else endTest(e)}function maxHeightOfElementSet(e){var t=0;return $.each(e,function(s){e.eq(s).outerHeight()>t&&(t=e.eq(s).outerHeight())}),t}function scale_flip_box_question(e){var t=$(e).find("#fca_qc_question").outerHeight(!0);t+=$(e).find(".fca_qc_quiz_question_img").outerHeight(!0);var s=0,i=0;$(e).find(".fca_qc_answer_div:visible").eq(0).hasClass("fca-qc-twoup")?(i=maxHeightOfElementSet($(e).find(".fca_qc_answer_div:visible")),s=$(e).find(".fca_qc_answer_div:visible").length,s=Math.floor(s/2)+s%2,t+=i*s):$(e).find(".fca_qc_answer_div:visible").eq(0).hasClass("fca-qc-threeup")?(i=maxHeightOfElementSet($(e).find(".fca_qc_answer_div:visible")),s=$(e).find(".fca_qc_answer_div:visible").length,t+=i*(s/=3)):$(e).find(".fca_qc_answer_div:visible").each(function(){t+=$(this).outerHeight(!0)}),t<200&&(t=200),$(e).find(".fca_qc_quiz_div, #fca_qc_answer_container, #fca_qc_back_container").outerHeight(t)}function scale_flip_box_back(e){var t=0;$(e).find("#fca_qc_back_container").children().each(function(){$(this).is(":visible")&&(t+=$(this).outerHeight(!0))}),(t+=35)<200&&(t=200),$(e).find(".fca_qc_quiz_div, #fca_qc_answer_container, #fca_qc_back_container").height(t)}function maybe_add_quarter_class(e){$(e).find(".fca_qc_answer_div").height("auto"),$(e).find(".fca_qc_answer_div").removeClass("fca-qc-twoup fca-qc-threeup"),$(e).find(".fca_qc_quiz_answer_img").css("marginBottom",0);var t=!0,s=0;if($(e).find(".fca_qc_answer_div:visible").each(function(){if(s++,""===$(this).find(".fca_qc_quiz_answer_img").attr("src")||!t)return t=!1,!1}),t){var i="fca-qc-twoup";s%3==0&&0===$(e).find(".fca_qc_mobile_check:visible").length&&(i="fca-qc-threeup"),$(e).find(".fca_qc_answer_div").addClass(i);var n=maxHeightOfElementSet($(e).find(".fca_qc_quiz_answer_img:visible"));n>200&&(n=200),$(e).find(".fca_qc_quiz_answer_img:visible").each(function(){$(this).css("marginBottom",n-$(this).height()+10+"px")});var c=maxHeightOfElementSet($(e).find(".fca_qc_answer_div:visible"));return $(e).find(".fca_qc_answer_div:visible").outerHeight(c),!0}return!1}function get_result(e){if(!e.quiz_results)return!1;if("pt"===e.quiz_settings.quiz_type){var t=[],s=-1;return $.each(e.quiz_results,function(e,t){t.hasOwnProperty("score")&&t.score>s&&(s=t.score)}),$.each(e.quiz_results,function(e,i){i.hasOwnProperty("score")&&i.score===s&&t.push(i)}),0===t.length&&(t=e.quiz_results),t[Math.floor(Math.random()*t.length)]}if("wq"===e.quiz_settings.quiz_type)for(i=0;i<e.quiz_results.length;i++)if(e.quiz_results[i].min<=e.score&&e.quiz_results[i].max>=e.score)return e.quiz_results[i];if("mc"===e.quiz_settings.quiz_type||""===e.quiz_settings.quiz_type)for(var i=0;i<e.quiz_results.length;i++)if(e.quiz_results[i].min<=e.score&&e.quiz_results[i].max>=e.score)return e.quiz_results[i];return!1}function show_responses(e){for(var t,s=0;s<e.questions.length;s++)t="",e.responses[s].isCorrect?t+="<div class='fca_qc_question_response_item correct-answer'>":t+="<div class='fca_qc_question_response_item wrong-answer'>",t+="<p class='fca_qc_question_response_question'>"+(s+1)+". "+e.questions[s].question+"</p>",t+="<img class='fca_qc_quiz_question_img' src='"+e.questions[s].img+"'>",t+="<p class='fca_qc_question_response_response'><span class='fca_qc_bold'>"+e.your_answer_string+" </span>"+e.responses[s].answer+"</p>",t+="<p class='fca_qc_question_response_correct_answer'><span class='fca_qc_bold'>"+e.correct_answer_string+" </span>"+e.responses[s].correctAnswer+"</p>",e.responses[s].hasOwnProperty("hint")&&(t+="<p class='fca_qc_question_response_hint'>"+e.responses[s].hint+"</p>"),t+="</div>",$(e.selector).find(".fca_qc_insert_response_above").before(t);$(e.selector).find(".fca_qc_your_answer_container").show()}function endTest(e){if($(e.selector).find(".fca_qc_quiz_footer").hide(),$(e.selector).find(".fca_qc_quiz_div").hide(),"mc"===e.quiz_settings.quiz_type||""===e.quiz_settings.quiz_type){var t=scoreString.replace("{{SCORE_CORRECT}}",e.score);t=t.replace("{{SCORE_TOTAL}}",e.questionCount),$(e.selector).find(".fca_qc_score_text").html(t)}"pt"!==e.quiz_settings.quiz_type&&"wq"!==e.quiz_settings.quiz_type||$(e.selector).find(".fca_qc_score_text").hide();var s=get_result(e);s&&($(e.selector).find(".fca_qc_score_title").html(s.title),$(e.selector).find(".fca_qc_score_img").attr("src",s.img),$(e.selector).find(".fca_qc_score_desc").html(s.desc)),"on"===e.optin_settings.capture_emails?show_optins(e,s):show_sharing_and_result_screen(e,s)}function show_optins(e,t){$(e.selector).find(".fca_qc_optin_input, .fca-qc-gdpr-consent").not(".tooltipstered").tooltipster({trigger:"custom",maxWidth:240,theme:["tooltipster-borderless","tooltipster-quiz-cat"]}),$(e.selector).find(".tooltipstered").tooltipster("close"),$(e.selector).find(".fca_qc_optin_container").show(),$(e.selector).find(".fca_qc_optin_input").first().focus(),$(e.selector).find(".fca_qc_skip_email_button").click(function(){$(e.selector).find(".fca_qc_optin_container").hide(),$(e.selector).find(".tooltipstered").tooltipster("close"),show_sharing_and_result_screen(e,t)}),$(e.selector).find(".fca_qc_submit_email_button").click(function(){var s=$(e.selector).find("#fca_qc_email_input").val(),i=$(e.selector).find("#fca_qc_name_input").val(),n=/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(s),c=""!==i||0===$(e.selector).find("#fca_qc_name_input").length;if($(e.selector).find(".fca_qc_optin_input").removeClass("fca_qc_invalid"),e.selector.offsetWidth=e.selector.offsetWidth,n&&c){$(e.selector).find(".tooltipstered").tooltipster("close");if(e.gdpr_checkbox){var r=$(e.selector).find(".fca-qc-gdpr-consent:visible");if(0==r.length)return $(e.selector).find(".fca-qc-gdpr").show(),$(e.selector).find(".fca_qc_optin_input").hide(),!1;if(0==r.prop("checked"))return r.tooltipster("open"),!1;!0}$(document).unbind("keypress"),$(e.selector).find(".tooltipstered").tooltipster("close"),e.user={name:i,email:s},add_to_mailing_list(e,s,i,t),$(e.selector).find(".fca_qc_optin_container").hide(),show_sharing_and_result_screen(e,t)}else n?($(e.selector).find("#fca_qc_email_input").tooltipster("close"),$(e.selector).find("#fca_qc_email_input").removeClass("fca_qc_invalid")):($(e.selector).find("#fca_qc_email_input").tooltipster("open"),$(e.selector).find("#fca_qc_email_input").addClass("fca_qc_invalid")),c?($(e.selector).find("#fca_qc_name_input").tooltipster("close"),$(e.selector).find("#fca_qc_name_input").removeClass("fca_qc_invalid")):($(e.selector).find("#fca_qc_name_input").tooltipster("open"),$(e.selector).find("#fca_qc_name_input").addClass("fca_qc_invalid"))}),0===$(e.selector).find(".fca_qc_skip_email_button").length&&0===$(e.selector).find(".fca_qc_submit_email_button").length?show_sharing_and_result_screen(e,t):$(document).keypress(function(t){if(13===t.which)return $(e.selector).find(".fca_qc_submit_email_button").click(),!1})}function add_to_mailing_list(e,t,s,i){if(fcaQcData.debug&&console.log(i),-1!==optins.indexOf(e.quiz_id))return fcaQcData.debug&&console.log("already opted in for this quiz! woop"),!1;optins.push(e.quiz_id);var n=jstz.determine();$.ajax({url:e.ajaxurl,type:"POST",data:{nonce:e.nonce,post_id:e.quiz_id,action:"fca_qc_add_to_mailing_list",email:t,name:s,result:get_result_text(e,i),tags:i.tags,groups:i.groups,timezone:n.name()}}).done(function(e){fcaQcData.debug&&console.log(e)})}function add_activity(e,t,s,i){if(0==fcaQcData.analytics)return!1;if("shares"===i){if(-1!==shared.indexOf(s))return fcaQcData.debug&&console.log("already shared this quiz! woop"),!1;shared.push(s)}else if("completions"===i){if(-1!==completed.indexOf(s))return fcaQcData.debug&&console.log("already completed this quiz! woop"),!1;completed.push(s)}$.ajax({url:e,type:"POST",data:{nonce:t,quiz_id:s,action:"fca_qc_activity",type:i}}).done(function(e){fcaQcData.debug&&console.log(e)})}function add_response(e,t,s,i,n){if(0==fcaQcData.analytics)return!1;$.ajax({url:e,type:"POST",data:{nonce:t,quiz_id:s,question:i,response:n,action:"fca_qc_add_response_ajax"}}).done(function(e){fcaQcData.debug&&console.log(e)})}function send_responses(e,t){var s="",i="",n="",c="unknown";if(0==fcaQcData.analytics)return!1;if(e.gdpr_checkbox){c=!!$(e.selector).find(".fca-qc-gdpr-consent").prop("checked")}e.hasOwnProperty("user")&&(s=e.user.name,i=e.user.email),n=t.hasOwnProperty("id")?t.id:e.score,$.ajax({url:e.ajaxurl,type:"POST",data:{nonce:e.nonce,quiz_id:e.quiz_id,name:s,email:i,gdpr_consent:c,result:n,result_text:get_result_text(e,t),responses:e.responses,action:"fca_qc_send_responses_ajax"}}).done(function(e){fcaQcData.debug&&console.log(e)})}function restart_quiz(e){location.href=location.origin+location.pathname+location.search+"#"+e.selector.id,location.reload(),location.href=location.origin+location.pathname+location.search+"#"+e.selector.id}function get_result_text(e,t){var s="";return t.hasOwnProperty("title")&&(s=t.title),"mc"!==e.quiz_settings.quiz_type&&""!==e.quiz_settings.quiz_type||(s=s?e.score+"/"+e.questionCount+": "+t.title:e.score+"/"+e.questionCount),s}function show_sharing_and_result_screen(e,t){send_responses(e,t),"redirect"===e.quiz_settings.result_mode?setTimeout(function(){window.location.href=t.url},1e3):("on"===e.quiz_settings.restart_button&&$("#fca_qc_restart_button").click(function(){restart_quiz(e),$(this).hide()}).show("fast"),"end"===e.hideAnswers&&show_responses(e),"on"===e.quiz_settings.show_sharing&&show_sharing(e,t),$(e.selector).find(".fca_qc_score_container").show())}function get_correct_answer_html(e){var t="",s="";return $(e.selector).find(".fca_qc_answer_div").each(function(){$(this).attr("data-question")===e.currentAnswer&&(t=addQuizImg($(this).find(".fca_qc_quiz_answer_img").attr("src")),s=$(this).find(".fca_qc_answer_span").html().replace(svg_square,""))}),t+s}function fix_hover(e){$(e.selector).find(".fca_qc_answer_div").hover(function(e){$(this).addClass("fakehover"),$(this).children("span").addClass("fakehover")},function(e){$(this).removeClass("fakehover"),$(this).children("span").removeClass("fakehover")})}function show_sharing(e,t){$(e.selector).find(".fca_qc_social_share").show("fast");var s=$(e.selector).find(".fca_qc_score_img").attr("src");""===s&&(s=$(e.selector).find(".fca_qc_quiz_description_img").attr("src")),""===s&&(s=default_img);var i=$(e.selector).find("#fca_qc_share_link_facebook");1===i.length&&(0==t?i.prop("href",i.prop("href")+"0"+encodeURIComponent("&fca_qc_title="+get_result_text(e,t))):i.prop("href",i.prop("href")+e.quiz_results.indexOf(t)+encodeURIComponent("&fca_qc_title="+get_result_text(e,t))));var n=$(e.selector).find("#fca_qc_share_link_twitter");1===n.length&&(n.data("sharestring",encodeURIComponent(n.data("sharestring").replace("{{MY_QUIZ_RESULT}}",get_result_text(e,t)))),n.prop("href",n.prop("href")+encodeURIComponent("&fca_qc_title="+get_result_text(e,t).replace(/ /g,"+"))+"&text="+n.data("sharestring")));var c=$(e.selector).find("#fca_qc_share_link_email");1===c.length&&encode_share_link(c,get_result_text(e,t)),iOS&&c.hide();var r=$(e.selector).find("#fca_qc_share_link_pinterest");1===r.length&&(encode_share_link(r,get_result_text(e,t)),r.prop("href",r.prop("href")+"&media="+s)),$(e.selector).find(".fca_qc_share_link").click(function(t){t.preventDefault();var s=$(this).prop("href");window.open(s,"_blank","resizable=yes,scrollbars=yes,titlebar=yes, width=560, height=443, top=100, left=50"),add_activity(e.ajaxurl,e.nonce,e.quiz_id,"shares")})}function encode_share_link(e,t){var s=encodeURIComponent(e.data("sharestring").replace("{{MY_QUIZ_RESULT}}",t)),i=e.prop("href");e.prop("href",i+s)}function shuffleArray(e){for(var t=e.length-1;t>0;t--){var s=Math.floor(Math.random()*(t+1)),i=e[t];e[t]=e[s],e[s]=i}return e}function addQuizImg(e){return e&&""!==e&&"string"==typeof e?"<img class='fca_qc_quiz_answer_img' src='"+e+"'>":""}function scrollQuizInToView(e){var t=$(e).offset().top+-100;t<0&&(t=0),$("html, body").animate({scrollTop:t},300)}function debounce(e,t,s){var i;return function(){var n=this,c=arguments,r=s&&!i;clearTimeout(i),i=setTimeout(function(){i=null,s||e.apply(n,c)},t),r&&e.apply(n,c)}}var usingOldBrowser=isIE()||isOldAndroidVersion(),iOS=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,scoreString=$(".fca_qc_score_text").first().html(),svg_square='<svg xmlns="http://www.w3.org/2000/svg" class="fca_qc_rectancle" width="26" height="26"><rect class="fca_qc_checkbox" width="26" height="26"></rect></svg>',quizzes={},default_img="";loadQuizzes(),fcaQcData.debug&&console.log(quizzes),preloadImages(),$(".fca_qc_start_button").click(function(){startQuiz(quizzes[get_quiz_id($(this).closest(".fca_qc_quiz"))])}),$(".fca_qc_next_question").click(function(){var e=quizzes[get_quiz_id($(this).closest(".fca_qc_quiz"))];usingOldBrowser?($(e.selector).find("#fca_qc_answer_container").show(),$(e.selector).find("#fca_qc_back_container").hide()):$(e.selector).find(".fca_qc_quiz_div").removeClass("flip"),showQuestion(e)}),$(".fca_qc_answer_div").click(function(){var e=quizzes[get_quiz_id($(this).closest(".fca_qc_quiz"))];$(this).blur(),$(".fakehover").removeClass("fakehover");var t=$(this).closest("#fca_qc_answer_container").data("id"),s=$(this).data("id"),i=!1;if(1===e.currentQuestion&&add_activity(e.ajaxurl,e.nonce,e.quiz_id,"starts"),"wq"===e.quiz_settings.quiz_type){var n=parseInt(e.questions[e.currentQuestion-1].answers.filter(function(e){return e.id===s})[0].points);isNaN(n)||(e.score=parseInt(e.score)+n)}else $(this).attr("data-question")===e.currentAnswer&&(e.score=e.score+1,i=!0);var c={answer:addQuizImg($(this).children(".fca_qc_quiz_answer_img").attr("src"))+$(this).children(".fca_qc_answer_span").html().replace(svg_square,""),answer:addQuizImg($(this).children(".fca_qc_quiz_answer_img").attr("src"))+$(this).children(".fca_qc_answer_span").html().replace(svg_square,""),isCorrect:i,correctAnswer:get_correct_answer_html(e),question:$(this).siblings("#fca_qc_question").html(),id:t,response:s};if("on"===e.quiz_settings.explanations){1===(a=e.questions[e.currentQuestion-1].answers.filter(function(e){return e.hasOwnProperty("hint")})).length&&(c.hint=a[0].hint)}if(e.responses.push(c),add_response(e.ajaxurl,e.nonce,e.quiz_id,t,s),"pt"===e.quiz_settings.quiz_type)$.each($(this).data("results"),function(t,s){$.each(e.quiz_results,function(e,t){s===t.id&&(t.hasOwnProperty("score")?t.score=t.score+1:t.score=1)})}),showQuestion(e);else if("wq"===e.quiz_settings.quiz_type)$.each($(this).data("results"),function(t,s){$.each(e.quiz_results,function(e,t){s===t.id&&(t.hasOwnProperty("score")?t.score=t.score+1:t.score=1)})}),showQuestion(e);else if("after"===e.hideAnswers){$(e.selector).find("#fca_qc_your_answer").html(addQuizImg($(this).children(".fca_qc_quiz_answer_img").attr("src"))+$(this).children(".fca_qc_answer_span").html().replace(svg_square,""));var r=get_correct_answer_html(e);if($(e.selector).find("#fca_qc_correct_answer").html(r),"on"===e.quiz_settings.explanations){var a=e.questions[e.currentQuestion-1].answers.filter(function(e){return e.hasOwnProperty("hint")});1===a.length?$(e.selector).find("#fca_qc_hint_p").html(a[0].hint):$(e.selector).find("#fca_qc_hint_p").html("")}usingOldBrowser?($(e.selector).find("#fca_qc_answer_container").hide(),$(e.selector).find("#fca_qc_back_container").show()):$(e.selector).find(".fca_qc_quiz_div").addClass("flip"),$(e.selector).find("#fca_qc_back_container").removeClass("correct-answer"),$(e.selector).find("#fca_qc_back_container").removeClass("wrong-answer"),i?($(e.selector).find("#fca_qc_back_container").addClass("correct-answer"),$(e.selector).find("#fca_qc_question_right_or_wrong").html(e.correct_string),$(e.selector).find("#fca_qc_correct_answer_p").hide()):($(e.selector).find("#fca_qc_back_container").addClass("wrong-answer"),$(e.selector).find("#fca_qc_question_right_or_wrong").html(e.wrong_string),$(e.selector).find("#fca_qc_correct_answer_p").show()),scale_flip_box_back(e.selector)}else showQuestion(e) });var optins=[],shared=[],completed=[],resizeWindow=debounce(function(){jQuery.each(quizzes,function(e){$(quizzes[e].selector).find("#fca_qc_answer_container").waitForImages(function(){maybe_add_quarter_class(quizzes[e].selector),$("#fca_qc_back_container").is(":visible")?scale_flip_box_back(quizzes[e].selector):scale_flip_box_question(quizzes[e].selector)})})},50)});1 jQuery(document).ready(function($){function isIE(){var e=window.navigator.userAgent;if(e.indexOf("MSIE ")>0)return!0;return e.indexOf("Trident/")>0}function isOldAndroidVersion(){var e=navigator.userAgent.toLowerCase().match(/android\s([0-9\.]*)/);return!!e&&parseFloat(e[1])<5}function oldBrowserFix(e){$(e).find("#fca_qc_back_container").css("backface-visibility","visible"),$(e).find("#fca_qc_back_container").css("transform","none"),$(e).find("#fca_qc_back_container").hide(),isIE()&&(svg_square='<svg xmlns="http://www.w3.org/2000/svg" class="fca_qc_rectancle" width="26" height="26"><rect class="fca_qc_checkbox" width="26" height="26"></rect></svg>')}function loadQuizzes(){$(".fca_qc_quiz").each(function(index){var thisId=get_quiz_id(this);thisId&&(quizzes[thisId]=eval("quizData_"+thisId),quizzes[thisId].selector=this,default_img=quizzes[thisId].default_img)}),$.each(quizzes,function(e,t){quizzes[e].questions=quizzes[e].questions.filter(function(e){return 0!==e.answers.filter(function(e){return e.answer||e.img}).length})}),$.each(quizzes,function(e){"on"===quizzes[e].quiz_settings.shuffle_questions&&(quizzes[e].questions=shuffleArray(quizzes[e].questions))}),$.each(quizzes,function(e){"on"===quizzes[e].quiz_settings.autostart_quiz&&startQuiz(quizzes[e])})}function preloadImages(){$.each(quizzes,function(e,t){quizzes[e].questions[0]&&lazyLoadQuestion(quizzes[e].questions[0])})}function lazyLoadResults(e){e.hasOwnProperty("quiz_results")&&$.each(e.quiz_results,function(t){e.quiz_results[t].hasOwnProperty("img")&&lazyLoadImage(e.quiz_results[t].img)})}function lazyLoadImage(e){if(""!==e&&void 0!==e&&"string"==typeof e){(new Image).src=e}}function lazyLoadQuestion(e){e.hasOwnProperty("img")&&lazyLoadImage(e.img),e.hasOwnProperty("answers")&&$.each(e.answers,function(t){e.answers[t].hasOwnProperty("img")&&lazyLoadImage(e.answers[t].img)})}function startQuiz(e){usingOldBrowser&&oldBrowserFix(e.selector),fix_hover(e),e.currentQuestion=0,e.score=0,e.responses=[],e.questionCount=e.questions.length,""===e.quiz_settings.hide_answers?e.hideAnswers="after":"on"===e.quiz_settings.hide_answers?e.hideAnswers="end":e.hideAnswers=e.quiz_settings.hide_answers,$(e.selector).find(".fca_qc_quiz_title").hide(),$(e.selector).find(".fca_qc_quiz_description").hide(),$(e.selector).find(".fca_qc_quiz_description_img").hide(),$(e.selector).find(".fca_qc_start_button").hide(),$(e.selector).find(".fca_qc_quiz_div").show(),$(e.selector).find(".fca_qc_quiz_footer").show(),$(e.selector).find(".flip-container").show(),$(e.selector).find(".fca_qc_question_count").html("1/"+e.questionCount),showQuestion(e)}function get_quiz_id(e){var t=$(e).attr("id");return!!t&&t.replace(/\D+/g,"")}function showQuestion(e){if(e.quiz_settings.disable_scroll||"on"===e.quiz_settings.autostart_quiz&&0===e.currentQuestion||scrollQuizInToView(e.selector),e.currentQuestion<e.questionCount){$(e.selector).find(".fca_qc_question_count").html(e.currentQuestion+1+"/"+e.questionCount);var t=e.questions[e.currentQuestion].question;$(e.selector).find("#fca_qc_question").html(t),$(e.selector).find("#fca_qc_question_back").html(t);var s=e.questions[e.currentQuestion].img;if($(e.selector).find("#fca_qc_answer_container").find(".fca_qc_quiz_question_img").attr("src",s),$(e.selector).find("#fca_qc_back_container").find(".fca_qc_quiz_question_img").attr("src",s),$(e.selector).find("#fca_qc_answer_container").data("id",e.questions[e.currentQuestion].id),e.questions[e.currentQuestion].correct)i=e.questions[e.currentQuestion].correct-1;else var i=0;if("mc"===e.quiz_settings.quiz_type||""===e.quiz_settings.quiz_type)var n=e.questions[e.currentQuestion].answers[i];if("off"!==quizzes[e.quiz_id].quiz_settings.fixed_answers&&quizzes[e.quiz_id].quiz_settings.fixed_answers)c=e.questions[e.currentQuestion].answers;else var c=shuffleArray(e.questions[e.currentQuestion].answers);e.currentQuestion+1<e.questionCount?lazyLoadQuestion(e.questions[e.currentQuestion+1]):lazyLoadResults(e),$(e.selector).find(".fca_qc_answer_div").hide();for(var r=0;r<c.length;r++){var a=void 0!==c[r].img&&""!==c[r].img,o=void 0!==c[r].answer&&""!==c[r].answer;(a||o)&&("mc"!==e.quiz_settings.quiz_type&&""!==e.quiz_settings.quiz_type||c[r].answer!==n.answer||c[r].img!==n.img||(e.currentAnswer=$(e.selector).find(".fca_qc_answer_div").eq(r).attr("data-question")),"pt"!==e.quiz_settings.quiz_type&&"wq"!==e.quiz_settings.quiz_type||$(e.selector).find(".fca_qc_answer_div").eq(r).data("results",c[r].results),$(e.selector).find(".fca_qc_answer_div").eq(r).find(".fca_qc_quiz_answer_img").attr("src",c[r].img),$(e.selector).find(".fca_qc_answer_div").eq(r).find(".fca_qc_answer_span").html(svg_square+c[r].answer),$(e.selector).find(".fca_qc_answer_div").eq(r).data("id",c[r].id),$(e.selector).find(".fca_qc_answer_div").eq(r).show())}$(e.selector).find("#fca_qc_answer_container").waitForImages(function(){maybe_add_quarter_class(e.selector),scale_flip_box_question(e.selector)}),e.currentQuestion=e.currentQuestion+1}else endTest(e)}function maxHeightOfElementSet(e){var t=0;return $.each(e,function(s){e.eq(s).outerHeight()>t&&(t=e.eq(s).outerHeight())}),t}function scale_flip_box_question(e){var t=$(e).find("#fca_qc_question").outerHeight(!0);t+=$(e).find(".fca_qc_quiz_question_img").outerHeight(!0);var s=0,i=0;$(e).find(".fca_qc_answer_div:visible").eq(0).hasClass("fca-qc-twoup")?(i=maxHeightOfElementSet($(e).find(".fca_qc_answer_div:visible")),s=$(e).find(".fca_qc_answer_div:visible").length,s=Math.floor(s/2)+s%2,t+=i*s):$(e).find(".fca_qc_answer_div:visible").eq(0).hasClass("fca-qc-threeup")?(i=maxHeightOfElementSet($(e).find(".fca_qc_answer_div:visible")),s=$(e).find(".fca_qc_answer_div:visible").length,t+=i*(s/=3)):$(e).find(".fca_qc_answer_div:visible").each(function(){t+=$(this).outerHeight(!0)}),t<200&&(t=200),$(e).find(".fca_qc_quiz_div, #fca_qc_answer_container, #fca_qc_back_container").outerHeight(t)}function scale_flip_box_back(e){var t=0;$(e).find("#fca_qc_back_container").children().each(function(){$(this).is(":visible")&&(t+=$(this).outerHeight(!0))}),(t+=35)<200&&(t=200),$(e).find(".fca_qc_quiz_div, #fca_qc_answer_container, #fca_qc_back_container").height(t)}function maybe_add_quarter_class(e){$(e).find(".fca_qc_answer_div").height("auto"),$(e).find(".fca_qc_answer_div").removeClass("fca-qc-twoup fca-qc-threeup"),$(e).find(".fca_qc_quiz_answer_img").css("marginBottom",0);var t=!0,s=0;if($(e).find(".fca_qc_answer_div:visible").each(function(){if(s++,""===$(this).find(".fca_qc_quiz_answer_img").attr("src")||!t)return t=!1,!1}),t){var i="fca-qc-twoup";s%3==0&&0===$(e).find(".fca_qc_mobile_check:visible").length&&(i="fca-qc-threeup"),$(e).find(".fca_qc_answer_div").addClass(i);var n=maxHeightOfElementSet($(e).find(".fca_qc_quiz_answer_img:visible"));n>200&&(n=200),$(e).find(".fca_qc_quiz_answer_img:visible").each(function(){$(this).css("marginBottom",n-$(this).height()+10+"px")});var c=maxHeightOfElementSet($(e).find(".fca_qc_answer_div:visible"));return $(e).find(".fca_qc_answer_div:visible").outerHeight(c),!0}return!1}function get_result(e){if(!e.quiz_results)return!1;if("pt"===e.quiz_settings.quiz_type){var t=[],s=-1;return $.each(e.quiz_results,function(e,t){t.hasOwnProperty("score")&&t.score>s&&(s=t.score)}),$.each(e.quiz_results,function(e,i){i.hasOwnProperty("score")&&i.score===s&&t.push(i)}),0===t.length&&(t=e.quiz_results),t[Math.floor(Math.random()*t.length)]}if("wq"===e.quiz_settings.quiz_type)for(i=0;i<e.quiz_results.length;i++)if(e.quiz_results[i].min<=e.score&&e.quiz_results[i].max>=e.score)return e.quiz_results[i];if("mc"===e.quiz_settings.quiz_type||""===e.quiz_settings.quiz_type)for(var i=0;i<e.quiz_results.length;i++)if(e.quiz_results[i].min<=e.score&&e.quiz_results[i].max>=e.score)return e.quiz_results[i];return!1}function show_responses(e){for(var t,s=0;s<e.questions.length;s++)t="",e.responses[s].isCorrect?t+="<div class='fca_qc_question_response_item correct-answer'>":t+="<div class='fca_qc_question_response_item wrong-answer'>",t+="<p class='fca_qc_question_response_question'>"+(s+1)+". "+e.questions[s].question+"</p>",t+="<img class='fca_qc_quiz_question_img' src='"+e.questions[s].img+"'>",t+="<p class='fca_qc_question_response_response'><span class='fca_qc_bold'>"+e.your_answer_string+" </span>"+e.responses[s].answer+"</p>",t+="<p class='fca_qc_question_response_correct_answer'><span class='fca_qc_bold'>"+e.correct_answer_string+" </span>"+e.responses[s].correctAnswer+"</p>",e.responses[s].hasOwnProperty("hint")&&(t+="<p class='fca_qc_question_response_hint'>"+e.responses[s].hint+"</p>"),t+="</div>",$(e.selector).find(".fca_qc_insert_response_above").before(t);$(e.selector).find(".fca_qc_your_answer_container").show()}function endTest(e){if($(e.selector).find(".fca_qc_quiz_footer").hide(),$(e.selector).find(".fca_qc_quiz_div").hide(),"mc"===e.quiz_settings.quiz_type||""===e.quiz_settings.quiz_type){var t=scoreString.replace("{{SCORE_CORRECT}}",e.score);t=t.replace("{{SCORE_TOTAL}}",e.questionCount),$(e.selector).find(".fca_qc_score_text").html(t)}"pt"!==e.quiz_settings.quiz_type&&"wq"!==e.quiz_settings.quiz_type||$(e.selector).find(".fca_qc_score_text").hide();var s=get_result(e);s&&($(e.selector).find(".fca_qc_score_title").html(s.title),$(e.selector).find(".fca_qc_score_img").attr("src",s.img),$(e.selector).find(".fca_qc_score_desc").html(s.desc)),"on"===e.optin_settings.capture_emails?show_optins(e,s):show_sharing_and_result_screen(e,s)}function show_optins(e,t){$(e.selector).find(".fca_qc_optin_input, .fca-qc-gdpr-consent").not(".tooltipstered").tooltipster({trigger:"custom",maxWidth:240,theme:["tooltipster-borderless","tooltipster-quiz-cat"]}),$(e.selector).find(".tooltipstered").tooltipster("close"),$(e.selector).find(".fca_qc_optin_container").show(),$(e.selector).find(".fca_qc_optin_input").first().focus(),$(e.selector).find(".fca_qc_skip_email_button").click(function(){$(e.selector).find(".fca_qc_optin_container").hide(),$(e.selector).find(".tooltipstered").tooltipster("close"),show_sharing_and_result_screen(e,t)}),$(e.selector).find(".fca_qc_submit_email_button").click(function(){var s=$(e.selector).find("#fca_qc_email_input").val(),i=$(e.selector).find("#fca_qc_name_input").val(),n=/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(s),c=""!==i||0===$(e.selector).find("#fca_qc_name_input").length;if($(e.selector).find(".fca_qc_optin_input").removeClass("fca_qc_invalid"),e.selector.offsetWidth=e.selector.offsetWidth,n&&c){$(e.selector).find(".tooltipstered").tooltipster("close");if(e.gdpr_checkbox){var r=$(e.selector).find(".fca-qc-gdpr-consent:visible");if(0==r.length)return $(e.selector).find(".fca-qc-gdpr").show(),$(e.selector).find(".fca_qc_optin_input").hide(),!1;if(0==r.prop("checked"))return r.tooltipster("open"),!1;!0}$(document).unbind("keypress"),$(e.selector).find(".tooltipstered").tooltipster("close"),e.user={name:i,email:s},add_to_mailing_list(e,s,i,t),$(e.selector).find(".fca_qc_optin_container").hide(),show_sharing_and_result_screen(e,t)}else n?($(e.selector).find("#fca_qc_email_input").tooltipster("close"),$(e.selector).find("#fca_qc_email_input").removeClass("fca_qc_invalid")):($(e.selector).find("#fca_qc_email_input").tooltipster("open"),$(e.selector).find("#fca_qc_email_input").addClass("fca_qc_invalid")),c?($(e.selector).find("#fca_qc_name_input").tooltipster("close"),$(e.selector).find("#fca_qc_name_input").removeClass("fca_qc_invalid")):($(e.selector).find("#fca_qc_name_input").tooltipster("open"),$(e.selector).find("#fca_qc_name_input").addClass("fca_qc_invalid"))}),0===$(e.selector).find(".fca_qc_skip_email_button").length&&0===$(e.selector).find(".fca_qc_submit_email_button").length?show_sharing_and_result_screen(e,t):$(document).keypress(function(t){if(13===t.which)return $(e.selector).find(".fca_qc_submit_email_button").click(),!1})}function add_to_mailing_list(e,t,s,i){if(fcaQcData.debug&&console.log(i),-1!==optins.indexOf(e.quiz_id))return fcaQcData.debug&&console.log("already opted in for this quiz! woop"),!1;optins.push(e.quiz_id);var n=jstz.determine();$.ajax({url:e.ajaxurl,type:"POST",data:{nonce:e.nonce,post_id:e.quiz_id,action:"fca_qc_add_to_mailing_list",email:t,name:s,result:get_result_text(e,i),tags:i.tags,groups:i.groups,timezone:n.name()}}).done(function(e){fcaQcData.debug&&console.log(e)})}function add_activity(e,t,s,i){if(0==fcaQcData.analytics)return!1;if("shares"===i){if(-1!==shared.indexOf(s))return fcaQcData.debug&&console.log("already shared this quiz! woop"),!1;shared.push(s)}else if("completions"===i){if(-1!==completed.indexOf(s))return fcaQcData.debug&&console.log("already completed this quiz! woop"),!1;completed.push(s)}$.ajax({url:e,type:"POST",data:{nonce:t,quiz_id:s,action:"fca_qc_activity",type:i}}).done(function(e){fcaQcData.debug&&console.log(e)})}function add_response(e,t,s,i,n){if(0==fcaQcData.analytics)return!1;$.ajax({url:e,type:"POST",data:{nonce:t,quiz_id:s,question:i,response:n,action:"fca_qc_add_response_ajax"}}).done(function(e){fcaQcData.debug&&console.log(e)})}function send_responses(e,t){var s="",i="",n="",c="unknown";if(0==fcaQcData.analytics)return!1;if(e.gdpr_checkbox){c=!!$(e.selector).find(".fca-qc-gdpr-consent").prop("checked")}e.hasOwnProperty("user")&&(s=e.user.name,i=e.user.email),n=t.hasOwnProperty("id")?t.id:e.score,$.ajax({url:e.ajaxurl,type:"POST",data:{nonce:e.nonce,quiz_id:e.quiz_id,name:s,email:i,gdpr_consent:c,result:n,result_text:get_result_text(e,t),responses:e.responses,action:"fca_qc_send_responses_ajax"}}).done(function(e){fcaQcData.debug&&console.log(e)})}function restart_quiz(e){location.href=location.origin+location.pathname+location.search+"#"+e.selector.id,location.reload(),location.href=location.origin+location.pathname+location.search+"#"+e.selector.id}function get_result_text(e,t){var s="";return t.hasOwnProperty("title")&&(s=t.title),"mc"!==e.quiz_settings.quiz_type&&""!==e.quiz_settings.quiz_type||(s=s?e.score+"/"+e.questionCount+": "+t.title:e.score+"/"+e.questionCount),s}function show_sharing_and_result_screen(e,t){send_responses(e,t),"redirect"===e.quiz_settings.result_mode?setTimeout(function(){window.location.href=t.url},1e3):("on"===e.quiz_settings.restart_button&&$("#fca_qc_restart_button").click(function(){restart_quiz(e),$(this).hide()}).show("fast"),"end"===e.hideAnswers&&show_responses(e),"on"===e.quiz_settings.show_sharing&&show_sharing(e,t),$(e.selector).find(".fca_qc_score_container").show())}function get_correct_answer_html(e){var t="",s="";return $(e.selector).find(".fca_qc_answer_div").each(function(){$(this).attr("data-question")===e.currentAnswer&&(t=addQuizImg($(this).find(".fca_qc_quiz_answer_img").attr("src")),s=$(this).find(".fca_qc_answer_span").html().replace(svg_square,""))}),t+s}function fix_hover(e){$(e.selector).find(".fca_qc_answer_div").hover(function(e){$(this).addClass("fakehover"),$(this).children("span").addClass("fakehover")},function(e){$(this).removeClass("fakehover"),$(this).children("span").removeClass("fakehover")})}function show_sharing(e,t){$(e.selector).find(".fca_qc_social_share").show("fast");var s=$(e.selector).find(".fca_qc_score_img").attr("src");""===s&&(s=$(e.selector).find(".fca_qc_quiz_description_img").attr("src")),""===s&&(s=default_img);var i=$(e.selector).find("#fca_qc_share_link_facebook");1===i.length&&(0==t?i.prop("href",i.prop("href")+"0"+encodeURIComponent("&fca_qc_title="+get_result_text(e,t))):i.prop("href",i.prop("href")+e.quiz_results.indexOf(t)+encodeURIComponent("&fca_qc_title="+get_result_text(e,t))));var n=$(e.selector).find("#fca_qc_share_link_twitter");1===n.length&&(n.data("sharestring",encodeURIComponent(n.data("sharestring").replace("{{MY_QUIZ_RESULT}}",get_result_text(e,t)))),n.prop("href",n.prop("href")+encodeURIComponent("&fca_qc_title="+get_result_text(e,t).replace(/ /g,"+"))+"&text="+n.data("sharestring")));var c=$(e.selector).find("#fca_qc_share_link_email");1===c.length&&encode_share_link(c,get_result_text(e,t)),iOS&&c.hide();var r=$(e.selector).find("#fca_qc_share_link_pinterest");1===r.length&&(encode_share_link(r,get_result_text(e,t)),r.prop("href",r.prop("href")+"&media="+s)),$(e.selector).find(".fca_qc_share_link").click(function(t){t.preventDefault();var s=$(this).prop("href");window.open(s,"_blank","resizable=yes,scrollbars=yes,titlebar=yes, width=560, height=443, top=100, left=50"),add_activity(e.ajaxurl,e.nonce,e.quiz_id,"shares")})}function encode_share_link(e,t){var s=encodeURIComponent(e.data("sharestring").replace("{{MY_QUIZ_RESULT}}",t)),i=e.prop("href");e.prop("href",i+s)}function shuffleArray(e){for(var t=e.length-1;t>0;t--){var s=Math.floor(Math.random()*(t+1)),i=e[t];e[t]=e[s],e[s]=i}return e}function addQuizImg(e){return e&&""!==e&&"string"==typeof e?"<img class='fca_qc_quiz_answer_img' src='"+e+"'>":""}function scrollQuizInToView(e){var t=$(e).offset().top+-100;t<0&&(t=0),$("html, body").animate({scrollTop:t},300)}function debounce(e,t,s){var i;return function(){var n=this,c=arguments,r=s&&!i;clearTimeout(i),i=setTimeout(function(){i=null,s||e.apply(n,c)},t),r&&e.apply(n,c)}}var usingOldBrowser=isIE()||isOldAndroidVersion(),iOS=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,scoreString=$(".fca_qc_score_text").first().html(),svg_square='<svg xmlns="http://www.w3.org/2000/svg" class="fca_qc_rectancle" width="26" height="26"><rect class="fca_qc_checkbox" width="26" height="26"></rect></svg>',quizzes={},default_img="";loadQuizzes(),fcaQcData.debug&&console.log(quizzes),preloadImages(),$(".fca_qc_start_button").click(function(){startQuiz(quizzes[get_quiz_id($(this).closest(".fca_qc_quiz"))])}),$(".fca_qc_next_question").click(function(){var e=quizzes[get_quiz_id($(this).closest(".fca_qc_quiz"))];usingOldBrowser?($(e.selector).find("#fca_qc_answer_container").show(),$(e.selector).find("#fca_qc_back_container").hide()):$(e.selector).find(".fca_qc_quiz_div").removeClass("flip"),showQuestion(e)}),$(".fca_qc_answer_div").click(function(){var e=quizzes[get_quiz_id($(this).closest(".fca_qc_quiz"))];$(this).blur(),$(".fakehover").removeClass("fakehover");var t=$(this).closest("#fca_qc_answer_container").data("id"),s=$(this).data("id"),i=!1;if(1===e.currentQuestion&&add_activity(e.ajaxurl,e.nonce,e.quiz_id,"starts"),"wq"===e.quiz_settings.quiz_type){var n=parseInt(e.questions[e.currentQuestion-1].answers.filter(function(e){return e.id===s})[0].points);isNaN(n)||(e.score=parseInt(e.score)+n)}else $(this).attr("data-question")===e.currentAnswer&&(e.score=e.score+1,i=!0);var c={answer:addQuizImg($(this).children(".fca_qc_quiz_answer_img").attr("src"))+$(this).children(".fca_qc_answer_span").html().replace(svg_square,""),answer:addQuizImg($(this).children(".fca_qc_quiz_answer_img").attr("src"))+$(this).children(".fca_qc_answer_span").html().replace(svg_square,""),isCorrect:i,correctAnswer:get_correct_answer_html(e),question:$(this).siblings("#fca_qc_question").html(),id:t,response:s};if("on"===e.quiz_settings.explanations){1===(a=e.questions[e.currentQuestion-1].answers.filter(function(e){return e.hasOwnProperty("hint")})).length&&(c.hint=a[0].hint)}if(e.responses.push(c),add_response(e.ajaxurl,e.nonce,e.quiz_id,t,s),"pt"===e.quiz_settings.quiz_type)$.each($(this).data("results"),function(t,s){$.each(e.quiz_results,function(e,t){s===t.id&&(t.hasOwnProperty("score")?t.score=t.score+1:t.score=1)})}),showQuestion(e);else if("wq"===e.quiz_settings.quiz_type)$.each($(this).data("results"),function(t,s){$.each(e.quiz_results,function(e,t){s===t.id&&(t.hasOwnProperty("score")?t.score=t.score+1:t.score=1)})}),showQuestion(e);else if("after"===e.hideAnswers){$(e.selector).find("#fca_qc_your_answer").html(addQuizImg($(this).children(".fca_qc_quiz_answer_img").attr("src"))+$(this).children(".fca_qc_answer_span").html().replace(svg_square,""));var r=get_correct_answer_html(e);if($(e.selector).find("#fca_qc_correct_answer").html(r),"on"===e.quiz_settings.explanations){var a=e.questions[e.currentQuestion-1].answers.filter(function(e){return e.hasOwnProperty("hint")});1===a.length?$(e.selector).find("#fca_qc_hint_p").html(a[0].hint):$(e.selector).find("#fca_qc_hint_p").html("")}usingOldBrowser?($(e.selector).find("#fca_qc_answer_container").hide(),$(e.selector).find("#fca_qc_back_container").show()):$(e.selector).find(".fca_qc_quiz_div").addClass("flip"),$(e.selector).find("#fca_qc_back_container").removeClass("correct-answer"),$(e.selector).find("#fca_qc_back_container").removeClass("wrong-answer"),i?($(e.selector).find("#fca_qc_back_container").addClass("correct-answer"),$(e.selector).find("#fca_qc_question_right_or_wrong").html(e.correct_string),$(e.selector).find("#fca_qc_correct_answer_p").hide()):($(e.selector).find("#fca_qc_back_container").addClass("wrong-answer"),$(e.selector).find("#fca_qc_question_right_or_wrong").html(e.wrong_string),$(e.selector).find("#fca_qc_correct_answer_p").show()),scale_flip_box_back(e.selector)}else showQuestion(e);scrollQuizInToView(e.selector)});var optins=[],shared=[],completed=[],resizeWindow=debounce(function(){jQuery.each(quizzes,function(e){$(quizzes[e].selector).find("#fca_qc_answer_container").waitForImages(function(){maybe_add_quarter_class(quizzes[e].selector),$("#fca_qc_back_container").is(":visible")?scale_flip_box_back(quizzes[e].selector):scale_flip_box_question(quizzes[e].selector)})})},50)}); -
quiz-cat/trunk/includes/quiz/quiz.php
r2475292 r2622618 86 86 } 87 87 88 $quiz_text_strings = fca_qc_set_quiz_text_strings( $ atts);88 $quiz_text_strings = fca_qc_set_quiz_text_strings( $post_id ); 89 89 90 90 $quiz_data = array( … … 244 244 color: <?php echo $next_button_font_color ?>; 245 245 border: <?php echo $next_button_border_color . ' 2px solid' ?>; 246 background-color: transparent; 246 247 } 247 248 … … 282 283 283 284 //SET UP THE MAIN QUIZ TEXTS FOR A QUIZ - CHECK FOR LOCALIZED STRINGS, THEN ANY PHP FILTERS, THEN SHORTCODES 284 function fca_qc_set_quiz_text_strings( $ atts = array()) {285 function fca_qc_set_quiz_text_strings( $post_id ) { 285 286 286 287 global $global_quiz_text_strings; 287 288 288 $quiz_text_strings = apply_filters( 'fca_qc_quiz_text', $global_quiz_text_strings ); 289 289 // Check for custom translations from the editor 290 $translations = get_post_meta ( $post_id, 'quiz_cat_translations', true ); 291 $text_strings = empty( $translations ) ? $global_quiz_text_strings : $translations; 292 293 $quiz_text_strings = apply_filters( 'fca_qc_quiz_text', $text_strings ); 294 295 // Then check for shortcode strings which overwrite translations 290 296 $shortcode_text_strings = array ( 291 297 … … 311 317 'pin' => empty( $atts['pin'] ) ? false : $atts['pin'], 312 318 'email' => empty( $atts['email'] ) ? false : $atts['email'], 313 314 319 315 320 ); 316 321 317 //CHECK SHORTCODES FOR TRANSLATIONS & OVERWRITE318 322 forEach ( $quiz_text_strings as $key => $value ) { 319 323 if ( !empty ( $shortcode_text_strings[$key] ) && $shortcode_text_strings[$key] !== false ) { 320 324 $quiz_text_strings[$key] = $shortcode_text_strings[$key]; 321 } 322 } 323 325 } 326 } 327 324 328 return $quiz_text_strings; 325 329 -
quiz-cat/trunk/quizcat.php
r2566881 r2622618 9 9 Author URI: https://fatcatapps.com/ 10 10 License: GPLv2 11 Version: 2.0. 611 Version: 2.0.7 12 12 */ 13 13 … … 25 25 define( 'FCA_QC_PLUGIN_VER', '2.0.' . time() ); 26 26 } else { 27 define( 'FCA_QC_PLUGIN_VER', '2.0. 6' );27 define( 'FCA_QC_PLUGIN_VER', '2.0.7' ); 28 28 } 29 29 define( 'FCA_QC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); -
quiz-cat/trunk/readme.txt
r2566881 r2622618 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 Stable tag: 2.0. 611 Stable tag: 2.0.7 12 12 13 13 Quiz Cat Lets You Create Beautiful Viral BuzzFeed-style Quizzes That Drive Social Shares & User Engagement. Set It Up In 2 Minutes. … … 171 171 == Changelog == 172 172 173 = Quiz Cat 2.0.7 = 174 * Added "Translations" tab to customize all quiz text 175 * Fixed some classnames so themes don't override quiz styles 176 * Fixed scroll issue with very long questions on frontend 177 * Tested with WordPress 5.8.1 178 173 179 = Quiz Cat 2.0.6 = 174 180 * Fixed save confirmation dialog in admin panel, now only shows when quiz data has changed -
quiz-cat/trunk/readmes/business.txt
r2566881 r2622618 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 Stable tag: 2.0. 611 Stable tag: 2.0.7 12 12 13 13 Quiz Cat Lets You Create Beautiful Viral BuzzFeed-style Quizzes That Drive Social Shares & User Engagement. Set It Up In 2 Minutes. … … 147 147 == Changelog == 148 148 149 = Quiz Cat 2.0.7 = 150 * Added "Translations" tab to customize all quiz text 151 * Added "quiz type" column in admin panel 152 * Fixed some classnames so themes don't override quiz styles 153 * Fixed scroll issue with very long questions on frontend 154 * Fixed social media sharing translations 155 * Tested with WordPress 5.8.1 156 149 157 = Quiz Cat 2.0.6 = 150 158 * Fixed save confirmation dialog in admin panel, now only shows when quiz data has changed -
quiz-cat/trunk/readmes/elite.txt
r2566881 r2622618 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 Stable tag: 2.0. 611 Stable tag: 2.0.7 12 12 13 13 Quiz Cat Lets You Create Beautiful Viral BuzzFeed-style Quizzes That Drive Social Shares & User Engagement. Set It Up In 2 Minutes. … … 147 147 == Changelog == 148 148 149 = Quiz Cat 2.0.7 = 150 * Added "Translations" tab to customize all quiz text 151 * Added "quiz type" column in admin panel 152 * Fixed some classnames so themes don't override quiz styles 153 * Fixed scroll issue with very long questions on frontend 154 * Fixed social media sharing translations 155 * Tested with WordPress 5.8.1 156 149 157 = Quiz Cat 2.0.6 = 150 158 * Fixed save confirmation dialog in admin panel, now only shows when quiz data has changed -
quiz-cat/trunk/readmes/free.txt
r2566881 r2622618 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 Stable tag: 2.0. 611 Stable tag: 2.0.7 12 12 13 13 Quiz Cat Lets You Create Beautiful Viral BuzzFeed-style Quizzes That Drive Social Shares & User Engagement. Set It Up In 2 Minutes. … … 171 171 == Changelog == 172 172 173 = Quiz Cat 2.0.7 = 174 * Added "Translations" tab to customize all quiz text 175 * Fixed some classnames so themes don't override quiz styles 176 * Fixed scroll issue with very long questions on frontend 177 * Tested with WordPress 5.8.1 178 173 179 = Quiz Cat 2.0.6 = 174 180 * Fixed save confirmation dialog in admin panel, now only shows when quiz data has changed -
quiz-cat/trunk/readmes/personal.txt
r2566881 r2622618 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 Stable tag: 2.0. 611 Stable tag: 2.0.7 12 12 13 13 Quiz Cat Lets You Create Beautiful Viral BuzzFeed-style Quizzes That Drive Social Shares & User Engagement. Set It Up In 2 Minutes. … … 146 146 == Changelog == 147 147 148 = Quiz Cat 2.0.7 = 149 * Added "Translations" tab to customize all quiz text 150 * Added "quiz type" column in admin panel 151 * Fixed some classnames so themes don't override quiz styles 152 * Fixed scroll issue with very long questions on frontend 153 * Fixed social media sharing translations 154 * Tested with WordPress 5.8.1 155 148 156 = Quiz Cat 2.0.6 = 149 157 * Fixed save confirmation dialog in admin panel, now only shows when quiz data has changed
Note: See TracChangeset
for help on using the changeset viewer.