michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: The selector locates elements that are suitable for annotation and enables michael@0: the user to select them. michael@0: michael@0: On 'mouseenter' events associated with
elements: michael@0: - if the selector is active and the element is not already annotated michael@0: - find the nearest ancestor which has an id attribute: this is supposed to michael@0: make identification of this element more accurate michael@0: - highlight the element michael@0: - bind 'click' for the element to send a message back to the add-on, including michael@0: all the information associated with the anchor. michael@0: */ michael@0: michael@0: var matchedElement = null; michael@0: var originalBgColor = null; michael@0: var active = false; michael@0: michael@0: function resetMatchedElement() { michael@0: if (matchedElement) { michael@0: matchedElement.css('background-color', originalBgColor); michael@0: matchedElement.unbind('click.annotator'); michael@0: } michael@0: } michael@0: michael@0: self.on('message', function onMessage(activation) { michael@0: active = activation; michael@0: if (!active) { michael@0: resetMatchedElement(); michael@0: } michael@0: }); michael@0: michael@0: function getInnerText(element) { michael@0: // jQuery.text() returns content of