PDA

View Full Version : [How-To] Disable double click on Reply buttons


cbiweb
02-09-2010, 10:00 PM
This article discusses code modifications made directly in the files, and will need to be done each time you upgrade vBulletin. If possible I will write a plugin when I get a chance, and this note and article will become irrelevant.


[How-To] Disable Double-Click On Reply Buttons

A lot of people agree that the new double-click functionality for the "Reply With Quote" and "+ Reply to Thread" buttons is not user friendly, and not a standard behavior for buttons on a web page. The biggest complaint is having to click twice to get to the regular Advanced editor.

It doesn't appear that the developers are going to change this soon, if ever, so until they do I went digging for a solution to bring back the familiar and very user friendly single-click action for these buttons.

Go to your clientscript folder, and open the vbulletin_quick_reply.js file. Look for this section of code:

function qr_init_buttons(obj)
{
// intercept post button clicks to use inline form
var anchors = fetch_tags(obj, 'a');
for (var i = 0; i < anchors.length; i++)
{
// reply button
if (anchors.id && (anchors[i].id.substr(0, 3) == 'qr_' || anchors[i].id.substr(0, 5) == 'qrwq_'))
{
YAHOO.util.Event.on(anchors[i], "click", qr_newreply_activate, this);
//anchors[i].onclick = function(e) { return qr_newreply_activate(this.id.substr(3), false); };
}
}

// set the "+Reply to Thread" buttons onlclick events
var replytothreadids = ["newreplylink_top", "newreplylink_bottom"];
YAHOO.util.Event.on(replytothreadids, "click", qr_replytothread_activate, this);
//YAHOO.util.Event.on(replytothreadids, "dblclick", function(e) { window.location = this.href; }, this);
}
In that section, comment out two of the lines as shown below. All you need to do is add the forward slashes that I've highlighted in red and blue:
function qr_init_buttons(obj)
{
// intercept post button clicks to use inline form
var anchors = fetch_tags(obj, 'a');
for (var i = 0; i < anchors.length; i++)
{
// reply button
if (anchors[i].id && (anchors[i].id.substr(0, 3) == 'qr_' || anchors[i].id.substr(0, 5) == 'qrwq_'))
{
//YAHOO.util.Event.on(anchors[i], "click", qr_newreply_activate, this);
//anchors[i].onclick = function(e) { return qr_newreply_activate(this.id.substr(3), false); };
}
}

// set the "+Reply to Thread" buttons onlclick events
var replytothreadids = ["newreplylink_top", "newreplylink_bottom"];
//YAHOO.util.Event.on(replytothreadids, "click", qr_replytothread_activate, this);
//YAHOO.util.Event.on(replytothreadids, "dblclick", function(e) { window.location = this.href; }, this);
}The red commented line reverts the "Reply With Quote" button back to a single click, and takes you directly to the regular Advanced editor with the quoted post included. Note: Commenting out this line will also disable the regular "[I]Reply" button from opening Quick Reply.

The blue commented line reverts the "+ Reply to Thread" buttons back to single click, which takes you directly to the Advanced editor.

One more thing, Multi-quote behavior depends on which line(s) you comment out.


If you ever want to use the default double-click behavior for either button, simply remove the two forward slashes that you added. And remember, until I create the plugin/product, you will need to make this change each time you upgrade your forums.

Switch3130
02-12-2010, 02:43 AM
Awesome work just what I was looking for.

Merjawy
02-12-2010, 02:51 AM
Thank you

Switch3130
02-13-2010, 12:40 AM
Would you mind sending me over the .js file with the updated changes? I tried making the changes and things didn't seem right.

Also when I searched for this "YAHOO.util.Event.on(anchors[i]" in the file to make the changes it wasn't found.

What is going on?

cbiweb
02-13-2010, 11:19 AM
when I searched for this "YAHOO.util.Event.on(anchors[i]" in the file to make the changes it wasn't found.

