/* SelectFilter2 - Turns a multiple-select box into a filter interface. Different than SelectFilter because this is coupled to the admin framework. Requires SelectBox.js and addevent.js. */ // quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]); function quickElement() { var obj = document.createElement(arguments[0]); if (arguments[2] != '' && arguments[2] != null) { var textNode = document.createTextNode(arguments[2]); obj.appendChild(textNode); } var len = arguments.length; for (var i = 3; i < len; i += 2) { obj.setAttribute(arguments[i], arguments[i+1]); } arguments[1].appendChild(obj); return obj; } function findForm(node) { // returns the node of the form containing the given node if (node.tagName.toLowerCase() != 'form') { return findForm(node.parentNode); } return node; } var SelectFilter = { init: function(field_id, field_name, is_stacked) { var from_box = document.getElementById(field_id); from_box.id += '_from'; // change its ID from_box.className = 'filtered'; // Remove

, because it just gets in the way. var ps = from_box.parentNode.getElementsByTagName('p'); for (var i=0; i or

var selector_div = quickElement('div', from_box.parentNode); selector_div.className = is_stacked ? 'selector stacked' : 'selector'; //
var selector_available = quickElement('div', selector_div, ''); selector_available.className = 'selector-available'; quickElement('h2', selector_available, 'Available ' + field_name); var filter_p = quickElement('p', selector_available, ''); filter_p.className = 'selector-filter'; quickElement('img', filter_p, '', 'src', 'http://media.ljworld.com/img/admin/selector-search.gif'); filter_p.appendChild(document.createTextNode(' ')); var filter_input = quickElement('input', filter_p, '', 'type', 'text'); filter_input.id = field_id + '_input'; selector_available.appendChild(from_box); var choose_all = quickElement('a', selector_available, 'Choose all', 'href', 'javascript: (function(){ SelectBox.move_all("' + field_id + '_from", "' + field_id + '_to"); })()'); choose_all.className = 'selector-chooseall'; //