@checksub_team/peaks_timeline 1.4.27 → 1.4.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/lines.js CHANGED
@@ -7,10 +7,12 @@
7
7
  */
8
8
 
9
9
  define([
10
+ './segments-group',
10
11
  './line',
11
12
  './line-indicator',
12
13
  './utils'
13
14
  ], function(
15
+ SegmentsGroup,
14
16
  Line,
15
17
  LineIndicator,
16
18
  Utils) {
@@ -26,6 +28,9 @@ define([
26
28
  this._areSourceInteractionsAllowed = true;
27
29
  this._areSegmentInteractionsAllowed = true;
28
30
 
31
+ this._segmentsGroups = {};
32
+ this._segmentsGroupToLine = {};
33
+
29
34
  this._lineId = 0;
30
35
 
31
36
  this._lineIndicator = new LineIndicator(
@@ -37,8 +42,50 @@ define([
37
42
  this._peaks.on('line.heightChanged', this._onLineHeightChanged.bind(this));
38
43
  this._peaks.on('line.add', this._onLineAdd.bind(this));
39
44
  this._peaks.on('line.remove', this._onLineRemove.bind(this));
45
+
46
+ this._peaks.on('segment.updated', this._onSegmentsUpdate.bind(this));
47
+ this._peaks.on('segments.add', this._onSegmentsAdd.bind(this));
48
+ this._peaks.on('segments.remove', this._onSegmentsRemove.bind(this));
49
+ this._peaks.on('segments.remove_all', this._onSegmentsRemoveAll.bind(this));
50
+ this._peaks.on('segments.dragend', this._onSegmentUpdated.bind(this));
40
51
  }
41
52
 
53
+ Lines.prototype._onSegmentsAdd = function(segments) {
54
+ var self = this;
55
+
56
+ segments.forEach(function(segment) {
57
+ if (!self._segmentsGroups[segment.line]) {
58
+ self._segmentsGroups[segment.line] = new SegmentsGroup(self._peaks, self._view, true);
59
+ }
60
+
61
+ self._segmentsGroups[segment.line].onSegmentsAdd([segment]);
62
+ });
63
+ };
64
+
65
+ Lines.prototype._onSegmentsUpdate = function(segment) {
66
+ this._segmentsGroups[segment.line].onSegmentsUpdate(segment);
67
+ };
68
+
69
+ Lines.prototype._onSegmentUpdated = function(segment) {
70
+ this._segmentsGroups[segment.line].onSegmentUpdated();
71
+ };
72
+
73
+ Lines.prototype._onSegmentsRemove = function(segments) {
74
+ var self = this;
75
+
76
+ segments.forEach(function(segment) {
77
+ self._segmentsGroups[segment.line].onSegmentsRemove([segment]);
78
+ });
79
+ };
80
+
81
+ Lines.prototype._onSegmentsRemoveAll = function(lineId) {
82
+ this._segmentsGroups[lineId].onSegmentsRemoveAll();
83
+
84
+ if (Utils.objectHasProperty(this._segmentsGroupToLine, lineId)) {
85
+ this._segmentsGroupToLine[lineId].refreshSegmentsHeight();
86
+ }
87
+ };
88
+
42
89
  Lines.prototype._onLineHeightChanged = function(position) {
43
90
  this._updateLinesPosition(position);
44
91
  this._view.updateTimeline();
@@ -78,12 +125,13 @@ define([
78
125
  this._linesBySourceId[sourceGroup.getSource().id] = this._linesByPosition[position];
79
126
  };
80
127
 
81
- Lines.prototype.addSegments = function(segmentsGroup, position) {
128
+ Lines.prototype.addSegments = function(lineId, position) {
82
129
  this._createLine(position);
83
130
 
84
131
  this._linesByPosition[position].allowInteractions(this._areSegmentInteractionsAllowed);
85
- this._linesByPosition[position].addSegments(segmentsGroup);
86
- this._segmentsLine = this._linesByPosition[position];
132
+ this._linesByPosition[position].addSegments(this._segmentsGroups[lineId]);
133
+
134
+ this._segmentsGroupToLine[lineId] = this._linesByPosition[position];
87
135
 
88
136
  this._setInteractions(position);
89
137
 
@@ -130,6 +178,10 @@ define([
130
178
  return positions;
131
179
  };
132
180
 
181
+ Lines.prototype.getSegmentsGroups = function() {
182
+ return this._segmentsGroups;
183
+ };
184
+
133
185
  Lines.prototype.addToLayer = function(layer) {
134
186
  for (var position in this._linesByPosition) {
135
187
  if (Utils.objectHasProperty(this._linesByPosition, position)) {
@@ -302,8 +354,10 @@ define([
302
354
  };
303
355
 
304
356
  Lines.prototype.updateSegments = function(frameStartTime, frameEndTime) {
305
- if (this._segmentsLine) {
306
- this._segmentsLine.updateSegments(frameStartTime, frameEndTime);
357
+ for (var lineId in this._segmentsGroups) {
358
+ if (Utils.objectHasProperty(this._segmentsGroups, lineId)) {
359
+ this._segmentsGroups[lineId].updateSegments(frameStartTime, frameEndTime);
360
+ }
307
361
  }
308
362
  };
309
363
 
package/src/main.js CHANGED
@@ -596,8 +596,18 @@ define([
596
596
  this.sources.hideById(sourceId);
597
597
  };
598
598
 
599
- Peaks.prototype.showSegments = function(position) {
600
- this.segments.addSegmentsToPosition(position);
599
+ Peaks.prototype.showSegments = function(lineId, position) {
600
+ this.segments.addSegmentsToPosition(lineId, position);
601
+ };
602
+
603
+ /**
604
+ * Destroy a segment from the {@link Peaks} instance.
605
+ *
606
+ * @param {String} segmentId
607
+ */
608
+
609
+ Peaks.prototype.destroySegment = function(segmentId) {
610
+ this.segments.removeById(segmentId);
601
611
  };
602
612
 
603
613
  Peaks.prototype.setDefaultMode = function() {
@@ -635,7 +645,7 @@ define([
635
645
 
636
646
  Peaks.prototype.deselectSource = function() {
637
647
  return this.view
638
- .deselectSource();
648
+ .deselectElement();
639
649
  };
640
650
 
641
651
  Peaks.prototype._addWindowResizeHandler = function() {
package/src/mode-layer.js CHANGED
@@ -61,22 +61,32 @@ define([
61
61
  stage.add(this._layer);
62
62
  };
63
63
 
64
- ModeLayer.prototype.selectSourceGroup = function(sourceGroup, notify) {
65
- this.deselectSourceGroup();
66
- if (sourceGroup) {
67
- this._selectedElement = sourceGroup;
64
+ ModeLayer.prototype.selectElement = function(element, notify) {
65
+ this.deselectElement(notify);
66
+ if (element) {
67
+ this._selectedElement = element;
68
68
  this._selectedElement.setSelected(true);
69
69
  if (notify) {
70
- this._peaks.emit('source.selected', this._selectedElement.getSource());
70
+ if (element instanceof SourceGroup) {
71
+ this._peaks.emit('source.selected', this._selectedElement.getSource());
72
+ }
73
+ else {
74
+ this._peaks.emit('segment.selected', this._selectedElement.getSegment());
75
+ }
71
76
  }
72
77
  }
73
78
  };
74
79
 
75
- ModeLayer.prototype.deselectSourceGroup = function(notify) {
80
+ ModeLayer.prototype.deselectElement = function(notify) {
76
81
  if (this._selectedElement) {
77
82
  this._selectedElement.setSelected(false);
78
83
  if (notify) {
79
- this._peaks.emit('source.deselected', this._selectedElement.getSource());
84
+ if (this._selectedElement instanceof SourceGroup) {
85
+ this._peaks.emit('source.deselected', this._selectedElement.getSource());
86
+ }
87
+ else {
88
+ this._peaks.emit('segment.deselected', this._selectedElement.getSegment());
89
+ }
80
90
  }
81
91
  this._selectedElement = null;
82
92
  }
@@ -140,16 +150,27 @@ define([
140
150
  var hoveredElement = this._view.getHoveredElement();
141
151
 
142
152
  if (hoveredElement) {
143
- this.selectSourceGroup(hoveredElement, true);
153
+ this.selectElement(hoveredElement, true);
144
154
  }
145
155
  else {
146
- this.deselectSourceGroup(true);
156
+ this.deselectElement(true);
147
157
  }
148
158
  };
149
159
 
150
160
  ModeLayer.prototype._onKeyboardDelete = function() {
151
161
  if (this._selectedElement) {
152
- this._peaks.destroySource(this._selectedElement.getSource().id);
162
+ var selectedElement = this._selectedElement;
163
+
164
+ this.deselectElement(true);
165
+
166
+ if (selectedElement instanceof SourceGroup) {
167
+ this._peaks.destroySource(selectedElement.getSource().id);
168
+ }
169
+ else {
170
+ if (selectedElement.getSegment().allowDeletion) {
171
+ this._peaks.destroySegment(selectedElement.getSegment().id);
172
+ }
173
+ }
153
174
  }
154
175
  };
155
176
 
@@ -318,7 +339,7 @@ define([
318
339
  break;
319
340
  }
320
341
 
321
- this.deselectSourceGroup(true);
342
+ this.deselectElement(true);
322
343
 
323
344
  // Set new mode
324
345
  switch (mode) {
@@ -26,10 +26,10 @@ define([
26
26
  * is shown next to the playhead.
27
27
  */
28
28
 
29
- function PlayheadLayer(peaks, view, segmentsGroup, showTime) {
29
+ function PlayheadLayer(peaks, view, lines, showTime) {
30
30
  this._peaks = peaks;
31
31
  this._view = view;
32
- this._segmentsGroup = segmentsGroup;
32
+ this._lines = lines;
33
33
  this._playheadPixel = 0;
34
34
  this._playheadLineAnimation = null;
35
35
  this._playheadVisible = false;
@@ -38,8 +38,8 @@ define([
38
38
 
39
39
  this._playheadLayer = new Konva.Layer();
40
40
 
41
- this._activeSegment = null;
42
- this._lastActiveSegmentId = null;
41
+ this._activeSegments = {};
42
+ this._lastActiveSegments = {};
43
43
 
44
44
  this._createPlayhead(this._playheadColor);
45
45
 
@@ -56,22 +56,26 @@ define([
56
56
  }
57
57
 
58
58
  PlayheadLayer.prototype._onSegmentsRemoveAll = function() {
59
- this._activeSegment = null;
60
- this._lastActiveSegmentId = null;
59
+ this._activeSegments = {};
60
+ this._lastActiveSegments = {};
61
61
  };
62
62
 
63
63
  PlayheadLayer.prototype._onSegmentsRemove = function(segments) {
64
- if (this._activeSegment || this._lastActiveSegmentId) {
65
- var activeSegmentId = this._activeSegment ? this._activeSegment.id : null;
66
- var lastActiveSegmentId = this._lastActiveSegmentId ? this._lastActiveSegmentId.id : null;
67
-
64
+ if (this._activeSegments || this._lastActiveSegments) {
68
65
  for (var id in segments) {
69
66
  if (Utils.objectHasProperty(segments, id)) {
67
+ var activeSegmentId = this._activeSegments[segments[id].line] ?
68
+ this._activeSegments[segments[id].line].id :
69
+ null;
70
+ var lastActiveSegmentId = this._lastActiveSegments[segments[id].line] ?
71
+ this._lastActiveSegments[segments[id].line].id :
72
+ null;
73
+
70
74
  if (segments[id].id === activeSegmentId) {
71
- this._activeSegment = null;
75
+ delete this._activeSegments[segments[id].line];
72
76
  }
73
77
  if (segments[id].id === lastActiveSegmentId) {
74
- this._lastActiveSegmentId = null;
78
+ delete this._lastActiveSegments[segments[id].line];
75
79
  }
76
80
  }
77
81
  }
@@ -279,21 +283,27 @@ define([
279
283
  var playheadPositionDiff = this._playheadGroup.x() - playheadX;
280
284
 
281
285
  if (playheadPositionDiff) {
282
- var newActiveSegment = this._segmentsGroup.getActiveSegment(
283
- this._view.pixelsToTime(playheadX + frameOffset),
284
- null,
285
- true
286
- );
286
+ var segmentsGroup = this._lines.getSegmentsGroups();
287
+
288
+ for (var lineId in segmentsGroup) {
289
+ if (Utils.objectHasProperty(segmentsGroup, lineId)) {
290
+ var newActiveSegment = segmentsGroup[lineId].getActiveSegment(
291
+ this._view.pixelsToTime(playheadX + frameOffset),
292
+ null,
293
+ true
294
+ );
287
295
 
288
- if (newActiveSegment !== this._activeSegment) {
289
- if (this._activeSegment) {
290
- this._peaks.emit('segments.exit', this._activeSegment);
291
- this._activeSegment = null;
292
- }
293
- if (newActiveSegment) {
294
- this._peaks.emit('segments.enter', newActiveSegment);
295
- this._activeSegment = newActiveSegment;
296
- this._lastActiveSegment = this._activeSegment;
296
+ if (newActiveSegment !== this._activeSegments[lineId]) {
297
+ if (this._activeSegments[lineId]) {
298
+ this._peaks.emit('segments.exit', this._activeSegments[lineId]);
299
+ delete this._activeSegments[lineId];
300
+ }
301
+ if (newActiveSegment) {
302
+ this._peaks.emit('segments.enter', newActiveSegment);
303
+ this._activeSegments[lineId] = newActiveSegment;
304
+ this._lastActiveSegments[lineId] = this._activeSegments[lineId];
305
+ }
306
+ }
297
307
  }
298
308
  }
299
309
  }
@@ -39,6 +39,7 @@ define([
39
39
  this._startMarker = null;
40
40
  this._endMarker = null;
41
41
  this._rectangle = null;
42
+ this._isSelected = false;
42
43
 
43
44
  this._segmentHeight = this._peaks.options.segmentHeight;
44
45
 
@@ -244,7 +245,9 @@ define([
244
245
  SegmentShape.prototype._onMouseEnter = function() {
245
246
  this._view.setCursor('pointer');
246
247
 
247
- this._rectangle.fill(this._segment.selectedColor + Math.round(
248
+ this._view.setHoveredElement(this);
249
+
250
+ this._rectangle.fill(this._segment.activeColor + Math.round(
248
251
  this._segment.opacity * 255
249
252
  ).toString(16));
250
253
 
@@ -256,6 +259,8 @@ define([
256
259
  SegmentShape.prototype._onMouseLeave = function() {
257
260
  this._view.setCursor('default');
258
261
 
262
+ this._view.setHoveredElement(null);
263
+
259
264
  this._rectangle.fill(this._segment.color + Math.round(
260
265
  this._segment.opacity * 255
261
266
  ).toString(16));
@@ -315,6 +320,10 @@ define([
315
320
  this._peaks.emit('segments.dragend', this._segment, startMarker);
316
321
  };
317
322
 
323
+ SegmentShape.prototype.setSelected = function(isSelected) {
324
+ this._isSelected = isSelected;
325
+ };
326
+
318
327
  SegmentShape.prototype.fitToView = function() {
319
328
  if (this._startMarker) {
320
329
  this._startMarker.fitToView();
package/src/segment.js CHANGED
@@ -50,6 +50,10 @@ define([
50
50
  else if (!Utils.isString(options.labelText)) {
51
51
  throw new TypeError('peaks.segments.' + context + ': labelText must be a string');
52
52
  }
53
+
54
+ if (!Utils.isInteger(options.line)) {
55
+ throw new TypeError('peaks.segments.' + context + ': line must be an integer');
56
+ }
53
57
  }
54
58
 
55
59
  /**
@@ -70,7 +74,7 @@ define([
70
74
  */
71
75
 
72
76
  function Segment(peaks, id, startTime, endTime, labelText, color,
73
- textColor, handleTextColor, opacity, editable) {
77
+ textColor, handleTextColor, opacity, editable, allowDeletion, line) {
74
78
  var opts = {
75
79
  startTime: startTime,
76
80
  endTime: endTime,
@@ -79,7 +83,9 @@ define([
79
83
  textColor: textColor,
80
84
  handleTextColor: handleTextColor,
81
85
  opacity: opacity,
82
- editable: editable
86
+ editable: editable,
87
+ allowDeletion: allowDeletion,
88
+ line: line
83
89
  };
84
90
 
85
91
  validateSegment(peaks, opts, 'add()');
@@ -90,11 +96,13 @@ define([
90
96
  this._endTime = opts.endTime;
91
97
  this._labelText = opts.labelText;
92
98
  this._color = opts.color;
93
- this._selectedColor = Utils.shadeColor(color, 20);
99
+ this._activeColor = Utils.shadeColor(color, 20);
94
100
  this._textColor = opts.textColor;
95
101
  this._handleTextColor = opts.handleTextColor;
96
102
  this._opacity = opts.opacity;
97
103
  this._editable = opts.editable;
104
+ this._allowDeletion = opts.allowDeletion;
105
+ this._line = opts.line;
98
106
  this._minSize = peaks.options.minSegmentSize;
99
107
  }
100
108
 
@@ -137,10 +145,10 @@ define([
137
145
  return this._color;
138
146
  }
139
147
  },
140
- selectedColor: {
148
+ activeColor: {
141
149
  enumerable: true,
142
150
  get: function() {
143
- return this._selectedColor;
151
+ return this._activeColor;
144
152
  }
145
153
  },
146
154
  textColor: {
@@ -167,6 +175,18 @@ define([
167
175
  return this._editable;
168
176
  }
169
177
  },
178
+ allowDeletion: {
179
+ enumerable: true,
180
+ get: function() {
181
+ return this._allowDeletion;
182
+ }
183
+ },
184
+ line: {
185
+ enumerable: true,
186
+ get: function() {
187
+ return this._line;
188
+ }
189
+ },
170
190
  minSize: {
171
191
  enumerable: true,
172
192
  get: function() {
@@ -184,7 +204,9 @@ define([
184
204
  textColor: this.textColor,
185
205
  handleTextColor: this.handleTextColor,
186
206
  opacity: this.opacity,
187
- editable: this.editable
207
+ editable: this.editable,
208
+ allowDeletion: this.allowDeletion,
209
+ line: this.line
188
210
  };
189
211
 
190
212
  Utils.extend(opts, options);
@@ -199,6 +221,8 @@ define([
199
221
  this._handleTextColor = opts.handleTextColor;
200
222
  this._opacity = opts.opacity;
201
223
  this._editable = opts.editable;
224
+ this._allowDeletion = opts.allowDeletion;
225
+ this._line = opts.line;
202
226
 
203
227
  this._peaks.emit('segment.updated', this);
204
228
  };
@@ -44,11 +44,6 @@ define([
44
44
 
45
45
  this._isMagnetized = false;
46
46
 
47
- this._peaks.on('segment.updated', this._onSegmentsUpdate.bind(this));
48
- this._peaks.on('segments.add', this._onSegmentsAdd.bind(this));
49
- this._peaks.on('segments.remove', this._onSegmentsRemove.bind(this));
50
- this._peaks.on('segments.remove_all', this._onSegmentsRemoveAll.bind(this));
51
- this._peaks.on('segments.dragend', this._onSegmentUpdated.bind(this));
52
47
  this._peaks.on('segments.setMagnetizing', this.setMagnetizing.bind(this));
53
48
  }
54
49
 
@@ -112,7 +107,7 @@ define([
112
107
  return activeSegment;
113
108
  };
114
109
 
115
- SegmentsGroup.prototype._onSegmentsUpdate = function(segment) {
110
+ SegmentsGroup.prototype.onSegmentsUpdate = function(segment) {
116
111
  if (this._segments[segment.id]) {
117
112
  var redraw = false;
118
113
  var segmentShape = this._segmentShapes[segment.id];
@@ -140,12 +135,12 @@ define([
140
135
  }
141
136
  };
142
137
 
143
- SegmentsGroup.prototype._onSegmentUpdated = function() {
138
+ SegmentsGroup.prototype.onSegmentUpdated = function() {
144
139
  this._peaks.emit('segments.updated', this._updatedSegments);
145
140
  this._updatedSegments = [];
146
141
  };
147
142
 
148
- SegmentsGroup.prototype._onSegmentsAdd = function(segments) {
143
+ SegmentsGroup.prototype.onSegmentsAdd = function(segments) {
149
144
  var self = this;
150
145
 
151
146
  var frameOffset = self._view.getFrameOffset();
@@ -161,7 +156,7 @@ define([
161
156
  self.updateSegments(frameStartTime, frameEndTime);
162
157
  };
163
158
 
164
- SegmentsGroup.prototype._onSegmentsRemove = function(segments) {
159
+ SegmentsGroup.prototype.onSegmentsRemove = function(segments) {
165
160
  var self = this;
166
161
 
167
162
  segments.forEach(function(segment) {
@@ -178,7 +173,7 @@ define([
178
173
  this._draw();
179
174
  };
180
175
 
181
- SegmentsGroup.prototype._onSegmentsRemoveAll = function() {
176
+ SegmentsGroup.prototype.onSegmentsRemoveAll = function() {
182
177
  this._group.removeChildren();
183
178
  this._firstSegmentId = null;
184
179
  this._segments = {};
@@ -313,7 +308,7 @@ define([
313
308
 
314
309
  SegmentsGroup.prototype.updateSegments = function(startTime, endTime) {
315
310
  // Update segments in visible time range.
316
- var segments = this._peaks.segments.find(startTime, endTime);
311
+ var segments = this.find(startTime, endTime);
317
312
 
318
313
  var count = segments.length;
319
314
 
@@ -327,6 +322,31 @@ define([
327
322
  }
328
323
  };
329
324
 
325
+ SegmentsGroup.prototype.find = function(startTime, endTime) {
326
+ var currentSegment = null;
327
+ var visibleSegments = [];
328
+
329
+ if (this._firstSegmentId) {
330
+ do {
331
+ if (!currentSegment) {
332
+ currentSegment = this._segments[this._firstSegmentId];
333
+ }
334
+ else {
335
+ currentSegment = this._segments[currentSegment.nextSegmentId];
336
+ }
337
+
338
+ if (currentSegment.segment.isVisible(startTime, endTime)) {
339
+ visibleSegments.push(currentSegment.segment);
340
+ }
341
+ else if (visibleSegments.length) {
342
+ break;
343
+ }
344
+ } while (currentSegment.nextSegmentId);
345
+ }
346
+
347
+ return visibleSegments;
348
+ };
349
+
330
350
  SegmentsGroup.prototype._draw = function() {
331
351
  this._view.drawSourcesLayer();
332
352
  };
@@ -352,8 +372,13 @@ define([
352
372
  }
353
373
  }
354
374
 
355
- if (!currentHeight && this._segments) {
356
- currentHeight = this._peaks.options.segmentHeight;
375
+ if (!currentHeight) {
376
+ if (Object.keys(this._segments).length > 0) {
377
+ currentHeight = this._peaks.options.segmentHeight;
378
+ }
379
+ else {
380
+ currentHeight = this._peaks.options.emptyLineHeight;
381
+ }
357
382
  }
358
383
 
359
384
  return currentHeight;
@@ -693,11 +718,7 @@ define([
693
718
  };
694
719
 
695
720
  SegmentsGroup.prototype.destroy = function() {
696
- this._peaks.off('segment.updated', this._onSegmentsUpdate);
697
- this._peaks.off('segments.add', this._onSegmentsAdd);
698
- this._peaks.off('segments.remove', this._onSegmentsRemove);
699
- this._peaks.off('segments.remove_all', this._onSegmentsRemoveAll);
700
- this._peaks.off('segments.dragged', this._onSegmentsDragged);
721
+ this._peaks.off('segments.setMagnetizing', this.setMagnetizing);
701
722
  };
702
723
 
703
724
  SegmentsGroup.prototype.fitToView = function() {
@@ -8,7 +8,6 @@
8
8
 
9
9
  define([
10
10
  './source-group',
11
- './segments-group',
12
11
  './lines',
13
12
  './data-retriever',
14
13
  './utils',
@@ -16,7 +15,6 @@ define([
16
15
  'konva'
17
16
  ], function(
18
17
  SourceGroup,
19
- SegmentsGroup,
20
18
  Lines,
21
19
  DataRetriever,
22
20
  Utils,
@@ -45,8 +43,6 @@ define([
45
43
  this._lines = new Lines(peaks, view, this);
46
44
  this._lines.addToLayer(this);
47
45
 
48
- this._segmentsGroup = new SegmentsGroup(peaks, view, true);
49
-
50
46
  this._loadedData = {};
51
47
 
52
48
  this._debouncedRescale = new Invoker().debounce(
@@ -72,8 +68,8 @@ define([
72
68
  this._loadedData[id] = data;
73
69
  };
74
70
 
75
- SourcesLayer.prototype.getSegmentsGroup = function() {
76
- return this._segmentsGroup;
71
+ SourcesLayer.prototype.getSegmentsGroups = function() {
72
+ return this._lines.getSegmentsGroups();
77
73
  };
78
74
 
79
75
  SourcesLayer.prototype.add = function(element) {
@@ -242,8 +238,8 @@ define([
242
238
  this._layer.draw();
243
239
  };
244
240
 
245
- SourcesLayer.prototype._onSegmentsShow = function(position) {
246
- this._lines.addSegments(this._segmentsGroup, position);
241
+ SourcesLayer.prototype._onSegmentsShow = function(lineId, position) {
242
+ this._lines.addSegments(lineId, position);
247
243
  this._view.updateTimelineLength();
248
244
  this._layer.draw();
249
245
  };
@@ -136,7 +136,9 @@ define([
136
136
  options.textColor || '#000000',
137
137
  options.handleTextColor || '#000000',
138
138
  options.opacity || 1,
139
- true // editable
139
+ true, // editable
140
+ options.allowDeletion || false,
141
+ options.line
140
142
  );
141
143
 
142
144
  return segment;
@@ -156,8 +158,8 @@ define([
156
158
  * Add segments to the given line so they can be displayed.
157
159
  */
158
160
 
159
- TimelineSegments.prototype.addSegmentsToPosition = function(position) {
160
- this._peaks.emit('segments.show', position);
161
+ TimelineSegments.prototype.addSegmentsToPosition = function(lineId, position) {
162
+ this._peaks.emit('segments.show', lineId, position);
161
163
  };
162
164
 
163
165
  /**
@@ -379,10 +381,13 @@ define([
379
381
  * <code>segments.remove_all</code> event.
380
382
  */
381
383
 
382
- TimelineSegments.prototype.removeAll = function() {
383
- this._segments = [];
384
- this._segmentsById = {};
385
- this._peaks.emit('segments.remove_all');
384
+ TimelineSegments.prototype.removeAll = function(lineId) {
385
+ var indexes = this._findSegment(function(segment) {
386
+ return segment.line === lineId;
387
+ });
388
+
389
+ this._removeIndexes(indexes);
390
+ this._peaks.emit('segments.remove_all', lineId);
386
391
  };
387
392
 
388
393
  return TimelineSegments;
@@ -131,7 +131,7 @@ define([
131
131
  self._playheadLayer = new PlayheadLayer(
132
132
  peaks,
133
133
  self,
134
- self._sourcesLayer.getSegmentsGroup(),
134
+ self._sourcesLayer,
135
135
  self._options.showPlayheadTime
136
136
  );
137
137
 
@@ -365,12 +365,12 @@ define([
365
365
  var sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
366
366
 
367
367
  if (sourceGroup) {
368
- this._modeLayer.selectSourceGroup(sourceGroup, false);
368
+ this._modeLayer.selectElement(sourceGroup, false);
369
369
  }
370
370
  };
371
371
 
372
- TimelineZoomView.prototype.deselectSource = function() {
373
- this._modeLayer.deselectSourceGroup(false);
372
+ TimelineZoomView.prototype.deselectElement = function() {
373
+ this._modeLayer.deselectElement(false);
374
374
  };
375
375
 
376
376
  TimelineZoomView.prototype.isListening = function() {