src/js/widgets/createAnnotationWidget.js
changeset 852 eefb64f74a3f
parent 842 4ae2247a59f4
child 855 1be5beb4b196
equal deleted inserted replaced
846:a6de16e6a3a3 852:eefb64f74a3f
   103   });
   103   });
   104   
   104   
   105   // js_mod is a custom event because there's no simple way to test for a js
   105   // js_mod is a custom event because there's no simple way to test for a js
   106   // change in a textfield.                    
   106   // change in a textfield.                    
   107   this.selector.find(".Ldt-createAnnotation-Description")
   107   this.selector.find(".Ldt-createAnnotation-Description")
   108                .bind("propertychange keyup input paste click js_mod", IriSP.wrap(this, this.handleTextChanges))
   108                .bind("propertychange keyup input paste click js_mod", IriSP.wrap(this, this.handleTextChanges));
   109           .keyup(function(_e) {
       
   110               console.log(_e);
       
   111           });
       
   112                
   109                
   113   /* the cinecast version of the player is supposed to pause when the user clicks on the button */
   110   /* the cinecast version of the player is supposed to pause when the user clicks on the button */
   114 
   111 
   115   /* the cinecast version expects the user to comment on a defined segment.
   112   /* the cinecast version expects the user to comment on a defined segment.
   116      As the widget is always shown, we need a way to update it's content as
   113      As the widget is always shown, we need a way to update it's content as
   191         _contents = _field.val();
   188         _contents = _field.val();
   192     _contents = ( _rx.test(_contents)
   189     _contents = ( _rx.test(_contents)
   193         ? _contents.replace(_rx,"").replace("  "," ").trim()
   190         ? _contents.replace(_rx,"").replace("  "," ").trim()
   194         : _contents.trim() + " " + _keyword
   191         : _contents.trim() + " " + _keyword
   195     );
   192     );
   196     _field.val(_contents.trim());
   193     _field.val(_contents.trim()).trigger("js_mod");
   197     _field.trigger("js_mod");
       
   198 }
   194 }
   199 
   195 
   200 /** handles clicks on the annotate button. Works only for the non-cinecast version */
   196 /** handles clicks on the annotate button. Works only for the non-cinecast version */
   201 IriSP.createAnnotationWidget.prototype.handleAnnotateSignal = function() {
   197 IriSP.createAnnotationWidget.prototype.handleAnnotateSignal = function() {
   202   
   198   
   496                         annotation.type = "cinecast:UserAnnotation";
   492                         annotation.type = "cinecast:UserAnnotation";
   497                     }
   493                     }
   498                     annotation.is_new = true;
   494                     annotation.is_new = true;
   499                     // everything is shared so there's no need to propagate the change
   495                     // everything is shared so there's no need to propagate the change
   500                     _this._serializer._data.annotations.push(annotation);
   496                     _this._serializer._data.annotations.push(annotation);
   501  
       
   502                     _this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation", annotation);
   497                     _this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation", annotation);
   503                     this.selector.find(".Ldt-createAnnotation-Description").val("");
   498                     this.selector.find(".Ldt-createAnnotation-Description").val("").trigger("js_mod");
   504                     callback(annotation);
   499                     callback(annotation);
   505       }), 
   500       }), 
   506       error: 
   501       error: 
   507               function(jqXHR, textStatus, errorThrown) { 
   502               function(jqXHR, textStatus, errorThrown) { 
   508                             console.log("an error occured while contacting " 
   503                             console.log("an error occured while contacting "