Browse Source

Fixed #355: Titles support HTML elements

v3_develop
jos 9 years ago
parent
commit
1cd5b0f113
3 changed files with 16 additions and 7 deletions
  1. +1
    -0
      HISTORY.md
  2. +5
    -3
      docs/network.html
  3. +10
    -4
      lib/network/Popup.js

+ 1
- 0
HISTORY.md View File

@ -5,6 +5,7 @@ http://visjs.org
### Network
- Title of nodes and edges can now be an HTML element too.
- Renamed storePosition to storePositions. Added deprication message and old name still works.
- Worked around hammer.js bug with multiple release listeners.
- Improved cleaning up after manipulation toolbar.

+ 5
- 3
docs/network.html View File

@ -316,10 +316,11 @@ When using a DataSet, the network is automatically updating to changes in the Da
<tr>
<td>title</td>
<td>string | function</td>
<td>string | function | Element</td>
<td>no</td>
<td>Title to be displayed when the user hovers over the node.
The title can contain HTML code. If using a function, returning <code>undefined</code>
The title can be an HTML element or a string containing plain text or HTML.
When title is a function, the returned result is displayed as tooltip, and returning <code>undefined</code>
will prevent the tooltip from being displayed.</td>
</tr>
@ -428,7 +429,8 @@ When using a DataSet, the network is automatically updating to changes in the Da
<td>string | function</td>
<td>no</td>
<td>Title to be displayed when the user hovers over the edge.
The title can contain HTML code. If using a function, returning <code>undefined</code>
The title can be an HTML element or a string containing plain text or HTML.
When title is a function, the returned result is displayed as tooltip, and returning <code>undefined</code>
will prevent the tooltip from being displayed.</td>
</tr>

+ 10
- 4
lib/network/Popup.js View File

@ -77,11 +77,17 @@ Popup.prototype.setPosition = function(x, y) {
};
/**
* Set the text for the popup window. This can be HTML code
* @param {string} text
* Set the content for the popup window. This can be HTML code or text.
* @param {string | Element} content
*/
Popup.prototype.setText = function(text) {
this.frame.innerHTML = text;
Popup.prototype.setText = function(content) {
if (content instanceof Element) {
this.frame.innerHTML = '';
this.frame.appendChild(content);
}
else {
this.frame.innerHTML = content; // string containing text or HTML
}
};
/**

Loading…
Cancel
Save