What is going on?
The code is there, but if you downloaded the compressed version of the file it looks slightly different. You need to search for these two strings:
{YAHOO.util.Event.on(C[b],"click",qr_newreply_activate,this)}and
YAHOO.util.Event.on(A,"click",qr_replytothread_activate,this)Comment them per my first post. Depending what result you want will determine which one(s) you comment out. (Yes, the first one has a curly brace but the second one does not. :) ) If it doesn't work for you, try adding a space before the comment lines, which worked for boatswife in post #11 below.

I only found out about the compressed version after I wrote the article, or I would've included it then. :)

Switch3130
02-15-2010, 10:51 AM
After I made those changes I get errors on the thread page:

missing } in compound statement
[Break on this error] _tbody","hidden");vB_Editor[QR_EditorI...;return false}}var vB_QuickReply=true;

cbiweb
02-15-2010, 11:40 AM
That is strange. I've done it with the compressed and non-compressed versions of the file with no problems. Try again because it would be easy to make a mistake with the compressed file, being that it's all mushed together. PM me if you have further problems. :)

BizAdventure
02-21-2010, 10:29 AM
I am curious if you got this working on 4.0.2 - I cannot find that information in that file - I find similarities, but not what is above.

I can paste the code, but it's awfully long.

cbiweb
02-21-2010, 07:28 PM
Hey Biz, we meet again. :D As you know, I'm in the middle of reinstalling everything onto a new HD today, so I can't access my vBulletin projects to check on this for 4.0.2. But soon as I'm able, I will.

BizAdventure
02-22-2010, 01:04 AM
I will wait patiently, thank you!!!

boatswife
02-23-2010, 02:15 AM
The code is there, but if you downloaded the compressed version of the file it looks slightly different. You need to search for these two strings:
YAHOO.util.Event.on(C[b],"click",qr_newreply_activate,this)and
YAHOO.util.Event.on(A,"click",qr_replytothread_activate,this)Comment them per my first post. Depending what result you want will determine which one(s) you comment out.

I only found out about the compressed version after I wrote the article, or I would've included it then. :)


I had the compressed version and found this code. I put the // in front of both strings and it didn't do anything. I then put a space before the // in each string and it now works.

I don't have a clue if that's the technical thing to do, but it's working for me.

cbiweb
02-23-2010, 01:14 PM
I am curious if you got this working on 4.0.2 - I cannot find that information in that file - I find similarities, but not what is above.

I can paste the code, but it's awfully long.
I just checked the compressed and non-compressed versions of vbulletin_quick_reply.js for 4.0.2, and the same code is still there. Are you sure you checked the correct file? I ask because I spent a few minutes looking for the code in the wrong file myself, lol. But yes, nothing's changed in 4.0.2.

I had the compressed version and found this code. I put the // in front of both strings and it didn't do anything. I then put a space before the // in each string and it now works.

I don't have a clue if that's the technical thing to do, but it's working for me.
It does makes sense, now that you bring it up. Never thought to mention that. Glad you figured it out. :)


After I made those changes I get errors on the thread page:

missing } in compound statement
[Break on this error] _tbody","hidden");vB_Editor[QR_EditorI...;return false}}var vB_QuickReply=true;
Did you ever get this sorted?

as7apcool
02-24-2010, 09:43 PM
Thanks 4 good work

DocEldridge
02-25-2010, 02:51 AM
Is there a way to change both the reply and reply with quote both to a single click?

Cloughie
02-26-2010, 08:35 AM
This worked for me, good job.

Why VB introduced the double click thing is beyond me - its totally non web standard and so confusing for people.

Peter Caparelli
03-04-2010, 06:18 PM
Cloughie, I couldn't agree with you more! Thank You cbiweb!!

cbiweb
03-05-2010, 11:47 PM
You're all very welcome. :) Glad to help.

archet1337
03-06-2010, 08:31 AM
I don't even have "YAHOO" in vbulletin_quick_reply.js .. where can I get a file that let me apply this mod?

