From 5fae9d22133316400156f421cfa5b1ff24807645 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 12 Feb 2014 13:39:50 +0530 Subject: [PATCH] clip panel: add selectClipAtPosition --- source/Ox.UI/js/Video/ClipPanel.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/source/Ox.UI/js/Video/ClipPanel.js b/source/Ox.UI/js/Video/ClipPanel.js index 369d7d8c..8aebc04b 100644 --- a/source/Ox.UI/js/Video/ClipPanel.js +++ b/source/Ox.UI/js/Video/ClipPanel.js @@ -41,6 +41,9 @@ Ox.ClipPanel = function(options, self) { sort: getListSort(), sortable: isSortable() }); + self.$menu[ + self.options.clips.length ? 'enableItem' : 'disableItem' + ]('select'); updateStatus(); }, duration: updateStatus, @@ -170,11 +173,11 @@ Ox.ClipPanel = function(options, self) { {id: 'annotations', title: Ox._('View Annotations'), checked: self.options.view == 'annotations'}, ]}, {}, - {id: 'select', title: 'Select Clip at Current Position', disabled: true}, + {id: 'select', title: 'Select Clip at Current Position', disabled: self.options.clips.length == 0}, {}, - {id: 'split', title: Ox._('Split Selected Clips at Cuts'), disabled: !self.options.editable || !self.options.selected.length || self.options.view == 'annotations'}, + {id: 'split', title: Ox._('Split Selected Clips at Cuts'), disabled: !self.options.editable || self.options.selected.length == 0 || self.options.view == 'annotations'}, {id: 'join', title: Ox._('Join Selected Clips at Cuts'), disabled: !self.options.editable || self.options.selected.length < 2 || self.options.view == 'annotations'}, - {id: 'replace', title: Ox._('Make Selected Clips Editable'), disabled: !self.options.editable || !self.options.selected.length || self.options.view == 'annotations'} + {id: 'replace', title: Ox._('Make Selected Clips Editable'), disabled: !self.options.editable || self.options.selected.length == 0 || self.options.view == 'annotations'} ], title: 'set', tooltip: Ox._('Options'), @@ -518,7 +521,7 @@ Ox.ClipPanel = function(options, self) { } }); if (joined) { - return false; // brea; + return false; // break; } }); } while (joined); @@ -531,6 +534,19 @@ Ox.ClipPanel = function(options, self) { } } + function selectClipAtPosition() { + var index; + Ox.forEach(self.options.clips, function(clip, i) { + index = i; + if (clip.position + clip.duration < self.options.position) { + return false; // break + } + }); + self.options.selected = [self.options.clips[index].id]; + selectClips(); + that.triggerEvent('select', {ids: self.options.selected}); + } + function selectClips() { if (self.options.editable) { self.$menu[