Skip to content

Commit

Permalink
initElem: setHover only if attrsHover set
Browse files Browse the repository at this point in the history
  • Loading branch information
Indigo744 committed Dec 21, 2015
1 parent b203040 commit 4a8d1e0
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions js/jquery.mapael.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,10 @@
var bbox = {};
var textPosition = {};

if (elemOptions.value !== undefined)
// Assign value attribute to element
if (elemOptions.value !== undefined){
elem.value = elemOptions.value;

// Init attrsHover
self.setHoverOptions(elem.mapElem, elemOptions.attrs, elemOptions.attrsHover);
}

// Init the label related to the element
if (elemOptions.text && elemOptions.text.content !== undefined) {
Expand All @@ -360,13 +359,21 @@
textPosition = self.getTextPosition(bbox, elemOptions.text.position, elemOptions.text.margin);
elemOptions.text.attrs["text-anchor"] = textPosition.textAnchor;
elem.textElem = self.paper.text(textPosition.x, textPosition.y, elemOptions.text.content).attr(elemOptions.text.attrs);
self.setHoverOptions(elem.textElem, elemOptions.text.attrs, elemOptions.text.attrsHover);
if (elemOptions.eventHandlers) self.setEventHandlers(id, elemOptions, elem.mapElem, elem.textElem);
self.setHover(elem.mapElem, elem.textElem);
$(elem.textElem.node).attr("data-id", id);
} else {
if (elemOptions.eventHandlers) self.setEventHandlers(id, elemOptions, elem.mapElem);
self.setHover(elem.mapElem);
}

// Set user event handlers
if (elemOptions.eventHandlers) self.setEventHandlers(id, elemOptions, elem.mapElem, elem.textElem);

// Set hover behavior only if attrsHover is set for area or for text
if (($.isEmptyObject(elemOptions.attrsHover) === false) ||
(elem.textElem && $.isEmptyObject(elemOptions.text.attrsHover) === false)) {
// Set hover option for mapElem
self.setHoverOptions(elem.mapElem, elemOptions.attrs, elemOptions.attrsHover);
// Set hover option for textElem
if (elem.textElem) self.setHoverOptions(elem.textElem, elemOptions.text.attrs, elemOptions.text.attrsHover);
// Set hover behavior
self.setHover(elem.mapElem, elem.textElem);
}

// Init the tooltip
Expand Down

0 comments on commit 4a8d1e0

Please sign in to comment.