Author |
Topic |
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 21 June 2004 : 21:21:01
|
It wasn't last night when I tried it. I'll add the changes back to inc_code.js so you can test it out on this site. |
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 21 June 2004 : 21:23:55
|
Ok, it's been changed. you'll probably have to force a refresh to get the updated inc_code.js file. |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 21 June 2004 : 21:37:31
|
After a forced refresh it appears to be working as I expected at least. |
Nathan Bales CoreBoard | Active Users Download |
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 21 June 2004 : 21:46:30
|
ok, I'll test it again when I get home tonight. |
|
|
Davio
Development Team Member
Jamaica
12217 Posts |
Posted - 21 June 2004 : 22:37:48
|
Richard, when you say tags you mean the forum code?
If I select the text "This is just some text" and click the bold button, it puts the bold tags around the text, then the cursor goes to the end of the message box.
Ok, just tested it again and it now keeps the selected text highlighted. Cool.
And I am using firefox 0.9. |
Support Snitz Forums
|
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 21 June 2004 : 22:40:33
|
Yes, that is what I mean. When I tested it last night it wasn't working for some reason. Glad to know it's working though. Thank you Nathan for providing/testing the code, and thank you Davio for testing it out. |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 22 June 2004 : 07:20:10
|
quote: Originally posted by DavioOk, just tested it again and it now keeps the selected text highlighted. Cool.
The funny thing is, IE leaves it selected, but doesn't highlight the selection to let you know that its selected. Thats what I was wondering if it's an IE bug. (After inserting a set of tags in IE, there is nothing highlighted but if you press a key it replaces the tags and everthing in between with that letter.)
Maybe its just my IE. Or maybe the wanted it like that, who knows.
Richard - no problem [=)] |
Nathan Bales CoreBoard | Active Users Download |
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 22 June 2004 : 07:35:57
|
ok, the text selection is working for me now
But, when you click on a smilie (or any other tag), it leaves the Forum Code highlighted so if you want to enter more than 1 smilie, you have to click on the smilie, then click in the text area, then click the smilie, then click in the textarea, etc.. Which is different than the way it works in IE. Also, if you are typing and then click on a smilie, if you don't click in the text area with the mouse before typing, you will end up typing over the Forum Code for the smilie.. Just some observations... |
|
|
Nertz
Junior Member
Canada
341 Posts |
Posted - 22 June 2004 : 08:30:31
|
quote: Originally posted by Nathan
The funny thing is, IE leaves it selected, but doesn't highlight the selection to let you know that its selected. Thats what I was wondering if it's an IE bug. (After inserting a set of tags in IE, there is nothing highlighted but if you press a key it replaces the tags and everthing in between with that letter.)
Maybe its just my IE. Or maybe the wanted it like that, who knows.
just confirming my IE 6.0 w/ SP1 has always behaved exactly the same as Nathan's. Useful for applying more than one set of tags (ie bold & underline), but it's easy to overtype if you forget about the behaviour and haven't clicked elsewhere to move cursor off selected text.
cheers, Nat |
Sadly, most Family Court Judges wrongfully reward opportunistic gold diggers that use our children unjustly as "instruments" of power.
www.fathers-4-justice-canada.ca |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 23 June 2004 : 02:56:01
|
Wow, that .focus(caretPos) line is packed.
This should take care of the case when nothing is selected before the insert.
function AddText(text) {
var tarea = document.PostTopic.Message;
if (tarea.selectionStart){ // if it supports DOM2
start = tarea.selectionStart;
end = tarea.selectionEnd;
tarea.value = tarea.value.substr(0,tarea.selectionStart)
+ text + tarea.value.substr(tarea.selectionEnd);
tarea.focus();
tarea.selectionStart = ((start - end) == 0) ? start + text.length : start;
tarea.selectionEnd = start + text.length;
} else {
if (tarea.createTextRange && tarea.caretPos) {
var caretPos = tarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
}
else {
tarea.value += text;
}
tarea.focus(caretPos);
}
}
I tested this and it works on my local snitz. |
Nathan Bales CoreBoard | Active Users Download |
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 23 June 2004 : 05:43:46
|
That fixed the smilie problem.
Sorry to keep bothering you with this..
One last thing though, and it's probably just a limitation of the Browser...
When you select text all the way to the beginning of the textarea and then click on one of the ForumCode buttons, then it places the tag at the end of the selected text instead of around it. |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 23 June 2004 : 07:09:28
|
Thank you Richard, that bug actually effected Coreboard as well.
The problem was caused because I used if (tarea.selectionStart) to determine if tarea.selectionStart was defined. If it was 0, then its well defined, but fails my test.
I found somewhere on the internet that this: typeof property != 'undefined' can be used to determine if something is defined, so I change it to that.
function AddText(text) {
var tarea = document.PostTopic.Message;
if (typeof tarea.selectionStart != 'undefined'){ // if it supports DOM2
start = tarea.selectionStart;
end = tarea.selectionEnd;
tarea.value = tarea.value.substr(0,tarea.selectionStart)
+ text + tarea.value.substr(tarea.selectionEnd);
tarea.focus();
tarea.selectionStart = ((start - end) == 0) ? start + text.length : start;
tarea.selectionEnd = start + text.length;
} else {
if (tarea.createTextRange && tarea.caretPos) {
var caretPos = tarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
}
else {
tarea.value += text;
}
tarea.focus(caretPos);
}
}
function getText() {
var tarea = document.PostTopic.Message;
if (tarea.createTextRange && tarea.caretPos) {
return tarea.caretPos.text;
} else if (typeof tarea.selectionStart != 'undefined'){
return tarea.value.substr(tarea.selectionStart,tarea.selectionEnd-tarea.selectionStart)
}
return '';
} |
Nathan Bales CoreBoard | Active Users Download |
Edited by - Nathan on 23 June 2004 07:20:24 |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 23 June 2004 : 07:11:15
|
Hold a sec, that breaks Opera. . .
Fixed . . . and I edited the first post to reflect the most recent code. |
Nathan Bales CoreBoard | Active Users Download |
Edited by - Nathan on 23 June 2004 07:22:56 |
|
|
RichardKinser
Snitz Forums Admin
USA
16655 Posts |
Posted - 23 June 2004 : 07:47:47
|
thanks, that seems to have fixed it. (code is updated on this site) |
|
|
Davio
Development Team Member
Jamaica
12217 Posts |
|
Topic |
|