Skip to content

Commit

Permalink
Merge pull request yotamberk#12 from yotamberk/develop
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
yotamberk authored Jul 1, 2018
2 parents c65b74e + 7cde8e0 commit 7c6c29e
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"presets": ["es2015"],
"presets": ["env"],
"plugins": [
"transform-es3-property-literals",
"transform-es3-member-expression-literals",
Expand Down
87 changes: 45 additions & 42 deletions dist/timeline.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
/**
* timeline.js
* https://github.com/almende/vis
*
* A dynamic, browser-based visualization library.
* timeline plus
* https://yotamberk.github.io/timeline-plus
*
* @version 1.0.0
* @date 2018-04-06
*
* @license
* Copyright (C) 2011-2017 Almende B.V, http://almende.com
*
* timeline.js is dual licensed under both
*
* * The Apache 2.0 License
* http://www.apache.org/licenses/LICENSE-2.0
* @date 2018-07-01
*
* and
*
* * The MIT License
* http://opensource.org/licenses/MIT
*
* timeline.js may be distributed under either license.
*/

"use strict";
Expand Down Expand Up @@ -12695,27 +12679,42 @@ ItemSet.prototype._orderGroups = function () {
* @private
*/
ItemSet.prototype._orderNestedGroups = function (groupIds) {
var newGroupIdsOrder = [];
var _this = this;

groupIds.forEach(function (groupId) {
var groupData = this.groupsData.get(groupId);
if (!groupData.nestedInGroup) {
newGroupIdsOrder.push(groupId);
}
if (groupData.nestedGroups) {
var nestedGroups = this.groupsData.get({
filter: function filter(nestedGroup) {
return nestedGroup.nestedInGroup == groupId;
},
order: this.options.groupOrder
});
var nestedGroupIds = nestedGroups.map(function (nestedGroup) {
return nestedGroup.id;
});
newGroupIdsOrder = newGroupIdsOrder.concat(nestedGroupIds);
}
}, this);
return newGroupIdsOrder;
/**
* Recursively order nested groups
*
* @param {ItemSet} t
* @param {Array.<number>} groupIds
* @returns {Array.<number>}
* @private
*/
function getOrderedNestedGroups(t, groupIds) {
var result = [];
groupIds.forEach(function (groupId) {
result.push(groupId);
var groupData = t.groupsData.get(groupId);
if (groupData.nestedGroups) {
var nestedGroupIds = t.groupsData.get({
filter: function filter(nestedGroup) {
return nestedGroup.nestedInGroup == groupId;
},
order: t.options.groupOrder
}).map(function (nestedGroup) {
return nestedGroup.id;
});
result = result.concat(getOrderedNestedGroups(t, nestedGroupIds));
}
});

return result;
}

var topGroupIds = groupIds.filter(function (groupId) {
return !_this.groupsData.get(groupId).nestedInGroup;
});

return getOrderedNestedGroups(this, topGroupIds);
};

/**
Expand Down Expand Up @@ -15863,6 +15862,8 @@ DataAxis.prototype._create = function () {
this.dom.lineContainer.style.width = '100%';
this.dom.lineContainer.style.height = this.height;
this.dom.lineContainer.style.position = 'relative';
this.dom.lineContainer.style.visibility = 'visible';
this.dom.lineContainer.style.display = 'block';

// create svg element for graph drawing.
this.svg = document.createElementNS('http://www.w3.org/2000/svg', "svg");
Expand Down Expand Up @@ -15930,6 +15931,7 @@ DataAxis.prototype.show = function () {
if (!this.dom.lineContainer.parentNode) {
this.body.dom.backgroundHorizontal.appendChild(this.dom.lineContainer);
}
this.dom.lineContainer.style.display = 'block';
};

/**
Expand All @@ -15941,9 +15943,7 @@ DataAxis.prototype.hide = function () {
this.dom.frame.parentNode.removeChild(this.dom.frame);
}

if (this.dom.lineContainer.parentNode) {
this.dom.lineContainer.parentNode.removeChild(this.dom.lineContainer);
}
this.dom.lineContainer.style.display = 'none';
};

/**
Expand Down Expand Up @@ -16071,6 +16071,9 @@ DataAxis.prototype._redrawLabels = function () {

if (this.master === false && this.masterAxis != undefined) {
this.scale.followScale(this.masterAxis.scale);
this.dom.lineContainer.style.display = 'none';
} else {
this.dom.lineContainer.style.display = 'block';
}

//Is updated in side-effect of _redrawLabel():
Expand Down
2 changes: 1 addition & 1 deletion dist/timeline.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions examples/editing/editingItemsCallbacks.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
font-size: 11pt;
}
</style>

<script src="http://t4t5.github.io/sweetalert/dist/sweetalert.min.js"></script>
<link href="http://t4t5.github.io/sweetalert/dist/sweetalert.css" rel="stylesheet" type="text/css"/>
<script src="https://cdn.jsdelivr.net/npm/sweetalert@1.1.3/dist/sweetalert.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/sweetalert@1.1.3/dist/sweetalert.css" rel="stylesheet" type="text/css"/>

<script src="../../dist/timeline.js"></script>
<link href="../../dist/timeline.min.css" rel="stylesheet" type="text/css" />
Expand Down
10 changes: 7 additions & 3 deletions lib/timeline/component/DataAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ DataAxis.prototype._create = function () {
this.dom.lineContainer.style.width = '100%';
this.dom.lineContainer.style.height = this.height;
this.dom.lineContainer.style.position = 'relative';
this.dom.lineContainer.style.visibility = 'visible';
this.dom.lineContainer.style.display = 'block';

// create svg element for graph drawing.
this.svg = document.createElementNS('http://www.w3.org/2000/svg', "svg");
Expand Down Expand Up @@ -232,6 +234,7 @@ DataAxis.prototype.show = function () {
if (!this.dom.lineContainer.parentNode) {
this.body.dom.backgroundHorizontal.appendChild(this.dom.lineContainer);
}
this.dom.lineContainer.style.display = 'block';
};

/**
Expand All @@ -243,9 +246,7 @@ DataAxis.prototype.hide = function () {
this.dom.frame.parentNode.removeChild(this.dom.frame);
}

if (this.dom.lineContainer.parentNode) {
this.dom.lineContainer.parentNode.removeChild(this.dom.lineContainer);
}
this.dom.lineContainer.style.display = 'none';
};

/**
Expand Down Expand Up @@ -382,6 +383,9 @@ DataAxis.prototype._redrawLabels = function () {

if (this.master === false && this.masterAxis != undefined) {
this.scale.followScale(this.masterAxis.scale);
this.dom.lineContainer.style.display = 'none';
} else {
this.dom.lineContainer.style.display = 'block';
}

//Is updated in side-effect of _redrawLabel():
Expand Down
48 changes: 29 additions & 19 deletions lib/timeline/component/ItemSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1240,27 +1240,37 @@ ItemSet.prototype._orderGroups = function () {
* @private
*/
ItemSet.prototype._orderNestedGroups = function(groupIds) {
var newGroupIdsOrder = [];
/**
* Recursively order nested groups
*
* @param {ItemSet} t
* @param {Array.<number>} groupIds
* @returns {Array.<number>}
* @private
*/
function getOrderedNestedGroups(t, groupIds) {
var result = [];
groupIds.forEach(function (groupId) {
result.push(groupId);
var groupData = t.groupsData.get(groupId);
if (groupData.nestedGroups) {
var nestedGroupIds = t.groupsData.get({
filter: function(nestedGroup) {
return nestedGroup.nestedInGroup == groupId;
},
order: t.options.groupOrder
}).map(function(nestedGroup) { return nestedGroup.id });
result = result.concat(getOrderedNestedGroups(t, nestedGroupIds));
}
});

groupIds.forEach(function(groupId){
var groupData = this.groupsData.get(groupId);
if (!groupData.nestedInGroup) {
newGroupIdsOrder.push(groupId)
}
if (groupData.nestedGroups) {
var nestedGroups = this.groupsData.get({
filter: function(nestedGroup) {
return nestedGroup.nestedInGroup == groupId;
},
order: this.options.groupOrder
});
var nestedGroupIds = nestedGroups.map(function(nestedGroup) { return nestedGroup.id });
newGroupIdsOrder = newGroupIdsOrder.concat(nestedGroupIds);
}
}, this);
return newGroupIdsOrder;
};
return result;
}

var topGroupIds = groupIds.filter(groupId => !this.groupsData.get(groupId).nestedInGroup);

return getOrderedNestedGroups(this, topGroupIds);
};

/**
* Add a new item
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "timeline-plus",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"main": "./dist/timeline.js",
"directories": {
Expand Down Expand Up @@ -39,7 +39,7 @@
"babel-plugin-transform-es3-property-literals": "^6.22.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-env": "^1.7.0",
"babel-runtime": "^6.23.0",
"babelify": "^7.3.0",
"clean-css": "^4.1.7",
Expand Down

0 comments on commit 7c6c29e

Please sign in to comment.