@checksub_team/peaks_timeline 1.4.28 → 1.4.31

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": "1.4.28",
3
+ "version": "1.4.31",
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
@@ -14889,6 +14889,15 @@ module.exports = function (Konva, Utils) {
14889
14889
  this._height = this._segmentsGroup.getCurrentHeight();
14890
14890
  segmentsGroup.addToGroup(this._group);
14891
14891
  };
14892
+ Line.prototype.refreshSegmentsHeight = function () {
14893
+ if (this.isSegmentsLine) {
14894
+ var oldHeight = this._height;
14895
+ this._height = this._segmentsGroup.getCurrentHeight();
14896
+ if (this._height !== oldHeight) {
14897
+ this._peaks.emit('line.heightChanged', this._position);
14898
+ }
14899
+ }
14900
+ };
14892
14901
  Line.prototype._canBePlacedBetween = function (startTime, endTime, startLimit, endLimit) {
14893
14902
  var timeWidth = endTime - startTime;
14894
14903
  var newTimes = null;
@@ -15158,6 +15167,7 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
15158
15167
  this._areSourceInteractionsAllowed = true;
15159
15168
  this._areSegmentInteractionsAllowed = true;
15160
15169
  this._segmentsGroups = {};
15170
+ this._segmentsGroupToLine = {};
15161
15171
  this._lineId = 0;
15162
15172
  this._lineIndicator = new LineIndicator(peaks, view, document.getElementById('line-indicator-container'));
15163
15173
  this._peaks.on('line.heightChanged', this._onLineHeightChanged.bind(this));
@@ -15176,6 +15186,9 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
15176
15186
  self._segmentsGroups[segment.line] = new SegmentsGroup(self._peaks, self._view, true);
15177
15187
  }
15178
15188
  self._segmentsGroups[segment.line].onSegmentsAdd([segment]);
15189
+ if (Utils.objectHasProperty(self._segmentsGroupToLine, segment.line)) {
15190
+ self._segmentsGroupToLine[segment.line].refreshSegmentsHeight();
15191
+ }
15179
15192
  });
15180
15193
  };
15181
15194
  Lines.prototype._onSegmentsUpdate = function (segment) {
@@ -15192,6 +15205,9 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
15192
15205
  };
15193
15206
  Lines.prototype._onSegmentsRemoveAll = function (lineId) {
15194
15207
  this._segmentsGroups[lineId].onSegmentsRemoveAll();
15208
+ if (Utils.objectHasProperty(this._segmentsGroupToLine, lineId)) {
15209
+ this._segmentsGroupToLine[lineId].refreshSegmentsHeight();
15210
+ }
15195
15211
  };
15196
15212
  Lines.prototype._onLineHeightChanged = function (position) {
15197
15213
  this._updateLinesPosition(position);
@@ -15217,7 +15233,7 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
15217
15233
  }
15218
15234
  };
15219
15235
  Lines.prototype.addSourceGroup = function (sourceGroup, position) {
15220
- if (!this._linesByPosition[position]) {
15236
+ if (!this._linesByPosition[position] || this._linesByPosition[position].isSegmentsLine()) {
15221
15237
  this._createLine(position);
15222
15238
  this._setInteractions(position);
15223
15239
  }
@@ -15229,6 +15245,7 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
15229
15245
  this._createLine(position);
15230
15246
  this._linesByPosition[position].allowInteractions(this._areSegmentInteractionsAllowed);
15231
15247
  this._linesByPosition[position].addSegments(this._segmentsGroups[lineId]);
15248
+ this._segmentsGroupToLine[lineId] = this._linesByPosition[position];
15232
15249
  this._setInteractions(position);
15233
15250
  this._updateLinesPosition(position);
15234
15251
  };
@@ -16515,7 +16532,7 @@ module.exports = function (Konva, SegmentMarker) {
16515
16532
  fill: segment.color + Math.round(segment.opacity * 255).toString(16),
16516
16533
  stroke: segment.textColor + 'FF',
16517
16534
  strokeWidth: 1,
16518
- draggable: true
16535
+ draggable: this._segment.editable
16519
16536
  });
16520
16537
  var self = this;