cbiweb
03-06-2010, 10:39 AM
If you're running 4.0.1 or 4.0.2, it is most definitely there. I can't be sure about any of the betas, the RC's or 4.0.0, since I only figured it out in 4.0.1.

archet1337
03-06-2010, 10:53 AM
vbulletin_quick_reply.js says "vBulletin 4.0.2 Patch Level 1"

Am i allowed to post the file here so you can take a look?

cbiweb
03-06-2010, 11:08 AM
Sure. :) I'm going out for about an hour, but will take look after that.

archet1337
03-06-2010, 11:14 AM
Great stuff. Here you go :)

/*================================================= =====================*\
|| ################################################## ################## ||
|| # vBulletin 4.0.2 Patch Level 1
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2000-2010 vBulletin Solutions Inc. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| ################################################## ################## ||
\*================================================ ======================*/
var qr_repost=false;var qr_errors_shown=false;var qr_active=false;var qr_ajax=null;var qr_postid=null;var qr_withquote=null;var qr_imgsrc="";var clickedelm=false;var qr_require_click=false;if(typeof (vB_XHTML_Ready)!="undefined"){vB_XHTML_Ready.subscribe(qr_init)}function qr_init(){if(typeof (vBulletin.attachinfo)=="undefined"){vBulletin.attachinfo={posthash:"",poststarttime:""}}if(fetch_object("quick_reply")){qr_disable_controls();qr_init_buttons(fetch_obj ect("posts"))}}function qr_init_buttons(D){var C=fetch_tags(D,"a");for(var B=0;B<C.length;B++){if(C[B].id&&(C[B].id.substr(0,3)=="qr_"||C[B].id.substr(0,5)=="qrwq_")){YAHOO.util.Event.on(C[B],"click",qr_newreply_activate,this)}}var A=["newreplylink_top","newreplylink_bottom"];YAHOO.util.Event.on(A,"click",qr_replytothread_activate,this)}function qr_disable_controls(){if(require_click){fetch_obje ct("qr_postid").value=0;vB_Editor[QR_EditorID].disable_editor(vbphrase.click_quick_reply_icon);v ar A=fetch_object("cb_signature");if(A!=null){A.disabled=true}active=false;qr_acti ve=false}else{vB_Editor[QR_EditorID].write_editor_contents("");qr_active=true}}function qr_activate(D,B){var C=fetch_object("collapseobj_quickreply");if(C&&C.style.display=="none"){toggle_collapse("quickreply")}fetch_object("qr_postid").value=D;if(fetch_object("qr_specifiedpost")){fetch_object("qr_specifiedpost").value=1}var A=fetch_object("cb_signature");if(A){A.disabled=false;A.checked=true}B=(B?B:"");vB_Editor[QR_EditorID].enable_editor(B);if(!is_ie&&vB_Editor[QR_EditorID].wysiwyg_mode){fetch_object("qr_scroll").scrollIntoView(false)}vB_Editor[QR_EditorID].check_focus();qr_active=true;return false}function qr_replytothread_activate(C){var A=this.href;if(qr_postid==last_post_id&&qr_withquote==true){window.location=A;return true}YAHOO.util.Event.preventDefault(C);qr_postid= last_post_id;qr_withquote=true;YAHOO.util.Dom.setS tyle("progress_newreplylink_top","display","");YAHOO.util.Dom.setStyle("progress_newreplylink_bottom","display","");document.body.style.cursor="wait";var B=YAHOO.util.Dom.get("qr_threadid").value;qr_ajax=YAHOO.util.Connect.asyncRequest("POST","ajax.php",{success:qr_replytothread_handle_activate,failure :function(D){window.location=A},timeout:vB_Default _Timeout},SESSIONURL+"securitytoken="+SECURITYTOKEN+"&do=getquotes&t="+B)}function qr_replytothread_handle_activate(B){qr_reset();qr_ disable_controls();qr_hide_errors();var C="";if(B){var A=B.responseXML.getElementsByTagName("quotes");if(A.length&&A[0].firstChild){var C=A[0].firstChild.nodeValue;if(vB_Editor[QR_EditorID].wysiwyg_mode){C=C.replace(/\r?\n/g,"<br />")}}}if(YAHOO.util.Dom.hasClass("qr_defaultcontainer","qr_require_click")){YAHOO.util.Dom.removeClass("qr_defaultcontainer","qr_require_click");qr_require_click=true}qr_activate(last_post_id,C );fetch_object("progress_newreplylink_top").style.display="none";fetch_object("progress_newreplylink_bottom").style.display="none";document.body.style.cursor="auto"}function qr_newreply_activate(C){var B=false;if(this.id.substr(0,3)=="qr_"){var D=this.id.substr(3)}else{if(this.id.substr(0,5)=="qrwq_"){var D=this.id.substr(5);B=true}else{return true}}if(qr_postid==D&&qr_withquote==B){return true}YAHOO.util.Event.stopEvent(C);qr_postid=D;qr_ withquote=B;if(YAHOO.util.Dom.get("progress_"+D)){var A=(B?"quoteimg_":"replyimg_")+D;qr_imgsrc=YAHOO.util.Dom.get(A).getAttribute("src");YAHOO.util.Dom.get(A).setAttribute("src",YAHOO.util.Dom.get("progress_"+D).getAttribute("src"))}document.body.style.cursor="wait";if(B){qr_ajax=YAHOO.util.Connect.asyncRequest("POST","ajax.php?do=getquotes&p="+D,{success:qr_handle_activate,failure:vBulletin_A JAX_Error_Handler,timeout:vB_Default_Timeout},SESS IONURL+"securitytoken="+SECURITYTOKEN+"&do=getquotes&p="+D)}else{qr_handle_activate(false)}}function qr_handle_activate(H){var B=qr_postid;qr_reset();qr_disable_controls();qr_hi de_errors();qr_postid=B;var F="";if(H){var E=H.responseXML.getElementsByTagName("quotes");if(E){var F=E[0].firstChild.nodeValue;if(vB_Editor[QR_EditorID].wysiwyg_mode){F=F.replace(/\r?\n/g,"<br />")}}}var G=fetch_object("qr_cancelbutton");G.style.display="";var J=document.createElement("li");J.id="qr_"+B;var I=YAHOO.util.Dom.get("post_"+B);var D=I.parentNode.insertBefore(J,I.nextSibling);var C=fetch_object("quick_reply");D.appendChild(C);qr_activate(B,F);if(YAHOO.util. Dom.get("progress_"+B)){var A=(qr_withquote?"quoteimg_":"replyimg_")+B;YAHOO.util.Dom.get(A).setAttribute("src",qr_imgsrc)}document.body.style.cursor="auto"}function qr_reset(){qr_postid=null;fetch_object("qr_postid").value=last_post_id;var C=fetch_object("quick_reply");var B=fetch_object("qr_defaultcontainer");if(C.parentNode!=B){var D=C.parentNode;B.appendChild(C);D.parentNode.remov eChild(D)}var A=fetch_object("qr_cancelbutton");A.style.display="none";if(!require_click){vB_Editor[QR_EditorID].enable_editor("")}if(qr_require_click&&!YAHOO.util.Dom.hasClass("qr_defaultcontainer","qr_require_click")){YAHOO.util.Dom.addClass("qr_defaultcontainer","qr_require_click")}return false}function qr_prepare_submit(D,A){if(qr_repost==true){return true}if(!allow_ajax_qr||!AJAX_Compatible){return qr_check_data(D,A)}else{if(qr_check_data(D,A)){if( typeof vb_disable_ajax!="undefined"&&vb_disable_ajax>0){return true}if(is_ie&&userAgent.indexOf("msie 5.")!=-1){if(PHP.urlencode(D.message.value).indexOf("%u")!=-1){return true}}if(YAHOO.util.Connect.isCallInProgress(qr_aj ax)){return false}D.posthash.value=vBulletin.attachinfo.postha sh;D.poststarttime.value=vBulletin.attachinfo.post starttime;if(clickedelm==D.preview.value){return true}else{var E="ajax=1";if(typeof ajax_last_post!="undefined"){E+="&ajax_lastpost="+PHP.urlencode(ajax_last_post)}for(var C=0;C<D.elements.length;C++){var F=D.elements[C];if(F.name&&!F.disabled){switch(F.type){case"text":case"textarea":case"hidden":E+="&"+F.name+"="+PHP.urlencode(F.value);break;case"checkbox":case"radio":E+=F.checked?"&"+F.name+"="+PHP.urlencode(F.value):"";break;case"select-one":E+="&"+F.name+"="+PHP.urlencode(F.options[F.selectedIndex].value);break;case"select-multiple":for(var B=0;B<F.options.length;B++){E+=(F.options[B].selected?"&"+F.name+"="+PHP.urlencode(F.options[B].value):"")}break}}}fetch_object("qr_posting_msg").style.display="";document.body.style.cursor="wait";qr_ajax_post(D.action,E);return false}}else{return false}}}function qr_resubmit(){qr_repost=true;var B=document.createElement("input");B.type="hidden";B.name="ajaxqrfailed";B.value="1";var A=YAHOO.util.Dom.get("quick_reply");if(!A){A=YAHOO.util.Dom.get("qrform")}A.appendChild(B);A.submit()}function qr_check_data(B,A){switch(fetch_object("qr_postid").value){case"0":fetch_object("qr_postid").value=last_post_id;case"who cares":if(typeof B.quickreply!="undefined"){B.quickreply.checked=false}break}if(clickedelm== B.preview.value){A=0}return vB_Editor[QR_EditorID].prepare_submit(0,A)}function qr_ajax_post(B,A){if(YAHOO.util.Connect.isCallInPr ogress(qr_ajax)){YAHOO.util.Connect.abort(qr_ajax) }qr_repost=false;qr_ajax=YAHOO.util.Connect.asyncR equest("POST",B,{success:qr_do_ajax_post,failure:qr_handle_erro r,timeout:vB_Default_Timeout},SESSIONURL+"securitytoken="+SECURITYTOKEN+"&"+A)}function qr_handle_error(A){vBulletin_AJAX_Error_Handler(A) ;fetch_object("qr_posting_msg").style.display="none";document.body.style.cursor="default";qr_resubmit()}function qr_do_ajax_post(F){if(F.responseXML){document.body .style.cursor="auto";fetch_object("qr_posting_msg").style.display="none";var D;if(fetch_tag_count(F.responseXML,"postbit")){qr_reset();ajax_last_post=F.responseXML.getElem entsByTagName("time")[0].firstChild.nodeValue;qr_disable_controls();qr_hid e_errors();var C=F.responseXML.getElementsByTagName("postbit");for(D=0;D<C.length;D++){var I=document.createElement("div");I.innerHTML=C[D].firstChild.nodeValue;var A=I.getElementsByTagName("li")[0];var H=YAHOO.util.Dom.get("posts");if(A){var B=H.appendChild(A);PostBit_Init(B,C[D].getAttribute("postid"));A.scrollIntoView(false)}}if(typeof mq_unhighlight_all=="function"){mq_unhighlight_all()}if(fetch_object("qr_submit")){fetch_object("qr_submit").blur()}}else{if(!is_saf){var G=F.responseXML.getElementsByTagName("error");if(G.length){var E="<ol>";for(D=0;D<G.length;D++){E+="<li>"+G[D].firstChild.nodeValue+"</li>"}E+="</ol>";qr_show_errors(E);return false}}qr_resubmit()}}else{qr_resubmit()}}function qr_show_errors(A){qr_errors_shown=true;fetch_objec t("qr_error_td").innerHTML=A;YAHOO.util.Dom.removeClass("qr_error_tbody","hidden");vB_Editor[QR_EditorID].check_focus();return false}function qr_hide_errors(){if(qr_errors_shown){qr_errors_sho wn=true;YAHOO.util.Dom.addClass("qr_error_tbody","hidden");return false}}var vB_QuickReply=true;

