src/js/widgets/createAnnotationWidget.js
author hamidouk
Thu, 29 Dec 2011 17:14:10 +0100
branchpopcorn-port
changeset 548 96a188138c20
parent 547 5b58a108086a
child 549 8abffd2de54a
permissions -rw-r--r--
refactored the code a bit.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
543
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
     1
IriSP.createAnnotationWidget = function(Popcorn, config, Serializer) {
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
     2
  IriSP.Widget.call(this, Popcorn, config, Serializer);
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
     3
  this._hidden = true;
547
5b58a108086a adding support for keywords.
hamidouk
parents: 543
diff changeset
     4
  this.keywords = IriSP.widgetsDefaults["createAnnotationWidget"].keywords;
543
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
     5
};
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
     6
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
     7
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
     8
IriSP.createAnnotationWidget.prototype = new IriSP.Widget();
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
     9
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    10
IriSP.createAnnotationWidget.prototype.clear = function() {
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    11
    this.selector.find(".Ldt-SaTitle").text("");
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    12
    this.selector.find(".Ldt-SaDescription").text("");
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    13
    this.selector.find(".Ldt-SaKeywordText").text("");
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    14
};
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    15
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    16
IriSP.createAnnotationWidget.prototype.showWidget = function() {
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    17
  this.layoutManager.slice.after("ArrowWidget")
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    18
                          .before("createAnnotationWidget")
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    19
                          .jQuerySelector().hide();
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    20
  this.selector.show();
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    21
};
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    22
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    23
IriSP.createAnnotationWidget.prototype.hideWidget = function() {
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    24
  this.selector.hide();
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    25
  this.layoutManager.slice.after("ArrowWidget")
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    26
                          .before("createAnnotationWidget")
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    27
                          .jQuerySelector().show();
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    28
};
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    29
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    30
IriSP.createAnnotationWidget.prototype.draw = function() {
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    31
  var _this = this;
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    32
548
96a188138c20 refactored the code a bit.
hamidouk
parents: 547
diff changeset
    33
  var annotationMarkup = IriSP.templToHTML(IriSP.createAnnotationWidget_template);
543
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    34
	this.selector.append(annotationMarkup);
548
96a188138c20 refactored the code a bit.
hamidouk
parents: 547
diff changeset
    35
  
543
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    36
  this.selector.hide();
548
96a188138c20 refactored the code a bit.
hamidouk
parents: 547
diff changeset
    37
  for (var i = 0; i < this.keywords.length; i++) {
96a188138c20 refactored the code a bit.
hamidouk
parents: 547
diff changeset
    38
    var templ = IriSP.templToHTML("<span class='Ldt-createAnnotation-absent-keyword'>{{keyword}}</span>", 
96a188138c20 refactored the code a bit.
hamidouk
parents: 547
diff changeset
    39
                                  {keyword: this.keywords[i]});
96a188138c20 refactored the code a bit.
hamidouk
parents: 547
diff changeset
    40
                                  
96a188138c20 refactored the code a bit.
hamidouk
parents: 547
diff changeset
    41
    this.selector.find(".Ldt-createAnnotation-keywords").append(templ);
96a188138c20 refactored the code a bit.
hamidouk
parents: 547
diff changeset
    42
  }
96a188138c20 refactored the code a bit.
hamidouk
parents: 547
diff changeset
    43
  
543
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    44
  
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    45
  this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", 
547
5b58a108086a adding support for keywords.
hamidouk
parents: 543
diff changeset
    46
                        IriSP.wrap(this, this.handleAnnotateSignal));  
543
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    47
};
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    48
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    49
IriSP.createAnnotationWidget.prototype.handleAnnotateSignal = function() {
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    50
  if (this._hidden == false) {
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    51
    this.selector.hide();
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    52
    this._hidden = true;
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    53
  } else {
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    54
    this.selector.show();
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    55
    this._hidden = false;
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    56
  }
5856fab9596c WIP - adding widget to create annotations.
hamidouk
parents:
diff changeset
    57
};