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

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.
@@ -49,6 +49,10 @@ define([
49
49
  return this._line.id;
50
50
  };
51
51
 
52
+ LineGroup.prototype.isLocked = function() {
53
+ return this._line.locked;
54
+ };
55
+
52
56
  LineGroup.prototype.getLine = function() {
53
57
  return this._line;
54
58
  };
@@ -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 = [];
@@ -78,17 +79,8 @@ define([
78
79
  this._group.on('dragend', this._onDragEnd.bind(this));
79
80
 
80
81
  this._cursor = null;
81
- this._group.on('mouseenter', function() {
82
- self._view.setHoveredElement(self);
83
- if (!self._source.loading) {
84
- self._showButtons();
85
- }
86
- });
87
-
88
- this._group.on('mouseleave', function() {
89
- self._view.setHoveredElement(null);
90
- self._hideButtons();
91
- });
82
+ this._group.on('mouseenter', this._onHoverStart.bind(this));
83
+ this._group.on('mouseleave', this._onHoverEnd.bind(this));
92
84
 
93
85
  this._group.on('mouseover', function() {
94
86
  if (self._source.draggable) {
@@ -133,16 +125,60 @@ define([
133
125
  this.setLoadingState(this._source.loading);
134
126
  }
135
127
 
128
+ SourceGroup.prototype._onHoverStart = function() {
129
+ this._hovered = true;
130
+ this._view.setHoveredElement(this);
131
+ if (!this._source.loading) {
132
+ this._showButtons();
133
+ }
134
+ this._group.draw();
135
+ };
136
+
137
+ SourceGroup.prototype._onHoverEnd = function() {
138
+ this._hovered = false;
139
+ this._manualHover = false;
140
+ this._view.setHoveredElement(null);
141
+ this._hideButtons();
142
+ this._group.draw();
143
+ };
144
+
136
145
  SourceGroup.prototype._onDragStart = function(element) {
137
146
  this._isDragged = true;
147
+ this._peaks.on('handler.view.mouseup', this.stopDrag.bind(this));
138
148
  this._layer.onSourcesGroupDragStart(element);
139
149
  };
140
150
 
141
151
  SourceGroup.prototype._onDragEnd = function(element) {
142
152
  this._isDragged = false;
153
+ this._peaks.off('handler.view.mouseup', this.stopDrag.bind(this));
154
+ this._manageManualHoverStop();
143
155
  this._layer.onSourcesGroupDragEnd(element);
144
156
  };
145
157
 
158
+ SourceGroup.prototype._manageManualHoverStop = function() {
159
+ if (!this._manualHover) {
160
+ return;
161
+ }
162
+
163
+ var pointer = this._view.getPointerPosition();
164
+
165
+ if (pointer) {
166
+ var absPos = this._group.absolutePosition();
167
+ var inside = (
168
+ pointer.x >= absPos.x && pointer.x <= absPos.x + this._width &&
169
+ pointer.y >= absPos.y && pointer.y <= absPos.y + this._height
170
+ );
171
+
172
+ if (!inside) {
173
+ this.stopHover();
174
+ }
175
+ }
176
+ };
177
+
178
+ SourceGroup.prototype.isHovered = function() {
179
+ return this._hovered;
180
+ };
181
+
146
182
  SourceGroup.prototype.isActive = function() {
147
183
  return this._isDragged;
148
184
  };
@@ -419,13 +455,25 @@ define([
419
455
  ctx.closePath();
420
456
 
421
457
  if (fill) {
458
+ var backgroundColor;
459
+
460
+ if (this._selected) {
461
+ backgroundColor = this._source.selectedBackgroundColor;
462
+ }
463
+ else if (this._hovered) {
464
+ backgroundColor = this._source.hoverBackgroundColor;
465
+ }
466
+ else {
467
+ backgroundColor = this._source.backgroundColor;
468
+ }
469
+
422
470
  if (this._source.shouldShowWarning()) {
423
471
  var gradient = ctx.createLinearGradient(0, 0, this._width, 0);
424
472
 
425
473
  if (this._source.mediaEndTime < this._source.duration) {
426
474
  var rightStopPosition = Math.max(1 - (this._source.warningWidth / this._width), 0.5);
427
475
 
428
- gradient.addColorStop(rightStopPosition, this._source.backgroundColor);
476
+ gradient.addColorStop(rightStopPosition, backgroundColor);
429
477
  gradient.addColorStop(1, this._source.warningColor);
430
478
  }
431
479
 
@@ -433,14 +481,14 @@ define([
433
481
  var leftStopPosition = Math.min(this._source.warningWidth / this._width, 0.5);
434
482
 
435
483
  gradient.addColorStop(0, this._source.warningColor);
436
- gradient.addColorStop(leftStopPosition, this._source.backgroundColor);
484
+ gradient.addColorStop(leftStopPosition, backgroundColor);
437
485
  }
438
486
 
439
487
  ctx.fillStyle = gradient;
440
488
  ctx.fill();
441
489
  }
442
490
  else {
443
- ctx.fillStyle = this._source.backgroundColor;
491
+ ctx.fillStyle = backgroundColor;
444
492
  ctx.fill();
445
493
  }
446
494
  }
@@ -654,6 +702,15 @@ define([
654
702
  return this._source;
655
703
  };
656
704
 
705
+ SourceGroup.prototype.startHover = function() {
706
+ this._manualHover = true;
707
+ this._group.fire('mouseenter', { evt: new MouseEvent('mouseenter') }, true);
708
+ };
709
+
710
+ SourceGroup.prototype.stopHover = function() {
711
+ this._group.fire('mouseleave', { evt: new MouseEvent('mouseleave') }, true);
712
+ };
713
+
657
714
  SourceGroup.prototype.startDrag = function() {
658
715
  return this._group.startDrag();
659
716
  };
@@ -671,7 +728,7 @@ define([
671
728
  };
672
729
 
673
730
  SourceGroup.prototype.hideButKeepFocus = function() {
674
- this._group.moveTo(this._view.getTempLayer());
731
+ this._group.moveTo(this._view.getTempGroup());
675
732
  };
676
733
 
677
734
  SourceGroup.prototype.getParent = function() {
@@ -874,7 +931,7 @@ define([
874
931
  this._selected = this._source.selected;
875
932
  if (this._border) {
876
933
  if (this._selected) {
877
- this._border.fill(this._source.selectedColor);
934
+ this._border.fill(this._source.selectedBorderColor);
878
935
  this._borderWidth = this._peaks.options.sourceSelectedBorderWidth;
879
936
  }
880
937
  else {
@@ -891,7 +948,7 @@ define([
891
948
 
892
949
  if (unwrap_background) {
893
950
  if (this._selected) {
894
- unwrap_background.stroke(this._source.selectedColor);
951
+ unwrap_background.stroke(this._source.selectedBorderColor);
895
952
  unwrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
896
953
  }
897
954
  else {
@@ -908,7 +965,7 @@ define([
908
965
 
909
966
  if (wrap_background) {
910
967
  if (this._selected) {
911
- wrap_background.stroke(this._source.selectedColor);
968
+ wrap_background.stroke(this._source.selectedBorderColor);
912
969
  wrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
913
970
  }
914
971
  else {
@@ -1572,6 +1629,7 @@ define([
1572
1629
 
1573
1630
  volumeSliderGroup.on('dragstart', function() {
1574
1631
  volumeText.visible(true);
1632
+ self._peaks.emit('source.startVolumeChange', self._source);
1575
1633
  });
1576
1634
 
1577
1635
  volumeSliderGroup.on('dragmove', function() {
@@ -1587,6 +1645,7 @@ define([
1587
1645
 
1588
1646
  volumeSliderGroup.on('dragend', function() {
1589
1647
  volumeText.visible(false);
1648
+ self._peaks.emit('source.endVolumeChange', self._source);
1590
1649
  });
1591
1650
 
1592
1651
  volumeSliderGroup.on('mouseover', function() {
@@ -109,20 +109,31 @@ 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 isSourceGroupHovered = false;
119
+ var isSourceGroupActive = false;
118
120
 
119
121
  if (sourceGroup) {
122
+ isSourceGroupHovered = sourceGroup.isHovered();
123
+ isSourceGroupActive = sourceGroup.isActive();
120
124
  this._destroySourceGroup(source);
121
125
  redraw = true;
122
126
  }
123
127
 
124
- if (source.isVisible(frameStartTime, frameEndTime)) {
125
- this._addSourceGroup(source);
128
+ if (source.isVisible(frameStartTime, frameEndTime) || isSourceGroupActive) {
129
+ const newSourceGroup = this._addSourceGroup(source);
130
+
131
+ if (isSourceGroupHovered) {
132
+ newSourceGroup.startHover();
133
+ }
134
+ if (isSourceGroupActive) {
135
+ newSourceGroup.startDrag();
136
+ }
126
137
  redraw = true;
127
138
  }
128
139
 
@@ -220,8 +231,8 @@ define([
220
231
  }
221
232
  };
222
233
 
223
- SourcesLayer.prototype._onSegmentsShow = function(lineId, lineOptions) {
224
- this._lineGroups.addSegments(lineId, lineOptions);
234
+ SourcesLayer.prototype._onSegmentsShow = function(segmentsGroupId, lineId) {
235
+ this._lineGroups.addSegments(segmentsGroupId, lineId);
225
236
  this._view.updateTimelineLength();
226
237
  this._layer.draw();
227
238
  };
@@ -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
  /**