All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jsf.src.main.webapp.resources.js.util.js Maven / Gradle / Ivy

There is a newer version: 2.0.0-M2
Show newest version
function selectUnselectAll(checkbox) {
	var elements = checkbox.form.elements;
	for ( var i = 0; i < elements.length; i++) {
		var element = elements[i];
		if (/selected$/.test(element.id)) {
			element.checked = checkbox.checked;
		}
	}
}

function selectBox(arg) {
	checkbox = document.getElementById(arg);
	var elements = checkbox.form.elements;
	var allSelected = true;
	for ( var elementIndex = 0; elementIndex < elements.length; elementIndex++) {
		var element = elements[elementIndex];
		if (/selected$/.test(element.id)) {
			if (!element.checked) {
				allSelected = false;
			}
		}
	}
	checkbox.checked = allSelected;
}

function setSelectionRange(input, selectionStart, selectionEnd) {
	if (input.setSelectionRange) {
		input.focus();
		input.setSelectionRange(selectionStart, selectionEnd);
	} else if (input.createTextRange) {
		var range = input.createTextRange();
		range.collapse(true);
		range.moveEnd('character', selectionEnd);
		range.moveStart('character', selectionStart);
		range.select();
	}
}

function setCaretToEnd(e) {
	var input = $((e.target ? e.target : e.srcElement).id);
	setSelectionRange(input, input.value.length, input.value.length);
}





function selectUnselectAllComponents(checkbox) {
	var elements = checkbox.form.elements;
	for ( var i = 0; i < elements.length; i++) {
		var element = elements[i];
		if (/selected$/.test(element.id)) {
			element.checked = checkbox.checked;
		}
	}
	if (checkbox.checked == true) {
		showActions();
	} else {
		hideActions();
	}
}

function selectComponentBox(arg) {
	checkbox = document
			.getElementById(arg);
	var elements = checkbox.form.elements;
	var allSelected = true;
	var selectedItemNumber = 0;
	for ( var elementIndex = 0; elementIndex < elements.length; elementIndex++) {
		var element = elements[elementIndex];
		if (/selected$/.test(element.id)) {
			if (!element.checked) {
				allSelected = false;
			} else {
				selectedItemNumber++;
			}
		}
	}
	checkbox.checked = allSelected;
	if (selectedItemNumber > 0) {
		showActions();
	} else {
		hideActions();
	}
}

function showActions() {
	document.getElementById('actions').style.display = "block";
}

function hideActions() {
	document.getElementById('actions').style.display = "none";
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy