@checksub_team/peaks_timeline 2.0.0-alpha.0 → 2.0.0-alpha.10

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.
@@ -159,15 +159,13 @@ define([
159
159
  lineGroup.addSource(source, sourceGroup, sourcesAround);
160
160
  };
161
161
 
162
- LineGroups.prototype.addSegments = function(lineId, lineOptions) {
163
- this._peaks.addLine(lineOptions, true);
164
-
165
- const lineGroup = this._lineGroupsByPosition[lineOptions.position];
162
+ LineGroups.prototype.addSegments = function(segmentsGroupId, lineId) {
163
+ const lineGroup = this._lineGroupsById[lineId];
166
164
 
167
165
  lineGroup.allowInteractions(this._areSegmentInteractionsAllowed);
168
- lineGroup.addSegments(this._segmentsGroups[lineId]);
166
+ lineGroup.addSegments(this._segmentsGroups[segmentsGroupId]);
169
167
 
170
- this._segmentsGroupToLine[lineId] = lineGroup;
168
+ this._segmentsGroupToLine[segmentsGroupId] = lineGroup;
171
169
 
172
170
  this._setInteractions(lineGroup.getId());
173
171
 
@@ -335,19 +333,27 @@ define([
335
333
  return;
336
334
  }
337
335
 
338
- const position = this._lineGroupsById[sources[0].lineId].getPosition();
336
+ const currentLineGroup = this._lineGroupsById[sources[0].lineId];
337
+ const position = currentLineGroup.getPosition();
339
338
  const linePos = this.getLinesUnderY(mouseY);
340
339
 
340
+ if (currentLineGroup.isLocked()) {
341
+ return;
342
+ }
343
+
341
344
  if (linePos[0] !== linePos[1]) {
342
345
  this.manageAutomaticLineCreation(linePos[0] + 1, position, sources);
343
346
  }
344
347
  else {
345
348
  this.stopAutomaticLineCreation();
346
349
 
350
+ const targetLineGroup = this._lineGroupsByPosition[linePos[0]];
351
+
347
352
  if (
348
353
  !Utils.isNullOrUndefined(mouseX)
349
354
  && linePos[0] !== position
350
- && !this._lineGroupsByPosition[linePos[0]].isSegmentsLine()
355
+ && !targetLineGroup.isLocked()
356
+ && !targetLineGroup.isSegmentsLine()
351
357
  ) {
352
358
  var mouseTime = this._view.pixelsToTime(mouseX + this._view.getFrameOffset());
353
359
  var sourceDuration = Utils.roundTime(endTime - startTime);
@@ -450,16 +456,17 @@ define([
450
456
  for (var position in this._lineGroupsByPosition) {
451
457
  if (Utils.objectHasProperty(this._lineGroupsByPosition, position)) {
452
458
  if (this._lineGroupsByPosition[position].y() !== y) {
453
- anyChange = true;
454
459
  this._lineGroupsByPosition[position].y(y);
460
+ anyChange = true;
455
461
  }
456
462
  y += this._lineGroupsByPosition[position].lineHeight() + this._peaks.options.interline;
457
463
  }
458
464
  }
459
-
460
- if (anyChange && this._lineIndicator.refreshIndicators()) {
461
- this._lineIndicator.draw();
465
+ if (anyChange) {
466
+ this._view.updateTimeline();
462
467
  }
468
+
469
+ this._lineIndicator.refreshIndicators();
463
470
  };
464
471
 
465
472
  LineGroups.prototype._setLinePosition = function(lineId, position) {
@@ -569,9 +576,9 @@ define([
569
576
  };
570
577
 
571
578
  LineGroups.prototype.allowInteractions = function(forSources, forSegments) {
572
- this._areSourceInteractionsAllowed = typeof forSources !== 'undefined' ?
579
+ this._areSourceInteractionsAllowed = !Utils.isNullOrUndefined(forSources) ?
573
580
  forSources : this._areSourceInteractionsAllowed;
574
- this._areSegmentInteractionsAllowed = typeof forSegments !== 'undefined' ?
581
+ this._areSegmentInteractionsAllowed = !Utils.isNullOrUndefined(forSegments) ?
575
582
  forSegments : this._areSegmentInteractionsAllowed;
576
583
  for (var id in this._lineGroupsById) {
577
584
  if (Utils.objectHasProperty(this._lineGroupsById, id)) {
@@ -77,6 +77,8 @@ define([
77
77
  this._stage.height(this._height);
78
78
 
79
79
  this._separatingLine.points([this._width, 0, this._width, this._height]);
80
+
81
+ this.refreshIndicators();
80
82
  };
81
83
 
82
84
  LineIndicator.prototype._createIndicator = function(lineGroup, type, text) {
@@ -297,6 +299,9 @@ define([
297
299
  }
298
300
  }
299
301
 
302
+ if (anyChange) {
303
+ this.draw();
304
+ }
300
305
  return anyChange;
301
306
  };
302
307
 
@@ -56,6 +56,7 @@ define([
56
56
  this._borderWidth = this._source.borderWidth || 0;
57
57
  this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
58
58
  this._selected = this._source.selected;
59
+ this._hovered = false;
59
60
  this._isDragged = false;
60
61
 
61
62
  this._previewList = [];
@@ -79,6 +80,7 @@ define([
79
80
 
80
81
  this._cursor = null;
81
82
  this._group.on('mouseenter', function() {
83
+ self._setHovered(true);
82
84
  self._view.setHoveredElement(self);
83
85
  if (!self._source.loading) {
84
86
  self._showButtons();
@@ -86,6 +88,7 @@ define([
86
88
  });
87
89
 
88
90
  this._group.on('mouseleave', function() {
91
+ self._setHovered(false);
89
92
  self._view.setHoveredElement(null);
90
93
  self._hideButtons();
91
94
  });
@@ -133,6 +136,11 @@ define([
133
136
  this.setLoadingState(this._source.loading);
134
137
  }
135
138
 
139
+ SourceGroup.prototype._setHovered = function(newValue) {
140
+ this._hovered = newValue;
141
+ this._group.draw();
142
+ };
143
+
136
144
  SourceGroup.prototype._onDragStart = function(element) {
137
145
  this._isDragged = true;
138
146
  this._layer.onSourcesGroupDragStart(element);
@@ -419,13 +427,25 @@ define([
419
427
  ctx.closePath();
420
428
 
421
429
  if (fill) {
430
+ var backgroundColor;
431
+
432
+ if (this._selected) {
433
+ backgroundColor = this._source.selectedBackgroundColor;
434
+ }
435
+ else if (this._hovered) {
436
+ backgroundColor = this._source.hoverBackgroundColor;
437
+ }
438
+ else {
439
+ backgroundColor = this._source.backgroundColor;
440
+ }
441
+
422
442
  if (this._source.shouldShowWarning()) {
423
443
  var gradient = ctx.createLinearGradient(0, 0, this._width, 0);
424
444
 
425
445
  if (this._source.mediaEndTime < this._source.duration) {
426
446
  var rightStopPosition = Math.max(1 - (this._source.warningWidth / this._width), 0.5);
427
447
 
428
- gradient.addColorStop(rightStopPosition, this._source.backgroundColor);
448
+ gradient.addColorStop(rightStopPosition, backgroundColor);
429
449
  gradient.addColorStop(1, this._source.warningColor);
430
450
  }
431
451
 
@@ -433,14 +453,14 @@ define([
433
453
  var leftStopPosition = Math.min(this._source.warningWidth / this._width, 0.5);
434
454
 
435
455
  gradient.addColorStop(0, this._source.warningColor);
436
- gradient.addColorStop(leftStopPosition, this._source.backgroundColor);
456
+ gradient.addColorStop(leftStopPosition, backgroundColor);
437
457
  }
438
458
 
439
459
  ctx.fillStyle = gradient;
440
460
  ctx.fill();
441
461
  }
442
462
  else {
443
- ctx.fillStyle = this._source.backgroundColor;
463
+ ctx.fillStyle = backgroundColor;
444
464
  ctx.fill();
445
465
  }
446
466
  }
@@ -671,7 +691,7 @@ define([
671
691
  };
672
692
 
673
693
  SourceGroup.prototype.hideButKeepFocus = function() {
674
- this._group.moveTo(this._view.getTempLayer());
694
+ this._group.moveTo(this._view.getTempGroup());
675
695
  };
676
696
 
677
697
  SourceGroup.prototype.getParent = function() {
@@ -874,7 +894,7 @@ define([
874
894
  this._selected = this._source.selected;
875
895
  if (this._border) {
876
896
  if (this._selected) {
877
- this._border.fill(this._source.selectedColor);
897
+ this._border.fill(this._source.selectedBorderColor);
878
898
  this._borderWidth = this._peaks.options.sourceSelectedBorderWidth;
879
899
  }
880
900
  else {
@@ -891,7 +911,7 @@ define([
891
911
 
892
912
  if (unwrap_background) {
893
913
  if (this._selected) {
894
- unwrap_background.stroke(this._source.selectedColor);
914
+ unwrap_background.stroke(this._source.selectedBorderColor);
895
915
  unwrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
896
916
  }
897
917
  else {
@@ -908,7 +928,7 @@ define([
908
928
 
909
929
  if (wrap_background) {
910
930
  if (this._selected) {
911
- wrap_background.stroke(this._source.selectedColor);
931
+ wrap_background.stroke(this._source.selectedBorderColor);
912
932
  wrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
913
933
  }
914
934
  else {
@@ -1572,6 +1592,7 @@ define([
1572
1592
 
1573
1593
  volumeSliderGroup.on('dragstart', function() {
1574
1594
  volumeText.visible(true);
1595
+ self._peaks.emit('source.startVolumeChange', self._source);
1575
1596
  });
1576
1597
 
1577
1598
  volumeSliderGroup.on('dragmove', function() {
@@ -1587,6 +1608,7 @@ define([
1587
1608
 
1588
1609
  volumeSliderGroup.on('dragend', function() {
1589
1610
  volumeText.visible(false);
1611
+ self._peaks.emit('source.endVolumeChange', self._source);
1590
1612
  });
1591
1613
 
1592
1614
  volumeSliderGroup.on('mouseover', function() {
@@ -109,20 +109,26 @@ define([
109
109
  };
110
110
 
111
111
  SourcesLayer.prototype._onSourceUpdate = function(source) {
112
+ const sourceGroup = this._sourcesGroup[source.id];
113
+ const frameOffset = this._view.getFrameOffset();
114
+ const width = this._view.getWidth();
115
+ const frameStartTime = this._view.pixelsToTime(frameOffset);
116
+ const frameEndTime = this._view.pixelsToTime(frameOffset + width);
112
117
  var redraw = false;
113
- var sourceGroup = this._sourcesGroup[source.id];
114
- var frameOffset = this._view.getFrameOffset();
115
- var width = this._view.getWidth();
116
- var frameStartTime = this._view.pixelsToTime(frameOffset);
117
- var frameEndTime = this._view.pixelsToTime(frameOffset + width);
118
+ var isSourceGroupActive = false;
118
119
 
119
120
  if (sourceGroup) {
121
+ isSourceGroupActive = sourceGroup.isActive();
120
122
  this._destroySourceGroup(source);
121
123
  redraw = true;
122
124
  }
123
125
 
124
- if (source.isVisible(frameStartTime, frameEndTime)) {
125
- this._addSourceGroup(source);
126
+ if (source.isVisible(frameStartTime, frameEndTime) || isSourceGroupActive) {
127
+ const newSourceGroup = this._addSourceGroup(source);
128
+
129
+ if (isSourceGroupActive) {
130
+ newSourceGroup.startDrag();
131
+ }
126
132
  redraw = true;
127
133
  }
128
134
 
@@ -220,8 +226,8 @@ define([
220
226
  }
221
227
  };
222
228
 
223
- SourcesLayer.prototype._onSegmentsShow = function(lineId, lineOptions) {
224
- this._lineGroups.addSegments(lineId, lineOptions);
229
+ SourcesLayer.prototype._onSegmentsShow = function(segmentsGroupId, lineId) {
230
+ this._lineGroups.addSegments(segmentsGroupId, lineId);
225
231
  this._view.updateTimelineLength();
226
232
  this._layer.draw();
227
233
  };
@@ -68,7 +68,8 @@ define([
68
68
  Utils.isNullOrUndefined(options.id) ? Utils.createUuidv4() : options.id,
69
69
  options.position,
70
70
  options.indicatorType,
71
- options.indicatorText
71
+ options.indicatorText,
72
+ options.locked
72
73
  );
73
74
 
74
75
  return line;
package/src/main.js CHANGED
@@ -135,6 +135,11 @@ define([
135
135
  */
136
136
  randomizeSegmentColor: true,
137
137
 
138
+ /**
139
+ * Block mouse clicks if a control key is pressed
140
+ */
141
+ blockUpdatingOnMouseClickWithCtrlKey: false,
142
+
138
143
  /**
139
144
  * Block mouse clicks if a meta key is pressed
140
145
  */
@@ -722,8 +727,8 @@ define([
722
727
  this.lineHandler.moveById(lineId, position);
723
728
  };
724
729
 
725
- Peaks.prototype.showSegments = function(lineId, lineOptions) {
726
- this.segmentHandler.addSegmentsToPosition(lineId, lineOptions);
730
+ Peaks.prototype.showSegments = function(segmentsGroupId, lineId) {
731
+ this.segmentHandler.addSegmentsToLine(segmentsGroupId, lineId);
727
732
  };
728
733
 
729
734
  /**
@@ -744,18 +749,6 @@ define([
744
749
  this.emit('handler.view.cutmode');
745
750
  };
746
751
 
747
- Peaks.prototype.setIndicatorType = function(linePosition, type) {
748
- var lineId = this.view.getLineByPosition(linePosition).getId();
749
-
750
- this.emit('lineIndicator.setType', lineId, type);
751
- };
752
-
753
- Peaks.prototype.setIndicatorText = function(linePosition, text) {
754
- var lineId = this.view.getLineByPosition(linePosition).getId();
755
-
756
- this.emit('lineIndicator.setText', lineId, text);
757
- };
758
-
759
752
  Peaks.prototype.getVisibleSegments = function() {
760
753
  return this.view
761
754
  .getSegmentsGroup()
@@ -29,6 +29,13 @@ define([
29
29
  else if (!Utils.isString(options.indicatorText)) {
30
30
  throw new TypeError('peaks.lines.' + context + ': indicatorText must be a string');
31
31
  }
32
+
33
+ if (Utils.isNullOrUndefined(options.locked)) {
34
+ options.locked = false;
35
+ }
36
+ else if (!Utils.isBoolean(options.locked)) {
37
+ throw new TypeError('peaks.lines.' + context + ': locked must be a boolean');
38
+ }
32
39
  }
33
40
 
34
41
  /**
@@ -44,11 +51,12 @@ define([
44
51
  * @param {String} indicatorText Text to display above the line indicator.
45
52
  */
46
53
 
47
- function Line(peaks, id, position, indicatorType, indicatorText) {
54
+ function Line(peaks, id, position, indicatorType, indicatorText, locked) {
48
55
  var opts = {
49
56
  position: position,
50
57
  indicatorType: indicatorType,
51
- indicatorText: indicatorText
58
+ indicatorText: indicatorText,
59
+ locked: locked
52
60
  };
53
61
 
54
62
  validateLine(opts, 'add()');
@@ -58,6 +66,7 @@ define([
58
66
  this._position = opts.position;
59
67
  this._indicatorType = opts.indicatorType;
60
68
  this._indicatorText = opts.indicatorText;
69
+ this._locked = opts.locked;
61
70
  }
62
71
 
63
72
  Object.defineProperties(Line.prototype, {
@@ -74,9 +83,6 @@ define([
74
83
  },
75
84
 
76
85
  set: function(pos) {
77
- if (!Utils.isInteger(pos) || pos < 0) {
78
- throw new TypeError('peaks.lines.setPosition(): position must be a non-negative integer');
79
- }
80
86
  this._position = pos;
81
87
  }
82
88
  },
@@ -91,6 +97,12 @@ define([
91
97
  get: function() {
92
98
  return this._indicatorText;
93
99
  }
100
+ },
101
+ locked: {
102
+ enumerable: true,
103
+ get: function() {
104
+ return this._locked;
105
+ }
94
106
  }
95
107
  });
96
108
 
@@ -98,30 +110,18 @@ define([
98
110
  var opts = {
99
111
  position: this.position,
100
112
  indicatorType: this.indicatorType,
101
- indicatorText: this.indicatorText
113
+ indicatorText: this.indicatorText,
114
+ locked: this.locked
102
115
  };
103
116
 
104
117
  Utils.extend(opts, options);
105
118
 
106
- validateLine(this._peaks, opts, 'update()');
107
-
108
- this._startTime = opts.startTime;
109
- this._endTime = opts.endTime;
110
- this._duration = opts.duration;
111
- this._labelText = opts.labelText;
112
- this._color = opts.color;
113
- this._textColor = opts.textColor;
114
- this._handleTextColor = opts.handleTextColor;
115
- this._hoverColor = opts.hoverColor;
116
- this._warningColor = opts.warningColor;
117
- this._opacity = opts.opacity;
118
- this._borderColor = opts.borderColor;
119
- this._borderWidth = opts.borderWidth;
120
- this._borderRadius = opts.borderRadius;
121
- this._editable = opts.editable;
122
- this._allowDeletion = opts.allowDeletion;
123
- this._line = opts.line;
124
- this._indicators = opts.indicators;
119
+ validateLine(opts, 'update()');
120
+
121
+ this._position = opts.position;
122
+ this._indicatorType = opts.indicatorType;
123
+ this._indicatorText = opts.indicatorText;
124
+ this._locked = opts.locked;
125
125
 
126
126
  this._peaks.emit('model.line.update', this);
127
127
  };
@@ -121,16 +121,39 @@ define([
121
121
  );
122
122
  }
123
123
 
124
- if (!Utils.isValidColor(options.borderColor)) {
124
+ if (Utils.isNullOrUndefined(options.selectedBackgroundColor)) {
125
+ options.selectedBackgroundColor = options.backgroundColor;
126
+ }
127
+ else if (!Utils.isValidColor(options.selectedBackgroundColor)) {
128
+ throw new TypeError(
129
+ 'peaks.sources.' + context + ': selectedBackgroundColor should be a valid CSS color'
130
+ );
131
+ }
132
+
133
+ if (Utils.isNullOrUndefined(options.hoverBackgroundColor)) {
134
+ options.hoverBackgroundColor = Utils.shadeColor(options.backgroundColor, 30);
135
+ }
136
+ else if (!Utils.isValidColor(options.hoverBackgroundColor)) {
137
+ throw new TypeError(
138
+ 'peaks.sources.' + context + ': hoverBackgroundColor should be a valid CSS color'
139
+ );
140
+ }
141
+
142
+ if (Utils.isNullOrUndefined(options.borderColor)) {
125
143
  options.borderColor = options.color;
126
144
  }
145
+ else if (!Utils.isValidColor(options.borderColor)) {
146
+ throw new TypeError(
147
+ 'peaks.sources.' + context + ': borderColor should be a valid CSS color'
148
+ );
149
+ }
127
150
 
128
- if (Utils.isNullOrUndefined(options.selectedColor)) {
129
- options.selectedColor = null;
151
+ if (Utils.isNullOrUndefined(options.selectedBorderColor)) {
152
+ options.selectedBorderColor = Utils.shadeColor(options.borderColor, 30);
130
153
  }
131
- else if (!Utils.isValidColor(options.selectedColor)) {
154
+ else if (!Utils.isValidColor(options.selectedBorderColor)) {
132
155
  throw new TypeError(
133
- 'peaks.sources.' + context + ': selectedColor should be a valid CSS color'
156
+ 'peaks.sources.' + context + ': selectedBorderColor should be a valid CSS color'
134
157
  );
135
158
  }
136
159
 
@@ -374,7 +397,7 @@ define([
374
397
  * @param {String} color Primary color of the source representation.
375
398
  * @param {String} backgroundColor Background color of the source.
376
399
  * @param {String} borderColor Border color of the source.
377
- * @param {String} selectedColor Color when the source is selected.
400
+ * @param {String} selectedBorderColor Color when the source is selected.
378
401
  * @param {String} warningColor Color used for warning states.
379
402
  * @param {String} volumeSliderColor Color of the volume slider.
380
403
  * @param {Number} volumeSliderWidth Width of the volume slider.
@@ -407,9 +430,9 @@ define([
407
430
  */
408
431
 
409
432
  function Source(peaks, id, lineId, originId, elementId, title, titleAlignments, url, previewUrl, binaryUrl, kind,
410
- subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor,
411
- borderColor, selectedColor, warningColor, warningWidth, volumeSliderColor, volumeSliderWidth,
412
- volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition,
433
+ subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, hoverBackgroundColor,
434
+ selectedBackgroundColor, borderColor, selectedBorderColor, warningColor, warningWidth, volumeSliderColor,
435
+ volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition,
413
436
  textAutoScroll, borderWidth, borderRadius, wrapped, draggable, orderable, resizable,
414
437
  cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, buttons, markerColor,
415
438
  markerWidth, volume, volumeRange, loading, ...customParams) {
@@ -428,8 +451,10 @@ define([
428
451
  mediaEndTime: mediaEndTime,
429
452
  color: color,
430
453
  backgroundColor: backgroundColor,
454
+ hoverBackgroundColor: hoverBackgroundColor,
455
+ selectedBackgroundColor: selectedBackgroundColor,
431
456
  borderColor: borderColor,
432
- selectedColor: selectedColor,
457
+ selectedBorderColor: selectedBorderColor,
433
458
  warningColor: warningColor,
434
459
  warningWidth: warningWidth,
435
460
  textFont: textFont,
@@ -483,8 +508,10 @@ define([
483
508
  this._mediaEndTime = opts.mediaEndTime;
484
509
  this._color = opts.color;
485
510
  this._backgroundColor = opts.backgroundColor;
511
+ this._hoverBackgroundColor = opts.hoverBackgroundColor;
512
+ this._selectedBackgroundColor = opts.selectedBackgroundColor;
486
513
  this._borderColor = opts.borderColor;
487
- this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
514
+ this._selectedBorderColor = opts.selectedBorderColor;
488
515
  this._warningColor = opts.warningColor;
489
516
  this._warningWidth = opts.warningWidth;
490
517
  this._volumeSliderColor = opts.volumeSliderColor;
@@ -669,6 +696,26 @@ define([
669
696
  this._backgroundColor = backgroundColor;
670
697
  }
671
698
  },
699
+ hoverBackgroundColor: {
700
+ enumerable: true,
701
+ get: function() {
702
+ return this._hoverBackgroundColor;
703
+ },
704
+
705
+ set: function(hoverBackgroundColor) {
706
+ this._hoverBackgroundColor = hoverBackgroundColor;
707
+ }
708
+ },
709
+ selectedBackgroundColor: {
710
+ enumerable: true,
711
+ get: function() {
712
+ return this._selectedBackgroundColor;
713
+ },
714
+
715
+ set: function(selectedBackgroundColor) {
716
+ this._selectedBackgroundColor = selectedBackgroundColor;
717
+ }
718
+ },
672
719
  borderColor: {
673
720
  enumerable: true,
674
721
  get: function() {
@@ -679,14 +726,14 @@ define([
679
726
  this._borderColor = borderColor;
680
727
  }
681
728
  },
682
- selectedColor: {
729
+ selectedBorderColor: {
683
730
  enumerable: true,
684
731
  get: function() {
685
- return this._selectedColor;
732
+ return this._selectedBorderColor;
686
733
  },
687
734
 
688
- set: function(selectedColor) {
689
- this._selectedColor = selectedColor;
735
+ set: function(selectedBorderColor) {
736
+ this._selectedBorderColor = selectedBorderColor;
690
737
  }
691
738
  },
692
739
  warningColor: {
@@ -1084,8 +1131,10 @@ define([
1084
1131
  mediaEndTime: this.mediaEndTime,
1085
1132
  color: this.color,
1086
1133
  backgroundColor: this.backgroundColor,
1134
+ hoverBackgroundColor: this.hoverBackgroundColor,
1135
+ selectedBackgroundColor: this.selectedBackgroundColor,
1087
1136
  borderColor: this.borderColor,
1088
- selectedColor: this.selectedColor,
1137
+ selectedBorderColor: this.selectedBorderColor,
1089
1138
  warningColor: this.warningColor,
1090
1139
  warningWidth: this.warningWidth,
1091
1140
  volumeSliderColor: this.volumeSliderColor,
@@ -1137,7 +1186,7 @@ define([
1137
1186
  this._color = opts.color;
1138
1187
  this._backgroundColor = opts.backgroundColor;
1139
1188
  this._borderColor = opts.borderColor;
1140
- this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
1189
+ this._selectedBorderColor = opts.selectedBorderColor;
1141
1190
  this._warningColor = opts.warningColor;
1142
1191
  this._warningWidth = opts.warningWidth;
1143
1192
  this._volumeSliderColor = opts.volumeSliderColor;
@@ -176,8 +176,16 @@ define([
176
176
  * Add segments to the given line so they can be displayed.
177
177
  */
178
178
 
179
- SegmentHandler.prototype.addSegmentsToPosition = function(lineId, lineOptions) {
180
- this._peaks.emit('handler.segments.show', lineId, lineOptions);
179
+ SegmentHandler.prototype.addSegmentsToLine = function(segmentsGroupId, lineId) {
180
+ if (
181
+ !Utils.isString(lineId) ||
182
+ Utils.isNullOrUndefined(this._peaks.lineHandler.getLine(lineId))
183
+ ) {
184
+ throw new Error('peaks.segmentHandler.addSegmentsToLine(): line with id ' + lineId +
185
+ ' does not exist');
186
+ }
187
+
188
+ this._peaks.emit('handler.segments.show', segmentsGroupId, lineId);
181
189
  };
182
190
 
183
191
  /**
@@ -78,8 +78,10 @@ define([
78
78
  mediaEndTime: originalMediaEndTime,
79
79
  color: sourceToCut.color,
80
80
  backgroundColor: sourceToCut.backgroundColor,
81
+ hoverBackgroundColor: sourceToCut.hoverBackgroundColor,
82
+ selectedBackgroundColor: sourceToCut.selectedBackgroundColor,
81
83
  borderColor: sourceToCut.borderColor,
82
- selectedColor: sourceToCut.selectedColor,
84
+ selectedBorderColor: sourceToCut.selectedBorderColor,
83
85
  warningColor: sourceToCut.warningColor,
84
86
  warningWidth: sourceToCut.warningWidth,
85
87
  volumeSliderColor: sourceToCut.volumeSliderColor,
@@ -143,8 +145,10 @@ define([
143
145
  SourceHandler.prototype._addSource = function(source) {
144
146
  this._sources.push(source);
145
147
  this._sourcesById[source.id] = source;
146
- this._sourcesByLineId[source.lineId] = this._sourcesByLineId[source.lineId] || [];
147
- this._sourcesByLineId[source.lineId].push(source);
148
+ if (Utils.isNullOrUndefined(this._sourcesByLineId[source.lineId])) {
149
+ this._sourcesByLineId[source.lineId] = {};
150
+ }
151
+ this._sourcesByLineId[source.lineId][source.id] = source;
148
152
  };
149
153
 
150
154
  /**
@@ -190,8 +194,10 @@ define([
190
194
  options.mediaEndTime,
191
195
  options.color,
192
196
  options.backgroundColor,
197
+ options.hoverBackgroundColor,
198
+ options.selectedBackgroundColor,
193
199
  options.borderColor,
194
- options.selectedColor,
200
+ options.selectedBorderColor,
195
201
  options.warningColor,
196
202
  options.warningWidth,
197
203
  options.volumeSliderColor,
@@ -238,6 +244,10 @@ define([
238
244
  return this._sources;
239
245
  };
240
246
 
247
+ SourceHandler.prototype.getSourcesByLineId = function(lineId) {
248
+ return Utils.isNullOrUndefined(lineId) ? this._sourcesByLineId : this._sourcesByLineId[lineId];
249
+ };
250
+
241
251
  /**
242
252
  * Returns all sources, serialized to a plain object.
243
253
  *
@@ -380,6 +390,7 @@ define([
380
390
  var itemDestroyed = this._sources.splice(index, 1)[0];
381
391
 
382
392
  delete this._sourcesById[itemDestroyed.id];
393
+ delete this._sourcesByLineId[itemDestroyed.lineId][itemDestroyed.id];
383
394
 
384
395
  destroyed.push(itemDestroyed);
385
396
  }