src/widgets/Renkan.js
branchnew-model
changeset 941 1e64e46a954f
parent 938 991f897f1cb1
child 950 b7e236e4ec1c
equal deleted inserted replaced
940:9698ad710824 941:1e64e46a954f
    36         if (_annmatch) {
    36         if (_annmatch) {
    37             var _annotations = _list.filter(function(_ann) {
    37             var _annotations = _list.filter(function(_ann) {
    38                 return _ann.getMedia().id == _annmatch[1] && _ann.id == _annmatch[2];
    38                 return _ann.getMedia().id == _annmatch[1] && _ann.id == _annmatch[2];
    39             });
    39             });
    40             _annotations.forEach(function(_ann) {
    40             _annotations.forEach(function(_ann) {
       
    41                 var _duration = _ann.getDuration(),
       
    42                     _preroll = + ( _duration < _this.min_duration ) * ( _this.min_duration / 2);
       
    43                 var _nt = {
       
    44                     selected: false,
       
    45                     node: _node,
       
    46                     begin: _ann.begin - _preroll,
       
    47                     end: _ann.end + _preroll
       
    48                 }
       
    49                 _this.node_times.push(_nt);
    41                 _ann.on("select", function(_stop) {
    50                 _ann.on("select", function(_stop) {
    42                     if (!_stop) {
    51                     if (!_stop) {
    43                         _node.trigger("select",true);
    52                         _node.trigger("select",true);
    44                     }
    53                     }
    45                 });
    54                 });
    52                     if (!_stop) {
    61                     if (!_stop) {
    53                         _node.trigger("unselect",true);
    62                         _node.trigger("unselect",true);
    54                     }
    63                     }
    55                 });
    64                 });
    56                 _node.on("unselect", function(_stop) {
    65                 _node.on("unselect", function(_stop) {
       
    66                     _nt.selected = false;
    57                     if (!_stop) {
    67                     if (!_stop) {
    58                         _ann.trigger("unselect",true);
    68                         _ann.trigger("unselect",true);
    59                     }
    69                     }
    60                 });
    70                 });
    61                 _node.on("click", function() {
    71                 _node.on("click", function() {
    62                     _this.player.popcorn.currentTime(_ann.begin.getSeconds());
    72                     _this.player.popcorn.currentTime(_ann.begin.getSeconds());
    63                     _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToAnnotation", _ann.id);
    73                     _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToAnnotation", _ann.id);
    64                 });
       
    65                 var _duration = _ann.getDuration(),
       
    66                     _preroll = + ( _duration < _this.min_duration ) * ( _this.min_duration / 2);
       
    67                 _this.node_times.push({
       
    68                     selected: false,
       
    69                     node: _node,
       
    70                     begin: _ann.begin - _preroll,
       
    71                     end: _ann.end + _preroll
       
    72                 });
    74                 });
    73             });
    75             });
    74         }
    76         }
    75         var _tagmatch = _uri.match(_this.tag_regexp);
    77         var _tagmatch = _uri.match(_this.tag_regexp);
    76         if (_tagmatch) {
    78         if (_tagmatch) {
    96                 _nt.selected = true;
    98                 _nt.selected = true;
    97                 _nt.node.trigger("select", true);
    99                 _nt.node.trigger("select", true);
    98             }
   100             }
    99         } else {
   101         } else {
   100             if (_nt.selected) {
   102             if (_nt.selected) {
   101                 _nt.selected = false;
       
   102                 _nt.node.trigger("unselect", true);
   103                 _nt.node.trigger("unselect", true);
   103             }
   104             }
   104         }
   105         }
   105     });
   106     });
   106 }
   107 }