src/widgets/AnnotationsController.js
changeset 1048 13211bca0256
parent 1046 eb77616c245f
child 1069 2409cb4cebaf
equal deleted inserted replaced
1047:c3bf174e0ef8 1048:13211bca0256
    19 };
    19 };
    20 
    20 
    21 IriSP.Widgets.AnnotationsController.prototype.template = 
    21 IriSP.Widgets.AnnotationsController.prototype.template = 
    22     "<div class='Ldt-AnnotationsController'>"
    22     "<div class='Ldt-AnnotationsController'>"
    23     + "<div class='Ldt-AnnotationsController-ButtonsContainer'>"
    23     + "<div class='Ldt-AnnotationsController-ButtonsContainer'>"
       
    24     + "    <div class='Ldt-AnnotationsController-Button Ldt-AnnotationsController-ShowCreateAnnotationButton'>{{l10n.write}}</div>"
    24     + "    <div class='Ldt-AnnotationsController-Button Ldt-AnnotationsController-ShowAnnotationsListButton'>{{l10n.display}}</div>"
    25     + "    <div class='Ldt-AnnotationsController-Button Ldt-AnnotationsController-ShowAnnotationsListButton'>{{l10n.display}}</div>"
    25     + "    <div class='Ldt-AnnotationsController-Button Ldt-AnnotationsController-ShowCreateAnnotationButton'>{{l10n.write}}</div>"
       
    26     + "</div>"
    26     + "</div>"
    27     + "</div>"
    27     + "</div>"
    28 
    28 
    29 IriSP.Widgets.AnnotationsController.prototype.messages = {
    29 IriSP.Widgets.AnnotationsController.prototype.messages = {
    30     en : {
    30     en : {
    44     
    44     
    45     this.displayButton_$ = this.$.find(".Ldt-AnnotationsController-ShowAnnotationsListButton");
    45     this.displayButton_$ = this.$.find(".Ldt-AnnotationsController-ShowAnnotationsListButton");
    46     this.writeButton_$ = this.$.find(".Ldt-AnnotationsController-ShowCreateAnnotationButton");
    46     this.writeButton_$ = this.$.find(".Ldt-AnnotationsController-ShowCreateAnnotationButton");
    47     
    47     
    48     this.writeButton_$.click(function(){
    48     this.writeButton_$.click(function(){
    49         _this.player.trigger("CreateAnnotation.toggle");
    49         if (!_this.writeButton_$.hasClass("selected")){
       
    50             _this.player.trigger("CreateAnnotation.show")
       
    51         }
       
    52         else {
       
    53             _this.player.trigger("CreateAnnotation.hide")
       
    54         }
    50         if (_this.display_or_write){
    55         if (_this.display_or_write){
    51             _this.player.trigger("AnnotationsList.hide");
    56             _this.player.trigger("AnnotationsList.hide");
    52         }
    57         }
    53     });
    58     });
    54     this.displayButton_$.click(function(){
    59     this.displayButton_$.click(function(){
    55         _this.player.trigger("AnnotationsList.toggle");
    60         if (!_this.displayButton_$.hasClass("selected")){
       
    61             _this.player.trigger("AnnotationsList.show")
       
    62         }
       
    63         else {
       
    64             _this.player.trigger("AnnotationsList.hide")
       
    65         }
    56         if (_this.display_or_write){
    66         if (_this.display_or_write){
    57             _this.player.trigger("CreateAnnotation.hide");
    67             _this.player.trigger("CreateAnnotation.hide");
    58         }
    68         }
    59     })
    69     })
    60     
    70     
    66             _this.refresh(_timeRange);
    76             _this.refresh(_timeRange);
    67         })
    77         })
    68         this.segments = this.source.getAnnotationsByTypeTitle(this.segments_annotation_type)
    78         this.segments = this.source.getAnnotationsByTypeTitle(this.segments_annotation_type)
    69         this.currentSegment = false
    79         this.currentSegment = false
    70     }
    80     }
       
    81     
       
    82     this.onMdpEvent("CreateAnnotation.hide", function(){
       
    83         _this.writeButton_$.toggleClass("selected", false);
       
    84     })
       
    85     this.onMdpEvent("CreateAnnotation.show", function(){
       
    86         _this.writeButton_$.toggleClass("selected", true);
       
    87     })
       
    88     this.onMdpEvent("AnnotationsList.hide", function(){
       
    89         _this.displayButton_$.toggleClass("selected", false);
       
    90     })
       
    91     this.onMdpEvent("AnnotationsList.show", function(){
       
    92         _this.displayButton_$.toggleClass("selected", true);
       
    93     })
    71     
    94     
    72     if (this.starts_hidden) {
    95     if (this.starts_hidden) {
    73         this.visible = true
    96         this.visible = true
    74         this.hide();
    97         this.hide();
    75     }
    98     }
   116             }
   139             }
   117         }
   140         }
   118         if (!currentSegment && _currentSegments.length == 0){
   141         if (!currentSegment && _currentSegments.length == 0){
   119             if (this.visible){
   142             if (this.visible){
   120                 this.hide();
   143                 this.hide();
       
   144                 this.writeButton_$.toggleClass("selected", false);
       
   145                 this.displayButton_$.toggleClass("selected", false);
   121                 this.player.trigger("CreateAnnotation.hide");
   146                 this.player.trigger("CreateAnnotation.hide");
   122                 this.player.trigger("AnnotationsList.hide");
   147                 this.player.trigger("AnnotationsList.hide");
   123             }
   148             }
   124         }
   149         }
   125         else {
   150         else {
   126             if (!this.visible){
   151             if (!this.visible){
   127                 this.show();
   152                 this.show();
       
   153                 this.writeButton_$.toggleClass("selected", false);
       
   154                 this.displayButton_$.toggleClass("selected", false);
   128                 this.player.trigger("CreateAnnotation.hide");
   155                 this.player.trigger("CreateAnnotation.hide");
   129                 this.player.trigger("AnnotationsList.hide");
   156                 this.player.trigger("AnnotationsList.hide");
   130             }
   157             }
   131         }
   158         }
   132     }
   159     }