Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 MicroMod: Insert Tags for Mozilla (Take 4)
 New Topic  Topic Locked
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 4

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 21 June 2004 :  21:21:01  Show Profile
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.
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 21 June 2004 :  21:23:55  Show Profile
Ok, it's been changed. you'll probably have to force a refresh to get the updated inc_code.js file.
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 21 June 2004 :  21:37:31  Show Profile  Visit Nathan's Homepage
After a forced refresh it appears to be working as I expected at least.

Nathan Bales
CoreBoard | Active Users Download
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 21 June 2004 :  21:46:30  Show Profile
ok, I'll test it again when I get home tonight.
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 21 June 2004 :  22:37:48  Show Profile
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
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 21 June 2004 :  22:40:33  Show Profile
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.
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 22 June 2004 :  07:20:10  Show Profile  Visit Nathan's Homepage
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
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 22 June 2004 :  07:35:57  Show Profile
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...
Go to Top of Page

Nertz
Junior Member

Canada
341 Posts

Posted - 22 June 2004 :  08:30:31  Show Profile
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
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 23 June 2004 :  02:56:01  Show Profile  Visit Nathan's Homepage
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
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 23 June 2004 :  05:43:46  Show Profile
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.
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 23 June 2004 :  07:09:28  Show Profile  Visit Nathan's Homepage
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
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 23 June 2004 :  07:11:15  Show Profile  Visit Nathan's Homepage
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
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 23 June 2004 :  07:47:47  Show Profile
thanks, that seems to have fixed it. (code is updated on this site)
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 23 June 2004 :  16:54:11  Show Profile
Nice work Nathan.

Support Snitz Forums
Go to Top of Page
Page: of 4 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.15 seconds. Powered By: Snitz Forums 2000 Version 3.4.07