summaryrefslogtreecommitdiffstats
path: root/assets/js/collections/samples.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/collections/samples.js')
-rw-r--r--assets/js/collections/samples.js38
1 files changed, 37 insertions, 1 deletions
diff --git a/assets/js/collections/samples.js b/assets/js/collections/samples.js
index bd0b926..5965dbd 100644
--- a/assets/js/collections/samples.js
+++ b/assets/js/collections/samples.js
@@ -1,3 +1,39 @@
ClipPlay.Collections.Samples = Backbone.Collection.extend({
- model: ClipPlay.Models.Sample
+ model: ClipPlay.Models.Sample,
+
+ // -----------------------------------------------------------------------
+ // What follows is WRONG. Change so that the following functions don't use
+ // any DOM elements
+ // -----------------------------------------------------------------------
+
+ // percentage_progress
+ //
+ // Get a percentage value from a clip-line that represents its
+ // position within the progress bar.
+ //
+ percentage_progress: function($el) {
+ var container = $el.parents('.progress-bar');
+ var position_in_pixels = $el.css('left');
+
+ var percentage = (position_in_pixels / container.width()) * 100;
+
+ return percentage;
+ },
+
+
+ // seek_point
+ //
+ // Example:
+ // sample_editor.seek_point({
+ // $el: $('.clip-line'),
+ // video_length: 586
+ // });
+ //
+ seek_point: function(options) {
+ var options = options || {};
+
+ var progress = this.percentage_progress(options.$el);
+
+ return (progress * options.video_length) / 100;
+ }
}); \ No newline at end of file