]*?)?>/i); if( n < 0 ){ var phrase = wpforo_phrase(notice); if( arguments.length > 2 ){ var i; for( i = 2; i < arguments.length; i++ ){ if( arguments[i] !== undefined ) phrase = phrase.replace(/%[dfs]/, arguments[i]); } } notice = '
' + phrase + '
'; } notice = jQuery(notice); var msg_box = jQuery("#wpf-msg-box"); msg_box.append(notice); msg_box.appendTo('body'); msg_box.show(150); notice.delay(type === 'error' ? 6500 : 2500).fadeOut(200, function () { jQuery(this).remove(); }); } function wpforo_notice_hide(){ jQuery("#wpf-msg-box").hide(); } function wpforo_load_show(msg){ msg = typeof msg !== "undefined" ? msg : 'Working'; msg = String(msg); msg = wpforo_phrase(msg); var load = jQuery('#wpforo-load'); jQuery('.loadtext', load).text(msg); load.appendTo('body'); wpforo_notice_hide(); load.visible(); } function wpforo_load_hide(){ jQuery('#wpforo-load').invisible(); } function wpforo_init_dialog(){ jQuery('#wpforo-dialog-extra-wrap').on("click", "#wpforo-dialog-close", function () { wpforo_dialog_hide(); }); jQuery(document).on("mousedown", "#wpforo-dialog-extra-wrap", function (e) { if( !jQuery(e.target).closest('#wpforo-dialog').length ) wpforo_dialog_hide(); }); jQuery(document).on("keydown", function (e) { if( e.which === 27 ) wpforo_dialog_hide(); }); } function wpforo_dialog_show(title, content, w, h){ var dialog = jQuery('#wpforo-dialog'); if(content){ var dialog_body = jQuery("#wpforo-dialog-body", dialog); dialog_body.children().appendTo('#wpforo-dialog-backups'); dialog_body.empty(); if( content instanceof jQuery){ content.appendTo(dialog_body); content.show(); content.css('visibility', 'visible'); if(!title) title = content.data('title'); }else if( typeof content === 'string'){ dialog_body.html(content); } } if(title) jQuery("#wpforo-dialog-title", dialog).html( wpforo_phrase(title) ); if(w) dialog.css('width', w); if(h) dialog.css('height', h); jQuery("#wpforo-dialog-extra-wrap").appendTo('body'); jQuery("html").addClass('wpforo-dialog-visible'); jQuery("body").addClass('wpforo-dialog-visible animated fadeIn'); } function wpforo_dialog_hide(){ jQuery("html").removeClass('wpforo-dialog-visible'); jQuery("body").removeClass('wpforo-dialog-visible animated fadeIn'); } function wpforo_phrase(phrase_key){ // if( !(window.wpforo_phrases && typeof window.wpforo_phrases === 'object' && Object.keys(window.wpforo_phrases).length) ) wpforo_init_phrases(); if( window.wpforo_phrases && typeof window.wpforo_phrases === 'object' && Object.keys(window.wpforo_phrases).length ){ var phrase_key_lower = phrase_key.toLowerCase(); if( window.wpforo_phrases[phrase_key_lower] !== undefined ) phrase_key = window.wpforo_phrases[phrase_key_lower]; } return phrase_key; } function wpforo_getTextSelection(){ jQuery("#wpf_multi_quote").remove(); if (window.getSelection) { var sel = window.getSelection(); if ( sel && sel.anchorNode && sel.anchorNode.parentNode && sel.anchorNode.parentNode.tagName !== 'A' ) { var selectedText = sel.toString().trim(); if ( sel.rangeCount && selectedText.length ) { var getRangeAt_0 = sel.getRangeAt(0); var rangeBounding = getRangeAt_0.getBoundingClientRect(); var bodyBounding = document.documentElement.getBoundingClientRect(); var left = rangeBounding.left + rangeBounding.width/2 + Math.abs( bodyBounding.left ) - 15; var top = rangeBounding.bottom + Math.abs( bodyBounding.top ) + 50; var parent = jQuery(getRangeAt_0.commonAncestorContainer).closest('.wpforo-post-content, .wpforo-comment-content'); var noNeedParent = jQuery(getRangeAt_0.commonAncestorContainer).closest('.wpforo-post-signature, .wpforo-post-content-bottom, .wpf-post-button-actions'); var noNeedChild = jQuery(getRangeAt_0.endContainer).closest('.wpforo-post-signature, .wpforo-post-content-bottom, .wpf-post-button-actions'); if( parent.length && !noNeedParent.length && !noNeedChild.length ){ var toolTip = jQuery(''); toolTip.css({top: top, left: left}); var link = jQuery('').on('mousedown touchstart', function () { var container = document.createElement("div"); for (var i = 0; i < sel.rangeCount; ++i) container.appendChild(sel.getRangeAt(i).cloneContents()); var post_wrap = jQuery(getRangeAt_0.startContainer).parents('[data-postid]'); var userid = post_wrap.data('userid'); if( !userid ) userid = 0; var postid = post_wrap.data('postid'); if( !postid ) postid = 0; var mention_html = ''; var mention = post_wrap.data('mention'); if( mention ){ mention_html = ''; }else{ mention = ''; } var editorContent = ''+ mention_html +''; wpforo_editor.insert_content( editorContent, wpforo_editor.get_main() ); jQuery('html, body').animate({ scrollTop: jQuery("form.wpforo-main-form").offset().top }, 500); jQuery(this).remove(); }); toolTip.append(link); jQuery('body').append(toolTip); } } } } } window.wpforo_fix_form_data_attributes = function(){ jQuery('form textarea[id^="wpf_"]:first').each(function(t){ var form = jQuery(this).closest('form'); var id = jQuery(this).attr('id'); form.attr('data-textareaid', id); form.prop('data-textareaid', id); form.data('textareaid', id); }); } jQuery(document).ready(function($){ var wpforo_wrap = $('#wpforo-wrap'); var scroll_to; var exreg = new RegExp('\/' + wpforo.template_slugs['postid'] + '\/(\\d+)\/?$', 'i'); var match = location.pathname.match(exreg); if(match){ scroll_to = $('#post-' + match[1]); }else{ //scroll_to = $("#m_, .wpforo-members-content, .wpforo-search-content", wpforo_wrap); } if( scroll_to != undefined && scroll_to.length ){ $('html, body').scrollTop(scroll_to.offset().top - 25); } wpforo_init_dialog(); if ($('form.wpforo-main-form').length) { document.onselectionchange = function () { wpforo_getTextSelection(); }; } window.onbeforeunload = function(e) { var forms = $('form[data-textareaid]').not(":hidden"); if( forms.length ){ var i, textareaid; for( i = 0; i < forms.length; i++ ){ textareaid = $( forms[i] ).data('textareaid'); if( wpforo_editor.get_stats(textareaid).has_content ){ e = e || window.event; e.returnValue = wpforo_phrase("Write something clever here.."); return wpforo_phrase("Write something clever here.."); } } } }; window.wpforo_fix_form_data_attributes(); setTimeout(function () { wpforo_editor.fix_textareaid(); wpforo_editor.set_main('', true); }, 1000); wpforo_wrap.on('click drop', 'form[data-textareaid]', function () { var textareaid = $(this).data('textareaid'); wpforo_editor.set_active(textareaid); }); wpforo_wrap.on('focus', 'form[data-textareaid] textarea', function () { var textareaid = $(this).parents('form[data-textareaid]').data('textareaid'); if( textareaid === this.id ) wpforo_editor.set_active(this.id); }); wpforo_wrap.on('keydown', 'form[data-textareaid]', function (e) { if (e.ctrlKey && e.keyCode === 13) { $('[type=submit]', $(this)).click(); }else if( (e.ctrlKey && e.which === 83) || e.which === 19 ){ wpforo_trigger_custom_event(document, 'wpforo_textarea_ctrl_s', e); e.preventDefault(); return false; } }); if( $('.wpforo-recent-content .wpf-p-error', wpforo_wrap).length ){ $('.wpf-navi', wpforo_wrap).remove(); } /** * prevent multi submitting * disable form elements for 10 seconds */ window.wpforo_prev_submit_time = 0; wpforo_wrap.on('submit', 'form', function () { if( window.wpforo_prev_submit_time ){ if( Date.now() - window.wpforo_prev_submit_time < 10000 ) return false; }else{ var textareaid = $(this).data('textareaid'); if( textareaid ){ var bodyminlength = $(this).data('bodyminlength'); var bodymaxlength = $(this).data('bodymaxlength'); if( bodyminlength || bodymaxlength ){ var body_stat = wpforo_editor.get_stats(textareaid); if( bodyminlength ){ if( body_stat.chars < bodyminlength && !body_stat.embeds && !body_stat.links && !body_stat.imgs ){ wpforo_notice_show('Content characters length must be greater than %d', 'error', bodyminlength); return false; } } if( bodymaxlength ){ if( body_stat.chars > bodymaxlength ){ wpforo_notice_show('Content characters length must be smaller than %d', 'error', bodymaxlength); return false; } } } } wpforo_load_show(); window.wpforo_prev_submit_time = Date.now(); window.onbeforeunload = null; setTimeout(function () { window.wpforo_prev_submit_time = 0; wpforo_load_hide(); }, 10000); } }); wpforo_wrap.on('click', '.wpf-spoiler-head', function(){ var spoiler_wrap = $(this).parents('.wpf-spoiler-wrap'); if( spoiler_wrap.length ){ spoiler_wrap = $(spoiler_wrap[0]); if( !spoiler_wrap.hasClass('wpf-spoiler-processing') ){ spoiler_wrap.toggleClass("wpf-spoiler-open").addClass("wpf-spoiler-processing"); var spoiler_body = $('.wpf-spoiler-body', spoiler_wrap); if( spoiler_body.length ){ var spoiler_chevron = $('.wpf-spoiler-chevron', spoiler_wrap); $(spoiler_chevron[0]).toggleClass('fa-chevron-down fa-chevron-up'); $(spoiler_body[0]).slideToggle(500, function () { spoiler_wrap.removeClass("wpf-spoiler-processing"); if( !spoiler_wrap.hasClass('wpf-spoiler-open') ){ $('.wpf-spoiler-wrap.wpf-spoiler-open .wpf-spoiler-head', spoiler_wrap).click(); } }); } } } }); wpforo_wrap.on('click', '#add_wpftopic:not(.not_reg_user)', function(){ var form = $( ".wpf-topic-create" ); var stat = form.is( ":hidden" ); form.slideToggle( "slow" ); wpforo_editor.set_content(''); $('[name="topic[title]"]').focus(); var add_wpftopic = ''; if( !stat ) add_wpftopic = $('input[type="submit"]', form).val(); $(this).html(add_wpftopic); $('html, body').animate({ scrollTop: ($(this).offset().top - 35) }, 415); }); wpforo_wrap.on('click', '.wpf-answer-button .wpf-button:not(.not_reg_user)', function(){ $(this).closest('.wpf-bottom-bar').hide(); }); wpforo_wrap.on('click', '.wpfl-4 .add_wpftopic:not(.not_reg_user)', function(){ $( '.wpf-topic-form-ajax-wrap').empty(); var wrap = $(this).parents('div.wpfl-4'); var form_wrap = $( ".wpf-topic-form-extra-wrap", wrap ); var stat = form_wrap.is( ":hidden" ); $(".wpfl-4 .add_wpftopic").html($(".wpfl-4 .add_wpftopic").data('phrase')); $(".wpf-topic-form-extra-wrap").slideUp("slow"); var add_wpftopic = ''; if( stat ){ add_wpftopic = ''; form_wrap.slideDown("slow"); }else{ add_wpftopic = $(this).data('phrase'); form_wrap.slideUp("slow"); } var option_no_selected = $( 'option.wpf-topic-form-no-selected-forum' ); option_no_selected.show(); option_no_selected.prop('selected', true); $( this ).html(add_wpftopic); $('html, body').animate({ scrollTop: (wrap.offset().top -30 ) }, 415); }); wpforo_wrap.on('click', '.not_reg_user', function(){ wpforo_load_show(); wpforo_notice_show(wpforo.notice.login_or_register); wpforo_load_hide(); }); $(document).on('click', '#wpf-msg-box', function(){ $(this).hide(); }); /* Home page loyouts toipcs toglle */ wpforo_wrap.on('click', ".topictoggle", function(){ wpforo_load_show(); var id = $(this).attr( 'id' ); id = id.replace( "img-arrow-", "" ); $( ".wpforo-last-topics-" + id ).slideToggle( "slow" ); if( $(this).hasClass('topictoggle') && $(this).hasClass('fa-chevron-down') ){ $( '#img-arrow-' + id ).removeClass('fa-chevron-down').addClass('fa-chevron-up'); }else{ $( '#img-arrow-' + id ).removeClass('fa-chevron-up').addClass('fa-chevron-down'); } id = id.replace( "button-arrow-", "" ); $( ".wpforo-last-posts-" + id ).slideToggle( "slow" ); if( $(this).hasClass('topictoggle') && $(this).hasClass('wpfcl-a') && $(this).hasClass('fa-chevron-down') ){ $( '#button-arrow-' + id ).removeClass('fa-chevron-down').addClass('fa-chevron-up'); }else{ $( '#button-arrow-' + id ).removeClass('fa-chevron-up').addClass('fa-chevron-down'); } wpforo_load_hide(); }); /* Home page loyouts toipcs toglle */ wpforo_wrap.on('click', ".wpforo-membertoggle", function(){ var id = $(this).attr( 'id' ); id = id.replace( "wpforo-memberinfo-toggle-", "" ); $( "#wpforo-memberinfo-" + id ).slideToggle( "slow" ); if( $(this).find( "i" ).hasClass('fa-caret-down') ){ $(this).find( "i" ).removeClass('fa-caret-down').addClass('fa-caret-up'); }else{ $(this).find( "i" ).removeClass('fa-caret-up').addClass('fa-caret-down'); } }); /* Threaded Layout Hide Replies */ wpforo_wrap.on('click', ".wpf-post-replies-bar", function(){ var id = $(this).attr( 'id' ); id = id.replace( "wpf-ttgg-", "" ); $( "#wpf-post-replies-" + id ).slideToggle( "slow" ); if( $(this).find( "i" ).hasClass('fa-angle-down') ){ $(this).find( "i" ).removeClass('fa-angle-down').addClass('fa-angle-up'); $(this).find( ".wpforo-ttgg" ).attr('wpf-tooltip', wpforo_phrase('Hide Replies')); }else{ $(this).find( "i" ).removeClass('fa-angle-up').addClass('fa-angle-down'); $(this).find( ".wpforo-ttgg" ).attr('wpf-tooltip', wpforo_phrase('Show Replies')); } }); //Reply wpforo_wrap.on('click', ".wpforo-reply:not(.wpforo_layout_4)", function(){ wpforo_load_show(); var main_form = $('form.wpforo-main-form[data-textareaid]'); var wrap = main_form.closest('.wpf-form-wrapper'); wrap.show(); $(".wpf-reply-form-title").html( wpforo_phrase('Leave a reply') ); var post_wrap = $(this).closest('[id^=post-][data-postid]'); var parentpostid = post_wrap.data('postid'); if( !parentpostid ) parentpostid = 0; $(".wpf-form-post-parentid", main_form).val( parentpostid ); var mention = $(this).data('mention'); var content = ( mention ? '@' + mention + "\r\n" : '' ); wpforo_editor.set_content( content, wpforo_editor.get_main() ); $('html, body').animate({ scrollTop: wrap.offset().top }, 500); wpforo_load_hide(); }); //Answer wpforo_wrap.on('click', ".wpforo-answer", function(){ wpforo_load_show(); var main_form = $('form.wpforo-main-form[data-textareaid]'); var wrap = main_form.closest('.wpf-form-wrapper'); wrap.show(); $(".wpf-reply-form-title").html( wpforo_phrase('Your answer') ); $( ".wpf-form-postid", main_form ).val(0); $(".wpf-form-post-parentid", main_form).val(0); var mention = $(this).data('mention'); var content = ( mention ? '@' + mention + "\r\n" : '' ); wpforo_editor.set_content( content, wpforo_editor.get_main() ); $('html, body').animate({ scrollTop: wrap.offset().top }, 500); wpforo_load_hide(); }); wpforo_wrap.on('click', '.wpforo-qa-comment, .wpforo-reply.wpf-action.wpforo_layout_4', function () { var wrap = $(this).parents('.reply-wrap,.wpforo-qa-item-wrap'); var post_wrap = $('.post-wrap', wrap); if( !post_wrap.length ) post_wrap = wrap; var parentid = post_wrap.data('postid'); if (!parentid) parentid = post_wrap.attr('id').replace('post-', ''); if (!parentid) parentid = 0; var form = $('.wpforo-post-form'); var textareaid = form.data('textareaid'); var textarea_wrap = $('.wpf_post_form_textarea_wrap', form); var textarea = $('#' + textareaid, textarea_wrap); var textareatype = textarea_wrap.data('textareatype'); $('.wpf_post_parentid').val(parentid); $('.wpforo-qa-comment,.wpforo-reply.wpf-action.wpforo_layout_4').show(); $(this).hide(); $('.wpforo-portable-form-wrap', wrap).show(); if( ! $('.wpforo-post-form', wrap).length ) form.appendTo($('.wpforo-portable-form-wrap', wrap)); form.show(); if( textareatype && textareatype === 'rich_editor' ){ textarea_wrap.html(''); wpforo_tinymce_initializeIt( '#' + textareaid ); }else{ textarea.val(''); textarea.focus(); } var mention = $(this).data('mention'); var content = ( mention ? '@' + mention + "\r\n" : '' ); wpforo_editor.set_content( content, textareaid ); }); wpforo_wrap.on('click', '.wpf-button-close-form', function () { $(this).parents('.wpforo-portable-form-wrap').hide(); $('.wpforo-post-form').hide(); $('.wpforo-qa-comment,.wpforo-reply.wpf-action.wpforo_layout_4').show(); wpforo_editor.set_content(''); }); //mobile menu responsive toggle wpforo_wrap.on('click', "#wpforo-menu .wpf-res-menu", function(){ $("#wpforo-menu .wpf-menu").toggle(); }); var wpfwin = $(window).width(); var wpfwrap = wpforo_wrap.width(); if( wpfwin >= 602 && wpfwrap < 800 ){ wpforo_wrap.on('focus', "#wpforo-menu .wpf-search-field", function(){ $("#wpforo-menu .wpf-menu li").hide(); wpforo_wrap.find("#wpforo-menu .wpf-res-menu").show(); $("#wpforo-menu .wpf-search-field").css('transition-duration', '0s'); }); wpforo_wrap.on('blur', "#wpforo-menu .wpf-search-field", function(){ wpforo_wrap.find("#wpforo-menu .wpf-res-menu").hide(); $("#wpforo-menu .wpf-menu li").show(); $("#wpforo-menu .wpf-search-field").css('transition-duration', '0.4s'); }); } // password show/hide switcher */ wpforo_wrap.on('click', '.wpf-show-password', function () { var btn = $(this); var parent = btn.parents('.wpf-field-wrap'); var input = $(':input', parent); if (input.attr('type') === 'password') { input.attr('type', 'text'); btn.removeClass('fa-eye-slash'); btn.addClass('fa-eye'); } else { input.attr('type', 'password'); btn.removeClass('fa-eye'); btn.addClass('fa-eye-slash'); } }); //Turn off on dev mode //$(window).bind('resize', function(){ if (window.RT) { clearTimeout(window.RT); } window.RT = setTimeout(function(){ this.location.reload(false);}, 100); }); wpforo_wrap.on("change", "#wpforo_split_form #wpf_split_create_new", function () { var checked = $("#wpf_split_create_new").is(":checked"), target_url = $("#wpf_split_target_url"), append = $("#wpf_split_append"), new_title = $("#wpf_split_new_title"), forumid = $("#wpf_split_forumid"); if( checked ){ target_url.children("input").prop("disabled", true); target_url.hide(); append.children("input").prop("disabled", true); append.hide(); new_title.children("input").prop("disabled", false); new_title.show(); forumid.children("select").prop("disabled", false); forumid.show(); }else{ target_url.children("input").prop("disabled", false); target_url.show(); append.children("input").prop("disabled", false); append.show(); new_title.children("input").prop("disabled", true); new_title.hide(); forumid.children("select").prop("disabled", true); forumid.hide(); } }); //Facebook Share Buttons wpforo_wrap.on('click','.wpf-fb', function(){ var item_url = $(this).data('wpfurl'); var item_quote = $(this).parents('.post-wrap').find('.wpforo-post-content').text(); FB.ui({ method: 'share', href: item_url, quote: item_quote, hashtag: null }, function (response) {}); }); //Share Buttons Toggle wpforo_wrap.on('mouseover', '.wpf-sb', function(){ $(this).find(".wpf-sb-toggle").find("i").addClass("wpfsa"); $(this).find(".wpf-sb-buttons").show(); }); wpforo_wrap.on('mouseout', '.wpf-sb', function() { $(this).find(".wpf-sb-toggle").find("i").removeClass("wpfsa"); $(this).find(".wpf-sb-buttons").hide(); }); wpforo_wrap.on('mouseover', '.wpf-sb-toggle', function(){ $(this).next().filter('.wpf-sb-buttons').parent().find("i").addClass("wpfsa"); }); wpforo_wrap.on('mouseout', '.wpf-sb-toggle', function(){ $(this).next().filter('.wpf-sb-buttons').parent().find("i").removeClass("wpfsa"); }); //Forum Rules wpforo_wrap.on('click', "#wpf-open-rules", function(){ $(".wpforo-legal-rules").toggle(); return false; }); wpforo_wrap.on('click','#wpflegal-rules-yes', function(){ $('#wpflegal_rules').prop('checked', true); $('#wpflegal-rules-not').removeClass('wpflb-active-not'); $(this).addClass('wpflb-active-yes'); setTimeout(function(){ $(".wpforo-legal-rules").slideToggle( "slow" ); }, 500); }); wpforo_wrap.on('click','#wpflegal-rules-not', function(){ $('#wpflegal_rules').prop('checked', false); $('#wpflegal-rules-yes').removeClass('wpflb-active-yes'); $(this).addClass('wpflb-active-not'); }); //Forum Privacy Buttons wpforo_wrap.on('click', "#wpf-open-privacy", function(){ $(".wpforo-legal-privacy").toggle(); return false; }); wpforo_wrap.on('click','#wpflegal-privacy-yes', function(){ $('#wpflegal_privacy').prop('checked', true); $('#wpflegal-privacy-not').removeClass('wpflb-active-not'); $(this).addClass('wpflb-active-yes'); setTimeout(function(){ $(".wpforo-legal-privacy").slideToggle( "slow" ); }, 500); }); wpforo_wrap.on('click','#wpflegal-privacy-not', function(){ $('#wpflegal_privacy').prop('checked', false); $('#wpflegal-privacy-yes').removeClass('wpflb-active-yes'); $(this).addClass('wpflb-active-not'); }); //Facebook Login Button wpforo_wrap.on('click', '#wpflegal_fblogin', function() { if( $(this).is(':checked') ){ $('.wpforo_fb-button').attr('style','pointer-events:auto; opacity:1;'); } else{ $('.wpforo_fb-button').attr('style','pointer-events: none; opacity:0.6;'); } }); wpforo_wrap.on('click', '.wpf-load-threads .wpf-forums', function () { $( '.wpf-cat-forums', $(this).parents('div.wpfl-4') ).slideToggle('slow'); $('i', $(this)).toggleClass('fa-chevron-down fa-chevron-up'); }); wpforo_wrap.on('click', '[data-copy-wpf-furl], [data-copy-wpf-shurl]', function(){ var urls = []; var full_url = $(this).data('copy-wpf-furl'); if( full_url ) urls.push( decodeURIComponent(full_url) ); var short_url = $(this).data('copy-wpf-shurl'); if( short_url ) urls.push( decodeURIComponent(short_url) ); if(urls.length){ var label = ''; var html = ''; urls.forEach(function(url, i){ label = (urls.length === 2 && i === 1 ) ? wpforo_phrase('Short') : wpforo_phrase('Full'); html += '' + container.innerHTML.replace(/\s*data-[\w-]+="[^"]*?"/gi, '') + '