Skip to content

Commit 0c20b65

Browse files
committed
CHange the selection api, add method to remove the overlay items
1 parent 73453e5 commit 0c20b65

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

src/selection.js

+28-5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ function Selection(teleperiod) {
6262
if (selection.dtstart.getTime() < pointerDate.getTime()) {
6363
selection.dtend = pointerDate;
6464

65+
if (selection.isValid()) {
66+
selection.highlightPeriods();
67+
}
68+
6569
if (selection.teleperiod.settings.onUpdated) {
6670
selection.teleperiod.settings.onUpdated(selection);
6771
}
@@ -204,7 +208,26 @@ function Selection(teleperiod) {
204208
return rect;
205209
};
206210

211+
/**
212+
* Remove all overlay of the selection
213+
*
214+
*/
215+
this.removeOverlay = function()
216+
{
217+
for (var i=0; i<selection.overlayItems.length; i++) {
218+
selection.overlayItems[i].remove();
219+
}
220+
221+
selection.overlayItems = [];
207222

223+
};
224+
225+
226+
/**
227+
* Apply or remove a classname on all averlay items
228+
* @param string classname
229+
* @param bool status
230+
*/
208231
this.setOverlayClassed = function(classname, status)
209232
{
210233
for (var i=0; i<selection.overlayItems.length; i++) {
@@ -213,13 +236,13 @@ function Selection(teleperiod) {
213236
};
214237

215238

239+
/**
240+
* Remove existing overlay
241+
* and fire the callback
242+
*/
216243
this.resetOverlay = function()
217244
{
218-
for (var i=0; i<selection.overlayItems.length; i++) {
219-
selection.overlayItems[i].remove();
220-
}
221-
222-
selection.overlayItems = [];
245+
selection.removeOverlay();
223246

224247
if (selection.teleperiod.settings.onUpdated) {
225248
selection.teleperiod.settings.onUpdated(selection);

src/teleperiod.js

-3
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,6 @@ function Teleperiod(settings) {
664664
mousemove: telep.updateWtTooltip,
665665
click: function() {
666666
telep.selection.setDate(telep.getPointerDate(this));
667-
if (telep.selection.isValid()) {
668-
telep.selection.highlightPeriods();
669-
}
670667
}
671668
});
672669
};

0 commit comments

Comments
 (0)