I have to work through some code and found the following function, which I do not understand. What does hintContainer, it grabs the return-value of each() and it seems that this object should be placed inside the callback-function?
Thanks in advance for any guesses, unfortunately I cannot contact the developer. In short, the function should grab all divs with the class userHinterPanel und should show them.
function prepareHintMessages() {
// gets all userHintePanels
var hintContainer = jQuery('div.userHintPanel').each(function() {
hintContainer = jQuery(this);
// hint content div
var hintContent = hintContainer.next();
// hint content text
var closeText = hintContainer.find('div.closeTextContainer');
// inserts text into the content container
hintContent.insertBefore(closeText);
// show the complete hint panel
hintContainer.parent().show();
});
}
UPDATE HTML Snippet, this is the info-Box:
<form id="form" name="form" method="post"
action="xxx.jsf"
enctype="application/x-www-form-urlencoded" class="newPatientForm">
<div id="form_showAllHintsContainer" class="showAllHintsContainer"
onclick="jQuery('#form_showAllUserHints').click();"
title="Alle verfügbaren Hinweise auf dieser Seite einblenden">
?<input class="hidden" id="form_showAllUserHints"
name="form_showAllUserHints"
onclick="A4J.AJAX.Submit('form',event,{'oncomplete':function(request,event,data){prepareHintMessages();},'similarityGroupingId':'form_showAllUserHints','parameters':{'userPrefActionParamShow':'NEW_PATIENT_HINT','form_showAllUserHints':'form_showAllUserHints'} } );return false;"
value="showUserHints" type="button" />
</div>
<div class="generalPadding">
<div id="form_hintRerenderContainer">
<div id="form_newPatientHintWithIsh"
class="userHintPanelContainer newPatient">
<div id="form_newPatientHintWithIshHintPanel"
class="alert-message block-message warning userHintPanel">
<a href="#" onclick="closeHintMessage(this);"
title="Hinweis ausblenden" class="close">×</a>
<div class="header">Hinweis</div>
<div class="text">
<div class="closeTextContainer"
style="position: relative; height: 20px;">
<a href="#" onclick="closeHintMessage(this);"
style="font-size: 14px;" class="close"> Hinweis ausblenden</a>
</div>
</div>
<input class="hidden hideHintButton"
id="form_newPatientHintWithIshHintPanelHideButton"
name="form_newPatientHintWithIshHintPanelHideButton"
onclick="A4J.AJAX.Submit('form',event,{'similarityGroupingId':'form_newPatientHintWithIshHintPanelHideButton','parameters':{'form_newPatientHintWithIshHintPanelHideButton':'form_newPatientHintWithIshHintPanelHideButton','userPrefActionParam':'NEW_PATIENT_HINT'} } );return false;"
value="hideUserHints" type="button" />
</div>
<div class="hintContent">
<ul>...</ul>
</div>
</div>
</div>
It graps all elements with class “userHintPanel” and adds some content just before the close text container and after that shows all prepared userHintPanels
One thing:
It targets something that looks like this:
But in your code it won’t grab the text, but the element itself. Did the developer mean this perhaps?
If it’s really the intend to to grab the element, better rename the var to ‘closeTextElement’ for better understanding of the code.
Another weird thing:
This will result in that at the last userHintPanel, hintContent is ‘undefined’. Is that the intend?
Another very important thing:
Is the parent of userHintPanel an iFrame? If that’s the case the following statement will fail for sure in Safari:
The error you should get is: SCRIPT5022: DOM Exception: HIERARCHY_REQUEST_ERR (3)