Bug 41801 - [Help] like to un-highlight search terms
Summary: [Help] like to un-highlight search terms
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: User Assistance (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P4 enhancement (vote)
Target Milestone: 3.3 M1   Edit
Assignee: Adam Archer CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
: 48813 103210 179357 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-08-21 10:17 EDT by DJ Houghton CLA
Modified: 2007-06-11 10:08 EDT (History)
8 users (show)

See Also:


Attachments
highlight switch code patch (10.47 KB, patch)
2006-03-30 01:25 EST, Jiang Lin Quan CLA
no flags Details | Diff
highlight switch button icon (192 bytes, image/gif)
2006-03-30 01:27 EST, Jiang Lin Quan CLA
no flags Details
Only works in IE and Firefox (15.81 KB, patch)
2006-08-02 12:33 EDT, Adam Archer CLA
no flags Details | Diff
Fully Functional - Untested (24.36 KB, patch)
2006-08-03 01:42 EDT, Adam Archer CLA
no flags Details | Diff
Icons for the patch (1.99 KB, multipart/x-zip)
2006-08-03 01:44 EDT, Adam Archer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description DJ Houghton CLA 2003-08-21 10:17:52 EDT
build i820.

I opened the Help Contents and did a search. In the search results the search 
terms are high-lighted. But if there are a lot of matches, I would like to 
turn off this high-lighting to make the relavent documents easier to read.
Comment 1 Dorian Birsan CLA 2003-08-21 10:26:41 EDT
Yes, this is a good idea.
For the time being, you can synchronize with the table of contents, and, 
assuming the topic exists in the tree, click on it. This will reload the 
document without the highlighting.
Comment 2 Konrad Kolosowski CLA 2003-09-02 11:13:34 EDT
I think highlighting should be turned off by means of some button, not a 
preference settings.
It is not a good idea to put the button in the toolbar on the right, since the 
button should appear only when document displayed is from search results.
I think it might be enough to add a button to search view toolbar (a toolbar 
on the left, only when search tab is active).  The button would control 
whether clicking on search results displays documents with highlighted 
keywords or not, and would not affect the document that is already displayed.
Comment 3 Konrad Kolosowski CLA 2003-12-15 22:27:16 EST
*** Bug 48813 has been marked as a duplicate of this bug. ***
Comment 4 Felix Pahl CLA 2004-02-14 20:24:59 EST
I agree that this should be a button, not a preference,
but I think it would be better if you could turn off
the highlighting after a search has been performed.
Whether you want the highlighting on or off will
depend very much on the page, and you'll only know
after you've seen it. Or I guess there could be a
threshold density of highlights above which they
are automatically turned off -- or they could be
gradually lighter and less obtrusive the denser
they are (such that the total color density they
contribute to the page remains constant :-)
Comment 5 Gary Gregory CLA 2004-02-14 20:37:20 EST
IMHO, in this case, the simpler, the better. An on/off button seems to fit the bill.
Comment 6 Felix Pahl CLA 2004-02-14 21:12:07 EST
Well, I admit that my proposal of constant color contribution
was a bit fanciful :-) My main point was that the on/off button
should apply to the search results after they've been obtained;
otherwise I think one would often end up toggling the button and
then redoing the search.
Comment 7 Lee Anne Kowalski CLA 2004-03-04 18:37:06 EST
Another thing related to the search highlighting currently is that if I do a 
search and the topic has the highlighting and then I print the topic, all of 
the highlighting gets printed as well. This means that all of the terms that I 
searched on are printed as black blocks. :-/

Comment 8 Lee Anne Kowalski CLA 2004-07-30 18:33:36 EDT
If possible, can you consider doing this in two phases:
1. Ability for the user to specify "No search highlighting" in Search window 
before initiating a search. Have a string in the banner reflect "Search 
highlighting off" (like it reflects the scoped search today).

2. Ability for the user to turn off the search highlighting after doing a 
search and loading the page, to turn off the black highlighting in the result 
page.

Phase 2 would require reload of the page, so as a first step, it would be 
easier to do Phase 1 first.

Thanks for the consideration,
--Lee Anne
Comment 9 Konrad Kolosowski CLA 2005-07-19 07:50:29 EDT
*** Bug 103210 has been marked as a duplicate of this bug. ***
Comment 10 Eddie Galvez CLA 2006-03-27 09:35:54 EST
I would like to express interest in seeing this feature added so we can benefit from this in our RCP product.
Comment 11 Curtis d'Entremont CLA 2006-03-27 10:29:25 EST
I would like to see this as well, but unfortunately this week is milestone week for M6 which is feature freeze, so unless someone can supply me a good patch today we will have to defer until next release.
Comment 12 Jiang Lin Quan CLA 2006-03-30 01:25:07 EST
Created attachment 37273 [details]
highlight switch code patch
Comment 13 Jiang Lin Quan CLA 2006-03-30 01:27:49 EST
Created attachment 37274 [details]
highlight switch button icon

This icon should be put in dirctory:

<<eclipse_home>>\plugins\org.eclipse.help.webapp\advanced\images
Comment 14 Curtis d'Entremont CLA 2006-05-30 16:09:52 EDT
I tested the patch (thanks Jiang) but I ran into a few problems while doing so:

- By default I could not get the button to ever show up, even though cookies are enabled. I'm not sure exactly where it's failing, but it's either in UrlUtil.isHighlight() or in the cookie check. I was able to get it to show up by commenting out those parts in contentToolbar.jsp.

