@checksub_team/peaks_timeline 1.5.4 → 1.5.6

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.5.4",
3
+ "version": "1.5.6",
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
@@ -16331,9 +16331,9 @@ module.exports = function (Konva, SegmentMarker, Utils) {
16331
16331
  this._rectangle = new Konva.Rect({
16332
16332
  width: width,
16333
16333
  height: this._segmentHeight,
16334
- cornerRadius: SEGMENT_CORNER_RADIUS,
16335
- stroke: segment.textColor + 'FF',
16336
- strokeWidth: 2,
16334
+ cornerRadius: this._cornerRadius(),
16335
+ stroke: segment.borderColor || segment.textColor + 'FF',
16336
+ strokeWidth: segment.borderWidth !== undefined && segment.borderWidth !== null ? segment.borderWidth : 2,
16337
16337
  fillPriority: segment.shouldShowWarning() ? 'linear-gradient' : 'color',
16338
16338
  fill: fillColor,
16339
16339
  fillLinearGradientColorStops: [
@@ -16379,6 +16379,9 @@ module.exports = function (Konva, SegmentMarker, Utils) {
16379
16379
  this._shapeGroup.add(this._indicatorsGroup);
16380
16380
  this.createIndicators();
16381
16381
  }
16382
+ SegmentShape.prototype._cornerRadius = function () {
16383
+ return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ? this._segment.borderRadius : SEGMENT_CORNER_RADIUS;
16384
+ };
16382
16385
  SegmentShape.prototype.update = function () {
16383
16386
  var startPixel = this._view.timeToPixels(this._segment.startTime);
16384
16387
  var endPixel = this._view.timeToPixels(this._segment.endTime);
@@ -16629,16 +16632,17 @@ module.exports = function (Konva, SegmentMarker, Utils) {
16629
16632
  }
16630
16633
  };
16631
16634
  SegmentShape.prototype._drawRect = function (ctx) {
16635
+ var cornerRadius = this._cornerRadius();
16632
16636
  ctx.beginPath();
16633
- ctx.moveTo(SEGMENT_CORNER_RADIUS + 1.5, 0);
16634
- ctx.lineTo(this._segmentWidth - SEGMENT_CORNER_RADIUS - 1.5, 0);
16635
- ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth, SEGMENT_CORNER_RADIUS + 1.5);
16636
- ctx.lineTo(this._segmentWidth, this._segmentHeight - SEGMENT_CORNER_RADIUS - 1.5);
16637
- ctx.quadraticCurveTo(this._segmentWidth, this._segmentHeight, this._segmentWidth - SEGMENT_CORNER_RADIUS - 1.5, this._segmentHeight);
16638
- ctx.lineTo(SEGMENT_CORNER_RADIUS + 1.5, this._segmentHeight);
16639
- ctx.quadraticCurveTo(0, this._segmentHeight, 0, this._segmentHeight - SEGMENT_CORNER_RADIUS - 1.5);
16640
- ctx.lineTo(0, SEGMENT_CORNER_RADIUS + 1.5);
16641
- ctx.quadraticCurveTo(0, 0, SEGMENT_CORNER_RADIUS + 1.5, 0);
16637
+ ctx.moveTo(cornerRadius + 1.5, 0);
16638
+ ctx.lineTo(this._segmentWidth - cornerRadius - 1.5, 0);
16639
+ ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth, cornerRadius + 1.5);
16640
+ ctx.lineTo(this._segmentWidth, this._segmentHeight - cornerRadius - 1.5);
16641
+ ctx.quadraticCurveTo(this._segmentWidth, this._segmentHeight, this._segmentWidth - cornerRadius - 1.5, this._segmentHeight);
16642
+ ctx.lineTo(cornerRadius + 1.5, this._segmentHeight);
16643
+ ctx.quadraticCurveTo(0, this._segmentHeight, 0, this._segmentHeight - cornerRadius - 1.5);
16644
+ ctx.lineTo(0, cornerRadius + 1.5);
16645
+ ctx.quadraticCurveTo(0, 0, cornerRadius + 1.5, 0);
16642
16646
  ctx.closePath();
16643
16647
  };
16644
16648
  return SegmentShape;
@@ -16698,7 +16702,7 @@ module.exports = function (Utils) {
16698
16702
  }
16699
16703
  return shouldNotifyUpdate;
16700
16704
  }
16701
- function Segment(peaks, id, startTime, endTime, duration, labelText, color, textColor, handleTextColor, hoverColor, warningColor, opacity, editable, allowDeletion, line, indicators) {
16705
+ function Segment(peaks, id, startTime, endTime, duration, labelText, color, textColor, handleTextColor, hoverColor, warningColor, opacity, borderColor, borderWidth, borderRadius, editable, allowDeletion, line, indicators) {
16702
16706
  var opts = {
16703
16707
  startTime: startTime,
16704
16708
  endTime: endTime,
@@ -16710,6 +16714,9 @@ module.exports = function (Utils) {
16710
16714
  hoverColor: hoverColor,
16711
16715
  warningColor: warningColor,
16712
16716
  opacity: opacity,
16717
+ borderColor: borderColor,
16718
+ borderWidth: borderWidth,
16719
+ borderRadius: borderRadius,
16713
16720
  editable: editable,
16714
16721
  allowDeletion: allowDeletion,
16715
16722
  line: line,
@@ -16728,6 +16735,9 @@ module.exports = function (Utils) {
16728
16735
  this._handleTextColor = opts.handleTextColor;
16729
16736
  this._warningColor = opts.warningColor;
16730
16737
  this._opacity = opts.opacity;
16738
+ this._borderColor = opts.borderColor;
16739
+ this._borderWidth = opts.borderWidth;
16740
+ this._borderRadius = opts.borderRadius;
16731
16741
  this._editable = opts.editable;
16732
16742
  this._allowDeletion = opts.allowDeletion;
16733
16743
  this._line = opts.line;
@@ -16814,6 +16824,24 @@ module.exports = function (Utils) {
16814
16824
  return this._opacity;
16815
16825
  }
16816
16826
  },
16827
+ borderColor: {
16828
+ enumerable: true,
16829
+ get: function () {
16830
+ return this._borderColor;
16831
+ }
16832
+ },
16833
+ borderWidth: {
16834
+ enumerable: true,
16835
+ get: function () {
16836
+ return this._borderWidth;
16837
+ }
16838
+ },
16839
+ borderRadius: {
16840
+ enumerable: true,
16841
+ get: function () {
16842
+ return this._borderRadius;
16843
+ }
16844
+ },
16817
16845
  editable: {
16818
16846
  enumerable: true,
16819
16847
  get: function () {
@@ -16866,6 +16894,9 @@ module.exports = function (Utils) {
16866
16894
  hoverColor: this.hoverColor,
16867
16895
  warningColor: this.warningColor,
16868
16896
  opacity: this.opacity,
16897
+ borderColor: this.borderColor,
16898
+ borderWidth: this.borderWidth,
16899
+ borderRadius: this.borderRadius,
16869
16900
  editable: this.editable,
16870
16901
  allowDeletion: this.allowDeletion,
16871
16902
  line: this.line,
@@ -16883,6 +16914,9 @@ module.exports = function (Utils) {
16883
16914
  this._hoverColor = opts.hoverColor;
16884
16915
  this._warningColor = opts.warningColor;
16885
16916
  this._opacity = opts.opacity;
16917
+ this._borderColor = opts.borderColor;
16918
+ this._borderWidth = opts.borderWidth;
16919
+ this._borderRadius = opts.borderRadius;
16886
16920
  this._editable = opts.editable;
16887
16921
  this._allowDeletion = opts.allowDeletion;
16888
16922
  this._line = opts.line;
@@ -17535,6 +17569,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17535
17569
  this.unwrap();
17536
17570
  this._height = this._unwrappedHeight;
17537
17571
  }
17572
+ if (this._title) {
17573
+ this._title.y(this._getTitleY());
17574
+ }
17538
17575
  this.setHandlesWrapping(wrap);
17539
17576
  };
17540
17577
  SourceGroup.prototype.setHandlesWrapping = function (wrap) {
@@ -17638,7 +17675,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17638
17675
  }
17639
17676
  };
17640
17677
  SourceGroup.prototype.drawSourceShape = function (ctx, shape) {
17641
- var radius = Math.max(1, Math.min(this._width / 2, Math.min(CORNER_RADIUS, this._height / 2)));
17678
+ var radius = this._source.borderRadius !== undefined && this._source.borderRadius !== null ? this._source.borderRadius : Math.max(1, Math.min(this._width / 2, Math.min(CORNER_RADIUS, this._height / 2)));
17642
17679
  var x = Math.max(0, this._view.getFrameOffset() - this._x - radius);
17643
17680
  var width = Math.min(this._width - x, this._view.getOriginalWidth() + radius - Math.max(0, this._x - this._view.getFrameOffset()));
17644
17681
  var xWidth = x + width;
@@ -17760,6 +17797,16 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
17760
17797
  }
17761
17798
  this._group.add(this._title);
17762
17799
  };
17800
+ SourceGroup.prototype._getTitleY = function () {
17801
+ if (!this._title) {
17802
+ return 0;
17803
+ }
17804
+ if (this._source.textPosition === 'bottom') {
17805
+ return Math.max(this._height - this._title.getClientRect().height - 5, 5);
17806
+ } else {
17807
+ return 5;
17808
+ }
17809
+ };
17763
17810
  SourceGroup.prototype._createTitle = function () {
17764
17811
  var title = new Konva.Text({
17765
17812
  x: 5,
@@ -18217,6 +18264,11 @@ module.exports = function (Utils) {
18217
18264
  } else if (!Utils.isValidColor(options.textColor)) {
18218
18265
  throw new TypeError('peaks.sources.' + context + ': textColor should be a valid CSS color');
18219
18266
  }
18267
+ if (Utils.isNullOrUndefined(options.textPosition)) {
18268
+ options.textPosition = 'bottom';
18269
+ } else if (!Utils.isString(options.textPosition)) {
18270
+ throw new TypeError('peaks.sources.' + context + ': textPosition must be a string');
18271
+ }
18220
18272
  if (Utils.isNullOrUndefined(options.borderWidth)) {
18221
18273
  options.borderWidth = 0;
18222
18274
  }
@@ -18269,7 +18321,7 @@ module.exports = function (Utils) {
18269
18321
  options.wrapped = false;
18270
18322
  }
18271
18323
  }
18272
- function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable, wrapping, previewHeight, binaryHeight) {
18324
+ function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, textColor, textPosition, borderWidth, borderRadius, wrapped, position, draggable, resizable, wrapping, previewHeight, binaryHeight) {
18273
18325
  var opts = {
18274
18326
  title: title,
18275
18327
  url: url,
@@ -18287,7 +18339,9 @@ module.exports = function (Utils) {
18287
18339
  borderColor: borderColor,
18288
18340
  selectedColor: selectedColor,
18289
18341
  textColor: textColor,
18342
+ textPosition: textPosition,
18290
18343
  borderWidth: borderWidth,
18344
+ borderRadius: borderRadius,
18291
18345
  wrapped: wrapped,
18292
18346
  position: position,
18293
18347
  draggable: draggable,
@@ -18317,7 +18371,9 @@ module.exports = function (Utils) {
18317
18371
  this._borderColor = opts.borderColor;
18318
18372
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
18319
18373
  this._textColor = opts.textColor;
18374
+ this._textPosition = opts.textPosition;
18320
18375
  this._borderWidth = opts.borderWidth;
18376
+ this._borderRadius = opts.borderRadius;
18321
18377
  this._wrapped = opts.wrapped;
18322
18378
  this._position = opts.position;
18323
18379
  this._draggable = opts.draggable;
@@ -18472,6 +18528,15 @@ module.exports = function (Utils) {
18472
18528
  this._textColor = textColor;
18473
18529
  }
18474
18530
  },
18531
+ textPosition: {
18532
+ enumerable: true,
18533
+ get: function () {
18534
+ return this._textPosition;
18535
+ },
18536
+ set: function (textPosition) {
18537
+ this._textPosition = textPosition;
18538
+ }
18539
+ },
18475
18540
  borderWidth: {
18476
18541
  enumerable: true,
18477
18542
  get: function () {
@@ -18481,6 +18546,15 @@ module.exports = function (Utils) {
18481
18546
  this._borderWidth = borderWidth;
18482
18547
  }
18483
18548
  },
18549
+ borderRadius: {
18550
+ enumerable: true,
18551
+ get: function () {
18552
+ return this._borderRadius;
18553
+ },
18554
+ set: function (borderRadius) {
18555
+ this._borderRadius = borderRadius;
18556
+ }
18557
+ },
18484
18558
  wrapped: {
18485
18559
  enumerable: true,
18486
18560
  get: function () {
@@ -18653,7 +18727,9 @@ module.exports = function (Utils) {
18653
18727
  borderColor: this.borderColor,
18654
18728
  selectedColor: this.selectedColor,
18655
18729
  textColor: this.textColor,
18730
+ textPosition: this.textPosition,
18656
18731
  borderWidth: this.borderWidth,
18732
+ borderRadius: this.borderRadius,
18657
18733
  wrapped: this.wrapped,
18658
18734
  position: this.position,
18659
18735
  draggable: this.draggable,
@@ -18680,7 +18756,9 @@ module.exports = function (Utils) {
18680
18756
  this._borderColor = opts.borderColor;
18681
18757
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
18682
18758
  this._textColor = opts.textColor;
18759
+ this._textPosition = opts.textPosition;
18683
18760
  this._borderWidth = opts.borderWidth;
18761
+ this._borderRadius = opts.borderRadius;
18684
18762
  this._wrapped = opts.wrapped;
18685
18763
  this._position = opts.position;
18686
18764
  this._draggable = opts.draggable;
@@ -19233,7 +19311,7 @@ module.exports = function (Colors, Segment, Utils) {
19233
19311
  if (!Utils.isObject(options)) {
19234
19312
  throw new TypeError('peaks.segments.add(): expected a Segment object parameter');
19235
19313
  }
19236
- var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.duration, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.hoverColor, options.warningColor, options.opacity || 1, options.editable, options.allowDeletion || false, options.line, options.indicators);
19314
+ var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.duration, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.hoverColor, options.warningColor, options.opacity || 1, options.borderColor, options.borderWidth, options.borderRadius, options.editable, options.allowDeletion || false, options.line, options.indicators);
19237
19315
  return segment;
19238
19316
  };
19239
19317
  TimelineSegments.prototype.getSegments = function () {
@@ -19390,7 +19468,9 @@ module.exports = function (Source, Utils) {
19390
19468
  borderColor: sourceToCut.borderColor,
19391
19469
  selectedColor: sourceToCut.selectedColor,
19392
19470
  textColor: sourceToCut.textColor,
19471
+ textPosition: sourceToCut.textPosition,
19393
19472
  borderWidth: sourceToCut.borderWidth,
19473
+ borderRadius: sourceToCut.borderRadius,
19394
19474
  wrapped: sourceToCut.wrapped,
19395
19475
  position: sourceToCut.position,
19396
19476
  draggable: sourceToCut.draggable,
@@ -19412,7 +19492,7 @@ module.exports = function (Source, Utils) {
19412
19492
  if (!Utils.isObject(options)) {
19413
19493
  throw new TypeError('peaks.sources.add(): expected a Source object parameter');
19414
19494
  }
19415
- 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.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.borderColor, options.selectedColor, options.textColor, options.borderWidth, options.wrapped, options.position, options.draggable, options.resizable, options.wrapping, options.previewHeight, options.binaryHeight);
19495
+ 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.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.borderColor, options.selectedColor, options.textColor, options.textPosition, options.borderWidth, options.borderRadius, options.wrapped, options.position, options.draggable, options.resizable, options.wrapping, options.previewHeight, options.binaryHeight);
19416
19496
  return source;
19417
19497
  };
19418
19498
  TimelineSources.prototype.getSources = function () {
@@ -71,9 +71,11 @@ define([
71
71
  this._rectangle = new Konva.Rect({
72
72
  width: width,
73
73
  height: this._segmentHeight,
74
- cornerRadius: SEGMENT_CORNER_RADIUS,
75
- stroke: segment.textColor + 'FF',
76
- strokeWidth: 2,
74
+ cornerRadius: this._cornerRadius(),
75
+ stroke: segment.borderColor || segment.textColor + 'FF',
76
+ strokeWidth: segment.borderWidth !== undefined && segment.borderWidth !== null ?
77
+ segment.borderWidth :
78
+ 2,
77
79
  fillPriority: segment.shouldShowWarning() ? 'linear-gradient' : 'color',
78
80
  fill: fillColor,
79
81
  fillLinearGradientColorStops: [
@@ -136,6 +138,12 @@ define([
136
138
  this.createIndicators();
137
139
  }
138
140
 
141
+ SegmentShape.prototype._cornerRadius = function() {
142
+ return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ?
143
+ this._segment.borderRadius :
144
+ SEGMENT_CORNER_RADIUS;
145
+ };
146
+
139
147
  SegmentShape.prototype.update = function() {
140
148
  var startPixel = this._view.timeToPixels(this._segment.startTime);
141
149
  var endPixel = this._view.timeToPixels(this._segment.endTime);
@@ -475,23 +483,25 @@ define([
475
483
  };
476
484
 
477
485
  SegmentShape.prototype._drawRect = function(ctx) {
486
+ var cornerRadius = this._cornerRadius();
487
+
478
488
  ctx.beginPath();
479
- ctx.moveTo(SEGMENT_CORNER_RADIUS + 1.5, 0);
480
- ctx.lineTo(this._segmentWidth - SEGMENT_CORNER_RADIUS - 1.5, 0);
481
- ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth, SEGMENT_CORNER_RADIUS + 1.5);
482
- ctx.lineTo(this._segmentWidth, this._segmentHeight - SEGMENT_CORNER_RADIUS - 1.5);
489
+ ctx.moveTo(cornerRadius + 1.5, 0);
490
+ ctx.lineTo(this._segmentWidth - cornerRadius - 1.5, 0);
491
+ ctx.quadraticCurveTo(this._segmentWidth, 0, this._segmentWidth, cornerRadius + 1.5);
492
+ ctx.lineTo(this._segmentWidth, this._segmentHeight - cornerRadius - 1.5);
483
493
  ctx.quadraticCurveTo(
484
494
  this._segmentWidth,
485
495
  this._segmentHeight,
486
- this._segmentWidth - SEGMENT_CORNER_RADIUS - 1.5,
496
+ this._segmentWidth - cornerRadius - 1.5,
487
497
  this._segmentHeight
488
498
  );
489
- ctx.lineTo(SEGMENT_CORNER_RADIUS + 1.5, this._segmentHeight);
499
+ ctx.lineTo(cornerRadius + 1.5, this._segmentHeight);
490
500
  ctx.quadraticCurveTo(
491
- 0, this._segmentHeight, 0, this._segmentHeight - SEGMENT_CORNER_RADIUS - 1.5
501
+ 0, this._segmentHeight, 0, this._segmentHeight - cornerRadius - 1.5
492
502
  );
493
- ctx.lineTo(0, SEGMENT_CORNER_RADIUS + 1.5);
494
- ctx.quadraticCurveTo(0, 0, SEGMENT_CORNER_RADIUS + 1.5, 0);
503
+ ctx.lineTo(0, cornerRadius + 1.5);
504
+ ctx.quadraticCurveTo(0, 0, cornerRadius + 1.5, 0);
495
505
  ctx.closePath();
496
506
  };
497
507
 
package/src/segment.js CHANGED
@@ -105,7 +105,8 @@ define([
105
105
 
106
106
  function Segment(peaks, id, startTime, endTime, duration, labelText,
107
107
  color, textColor, handleTextColor, hoverColor, warningColor, opacity,
108
- editable, allowDeletion, line, indicators) {
108
+ borderColor, borderWidth, borderRadius, editable, allowDeletion, line,
109
+ indicators) {
109
110
  var opts = {
110
111
  startTime: startTime,
111
112
  endTime: endTime,
@@ -117,6 +118,9 @@ define([
117
118
  hoverColor: hoverColor,
118
119
  warningColor: warningColor,
119
120
  opacity: opacity,
121
+ borderColor: borderColor,
122
+ borderWidth: borderWidth,
123
+ borderRadius: borderRadius,
120
124
  editable: editable,
121
125
  allowDeletion: allowDeletion,
122
126
  line: line,
@@ -137,6 +141,9 @@ define([
137
141
  this._handleTextColor = opts.handleTextColor;
138
142
  this._warningColor = opts.warningColor;
139
143
  this._opacity = opts.opacity;
144
+ this._borderColor = opts.borderColor;
145
+ this._borderWidth = opts.borderWidth;
146
+ this._borderRadius = opts.borderRadius;
140
147
  this._editable = opts.editable;
141
148
  this._allowDeletion = opts.allowDeletion;
142
149
  this._line = opts.line;
@@ -228,6 +235,24 @@ define([
228
235
  return this._opacity;
229
236
  }
230
237
  },
238
+ borderColor: {
239
+ enumerable: true,
240
+ get: function() {
241
+ return this._borderColor;
242
+ }
243
+ },
244
+ borderWidth: {
245
+ enumerable: true,
246
+ get: function() {
247
+ return this._borderWidth;
248
+ }
249
+ },
250
+ borderRadius: {
251
+ enumerable: true,
252
+ get: function() {
253
+ return this._borderRadius;
254
+ }
255
+ },
231
256
  editable: {
232
257
  enumerable: true,
233
258
  get: function() {
@@ -281,6 +306,9 @@ define([
281
306
  hoverColor: this.hoverColor,
282
307
  warningColor: this.warningColor,
283
308
  opacity: this.opacity,
309
+ borderColor: this.borderColor,
310
+ borderWidth: this.borderWidth,
311
+ borderRadius: this.borderRadius,
284
312
  editable: this.editable,
285
313
  allowDeletion: this.allowDeletion,
286
314
  line: this.line,
@@ -301,6 +329,9 @@ define([
301
329
  this._hoverColor = opts.hoverColor;
302
330
  this._warningColor = opts.warningColor;
303
331
  this._opacity = opts.opacity;
332
+ this._borderColor = opts.borderColor;
333
+ this._borderWidth = opts.borderWidth;
334
+ this._borderRadius = opts.borderRadius;
304
335
  this._editable = opts.editable;
305
336
  this._allowDeletion = opts.allowDeletion;
306
337
  this._line = opts.line;
@@ -220,6 +220,10 @@ define([
220
220
  this._height = this._unwrappedHeight;
221
221
  }
222
222
 
223
+ if (this._title) {
224
+ this._title.y(this._getTitleY());
225
+ }
226
+
223
227
  this.setHandlesWrapping(wrap);
224
228
  };
225
229
 
@@ -343,16 +347,18 @@ define([
343
347
  };
344
348
 
345
349
  SourceGroup.prototype.drawSourceShape = function(ctx, shape) {
346
- var radius = Math.max(
347
- 1,
348
- Math.min(
349
- this._width / 2,
350
+ var radius = this._source.borderRadius !== undefined && this._source.borderRadius !== null ?
351
+ this._source.borderRadius :
352
+ Math.max(
353
+ 1,
350
354
  Math.min(
351
- CORNER_RADIUS,
352
- this._height / 2
355
+ this._width / 2,
356
+ Math.min(
357
+ CORNER_RADIUS,
358
+ this._height / 2
359
+ )
353
360
  )
354
- )
355
- );
361
+ );
356
362
  var x = Math.max(
357
363
  0,
358
364
  this._view.getFrameOffset() - this._x - radius
@@ -506,6 +512,19 @@ define([
506
512
  this._group.add(this._title);
507
513
  };
508
514
 
515
+ SourceGroup.prototype._getTitleY = function() {
516
+ if (!this._title) {
517
+ return 0;
518
+ }
519
+
520
+ if (this._source.textPosition === 'bottom') {
521
+ return Math.max(this._height - this._title.getClientRect().height - 5, 5);
522
+ }
523
+ else {
524
+ return 5;
525
+ }
526
+ };
527
+
509
528
  SourceGroup.prototype._createTitle = function() {
510
529
  var title = new Konva.Text({
511
530
  x: 5,
package/src/source.js CHANGED
@@ -134,6 +134,13 @@ define([
134
134
  throw new TypeError('peaks.sources.' + context + ': textColor should be a valid CSS color');
135
135
  }
136
136
 
137
+ if (Utils.isNullOrUndefined(options.textPosition)) {
138
+ options.textPosition = 'bottom';
139
+ }
140
+ else if (!Utils.isString(options.textPosition)) {
141
+ throw new TypeError('peaks.sources.' + context + ': textPosition must be a string');
142
+ }
143
+
137
144
  if (Utils.isNullOrUndefined(options.borderWidth)) {
138
145
  options.borderWidth = 0;
139
146
  }
@@ -227,8 +234,8 @@ define([
227
234
 
228
235
  function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind,
229
236
  subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor,
230
- borderColor, selectedColor, textColor, borderWidth, wrapped, position, draggable, resizable,
231
- wrapping, previewHeight, binaryHeight) {
237
+ borderColor, selectedColor, textColor, textPosition, borderWidth, borderRadius, wrapped,
238
+ position, draggable, resizable, wrapping, previewHeight, binaryHeight) {
232
239
  var opts = {
233
240
  title: title,
234
241
  url: url,
@@ -246,7 +253,9 @@ define([
246
253
  borderColor: borderColor,
247
254
  selectedColor: selectedColor,
248
255
  textColor: textColor,
256
+ textPosition: textPosition,
249
257
  borderWidth: borderWidth,
258
+ borderRadius: borderRadius,
250
259
  wrapped: wrapped,
251
260
  position: position,
252
261
  draggable: draggable,
@@ -278,7 +287,9 @@ define([
278
287
  this._borderColor = opts.borderColor;
279
288
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
280
289
  this._textColor = opts.textColor;
290
+ this._textPosition = opts.textPosition;
281
291
  this._borderWidth = opts.borderWidth;
292
+ this._borderRadius = opts.borderRadius;
282
293
  this._wrapped = opts.wrapped;
283
294
  this._position = opts.position;
284
295
  this._draggable = opts.draggable;
@@ -444,6 +455,16 @@ define([
444
455
  this._textColor = textColor;
445
456
  }
446
457
  },
458
+ textPosition: {
459
+ enumerable: true,
460
+ get: function() {
461
+ return this._textPosition;
462
+ },
463
+
464
+ set: function(textPosition) {
465
+ this._textPosition = textPosition;
466
+ }
467
+ },
447
468
  borderWidth: {
448
469
  enumerable: true,
449
470
  get: function() {
@@ -454,6 +475,16 @@ define([
454
475
  this._borderWidth = borderWidth;
455
476
  }
456
477
  },
478
+ borderRadius: {
479
+ enumerable: true,
480
+ get: function() {
481
+ return this._borderRadius;
482
+ },
483
+
484
+ set: function(borderRadius) {
485
+ this._borderRadius = borderRadius;
486
+ }
487
+ },
457
488
  wrapped: {
458
489
  enumerable: true,
459
490
  get: function() {
@@ -663,7 +694,9 @@ define([
663
694
  borderColor: this.borderColor,
664
695
  selectedColor: this.selectedColor,
665
696
  textColor: this.textColor,
697
+ textPosition: this.textPosition,
666
698
  borderWidth: this.borderWidth,
699
+ borderRadius: this.borderRadius,
667
700
  wrapped: this.wrapped,
668
701
  position: this.position,
669
702
  draggable: this.draggable,
@@ -693,7 +726,9 @@ define([
693
726
  this._borderColor = opts.borderColor;
694
727
  this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
695
728
  this._textColor = opts.textColor;
729
+ this._textPosition = opts.textPosition;
696
730
  this._borderWidth = opts.borderWidth;
731
+ this._borderRadius = opts.borderRadius;
697
732
  this._wrapped = opts.wrapped;
698
733
  this._position = opts.position;
699
734
  this._draggable = opts.draggable;
@@ -139,6 +139,9 @@ define([
139
139
  options.hoverColor,
140
140
  options.warningColor,
141
141
  options.opacity || 1,
142
+ options.borderColor,
143
+ options.borderWidth,
144
+ options.borderRadius,
142
145
  options.editable,
143
146
  options.allowDeletion || false,
144
147
  options.line,
@@ -82,7 +82,9 @@ define([
82
82
  borderColor: sourceToCut.borderColor,
83
83
  selectedColor: sourceToCut.selectedColor,
84
84
  textColor: sourceToCut.textColor,
85
+ textPosition: sourceToCut.textPosition,
85
86
  borderWidth: sourceToCut.borderWidth,
87
+ borderRadius: sourceToCut.borderRadius,
86
88
  wrapped: sourceToCut.wrapped,
87
89
  position: sourceToCut.position,
88
90
  draggable: sourceToCut.draggable,
@@ -156,7 +158,9 @@ define([
156
158
  options.borderColor,
157
159
  options.selectedColor,
158
160
  options.textColor,
161
+ options.textPosition,
159
162
  options.borderWidth,
163
+ options.borderRadius,
160
164
  options.wrapped,
161
165
  options.position,
162
166
  options.draggable,