Browse Source

added templating for groups

flowchartTest
Martin Fischer 9 years ago
parent
commit
6cf519175c
4 changed files with 19 additions and 4 deletions
  1. +8
    -1
      docs/timeline/index.html
  2. +9
    -2
      lib/timeline/component/Group.js
  3. +1
    -1
      lib/timeline/component/ItemSet.js
  4. +1
    -0
      lib/timeline/optionsTimeline.js

+ 8
- 1
docs/timeline/index.html View File

@ -580,6 +580,13 @@ function (option, path) {
</td>
</tr>
<tr>
<td>groupTemplate</td>
<td>function</td>
<td>none</td>
<td>A template function used to generate the contents of the groups. The function is called by the Timeline with a groups data as argument, and must return HTML code as result. When the option groupTemplate is specified, the groups do not need to have a field <code>content</code>. See section <a href="#Templates">Templates</a> for a detailed explanation.</td>
</tr>
<tr>
<td>height</td>
<td>number or String</td>
@ -1591,4 +1598,4 @@ var options = {
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../js/ie10-viewport-bug-workaround.js"></script>
<script src="../js/ie10-viewport-bug-workaround.js"></script>

+ 9
- 2
lib/timeline/component/Group.js View File

@ -81,9 +81,16 @@ Group.prototype._create = function() {
*/
Group.prototype.setData = function(data) {
// update contents
var content = data && data.content;
var content;
if (this.itemSet.options && this.itemSet.options.groupTemplate) {
content = this.itemSet.options.groupTemplate(data);
}
else {
content = data && data.content;
}
if (content instanceof Element) {
this.dom.inner.appendChild(content);
this.dom.inner.appendChild(content);
}
else if (content !== undefined && content !== null) {
this.dom.inner.innerHTML = content;

+ 1
- 1
lib/timeline/component/ItemSet.js View File

@ -279,7 +279,7 @@ ItemSet.prototype._create = function(){
ItemSet.prototype.setOptions = function(options) {
if (options) {
// copy all options that we know
var fields = ['type', 'align', 'order', 'stack', 'selectable', 'multiselect', 'groupOrder', 'dataAttributes', 'template','hide', 'snap'];
var fields = ['type', 'align', 'order', 'stack', 'selectable', 'multiselect', 'groupOrder', 'dataAttributes', 'template','groupTemplate','hide', 'snap'];
util.selectiveExtend(fields, this.options, options);
if ('orientation' in options) {

+ 1
- 0
lib/timeline/optionsTimeline.js View File

@ -104,6 +104,7 @@ let allOptions = {
snap: {'function': 'function', 'null': 'null'},
start: {date, number, string, moment},
template: {'function': 'function'},
groupTemplate: {'function': 'function'},
timeAxis: {
scale: {string,'undefined': 'undefined'},
step: {number,'undefined': 'undefined'},

Loading…
Cancel
Save