@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checksub_team/peaks_timeline",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.10",
4
4
  "description": "JavaScript UI component for displaying audio waveforms",
5
5
  "main": "./peaks.js",
6
6
  "types": "./peaks.js.d.ts",
package/peaks.js CHANGED
@@ -14827,6 +14827,9 @@ module.exports = function (SourceGroup, Utils, Konva) {
14827
14827
  LineGroup.prototype.getId = function () {
14828
14828
  return this._line.id;
14829
14829
  };
14830
+ LineGroup.prototype.isLocked = function () {
14831
+ return this._line.locked;
14832
+ };
14830
14833
  LineGroup.prototype.getLine = function () {
14831
14834
  return this._line;
14832
14835
  };
@@ -15397,12 +15400,11 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15397
15400
  }
15398
15401
  lineGroup.addSource(source, sourceGroup, sourcesAround);
15399
15402
  };
15400
- LineGroups.prototype.addSegments = function (lineId, lineOptions) {
15401
- this._peaks.addLine(lineOptions, true);
15402
- const lineGroup = this._lineGroupsByPosition[lineOptions.position];
15403
+ LineGroups.prototype.addSegments = function (segmentsGroupId, lineId) {
15404
+ const lineGroup = this._lineGroupsById[lineId];
15403
15405
  lineGroup.allowInteractions(this._areSegmentInteractionsAllowed);
15404
- lineGroup.addSegments(this._segmentsGroups[lineId]);
15405
- this._segmentsGroupToLine[lineId] = lineGroup;
15406
+ lineGroup.addSegments(this._segmentsGroups[segmentsGroupId]);
15407
+ this._segmentsGroupToLine[segmentsGroupId] = lineGroup;
15406
15408
  this._setInteractions(lineGroup.getId());
15407
15409
  this.refreshLineYs();
15408
15410
  };
@@ -15526,13 +15528,18 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15526
15528
  if (Utils.isNullOrUndefined(mouseX)) {
15527
15529
  return;
15528
15530
  }
15529
- const position = this._lineGroupsById[sources[0].lineId].getPosition();
15531
+ const currentLineGroup = this._lineGroupsById[sources[0].lineId];
15532
+ const position = currentLineGroup.getPosition();
15530
15533
  const linePos = this.getLinesUnderY(mouseY);
15534
+ if (currentLineGroup.isLocked()) {
15535
+ return;
15536
+ }
15531
15537
  if (linePos[0] !== linePos[1]) {
15532
15538
  this.manageAutomaticLineCreation(linePos[0] + 1, position, sources);
15533
15539
  } else {
15534
15540
  this.stopAutomaticLineCreation();
15535
- if (!Utils.isNullOrUndefined(mouseX) && linePos[0] !== position && !this._lineGroupsByPosition[linePos[0]].isSegmentsLine()) {
15541
+ const targetLineGroup = this._lineGroupsByPosition[linePos[0]];
15542
+ if (!Utils.isNullOrUndefined(mouseX) && linePos[0] !== position && !targetLineGroup.isLocked() && !targetLineGroup.isSegmentsLine()) {
15536
15543
  var mouseTime = this._view.pixelsToTime(mouseX + this._view.getFrameOffset());
15537
15544
  var sourceDuration = Utils.roundTime(endTime - startTime);
15538
15545
  this._moveSourcesToPositionIfPossible(sources, linePos[0], mouseTime, sourceDuration);
@@ -15606,15 +15613,16 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15606
15613
  for (var position in this._lineGroupsByPosition) {
15607
15614
  if (Utils.objectHasProperty(this._lineGroupsByPosition, position)) {
15608
15615
  if (this._lineGroupsByPosition[position].y() !== y) {
15609
- anyChange = true;
15610
15616
  this._lineGroupsByPosition[position].y(y);
15617
+ anyChange = true;
15611
15618
  }
15612
15619
  y += this._lineGroupsByPosition[position].lineHeight() + this._peaks.options.interline;
15613
15620
  }
15614
15621
  }
15615
- if (anyChange && this._lineIndicator.refreshIndicators()) {
15616
- this._lineIndicator.draw();
15622
+ if (anyChange) {
15623
+ this._view.updateTimeline();
15617
15624
  }
15625
+ this._lineIndicator.refreshIndicators();
15618
15626
  };
15619
15627
  LineGroups.prototype._setLinePosition = function (lineId, position) {
15620
15628
  const lineGroup = this._lineGroupsById[lineId];
@@ -15690,8 +15698,8 @@ module.exports = function (SegmentsGroup, LineGroup, LineIndicator, Utils) {
15690
15698
  }
15691
15699
  };
15692
15700
  LineGroups.prototype.allowInteractions = function (forSources, forSegments) {
15693
- this._areSourceInteractionsAllowed = typeof forSources !== 'undefined' ? forSources : this._areSourceInteractionsAllowed;
15694
- this._areSegmentInteractionsAllowed = typeof forSegments !== 'undefined' ? forSegments : this._areSegmentInteractionsAllowed;
15701
+ this._areSourceInteractionsAllowed = !Utils.isNullOrUndefined(forSources) ? forSources : this._areSourceInteractionsAllowed;
15702
+ this._areSegmentInteractionsAllowed = !Utils.isNullOrUndefined(forSegments) ? forSegments : this._areSegmentInteractionsAllowed;
15695
15703
  for (var id in this._lineGroupsById) {
15696
15704
  if (Utils.objectHasProperty(this._lineGroupsById, id)) {
15697
15705
  this._setInteractions(id);
@@ -15753,6 +15761,7 @@ module.exports = function (Konva, SVGs, Utils) {
15753
15761
  this._width,
15754
15762
  this._height
15755
15763
  ]);
15764
+ this.refreshIndicators();
15756
15765
  };
15757
15766
  LineIndicator.prototype._createIndicator = function (lineGroup, type, text) {
15758
15767
  const indicator = new Konva.Group();
@@ -15911,6 +15920,9 @@ module.exports = function (Konva, SVGs, Utils) {
15911
15920
  anyChange = this.refreshIndicator(lineId) || anyChange;
15912
15921
  }
15913
15922
  }
15923
+ if (anyChange) {
15924
+ this.draw();
15925
+ }
15914
15926
  return anyChange;
15915
15927
  };
15916
15928
  LineIndicator.prototype.draw = function () {
@@ -17633,6 +17645,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
17633
17645
  this._borderWidth = this._source.borderWidth || 0;
17634
17646
  this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
17635
17647
  this._selected = this._source.selected;
17648
+ this._hovered = false;
17636
17649
  this._isDragged = false;
17637
17650
  this._previewList = [];
17638
17651
  this._markersGroup = this._createMarkers();
@@ -17651,12 +17664,14 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
17651
17664
  this._group.on('dragend', this._onDragEnd.bind(this));
17652
17665
  this._cursor = null;
17653
17666
  this._group.on('mouseenter', function () {
17667
+ self._setHovered(true);
17654
17668
  self._view.setHoveredElement(self);
17655
17669
  if (!self._source.loading) {
17656
17670
  self._showButtons();
17657
17671
  }
17658
17672
  });
17659
17673
  this._group.on('mouseleave', function () {
17674
+ self._setHovered(false);
17660
17675
  self._view.setHoveredElement(null);
17661
17676
  self._hideButtons();
17662
17677
  });
@@ -17694,6 +17709,10 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
17694
17709
  this.createIndicators();
17695
17710
  this.setLoadingState(this._source.loading);
17696
17711
  }
17712
+ SourceGroup.prototype._setHovered = function (newValue) {
17713
+ this._hovered = newValue;
17714
+ this._group.draw();
17715
+ };
17697
17716
  SourceGroup.prototype._onDragStart = function (element) {
17698
17717
  this._isDragged = true;
17699
17718
  this._layer.onSourcesGroupDragStart(element);
@@ -17895,22 +17914,30 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
17895
17914
  ctx.quadraticCurveTo(x + offset, offset, x + radius, offset);
17896
17915
  ctx.closePath();
17897
17916
  if (fill) {
17917
+ var backgroundColor;
17918
+ if (this._selected) {
17919
+ backgroundColor = this._source.selectedBackgroundColor;
17920
+ } else if (this._hovered) {
17921
+ backgroundColor = this._source.hoverBackgroundColor;
17922
+ } else {
17923
+ backgroundColor = this._source.backgroundColor;
17924
+ }
17898
17925
  if (this._source.shouldShowWarning()) {
17899
17926
  var gradient = ctx.createLinearGradient(0, 0, this._width, 0);
17900
17927
  if (this._source.mediaEndTime < this._source.duration) {
17901
17928
  var rightStopPosition = Math.max(1 - this._source.warningWidth / this._width, 0.5);
17902
- gradient.addColorStop(rightStopPosition, this._source.backgroundColor);
17929
+ gradient.addColorStop(rightStopPosition, backgroundColor);
17903
17930
  gradient.addColorStop(1, this._source.warningColor);
17904
17931
  }
17905
17932
  if (this._source.mediaStartTime > 0) {
17906
17933
  var leftStopPosition = Math.min(this._source.warningWidth / this._width, 0.5);
17907
17934
  gradient.addColorStop(0, this._source.warningColor);
17908
- gradient.addColorStop(leftStopPosition, this._source.backgroundColor);
17935
+ gradient.addColorStop(leftStopPosition, backgroundColor);
17909
17936
  }
17910
17937
  ctx.fillStyle = gradient;
17911
17938
  ctx.fill();
17912
17939
  } else {
17913
- ctx.fillStyle = this._source.backgroundColor;
17940
+ ctx.fillStyle = backgroundColor;
17914
17941
  ctx.fill();
17915
17942
  }
17916
17943
  }
@@ -18094,7 +18121,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18094
18121
  return group.isAncestorOf(this._group);
18095
18122
  };
18096
18123
  SourceGroup.prototype.hideButKeepFocus = function () {
18097
- this._group.moveTo(this._view.getTempLayer());
18124
+ this._group.moveTo(this._view.getTempGroup());
18098
18125
  };
18099
18126
  SourceGroup.prototype.getParent = function () {
18100
18127
  return this._group.getParent();
@@ -18249,7 +18276,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18249
18276
  this._selected = this._source.selected;
18250
18277
  if (this._border) {
18251
18278
  if (this._selected) {
18252
- this._border.fill(this._source.selectedColor);
18279
+ this._border.fill(this._source.selectedBorderColor);
18253
18280
  this._borderWidth = this._peaks.options.sourceSelectedBorderWidth;
18254
18281
  } else {
18255
18282
  this._border.fill(this._source.borderColor);
@@ -18262,7 +18289,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18262
18289
  })[0];
18263
18290
  if (unwrap_background) {
18264
18291
  if (this._selected) {
18265
- unwrap_background.stroke(this._source.selectedColor);
18292
+ unwrap_background.stroke(this._source.selectedBorderColor);
18266
18293
  unwrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
18267
18294
  } else {
18268
18295
  unwrap_background.strokeWidth(0);
@@ -18275,7 +18302,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18275
18302
  })[0];
18276
18303
  if (wrap_background) {
18277
18304
  if (this._selected) {
18278
- wrap_background.stroke(this._source.selectedColor);
18305
+ wrap_background.stroke(this._source.selectedBorderColor);
18279
18306
  wrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
18280
18307
  } else {
18281
18308
  wrap_background.strokeWidth(0);
@@ -18785,6 +18812,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18785
18812
  volumeSliderGroup.add(volumeSliderLine);
18786
18813
  volumeSliderGroup.on('dragstart', function () {
18787
18814
  volumeText.visible(true);
18815
+ self._peaks.emit('source.startVolumeChange', self._source);
18788
18816
  });
18789
18817
  volumeSliderGroup.on('dragmove', function () {
18790
18818
  var volume = self._getVolumeFromY(volumeSliderGroup.y());
@@ -18795,6 +18823,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Loader, Utils, Konva)
18795
18823
  });
18796
18824
  volumeSliderGroup.on('dragend', function () {
18797
18825
  volumeText.visible(false);
18826
+ self._peaks.emit('source.endVolumeChange', self._source);
18798
18827
  });
18799
18828
  volumeSliderGroup.on('mouseover', function () {
18800
18829
  self._cursor = 'ns-resize';
@@ -18883,18 +18912,23 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
18883
18912
  this.updateSources(this._view.pixelsToTime(frameOffset), this._view.pixelsToTime(frameOffset + width));
18884
18913
  };
18885
18914
  SourcesLayer.prototype._onSourceUpdate = function (source) {
18915
+ const sourceGroup = this._sourcesGroup[source.id];
18916
+ const frameOffset = this._view.getFrameOffset();
18917
+ const width = this._view.getWidth();
18918
+ const frameStartTime = this._view.pixelsToTime(frameOffset);
18919
+ const frameEndTime = this._view.pixelsToTime(frameOffset + width);
18886
18920
  var redraw = false;
18887
- var sourceGroup = this._sourcesGroup[source.id];
18888
- var frameOffset = this._view.getFrameOffset();
18889
- var width = this._view.getWidth();
18890
- var frameStartTime = this._view.pixelsToTime(frameOffset);
18891
- var frameEndTime = this._view.pixelsToTime(frameOffset + width);
18921
+ var isSourceGroupActive = false;
18892
18922
  if (sourceGroup) {
18923
+ isSourceGroupActive = sourceGroup.isActive();
18893
18924
  this._destroySourceGroup(source);
18894
18925
  redraw = true;
18895
18926
  }
18896
- if (source.isVisible(frameStartTime, frameEndTime)) {
18897
- this._addSourceGroup(source);
18927
+ if (source.isVisible(frameStartTime, frameEndTime) || isSourceGroupActive) {
18928
+ const newSourceGroup = this._addSourceGroup(source);
18929
+ if (isSourceGroupActive) {
18930
+ newSourceGroup.startDrag();
18931
+ }
18898
18932
  redraw = true;
18899
18933
  }
18900
18934
  if (redraw) {
@@ -18968,8 +19002,8 @@ module.exports = function (SourceGroup, LineGroups, DataRetriever, Invoker, Util
18968
19002
  }
18969
19003
  }
18970
19004
  };
18971
- SourcesLayer.prototype._onSegmentsShow = function (lineId, lineOptions) {
18972
- this._lineGroups.addSegments(lineId, lineOptions);
19005
+ SourcesLayer.prototype._onSegmentsShow = function (segmentsGroupId, lineId) {
19006
+ this._lineGroups.addSegments(segmentsGroupId, lineId);
18973
19007
  this._view.updateTimelineLength();
18974
19008
  this._layer.draw();
18975
19009
  };
@@ -19666,7 +19700,7 @@ module.exports = function (Line, Utils) {
19666
19700
  if (!Utils.isObject(options)) {
19667
19701
  throw new TypeError('peaks.lines.add(): expected a Line object parameter');
19668
19702
  }
19669
- var line = new Line(this._peaks, Utils.isNullOrUndefined(options.id) ? Utils.createUuidv4() : options.id, options.position, options.indicatorType, options.indicatorText);
19703
+ var line = new Line(this._peaks, Utils.isNullOrUndefined(options.id) ? Utils.createUuidv4() : options.id, options.position, options.indicatorType, options.indicatorText, options.locked);
19670
19704
  return line;
19671
19705
  };
19672
19706
  LineHandler.prototype.getLines = function () {
@@ -19733,6 +19767,7 @@ module.exports = function (Colors, EventEmitter, SegmentHandler, SourceHandler,
19733
19767
  nudgeIncrement: 1,
19734
19768
  zoomWaveformColor: 'rgba(180, 180, 180, 1)',
19735
19769
  randomizeSegmentColor: true,
19770
+ blockUpdatingOnMouseClickWithCtrlKey: false,
19736
19771
  blockUpdatingOnMouseClickWithMetaKey: false,
19737
19772
  height: 200,
19738
19773
  segmentColor: Colors.orange,
@@ -19922,8 +19957,8 @@ module.exports = function (Colors, EventEmitter, SegmentHandler, SourceHandler,
19922
19957
  Peaks.prototype.moveLine = function (lineId, position) {
19923
19958
  this.lineHandler.moveById(lineId, position);
19924
19959
  };
19925
- Peaks.prototype.showSegments = function (lineId, lineOptions) {
19926
- this.segmentHandler.addSegmentsToPosition(lineId, lineOptions);
19960
+ Peaks.prototype.showSegments = function (segmentsGroupId, lineId) {
19961
+ this.segmentHandler.addSegmentsToLine(segmentsGroupId, lineId);
19927
19962
  };
19928
19963
  Peaks.prototype.destroySegment = function (segmentId) {
19929
19964
  this.segmentHandler.removeById(segmentId);
@@ -19934,14 +19969,6 @@ module.exports = function (Colors, EventEmitter, SegmentHandler, SourceHandler,
19934
19969
  Peaks.prototype.setCutMode = function () {
19935
19970
  this.emit('handler.view.cutmode');
19936
19971
  };
19937
- Peaks.prototype.setIndicatorType = function (linePosition, type) {
19938
- var lineId = this.view.getLineByPosition(linePosition).getId();
19939
- this.emit('lineIndicator.setType', lineId, type);
19940
- };
19941
- Peaks.prototype.setIndicatorText = function (linePosition, text) {
19942
- var lineId = this.view.getLineByPosition(linePosition).getId();
19943
- this.emit('lineIndicator.setText', lineId, text);
19944
- };
19945
19972
  Peaks.prototype.getVisibleSegments = function () {
19946
19973
  return this.view.getSegmentsGroup().getVisibleSegments();
19947
19974
  };
@@ -20022,12 +20049,18 @@ module.exports = function (Utils) {
20022
20049
  } else if (!Utils.isString(options.indicatorText)) {
20023
20050
  throw new TypeError('peaks.lines.' + context + ': indicatorText must be a string');
20024
20051
  }
20052
+ if (Utils.isNullOrUndefined(options.locked)) {
20053
+ options.locked = false;
20054
+ } else if (!Utils.isBoolean(options.locked)) {
20055
+ throw new TypeError('peaks.lines.' + context + ': locked must be a boolean');
20056
+ }
20025
20057
  }
20026
- function Line(peaks, id, position, indicatorType, indicatorText) {
20058
+ function Line(peaks, id, position, indicatorType, indicatorText, locked) {
20027
20059
  var opts = {
20028
20060
  position: position,
20029
20061
  indicatorType: indicatorType,
20030
- indicatorText: indicatorText
20062
+ indicatorText: indicatorText,
20063
+ locked: locked
20031
20064
  };
20032
20065
  validateLine(opts, 'add()');
20033
20066
  this._peaks = peaks;
@@ -20035,6 +20068,7 @@ module.exports = function (Utils) {
20035
20068
  this._position = opts.position;
20036
20069
  this._indicatorType = opts.indicatorType;
20037
20070
  this._indicatorText = opts.indicatorText;
20071
+ this._locked = opts.locked;
20038
20072
  }
20039
20073
  Object.defineProperties(Line.prototype, {
20040
20074
  id: {
@@ -20049,9 +20083,6 @@ module.exports = function (Utils) {
20049
20083
  return this._position;
20050
20084
  },
20051
20085
  set: function (pos) {
20052
- if (!Utils.isInteger(pos) || pos < 0) {
20053
- throw new TypeError('peaks.lines.setPosition(): position must be a non-negative integer');
20054
- }
20055
20086
  this._position = pos;
20056
20087
  }
20057
20088
  },
@@ -20066,33 +20097,27 @@ module.exports = function (Utils) {
20066
20097
  get: function () {
20067
20098
  return this._indicatorText;
20068
20099
  }
20100
+ },
20101
+ locked: {
20102
+ enumerable: true,
20103
+ get: function () {
20104
+ return this._locked;
20105
+ }
20069
20106
  }
20070
20107
  });
20071
20108
  Line.prototype.update = function (options) {
20072
20109
  var opts = {
20073
20110
  position: this.position,
20074
20111
  indicatorType: this.indicatorType,
20075
- indicatorText: this.indicatorText
20112
+ indicatorText: this.indicatorText,
20113
+ locked: this.locked
20076
20114
  };
20077
20115
  Utils.extend(opts, options);
20078
- validateLine(this._peaks, opts, 'update()');
20079
- this._startTime = opts.startTime;
20080
- this._endTime = opts.endTime;
20081
- this._duration = opts.duration;
20082
- this._labelText = opts.labelText;
20083
- this._color = opts.color;
20084
- this._textColor = opts.textColor;
20085
- this._handleTextColor = opts.handleTextColor;
20086
- this._hoverColor = opts.hoverColor;
20087
- this._warningColor = opts.warningColor;
20088
- this._opacity = opts.opacity;
20089
- this._borderColor = opts.borderColor;
20090
- this._borderWidth = opts.borderWidth;
20091
- this._borderRadius = opts.borderRadius;
20092
- this._editable = opts.editable;
20093
- this._allowDeletion = opts.allowDeletion;
20094
- this._line = opts.line;
20095
- this._indicators = opts.indicators;
20116
+ validateLine(opts, 'update()');
20117
+ this._position = opts.position;
20118
+ this._indicatorType = opts.indicatorType;
20119
+ this._indicatorText = opts.indicatorText;
20120
+ this._locked = opts.locked;
20096
20121
  this._peaks.emit('model.line.update', this);
20097
20122
  };
20098
20123
  Line.prototype.toSerializable = function () {
@@ -20507,13 +20532,25 @@ module.exports = function (Utils) {
20507
20532
  if (!Utils.isValidColor(options.backgroundColor)) {
20508
20533
  throw new TypeError('peaks.sources.' + context + ': backgroundColor should be a valid CSS color');
20509
20534
  }
20510
- if (!Utils.isValidColor(options.borderColor)) {
20535
+ if (Utils.isNullOrUndefined(options.selectedBackgroundColor)) {
20536
+ options.selectedBackgroundColor = options.backgroundColor;
20537
+ } else if (!Utils.isValidColor(options.selectedBackgroundColor)) {
20538
+ throw new TypeError('peaks.sources.' + context + ': selectedBackgroundColor should be a valid CSS color');
20539
+ }
20540
+ if (Utils.isNullOrUndefined(options.hoverBackgroundColor)) {
20541
+ options.hoverBackgroundColor = Utils.shadeColor(options.backgroundColor, 30);
20542
+ } else if (!Utils.isValidColor(options.hoverBackgroundColor)) {
20543
+ throw new TypeError('peaks.sources.' + context + ': hoverBackgroundColor should be a valid CSS color');
20544
+ }
20545
+ if (Utils.isNullOrUndefined(options.borderColor)) {
20511
20546
  options.borderColor = options.color;
20547
+ } else if (!Utils.isValidColor(options.borderColor)) {
20548
+ throw new TypeError('peaks.sources.' + context + ': borderColor should be a valid CSS color');
20512
20549
  }
20513
- if (Utils.isNullOrUndefined(options.selectedColor)) {
20514
- options.selectedColor = null;
20515
- } else if (!Utils.isValidColor(options.selectedColor)) {
20516
- throw new TypeError('peaks.sources.' + context + ': selectedColor should be a valid CSS color');
20550
+ if (Utils.isNullOrUndefined(options.selectedBorderColor)) {
20551
+ options.selectedBorderColor = Utils.shadeColor(options.borderColor, 30);
20552
+ } else if (!Utils.isValidColor(options.selectedBorderColor)) {
20553
+ throw new TypeError('peaks.sources.' + context + ': selectedBorderColor should be a valid CSS color');
20517
20554
  }
20518
20555
  if (Utils.isNullOrUndefined(options.warningColor)) {
20519
20556
  options.warningColor = null;
@@ -20662,7 +20699,7 @@ module.exports = function (Utils) {
20662
20699
  throw new TypeError('peaks.sources.' + context + ': loading must be a boolean');
20663
20700
  }
20664
20701
  }
20665
- function Source(peaks, id, lineId, originId, elementId, title, titleAlignments, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, warningColor, warningWidth, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition, textAutoScroll, borderWidth, borderRadius, wrapped, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, buttons, markerColor, markerWidth, volume, volumeRange, loading, ...customParams) {
20702
+ function Source(peaks, id, lineId, originId, elementId, title, titleAlignments, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, hoverBackgroundColor, selectedBackgroundColor, borderColor, selectedBorderColor, warningColor, warningWidth, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition, textAutoScroll, borderWidth, borderRadius, wrapped, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, buttons, markerColor, markerWidth, volume, volumeRange, loading, ...customParams) {
20666
20703
  var opts = {
20667
20704
  title: title,
20668
20705
  titleAlignments: titleAlignments,
@@ -20678,8 +20715,10 @@ module.exports = function (Utils) {
20678
20715
  mediaEndTime: mediaEndTime,
20679
20716
  color: color,
20680
20717
  backgroundColor: backgroundColor,
20718
+ hoverBackgroundColor: hoverBackgroundColor,
20719
+ selectedBackgroundColor: selectedBackgroundColor,
20681
20720
  borderColor: borderColor,
20682
- selectedColor: selectedColor,
20721
+ selectedBorderColor: selectedBorderColor,
20683
20722
  warningColor: warningColor,
20684
20723
  warningWidth: warningWidth,
20685
20724
  textFont: textFont,
@@ -20731,8 +20770,10 @@ module.exports = function (Utils) {
20731
20770
  this._mediaEndTime = opts.mediaEndTime;
20732
20771
  this._color = opts.color;
20733
20772
  this._backgroundColor = opts.backgroundColor;
20773
+ this._hoverBackgroundColor = opts.hoverBackgroundColor;
20774
+ this._selectedBackgroundColor = opts.selectedBackgroundColor;
20734
20775
  this._borderColor = opts.borderColor;
20735
- this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
20776
+ this._selectedBorderColor = opts.selectedBorderColor;
20736
20777
  this._warningColor = opts.warningColor;
20737
20778
  this._warningWidth = opts.warningWidth;
20738
20779
  this._volumeSliderColor = opts.volumeSliderColor;
@@ -20906,6 +20947,24 @@ module.exports = function (Utils) {
20906
20947
  this._backgroundColor = backgroundColor;
20907
20948
  }
20908
20949
  },
20950
+ hoverBackgroundColor: {
20951
+ enumerable: true,
20952
+ get: function () {
20953
+ return this._hoverBackgroundColor;
20954
+ },
20955
+ set: function (hoverBackgroundColor) {
20956
+ this._hoverBackgroundColor = hoverBackgroundColor;
20957
+ }
20958
+ },
20959
+ selectedBackgroundColor: {
20960
+ enumerable: true,
20961
+ get: function () {
20962
+ return this._selectedBackgroundColor;
20963
+ },
20964
+ set: function (selectedBackgroundColor) {
20965
+ this._selectedBackgroundColor = selectedBackgroundColor;
20966
+ }
20967
+ },
20909
20968
  borderColor: {
20910
20969
  enumerable: true,
20911
20970
  get: function () {
@@ -20915,13 +20974,13 @@ module.exports = function (Utils) {
20915
20974
  this._borderColor = borderColor;
20916
20975
  }
20917
20976
  },
20918
- selectedColor: {
20977
+ selectedBorderColor: {
20919
20978
  enumerable: true,
20920
20979
  get: function () {
20921
- return this._selectedColor;
20980
+ return this._selectedBorderColor;
20922
20981
  },
20923
- set: function (selectedColor) {
20924
- this._selectedColor = selectedColor;
20982
+ set: function (selectedBorderColor) {
20983
+ this._selectedBorderColor = selectedBorderColor;
20925
20984
  }
20926
20985
  },
20927
20986
  warningColor: {
@@ -21271,8 +21330,10 @@ module.exports = function (Utils) {
21271
21330
  mediaEndTime: this.mediaEndTime,
21272
21331
  color: this.color,
21273
21332
  backgroundColor: this.backgroundColor,
21333
+ hoverBackgroundColor: this.hoverBackgroundColor,
21334
+ selectedBackgroundColor: this.selectedBackgroundColor,
21274
21335
  borderColor: this.borderColor,
21275
- selectedColor: this.selectedColor,
21336
+ selectedBorderColor: this.selectedBorderColor,
21276
21337
  warningColor: this.warningColor,
21277
21338
  warningWidth: this.warningWidth,
21278
21339
  volumeSliderColor: this.volumeSliderColor,
@@ -21321,7 +21382,7 @@ module.exports = function (Utils) {
21321
21382
  this._color = opts.color;
21322
21383
  this._backgroundColor = opts.backgroundColor;
21323
21384
  this._borderColor = opts.borderColor;
21324
- this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
21385
+ this._selectedBorderColor = opts.selectedBorderColor;
21325
21386
  this._warningColor = opts.warningColor;
21326
21387
  this._warningWidth = opts.warningWidth;
21327
21388
  this._volumeSliderColor = opts.volumeSliderColor;
@@ -21490,8 +21551,11 @@ module.exports = function (Colors, Segment, Utils) {
21490
21551
  return segment.toSerializable();
21491
21552
  });
21492
21553
  };
21493
- SegmentHandler.prototype.addSegmentsToPosition = function (lineId, lineOptions) {
21494
- this._peaks.emit('handler.segments.show', lineId, lineOptions);
21554
+ SegmentHandler.prototype.addSegmentsToLine = function (segmentsGroupId, lineId) {
21555
+ if (!Utils.isString(lineId) || Utils.isNullOrUndefined(this._peaks.lineHandler.getLine(lineId))) {
21556
+ throw new Error('peaks.segmentHandler.addSegmentsToLine(): line with id ' + lineId + ' does not exist');
21557
+ }
21558
+ this._peaks.emit('handler.segments.show', segmentsGroupId, lineId);
21495
21559
  };
21496
21560
  SegmentHandler.prototype.getSegment = function (id) {
21497
21561
  return this._segmentsById[id] || null;
@@ -21631,8 +21695,10 @@ module.exports = function (Source, Utils) {
21631
21695
  mediaEndTime: originalMediaEndTime,
21632
21696
  color: sourceToCut.color,
21633
21697
  backgroundColor: sourceToCut.backgroundColor,
21698
+ hoverBackgroundColor: sourceToCut.hoverBackgroundColor,
21699
+ selectedBackgroundColor: sourceToCut.selectedBackgroundColor,
21634
21700
  borderColor: sourceToCut.borderColor,
21635
- selectedColor: sourceToCut.selectedColor,
21701
+ selectedBorderColor: sourceToCut.selectedBorderColor,
21636
21702
  warningColor: sourceToCut.warningColor,
21637
21703
  warningWidth: sourceToCut.warningWidth,
21638
21704
  volumeSliderColor: sourceToCut.volumeSliderColor,
@@ -21680,8 +21746,10 @@ module.exports = function (Source, Utils) {
21680
21746
  SourceHandler.prototype._addSource = function (source) {
21681
21747
  this._sources.push(source);
21682
21748
  this._sourcesById[source.id] = source;
21683
- this._sourcesByLineId[source.lineId] = this._sourcesByLineId[source.lineId] || [];
21684
- this._sourcesByLineId[source.lineId].push(source);
21749
+ if (Utils.isNullOrUndefined(this._sourcesByLineId[source.lineId])) {
21750
+ this._sourcesByLineId[source.lineId] = {};
21751
+ }
21752
+ this._sourcesByLineId[source.lineId][source.id] = source;
21685
21753
  };
21686
21754
  SourceHandler.prototype._createSource = function (options) {
21687
21755
  if (!Utils.isObject(options)) {
@@ -21693,12 +21761,15 @@ module.exports = function (Source, Utils) {
21693
21761
  customParams.push(key, value);
21694
21762
  }
21695
21763
  });
21696
- var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.lineId, options.originId, options.elementId, options.title, options.titleAlignments, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.borderColor, options.selectedColor, options.warningColor, options.warningWidth, options.volumeSliderColor, options.volumeSliderWidth, options.volumeSliderDraggingWidth, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.textAutoScroll, options.borderWidth, options.borderRadius, options.wrapped, options.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators, options.markers, options.buttons, options.markerColor, options.markerWidth, options.volume, options.volumeRange, options.loading, ...customParams);
21764
+ var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.lineId, options.originId, options.elementId, options.title, options.titleAlignments, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.hoverBackgroundColor, options.selectedBackgroundColor, options.borderColor, options.selectedBorderColor, options.warningColor, options.warningWidth, options.volumeSliderColor, options.volumeSliderWidth, options.volumeSliderDraggingWidth, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.textAutoScroll, options.borderWidth, options.borderRadius, options.wrapped, options.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators, options.markers, options.buttons, options.markerColor, options.markerWidth, options.volume, options.volumeRange, options.loading, ...customParams);
21697
21765
  return source;
21698
21766
  };
21699
21767
  SourceHandler.prototype.getSources = function () {
21700
21768
  return this._sources;
21701
21769
  };
21770
+ SourceHandler.prototype.getSourcesByLineId = function (lineId) {
21771
+ return Utils.isNullOrUndefined(lineId) ? this._sourcesByLineId : this._sourcesByLineId[lineId];
21772
+ };
21702
21773
  SourceHandler.prototype.getSourcesSerialized = function () {
21703
21774
  return this._sources.map(function (source) {
21704
21775
  return source.toSerializable();
@@ -21755,6 +21826,7 @@ module.exports = function (Source, Utils) {
21755
21826
  var index = indexes[i] - destroyed.length;
21756
21827
  var itemDestroyed = this._sources.splice(index, 1)[0];
21757
21828
  delete this._sourcesById[itemDestroyed.id];
21829
+ delete this._sourcesByLineId[itemDestroyed.lineId][itemDestroyed.id];
21758
21830
  destroyed.push(itemDestroyed);
21759
21831
  }
21760
21832
  return destroyed;
@@ -22023,7 +22095,6 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22023
22095
  self._timelineLength = 0;
22024
22096
  self._timeToPixelsScale = self._options.initialZoomLevel;
22025
22097
  self._timeToPixelsMinScale = self._options.minScale;
22026
- self._resizeTimeoutId = null;
22027
22098
  self._isFocused = false;
22028
22099
  self._isClickable = true;
22029
22100
  self._width = container.clientWidth;
@@ -22051,8 +22122,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22051
22122
  width: self._width - self._peaks.options.lineIndicatorWidth,
22052
22123
  height: self._height
22053
22124
  });
22054
- self._tempLayer = new Konva.Layer();
22055
- self._stage.add(self._tempLayer);
22125
+ self._tempGroup = new Konva.Group({ listening: false });
22056
22126
  self._width -= self._peaks.options.lineIndicatorWidth;
22057
22127
  self._axis = new Axis(self._peaks, self, {
22058
22128
  axisGridlineColor: this._options.axisGridlineColor,
@@ -22061,6 +22131,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22061
22131
  self._axis.addBackToStage(self._stage);
22062
22132
  self._sourcesLayer = new SourcesLayer(peaks, self, true);
22063
22133
  self._sourcesLayer.addToStage(self._stage);
22134
+ self._sourcesLayer.add(self._tempGroup);
22064
22135
  self._axis.addFrontToStage(self._stage);
22065
22136
  self._playheadLayer = new PlayheadLayer(peaks, self, self._sourcesLayer, self._options.showPlayheadTime);
22066
22137
  self._playheadLayer.addToStage(self._stage);
@@ -22169,8 +22240,8 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22169
22240
  View.prototype.setClickable = function (clickable) {
22170
22241
  this._isClickable = clickable;
22171
22242
  };
22172
- View.prototype.getTempLayer = function () {
22173
- return this._tempLayer;
22243
+ View.prototype.getTempGroup = function () {
22244
+ return this._tempGroup;
22174
22245
  };
22175
22246
  View.prototype.getSelectedElements = function () {
22176
22247
  return Object.values(this._modeLayer.getSelectedElements());
@@ -22540,10 +22611,6 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
22540
22611
  return this._sourcesLayer.getFullHeight();
22541
22612
  };
22542
22613
  View.prototype.destroy = function () {
22543
- if (this._resizeTimeoutId) {
22544
- clearTimeout(this._resizeTimeoutId);
22545
- this._resizeTimeoutId = null;
22546
- }
22547
22614
  this._peaks.off('player_time_update', this._onTimeUpdate);
22548
22615
  this._peaks.off('user_seek', this._onSeek);
22549
22616
  this._peaks.off('player_play', this._onPlay);
@@ -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
  };