mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 12:03:21 +01:00
Merge pull request #1435 from cyberalien/ticket/11562
forum_fn.js cleanup
This commit is contained in:
commit
9d5ab7615f
@ -42,19 +42,12 @@ function jumpto() {
|
||||
* id = ID of parent container, name = name prefix, state = state [true/false]
|
||||
*/
|
||||
function marklist(id, name, state) {
|
||||
var parent = document.getElementById(id) || document[id];
|
||||
|
||||
if (!parent) {
|
||||
return;
|
||||
}
|
||||
|
||||
var rb = parent.getElementsByTagName('input');
|
||||
|
||||
for (var r = 0; r < rb.length; r++) {
|
||||
if (rb[r].name.substr(0, name.length) === name) {
|
||||
rb[r].checked = state;
|
||||
jQuery('#' + id + ' input[type=checkbox][name]').each(function() {
|
||||
var $this = jQuery(this);
|
||||
if ($this.attr('name').substr(0, name.length) == name) {
|
||||
$this.prop('checked', state);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,29 +117,15 @@ jQuery(document).ready(function() {
|
||||
}
|
||||
|
||||
function subPanels(p) {
|
||||
var i, e, t;
|
||||
var i;
|
||||
|
||||
if (typeof(p) === 'string') {
|
||||
show_panel = p;
|
||||
}
|
||||
|
||||
for (i = 0; i < panels.length; i++) {
|
||||
e = document.getElementById(panels[i]);
|
||||
t = document.getElementById(panels[i] + '-tab');
|
||||
|
||||
if (e) {
|
||||
if (panels[i] === show_panel) {
|
||||
e.style.display = 'block';
|
||||
if (t) {
|
||||
t.className = 'activetab';
|
||||
}
|
||||
} else {
|
||||
e.style.display = 'none';
|
||||
if (t) {
|
||||
t.className = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
jQuery('#' + panels[i]).css('display', panels[i] === show_panel ? 'block' : 'none');
|
||||
jQuery('#' + panels[i] + '-tab').toggleClass('activetab', panels[i] === show_panel);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -255,57 +234,6 @@ function play_qt_file(obj) {
|
||||
obj.Play();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the nodeName of elem is name
|
||||
* @author jQuery
|
||||
*/
|
||||
function is_node_name(elem, name) {
|
||||
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if elem is in array, return position
|
||||
* @author jQuery
|
||||
*/
|
||||
function is_in_array(elem, array) {
|
||||
for (var i = 0, length = array.length; i < length; i++) {
|
||||
// === is correct (IE)
|
||||
if (array[i] === elem) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Element, type and class in tree
|
||||
* Not used, but may come in handy for those not using JQuery
|
||||
* @author jQuery.find, Meik Sievertsen
|
||||
*/
|
||||
function find_in_tree(node, tag, type, class_name) {
|
||||
var result, element, i = 0, length = node.childNodes.length;
|
||||
|
||||
for (element = node.childNodes[0]; i < length; element = node.childNodes[++i]) {
|
||||
if (!element || element.nodeType !== 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((!tag || is_node_name(element, tag)) && (!type || element.type === type)
|
||||
&& (!class_name || is_in_array(class_name, (element.className || element).toString().split(/\s+/)) > -1)) {
|
||||
return element;
|
||||
}
|
||||
|
||||
if (element.childNodes.length) {
|
||||
result = find_in_tree(element, tag, type, class_name);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var in_autocomplete = false;
|
||||
var last_key_entered = '';
|
||||
|
||||
@ -336,47 +264,6 @@ function phpbb_check_key(event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Usually used for onkeypress event, to submit a form on enter
|
||||
*/
|
||||
function submit_default_button(event, selector, class_name) {
|
||||
// Add which for key events
|
||||
if (!event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode)) {
|
||||
event.which = event.charCode || event.keyCode;
|
||||
}
|
||||
|
||||
if (phpbb_check_key(event)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var current = selector.parentNode;
|
||||
|
||||
// Search parent form element
|
||||
while (current && (!current.nodeName || current.nodeType !== 1 || !is_node_name(current, 'form')) && current !== document) {
|
||||
current = current.parentNode;
|
||||
}
|
||||
|
||||
// Find the input submit button with the class name
|
||||
//current = find_in_tree(current, 'input', 'submit', class_name);
|
||||
var input_tags = current.getElementsByTagName('input');
|
||||
current = false;
|
||||
|
||||
for (var i = 0, element = input_tags[0]; i < input_tags.length; element = input_tags[++i]) {
|
||||
if (element.type === 'submit' && is_in_array(class_name, (element.className || element).toString().split(/\s+/)) > -1) {
|
||||
current = element;
|
||||
}
|
||||
}
|
||||
|
||||
if (!current) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Submit form
|
||||
current.focus();
|
||||
current.click();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply onkeypress event for forcing default submit button on ENTER key press
|
||||
* The jQuery snippet used is based on http://greatwebguy.com/programming/dom/default-html-button-submit-on-enter-with-jquery/
|
||||
|
Loading…
x
Reference in New Issue
Block a user