@checksub_team/peaks_timeline 1.16.0-alpha.1 → 1.16.0
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 +340 -428
- package/src/line.js +199 -228
- package/src/lines.js +40 -163
- package/src/main.js +1 -7
- package/src/segments-group.js +0 -4
- package/src/source-group.js +27 -41
- package/src/source.js +64 -18
- package/src/sources-layer.js +93 -88
- package/src/timeline-sources.js +12 -10
- package/src/timeline-zoomview.js +0 -4
package/src/lines.js
CHANGED
|
@@ -22,15 +22,12 @@ define([
|
|
|
22
22
|
this._peaks = peaks;
|
|
23
23
|
this._view = view;
|
|
24
24
|
this._layer = layer;
|
|
25
|
+
this._linesBySourceId = {};
|
|
25
26
|
this._linesByPosition = {};
|
|
26
27
|
this._autoAddToLayer = false;
|
|
27
28
|
this._areSourceInteractionsAllowed = true;
|
|
28
29
|
this._areSegmentInteractionsAllowed = true;
|
|
29
30
|
|
|
30
|
-
this._automaticallyCreatedLineId = null;
|
|
31
|
-
this._automaticLineCreationPosition = null;
|
|
32
|
-
this._automaticLineCreationTimeout = null;
|
|
33
|
-
|
|
34
31
|
this._segmentsGroups = {};
|
|
35
32
|
this._segmentsGroupToLine = {};
|
|
36
33
|
|
|
@@ -46,9 +43,6 @@ define([
|
|
|
46
43
|
this._peaks.on('line.add', this._onLineAdd.bind(this));
|
|
47
44
|
this._peaks.on('line.remove', this._onLineRemove.bind(this));
|
|
48
45
|
|
|
49
|
-
this._peaks.on('sources.show', this._onSourcesWrappingChanged.bind(this));
|
|
50
|
-
this._peaks.on('sources.hide', this._onSourcesWrappingChanged.bind(this));
|
|
51
|
-
|
|
52
46
|
this._peaks.on('segment.updated', this._onSegmentsUpdate.bind(this));
|
|
53
47
|
this._peaks.on('segments.add', this._onSegmentsAdd.bind(this));
|
|
54
48
|
this._peaks.on('segments.remove', this._onSegmentsRemove.bind(this));
|
|
@@ -111,16 +105,10 @@ define([
|
|
|
111
105
|
};
|
|
112
106
|
|
|
113
107
|
Lines.prototype._onLineRemove = function(position) {
|
|
114
|
-
this.removeLine(position);
|
|
115
|
-
|
|
116
|
-
};
|
|
108
|
+
var oldLine = this.removeLine(position);
|
|
109
|
+
var lineNewY = oldLine.getY();
|
|
117
110
|
|
|
118
|
-
|
|
119
|
-
sources.forEach(function(source) {
|
|
120
|
-
if (this._linesByPosition[source.position]) {
|
|
121
|
-
this._linesByPosition[source.position].updateLineHeight(source, 'wrappingChanged');
|
|
122
|
-
}
|
|
123
|
-
}.bind(this));
|
|
111
|
+
this._updateLinesPosition(position, lineNewY);
|
|
124
112
|
};
|
|
125
113
|
|
|
126
114
|
Lines.prototype.changeLineHeight = function(from, to) {
|
|
@@ -133,14 +121,15 @@ define([
|
|
|
133
121
|
}
|
|
134
122
|
};
|
|
135
123
|
|
|
136
|
-
Lines.prototype.addSourceGroup = function(
|
|
124
|
+
Lines.prototype.addSourceGroup = function(sourceGroup, position) {
|
|
137
125
|
if (!this._linesByPosition[position] || this._linesByPosition[position].isSegmentsLine()) {
|
|
138
126
|
this._createLine(position);
|
|
139
127
|
this._setInteractions(position);
|
|
140
128
|
}
|
|
141
129
|
|
|
142
|
-
|
|
143
|
-
this._linesByPosition[position].addSourceGroup(
|
|
130
|
+
sourceGroup.getSource().position = position;
|
|
131
|
+
this._linesByPosition[position].addSourceGroup(sourceGroup);
|
|
132
|
+
this._linesBySourceId[sourceGroup.getSource().id] = this._linesByPosition[position];
|
|
144
133
|
};
|
|
145
134
|
|
|
146
135
|
Lines.prototype.addSegments = function(lineId, position) {
|
|
@@ -157,13 +146,10 @@ define([
|
|
|
157
146
|
};
|
|
158
147
|
|
|
159
148
|
Lines.prototype.removeSourceGroup = function(source, isPermanent) {
|
|
160
|
-
if (!this._linesByPosition[source.position]) {
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
149
|
var sourceGroup = this._linesByPosition[source.position].removeSourceGroup(source, isPermanent);
|
|
165
150
|
|
|
166
151
|
if (isPermanent) {
|
|
152
|
+
delete this._linesBySourceId[source.id];
|
|
167
153
|
this._updateLinesPosition(source.position);
|
|
168
154
|
}
|
|
169
155
|
|
|
@@ -172,22 +158,18 @@ define([
|
|
|
172
158
|
|
|
173
159
|
Lines.prototype.removeLine = function(pos) {
|
|
174
160
|
var oldLine = this._linesByPosition[pos];
|
|
175
|
-
var lineId = oldLine.getId();
|
|
176
161
|
|
|
177
|
-
if (this._automaticallyCreatedLineId === lineId) {
|
|
178
|
-
this._automaticallyCreatedLineId = null;
|
|
179
|
-
}
|
|
180
162
|
oldLine.destroy();
|
|
181
163
|
|
|
182
164
|
delete this._linesByPosition[pos];
|
|
183
165
|
|
|
184
|
-
this._lineIndicator.removeIndicator(
|
|
166
|
+
this._lineIndicator.removeIndicator(oldLine.getId(), false);
|
|
185
167
|
|
|
186
168
|
return oldLine;
|
|
187
169
|
};
|
|
188
170
|
|
|
189
171
|
Lines.prototype.isLineVisible = function(position) {
|
|
190
|
-
return this._linesByPosition[position]
|
|
172
|
+
return this._linesByPosition[position].isVisible();
|
|
191
173
|
};
|
|
192
174
|
|
|
193
175
|
Lines.prototype.getVisibleLines = function() {
|
|
@@ -225,22 +207,16 @@ define([
|
|
|
225
207
|
this._updateLinesPosition(position);
|
|
226
208
|
};
|
|
227
209
|
|
|
228
|
-
Lines.prototype._updateLinesPosition = function(position) {
|
|
210
|
+
Lines.prototype._updateLinesPosition = function(position, forceNewY) {
|
|
229
211
|
var line = this._linesByPosition[position];
|
|
230
212
|
var dy = null;
|
|
231
213
|
var newY;
|
|
232
214
|
|
|
233
|
-
if (
|
|
234
|
-
newY =
|
|
215
|
+
if (forceNewY) {
|
|
216
|
+
newY = forceNewY;
|
|
235
217
|
}
|
|
236
218
|
else {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
while ((previousLine === undefined || previousLine === null) && position > 0) {
|
|
240
|
-
previousLine = this._linesByPosition[--position];
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
newY = previousLine ? previousLine.getY() + previousLine.lineHeight() + this._peaks.options.interline : 0;
|
|
219
|
+
newY = line.getY() + line.lineHeight() + this._peaks.options.interline;
|
|
244
220
|
}
|
|
245
221
|
|
|
246
222
|
for (var pos in this._linesByPosition) {
|
|
@@ -259,7 +235,8 @@ define([
|
|
|
259
235
|
|
|
260
236
|
this._lineIndicator.updateIndicators();
|
|
261
237
|
this._lineIndicator.draw();
|
|
262
|
-
|
|
238
|
+
|
|
239
|
+
this._view.drawSourcesLayer();
|
|
263
240
|
};
|
|
264
241
|
|
|
265
242
|
Lines.prototype.setOffsetY = function(frameOffset) {
|
|
@@ -305,112 +282,25 @@ define([
|
|
|
305
282
|
return length;
|
|
306
283
|
};
|
|
307
284
|
|
|
308
|
-
Lines.prototype.
|
|
309
|
-
if (
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
this._automaticLineCreationTimeout = null;
|
|
313
|
-
this._automaticLineCreationPosition = null;
|
|
314
|
-
this._automaticallyCreatedLineId = null;
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
Lines.prototype.manageAutomaticLineCreation = function(newLinePosition, initialPosition, sources) {
|
|
318
|
-
if (this._automaticallyCreatedLineId !== null) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
else if (
|
|
322
|
-
this._automaticLineCreationPosition !== null
|
|
323
|
-
&& this._automaticLineCreationPosition !== newLinePosition
|
|
324
|
-
) {
|
|
325
|
-
this.stopAutomaticLineCreation();
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
if (this._automaticLineCreationTimeout) {
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
this._automaticLineCreationPosition = newLinePosition;
|
|
333
|
-
this._automaticLineCreationTimeout = setTimeout(function() {
|
|
334
|
-
this._automaticLineCreationTimeout = null;
|
|
335
|
-
|
|
336
|
-
var currentLine = this._linesByPosition[initialPosition];
|
|
337
|
-
|
|
338
|
-
if (currentLine.countRemainingElements() === sources.length) {
|
|
339
|
-
this.stopAutomaticLineCreation();
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
this._automaticallyCreatedLineId = this._createLine(newLinePosition);
|
|
344
|
-
this._setInteractions(newLinePosition);
|
|
345
|
-
this.moveSourcesToPosition(sources, currentLine.getPosition(), newLinePosition);
|
|
346
|
-
}.bind(this), this._peaks.options.automaticLineCreationDelay);
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
Lines.prototype.manageVerticalPosition = function(sources, startTime, endTime, mouseX, mouseY) {
|
|
350
|
-
if (mouseX === null || mouseX === undefined) {
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const position = sources[0].position;
|
|
355
|
-
const linePos = this.getLinesUnderY(mouseY);
|
|
285
|
+
Lines.prototype.manageVerticalPosition = function(source, newY) {
|
|
286
|
+
if (newY !== null && newY !== undefined) {
|
|
287
|
+
var pos = this.getLineOnPosition(newY);
|
|
356
288
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
this.stopAutomaticLineCreation();
|
|
362
|
-
|
|
363
|
-
if (
|
|
364
|
-
mouseX !== null && mouseX !== undefined
|
|
365
|
-
&& linePos[0] !== position
|
|
366
|
-
&& !this._linesByPosition[linePos[0]].isSegmentsLine()
|
|
367
|
-
) {
|
|
368
|
-
var mouseTime = this._view.pixelsToTime(mouseX + this._view.getFrameOffset());
|
|
369
|
-
var sourceDuration = Utils.roundTime(endTime - startTime);
|
|
370
|
-
|
|
371
|
-
if (this._hasSpaceForSourceAt(linePos[0], mouseTime, sourceDuration)) {
|
|
372
|
-
this.moveSourcesToPosition(sources, position, linePos[0]);
|
|
373
|
-
}
|
|
289
|
+
if (pos[0] === pos[1]
|
|
290
|
+
&& pos[0] !== source.position
|
|
291
|
+
&& !this._linesByPosition[pos[0]].isSegmentsLine()) {
|
|
292
|
+
this.moveSourceToPosition(source, pos[0]);
|
|
374
293
|
}
|
|
375
294
|
}
|
|
376
295
|
};
|
|
377
296
|
|
|
378
|
-
Lines.prototype._hasSpaceForSourceAt = function(linePosition, mouseTime, sourceDuration) {
|
|
379
|
-
var line = this._linesByPosition[linePosition];
|
|
380
|
-
|
|
381
|
-
if (!line || line.isSegmentsLine()) {
|
|
382
|
-
return false;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
var sourcesAround = line.getSourcesAround(mouseTime);
|
|
386
|
-
|
|
387
|
-
if (sourcesAround.overlapping) {
|
|
388
|
-
return false;
|
|
389
|
-
}
|
|
390
|
-
else if (!sourcesAround.right) {
|
|
391
|
-
return true;
|
|
392
|
-
}
|
|
393
|
-
else {
|
|
394
|
-
var leftLimit = sourcesAround.left ? sourcesAround.left.endTime : 0;
|
|
395
|
-
var rightLimit = sourcesAround.right.startTime;
|
|
396
|
-
|
|
397
|
-
return sourceDuration <= Utils.roundTime(rightLimit - leftLimit);
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
|
|
401
297
|
Lines.prototype.getLineByPosition = function(pos) {
|
|
402
298
|
return this._linesByPosition[pos];
|
|
403
299
|
};
|
|
404
300
|
|
|
405
|
-
Lines.prototype.
|
|
406
|
-
var keys = Object.keys(this._linesByPosition);
|
|
407
|
-
|
|
408
|
-
return keys.pop();
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
Lines.prototype.getLinesUnderY = function(y) {
|
|
301
|
+
Lines.prototype.getLineOnPosition = function(y) {
|
|
412
302
|
var height;
|
|
413
|
-
var pos = [-1,
|
|
303
|
+
var pos = [-1, Number.MAX_VALUE];
|
|
414
304
|
|
|
415
305
|
for (var position in this._linesByPosition) {
|
|
416
306
|
if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
@@ -429,18 +319,16 @@ define([
|
|
|
429
319
|
return pos;
|
|
430
320
|
};
|
|
431
321
|
|
|
432
|
-
Lines.prototype.
|
|
433
|
-
|
|
434
|
-
var sourceGroup = this._linesByPosition[initialPosition].removeSourceGroup(source, true);
|
|
322
|
+
Lines.prototype.moveSourceToPosition = function(source, pos) {
|
|
323
|
+
var sourceGroup = this._linesByPosition[source.position].removeSourceGroup(source, true);
|
|
435
324
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
325
|
+
delete this._linesBySourceId[source.id];
|
|
326
|
+
|
|
327
|
+
sourceGroup.moveTo(this._linesByPosition[pos].getKonvaGroup());
|
|
439
328
|
|
|
440
|
-
|
|
441
|
-
}.bind(this));
|
|
329
|
+
this._updateLinesPosition(source.position);
|
|
442
330
|
|
|
443
|
-
this.
|
|
331
|
+
this.addSourceGroup(sourceGroup, pos);
|
|
444
332
|
};
|
|
445
333
|
|
|
446
334
|
Lines.prototype._getNextLineId = function() {
|
|
@@ -460,17 +348,9 @@ define([
|
|
|
460
348
|
y += this._linesByPosition[pos].lineHeight() + this._peaks.options.interline;
|
|
461
349
|
}
|
|
462
350
|
else {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
var newPosition = currentPos + 1;
|
|
467
|
-
|
|
468
|
-
this._linesByPosition[currentPos].updatePosition(newPosition);
|
|
469
|
-
newLinesByPosition[newPosition] = this._linesByPosition[currentPos];
|
|
470
|
-
|
|
471
|
-
if (!this._linesByPosition[newPosition]) {
|
|
472
|
-
break;
|
|
473
|
-
}
|
|
351
|
+
if (this._linesByPosition[position]) {
|
|
352
|
+
this._linesByPosition[currentPos].updatePosition(currentPos + 1);
|
|
353
|
+
newLinesByPosition[currentPos + 1] = this._linesByPosition[currentPos];
|
|
474
354
|
}
|
|
475
355
|
}
|
|
476
356
|
}
|
|
@@ -486,8 +366,6 @@ define([
|
|
|
486
366
|
|
|
487
367
|
newLinesByPosition[position] = line;
|
|
488
368
|
this._linesByPosition = newLinesByPosition;
|
|
489
|
-
|
|
490
|
-
return line.getId();
|
|
491
369
|
};
|
|
492
370
|
|
|
493
371
|
Lines.prototype.updateSegments = function(frameStartTime, frameEndTime) {
|
|
@@ -498,13 +376,12 @@ define([
|
|
|
498
376
|
}
|
|
499
377
|
};
|
|
500
378
|
|
|
501
|
-
Lines.prototype.manageCollision = function(
|
|
502
|
-
return this.
|
|
379
|
+
Lines.prototype.manageCollision = function(source, newTimes) {
|
|
380
|
+
return this._linesBySourceId[source.id].manageCollision(source, newTimes);
|
|
503
381
|
};
|
|
504
382
|
|
|
505
|
-
Lines.prototype.
|
|
506
|
-
|
|
507
|
-
return this._linesByPosition[sources[0].position].manageOrder(sources, startTime, endTime);
|
|
383
|
+
Lines.prototype.manageSourceOrder = function(source, newTimes) {
|
|
384
|
+
return this._linesBySourceId[source.id].manageSourceOrder(source, newTimes);
|
|
508
385
|
};
|
|
509
386
|
|
|
510
387
|
Lines.prototype._setInteractions = function(position) {
|
package/src/main.js
CHANGED
|
@@ -409,13 +409,7 @@ define([
|
|
|
409
409
|
* Indicates whether or not sources can be dragged
|
|
410
410
|
* from one line to another
|
|
411
411
|
*/
|
|
412
|
-
canMoveSourcesBetweenLines: true
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Delay in milliseconds before a new line is created
|
|
416
|
-
* when dragging a source between 2 lines.
|
|
417
|
-
*/
|
|
418
|
-
automaticLineCreationDelay: 100
|
|
412
|
+
canMoveSourcesBetweenLines: true
|
|
419
413
|
};
|
|
420
414
|
|
|
421
415
|
/**
|
package/src/segments-group.js
CHANGED
package/src/source-group.js
CHANGED
|
@@ -50,12 +50,12 @@ define([
|
|
|
50
50
|
this._roundedX = Math.round(this._x);
|
|
51
51
|
this._width = this._view.timeToPixels(source.endTime - source.startTime);
|
|
52
52
|
this._roundedWidth = Math.round(this._width);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this._wrappedHeight =
|
|
57
|
-
this._height = heights.current;
|
|
53
|
+
this._unwrappedHeight = source.binaryHeight && source.previewHeight ?
|
|
54
|
+
source.binaryHeight + source.previewHeight :
|
|
55
|
+
this._peaks.options.lineHeight;
|
|
56
|
+
this._wrappedHeight = this._peaks.options.wrappedLineHeight;
|
|
58
57
|
this._borderWidth = this._source.borderWidth || 0;
|
|
58
|
+
this._height = this._unwrappedHeight;
|
|
59
59
|
this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
|
|
60
60
|
this._selected = this._source.selected;
|
|
61
61
|
this._isDragged = false;
|
|
@@ -81,6 +81,7 @@ define([
|
|
|
81
81
|
|
|
82
82
|
this._cursor = null;
|
|
83
83
|
this._group.on('mouseenter', function() {
|
|
84
|
+
self._hovered = true;
|
|
84
85
|
self._view.setHoveredElement(self);
|
|
85
86
|
if (!self._source.loading) {
|
|
86
87
|
self._showButtons();
|
|
@@ -88,6 +89,7 @@ define([
|
|
|
88
89
|
});
|
|
89
90
|
|
|
90
91
|
this._group.on('mouseleave', function() {
|
|
92
|
+
self._hovered = false;
|
|
91
93
|
self._view.setHoveredElement(null);
|
|
92
94
|
self._hideButtons();
|
|
93
95
|
});
|
|
@@ -174,8 +176,8 @@ define([
|
|
|
174
176
|
|
|
175
177
|
this._view.updateWithAutoScroll(
|
|
176
178
|
function() {
|
|
177
|
-
if (this._layer.
|
|
178
|
-
|
|
179
|
+
if (this._layer.updateSource(
|
|
180
|
+
this._source,
|
|
179
181
|
leftHandle ? start + diff + timeOffsetDiff : null,
|
|
180
182
|
leftHandle ? null : end + diff + timeOffsetDiff
|
|
181
183
|
)) {
|
|
@@ -424,13 +426,25 @@ define([
|
|
|
424
426
|
ctx.closePath();
|
|
425
427
|
|
|
426
428
|
if (fill) {
|
|
429
|
+
var backgroundColor;
|
|
430
|
+
|
|
431
|
+
if (this._selected) {
|
|
432
|
+
backgroundColor = this._source.selectedBackgroundColor;
|
|
433
|
+
}
|
|
434
|
+
else if (this._hovered) {
|
|
435
|
+
backgroundColor = this._source.hoverBackgroundColor;
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
backgroundColor = this._source.backgroundColor;
|
|
439
|
+
}
|
|
440
|
+
|
|
427
441
|
if (this._source.shouldShowWarning()) {
|
|
428
442
|
var gradient = ctx.createLinearGradient(0, 0, this._roundedWidth, 0);
|
|
429
443
|
|
|
430
444
|
if (this._source.mediaEndTime < this._source.duration) {
|
|
431
445
|
var rightStopPosition = Math.max(1 - (this._source.warningWidth / this._roundedWidth), 0.5);
|
|
432
446
|
|
|
433
|
-
gradient.addColorStop(rightStopPosition,
|
|
447
|
+
gradient.addColorStop(rightStopPosition, backgroundColor);
|
|
434
448
|
gradient.addColorStop(1, this._source.warningColor);
|
|
435
449
|
}
|
|
436
450
|
|
|
@@ -438,14 +452,14 @@ define([
|
|
|
438
452
|
var leftStopPosition = Math.min(this._source.warningWidth / this._roundedWidth, 0.5);
|
|
439
453
|
|
|
440
454
|
gradient.addColorStop(0, this._source.warningColor);
|
|
441
|
-
gradient.addColorStop(leftStopPosition,
|
|
455
|
+
gradient.addColorStop(leftStopPosition, backgroundColor);
|
|
442
456
|
}
|
|
443
457
|
|
|
444
458
|
ctx.fillStyle = gradient;
|
|
445
459
|
ctx.fill();
|
|
446
460
|
}
|
|
447
461
|
else {
|
|
448
|
-
ctx.fillStyle =
|
|
462
|
+
ctx.fillStyle = backgroundColor;
|
|
449
463
|
ctx.fill();
|
|
450
464
|
}
|
|
451
465
|
}
|
|
@@ -882,7 +896,7 @@ define([
|
|
|
882
896
|
this._selected = this._source.selected;
|
|
883
897
|
if (this._border) {
|
|
884
898
|
if (this._selected) {
|
|
885
|
-
this._border.fill(this._source.
|
|
899
|
+
this._border.fill(this._source.selectedBorderColor);
|
|
886
900
|
this._borderWidth = this._peaks.options.sourceSelectedBorderWidth;
|
|
887
901
|
}
|
|
888
902
|
else {
|
|
@@ -899,7 +913,7 @@ define([
|
|
|
899
913
|
|
|
900
914
|
if (unwrap_background) {
|
|
901
915
|
if (this._selected) {
|
|
902
|
-
unwrap_background.stroke(this._source.
|
|
916
|
+
unwrap_background.stroke(this._source.selectedBorderColor);
|
|
903
917
|
unwrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
|
|
904
918
|
}
|
|
905
919
|
else {
|
|
@@ -916,7 +930,7 @@ define([
|
|
|
916
930
|
|
|
917
931
|
if (wrap_background) {
|
|
918
932
|
if (this._selected) {
|
|
919
|
-
wrap_background.stroke(this._source.
|
|
933
|
+
wrap_background.stroke(this._source.selectedBorderColor);
|
|
920
934
|
wrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
|
|
921
935
|
}
|
|
922
936
|
else {
|
|
@@ -1117,14 +1131,6 @@ define([
|
|
|
1117
1131
|
return this._height;
|
|
1118
1132
|
};
|
|
1119
1133
|
|
|
1120
|
-
SourceGroup.prototype.getHeights = function() {
|
|
1121
|
-
return {
|
|
1122
|
-
unwrapped: this._unwrappedHeight,
|
|
1123
|
-
wrapped: this._wrappedHeight,
|
|
1124
|
-
current: this._height
|
|
1125
|
-
};
|
|
1126
|
-
};
|
|
1127
|
-
|
|
1128
1134
|
SourceGroup.prototype.setVisible = function(boolean) {
|
|
1129
1135
|
this._group.visible(boolean);
|
|
1130
1136
|
};
|
|
@@ -1625,25 +1631,5 @@ define([
|
|
|
1625
1631
|
this._group.destroy();
|
|
1626
1632
|
};
|
|
1627
1633
|
|
|
1628
|
-
/**
|
|
1629
|
-
* Static method to get height for a source
|
|
1630
|
-
* @param {Source} source - The source object
|
|
1631
|
-
* @param {Object} peaks - The peaks instance (for options)
|
|
1632
|
-
* @returns {number} The calculated height
|
|
1633
|
-
*/
|
|
1634
|
-
SourceGroup.getHeights = function(source, peaks) {
|
|
1635
|
-
var unwrappedHeight = source.binaryHeight && source.previewHeight ?
|
|
1636
|
-
source.binaryHeight + source.previewHeight :
|
|
1637
|
-
peaks.options.lineHeight;
|
|
1638
|
-
var wrappedHeight = peaks.options.wrappedLineHeight;
|
|
1639
|
-
var height = source.wrapped ? wrappedHeight : unwrappedHeight;
|
|
1640
|
-
|
|
1641
|
-
return {
|
|
1642
|
-
unwrapped: unwrappedHeight,
|
|
1643
|
-
wrapped: wrappedHeight,
|
|
1644
|
-
current: height
|
|
1645
|
-
};
|
|
1646
|
-
};
|
|
1647
|
-
|
|
1648
1634
|
return SourceGroup;
|
|
1649
1635
|
});
|
package/src/source.js
CHANGED
|
@@ -121,16 +121,34 @@ define([
|
|
|
121
121
|
);
|
|
122
122
|
}
|
|
123
123
|
|
|
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
|
+
|
|
124
142
|
if (!Utils.isValidColor(options.borderColor)) {
|
|
125
143
|
options.borderColor = options.color;
|
|
126
144
|
}
|
|
127
145
|
|
|
128
|
-
if (Utils.isNullOrUndefined(options.
|
|
129
|
-
options.
|
|
146
|
+
if (Utils.isNullOrUndefined(options.selectedBorderColor)) {
|
|
147
|
+
options.selectedBorderColor = Utils.shadeColor(options.borderColor, 30);
|
|
130
148
|
}
|
|
131
|
-
else if (!Utils.isValidColor(options.
|
|
149
|
+
else if (!Utils.isValidColor(options.selectedBorderColor)) {
|
|
132
150
|
throw new TypeError(
|
|
133
|
-
'peaks.sources.' + context + ':
|
|
151
|
+
'peaks.sources.' + context + ': selectedBorderColor should be a valid CSS color'
|
|
134
152
|
);
|
|
135
153
|
}
|
|
136
154
|
|
|
@@ -377,7 +395,7 @@ define([
|
|
|
377
395
|
* @param {String} color Primary color of the source representation.
|
|
378
396
|
* @param {String} backgroundColor Background color of the source.
|
|
379
397
|
* @param {String} borderColor Border color of the source.
|
|
380
|
-
* @param {String}
|
|
398
|
+
* @param {String} selectedBorderColor Color when the source is selected.
|
|
381
399
|
* @param {String} warningColor Color used for warning states.
|
|
382
400
|
* @param {String} volumeSliderColor Color of the volume slider.
|
|
383
401
|
* @param {Number} volumeSliderWidth Width of the volume slider.
|
|
@@ -412,11 +430,11 @@ define([
|
|
|
412
430
|
|
|
413
431
|
function Source(peaks, id, originId, elementId, title, titleAlignments, url, previewUrl, binaryUrl, kind,
|
|
414
432
|
subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor,
|
|
415
|
-
|
|
416
|
-
volumeSliderDraggingWidth, textFont, textFontSize, textColor,
|
|
417
|
-
textAutoScroll, borderWidth, borderRadius, wrapped, position, draggable,
|
|
418
|
-
cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers,
|
|
419
|
-
markerWidth, volume, volumeRange, loading, ...customParams) {
|
|
433
|
+
hoverBackgroundColor, selectedBackgroundColor, borderColor, selectedBorderColor, warningColor, warningWidth,
|
|
434
|
+
volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor,
|
|
435
|
+
textBackgroundColor, textPosition, textAutoScroll, borderWidth, borderRadius, wrapped, position, draggable,
|
|
436
|
+
orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers,
|
|
437
|
+
buttons, markerColor, markerWidth, volume, volumeRange, loading, ...customParams) {
|
|
420
438
|
var opts = {
|
|
421
439
|
title: title,
|
|
422
440
|
titleAlignments: titleAlignments,
|
|
@@ -432,8 +450,10 @@ define([
|
|
|
432
450
|
mediaEndTime: mediaEndTime,
|
|
433
451
|
color: color,
|
|
434
452
|
backgroundColor: backgroundColor,
|
|
453
|
+
hoverBackgroundColor: hoverBackgroundColor,
|
|
454
|
+
selectedBackgroundColor: selectedBackgroundColor,
|
|
435
455
|
borderColor: borderColor,
|
|
436
|
-
|
|
456
|
+
selectedBorderColor: selectedBorderColor,
|
|
437
457
|
warningColor: warningColor,
|
|
438
458
|
warningWidth: warningWidth,
|
|
439
459
|
textFont: textFont,
|
|
@@ -487,8 +507,10 @@ define([
|
|
|
487
507
|
this._mediaEndTime = opts.mediaEndTime;
|
|
488
508
|
this._color = opts.color;
|
|
489
509
|
this._backgroundColor = opts.backgroundColor;
|
|
510
|
+
this._hoverBackgroundColor = opts.hoverBackgroundColor;
|
|
511
|
+
this._selectedBackgroundColor = opts.selectedBackgroundColor;
|
|
490
512
|
this._borderColor = opts.borderColor;
|
|
491
|
-
this.
|
|
513
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
492
514
|
this._warningColor = opts.warningColor;
|
|
493
515
|
this._warningWidth = opts.warningWidth;
|
|
494
516
|
this._volumeSliderColor = opts.volumeSliderColor;
|
|
@@ -664,6 +686,26 @@ define([
|
|
|
664
686
|
this._backgroundColor = backgroundColor;
|
|
665
687
|
}
|
|
666
688
|
},
|
|
689
|
+
hoverBackgroundColor: {
|
|
690
|
+
enumerable: true,
|
|
691
|
+
get: function() {
|
|
692
|
+
return this._hoverBackgroundColor;
|
|
693
|
+
},
|
|
694
|
+
|
|
695
|
+
set: function(hoverBackgroundColor) {
|
|
696
|
+
this._hoverBackgroundColor = hoverBackgroundColor;
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
selectedBackgroundColor: {
|
|
700
|
+
enumerable: true,
|
|
701
|
+
get: function() {
|
|
702
|
+
return this._selectedBackgroundColor;
|
|
703
|
+
},
|
|
704
|
+
|
|
705
|
+
set: function(selectedBackgroundColor) {
|
|
706
|
+
this._selectedBackgroundColor = selectedBackgroundColor;
|
|
707
|
+
}
|
|
708
|
+
},
|
|
667
709
|
borderColor: {
|
|
668
710
|
enumerable: true,
|
|
669
711
|
get: function() {
|
|
@@ -674,14 +716,14 @@ define([
|
|
|
674
716
|
this._borderColor = borderColor;
|
|
675
717
|
}
|
|
676
718
|
},
|
|
677
|
-
|
|
719
|
+
selectedBorderColor: {
|
|
678
720
|
enumerable: true,
|
|
679
721
|
get: function() {
|
|
680
|
-
return this.
|
|
722
|
+
return this._selectedBorderColor;
|
|
681
723
|
},
|
|
682
724
|
|
|
683
|
-
set: function(
|
|
684
|
-
this.
|
|
725
|
+
set: function(selectedBorderColor) {
|
|
726
|
+
this._selectedBorderColor = selectedBorderColor;
|
|
685
727
|
}
|
|
686
728
|
},
|
|
687
729
|
warningColor: {
|
|
@@ -1089,8 +1131,10 @@ define([
|
|
|
1089
1131
|
mediaEndTime: this.mediaEndTime,
|
|
1090
1132
|
color: this.color,
|
|
1091
1133
|
backgroundColor: this.backgroundColor,
|
|
1134
|
+
hoverBackgroundColor: this.hoverBackgroundColor,
|
|
1135
|
+
selectedBackgroundColor: this.selectedBackgroundColor,
|
|
1092
1136
|
borderColor: this.borderColor,
|
|
1093
|
-
|
|
1137
|
+
selectedBorderColor: this.selectedBorderColor,
|
|
1094
1138
|
warningColor: this.warningColor,
|
|
1095
1139
|
warningWidth: this.warningWidth,
|
|
1096
1140
|
volumeSliderColor: this.volumeSliderColor,
|
|
@@ -1142,8 +1186,10 @@ define([
|
|
|
1142
1186
|
this._mediaEndTime = opts.mediaEndTime;
|
|
1143
1187
|
this._color = opts.color;
|
|
1144
1188
|
this._backgroundColor = opts.backgroundColor;
|
|
1189
|
+
this._hoverBackgroundColor = opts.hoverBackgroundColor;
|
|
1190
|
+
this._selectedBackgroundColor = opts.selectedBackgroundColor;
|
|
1145
1191
|
this._borderColor = opts.borderColor;
|
|
1146
|
-
this.
|
|
1192
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
1147
1193
|
this._warningColor = opts.warningColor;
|
|
1148
1194
|
this._warningWidth = opts.warningWidth;
|
|
1149
1195
|
this._volumeSliderColor = opts.volumeSliderColor;
|