src/widgets/Renkan.js
branchnew-model
changeset 941 1e64e46a954f
parent 938 991f897f1cb1
child 950 b7e236e4ec1c
--- a/src/widgets/Renkan.js	Wed Aug 29 18:55:55 2012 +0200
+++ b/src/widgets/Renkan.js	Thu Aug 30 12:51:04 2012 +0200
@@ -38,6 +38,15 @@
                 return _ann.getMedia().id == _annmatch[1] && _ann.id == _annmatch[2];
             });
             _annotations.forEach(function(_ann) {
+                var _duration = _ann.getDuration(),
+                    _preroll = + ( _duration < _this.min_duration ) * ( _this.min_duration / 2);
+                var _nt = {
+                    selected: false,
+                    node: _node,
+                    begin: _ann.begin - _preroll,
+                    end: _ann.end + _preroll
+                }
+                _this.node_times.push(_nt);
                 _ann.on("select", function(_stop) {
                     if (!_stop) {
                         _node.trigger("select",true);
@@ -54,6 +63,7 @@
                     }
                 });
                 _node.on("unselect", function(_stop) {
+                    _nt.selected = false;
                     if (!_stop) {
                         _ann.trigger("unselect",true);
                     }
@@ -62,14 +72,6 @@
                     _this.player.popcorn.currentTime(_ann.begin.getSeconds());
                     _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToAnnotation", _ann.id);
                 });
-                var _duration = _ann.getDuration(),
-                    _preroll = + ( _duration < _this.min_duration ) * ( _this.min_duration / 2);
-                _this.node_times.push({
-                    selected: false,
-                    node: _node,
-                    begin: _ann.begin - _preroll,
-                    end: _ann.end + _preroll
-                });
             });
         }
         var _tagmatch = _uri.match(_this.tag_regexp);
@@ -98,7 +100,6 @@
             }
         } else {
             if (_nt.selected) {
-                _nt.selected = false;
                 _nt.node.trigger("unselect", true);
             }
         }