// simple event stacking. // i don't like Mochikit's one. function getBindTarget(fieldset) { var possibles = getElementsByTagAndClassName('DIV','conditional_target', fieldset); return possibles[0]; } function attachToElementEvent(elem, event_name, func) { // catch IE (grumble) if (elem.attachEvent) { elem.attachEvent('on'+event_name, func); } else { elem.addEventListener(event_name, func, false); } } function removeFromElementEvent(elem, event_name, func) { // catch IE (grumble) if (elem.detachEvent) { elem.detachEvent('on'+event_name, func); } else { elem.removeEventListener(event_name, func, false); } } // quick and dirty helper - find the nearest parent item matching tagName. // FIXME steal the klass or tagName logic from MochiK. // FIXME add to a core js-lib, and add some unit-tests. function breadcrumbFind(elem, tagName) { var stopTag = 'BODY'; var currentTag = elem.tagName; var currentElem = elem; while ((currentTag != stopTag) && (currentTag != tagName)) { currentElem = currentElem.parentNode; currentTag = currentElem.tagName; } if (currentTag == tagName) { return currentElem; } else { return null; } } /* Conditional Metadata Usage * * Allows the system to respond to conditional metadata events. */ /** == Basic process around Conditional Metadata JS/HTML interaction == The system works based on 3 concepts: 1. on the appropriate "activation" command, the entire "field" is serialised and replaced with a hidden input var, and a "user friendly" label. 2. a undo stack needs to be kept, which provides the user with a way to "un-fix" items. 3. When an item is activated, the system: (i) polls the page for fixed input-vars: this _includes_ (for example) fieldset_id, as well as later items. (ii) submits these to a targeturl (set as a "global var" - currently in _this_ file.) // FIXME: this needs to be programmatically settable. // TODO make this operate on a particular subset of the page, and be _instantiable_. (use fieldset as the "controlling component". // TODO lazy bind all activation handlers to ensure that the above problem is solveable. // TODO ensure that this functions across the required browser sets. // TODO verify that the entire set of "lookup" values works here: select and input seem to work. */ var conditional_usage_undostack = new Array(); var conditional_usage_keys = new Array(); // sorry mom. function checkStackForFieldset(fieldset) { for (var i=0; i array(), "formValues" => array()) that can be passed to be backend. // actually, this is ONLY and issue for the "fieldset_id" form-field: // for the rest of them, the backend should handle this sanely (e.g. in what it sends _us_). Suspect the "best" option is to call this // 'fieldset_id[]' since the backend can then extract which fieldsets have been called. other vars will get converted // from and // */ function parseFieldsetToForm(fieldset) { simpleLog('ERROR','call to untested fn: parseFieldsetToForm. '); var formContent = new Array(); var input_vars = getElementsByTagAndClassName('input','fixed',fieldset); formContent["formKeys"] = new Array(); formContent["formValues"] = new Array(); for (var i=0; i" // FIXME: is that a valid assumption? */ function bindToConditionalFieldset(fieldset, widget) { // handleChange needs to be bound to each input widget. // for type variables this means binding to onclick // for