google-code-backups / proveit-js

Automatically exported from code.google.com/p/proveit-js
0 stars 0 forks source link

Ensure correct highlighting in all supported browsers #78

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In Opera (10.63 on Linux), the correct length of text is highlighted in the 
textbox, but it does not start or end at the correct index.  It seems to 
consistently start at a lower index than it should, but the offset varies 
between and within a page.  Within a page, it increases in page order.

It may have to do with inconsistent treatment of white space.

Original issue reported on code.google.com by matthew....@gatech.edu on 30 Oct 2010 at 12:02

GoogleCodeExporter commented 8 years ago
Fixed in revision 3b06e.

Opera is apparently the only browser that includes CR (carriage return) in a 
textarea's value.  The problem is that the jQuery val getter strips CR, which 
then causes inconsistencies with the setSelectionRange call.

The solution is simply not to use the val function when dealing with textareas. 
 jQuery may have a reason to remove CR, but it's unhelpful in this case.  With 
just the native getters and setters, it works fine, since Opera is internally 
consistent here.

Original comment by matthew....@gatech.edu on 30 Oct 2010 at 10:48

GoogleCodeExporter commented 8 years ago
This is now broken in IE 8, so I am reopening and renaming the bug.

Original comment by matthew....@gatech.edu on 3 Nov 2010 at 11:31

GoogleCodeExporter commented 8 years ago
I found Wikipedia/MediaWiki's built-in functionality for textarea manipulation 
in plugins.js 
(http://bits.wikimedia.org/w/extensions/UsabilityInitiative/js/plugins.combined.
js).  It sets up a jQuery extension, textSelection.  This seems to have the key 
functionality we need, including setting the selection (setSelection), 
scrolling to it (scrollToCaretPosition), and adding and highlighting new text 
(encapsulateSelection).

As you can see, they've handled many of the cross-browser issues.  The other 
obvious advantage is that it's part of Wikipedia, so bugs should be fixed 
without us having to re-deploy other code.

I think we should rely on this if possible.  I'm in the process of adapting our 
code.

Original comment by matthew....@gatech.edu on 6 Nov 2010 at 6:57

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This should be mostly fixed as of e7b4e.  There are a couple remaining 
problems.  On IE 8, the caret seems to be lost when you navigate to the add 
tab.  Thus, you have to position it immediately before clicking the Add 
Reference button. 

In all browsers, the ibid text is not highlighted when inserting.  This may 
just require adjusting the encapsulateSelection options in 
insertRefIntoMWEditBox.

Original comment by matthew....@gatech.edu on 12 Nov 2010 at 8:06

GoogleCodeExporter commented 8 years ago
In Chrome, selecting any reference after the first 10 or so doesn't work. 
Specifically, it will highlight the text, but it won't scroll the window to the 
appropriate place.

For example, in this article, you can only select references 1-11:
http://en.wikipedia.org/w/index.php?title=Star_Wars&action=edit

In this article, only references 1-17:
http://en.wikipedia.org/w/index.php?title=Georgia_Institute_of_Technology&action
=edit

Original comment by kurt.luther on 14 Nov 2010 at 9:25

GoogleCodeExporter commented 8 years ago
Seems to work fine in Chrome v. 7.0.517.44

Original comment by kurt.luther on 16 Nov 2010 at 8:41

GoogleCodeExporter commented 8 years ago
The ibid issue should be fixed in revision 37c46.  This just required using 
peri and replace: true.  This is tested in IE 8, Safari 5.0.2, Chrome 
8.0.552.23, Firefox 3.6.13pre, and Opera 10.63.

Thus, the only remaining things should be the caret on IE, and the unconfirmed 
Chrome problem.  I think we decided the IE caret problem wasn't a blocker (and 
would be handled in docs).

Original comment by matthew....@gatech.edu on 17 Nov 2010 at 2:40

GoogleCodeExporter commented 8 years ago
This is confirmed in Chrome. Unfortunately it's the same version, 7.0.517.44, 
though I'm running Windows 7 on this PC. 

On the demo page, it produces the following JS error, and doesn't appear to 
highlight any references at all:

Uncaught TypeError: Object #<an Object> has no method 'textSelection' on 
ProveIt_Wikipedia.js line 132.

On Wikipedia, the same problem persists (the window won't scroll properly after 
the first handful of refs). But no JS error.

Original comment by kurt.luther on 20 Nov 2010 at 5:02

GoogleCodeExporter commented 8 years ago
The demo problem was fixed in revision acc32.  However, we confirmed during our 
meeting that the incorrect scrolling applies to at least Chrome and Firefox.  
Apparently, scrollToCaretPosition (from plugins.js) becomes increasingly 
inaccurate for selections farther down the page.

Original comment by matthew....@gatech.edu on 23 Nov 2010 at 10:30

GoogleCodeExporter commented 8 years ago
The scrolling issues should be fixed in all browsers after revision 95d36 and 
revision 22826.  I reinserted the prior scrolling code, and removed all calls 
to scrollToCaretPosition.

Original comment by matthew....@gatech.edu on 1 Dec 2010 at 1:28