Skip to content

Commit

Permalink
Moved resize method with timer from the timeline view to the main sti…
Browse files Browse the repository at this point in the history
…xviz class so it will be used by all views.
  • Loading branch information
gertner committed Mar 14, 2014
1 parent 28e3bff commit 8aaf0bf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/nodejs/public/js/STIXRelationshipGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ var StixGraph = function () {
configureNav();

// Add graph container element
$('#contentDiv').append($('#graphTemplate').html());
$('#contentDiv').html($('#graphTemplate').html());

/**
* Append svg container for tree
Expand Down
22 changes: 2 additions & 20 deletions src/nodejs/public/js/STIXRelationshipTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,10 @@ var StixTimeline = function () {


_self.resize = function () {
//Function exists to avoid errors but if we actually resize here
//we will get tons of resize events during a drag resize.
drawTimeline();
}

$(window).resize(function () {
waitForFinalEvent(function(){
drawTimeline();
}, 500, "some unique string");
});

var waitForFinalEvent = (function () {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId";
}
if (timers[uniqueId]) {
clearTimeout (timers[uniqueId]);
}
timers[uniqueId] = setTimeout(callback, ms);
};
})();

function drawTimeline()
{
Expand Down Expand Up @@ -150,7 +132,7 @@ var StixTimeline = function () {
var tooltip = d3.select("body")
.append("div")
.attr("class", "tooltip")
.style("visibility", "visible");
.style("visibility", "none");


//--------------------------------------------------------------------------
Expand Down
22 changes: 19 additions & 3 deletions src/nodejs/public/js/StixViz.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,26 @@ $(function () {
/**
* When the window is resized, resize and update the tree
*/
$(window).resize(function (e) {
view.resize();
});
$(window).resize(function () {
waitForFinalEvent(function(){
view.resize();
}, 500, "some unique string");
});

var waitForFinalEvent = (function () {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId";
}
if (timers[uniqueId]) {
clearTimeout (timers[uniqueId]);
}
timers[uniqueId] = setTimeout(callback, ms);
};
})();



/**
* Handler for Show HTML context menu
Expand Down

0 comments on commit 8aaf0bf

Please sign in to comment.