/* * Copyright (c) 2011 OJC Technologies. All rights reserved. * @author: Jake Smith */ function takeClickAction(e) { var ca; e.preventDefault(); ca = new ClickActor(e); ca.processClick(); printer.print("takeClickAction"); return false; } function ClickActor(e) { this.event = e || window.event; this.event.stopPropagation(); this.target = this.event.target || this.event.srcElement; if (printer) {printer.reset();} this.processClick = function() { if (cursor.isTarget(this.target)) { printer.print("cursor was click target, switched to parent"); this.target = this.target.parentNode; } cursor.remove(); if (this.target.nodeName == 'HTML') return; this.placeACursor(); } //-----------------------// // "Private" functions // //-----------------------// this.placeACursor = function() { var clickChooser, contenderNodes, posInfo; clickChooser = new ClickChooser(this.event); contenderNodes = this.getTerminalNodes(); posInfo = clickChooser.getPositionInfo(contenderNodes); cursor.placeAt(posInfo); } this.getTerminalNodes = function() { var termNodes = [], tw; tw = document.createTreeWalker(this.target, NodeFilter.SHOW_TEXT, null, false); while (tw.nextNode() != null) termNodes.push(tw.currentNode); return termNodes; } } // ClickActor(e) // standalone 'helper' function function makeTempSpan(textNode) { var elem, copyTextNode; copyTextNode = document.createTextNode(textNode.nodeValue); elem = getEmptyTempSpan(); elem.appendChild(copyTextNode); return elem; } // standalone 'helper' function function getEmptyTempSpan() { var elem; elem = document.createElement('span'); elem.setAttribute('class', 'temporarysearchspan'); return elem; }