Question Context help visibility
- mlocati
- Topic Author
- Visitor
This way, the current status of the page could be maintained (current data shown, fields manually set and for which users may need help, ...)
Technically, this could be implemented by assigning a css class to the question marks, and a javascript function could look for all the tags with that class and make them visible/hidden (node.style.display="inline/none" or node.style.visibility="visible/hidden").
That script could also set a cookie, so that any other pages could maintain the question marks visibility... I'm thinking in particular to the sub-windows opened by the main window (for example the edit_interface.php?action=add&fact=RESI&pid=I1) for whom at the moment there's no possibility to view context help.
--
Michele
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- mlocati
- Topic Author
- Visitor
In the attached zip you can find the files I modified (based on webtrees-8359).
I've placed the javascript code that manage the visibility of help links (and the text of the Help menu) at the end of /js/webtrees.js, since this script is included by the function print_header of /includes/functions/functions_print.php (and I'm pretty sure it's always called in every page where there's the Help menu).
When the visibility is toggled, we need to set the $_SESSION variable, so that the visibility is maintained in subsequent pages (and sub-windows like the "Add fact to individual"). So the javascript function I inserted in the /js/webtrees.js calls, via am XMLHttpRequest object, a page on the server which sets that session variable. This is the new php script that I called /set_session_variable.php.
Since the show_context_help session variable is set automatically by the file /includes/session.php, that page simply includes this file.
Looking at that /includes/session.php file, I found some code that is really unclear to me:
Why? I don't understand... If I'm missing something please let me know, but I think this code is better:
I then modified the file /includes/functions/functions_print.php to always print contextual help links, setting their visibility to 'hidden' when the $_SESSION variable is set to false.
And finally I modified the /includes/classes/class_menubar.php to change the contextual items of the Help menu.
The menu contains one item, with two span: 'Show contextual help' and 'Hide contextual help'. One of them is initially visible (depending on the $_SESSION variable); their visibility is switched by the javascript function I included in the /js/webtrees.js file.
This should be fine, except the case when tge Help menu is rendered with the getMenuAsDropdown method: the two spans are not suitable for this case. I don't know if the getMenuAsDropdown method could be called in some circustance... For now it seems to me it's not.
Ciao!
Michele
Please Log in or Create an account to join the conversation.
- kiwi
- Offline
- Platinum Member
I think you are right, for now its not used anywhere for Help. That function IS used in some themes for other menu items though. At the very least you would need to add a comment in the code warning that it can no longer be used for Help. Those alternative menu display functions exist to allow users to customise their menus in many different ways. Someone might want to use it for Help in the future.This should be fine, except the case when tge Help menu is rendered with the getMenuAsDropdown method: the two spans are not suitable for this case. I don't know if the getMenuAsDropdown method could be called in some circumstance... For now it seems to me it's not.
But I have a bigger question - Why does Help need a show/hide option at all? Can't we just make it permanently on show? Its not a large icon, so why bother hiding it? There has been a very old bug with it in PGV, I'd hate to introduce any more complications. Keep it simple.
Nigel
www.our-families.info
Please Log in or Create an account to join the conversation.
- mlocati
- Topic Author
- Visitor
There's another solution: adding a new parameter to the Menu class constructor, le'ts say $optionLabel, letting the themes to specify the label to use when rendering the menu as a select. This new parameter could have a default value of null meaning that we can use the usual $label. So, for contextual menu item, we could have the two spans in <li> items, and a text like "switch context help" in <option> items.I think you are right, for now its not used anywhere for Help. That function IS used in some themes for other menu items though. At the very least you would need to add a comment in the code warning that it can no longer be used for Help. Those alternative menu display functions exist to allow users to customise their menus in many different ways. Someone might want to use it for Help in the future.
kiwi wrote:
I don't think I'm the right person to answer this kind of questions. I've been using pgv just as a casual user (also because of it poor Italian translation), so my opinions are not the best ones we can have.But I have a bigger question - Why does Help need a show/hide option at all? Can't we just make it permanently on show? Its not a large icon, so why bother hiding it?
kiwi wrote:
I agree with you: this should be always be kept in mind when writing any piece of code... Better 10 clear lines of code than just one but cryptic.Keep it simple.
Please Log in or Create an account to join the conversation.
- mlocati
- Topic Author
- Visitor
I changed the "webtrees" theme to test the help menu rendered as a <select>.
The new context menu works a charm... Furthermore, other menu items (which I didn't touched) don't work.
Looking at the code, I see that the options have a value of "#", so the script associated to the <select> does this:
document.location="#".
Instead, the item I added has a value of "javascript:switchContextHelp(true)", so the <select> script does this:
document.location="javascript:switchContextHelp(true)".
This syntax is very strange, I've never seen such things, but it works (tested under Firefox, Chrome, IE8, Safari, Opera)...
Thinking a bit about it, anyway, doing something like
document.location="javascript:DoSomething()"
is like pressing this link
<a href="javascript:DoSomething()">...</a>
So it's normal that the <select> script works... Today too I've learned a new thing (which anyway I don't think I'll use )
Please Log in or Create an account to join the conversation.
- ToyGuy
- Offline
- Moderator
- Live like it's Christmas every day - Santa Stephen
Thanks for your polite and succinct posts which also educate the rest of it.
-Stephen
Santa Stephen the Fabled Santa
Latest webtrees at MyArnolds.com
Hosted by webtreesonline.com , a division of GeneHosts LLC
MacOS 10.6.8, Apache 2.2+, PHP 5.4.16, MySQL 5.5.28
Please Log in or Create an account to join the conversation.
- WGroleau
- Offline
- Platinum Member
- Posts: 2165
I agree; simplify. If someone finds the icon too big, they can make a smaller one for their theme.But I have a bigger question - Why does Help need a show/hide option at all? Can't we just make it permanently on show? Its not a large icon, so why bother hiding it? There has been a very old bug with it in PGV, I'd hate to introduce any more complications.
--
Wes Groleau
UniGen.us/
Please Log in or Create an account to join the conversation.