/** * Created by Atomic 1 on 8/7/2015. */ jQuery(document).ready(function ($) { // ATOMIC REACH SCORE REMINDER $("#awAdminNoticeSignup").click(function (e) { e.preventDefault(); $('html, body').animate({ scrollTop: $("#aranalyzer_metabox").offset().top }, 1000, function () { // Animation complete. $("#aranalyzer_metabox .inside").addClass('aw-glow'); setTimeout(function () { $("#aranalyzer_metabox .inside").removeClass('aw-glow'); }, 1000) }); }); (function () { var s = $("#aranalyzer_metabox .inside #awScoreReminder"); $.ajax({ type: 'POST', url: ajaxurl, data: {'action': 'awCheckScoreFreq_ajax'}, success: function (arScoreReminder) { if (typeof arScoreReminder == 'undefined') return; /* * 20 = activated for more than a day but never scored any post. * 22 = Last time user scored any post is more than 4 days. * */ if (arScoreReminder == 20) { s.find('h2').html("Don't forget to edit your article with AtomicWriter!"); showReminderMessage(); } else if (arScoreReminder == 22) { s.find('h2').html("See how you can quickly edit your article for your audience."); showReminderMessage(); } } }) function showReminderMessage(){ //hide after 10 seconds. s.slideToggle('slow', function () { $("#aranalyzer_metabox .inside").addClass('aw-glow'); setTimeout(function () { s.slideToggle("slow", function(){ $("#aranalyzer_metabox .inside").removeClass('aw-glow'); }); }, 4000) }) } })(); // ATOMIC REACH SCORE REMINDER $("#aw-goTosignUpForm").click(function (e) { e.preventDefault(); $("#aw-signIn").fadeOut(function () { // Animation complete. $("#aw-signUp").fadeIn(); }); }); $("#aw-goTosignInForm").click(function (e) { e.preventDefault(); $("#aw-signUp").fadeOut(function () { // Animation complete. $("#aw-signIn").fadeIn(); }); }); $("#aw-signUpForm").submit(function (e) { e.preventDefault(); var email = $("#aw-signUpEmail").val(); var pass = $("#aw-signUpPassword").val(); var pass2 = $("#aw-signUpPasswordReType").val(); if (pass != pass2) { $("#aw-API-Error").html("Password do not match!").show().delay(5000).fadeOut("slow", function () { $(this).empty() }); return; } if (!jQuery("#tos").is(":checked")) { $("#aw-API-Error").html("Unfortunately you cannot set up an account without accepting our Terms of Use. Please feel free to use our" + " Web App.").show().delay(9000).fadeOut("slow", function () { $(this).empty() }); return; } var newtab = window.open('', '', "width=600, height=800, menubar=0, status=0, titlebar=0, toolbar=0"); //var newtab = window.open('','_blank') ; var data = { 'action': 'awSignUpEmail_ajax', 'email': email, 'test': 'test', 'pass': pass }; $.post(ajaxurl, data, function (response) { console.log(response); if (!response.match(/ok/g)) { newtab.close(); var value = JSON.parse(response); if (typeof value.data.email !== 'undefined') { emailMessages = Object.keys(value.data.email); $.map(emailMessages, function (val, i) { $("#aw-API-Error").append("
Create Account - Email Error: " + value.data.email[val] + "
"); }); } if (typeof value.data.password !== 'undefined') { passwordMessages = Object.keys(value.data.password); $.map(passwordMessages, function (val, i) { $("#aw-API-Error").append("Create Account - Password Error: " + value.data.password[val] + "
"); }); } $("#aw-API-Error").show().delay(5000).fadeOut("slow", function () { $(this).empty() }); } else { var x = response.split("-"); newtab.location = 'https://www.atomicreach.com/wordpress-signup/?accountId=' + x[1]; $("#aw-atomicAdminNotice").fadeOut(); $("#AW-StandBy").load("../wp-content/plugins/atomic-reach-audience-engager/custom/html/audSlider-score.html", function () { $("#AW-notLoggedIn").slideUp("slow", function () { $("#AW-StandBy").slideDown("slow"); createTooltipsyForTheI(); }); }); } }).done(function () { }).always(function () { }); }); $("#aw-signInFormSubmit").click(function (e) { e.preventDefault(); var email = $("#aw-signInEmail").val(); var pass = $("#aw-signInPassword").val(); var data = { 'action': 'awSignInEmail_ajax', 'email': email, 'test': 'test', 'pass': pass }; $.ajax({ type: 'POST', url: ajaxurl, data: data, async: false, success: function (response) { if (response != 'ok') { //clearTimeout(myVar); $("#aw-API-Error").html(response).fadeIn().delay(5000).fadeOut("slow"); } else if (response == 'ok') { $("#aw-atomicAdminNotice").fadeOut(); $("#AW-StandBy").load("../wp-content/plugins/atomic-reach-audience-engager/custom/html/audSlider-score.html", function () { $("#AW-notLoggedIn").slideUp("slow", function () { $("#AW-StandBy").slideDown("slow"); createTooltipsyForTheI(); }); }); } }, done: function () { }, always: function () { } }); }); var audBand = 5; // change audience slider $("#aranalyzer_metabox").on("change", '.ar-aud-slider_WP', function (e) { var audnum = $(this).val(); var audText = ''; if (audnum == 1) { audText = 'General'; audBand = 5; $('#ar_desc-aud_WP, #ar_desc-aud_WP2').html("Beginner Novice Basic") } else if (audnum == 2) { audText = 'Knowledgeable'; audBand = 4; $('#ar_desc-aud_WP, #ar_desc-aud_WP2').html("Aware Familiar Informed"); } else if (audnum == 3) { audText = 'Specialist'; audBand = 3; $('#ar_desc-aud_WP, #ar_desc-aud_WP2').html("Advanced Trained Well-versed") } else if (audnum == 4) { audText = 'Academic'; audBand = 2; $('#ar_desc-aud_WP, #ar_desc-aud_WP2').html("Scholarly Collegiate Masterful") } else if (audnum == 5) { audText = 'Genius'; audBand = 1; $('#ar_desc-aud_WP, #ar_desc-aud_WP2').html("Expert Brilliant Intellectual") } $('#arSelectedAud_WP, #arSelectedAud2').text(audText).removeClass().addClass(audText + "ColorText"); $('#ar_desc-aud_WP, #ar_desc-aud_WP2').removeClass().addClass(audText + "ColorText"); targetAud = audText.toUpperCase(); }); // Click Score button $("#aranalyzer_metabox").on("click", "#arScore_WP", function (e) { e.preventDefault(); var title = $("#title").val(); var content = tinyMCE.activeEditor.getContent(); if (title == "") { $("#right-score").html("ERROR! : Title is missing. Please write your title and try again.").fadeIn().delay(5000).fadeOut(); return; } if (content == "") { $("#right-score").html("ERROR! : Content is missing. Please write some content and try again.").fadeIn().delay(5000).fadeOut(); return; } var data = { 'action': 'aranalyzer_ajax', 'arTitle': title, 'arContent': content, 'segmentId': audBand }; $.ajax({ type: "POST", url: ajaxurl, data: data, beforeSend: function () { if ($("#right-score").is(":visible")) { $("#right-score").slideUp(function () { $("#AW-staticBlock").fadeOut(function () { $("#awloadingBlock").fadeIn(); }); }); } else { $("#AW-staticBlock").fadeOut(function () { $("#awloadingBlock").fadeIn(); }); } clearAllhighlighting(); }, success: function (response) { $("#right-score").html(response).hide(); ARTabs(); ar_tips(); ar_tipsread(); }, error: function (response) { }, complete: function () { $("#awloadingBlock").fadeOut(function () { $("#AW-staticBlock").fadeIn(function () { $("#right-score").slideDown("slow"); }) }); //$("#arScore_WP").text("Rescore") } }); }); /********************************/ /**** Score Button & new-meta.php Tabs ui ****/ /********************************/ $("#right-score").on("load", "ul.AR-tabs", ARTabs()); function ARTabs() { $('ul.AR-tabs').each(function () { // For each set of tabs, we want to keep track of // which tab is active and it's associated content var $active, $content, $links = $(this).find('a'); // If the location.hash matches one of the links, use that as the active tab. // If no match is found, use the first link as the initial active tab. $active = $($links.filter('[href="' + location.hash + '"]')[0] || $links[2]); $active.addClass('active'); $content = $($active[0].hash); // Hide the remaining content $links.not($active).each(function () { $(this.hash).hide(); }); // Bind the click event handler $(this).on('click', 'a', function (e) { // Make the old tab inactive. $active.removeClass('active'); $content.hide(); // Update the variables with the new link and content $active = $(this); $content = $(this.hash); // Make the tab active. $active.addClass('active'); $content.show(); // Prevent the anchor's default click action e.preventDefault(); }); }); } function ar_tips() { if (titleKeywordState.toLowerCase() != 'green') { $("#ar-kword").tooltipsy({ offset: [-10, 0], className: 'arTooltipsy', content: 'Your Keywords:' + tgKeywords + '
' }); } if (lengthState == 'red' || 'yellow') { $("#ar-ln").tooltipsy({ offset: [-10, 0], className: 'arTooltipsy', content: 'Tip:The knowledge levels to choose from are:
" +
"General - your audience has a basic understanding of the content topic or theme.
" +
"Knowledgeable - your audience has an advanced understanding of content or theme.
" +
"Specialist - your audience has a superior understanding of content or theme.
" +
"Academic - your audience has a proficient understanding of content or theme.
" +
"Genius - your audience has an expert understanding of content or theme.