@checksub_team/peaks_timeline 1.4.24 → 1.4.27
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 +1 -1
- package/peaks.js +126 -20
- package/src/line.js +38 -1
- package/src/lines.js +10 -0
- package/src/main.js +18 -1
- package/src/mode-layer.js +25 -16
- package/src/source.js +20 -3
- package/src/sources-layer.js +35 -0
- package/src/timeline-sources.js +4 -2
- package/src/timeline-zoomview.js +12 -0
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -14754,6 +14754,35 @@ module.exports = function (Konva, Utils) {
|
|
|
14754
14754
|
Line.prototype.lineHeight = function () {
|
|
14755
14755
|
return this._height;
|
|
14756
14756
|
};
|
|
14757
|
+
Line.prototype.changeHeight = function (from, to) {
|
|
14758
|
+
if (this._sourceHeights[from]) {
|
|
14759
|
+
var oldHeight = this._height;
|
|
14760
|
+
if (this._sourceHeights[to]) {
|
|
14761
|
+
this._sourceHeights[to] += this._sourceHeights[from];
|
|
14762
|
+
} else {
|
|
14763
|
+
this._sourceHeights[to] = this._sourceHeights[from];
|
|
14764
|
+
}
|
|
14765
|
+
if (to > this._height) {
|
|
14766
|
+
this._height = to;
|
|
14767
|
+
} else if (from === this._height) {
|
|
14768
|
+
this._height = 0;
|
|
14769
|
+
for (var height in this._sourceHeights) {
|
|
14770
|
+
if (Utils.objectHasProperty(this._sourceHeights, height)) {
|
|
14771
|
+
var parsedHeight = parseInt(height, 10);
|
|
14772
|
+
if (parsedHeight !== from) {
|
|
14773
|
+
if (parsedHeight > this._height) {
|
|
14774
|
+
this._height = parsedHeight;
|
|
14775
|
+
}
|
|
14776
|
+
}
|
|
14777
|
+
}
|
|
14778
|
+
}
|
|
14779
|
+
}
|
|
14780
|
+
if (this._height !== oldHeight) {
|
|
14781
|
+
this._peaks.emit('line.heightChanged', this._position);
|
|
14782
|
+
}
|
|
14783
|
+
delete this._sourceHeights[from];
|
|
14784
|
+
}
|
|
14785
|
+
};
|
|
14757
14786
|
Line.prototype.updateLineHeight = function (sourceGroup, action) {
|
|
14758
14787
|
var oldHeight = this._height;
|
|
14759
14788
|
var sourceGroupHeight;
|
|
@@ -14782,7 +14811,7 @@ module.exports = function (Konva, Utils) {
|
|
|
14782
14811
|
for (var height in this._sourceHeights) {
|
|
14783
14812
|
if (Utils.objectHasProperty(this._sourceHeights, height)) {
|
|
14784
14813
|
var parsedHeight = parseInt(height, 10);
|
|
14785
|
-
if (
|
|
14814
|
+
if (parsedHeight > this._height) {
|
|
14786
14815
|
this._height = parsedHeight;
|
|
14787
14816
|
}
|
|
14788
14817
|
}
|
|
@@ -15148,6 +15177,15 @@ module.exports = function (Line, LineIndicator, Utils) {
|
|
|
15148
15177
|
var lineNewY = oldLine.getY();
|
|
15149
15178
|
this._updateLinesPosition(position, lineNewY);
|
|
15150
15179
|
};
|
|
15180
|
+
Lines.prototype.changeLineHeight = function (from, to) {
|
|
15181
|
+
for (var position in this._linesByPosition) {
|
|
15182
|
+
if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
15183
|
+
if (!this._linesByPosition[position].isSegmentsLine()) {
|
|
15184
|
+
this._linesByPosition[position].changeHeight(from, to);
|
|
15185
|
+
}
|
|
15186
|
+
}
|
|
15187
|
+
}
|
|
15188
|
+
};
|
|
15151
15189
|
Lines.prototype.addSourceGroup = function (sourceGroup, position) {
|
|
15152
15190
|
if (!this._linesByPosition[position]) {
|
|
15153
15191
|
this._createLine(position);
|
|
@@ -15562,6 +15600,12 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15562
15600
|
Peaks.prototype.allowInteractions = function (forSources, forSegments) {
|
|
15563
15601
|
return this.view.allowInteractions(forSources, forSegments);
|
|
15564
15602
|
};
|
|
15603
|
+
Peaks.prototype.selectSourceById = function (sourceId) {
|
|
15604
|
+
return this.view.selectSourceById(sourceId);
|
|
15605
|
+
};
|
|
15606
|
+
Peaks.prototype.deselectSource = function () {
|
|
15607
|
+
return this.view.deselectSource();
|
|
15608
|
+
};
|
|
15565
15609
|
Peaks.prototype._addWindowResizeHandler = function () {
|
|
15566
15610
|
this._onResize = this._onResize.bind(this);
|
|
15567
15611
|
window.addEventListener('resize', this._onResize);
|
|
@@ -15572,6 +15616,11 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15572
15616
|
Peaks.prototype._removeWindowResizeHandler = function () {
|
|
15573
15617
|
window.removeEventListener('resize', this._onResize);
|
|
15574
15618
|
};
|
|
15619
|
+
Peaks.prototype.setLineHeight = function (newLineHeight) {
|
|
15620
|
+
var oldHeight = this.options.lineHeight;
|
|
15621
|
+
this.options.lineHeight = newLineHeight;
|
|
15622
|
+
this.emit('options.set.line_height', oldHeight);
|
|
15623
|
+
};
|
|
15575
15624
|
Peaks.prototype.destroy = function () {
|
|
15576
15625
|
this._removeWindowResizeHandler();
|
|
15577
15626
|
if (this.keyboardHandler) {
|
|
@@ -15644,6 +15693,25 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15644
15693
|
ModeLayer.prototype.addToStage = function (stage) {
|
|
15645
15694
|
stage.add(this._layer);
|
|
15646
15695
|
};
|
|
15696
|
+
ModeLayer.prototype.selectSourceGroup = function (sourceGroup, notify) {
|
|
15697
|
+
this.deselectSourceGroup();
|
|
15698
|
+
if (sourceGroup) {
|
|
15699
|
+
this._selectedElement = sourceGroup;
|
|
15700
|
+
this._selectedElement.setSelected(true);
|
|
15701
|
+
if (notify) {
|
|
15702
|
+
this._peaks.emit('source.selected', this._selectedElement.getSource());
|
|
15703
|
+
}
|
|
15704
|
+
}
|
|
15705
|
+
};
|
|
15706
|
+
ModeLayer.prototype.deselectSourceGroup = function (notify) {
|
|
15707
|
+
if (this._selectedElement) {
|
|
15708
|
+
this._selectedElement.setSelected(false);
|
|
15709
|
+
if (notify) {
|
|
15710
|
+
this._peaks.emit('source.deselected', this._selectedElement.getSource());
|
|
15711
|
+
}
|
|
15712
|
+
this._selectedElement = null;
|
|
15713
|
+
}
|
|
15714
|
+
};
|
|
15647
15715
|
ModeLayer.prototype._prepareDefaultMode = function () {
|
|
15648
15716
|
this._selectedElement = null;
|
|
15649
15717
|
};
|
|
@@ -15695,20 +15763,13 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15695
15763
|
ModeLayer.prototype._onMouseClickInDefaultMode = function () {
|
|
15696
15764
|
var hoveredElement = this._view.getHoveredElement();
|
|
15697
15765
|
if (hoveredElement) {
|
|
15698
|
-
|
|
15699
|
-
this._selectedElement.setSelected(false);
|
|
15700
|
-
}
|
|
15701
|
-
this._selectedElement = hoveredElement;
|
|
15702
|
-
this._selectedElement.setSelected(true);
|
|
15766
|
+
this.selectSourceGroup(hoveredElement, true);
|
|
15703
15767
|
} else {
|
|
15704
|
-
|
|
15705
|
-
this._selectedElement.setSelected(false);
|
|
15706
|
-
this._selectedElement = null;
|
|
15707
|
-
}
|
|
15768
|
+
this.deselectSourceGroup(true);
|
|
15708
15769
|
}
|
|
15709
15770
|
};
|
|
15710
15771
|
ModeLayer.prototype._onKeyboardDelete = function () {
|
|
15711
|
-
if (this._selectedElement
|
|
15772
|
+
if (this._selectedElement) {
|
|
15712
15773
|
this._peaks.destroySource(this._selectedElement.getSource().id);
|
|
15713
15774
|
}
|
|
15714
15775
|
};
|
|
@@ -15825,12 +15886,9 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15825
15886
|
case 'default':
|
|
15826
15887
|
this._stage.off('click', this._onMouseClickInDefaultMode);
|
|
15827
15888
|
this._peaks.off('keyboard.delete', this._onKeyboardDelete);
|
|
15828
|
-
if (this._selectedElement) {
|
|
15829
|
-
this._selectedElement.setSelected(false);
|
|
15830
|
-
}
|
|
15831
15889
|
break;
|
|
15832
15890
|
}
|
|
15833
|
-
this.
|
|
15891
|
+
this.deselectSourceGroup(true);
|
|
15834
15892
|
switch (mode) {
|
|
15835
15893
|
case 'cut':
|
|
15836
15894
|
this._stage.on('mouseover', this._onMouseEnterInCutMode);
|
|
@@ -18077,8 +18135,11 @@ module.exports = function (Utils) {
|
|
|
18077
18135
|
} else if (options.wrapping === 'complete') {
|
|
18078
18136
|
options.wrapped = false;
|
|
18079
18137
|
}
|
|
18138
|
+
if (!Utils.isNullOrUndefined(options.tts) && !Utils.isBoolean(options.tts)) {
|
|
18139
|
+
throw new TypeError('peaks.sources.' + context + ': tts must be a boolean or undefined');
|
|
18140
|
+
}
|
|
18080
18141
|
}
|
|
18081
|
-
function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, borderColor, selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable, wrapping, previewHeight, binaryHeight) {
|
|
18142
|
+
function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, borderColor, selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable, wrapping, previewHeight, binaryHeight, tts) {
|
|
18082
18143
|
var opts = {
|
|
18083
18144
|
title: title,
|
|
18084
18145
|
url: url,
|
|
@@ -18101,7 +18162,8 @@ module.exports = function (Utils) {
|
|
|
18101
18162
|
resizable: resizable,
|
|
18102
18163
|
wrapping: wrapping,
|
|
18103
18164
|
previewHeight: previewHeight,
|
|
18104
|
-
binaryHeight: binaryHeight
|
|
18165
|
+
binaryHeight: binaryHeight,
|
|
18166
|
+
tts: tts
|
|
18105
18167
|
};
|
|
18106
18168
|
validateSource(peaks, opts, 'add()');
|
|
18107
18169
|
this._peaks = peaks;
|
|
@@ -18131,6 +18193,7 @@ module.exports = function (Utils) {
|
|
|
18131
18193
|
this._previewHeight = opts.previewHeight;
|
|
18132
18194
|
this._binaryHeight = opts.binaryHeight;
|
|
18133
18195
|
this._minSize = peaks.options.minSourceSize;
|
|
18196
|
+
this._tts = opts.tts;
|
|
18134
18197
|
}
|
|
18135
18198
|
Object.defineProperties(Source.prototype, {
|
|
18136
18199
|
id: {
|
|
@@ -18336,6 +18399,14 @@ module.exports = function (Utils) {
|
|
|
18336
18399
|
get: function () {
|
|
18337
18400
|
return this._minSize;
|
|
18338
18401
|
}
|
|
18402
|
+
},
|
|
18403
|
+
tts: {
|
|
18404
|
+
get: function () {
|
|
18405
|
+
return this._tts;
|
|
18406
|
+
},
|
|
18407
|
+
set: function (tts) {
|
|
18408
|
+
this._tts = tts;
|
|
18409
|
+
}
|
|
18339
18410
|
}
|
|
18340
18411
|
});
|
|
18341
18412
|
Source.prototype.updateTimes = function (newStartTime, newEndTime) {
|
|
@@ -18445,7 +18516,8 @@ module.exports = function (Utils) {
|
|
|
18445
18516
|
resizable: this.resizable,
|
|
18446
18517
|
wrapping: this.wrapping,
|
|
18447
18518
|
previewHeight: this.previewHeight,
|
|
18448
|
-
binaryHeight: this.binaryHeight
|
|
18519
|
+
binaryHeight: this.binaryHeight,
|
|
18520
|
+
tts: this.tts
|
|
18449
18521
|
};
|
|
18450
18522
|
Utils.extend(opts, options);
|
|
18451
18523
|
validateSource(this._peaks, opts, 'update()');
|
|
@@ -18471,6 +18543,7 @@ module.exports = function (Utils) {
|
|
|
18471
18543
|
this._wrapping = opts.wrapping;
|
|
18472
18544
|
this._previewHeight = opts.previewHeight;
|
|
18473
18545
|
this._binaryHeight = opts.binaryHeight;
|
|
18546
|
+
this._tts = opts.tts;
|
|
18474
18547
|
this._peaks.emit('source.update', this);
|
|
18475
18548
|
};
|
|
18476
18549
|
Source.prototype.isVisible = function (startTime, endTime) {
|
|
@@ -18501,6 +18574,7 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18501
18574
|
this._peaks.on('data.retrieved', this._onDataRetrieved.bind(this));
|
|
18502
18575
|
this._peaks.on('sources.refresh', this._onSourcesRefresh.bind(this));
|
|
18503
18576
|
this._peaks.on('segments.show', this._onSegmentsShow.bind(this));
|
|
18577
|
+
this._peaks.on('options.set.line_height', this._onOptionsLineHeightChange.bind(this));
|
|
18504
18578
|
}
|
|
18505
18579
|
SourcesLayer.prototype.getLoadedData = function (id) {
|
|
18506
18580
|
return this._loadedData[id];
|
|
@@ -18523,6 +18597,25 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18523
18597
|
SourcesLayer.prototype.isEditingEnabled = function () {
|
|
18524
18598
|
return this._allowEditing;
|
|
18525
18599
|
};
|
|
18600
|
+
SourcesLayer.prototype._onOptionsLineHeightChange = function (oldHeight) {
|
|
18601
|
+
var positions = [];
|
|
18602
|
+
for (var sourceId in this._sourcesGroup) {
|
|
18603
|
+
if (Utils.objectHasProperty(this._sourcesGroup, sourceId)) {
|
|
18604
|
+
var source = this._sourcesGroup[sourceId].getSource();
|
|
18605
|
+
if (!positions.includes(source.position)) {
|
|
18606
|
+
this._lines.changeLineHeight(oldHeight, this._peaks.options.lineHeight);
|
|
18607
|
+
positions.push(source.position);
|
|
18608
|
+
}
|
|
18609
|
+
this._removeSource(source);
|
|
18610
|
+
this._addSourceGroup(source);
|
|
18611
|
+
}
|
|
18612
|
+
}
|
|
18613
|
+
if (positions) {
|
|
18614
|
+
var frameOffset = this._view.getFrameOffset();
|
|
18615
|
+
var width = this._view.getWidth();
|
|
18616
|
+
this.updateSources(this._view.pixelsToTime(frameOffset), this._view.pixelsToTime(frameOffset + width));
|
|
18617
|
+
}
|
|
18618
|
+
};
|
|
18526
18619
|
SourcesLayer.prototype._onSourceUpdate = function (source) {
|
|
18527
18620
|
var redraw = false;
|
|
18528
18621
|
var sourceGroup = this._sourcesGroup[source.id];
|
|
@@ -18749,6 +18842,9 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18749
18842
|
SourcesLayer.prototype.stopDrag = function () {
|
|
18750
18843
|
this._layer.stopDrag();
|
|
18751
18844
|
};
|
|
18845
|
+
SourcesLayer.prototype.getSourceGroupById = function (sourceId) {
|
|
18846
|
+
return this._sourcesGroup[sourceId];
|
|
18847
|
+
};
|
|
18752
18848
|
SourcesLayer.prototype._sourcesOverlapped = function (source1, source2) {
|
|
18753
18849
|
var endsLater = source1.startTime < source2.startTime && source1.endTime > source2.startTime;
|
|
18754
18850
|
var startsEarlier = source1.startTime > source2.startTime && source1.startTime < source2.endTime;
|
|
@@ -19135,7 +19231,8 @@ module.exports = function (Source, Utils) {
|
|
|
19135
19231
|
resizable: sourceToCut.resizable,
|
|
19136
19232
|
wrapping: sourceToCut.wrapping,
|
|
19137
19233
|
previewHeight: sourceToCut.previewHeight,
|
|
19138
|
-
binaryHeight: sourceToCut.binaryHeight
|
|
19234
|
+
binaryHeight: sourceToCut.binaryHeight,
|
|
19235
|
+
tts: sourceToCut.tts
|
|
19139
19236
|
}]);
|
|
19140
19237
|
this._peaks.emit('sources.updated');
|
|
19141
19238
|
};
|
|
@@ -19150,7 +19247,7 @@ module.exports = function (Source, Utils) {
|
|
|
19150
19247
|
if (!Utils.isObject(options)) {
|
|
19151
19248
|
throw new TypeError('peaks.sources.add(): expected a Source object parameter');
|
|
19152
19249
|
}
|
|
19153
|
-
var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.url, options.previewUrl, options.binaryUrl, options.kind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.borderColor, options.selectedColor, options.textColor, options.borderWidth, options.wrapped, options.position, options.draggable, options.resizable, options.wrapping, options.previewHeight, options.binaryHeight);
|
|
19250
|
+
var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.url, options.previewUrl, options.binaryUrl, options.kind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.borderColor, options.selectedColor, options.textColor, options.borderWidth, options.wrapped, options.position, options.draggable, options.resizable, options.wrapping, options.previewHeight, options.binaryHeight, options.tts);
|
|
19154
19251
|
return source;
|
|
19155
19252
|
};
|
|
19156
19253
|
TimelineSources.prototype.getSources = function () {
|
|
@@ -19476,6 +19573,15 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
19476
19573
|
this._sourcesLayer.stopDrag();
|
|
19477
19574
|
this._sourcesLayer.draw();
|
|
19478
19575
|
};
|
|
19576
|
+
TimelineZoomView.prototype.selectSourceById = function (sourceId) {
|
|
19577
|
+
var sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
|
|
19578
|
+
if (sourceGroup) {
|
|
19579
|
+
this._modeLayer.selectSourceGroup(sourceGroup, false);
|
|
19580
|
+
}
|
|
19581
|
+
};
|
|
19582
|
+
TimelineZoomView.prototype.deselectSource = function () {
|
|
19583
|
+
this._modeLayer.deselectSourceGroup(false);
|
|
19584
|
+
};
|
|
19479
19585
|
TimelineZoomView.prototype.isListening = function () {
|
|
19480
19586
|
return this._stage.listening();
|
|
19481
19587
|
};
|
package/src/line.js
CHANGED
|
@@ -91,6 +91,43 @@ define([
|
|
|
91
91
|
return this._height;
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
+
Line.prototype.changeHeight = function(from, to) {
|
|
95
|
+
if (this._sourceHeights[from]) {
|
|
96
|
+
var oldHeight = this._height;
|
|
97
|
+
|
|
98
|
+
if (this._sourceHeights[to]) {
|
|
99
|
+
this._sourceHeights[to] += this._sourceHeights[from];
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this._sourceHeights[to] = this._sourceHeights[from];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (to > this._height) {
|
|
106
|
+
this._height = to;
|
|
107
|
+
}
|
|
108
|
+
else if (from === this._height) {
|
|
109
|
+
this._height = 0;
|
|
110
|
+
for (var height in this._sourceHeights) {
|
|
111
|
+
if (Utils.objectHasProperty(this._sourceHeights, height)) {
|
|
112
|
+
var parsedHeight = parseInt(height, 10);
|
|
113
|
+
|
|
114
|
+
if (parsedHeight !== from) {
|
|
115
|
+
if (parsedHeight > this._height) {
|
|
116
|
+
this._height = parsedHeight;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (this._height !== oldHeight) {
|
|
124
|
+
this._peaks.emit('line.heightChanged', this._position);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
delete this._sourceHeights[from];
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
94
131
|
Line.prototype.updateLineHeight = function(sourceGroup, action) {
|
|
95
132
|
var oldHeight = this._height;
|
|
96
133
|
var sourceGroupHeight;
|
|
@@ -127,7 +164,7 @@ define([
|
|
|
127
164
|
if (Utils.objectHasProperty(this._sourceHeights, height)) {
|
|
128
165
|
var parsedHeight = parseInt(height, 10);
|
|
129
166
|
|
|
130
|
-
if (
|
|
167
|
+
if (parsedHeight > this._height) {
|
|
131
168
|
this._height = parsedHeight;
|
|
132
169
|
}
|
|
133
170
|
}
|
package/src/lines.js
CHANGED
|
@@ -57,6 +57,16 @@ define([
|
|
|
57
57
|
this._updateLinesPosition(position, lineNewY);
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
Lines.prototype.changeLineHeight = function(from, to) {
|
|
61
|
+
for (var position in this._linesByPosition) {
|
|
62
|
+
if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
63
|
+
if (!this._linesByPosition[position].isSegmentsLine()) {
|
|
64
|
+
this._linesByPosition[position].changeHeight(from, to);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
60
70
|
Lines.prototype.addSourceGroup = function(sourceGroup, position) {
|
|
61
71
|
if (!this._linesByPosition[position]) {
|
|
62
72
|
this._createLine(position);
|
package/src/main.js
CHANGED
|
@@ -233,7 +233,7 @@ define([
|
|
|
233
233
|
lineHeight: 80,
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
|
-
*
|
|
236
|
+
* Height of a segment, in pixels.
|
|
237
237
|
*/
|
|
238
238
|
segmentHeight: 32,
|
|
239
239
|
|
|
@@ -628,6 +628,16 @@ define([
|
|
|
628
628
|
.allowInteractions(forSources, forSegments);
|
|
629
629
|
};
|
|
630
630
|
|
|
631
|
+
Peaks.prototype.selectSourceById = function(sourceId) {
|
|
632
|
+
return this.view
|
|
633
|
+
.selectSourceById(sourceId);
|
|
634
|
+
};
|
|
635
|
+
|
|
636
|
+
Peaks.prototype.deselectSource = function() {
|
|
637
|
+
return this.view
|
|
638
|
+
.deselectSource();
|
|
639
|
+
};
|
|
640
|
+
|
|
631
641
|
Peaks.prototype._addWindowResizeHandler = function() {
|
|
632
642
|
this._onResize = this._onResize.bind(this);
|
|
633
643
|
window.addEventListener('resize', this._onResize);
|
|
@@ -641,6 +651,13 @@ define([
|
|
|
641
651
|
window.removeEventListener('resize', this._onResize);
|
|
642
652
|
};
|
|
643
653
|
|
|
654
|
+
Peaks.prototype.setLineHeight = function(newLineHeight) {
|
|
655
|
+
var oldHeight = this.options.lineHeight;
|
|
656
|
+
|
|
657
|
+
this.options.lineHeight = newLineHeight;
|
|
658
|
+
this.emit('options.set.line_height', oldHeight);
|
|
659
|
+
};
|
|
660
|
+
|
|
644
661
|
/**
|
|
645
662
|
* Cleans up a Peaks instance after use.
|
|
646
663
|
*/
|
package/src/mode-layer.js
CHANGED
|
@@ -61,6 +61,27 @@ 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;
|
|
68
|
+
this._selectedElement.setSelected(true);
|
|
69
|
+
if (notify) {
|
|
70
|
+
this._peaks.emit('source.selected', this._selectedElement.getSource());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
ModeLayer.prototype.deselectSourceGroup = function(notify) {
|
|
76
|
+
if (this._selectedElement) {
|
|
77
|
+
this._selectedElement.setSelected(false);
|
|
78
|
+
if (notify) {
|
|
79
|
+
this._peaks.emit('source.deselected', this._selectedElement.getSource());
|
|
80
|
+
}
|
|
81
|
+
this._selectedElement = null;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
64
85
|
ModeLayer.prototype._prepareDefaultMode = function() {
|
|
65
86
|
this._selectedElement = null;
|
|
66
87
|
};
|
|
@@ -119,24 +140,15 @@ define([
|
|
|
119
140
|
var hoveredElement = this._view.getHoveredElement();
|
|
120
141
|
|
|
121
142
|
if (hoveredElement) {
|
|
122
|
-
|
|
123
|
-
this._selectedElement.setSelected(false);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
this._selectedElement = hoveredElement;
|
|
127
|
-
|
|
128
|
-
this._selectedElement.setSelected(true);
|
|
143
|
+
this.selectSourceGroup(hoveredElement, true);
|
|
129
144
|
}
|
|
130
145
|
else {
|
|
131
|
-
|
|
132
|
-
this._selectedElement.setSelected(false);
|
|
133
|
-
this._selectedElement = null;
|
|
134
|
-
}
|
|
146
|
+
this.deselectSourceGroup(true);
|
|
135
147
|
}
|
|
136
148
|
};
|
|
137
149
|
|
|
138
150
|
ModeLayer.prototype._onKeyboardDelete = function() {
|
|
139
|
-
if (this._selectedElement
|
|
151
|
+
if (this._selectedElement) {
|
|
140
152
|
this._peaks.destroySource(this._selectedElement.getSource().id);
|
|
141
153
|
}
|
|
142
154
|
};
|
|
@@ -303,13 +315,10 @@ define([
|
|
|
303
315
|
case 'default':
|
|
304
316
|
this._stage.off('click', this._onMouseClickInDefaultMode);
|
|
305
317
|
this._peaks.off('keyboard.delete', this._onKeyboardDelete);
|
|
306
|
-
if (this._selectedElement) {
|
|
307
|
-
this._selectedElement.setSelected(false);
|
|
308
|
-
}
|
|
309
318
|
break;
|
|
310
319
|
}
|
|
311
320
|
|
|
312
|
-
this.
|
|
321
|
+
this.deselectSourceGroup(true);
|
|
313
322
|
|
|
314
323
|
// Set new mode
|
|
315
324
|
switch (mode) {
|
package/src/source.js
CHANGED
|
@@ -197,6 +197,10 @@ define([
|
|
|
197
197
|
else if (options.wrapping === 'complete') {
|
|
198
198
|
options.wrapped = false;
|
|
199
199
|
}
|
|
200
|
+
|
|
201
|
+
if (!Utils.isNullOrUndefined(options.tts) && !Utils.isBoolean(options.tts)) {
|
|
202
|
+
throw new TypeError('peaks.sources.' + context + ': tts must be a boolean or undefined');
|
|
203
|
+
}
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
/**
|
|
@@ -222,7 +226,7 @@ define([
|
|
|
222
226
|
function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind,
|
|
223
227
|
duration, startTime, endTime, mediaStartTime, mediaEndTime, color, borderColor,
|
|
224
228
|
selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable, wrapping,
|
|
225
|
-
previewHeight, binaryHeight) {
|
|
229
|
+
previewHeight, binaryHeight, tts) {
|
|
226
230
|
var opts = {
|
|
227
231
|
title: title,
|
|
228
232
|
url: url,
|
|
@@ -245,7 +249,8 @@ define([
|
|
|
245
249
|
resizable: resizable,
|
|
246
250
|
wrapping: wrapping,
|
|
247
251
|
previewHeight: previewHeight,
|
|
248
|
-
binaryHeight: binaryHeight
|
|
252
|
+
binaryHeight: binaryHeight,
|
|
253
|
+
tts: tts
|
|
249
254
|
};
|
|
250
255
|
|
|
251
256
|
validateSource(peaks, opts, 'add()');
|
|
@@ -277,6 +282,7 @@ define([
|
|
|
277
282
|
this._previewHeight = opts.previewHeight;
|
|
278
283
|
this._binaryHeight = opts.binaryHeight;
|
|
279
284
|
this._minSize = peaks.options.minSourceSize;
|
|
285
|
+
this._tts = opts.tts;
|
|
280
286
|
}
|
|
281
287
|
|
|
282
288
|
Object.defineProperties(Source.prototype, {
|
|
@@ -497,6 +503,15 @@ define([
|
|
|
497
503
|
get: function() {
|
|
498
504
|
return this._minSize;
|
|
499
505
|
}
|
|
506
|
+
},
|
|
507
|
+
tts: {
|
|
508
|
+
get: function() {
|
|
509
|
+
return this._tts;
|
|
510
|
+
},
|
|
511
|
+
|
|
512
|
+
set: function(tts) {
|
|
513
|
+
this._tts = tts;
|
|
514
|
+
}
|
|
500
515
|
}
|
|
501
516
|
});
|
|
502
517
|
|
|
@@ -638,7 +653,8 @@ define([
|
|
|
638
653
|
resizable: this.resizable,
|
|
639
654
|
wrapping: this.wrapping,
|
|
640
655
|
previewHeight: this.previewHeight,
|
|
641
|
-
binaryHeight: this.binaryHeight
|
|
656
|
+
binaryHeight: this.binaryHeight,
|
|
657
|
+
tts: this.tts
|
|
642
658
|
};
|
|
643
659
|
|
|
644
660
|
Utils.extend(opts, options);
|
|
@@ -667,6 +683,7 @@ define([
|
|
|
667
683
|
this._wrapping = opts.wrapping;
|
|
668
684
|
this._previewHeight = opts.previewHeight;
|
|
669
685
|
this._binaryHeight = opts.binaryHeight;
|
|
686
|
+
this._tts = opts.tts;
|
|
670
687
|
|
|
671
688
|
this._peaks.emit('source.update', this);
|
|
672
689
|
};
|
package/src/sources-layer.js
CHANGED
|
@@ -61,6 +61,7 @@ define([
|
|
|
61
61
|
this._peaks.on('data.retrieved', this._onDataRetrieved.bind(this));
|
|
62
62
|
this._peaks.on('sources.refresh', this._onSourcesRefresh.bind(this));
|
|
63
63
|
this._peaks.on('segments.show', this._onSegmentsShow.bind(this));
|
|
64
|
+
this._peaks.on('options.set.line_height', this._onOptionsLineHeightChange.bind(this));
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
SourcesLayer.prototype.getLoadedData = function(id) {
|
|
@@ -97,6 +98,36 @@ define([
|
|
|
97
98
|
return this._allowEditing;
|
|
98
99
|
};
|
|
99
100
|
|
|
101
|
+
SourcesLayer.prototype._onOptionsLineHeightChange = function(oldHeight) {
|
|
102
|
+
var positions = [];
|
|
103
|
+
|
|
104
|
+
for (var sourceId in this._sourcesGroup) {
|
|
105
|
+
if (Utils.objectHasProperty(this._sourcesGroup, sourceId)) {
|
|
106
|
+
var source = this._sourcesGroup[sourceId].getSource();
|
|
107
|
+
|
|
108
|
+
if (!positions.includes(source.position)) {
|
|
109
|
+
this._lines.changeLineHeight(
|
|
110
|
+
oldHeight,
|
|
111
|
+
this._peaks.options.lineHeight
|
|
112
|
+
);
|
|
113
|
+
positions.push(source.position);
|
|
114
|
+
}
|
|
115
|
+
this._removeSource(source);
|
|
116
|
+
this._addSourceGroup(source);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (positions) {
|
|
121
|
+
var frameOffset = this._view.getFrameOffset();
|
|
122
|
+
var width = this._view.getWidth();
|
|
123
|
+
|
|
124
|
+
this.updateSources(
|
|
125
|
+
this._view.pixelsToTime(frameOffset),
|
|
126
|
+
this._view.pixelsToTime(frameOffset + width)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
100
131
|
SourcesLayer.prototype._onSourceUpdate = function(source) {
|
|
101
132
|
var redraw = false;
|
|
102
133
|
var sourceGroup = this._sourcesGroup[source.id];
|
|
@@ -471,6 +502,10 @@ define([
|
|
|
471
502
|
this._layer.stopDrag();
|
|
472
503
|
};
|
|
473
504
|
|
|
505
|
+
SourcesLayer.prototype.getSourceGroupById = function(sourceId) {
|
|
506
|
+
return this._sourcesGroup[sourceId];
|
|
507
|
+
};
|
|
508
|
+
|
|
474
509
|
SourcesLayer.prototype._sourcesOverlapped = function(source1, source2) {
|
|
475
510
|
var endsLater = (source1.startTime < source2.startTime)
|
|
476
511
|
&& (source1.endTime > source2.startTime);
|
package/src/timeline-sources.js
CHANGED
|
@@ -87,7 +87,8 @@ define([
|
|
|
87
87
|
resizable: sourceToCut.resizable,
|
|
88
88
|
wrapping: sourceToCut.wrapping,
|
|
89
89
|
previewHeight: sourceToCut.previewHeight,
|
|
90
|
-
binaryHeight: sourceToCut.binaryHeight
|
|
90
|
+
binaryHeight: sourceToCut.binaryHeight,
|
|
91
|
+
tts: sourceToCut.tts
|
|
91
92
|
}]);
|
|
92
93
|
|
|
93
94
|
this._peaks.emit('sources.updated');
|
|
@@ -159,7 +160,8 @@ define([
|
|
|
159
160
|
options.resizable,
|
|
160
161
|
options.wrapping,
|
|
161
162
|
options.previewHeight,
|
|
162
|
-
options.binaryHeight
|
|
163
|
+
options.binaryHeight,
|
|
164
|
+
options.tts
|
|
163
165
|
);
|
|
164
166
|
|
|
165
167
|
return source;
|
package/src/timeline-zoomview.js
CHANGED
|
@@ -361,6 +361,18 @@ define([
|
|
|
361
361
|
this._sourcesLayer.draw();
|
|
362
362
|
};
|
|
363
363
|
|
|
364
|
+
TimelineZoomView.prototype.selectSourceById = function(sourceId) {
|
|
365
|
+
var sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
|
|
366
|
+
|
|
367
|
+
if (sourceGroup) {
|
|
368
|
+
this._modeLayer.selectSourceGroup(sourceGroup, false);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
TimelineZoomView.prototype.deselectSource = function() {
|
|
373
|
+
this._modeLayer.deselectSourceGroup(false);
|
|
374
|
+
};
|
|
375
|
+
|
|
364
376
|
TimelineZoomView.prototype.isListening = function() {
|
|
365
377
|
return this._stage.listening();
|
|
366
378
|
};
|