Hi all!
I would like to share a solution for the subject. I use it on my own forum with Q&A layout (3), but it must work with other layouts.
Make next changes in the file: \wp-content\plugins\wpforo\wpf-assets\js\frontend.js
Before line:
jQuery(document).ready(function($){
Add next function:
function getTextSelection(e){
if ( e.target.tagName !== 'A' ) {
var mouseKey = e.button || e.which || null;
var pageX = e.pageX || e.clientX + document.documentElement.scrollLeft;
var pageY = e.pageY || e.clientY + document.documentElement.scrollTop;
setTimeout(function() {
var selectedText = '';
if (window.getSelection) {
selectedText = window.getSelection().toString();
} else if (document.getSelection) {
selectedText = document.getSelection().toString();
} else if (document.selection) {
selectedText = document.selection.createRange().text;
}
if ( selectedText !== '' ) {
var $selection = jQuery(window.getSelection().anchorNode.parentNode) || jQuery(document.getSelection().anchorNode.parentNode) || jQuery(document.selection.createRange().parentElement())
var isPost = $selection.closest('div.wpforo-post-content, div.wpforo-comment-content');
}
if ( selectedText !== '' && mouseKey <= 1 && jQuery('#wpf-form-wrapper').length && isPost.length > 0 ) {
jQuery("#selQuote").remove();
var toolTip = jQuery("<div class='wpf-tool-tip' id='selQuote'></div>");
toolTip.css({
position: 'absolute',
top: (pageY + 10),
left: (pageX > 160 ? pageX - 160 : pageX - 10)
});
var link = jQuery("<a href='#wpf-form-wrapper'>Add quote to answer</a>").on('click', function () {
var editorContent = tinyMCE.activeEditor.getContent();
editorContent += "<blockquote><p>" + selectedText + "</p></blockquote><p></p>"
tinyMCE.activeEditor.setContent(editorContent);
tinymce.execCommand('mceFocus',false,'postbody');
tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
tinyMCE.activeEditor.selection.collapse(false);
jQuery('html, body').animate({ scrollTop: jQuery("#wpf-form-wrapper").offset().top }, 500);
if (window.getSelection) {
if (window.getSelection().empty) { // Chrome
window.getSelection().empty();
} else if (window.getSelection().removeAllRanges) { // Firefox
window.getSelection().removeAllRanges();
}
} else if (document.selection) { // IE?
document.selection.empty();
}
jQuery("#selQuote").remove();
return false;
});
toolTip.append(link);
jQuery('body').append(toolTip);
} else {
jQuery("#selQuote").remove();
}
}, 0);
}
}
After line:
jQuery(document).ready(function($){
Next line:
$(document).on('mouseup', getTextSelection);
Save file. Update site in your browser.
It works with text in the post. Just select with the mouse any text and click on the appeared button "Add quote to answer".
@robert, if you want, you can bundle this function into wpForo.
Any feedback is welcome.
Thanks to everyone for the feedback!
@robert, please, test this function on mobile devices. It works perfectly on desktop, but I didn't test it in mobile browsers. This function is really useful. I used it for years on the old forum.
Hello,
This feature is present in all modern forums, why it is not implemented on wpforo?
This feature is present in all modern forums, why it is not implemented on wpforo?
I'm sorry but wpForo doesn't have Multiquote function yet. They should quote one by one in separate replies or use the simple Quote button. Just copy the text, paste in editor, select and click on quote button Like I did it here.
The Multiquote feature is already in our to-do list. We'll do our best to make it available with future releases as soon as possible. You just need to press on Enter twice: Vide0 example: https://www.screencast.com/t/VP5QR5k0vOD