16521
16538
  this._rectangle.dragBoundFunc(function () {
@@ -16760,6 +16777,11 @@ module.exports = function (Utils) {
16760
16777
  if (!Utils.isInteger(options.line)) {
16761
16778
  throw new TypeError('peaks.segments.' + context + ': line must be an integer');
16762
16779
  }
16780
+ if (Utils.isNullOrUndefined(options.editable)) {
16781
+ options.editable = true;
16782
+ } else if (!Utils.isBoolean(options.editable)) {
16783
+ throw new TypeError('peaks.segments.' + context + ': editable must be a boolean');
16784
+ }
16763
16785
  }
16764
16786
  function Segment(peaks, id, startTime, endTime, labelText, color, textColor, handleTextColor, opacity, editable, allowDeletion, line) {
16765
16787
  var opts = {
@@ -17106,18 +17128,20 @@ module.exports = function (SegmentShape, Utils, Konva) {
17106
17128
  SegmentsGroup.prototype.find = function (startTime, endTime) {
17107
17129
  var currentSegment = null;
17108
17130
  var visibleSegments = [];
17109
- do {
17110
- if (!currentSegment) {
17111
- currentSegment = this._segments[this._firstSegmentId];
17112
- } else {
17113
- currentSegment = this._segments[currentSegment.nextSegmentId];
17114
- }
17115
- if (currentSegment.segment.isVisible(startTime, endTime)) {
17116
- visibleSegments.push(currentSegment.segment);
17117
- } else if (visibleSegments.length) {
17118
- break;
17119
- }
17120
- } while (currentSegment.nextSegmentId);
17131
+ if (this._firstSegmentId) {
17132
+ do {
17133
+ if (!currentSegment) {
17134
+ currentSegment = this._segments[this._firstSegmentId];
17135
+ } else {
17136
+ currentSegment = this._segments[currentSegment.nextSegmentId];
17137
+ }
17138
+ if (currentSegment.segment.isVisible(startTime, endTime)) {
17139
+ visibleSegments.push(currentSegment.segment);
17140
+ } else if (visibleSegments.length) {
17141
+ break;
17142
+ }
17143
+ } while (currentSegment.nextSegmentId);
17144
+ }
17121
17145
  return visibleSegments;
17122
17146
  };
17123
17147
  SegmentsGroup.prototype._draw = function () {
@@ -17135,8 +17159,12 @@ module.exports = function (SegmentShape, Utils, Konva) {
17135
17159
  break;
17136
17160
  }
17137
17161
  }
17138
- if (!currentHeight && this._segments) {
17139
- currentHeight = this._peaks.options.segmentHeight;
17162
+ if (!currentHeight) {
17163
+ if (Object.keys(this._segments).length > 0) {
17164
+ currentHeight = this._peaks.options.segmentHeight;
17165
+ } else {
17166
+ currentHeight = this._peaks.options.emptyLineHeight;
17167
+ }
17140
17168
  }
17141
17169
  return currentHeight;
17142
17170
  };
@@ -17233,20 +17261,25 @@ module.exports = function (SegmentShape, Utils, Konva) {
17233
17261
  }
17234
17262
  } else if (segment.startTime >= newStartTime) {
17235
17263
  if (newStartTime < previousSegment.endTime) {
17236
- if (previousSegment.startTime + previousSegment.minSize > newStartTime) {
17237
- newStartTime = previousSegment.startTime + previousSegment.minSize;
17238
- startLimited = true;
17239
- }
17240
- if (previousSegment.endTime !== newStartTime) {
17241
- newXs = this.manageCollision(previousSegment, this._view.timeToPixels(previousSegment.startTime), this._view.timeToPixels(newStartTime));
17242
- if (newXs.startX !== null) {
17243
- previousSegment.startTime = this._view.pixelsToTime(newXs.startX);
17264
+ if (previousSegment.editable) {
17265
+ if (previousSegment.startTime + previousSegment.minSize > newStartTime) {
17266
+ newStartTime = previousSegment.startTime + previousSegment.minSize;
17267
+ startLimited = true;
17244
17268
  }
17245
- if (newXs.endX !== null) {
17246
- previousSegment.endTime = this._view.pixelsToTime(newXs.endX);
17269
+ if (previousSegment.endTime !== newStartTime) {
17270
+ newXs = this.manageCollision(previousSegment, this._view.timeToPixels(previousSegment.startTime), this._view.timeToPixels(newStartTime));
17271
+ if (newXs.startX !== null) {
17272
+ previousSegment.startTime = this._view.pixelsToTime(newXs.startX);
17273
+ }
17274
+ if (newXs.endX !== null) {
17275
+ previousSegment.endTime = this._view.pixelsToTime(newXs.endX);
17276
+ }
17277
+ this._updateSegment(previousSegment);
17278
+ this.addToUpdatedSegments(previousSegment);
17247
17279
  }
17248
- this._updateSegment(previousSegment);
17249
- this.addToUpdatedSegments(previousSegment);
17280
+ } else {
17281
+ newStartTime = previousSegment.endTime;
17282
+ startLimited = true;
17250
17283
  }
17251
17284
  }
17252
17285
  }
@@ -17274,20 +17307,25 @@ module.exports = function (SegmentShape, Utils, Konva) {
17274
17307
  }
17275
17308
  } else if (segment.endTime <= newEndTime) {
17276
17309
  if (newEndTime > nextSegment.startTime) {
17277
- if (nextSegment.endTime - nextSegment.minSize < newEndTime) {
17278
- newEndTime = nextSegment.endTime - nextSegment.minSize;
17279
- endLimited = true;
17280
- }
17281
- if (nextSegment.startTime !== newEndTime) {
17282
- newXs = this.manageCollision(nextSegment, this._view.timeToPixels(newEndTime), this._view.timeToPixels(nextSegment.endTime));
17283
- if (newXs.startX !== null) {
17284
- nextSegment.startTime = this._view.pixelsToTime(newXs.startX);
17310
+ if (nextSegment.editable) {
17311
+ if (nextSegment.endTime - nextSegment.minSize < newEndTime) {
17312
+ newEndTime = nextSegment.endTime - nextSegment.minSize;
17313
+ endLimited = true;
17285
17314
  }
17286
- if (newXs.endX !== null) {
17287
- nextSegment.endTime = this._view.pixelsToTime(newXs.endX);
17315
+ if (nextSegment.startTime !== newEndTime) {
17316
+ newXs = this.manageCollision(nextSegment, this._view.timeToPixels(newEndTime), this._view.timeToPixels(nextSegment.endTime));
17317
+ if (newXs.startX !== null) {
17318
+ nextSegment.startTime = this._view.pixelsToTime(newXs.startX);
17319
+ }
17320
+ if (newXs.endX !== null) {
17321
+ nextSegment.endTime = this._view.pixelsToTime(newXs.endX);
17322
+ }
17323
+ this._updateSegment(nextSegment);
17324
+ this.addToUpdatedSegments(nextSegment);
17288
17325
  }
17289
- this._updateSegment(nextSegment);
17290
- this.addToUpdatedSegments(nextSegment);
17326
+ } else {
17327
+ newEndTime = nextSegment.startTime;
17328
+ endLimited = true;
17291
17329
  }
17292
17330
  }
17293
17331
  }
@@ -18230,11 +18268,8 @@ module.exports = function (Utils) {
18230
18268
  } else if (options.wrapping === 'complete') {
18231
18269
  options.wrapped = false;
18232
18270
  }
18233
- if (!Utils.isNullOrUndefined(options.tts) && !Utils.isBoolean(options.tts)) {
18234
- throw new TypeError('peaks.sources.' + context + ': tts must be a boolean or undefined');
18235
- }
18236
18271
  }
18237
- 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) {
18272
+ 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) {
18238
18273
  var opts = {
18239
18274
  title: title,
18240
18275
  url: url,
@@ -18257,8 +18292,7 @@ module.exports = function (Utils) {
18257
18292
  resizable: resizable,
18258
18293
  wrapping: wrapping,
18259
18294
  previewHeight: previewHeight,
18260
- binaryHeight: binaryHeight,
18261
- tts: tts
18295
+ binaryHeight: binaryHeight
18262
18296
  };
18263
18297
  validateSource(peaks, opts, 'add()');
18264
18298
  this._peaks = peaks;
@@ -18288,7 +18322,6 @@ module.exports = function (Utils) {
18288
18322
  this._previewHeight = opts.previewHeight;
18289
18323
  this._binaryHeight = opts.binaryHeight;
18290
18324
  this._minSize = peaks.options.minSourceSize;
18291
- this._tts = opts.tts;
18292
18325
  }
18293
18326
  Object.defineProperties(Source.prototype, {
18294
18327
  id: {
@@ -18494,14 +18527,6 @@ module.exports = function (Utils) {
18494
18527
  get: function () {
18495
18528
  return this._minSize;
18496
18529
  }
18497
- },
18498
- tts: {
18499
- get: function () {
18500
- return this._tts;
18501
- },
18502
- set: function (tts) {
18503
- this._tts = tts;
18504
- }
18505
18530
  }
18506
18531
  });
18507
18532
  Source.prototype.updateTimes = function (newStartTime, newEndTime) {
@@ -18611,8 +18636,7 @@ module.exports = function (Utils) {
18611
18636
  resizable: this.resizable,
18612
18637
  wrapping: this.wrapping,
18613
18638
  previewHeight: this.previewHeight,
18614
- binaryHeight: this.binaryHeight,
18615
- tts: this.tts
18639
+ binaryHeight: this.binaryHeight
18616
18640
  };
18617
18641
  Utils.extend(opts, options);
18618
18642
  validateSource(this._peaks, opts, 'update()');
@@ -18638,7 +18662,6 @@ module.exports = function (Utils) {
18638
18662
  this._wrapping = opts.wrapping;
18639
18663
  this._previewHeight = opts.previewHeight;
18640
18664
  this._binaryHeight = opts.binaryHeight;
18641
- this._tts = opts.tts;
18642
18665
  this._peaks.emit('source.update', this);
18643
18666
  };
18644
18667
  Source.prototype.isVisible = function (startTime, endTime) {
@@ -19177,7 +19200,7 @@ module.exports = function (Colors, Segment, Utils) {
19177
19200
  if (!Utils.isObject(options)) {
19178
19201
  throw new TypeError('peaks.segments.add(): expected a Segment object parameter');
19179
19202
  }
19180
- var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.opacity || 1, true, options.allowDeletion || false, options.line);
19203
+ var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.opacity || 1, options.editable, options.allowDeletion || false, options.line);
19181
19204
  return segment;
19182
19205
  };
19183
19206
  TimelineSegments.prototype.getSegments = function () {
@@ -19276,8 +19299,10 @@ module.exports = function (Colors, Segment, Utils) {
19276
19299
  return this._removeSegments(fnFilter);
19277
19300
  };
19278
19301
  TimelineSegments.prototype.removeAll = function (lineId) {
19279
- this._segments = [];
19280
- this._segmentsById = {};
19302
+ var indexes = this._findSegment(function (segment) {
19303
+ return segment.line === lineId;
19304
+ });
19305
+ this._removeIndexes(indexes);
19281
19306
  this._peaks.emit('segments.remove_all', lineId);
19282
19307
  };
19283
19308
  return TimelineSegments;
@@ -19325,8 +19350,7 @@ module.exports = function (Source, Utils) {
19325
19350
  resizable: sourceToCut.resizable,
19326
19351
  wrapping: sourceToCut.wrapping,
19327
19352
  previewHeight: sourceToCut.previewHeight,
19328
- binaryHeight: sourceToCut.binaryHeight,
19329
- tts: sourceToCut.tts
19353
+ binaryHeight: sourceToCut.binaryHeight
19330
19354
  }]);
19331
19355
  this._peaks.emit('sources.updated');
19332
19356
  };
@@ -19341,7 +19365,7 @@ module.exports = function (Source, Utils) {
19341
19365
  if (!Utils.isObject(options)) {
19342
19366
  throw new TypeError('peaks.sources.add(): expected a Source object parameter');
19343
19367
  }
19344
- 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);
19368
+ 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);
19345
19369
  return source;
19346
19370
  };
19347
19371
  TimelineSources.prototype.getSources = function () {
package/src/line.js CHANGED
@@ -279,6 +279,18 @@ define([
279
279
  segmentsGroup.addToGroup(this._group);
280
280
  };
281
281
 
282
+ Line.prototype.refreshSegmentsHeight = function() {
283
+ if (this.isSegmentsLine) {
284
+ var oldHeight = this._height;
285
+
286
+ this._height = this._segmentsGroup.getCurrentHeight();
287
+
288
+ if (this._height !== oldHeight) {
289
+ this._peaks.emit('line.heightChanged', this._position);
290
+ }
291
+ }
292
+ };
293
+
282
294
  Line.prototype._canBePlacedBetween = function(startTime, endTime, startLimit, endLimit) {
283
295
  var timeWidth = endTime - startTime;
284
296
  var newTimes = null;
package/src/lines.js CHANGED
@@ -29,6 +29,7 @@ define([
29
29
  this._areSegmentInteractionsAllowed = true;
30
30
 
31
31
  this._segmentsGroups = {};
32
+ this._segmentsGroupToLine = {};
32
33
 
33
34
  this._lineId = 0;
34
35
 
@@ -58,6 +59,9 @@ define([
58
59
  }
59
60
 
60
61
  self._segmentsGroups[segment.line].onSegmentsAdd([segment]);
62
+ if (Utils.objectHasProperty(self._segmentsGroupToLine, segment.line)) {
63
+ self._segmentsGroupToLine[segment.line].refreshSegmentsHeight();
64
+ }
61
65
  });
62
66
  };
63
67
 
@@ -79,6 +83,10 @@ define([
79
83
 
80
84
  Lines.prototype._onSegmentsRemoveAll = function(lineId) {
81
85
  this._segmentsGroups[lineId].onSegmentsRemoveAll();
86
+
87
+ if (Utils.objectHasProperty(this._segmentsGroupToLine, lineId)) {
88
+ this._segmentsGroupToLine[lineId].refreshSegmentsHeight();
89
+ }
82
90
  };
83
91
 
84
92
  Lines.prototype._onLineHeightChanged = function(position) {
@@ -110,7 +118,7 @@ define([
110
118
  };
111
119
 
112
120
  Lines.prototype.addSourceGroup = function(sourceGroup, position) {
113
- if (!this._linesByPosition[position]) {
121
+ if (!this._linesByPosition[position] || this._linesByPosition[position].isSegmentsLine()) {
114
122
  this._createLine(position);
115
123
  this._setInteractions(position);
116
124
  }
@@ -126,6 +134,8 @@ define([
126
134
  this._linesByPosition[position].allowInteractions(this._areSegmentInteractionsAllowed);
127
135
  this._linesByPosition[position].addSegments(this._segmentsGroups[lineId]);
128
136
 
137
+ this._segmentsGroupToLine[lineId] = this._linesByPosition[position];
138
+
129
139
  this._setInteractions(position);
130
140
 
131
141
  this._updateLinesPosition(position);
@@ -52,7 +52,7 @@ define([
52
52
  fill: segment.color + Math.round(segment.opacity * 255).toString(16),
53
53
  stroke: segment.textColor + 'FF',
54
54
  strokeWidth: 1,
55
- draggable: true
55
+ draggable: this._segment.editable
56
56
  });
57
57
 
58
58
  var self = this;
package/src/segment.js CHANGED
@@ -54,6 +54,13 @@ define([
54
54
  if (!Utils.isInteger(options.line)) {
55
55
  throw new TypeError('peaks.segments.' + context + ': line must be an integer');
56
56
  }
57
+
58
+ if (Utils.isNullOrUndefined(options.editable)) {
59
+ options.editable = true;
60
+ }
61
+ else if (!Utils.isBoolean(options.editable)) {
62
+ throw new TypeError('peaks.segments.' + context + ': editable must be a boolean');
63
+ }
57
64
  }
58
65
 
59
66
  /**
@@ -326,21 +326,23 @@ define([
326
326
  var currentSegment = null;
327
327
  var visibleSegments = [];
328
328
 
329
- do {
330
- if (!currentSegment) {
331
- currentSegment = this._segments[this._firstSegmentId];
332
- }
333
- else {
334
- currentSegment = this._segments[currentSegment.nextSegmentId];
335
- }
329
+ if (this._firstSegmentId) {
330
+ do {
331
+ if (!currentSegment) {
332
+ currentSegment = this._segments[this._firstSegmentId];
333
+ }
334
+ else {
335
+ currentSegment = this._segments[currentSegment.nextSegmentId];
336
+ }
336
337
 
337
- if (currentSegment.segment.isVisible(startTime, endTime)) {
338
- visibleSegments.push(currentSegment.segment);
339
- }
340
- else if (visibleSegments.length) {
341
- break;
342
- }
343
- } while (currentSegment.nextSegmentId);
338
+ if (currentSegment.segment.isVisible(startTime, endTime)) {
339
+ visibleSegments.push(currentSegment.segment);
340
+ }
341
+ else if (visibleSegments.length) {
342
+ break;
343
+ }
344
+ } while (currentSegment.nextSegmentId);
345
+ }
344
346
 
345
347
  return visibleSegments;
346
348
  };
@@ -370,8 +372,13 @@ define([
370
372
  }
371
373
  }
372
374
 
373
- if (!currentHeight && this._segments) {
374
- currentHeight = this._peaks.options.segmentHeight;
375
+ if (!currentHeight) {
376
+ if (Object.keys(this._segments).length > 0) {
377
+ currentHeight = this._peaks.options.segmentHeight;
378
+ }
379
+ else {
380
+ currentHeight = this._peaks.options.emptyLineHeight;
381
+ }
375
382
  }
376
383
 
377
384
  return currentHeight;
@@ -520,27 +527,34 @@ define([
520
527
  // startMarker moved to the left
521
528
  if (newStartTime < previousSegment.endTime) {
522
529
  // there is collision
523
- if (previousSegment.startTime + previousSegment.minSize > newStartTime) {
524
- newStartTime = previousSegment.startTime + previousSegment.minSize;
525
- startLimited = true;
526
- }
530
+ if (previousSegment.editable) {
531
+ if (previousSegment.startTime + previousSegment.minSize > newStartTime) {
532
+ newStartTime = previousSegment.startTime + previousSegment.minSize;
533
+ startLimited = true;
534
+ }
527
535
 
528
- if (previousSegment.endTime !== newStartTime) {
529
- newXs = this.manageCollision(
530
- previousSegment,
531
- this._view.timeToPixels(previousSegment.startTime),
532
- this._view.timeToPixels(newStartTime)
533
- );
536
+ if (previousSegment.endTime !== newStartTime) {
537
+ newXs = this.manageCollision(
538
+ previousSegment,
539
+ this._view.timeToPixels(previousSegment.startTime),
540
+ this._view.timeToPixels(newStartTime)
541
+ );
534
542
 
535
- if (newXs.startX !== null) {
536
- previousSegment.startTime = this._view.pixelsToTime(newXs.startX);
537
- }
543
+ if (newXs.startX !== null) {
544
+ previousSegment.startTime = this._view.pixelsToTime(newXs.startX);
545
+ }
538
546
 
539
- if (newXs.endX !== null) {
540
- previousSegment.endTime = this._view.pixelsToTime(newXs.endX);
547
+ if (newXs.endX !== null) {
548
+ previousSegment.endTime = this._view.pixelsToTime(newXs.endX);
549
+ }
550
+
551
+ this._updateSegment(previousSegment);
552
+ this.addToUpdatedSegments(previousSegment);
541
553
  }
542
- this._updateSegment(previousSegment);
543
- this.addToUpdatedSegments(previousSegment);
554
+ }
555
+ else {
556
+ newStartTime = previousSegment.endTime;
557
+ startLimited = true;
544
558
  }
545
559
  }
546
560
  }
@@ -578,27 +592,34 @@ define([
578
592
  // endMarker moved to the right
579
593
  if (newEndTime > nextSegment.startTime) {
580
594
  // there is collision
581
- if (nextSegment.endTime - nextSegment.minSize < newEndTime) {
582
- newEndTime = nextSegment.endTime - nextSegment.minSize;
583
- endLimited = true;
584
- }
595
+ if (nextSegment.editable) {
596
+ if (nextSegment.endTime - nextSegment.minSize < newEndTime) {
597
+ newEndTime = nextSegment.endTime - nextSegment.minSize;
598
+ endLimited = true;
599
+ }
585
600
 
586
- if (nextSegment.startTime !== newEndTime) {
587
- newXs = this.manageCollision(
588
- nextSegment,
589
- this._view.timeToPixels(newEndTime),
590
- this._view.timeToPixels(nextSegment.endTime)
591
- );
601
+ if (nextSegment.startTime !== newEndTime) {
602
+ newXs = this.manageCollision(
603
+ nextSegment,
604
+ this._view.timeToPixels(newEndTime),
605
+ this._view.timeToPixels(nextSegment.endTime)
606
+ );
592
607
 
593
- if (newXs.startX !== null) {
594
- nextSegment.startTime = this._view.pixelsToTime(newXs.startX);
595
- }
608
+ if (newXs.startX !== null) {
609
+ nextSegment.startTime = this._view.pixelsToTime(newXs.startX);
610
+ }
611
+
612
+ if (newXs.endX !== null) {
613
+ nextSegment.endTime = this._view.pixelsToTime(newXs.endX);
614
+ }
596
615
 
597
- if (newXs.endX !== null) {
598
- nextSegment.endTime = this._view.pixelsToTime(newXs.endX);
616
+ this._updateSegment(nextSegment);
617
+ this.addToUpdatedSegments(nextSegment);
599
618
  }
600
- this._updateSegment(nextSegment);
601
- this.addToUpdatedSegments(nextSegment);
619
+ }
620
+ else {
621
+ newEndTime = nextSegment.startTime;
622
+ endLimited = true;
602
623
  }
603
624
  }
604
625
  }
package/src/source.js CHANGED
@@ -197,10 +197,6 @@ 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
- }
204
200
  }
205
201
 
206
202
  /**
@@ -226,7 +222,7 @@ define([
226
222
  function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind,
227
223
  duration, startTime, endTime, mediaStartTime, mediaEndTime, color, borderColor,
228
224
  selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable, wrapping,
229
- previewHeight, binaryHeight, tts) {
225
+ previewHeight, binaryHeight) {
230
226
  var opts = {
231
227
  title: title,
232
228
  url: url,
@@ -249,8 +245,7 @@ define([
249
245
  resizable: resizable,
250
246
  wrapping: wrapping,
251
247
  previewHeight: previewHeight,
252
- binaryHeight: binaryHeight,
253
- tts: tts
248
+ binaryHeight: binaryHeight
254
249
  };
255
250
 
256
251
  validateSource(peaks, opts, 'add()');
@@ -282,7 +277,6 @@ define([
282
277
  this._previewHeight = opts.previewHeight;
283
278
  this._binaryHeight = opts.binaryHeight;
284
279
  this._minSize = peaks.options.minSourceSize;
285
- this._tts = opts.tts;
286
280
  }
287
281
 
288
282
  Object.defineProperties(Source.prototype, {
@@ -503,15 +497,6 @@ define([
503
497
  get: function() {
504
498
  return this._minSize;
505
499
  }
506
- },
507
- tts: {
508
- get: function() {
509
- return this._tts;
510
- },
511
-
512
- set: function(tts) {
513
- this._tts = tts;
514
- }
515
500
  }
516
501
  });
517
502
 
@@ -653,8 +638,7 @@ define([
653
638
  resizable: this.resizable,
654
639
  wrapping: this.wrapping,
655
640
  previewHeight: this.previewHeight,
656
- binaryHeight: this.binaryHeight,
657
- tts: this.tts
641
+ binaryHeight: this.binaryHeight
658
642
  };
659
643
 
660
644
  Utils.extend(opts, options);
@@ -683,7 +667,6 @@ define([
683
667
  this._wrapping = opts.wrapping;
684
668
  this._previewHeight = opts.previewHeight;
685
669
  this._binaryHeight = opts.binaryHeight;
686
- this._tts = opts.tts;
687
670
 
688
671
  this._peaks.emit('source.update', this);
689
672
  };
@@ -136,7 +136,7 @@ define([
136
136
  options.textColor || '#000000',
137
137
  options.handleTextColor || '#000000',
138
138
  options.opacity || 1,
139
- true, // editable
139
+ options.editable,
140
140
  options.allowDeletion || false,
141
141
  options.line
142
142
  );
@@ -382,8 +382,11 @@ define([
382
382
  */
383
383
 
384
384
  TimelineSegments.prototype.removeAll = function(lineId) {
385
- this._segments = [];
386
- this._segmentsById = {};
385
+ var indexes = this._findSegment(function(segment) {
386
+ return segment.line === lineId;
387
+ });
388
+
389
+ this._removeIndexes(indexes);
387
390
  this._peaks.emit('segments.remove_all', lineId);
388
391
  };
389
392
 
@@ -87,8 +87,7 @@ define([
87
87
  resizable: sourceToCut.resizable,
88
88
  wrapping: sourceToCut.wrapping,
89
89
  previewHeight: sourceToCut.previewHeight,
90
- binaryHeight: sourceToCut.binaryHeight,
91
- tts: sourceToCut.tts
90
+ binaryHeight: sourceToCut.binaryHeight
92
91
  }]);
93
92
 
94
93
  this._peaks.emit('sources.updated');
@@ -160,8 +159,7 @@ define([
160
159
  options.resizable,
161
160
  options.wrapping,
162
161
  options.previewHeight,
163
- options.binaryHeight,
164
- options.tts
162
+ options.binaryHeight
165
163
  );
166
164
 
167
165
  return source;