src/js/widgets.js
author hamidouk
Wed, 19 Oct 2011 11:54:24 +0200
branchpopcorn-port
changeset 95 da3ab0bfadf3
parent 93 8c066a79a14f
child 98 ed4ac18baf07
permissions -rw-r--r--
the widget now displays correctly the annotations.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
66
13013b9452af Added a new file to the build, widgets.js, to contain widget classes.
hamidouk
parents:
diff changeset
     1
/* the widget classes and definitions */
13013b9452af Added a new file to the build, widgets.js, to contain widget classes.
hamidouk
parents:
diff changeset
     2
74
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
     3
IriSP.Widget = function(Popcorn, config, Serializer) {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
     4
  this._Popcorn = Popcorn;
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
     5
  this._config = config;  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
     6
  this._serializer = Serializer;
66
13013b9452af Added a new file to the build, widgets.js, to contain widget classes.
hamidouk
parents:
diff changeset
     7
};
13013b9452af Added a new file to the build, widgets.js, to contain widget classes.
hamidouk
parents:
diff changeset
     8
13013b9452af Added a new file to the build, widgets.js, to contain widget classes.
hamidouk
parents:
diff changeset
     9
IriSP.Widget.prototype.draw = function() {
13013b9452af Added a new file to the build, widgets.js, to contain widget classes.
hamidouk
parents:
diff changeset
    10
  /* implemented by "sub-classes" */  
13013b9452af Added a new file to the build, widgets.js, to contain widget classes.
hamidouk
parents:
diff changeset
    11
};
74
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    12
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    13
IriSP.Widget.prototype.redraw = function() {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    14
  /* implemented by "sub-classes" */  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    15
};
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    16
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    17
IriSP.PlayerWidget = function(Popcorn, config, Serializer) {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    18
  IriSP.Widget.call(this, Popcorn, config, Serializer);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    19
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    20
};
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    21
93
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    22
IriSP.PlayerWidget.prototype = new IriSP.Widget;
74
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    23
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    24
IriSP.PlayerWidget.prototype.draw = function() {
93
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    25
  var _this = this;
74
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    26
  var width = this._config.gui.width;
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    27
	var height = this._config.gui.height;
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    28
	var heightS = this._config.gui.height-20;
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    29
		
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    30
	if( this._config.gui.mode=="radio" ){
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    31
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    32
		//IriSP.jQuery( "#"+this._config.gui.container ).before(IriSP.search_template);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    33
		var radioPlayer = Mustache.to_html(IriSP.radio_template, {"share_template" : IriSP.share_template});    
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    34
		IriSP.jQuery(radioPlayer).appendTo("#"+this._config.gui.container);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    35
    
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    36
		// special tricks for IE 7
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    37
		if (IriSP.jQuery.browser.msie==true && IriSP.jQuery.browser.version=="7.0"){
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    38
			//LdtSearchContainer
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    39
			//__IriSP.jQuery("#LdtPlayer").attr("margin-top","50px");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    40
			IriSP.jQuery("#Ldt-Root").css("padding-top","25px");			
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    41
		}
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    42
	} else if(this._config.gui.mode=="video") {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    43
	
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    44
		var videoPlayer = Mustache.to_html(IriSP.video_template, {"share_template" : IriSP.share_template, "heightS" : heightS});
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    45
		IriSP.jQuery(videoPlayer).appendTo("#"+this._config.gui.container);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    46
	}
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    47
	
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    48
	IriSP.jQuery("#Ldt-Annotations").width(width-(75*2));
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    49
	IriSP.jQuery("#Ldt-Show-Arrow-container").width(width-(75*2));
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    50
	IriSP.jQuery("#Ldt-ShowAnnotation-audio").width(width-10);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    51
	IriSP.jQuery("#Ldt-ShowAnnotation-video").width(width-10);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    52
	IriSP.jQuery("#Ldt-SaKeyword").width(width-10);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    53
	IriSP.jQuery("#Ldt-controler").width(width-10);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    54
	IriSP.jQuery("#Ldt-Control").attr("z-index","100");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    55
	IriSP.jQuery("#Ldt-controler").hide();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    56
	
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    57
	IriSP.jQuery(IriSP.annotation_loading_template).appendTo("#Ldt-ShowAnnotation-audio");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    58
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    59
	if(this._config.gui.mode=='radio'){
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    60
		IriSP.jQuery("#Ldt-load-container").attr("width",this._config.gui.width);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    61
	}
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    62
	  		
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    63
  IriSP.jQuery( "#Ldt-controler" ).show();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    64
  //__IriSP.jQuery("#Ldt-Root").css('display','visible');
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    65
  IriSP.jQuery( "#Ldt-ShowAnnotation").click( function () { 
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    66
     //__IriSP.jQuery(this).slideUp(); 
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    67
  } );
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    68
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    69
  var LdtpPlayerY = IriSP.jQuery("#Ldt-PlaceHolder").attr("top");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    70
  var LdtpPlayerX = IriSP.jQuery("#Ldt-PlaceHolder").attr("left");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    71
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    72
  IriSP.jQuery( "#slider-range-min" ).slider( { //range: "min",
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    73
    value: 0,
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    74
    min: 1,
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    75
    max: this._serializer.currentMedia().meta["dc:duration"]/1000,//1:54:52.66 = 3600+3240+
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    76
    step: 0.1,
93
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    77
    slide: function(event, ui) {     
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    78
      _this._Popcorn.currentTime(ui.value);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    79
    },
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    80
    /* change event is similar to slide, but it happens when the slider position is 
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    81
       modified programatically. We use it for unit tests */
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    82
    /*   
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    83
    change: function(event, ui) {     
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    84
      _this._Popcorn.currentTime(ui.value);
74
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    85
    }
93
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    86
    */
74
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    87
  } );
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    88
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    89
  IriSP.jQuery("#amount").val(IriSP.jQuery("#slider-range-min").slider("value")+" s");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    90
  IriSP.jQuery(".Ldt-Control1 button:first").button({
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    91
    icons: {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    92
      primary: 'ui-icon-play'
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    93
    },
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    94
    text: false
93
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
    95
  }).click(function() { _this.playHandler.call(_this); })
74
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    96
    .next().button({
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    97
    icons: {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    98
      primary: 'ui-icon-seek-next'
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    99
    },
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   100
     text: false
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   101
  });
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   102
  IriSP.jQuery(".Ldt-Control2 button:first").button({
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   103
    icons: {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   104
      primary: 'ui-icon-search'//,
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   105
      //secondary: 'ui-icon-volume-off'
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   106
    },
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   107
    text: false
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   108
  }).next().button({
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   109
    icons: {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   110
      primary: 'ui-icon-volume-on'
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   111
    },
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   112
     text: false
93
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   113
  }).click(function() { _this.muteHandler.call(_this); } );
74
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   114
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   115
  // /!\ PB A MODIFIER 
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   116
  //__IriSP.MyTags.draw();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   117
  IriSP.jQuery( "#ldt-CtrlPlay" ).attr( "style", "background-color:#CD21C24;" );
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   118
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   119
  IriSP.jQuery( "#Ldt-load-container" ).hide();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   120
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   121
  if( this._config.gui.mode=="radio" & IriSP.jQuery.browser.msie != true ) {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   122
    IriSP.jQuery( "#Ldtplayer1" ).attr( "height", "0" );
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   123
  }
93
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   124
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   125
  this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   126
};
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   127
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   128
IriSP.PlayerWidget.prototype.playHandler = function() {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   129
  var status = this._Popcorn.media.paused;
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   130
  
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   131
  if ( status == true ){        
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   132
    this._Popcorn.play();
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   133
    IriSP.jQuery( ".ui-icon-play" ).css( "background-position", "-16px -160px" );
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   134
    IriSP.jQuery( "#ldt-CtrlPlay" ).attr("title", "Play");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   135
  } else {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   136
    this._Popcorn.pause();
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   137
    IriSP.jQuery( ".ui-icon-play" ).css( "background-position","0px -160px" );
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   138
    IriSP.jQuery( "#ldt-CtrlPlay" ).attr("title", "Pause");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   139
  }  
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   140
};
74
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   141
93
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   142
IriSP.PlayerWidget.prototype.muteHandler = function() {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   143
  if (!this._Popcorn.muted()) {    
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   144
      this._Popcorn.mute(true);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   145
      IriSP.jQuery(" .ui-icon-volume-on ").css("background-position", "-130px -160px");    
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   146
    } else {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   147
      this._Popcorn.mute(false);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   148
      IriSP.jQuery( ".ui-icon-volume-on" ).css("background-position", "-144px -160px" );
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   149
    }
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   150
};
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   151
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   152
IriSP.PlayerWidget.prototype.sliderUpdater = function() {  
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   153
  var currentPosition = this._Popcorn.currentTime();   
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   154
	IriSP.jQuery( "#slider-range-min" ).slider( "value", currentPosition);		
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   155
};
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   156
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   157
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   158
IriSP.AnnotationsWidget = function(Popcorn, config, Serializer) {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   159
  IriSP.Widget.call(this, Popcorn, config, Serializer);
74
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   160
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   161
};
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   162
93
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   163
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   164
IriSP.AnnotationsWidget.prototype = new IriSP.Widget;
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   165
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   166
IriSP.AnnotationsWidget.prototype.clear = function() {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   167
    IriSP.jQuery("#Ldt-SaTitle").text("");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   168
    IriSP.jQuery("#Ldt-SaDescription").text("");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   169
    IriSP.jQuery("#Ldt-SaKeywordText").text("");
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   170
};
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   171
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   172
IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   173
    var title = annotation.content.title;
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   174
    var description = annotation.content.description;
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   175
    var keywords =  "" // FIXME;
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   176
    var begin = +annotation.begin;
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   177
    var end = +annotation.end;
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   178
    var duration = +this._serializer.currentMedia().meta["dc:duration"];
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   179
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   180
    IriSP.jQuery("#Ldt-SaTitle").text(title);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   181
    IriSP.jQuery("#Ldt-SaDescription").text(description);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   182
    IriSP.jQuery("#Ldt-SaKeywordText").text("Mots clefs : "+ keywords);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   183
		var startPourcent = parseInt(Math.round((begin*1+(end*1-begin*1)/2) / (duration*1)) / 100); 
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   184
		IriSP.jQuery("#Ldt-Show-Arrow").animate({left:startPourcent+'%'},1000);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   185
		//IriSP.jQuery("#"+annotationTempo.id).animate({alpha:'100%'},1000);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   186
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   187
};
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   188
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   189
IriSP.AnnotationsWidget.prototype.draw = function() {
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   190
  var _this = this;
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   191
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   192
  var annotationMarkup = Mustache.to_html(IriSP.annotationWidget_template, {"share_template" : IriSP.share_template});
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   193
	IriSP.jQuery("#Ldt-Ligne").append(annotationMarkup);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   194
  console.dir(this._serializer);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   195
  
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   196
  var annotations = this._serializer._data.annotations;
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   197
	for (i in annotations) {    
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   198
    var annotation = annotations[i];
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   199
    var begin = Math.round((+ annotation.begin) / 1000);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   200
    var end = Math.round((+ annotation.end) / 1000);
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   201
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   202
    this._Popcorn = this._Popcorn.code({start: begin, end: end, 
95
da3ab0bfadf3 the widget now displays correctly the annotations.
hamidouk
parents: 93
diff changeset
   203
                                        onStart: 
da3ab0bfadf3 the widget now displays correctly the annotations.
hamidouk
parents: 93
diff changeset
   204
                                          function(annotation) { return function() { _this.displayAnnotation(annotation); } }(annotation) });                                             
74
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   205
  }
93
8c066a79a14f WIP - adding a widget to display annotations.
hamidouk
parents: 74
diff changeset
   206
};