cbiweb
03-06-2010, 12:22 PM
You have the compressed version of the file. Did you read the posts earlier in this thread regarding that? Also, did you do ctrl+F on the open file to search for the portions of code mentioned in post #5 of this thread?

I do see it in the code you posted from the file, so it is there. But instead of giving you a fish, I'd rather teach you how to catch one. ;)

archet1337
03-06-2010, 01:07 PM
I like fishing ;)

Think I've got something hooked now.

.................//{YAHOO.util.Event.on(C,"click",qr_newreply_activate,this)}}..............

...........newreplylink_bottom"];[B]//YAHOO.util.Event.on(A,"click",qr_replytothread_activate,this)}function......... .


Like that?

cbiweb
03-06-2010, 01:37 PM
That should do it. :) I haven't actually done it with the compressed version of the file, but from other's feedback you should be good with that (or with a space before the '//' marks, if necessary).

Now reel it in! :D

archet1337
03-06-2010, 01:50 PM
Guess what I'm having for dinner tonight?

Working like a charm! Thanks a lot mate. ;)

archet1337
03-22-2010, 07:30 PM
I've been using this mod for a while now, and it's doing the job, but commenting out the two YAHOO bits result in the following syntax error:

syntax error
[Break on this error] s("qr_error_tbody","hidden");vB_Editor...;return false}}var vB_QuickReply=true;

