function buttonDown(event) { if( isCheckable(event) || (event.type == "mouseup" && event.button == 0) || (event.type == "mousedown" && event.button == 0) || (event.type == "mouseout" && event.button == 0)) { event.target.setAttributeNS("http://www.w3.org/2005/07/aaa", "selected", "true"); return false; // Don't continue propagating event } return true; // Browser can still use event } function buttonUp(event) { if( isCheckable(event) || (event.type == "mouseup" && event.button == 0) || (event.type == "mousedown" && event.button == 0) || (event.type == "mouseout" && event.button == 0)) { event.target.setAttributeNS("http://www.w3.org/2005/07/aaa", "selected", "false"); return false; // Don't continue propagating event } return true; // Browser can still use event } function checkboxCheck(node) { node.setAttributeNS("http://www.w3.org/2005/07/aaa", "checked", "true"); } // Mouse and keyboard event handlers for controls, copied from Mozilla's Page function checkboxEvent(event) { if( isCheckable(event) ) { checkboxToggle(event.target); return false; // Don't continue propagating event } return true; // Browser can still use event } function checkboxMixedCheck(node) { node.setAttributeNS("http://www.w3.org/2005/07/aaa", "checked", "mixed"); } // Removes the "checked" attribute from a node function checkboxNoCheck(node) { node.removeAttributeNS("http://www.w3.org/2005/07/aaa", "checked"); } function checkboxToggle(node) { if (node.getAttributeNS("http://www.w3.org/2005/07/aaa", "checked") == "true") { checkboxUnCheck(node); } else { checkboxCheck(node); } } function checkboxTriStateCycle(node) { if (node.getAttributeNS("http://www.w3.org/2005/07/aaa", "checked") == "true") { checkboxMixedCheck(node); } else if (node.getAttributeNS("http://www.w3.org/2005/07/aaa", "checked") == "mixed") { checkboxUnCheck(node); } else { checkboxCheck(node); } } // Mouse and keyboard event handlers for controls, copied from Mozilla's Page function checkboxTriStateEvent(event) { if( isCheckable(event) ) { checkboxTriStateCycle(event.target); return false; // Don't continue propagating event } return true; // Browser can still use event } // Sets the "checked" attribute to false function checkboxUnCheck(node) { node.setAttributeNS("http://www.w3.org/2005/07/aaa", "checked", "false"); } // Returns an a array of radio controls in a group given a DOM radio group node // radioArray is used in the recursion, the root call should pass in "new Array()" function getRadioGroupArray(radioGroupNode, radioArray) { // Recursively search the tree below this node unless they are a radio group node for(var i=0; i -1 ) { return true; } return false; } // returns true if node has role=radio function isRadio(node) { // Attempt to match last part of string because of unrecognized-namespace-in-value issues if( node.getAttributeNS("http://www.w3.org/TR/xhtml2", "role").search(/radio$/) > -1 ) { return true; } return false; } // If radio node is previously unchecked, unchecks the previous // ... radio control in the same group and checks this one. // If radio node was checked, no changes are made. function radioCheck(node) { if(isChecked(node)) { return; // no changes necessary. } radios = getRadioGroupArray(getRadioParentGroup(node), new Array()); for(var i=0; i