Skip to content

Commit

Permalink
CHange the selection api, add method to remove the overlay items
Browse files Browse the repository at this point in the history
  • Loading branch information
polo2ro committed Mar 22, 2015
1 parent 73453e5 commit 0c20b65
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
33 changes: 28 additions & 5 deletions src/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ function Selection(teleperiod) {
if (selection.dtstart.getTime() < pointerDate.getTime()) {
selection.dtend = pointerDate;

if (selection.isValid()) {
selection.highlightPeriods();
}

if (selection.teleperiod.settings.onUpdated) {
selection.teleperiod.settings.onUpdated(selection);
}
Expand Down Expand Up @@ -204,7 +208,26 @@ function Selection(teleperiod) {
return rect;
};

/**
* Remove all overlay of the selection
*
*/
this.removeOverlay = function()
{
for (var i=0; i<selection.overlayItems.length; i++) {
selection.overlayItems[i].remove();
}

selection.overlayItems = [];

};


/**
* Apply or remove a classname on all averlay items
* @param string classname
* @param bool status
*/
this.setOverlayClassed = function(classname, status)
{
for (var i=0; i<selection.overlayItems.length; i++) {
Expand All @@ -213,13 +236,13 @@ function Selection(teleperiod) {
};


/**
* Remove existing overlay
* and fire the callback
*/
this.resetOverlay = function()
{
for (var i=0; i<selection.overlayItems.length; i++) {
selection.overlayItems[i].remove();
}

selection.overlayItems = [];
selection.removeOverlay();

if (selection.teleperiod.settings.onUpdated) {
selection.teleperiod.settings.onUpdated(selection);
Expand Down
3 changes: 0 additions & 3 deletions src/teleperiod.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,6 @@ function Teleperiod(settings) {
mousemove: telep.updateWtTooltip,
click: function() {
telep.selection.setDate(telep.getPointerDate(this));
if (telep.selection.isValid()) {
telep.selection.highlightPeriods();
}
}
});
};
Expand Down

0 comments on commit 0c20b65

Please sign in to comment.