src/js/widgets/createAnnotationWidget.js
branchpopcorn-port
changeset 722 ed12570ebd64
parent 721 0c53eba54b11
child 759 4dc3240f2c56
equal deleted inserted replaced
721:0c53eba54b11 722:ed12570ebd64
    73   if(this.polemic_mode)
    73   if(this.polemic_mode)
    74     for (var polemic in this.polemics) {
    74     for (var polemic in this.polemics) {
    75 
    75 
    76       var classname = IriSP.templToHTML("Ldt-createAnnotation-polemic-{{classname}}", {classname : this.polemics[polemic]});
    76       var classname = IriSP.templToHTML("Ldt-createAnnotation-polemic-{{classname}}", {classname : this.polemics[polemic]});
    77 
    77 
    78       var templ = IriSP.templToHTML("<button class='{{classname}}'>{{polemic}}</button>",
    78       var templ = IriSP.templToHTML("<button class='{{classname}} Ldt-createAnnotation-polemic-button'>{{polemic}}</button>",
    79                   {classname: classname, polemic: polemic});
    79                   {classname: classname, polemic: polemic});
    80                   
    80                   
    81       this.selector.find(".Ldt-createAnnotation-polemics").append(templ);
    81       this.selector.find(".Ldt-createAnnotation-polemics").append(templ);
    82       this.selector.find("." + classname).click(function(polemic) { return function() {
    82       this.selector.find("." + classname).click(function(polemic) { return function() {
    83           var contents = _this.selector.find(".Ldt-createAnnotation-Description").val();
    83           var contents = _this.selector.find(".Ldt-createAnnotation-Description").val();
   133           continue;
   133           continue;
   134       }
   134       }
   135       
   135       
   136       code = {start: annotation.begin / 1000, end: annotation.end / 1000,
   136       code = {start: annotation.begin / 1000, end: annotation.end / 1000,
   137               onStart: function(annotation) { return function() {
   137               onStart: function(annotation) { return function() {
       
   138                       console.log("runned ?", annotation);
   138                       if (typeof(annotation.content) !== "undefined")
   139                       if (typeof(annotation.content) !== "undefined")
   139                         _this.selector.find(".Ldt-createAnnotation-Title").html(annotation.content.title);
   140                         _this.selector.find(".Ldt-createAnnotation-Title").html(annotation.content.title);
   140 
   141 
   141                       _this._currentAnnotation = annotation;
   142                       _this._currentAnnotation = annotation;
   142                       var beginTime = IriSP.msToTime(annotation.begin);
   143                       var beginTime = IriSP.msToTime(annotation.begin);
   202     this.sliceLeft = left;
   203     this.sliceLeft = left;
   203     this.sliceWidth = width;
   204     this.sliceWidth = width;
   204     this._Popcorn.trigger("IriSP.SliceWidget.position", [left, width]);
   205     this._Popcorn.trigger("IriSP.SliceWidget.position", [left, width]);
   205     this._Popcorn.listen("IriSP.SliceWidget.zoneChange", IriSP.wrap(this, this.handleSliderChanges));
   206     this._Popcorn.listen("IriSP.SliceWidget.zoneChange", IriSP.wrap(this, this.handleSliderChanges));
   206     this._Popcorn.trigger("IriSP.SliceWidget.show");
   207     this._Popcorn.trigger("IriSP.SliceWidget.show");
       
   208     
       
   209     this.selector.find(".Ldt-createAnnotation-Title").html(currentChapter.content.title);
       
   210 
       
   211     this._currentcurrentChapter = currentChapter;
       
   212     var beginTime = IriSP.msToTime(currentChapter.begin);
       
   213     var endTime = IriSP.msToTime(currentChapter.end);
       
   214     var timeTemplate = IriSP.templToHTML("- ({{begin}} - {{ end }})", {begin: beginTime, end: endTime });
       
   215     this.selector.find(".Ldt-createAnnotation-TimeFrame").html(timeTemplate);
   207   }
   216   }
   208 };
   217 };
   209 
   218 
   210 
   219 
   211 /** watch for changes in the textfield and change the buttons accordingly */
   220 /** watch for changes in the textfield and change the buttons accordingly */
   224     } else {
   233     } else {
   225       /* the word is absent from the textarea but the button is toggled */
   234       /* the word is absent from the textarea but the button is toggled */
   226       if (this.selector.find("#" + id).hasClass("Ldt-createAnnotation-present-keyword")) {
   235       if (this.selector.find("#" + id).hasClass("Ldt-createAnnotation-present-keyword")) {
   227           this.selector.find("#" + id).removeClass("Ldt-createAnnotation-present-keyword")
   236           this.selector.find("#" + id).removeClass("Ldt-createAnnotation-present-keyword")
   228                                       .addClass("Ldt-createAnnotation-absent-keyword");
   237                                       .addClass("Ldt-createAnnotation-absent-keyword");
       
   238       }
       
   239     }
       
   240   }
       
   241   
       
   242   if (this.polemic_mode) {
       
   243     /* Also go through the polemics to highlight the buttons */
       
   244     for (var polemic in this.polemics) {
       
   245       /* Add the active class to the button */
       
   246       var classname = "Ldt-createAnnotation-polemic-" + this.polemics[polemic];
       
   247       if (contents.indexOf(polemic) != -1) {        
       
   248         this.selector.find("." + classname).addClass("Ldt-createAnnotation-polemic-active");
       
   249       } else {
       
   250         if (this.selector.find("." + classname).addClass("Ldt-createAnnotation-polemic-active"))
       
   251           this.selector.find("." + classname).removeClass("Ldt-createAnnotation-polemic-active")
   229       }
   252       }
   230     }
   253     }
   231   }
   254   }
   232 };
   255 };
   233 
   256