miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

Submitting the edited form (topicTitle) by hitting the Enter key on keyboard?

 
Author tom322
Active Member
#1 | Posted: 19 Apr 2014 01:26 
A forum moderator asked me to give this solution - he wants to use Enter on his keyboard to edit the title and submit the form. Currently he must click on the 'Edit Post' button to submit the form. But he usually edits old topic titles only and it would be faster if he could just edit the title and hit the enter key to submit the form. How is it possible to do it?

I guess some small change in the form.js file and maybe in the tools_edit_topic_title.html template too is needed. Maybe it wouldn't hurt to allow this for general forum users too. Thanks,

Author Paul
Lead Developer 
#2 | Posted: 21 Apr 2014 23:51 
Not truly a small change is needed, but still acceptable one, and it could be based on the solution which is provided for the login form. I have used the same function, only modified it a bit, so you may try the following:

1. Edit bb_plugins.php, below the file before the closing ?> paste:

/* Form's Submission on entering Topic's title */

if($action=='editmsg'){

$editMsgHandleEnterJsBlock=<<<out
<script type="text/javascript">
<!--
function handleEnterEditTopicTitle(e) {
var keynum;
if(window.event) keynum=e.keyCode;
else if(e.which) keynum = e.which;
if(keynum==13) submitForm();
return keynum;
}
//-->
</script>
out;

$editMsgHandleEnterJs=' onkeydown="JavaScript:handleEnterEditTopicTitle(event);"';

}

/* --Form's Submission on entering Topic's title */
2. Edit templates/tools_edit_topic_title.html, paste the following new fragments highlighted in bold:

<tr>
<td class="caption3"><strong>{$l_topicTitle}</strong></td></tr>
<tr><td class="tbTransparent txtL subjectPad">
{$editMsgHandleEnterJsBlock}
<input type="text" name="topicTitle" maxlength="{$topic_max_length}" value="{$topicTitle}" class="textForm topicTitle" {$editMsgHandleEnterJs}/>
</td>
</tr>
3. This all would mean the allowance to submit the form using the Enter key when it's focused in the Topic's Title text field.

Let me know if it worked on your end (on mine, it's all OK).

Author tom322
Active Member
#3 | Posted: 22 Apr 2014 01:28 
It works perfectly. It's possible to either use bb_plugins or add all the code directly to the tools_edit_topic_title.html template. The latter method is suggested for advanced webmasters only ;). Thank you!

Author Paul
Lead Developer 
#4 | Posted: 22 Apr 2014 01:30 
I've created the code in bb_plugins.php, having in mind it could be extended to just a certain user (certain moderator in your case).

This supposes, only that user will use the code - your proposal suggests it just for ALL users (by default, my solution suggests it too, but in a more advanced manner).

Anyway, for anyone interested further, you are welcome with your suggestions and proposals... thanks.

Author tom322
Active Member
#5 | Posted: 22 Apr 2014 01:31 
Yes, I figured it could work for all users since it appears to validate the title anyway (ie. not possible to enter empty title etc.).

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 Submitting the edited form (topicTitle) by hitting the Enter key on keyboard?
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Get the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