Fix Caret Bug

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
10
83%
Very Good
2
17%
Good
0
No votes
Fair
0
No votes
Poor
0
No votes
 
Total votes: 12

markus_petrux
Former Team Member
Posts: 1887
Joined: Wed Apr 23, 2003 7:11 am
Location: Girona, Catalunya (Spain)
Contact:

Post by markus_petrux »

Hi!

I've found something that might break other javascripts present on the page.

It is these lines inserted in the javascript section of posting_body.tpl

Code: Select all

window.onload = initInsertions;

// Fix a bug involving the TextRange object. From
// http://www.frostjedi.com/terra/scripts/demo/caretBug.html
function initInsertions() {
	document.post.message.focus();
	if (is_ie && typeof(baseHeight) != 'number') baseHeight = document.selection.createRange().duplicate().boundingHeight;
}
If there's another javascript in need of the onload handler of the window, it won't work 'cause it has been overridden by this MOD.

This could be fixed by doing something like this instead:

Code: Select all

var fixcaretbug_oldLoad = window.onload;
window.onload = initInsertions;

// Fix a bug involving the TextRange object. From
// http://www.frostjedi.com/terra/scripts/demo/caretBug.html
function initInsertions() {
	if( fixcaretbug_oldLoad )
	{
		fixcaretbug_oldLoad();
		fixcaretbug_oldLoad = null;
	}
	document.post.message.focus();
	if (is_ie && typeof(baseHeight) != 'number') baseHeight = document.selection.createRange().duplicate().boundingHeight;
}
If there was an onload event handler installed by another javascript, this small change will take care of it (note the use of the fixcaretbug_oldLoad variable).

HTH+ :)
EasyMOD Standards | MOD Template Actions | MODs in Development Rules
Useful information for MOD Authors | MOD Queue Stats | Search MODs
Write SQL/DDL portable to all SQL servers supported by phpBB!
Get EasyMOD 0.3.0! | Suport al phpBB en Català!
8)
TerraFrost
Former Team Member
Posts: 5957
Joined: Sun Dec 26, 2004 3:40 am
Location: Austin, TX

Post by TerraFrost »

Great observation! :)

I guess a new version will be due out, soon, heh :)
markus_petrux
Former Team Member
Posts: 1887
Joined: Wed Apr 23, 2003 7:11 am
Location: Girona, Catalunya (Spain)
Contact:

Post by markus_petrux »

I guess I've found another way, even simpler. I think it doesn't break anything.

Instead of getting the value of the baseHeight variable at onload event time, which requires to drive the focus to the message field, which is somehow annoying, for instance, when doing a preview... it could be done at onfocus event time.

Let's say we change this:

Code: Select all

window.onload = initInsertions;

// Fix a bug involving the TextRange object. From
// http://www.frostjedi.com/terra/scripts/demo/caretBug.html
function initInsertions() {
   document.post.message.focus();
   if (is_ie && typeof(baseHeight) != 'number') baseHeight = document.selection.createRange().duplicate().boundingHeight;
}
With just this:

Code: Select all

// Fix a bug involving the TextRange object. From
// http://www.frostjedi.com/terra/scripts/demo/caretBug.html
function initInsertions() {
   if (is_ie && typeof(baseHeight) != 'number') baseHeight = document.selection.createRange().duplicate().boundingHeight;
}
Then FIND (partial match):

Code: Select all

<textarea name="message"
IN-LINE FIND:

Code: Select all

onkeyup="storeCaret(this);"
IN-LINE AFTER ADD:

Code: Select all

 onfocus="initInsertions();"
BTW, I believe this also affects -=ET=-'s BBCodes & smilies use enhancement MOD.
EasyMOD Standards | MOD Template Actions | MODs in Development Rules
Useful information for MOD Authors | MOD Queue Stats | Search MODs
Write SQL/DDL portable to all SQL servers supported by phpBB!
Get EasyMOD 0.3.0! | Suport al phpBB en Català!
8)
valval
Registered User
Posts: 123
Joined: Mon Jul 05, 2004 5:55 pm

Post by valval »

TerraFrost wrote: I guess a new version will be due out, soon, heh :)
Any plans to release that new version afterall? :)
User avatar
freddie
Registered User
Posts: 404
Joined: Sun Mar 31, 2002 1:40 pm
Location: Estes Park, USA
Contact:

Post by freddie »

superb, finally got rid of that stupid error that prevent me from posting smilies :)
Kaspin
Registered User
Posts: 10
Joined: Wed Nov 23, 2005 11:28 pm
Location: San Francisco Bay Area
Contact:

Post by Kaspin »