- The content pane seems to refresh completely when turning on/off the highlighting, so there's some flashing and worse the page scrolls to the top of the document, so you lose your frame of reference. I'm not an expert in javascript, do you know if it's possible to do this without the flashing and scrolling?
Comment 15 Jiang Lin Quan CLA 2006-05-30 22:10:44 EDT
Thank you for testing the patch.

1, The patch works weel in my laptop, I have no idea about why the button could not show up even you cookies are enabled.  The cookie checking is required, if no checking, when you disabled your browser cookie, you still could see the button with no clicking effect.  That's strange for user.

2, Because the highlight code is trigered by onload() handler of whole page, So it's impossible to do this without the flashing.

For the scrolling, If you could use a parameter to store the current user browsing position. After the switch on/off, the page should be able to sroll to the original position user are borwsing. But I don't think it's a good Idea because we have another "automatically scroll to the first occurrence" function when user clicks the search results.

Comment 16 Curtis d'Entremont CLA 2006-05-31 11:17:45 EDT
Hi Jiang, I did a little research and it does seem possible to do this without refreshing. There are several approaches I can see:

1. Write javascript that goes through the DOM and highlights certain words, for example see http://www.nsftools.com/misc/SearchAndHighlight.htm

2. Switch the entire CSS on the fly, without sending a new request and reloading. This example shows switching page themes and does it without losing it's place on the page: http://www.dynamicdrive.com/dynamicindex9/stylesheetswitcher.htm

3. My preferred approach would be to target a specific (known) CSS rule and change it on the fly using javascript. So where the highlighting is added, it should do it via CSS using a span and a specific class. Then to turn it on and off, just toggle the CSS rule (i.e. change background color) back and forth. No markup changes or reloading needed. See: http://www.javascriptkit.com/domref/style.shtml

Do you think #3 is doable?
Comment 17 Jiang Lin Quan CLA 2006-05-31 23:10:00 EDT
Actually, #1 is using the same mechanism as the highlight method of current highlight.js

I've tried #3, it really works well ! And I have following concerns for #3:

1, We'll inject a CSS style to the result page in HighlightFilter.java.  And because the CSS style reference is gotten from "document.styleSheets[0].rules[0].style", We must inject the CSS as the first style occured in the result page. 

2, The style name could not overlap with the css name what have been existed in result page. Or there must be some weird diplay effect.
Comment 18 Curtis d'Entremont CLA 2006-06-01 10:34:50 EDT
They are both valid concerns. For #1 this may cause problems if someone uses javascript to do the same thing in their documents, and makes assumptions about the index. If we inject our own CSS with a single known rule, we could iterate through the stylesheets until we see one with only one rule that has our name (if this is possible, I don't know if it is). As for the name, we could use something long like org_eclipse_help_webapp_highlight to avoid conflicts.
Comment 19 Curtis d'Entremont CLA 2006-07-13 12:20:20 EDT
Adam, see if we can do approach 3 I mentioned in comment 16. Ideally it should not have to refresh the document in order to toggle the highlighting, we should only toggle a CSS rule and the browser will do the actual work.
Comment 20 Adam Archer CLA 2006-08-02 12:33:18 EDT
Created attachment 47240 [details]
Only works in IE and Firefox

The feature is implemented in the full help system only. There is currently no support in the help view. A button has been added to the ContentToolbar. It is hidden and shown dynamically based on whether or not the current document is a search result or not. The state of the button is persisted as a cookie. Thus it is browser specific and will persist across multiple workspaces. This has only been tested in IE and Firefox.

The implementation of the actual highlighting was achieved by using classes on the spans instead of directly using style attributes when highlighting initially. When the highlight option is toggled, the CSS class is dynamically updated (removing or re-adding the highlight style information). This, in turn, affects all spans using the class without refreshing the page.

Plans from here include adding support for Safari and adding the functionality to the help view. Ideally I would also like to stop using cookies in the full help system when it is running from the workbench (i.e. only use cookies when running as an infocenter). The button's persistent state should match the state of the, to be added, help view button if we are in workbench mode.
Comment 21 Lee Anne Kowalski CLA 2006-08-02 12:46:19 EDT
Wouldn't we still need cookies for the standalone help mode? I have a lot of teams using that (not full workbench, but also not strictly "infocenter" mode).

--Lee Anne
Comment 22 Adam Archer CLA 2006-08-03 01:42:18 EDT
Created attachment 47301 [details]
Fully Functional - Untested

Works in IE, Firefox and Safari and is supported in both the help window and the help view. Currently the toolbar button is not hidden for "non-search-result" documents in the help view. It is disabled instead.

To address the concern made by Lee Anne, the help window is currently using cookies to persist the button state regardless of the mode. This means that the help window button maintains a seperate state than the help view button. In the future I may still look into sharing the button state with the view when in workbench mode (i.e. not in infocenter or standalone mode). Thanks for your input Lee Anne.
Comment 23 Adam Archer CLA 2006-08-03 01:44:22 EDT
Created attachment 47302 [details]
Icons for the patch

The zip file contains the icons for the patch. The paths they need to be placed in are included in the archive.
Comment 24 Curtis d'Entremont CLA 2006-08-03 11:51:50 EDT
Patch submitted.

A few minor changes:

- Set default enablement for view highlight button to on for consistency with help window and previous behavior.
- Renamed help window button's tooltip to match view's ("Highlight search terms").
Comment 25 Chris Goldthorpe CLA 2007-03-27 12:07:11 EDT
*** Bug 179357 has been marked as a duplicate of this bug. ***
Comment 26 Adam Archer CLA 2007-06-11 10:08:25 EDT
Verified in I20070608-1718.