SİMAR
03-24-2010, 06:48 PM
thanks man

archet1337
03-24-2010, 07:04 PM
Someone needs to take a look at the syntax error I posted above. As a result of the error you will get "message too short" when using quick reply and will have to type the message once more in advanced view.

Would be nice to get a fix for this.

kingharrison
06-03-2010, 11:21 PM
Someone needs to take a look at the syntax error I posted above. As a result of the error you will get "message too short" when using quick reply and will have to type the message once more in advanced view.

Would be nice to get a fix for this.

I am getting the same error. What is weird is I don't get it in my browser (and a lot of my users dont) but there are a handful (20% of my users) who do get it.

Any news on what is happening?

sross
08-12-2010, 06:11 AM
This is just unreal that vbull would put buttons on a webpage that require double click. I am just stupified. So does this hack work for 4.0.5?

sross
09-01-2010, 10:19 PM
ok have been using this mod for a few days and reported to the dev my main issues. Main problem is that the mod has interfered with my postbit "reply" "quick reply" buttons. It has now turned these into reply with quote advanced. I want to reply and reply with quote in the postbit to use the quick reply box but am unsure how to force these buttons to do so. If anyone has an idea please let me know! Thanks :)

cbiweb
09-01-2010, 10:45 PM
Yes, I mentioned this in the initial post of the thread. :) I'm not sure how to fix that. The solution could very well be simple, but I just don't have time these days to sit down and check it out.

sross
09-01-2010, 11:33 PM
ok,

i found this other option to disable double click

http://www.vbulletin.com/forum/showthread.php?357406-How-to-revert-the-post-reply-function-back-to-vb3-way

it requires no js edits and worked beautifully. I'm not sure if anyone else knows about it so am posting it here for informational purposes. Thanks

MichaelDance
09-23-2010, 03:23 PM
Confused i use 4.0.7 which code looks so different.

NimhGreatOwl
05-16-2011, 07:42 PM
Just set up vBulletin and this was confusing me badly. I've used vBulletin on other sites for years and thought I had something misconfigured. It seemed like half the time it would go to quick reply and half the time advanced. I don't understand how people would know that it was supposed to behave this way. At least there is a way to disable it.

Daisyboo
05-13-2012, 09:34 AM
ok,

i found this other option to disable double click

http://www.vbulletin.com/forum/showthread.php?357406-How-to-revert-the-post-reply-function-back-to-vb3-way

it requires no js edits and worked beautifully. I'm not sure if anyone else knows about it so am posting it here for informational purposes. Thanks

Worked for me too