for search
* if user have clicked enter button.
*/
function submitSearchlink(linkId, e) {
var keycode;
if (window.event) {
keycode = window.event.keyCode;
} else if (e) {
keycode = e.which;
} else {
return true;
}
if (keycode == 13) {
var obj = document.getElementById(linkId);
if (obj != null) {
var fireOnThis = obj;
var evt = 'click';
if (document.createEvent) {
var evObj = document.createEvent('MouseEvents');
evObj.initEvent(evt, true, false);
fireOnThis.dispatchEvent(evObj);
}
else if (document.createEventObject) {
fireOnThis.fireEvent('on' + evt);
}
}
}
return true;
}
/**
* Disable the given Button when clicked and then Form is submitted.
*/
function submitAndDisable(button, disabledStyle, msg) {
button.className = disabledStyle; // the styleClass for disabled buttons.
button.disabled = true;
button.form.action += "?" + button.name + "=" + encodeURI(button.value); //bug# 6294035
if (msg != null && msg.length > 1) {
button.value = msg;
}
// // Code to disable other elements. The element values are not
// // submitted when this is applied.
// var e = button.form.elements;
// for (var elem, i = 0; (elem = e[i]); i++ ) {
//
// if (elem.nodeName == 'INPUT') {
// if (elem.type.toLowerCase() == 'submit') {
// elem.disabled = true;
// } else if (elem.type.toLowerCase() == 'text') {
// elem.disabled = true;
// } else if (elem.type.toLowerCase() == 'textarea') {
// elem.disabled = true;
// }
// } else if (elem.nodeName == 'TEXTAREA') {
// if (elem.type.toLowerCase() == 'textarea') {
// elem.disabled = true;
// }
// }
// }
button.form.submit();
return true;
}
function disableButton(button, disabledStyle, msg) {
button.className = disabledStyle; // the styleClass for disabled buttons.
//button.form.action += "?" + button.name + "=" + encodeURI(button.value); //bug# 6294035
if (msg != null && msg.length > 1) {
button.value = msg;
}
return true;
}
/**
* Use for dynamic input components in edit page for onchange event.
* Submit form if any attribute changed and element dataChanged has value false.
* In another case do nothing and return.
*/
function submitValue(strFormName) {
if (document.forms[strFormName] != undefined) {
var dataChanged = document.forms[strFormName].elements[strFormName + ':dataChanged'].value;
if ((dataChanged == false) || (dataChanged == 'false')) {
document.forms[strFormName].elements[strFormName + ':dataChanged'].value = 'true';
//document.forms[strFormName].submit();
// Do not submit the form, if any values has been changed on the
// edit page.
// Its a usability isuue of the page getting refreshed,
// the first time user changes something on the page.
// Fire a onchange event and handle it using ajax, so that the form
// is submitted and the user is not visually aware of this process.
fireEvent(document.forms[strFormName].elements[strFormName + ':dataChanged'], 'change');
return;
} else {
return;
}
}
// It's important to return undefined since onbeforeunload needs exactly this.
return;
}
/**
* Return false if the actually edited Tree, or InfoObjectDTO and so on has been
* changed and the user wants to discard the changes, else true.
* Has to be used as per jsf/infoobject/Edit.xhtml in the body tag:
*
*/
function discardChanges(msgDiscard, strFormName) {
// Hackish
if ((msgDiscard == '') || (msgDiscard == undefined)) {
msgDiscard = 'The data has been changed. Discard?';
}
var discardChanges = true;
if (document.forms[strFormName] != undefined) {
var dataChanged = document.forms[strFormName].elements[strFormName + ':dataChanged'].value;
if ((dataChanged == true) || (dataChanged == 'true')) {
terminatePleaseWait();
return msgDiscard;
} else {
// pleaseWait();
return;
}
}
// It's important to return undefined since onbeforeunload needs exactly this.
return;
}
/**
* confirm if user try to save IO and status Process is not "PUBLISHED"
**/
function confirmStatusChanged(msgStatChanged, strFormName, statusProcVisible) {
if (document.forms[strFormName] != undefined) {
var statVisible = document.forms[strFormName].elements[
strFormName + ':EDITING_STATUS_pgContent_statusProcess:' +
statusProcVisible].checked;
if ((statVisible == false) || (statVisible == 'false')) {
return confirm(msgStatChanged);
} else {
return true;
}
} else {
return true;
}
}
/**
* Capture the RETURN key (exclude textarea) pressed by the users in h:inputTexts: do nothing!
*/
function onEnterSubmitSwallowReturn(event) {
var ie4 = false;
if (document.all) {
ie4 = true;
}
var target = event.target || event.srcElement;
if (ie4) {
if (window.event && window.event.keyCode == 13) {
if (target != null && target != undefined && target.type == "textarea") {
return true;
}
if (target != null && target != undefined && target.contentEditable == "true") {
return true;
}
return false;
} else {
return true;
}
} else {
if (event && event.which == 13) {
if (target != null && target != undefined && target.type == "textarea") {
return true;
}
if (target != null && target != undefined && target.contentEditable == "true") {
return true;
}
return false;
} else {
return true;
}
}
}
/**
* To set the focus on UploadComponent after file uploading.
*/
function focusBrowser(formName) {
var idUploadComp = document.forms[formName].elements[formName + ':jumpToElementId'].value;
if (!(idUploadComp == "") && !(idUploadComp == null)) {
var element = document.forms[formName].elements[formName + ':' + idUploadComp];
if (element != undefined) {
if (idUploadComp.lastIndexOf("_sequenceRelation") != -1) {
// scroll to the element location only when the focus is on sequence component.
ScrollToElement(element);
}
element.focus();
}
// document.getElementById['\'' + formName + ':' + idUploadComp + '\''].focus();
}
}
function adjustHeight() {
var minHeight = $j(window).height() - 65;
$j('.content-section').css('minHeight', minHeight + 'px');
}
/**
* Call in body.onload If hidden element value is not empty, try to find element with given ID
* and scroll page to element.
*/
function focusOnElement() {
var focuesOn = document.getElementById("ioWizardView:ioWizardForm:FocusOnHelper");
// focusEleId is in Value of hidden inputfield in edit page
var focusEleId = null;
if (focuesOn != null) {
focusEleId = focuesOn.value;
}
if (focusEleId != null && focusEleId.length > 1) {
var ele;
if (focusEleId.lastIndexOf(":") > -1) {
ele = document.getElementById(focusEleId);
} else {
ele = $j('[id*=' + focusEleId + ']');
if (ele.length > 0) {
ele = ele[0];
}
}
if (ele != null) {
ele.focus();
/*var scrollIn = window;
if (focusEleId.lastIndexOf('childEditorSubview') > -1) {
scrollIn = $j('[id*=editDialogBody]')[0];
}
if (scrollIn != null) {
ScrollToElement(ele, scrollIn);
} */
}
}
}
function setFocusOnElementId(element) {
var focusOn = document.getElementById("ioWizardView:ioWizardForm:FocusOnHelper");
var elementId = $j(element).attr('id');
if ((elementId.length > 0) && (focusOn != null)) {
$j(focusOn).val(elementId);
$j(focusOn).trigger('onchange');
}
}
/**
* Scroll the page to a yindex of 100 below the actual yindex of the component.
*/
function ScrollToElement(element, scrollIn) {
var selectedPosX = 0;
var selectedPosY = 0;
while (element != null) {
selectedPosX += element.offsetLeft;
selectedPosY += element.offsetTop;
element = element.offsetParent;
}
scrollIn.scrollTo(selectedPosX, selectedPosY - 100);
}
/**
* This function evaluates the given text and truncates it until
* the given length of characters.
*
* @param inputField The HTML input field element.
* @param threshold The maximum number of characters to be allowed.
* @param remainingCharsFieldID The ID of the TextField that displays the
* remaining characters.
*/
function truncate(inputField, threshold, remainingCharsFieldID) {
var elementID = inputField.id;
// var inputField = document.getElementById(elementID);
var count = (threshold - inputField.value.length);
if (count <= 0) {
inputField.value = inputField.value.substring(0, threshold);
inputField.focus();
}
var lastColonIndex = elementID.lastIndexOf(':');
var fullCharsFieldID = elementID.substring(0, lastColonIndex) + ':' + remainingCharsFieldID;
// elements['nonNavObjectDetailForm:nonNavObjectDetailSubview:
// pgDetailCenterColumn:0:centerDetail_stat:remainingCharsField'].
document.
forms['nonNavObjectDetailForm'].
elements[fullCharsFieldID].
value = (threshold - inputField.value.length);
}
/**
* This function enables the Login button again, which will be
* disabled once clicked. We call this function in almost all
* the JSPs in the PublicView of ZWM, as the Login form is
* embedded in the header.
* This function assumes the following ID for the Login button:
* userLoginForm:loginButton
*
* @version ZWM
*/
function enableLoginButton() {
var loginForm = document.forms['userLoginForm'];
if (loginForm != null) {
loginForm.elements['userLoginForm:loginButton'].disabled = false;
}
}
/**
* Generate warning message, if user try to remove mandatory properties
* from field. Used in InfoObjectType and RelationType Attribute edit pages.
*/
function confirmMandatoryField(confirmMsg, elId) {
box = document.getElementById(elId);
if (!box.checked) {
if (confirm(confirmMsg)) {
return true;
} else {
box.checked = true;
return false;
}
} else {
return true;
}
}
/**
* Used in the file uploader module, to check if the selected file for upload
* already exists on the file server.
*/
function _onuploadHandler(e, fileNames, msg) {
var words = fileNames.split(',');
var i = 0;
var entryFile = e.memo.entries[0].fileName.split('\\');
var fileInList = entryFile[entryFile.length - 1];
for (i = 0; i < words.length; i++)
{
if (fileInList == words[i]) {
if (!confirm(words[i] + ' ' + msg)) {
e.memo.entries[0].uploadObject.clear(e.memo.entries[0], true);
return true;
} else {
document.getElementById('uploadFunction_modalPanel').component.show();
// #{rich:component('uploadFunction_modalPanel')}.show();
return true;
}
}
}
document.getElementById('uploadFunction_modalPanel').component.show();
// #{rich:component('uploadFunction_modalPanel')}.show();
return true;
}
/**
* Used to cancel the file upload process.
*/
function _oncancelHandler(componentId, uploadIdentifier) {
if (undefined != $(componentId).component.entries[0] && undefined != $(componentId).component) {
$(componentId).component.entries[0].uploadObject.stop();
//$(componentId).component.entries[0].uploadObject.clear($(componentId).component.entries[0],true);
$(componentId).component.clear();
}
document.getElementById(uploadIdentifier).component.hide();
// #{rich:component(uploadIdentifier)}.hide();
}
/**
* Solution for : In IE6, Combo boxes inside modal panel are disabled.
* In IE6, when the a modal panel is displayed then the modal panel mask does
* not disable the combobox elements on the underlying page. So RichFaces
* internally disables all the comboboxes on the current page incl those inside
* a modal panel. So here reset the disabled attribute of the select element,
* when showing the modal panel.
*
* Use this function on the 'onshow' event of a modalpanel, that could
* possibly contain a combobox. Pass in as attribute either the view id or the
* modal panel id in order to apply this function only for the elements inside
* this modal panel
*/
function enableSelectOptionForIE6(viewMode) {
if (isBrowserIE6OrBelow()) {
var ar = document.getElementsByTagName("select");
for (var i = 0; i < ar.length; i++) {
var cSel = ar[i];
if (cSel.id.indexOf(viewMode) != -1) {
cSel.setAttribute("enabled", "");
cSel.setAttribute("disabled", "");
}
}
}
}
/**
* This function returns the (currently viewed) width of the client's
* browser window.
* Ref: http://www.alistapart.com/articles/footers/
*/
function getCurrentWindowWidth() {
var windowWidth = 0;
if (typeof (window.innerWidth) == 'number') {
windowWidth = window.innerWidth;
} else {
if (document.documentElement && document.documentElement.clientWidth) {
windowWidth = document.documentElement.clientWidth;
} else {
if (document.body && document.body.clientWidth) {
windowWidth = document.body.clientWidth;
}
}
}
return windowWidth;
}
/**
* This function will update the style of the floating footer when the window
* width is less than 750px. This is a fix for Bug #1524.
*/
function updateFloatFooterStyle() {
if (document.getElementById) {
var windowWidth = getCurrentWindowWidth();
if (windowWidth > 0) {
var footerElement = document.getElementById('ioWizardView:ioWizardForm:floatFoot');
// alert('window width: ' + windowWidth);
if (null != footerElement) {
if (windowWidth < 756) {
footerElement.style.paddingLeft = '5px';
footerElement.style.width = '100%';
} else {
footerElement.style.paddingLeft = '243px';
footerElement.style.width = '746px';
}
}
}
}
}
/**
* This function is used to resize the Modal panels when the desktop resolution
* is less than 800x600. If the resolution is low, we decrease the size of the
* given element (identified by strPreviewBodyMainContent) to 600x200
*/
function resizePreviewDialog(strPreviewBodyMainContent) {
// Check if the screen resolution is low.
// In such cases, resize the preview dialog.
var elemPreviewBody = document.getElementById(strPreviewBodyMainContent);
if (null !== elemPreviewBody) {
var panelheight = elemPreviewBody.offsetHeight;
if ((screen.width <= '800') || (screen.height <= '600')) {
elemPreviewBody.style.width = '550px';
elemPreviewBody.style.height = '200px';
}
else if (panelheight > screen.height) {
elemPreviewBody.style.height = '550px';
elemPreviewBody.style.overflowY = 'auto';
}
}
}
/**
* This function sets the CSS position property of the floating footer container
* to 'relative', only if the Browser is Internet Explorer and its version <= 6.
*/
function fixedFooterInIE6() {
if (isBrowserIE6OrBelow()) {
var element = document.getElementById('ioWizardView:ioWizardForm:floatFoot');
element.style.position = 'relative';
}
}
/**
* Provides the functionality to toggle the Help DIV in modules.
*/
function toggleHelp() {
toggleHelper('help');
return;
}
function toggleHelper(strHelpId) {
if (document.getElementById(strHelpId)) {
helpDiv = document.getElementById(strHelpId);
if (helpDiv.style.display == "block") {
helpDiv.style.display = "none";
} else {
helpDiv.style.display = "block";
}
}
return;
}
/**
* Provides the functionality to toggle the Help in InfoObjectEditor wizard.
*/
function toggleEditorWizardHelp(helpTextGrid) {
if (helpTextGrid) {
var helpText = helpTextGrid.id + "_helptxt";
if (document.getElementById(helpText)) {
var helpBox = document.getElementById(helpText);
var agt = navigator.userAgent.toLowerCase();
if (agt.indexOf("safari") != -1) {
helpBox.style.width = '95%';
}
if (helpBox.style.display == "block") {
helpBox.style.display = "none";
} else {
helpBox.style.display = "block";
}
}
}
return;
}
// ================== BEGIN: Temporarily save relation attributes ==============
// Arrays for all input fields of RelationTypeAttributes displayed.
var allFormElements = new Array();
var arrayOfIdex = new Array();
/**
* In CONVERIS v3.5, after changing the value in the UIComponents of
* RelationTypeAttributes and clicking on 'Select' or 'Close' link will
* clear/reset the changed values to the original values. To avoid this
* behaviour, we store the entered values temporarily and then set them
* on the UIComponent, when an AJAX call is completed.
*/
function storeRelationAttributes(formElement) {
if (formElement) {
if (formElement.type == "select-one") {
var index = formElement.selectedIndex;
formElement.options[index].selected = true;
arrayOfIdex[arrayOfIdex.length] = formElement.id + ',' + index;
}
if (allFormElements.length == 0) {
allFormElements[0] = formElement;
} else if (!contains(allFormElements, formElement)) {
allFormElements[allFormElements.length] = formElement;
}
}
}
/**
* Checks whether the component is present in the temporary array of objects.
*/
function contains(formElement, obj) {
for (var i = 0; i < formElement.length; i++) {
if (formElement[i] == obj) {
return true;
}
}
return false;
}
/**
* After adding a relation, add the values present in the temporary array to
* the components in the page.
*/
function updateValuesOfRelationFields() {
var tempFormElement;
for (var i = 0; i < allFormElements.length; i++) {
tempFormElement = document.getElementById(allFormElements[i].id.toString());
if (tempFormElement.type == "text" || tempFormElement.type == "textarea") {
tempFormElement.value = allFormElements[i].value;
} else if (tempFormElement.type == "checkbox" || tempFormElement.type == "radio") {
tempFormElement.checked = allFormElements[i].checked;
} else if (tempFormElement.type == "select-one") {
var agt = navigator.userAgent.toLowerCase();
if (agt.indexOf("msie") != -1) {
for (var idx = 0; idx < arrayOfIdex.length; idx++) {
var tempArrayTextFields = arrayOfIdex[idx].split(',');
var tempId = tempArrayTextFields[0];
if (allFormElements[i].id == tempId) {
tempFormElement.selectedIndex = tempArrayTextFields[1];
}
}
} else {
var index1 = allFormElements[i].selectedIndex;
tempFormElement.options[index1].selected = true;
}
}
tempFormElement = null;
}
}
/**
* Reset the input fields when the page is reloaded.
*/
function resetRelationInputFields() {
allFormElements = [];
arrayOfIdex = [];
}
// ================== END: Temporarily save relation attributes ================
function findSearch(target) {
links = document.getElementsByTagName("input");
for (i = 0; i < links.length; i++) {
link = links[i];
var applyPattern = '.+:' + target + '$';
var match = link.id.match(applyPattern);
if (match != null) {
return link;
}
}
return null;
}
function clickSearch(target) {
var search = findSearch(target);
if (search) {
fireEvent(search, 'click');
}
}
function fireEvent(obj, evt) {
var fireOnThis = obj;
if (document.createEvent) {
var evObj = document.createEvent('MouseEvents');
evObj.initEvent(evt, true, false);
fireOnThis.dispatchEvent(evObj);
} else if (document.createEventObject) {
fireOnThis.fireEvent('on' + evt);
}
}
/**
* work around for bug only in Firefox 11
* find all rich:htmleditors in form and change height with 1px.
*/
function initHtmlEditors() {
var nAgt = navigator.userAgent;
if (nAgt.indexOf("Firefox/11") > -1) {
if (document.forms != null && document.forms != undefined) {
for (k = 0; k < document.forms.length; k++) {
var f = document.forms[k];
for (i = 0; i < f.elements.length; i++) {
var ele = f.elements[i];
if (ele.type != null && ele.type != undefined && ele.type == "textarea") {
initTMCE(ele.id + "_ifr");
}
}
}
}
}
}
/**
* Work around for rich:htmleditor in FF.11
* redefine iframe height via javascript
*/
function initTMCE(objID) {
var elemt = document.getElementById(objID);
if (elemt != null && elemt != undefined) {
var h1 = elemt.style.height;
if (h1 != null && h1 != undefined) {
var h2 = parseInt(h1) + 1;
elemt.style.height = h2 + "px";
} else {
elemt.style.height = "127px";
}
}
}
/**
* get the childNode element by className
* Apply style to childNode element
* @param {type} panelId
* @returns {undefined}
*/
function modalPanelScroll(panelId) {
var doc = document.getElementById(panelId);
if (null !== doc) {
doc.style.position = "absolute";
}
}
//get the height of the window
function getWindowHeight() {
windowHeight = $j(window).height();
}
/* get the height of modalPanel.
* calculate top of modalPanel using windowHeight and Modalpanel Height.
* Apply animation to set Top of ModalPanel.
**/
function positionModalPanel(modalId) {
var element = document.getElementById(modalId);
if (null !== element) {
var diffHeight = element.offsetTop;
if (diffHeight <= 0) {
diffHeight = 0;
}
var top = diffHeight / 2;
var dialogTop = top + $j(document).scrollTop() + 'px';
element.style.top = dialogTop;
}
}
/**
* set margin of the change user role modelpanel
*/
function changeRoleModalPanel(modalId) {
var element = document.getElementById(modalId);
element.style.margin = "0px";
element.style.padding = "2px 0px 0px 1px";
}
/*
*
*/
function modalWin(helpText) {
var width = 500;
var height = 395;
var left = screen.width - 500;
var top = 0;
var params = 'width=' + width + ', height=' + height;
params += ', top=' + top + ', left=' + left;
params += ', directories=no';
params += ', location=no';
params += ', menubar=no';
params += ', resizable=yes';
params += ', scrollbars=yes';
params += ', status=no';
params += ', toolbar=no';
var fontFamily = $("body").css("font-family");
var direction = $("body").css("direction");
myWindow = window.open('', 'name', params);
// var link = document.createElement('link');
// link.id = 'cssId';
// link.rel = 'stylesheet';
// link.type = 'text/css';
// link.href = '/converis/fonts/opensans/opensans-fontface.css';
myWindow.document.getElementsByTagName('body')[0].innerHTML = '';
myWindow.document.open();
myWindow.document.write(helpText);
myWindow.document.close();
// myWindow.document.getElementsByTagName('body')[0].appendChild(link);
myWindow.document.getElementsByTagName('body')[0].style.fontFamily = fontFamily;
myWindow.document.getElementsByTagName('body')[0].style.direction = direction;
myWindow.document.getElementsByTagName('body')[0].style.fontSize = '12px';
myWindow.focus();
}
/**
*
* @param {type} element
* @returns {undefined}
*/
function overviewAddnew(element) {
var descTextPanel = document.getElementById('dynaTempSelView:dynaTempSelForm:descTextPanel');
if(!element) {
$j(descTextPanel).html("");
} else {
//finds the child element based on input tagName
//gets descrption of selected element by obtaining the hiddenInput Id.
var hiddenDescription = document.getElementById($j(element).find('span[id*=hiddenDescriptiontree]').attr("id"));
//sets the description value to descriptionPanel.
// bug #15991 HTML-formatting not shown in helptext
// when using the text() in jquery it will ignore all the html tags and display palin text
// to over come this problem use the html()
$j(descTextPanel).html($j(hiddenDescription).html());
$j(element).attr("aria-describedby", $j(element).find('span[id*=hiddenDescriptiontree]').attr("id"));
}
}
/**
*
* @param {type} element
* @returns {undefined}
*/
function selectedDiv(element) {
// finds the child element based on div tagName
//switches the style onmouseover
var selectedText = $j(element).find('div').attr("id");
var selectedTextElement = document.getElementById(selectedText);
$j(selectedTextElement).removeClass('unselectedDiv');
$j(selectedTextElement).addClass('selectedDiv');
}
/**
*
* @param {type} element
* @returns {undefined}
*/
function unselectedDiv(element) {
// finds the child element based on div tagName
//switches the style onmouseover
var selectedText = $j(element).find('div').attr("id");
var selectedTextElement = document.getElementById(selectedText);
$j(selectedTextElement).removeClass('selectedDiv');
$j(selectedTextElement).addClass('unselectedDiv');
}
/**
* @param {type} scrollElementId
* @return {undefined}
*/
function ScrollToElementId(scrollElementId) {
var url = window.location.href;
var newUrl = url.split("#");
var loc = newUrl[0] + scrollElementId;
window.location.href = loc;
}
function IE8FilterForLoginPage() {
try {
var nAgt = navigator.userAgent;
if ((verOffset = nAgt.indexOf("MSIE")) != -1) {
var version = 8;
if (nAgt.indexOf("Trident/5.0") > -1) {
if (nAgt.indexOf("MSIE 8.0") > -1) {
version = 9; // IE 9
}
}
// if IE major version is less than or 8.
if (version <= 8) {
var htmlELe = document.getElementsByTagName("html")[0];
if (null != htmlELe) {
htmlELe.style.filter = "progid:DXImageTransform.Microsoft.gradient(startColorStr='#b22273a5', EndColorStr='#4c135781')";
}
document.body.style.filter = "progid:DXImageTransform.Microsoft.gradient(startColorStr='#b22273a5', EndColorStr='#4c0f4e72')";
}
}
} catch (error) {
}
}
/**
* Hide the component.
* @param panelId
*/
function hideComponent(panelId) {
if (document.getElementById(panelId) !== null) {
document.getElementById(panelId).style.display = 'none';
}
hideRichPanel();
}
/**
* Hide inactive tabs loading Images for publication search and profile modules.
*/
function resetInActiveLoadImg() {
hideRichPanel();
var x = document.getElementsByClassName("loadimg");
for (var i = 0; i < x.length; i++)
{
hideComponent(x[i].id);
}
}
/**
* Display the component.
* @param panelId
*/
function showComponent(panelId) {
if (document.getElementById(panelId) !== null) {
document.getElementById(panelId).style.display = 'block';
}
}
function ckEditorOnBlurEvent(element) {
// Get the CkEditor instances from current document.
var ckInstances = this.CKEDITOR.instances;
var CKED = ckInstances[element.id]; // Get the current CKEditor instance.
var regEx = /(\r\n|\n|\r)/gm; // Remove the new line characters.
var oldValue = element.value;
var dbValue = element.value;
oldValue = oldValue.replace(regEx, '');
regEx = /\s+/g; // Remove the additional spaces.
oldValue = oldValue.replace(regEx, " ");
regEx = /\s/g; // remove the space after p tag.
oldValue = oldValue.replace(regEx, '
');
element.innerHTML = oldValue;
oldValue = element.textContent;
regEx = '
'; // Remove the br tag.
var newValue = CKED.getSnapshot().replace(regEx, '');
// Assign the updated value to element inner html so that unescaped characters
// will be converted at innerHTML level.
element.innerHTML = newValue;
// Re assign the converted text content to the new value
newValue = element.textContent;
// Assign the original value to the innerHTML.
element.innerHTML = dbValue;
// Check whether editor content has been changed or not.
if (oldValue !== newValue) {
submitValue('ioWizardView:ioWizardForm');
}
}
function ckOnClickEvent() {
var x = document.getElementsByClassName("cke_path");
for (var i = 0; i < x.length; i++) {
x[i].style.display = 'none';
}
}
var scrollPosition;
function saveScrlPos() {
scrollPosition = $j('.boxOverflow').scrollTop();
}
function setScrlPos() {
$j('.boxOverflow').scrollTop(scrollPosition);
}
/**
* set the focus on the element with an id ending with the given elementId
* set tabindex attribute if the element has no tabindex
* @param {type} elementId
* @returns {undefined}
*/
function focusOn(elementId) {
focusOnJQuery("[id$='" + elementId + "']");
}
/**
* set the focus on the element with an id ending with the given elementId
* set tabindex attribute if the element has no tabindex
* @param {type} elementId
* @returns {undefined}
*/
function focusOnJQuery(identifier) {
var element = $j(identifier);
if (element.length) {
var tabindex = element.attr('tabindex');
if (!tabindex) {
if (!(element.is("input") || element.is("select") || element.is("button") || element.is("a"))) {
element.attr('tabindex', -1);
}
}
terminatePleaseWait();
element.focus();
}
}
/**
* focus on the element provided in the event data
* @param {type} event
* @returns {undefined}
*/
function focusOnEvent(event) {
if (event.type != "event" || event.status == "success") {
focusOn(event.source.id);
}
}
/**
* focus on the element id provided by the event but replacing a specific part
* @param {type} event
* @param {type} search
* @param {type} replace
* @returns {undefined}
*/
function focusOnEventReplace(event, search, replace) {
if (event.type != "event" || event.status == "success") {
focusOn(event.source.id.replace(search, replace));
}
}
/**
* focus on the first column of the filter row
* @param {type} event
* @returns {undefined}
*/
function focusOnFilterFirstColumn(event) {
if (event.type != "event" || event.status == "success") {
var idFirstPart = event.source.id.substr(0, event.source.id.lastIndexOf(":") + 1);
var element = $j(".filter-firstcolumn-select[id^='" + idFirstPart + "']");
if (element.length) {
element.focus();
}
}
}
/**
* focus on the attribute column of the filter row
* @param {type} event
* @returns {undefined}
*/
function focusOnFilterAttributeColumn(event) {
if (event.type != "event" || event.status == "success") {
var idFirstPart = event.source.id.substr(0, event.source.id.lastIndexOf(":") + 1);
var element = $j(".filter-attributecolumn-select[id^='" + idFirstPart + "']");
if (element.length) {
element.focus();
}
}
}
/**
* special focus handling for file input
* @param {type} elementId
* @returns {undefined}
*/
function focusOnFileInput(elementId) {
$j("[id$='" + elementId + "'] .rf-fu-inp").focus();
}
/**
* add focus event handler for pop-up
* @param {type} popupId
* @param {type} eventType
* @param {type} elementId
* @returns {addEventForFocus}
*/
function addEventForFocus(popupId, eventType, elementId) {
lEventHandler = function(event, element, data) {
RichFaces.Event.unbindById(popupId, eventType, lEventHandler);
focusOn(elementId);
}
RichFaces.Event.bindById(popupId, eventType, lEventHandler);
}
/**
* fire focus event on a richfaces element
* @param {type} elementId
* @param {type} eventType
* @returns {undefined}
*/
function fireEventForFocus(elementId, eventType) {
RichFaces.Event.fireById(elementId, eventType);
}
/**
* preserved element id for setting focus
* @type String|elementId
*/
var currentFocusId = "";
/**
* save the given elementId for focus setting
* @param {type} elementId
* @returns {undefined}
*/
function saveCurrentFocusId(elementId)
{
currentFocusId = elementId;
}
/**
* set the focus on the preserved focus element id
* @returns {undefined}
*/
function focusOnCurrentFocusId()
{
if (currentFocusId) {
focusOn(currentFocusId);
}
}
/*
*
* JavaScript for SelectAll function in the negativeRights section
* @param {type} type, matching string value
* @param {type} checkValue, whether is checked or unchecked.
* @returns {undefined}
*/
function toggleAll(type, checkValue) {
checkboxes = document.getElementsByTagName("input");
for (i = 0; i < checkboxes.length; i++) {
box = checkboxes[i];
var match = box.id.match(type);
if (match != null) {
box.checked = checkValue;
}
}
}
function updateWindowHeight() {
var height = $j(window).height();
if (height < 800) {
$j('body').height(800);
}
}