I installed this and it works great to fix the bug. However I have a slight issue on my forum. I'm using the [2.0.16] Super Quick Reply MOD, and I applied the caret fix to viewtopic_quickreply.tpl (part of the other MOD) and now when ever a user views a topic, the page will "jump" down to the text input box at the bottom of the page.

Is there a way to fix this so it doesn't jump down to the text box on page load?
TerraFrost
Former Team Member
Posts: 5957
Joined: Sun Dec 26, 2004 3:40 am
Location: Austin, TX

Post by TerraFrost »

The fix markus_petrux presented should actually fix it. As long as initInsertions is attached to body, though, I don't think there's really a feasable solution. The best I could come up with is as follows:

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
the appropriate file (i don't know what it is for that mod)
#
#-----[ FIND ]------------------------------------------
#
	if (is_ie && typeof(baseHeight) != 'number') baseHeight = document.selection.createRange().duplicate().boundingHeight;
#
#-----[ AFTER, ADD ]------------------------------------
#
	document.body.focus();
This isn't a perfect solution, though, since it'll always direct you to the top of the page (when viewing individual posts, this isn't what you want). An seemingly viable solution would be to play around with document.activeElement, but that only seems to work you've, by hand, given something the focus.
dnbspace
Registered User
Posts: 127
Joined: Thu Oct 19, 2006 11:21 am
Location: Milton Keynes

Post by dnbspace »

Hi when I open templates/beats101/posting_body.tpl

and search for
// Shows the help messages in the helpline window

its not there. any ideas as to what i need to do?
TerraFrost
Former Team Member
Posts: 5957
Joined: Sun Dec 26, 2004 3:40 am
Location: Austin, TX

Post by TerraFrost »

Can you post a link to your board so that I might look at the *.tpl files?
User avatar
freddie
Registered User
Posts: 404
Joined: Sun Mar 31, 2002 1:40 pm
Location: Estes Park, USA
Contact:

Post by freddie »

dnbspace, it is because you are using advanced bbcode box mod

i'm using also that mod and also can't find that line
dnbspace
Registered User
Posts: 127
Joined: Thu Oct 19, 2006 11:21 am
Location: Milton Keynes

Post by dnbspace »

yes i have installed the advanced mod. my website can be found at www.dnbspace.com (
TerraFrost
Former Team Member
Posts: 5957
Joined: Sun Dec 26, 2004 3:40 am
Location: Austin, TX

Post by TerraFrost »

Try this (untested):

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
mods/bbcode_box/bbcode_box.js
#
#-----[ FIND ]------------------------------------------
#
var GVideo = 0;
#
#-----[ AFTER, ADD ]------------------------------------
#
var baseHeight;
window.onload = initInsertions;

// Fix a bug involving the TextRange object. From
// http://www.frostjedi.com/terra/scripts/demo/caretBug.html
function initInsertions() {
	document.post.message.focus();
	if (is_ie && typeof(baseHeight) != 'number') baseHeight = document.selection.createRange().duplicate().boundingHeight;
}

#
#-----[ FIND ]------------------------------------------
#
	if (document.post.message.createTextRange && document.post.message.caretPos) {
#
#-----[ AFTER, ADD ]------------------------------------
#
		if (baseHeight != document.post.message.caretPos.boundingHeight) {
			document.post.message.focus();
			storeCaret(document.post.message);
		}
Looking at your bbcode_box.js file, it looks as though you've already sorta tried to adapt this MOD to it. You should undo those adaptions before doing the above (or adapt the above to "match" your own adaptations)
dnbspace
Registered User
Posts: 127
Joined: Thu Oct 19, 2006 11:21 am
Location: Milton Keynes

Post by dnbspace »

nice one this has fixed it :)

But the explorer still says

done but with errors on the page

Line: 454
Char21
Error: Expected','
code: 0
URL: http:///www.dnbspace.com/posting.php?mode=newtopic&f=1
TerraFrost
Former Team Member
Posts: 5957
Joined: Sun Dec 26, 2004 3:40 am
Location: Austin, TX

Post by TerraFrost »

*shrug* I've never been able to make heads or tails of IE's error messages. FireFox's are a lot better, but FireFox doesn't seem to have any bonafide complaints, either (it complains about CSS attributes it doesn't recognize, but I didn't see any complaints about missing ;'s).

Maybe asking the advanced bbcode box mod might be a good idea?
dnbspace
Registered User
Posts: 127
Joined: Thu Oct 19, 2006 11:21 am
Location: Milton Keynes

Post by dnbspace »

with the advanced bb code mod installed i have noticed that when I use the smilies and post it shows the smilies code and not the images. Why is this?
Post Reply

Return to “[2.0.x] MOD Database Releases”