News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Quote selected text only

Started by Uzbekistan, October 15, 2005, 04:39:40 PM

Previous topic - Next topic

Uzbekistan

Hi,

I've seen a mod on some bulettin boards, where a separate "quote selected" button quotes selected text from post only - not the whole post. I think this mod would be a nice addition to smf.

Oldiesmann

That's done with Javascript. Shouldn't be too hard to accomplish though.
Michael Eshom
Christian Metal Fans

Uzbekistan

Any update on this? Whould really appreciate one!

Microtonic

Hm.... this is nice idea. Who can do this mod?

enkiduwd

Any news?
I would really like to use this mod.


butch2k

#5
Looks like this has not been properly answered so far, so here is a javascript bit which should do the trick.

Select text and press ctrl/meta + Q


document.onkeydown = function(e){
if ((e.ctrlKey||e.metaKey) && e.keyCode == 81){
var selection = (typeof getSelection != "undefined")?getSelection():document.selection.createRange().text;
if ( selection != "" && typeof document.forms.postmodify != "undefined" )
replaceText("[quote]"+selection+"[/quote]", document.forms.postmodify.message);
}
};

kat

Where would you put that, Butch?

butch2k

#7
Quote from: K@ on October 05, 2013, 10:11:10 AM
Where would you put that, Butch?
Add this in a script tag in the header.
like this
<script>
document.onkeydown = function(e){
if ((e.ctrlKey||e.metaKey) && e.keyCode == 81){
var selection = (typeof getSelection != "undefined")?getSelection():document.selection.createRange().text;
if ( selection != "" && typeof document.forms.postmodify != "undefined" )
replaceText("[quote]"+selection+"[/quote]", document.forms.postmodify.message);
}
};
</script>

kat

Sorry, for being a bit dense... But, which file? (I'll be trying this out, myself) :)

butch2k

In index.template.php within template_html_above() function just after the various .js file references, it should work.

kat


butch2k

i altered my preious post to fix an issue with the older IEs (6 to 8), replace the .hmlText with .text else you'd get the html tags as well as the text.

the code should read like this
<script>
document.onkeydown = function(e){
if ((e.ctrlKey||e.metaKey) && e.keyCode == 81){
var selection = (typeof getSelection != "undefined")?getSelection():document.selection.createRange().text;
if ( selection != "" && typeof document.forms.postmodify != "undefined" )
replaceText("[quote]"+selection+"[/quote]", document.forms.postmodify.message);
}
};
</script>

kat

Thankyou!

Question: What's this "IE"? ;)

butch2k



Advertisement: