src/js/widgets.js
author hamidouk
Thu, 13 Oct 2011 17:12:52 +0200
branchpopcorn-port
changeset 74 d7a7d7216371
parent 66 13013b9452af
child 93 8c066a79a14f
permissions -rw-r--r--
lots of changes to the player widget... also added corresponsing unit tests.
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
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    22
IriSP.PlayerWidget.prototype = IriSP.Widget;
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() {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    25
  var width = this._config.gui.width;
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    26
	var height = this._config.gui.height;
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    27
	var heightS = this._config.gui.height-20;
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    28
		
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    29
	if( this._config.gui.mode=="radio" ){
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    30
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    31
		//IriSP.jQuery( "#"+this._config.gui.container ).before(IriSP.search_template);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    32
		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
    33
		IriSP.jQuery(radioPlayer).appendTo("#"+this._config.gui.container);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    34
    
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    35
		// special tricks for IE 7
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    36
		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
    37
			//LdtSearchContainer
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    38
			//__IriSP.jQuery("#LdtPlayer").attr("margin-top","50px");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    39
			IriSP.jQuery("#Ldt-Root").css("padding-top","25px");			
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    40
		}
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    41
	} else if(this._config.gui.mode=="video") {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    42
	
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    43
		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
    44
		IriSP.jQuery(videoPlayer).appendTo("#"+this._config.gui.container);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    45
	}
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
	IriSP.jQuery("#Ldt-Annotations").width(width-(75*2));
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    48
	IriSP.jQuery("#Ldt-Show-Arrow-container").width(width-(75*2));
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    49
	IriSP.jQuery("#Ldt-ShowAnnotation-audio").width(width-10);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    50
	IriSP.jQuery("#Ldt-ShowAnnotation-video").width(width-10);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    51
	IriSP.jQuery("#Ldt-SaKeyword").width(width-10);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    52
	IriSP.jQuery("#Ldt-controler").width(width-10);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    53
	IriSP.jQuery("#Ldt-Control").attr("z-index","100");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    54
	IriSP.jQuery("#Ldt-controler").hide();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    55
	
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    56
	IriSP.jQuery(IriSP.annotation_loading_template).appendTo("#Ldt-ShowAnnotation-audio");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    57
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    58
	if(this._config.gui.mode=='radio'){
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    59
		IriSP.jQuery("#Ldt-load-container").attr("width",this._config.gui.width);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    60
	}
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    61
	// Show or not the output
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    62
	if(this._config.gui.debug===true){
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    63
		IriSP.jQuery("#Ldt-output").show();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    64
	} else {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    65
		IriSP.jQuery("#Ldt-output").hide();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    66
	}
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
  IriSP.jQuery( "#Ldt-controler" ).show();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    69
  //__IriSP.jQuery("#Ldt-Root").css('display','visible');
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    70
  IriSP.jQuery( "#Ldt-ShowAnnotation").click( function () { 
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    71
     //__IriSP.jQuery(this).slideUp(); 
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    72
  } );
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    73
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    74
  var LdtpPlayerY = IriSP.jQuery("#Ldt-PlaceHolder").attr("top");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    75
  var LdtpPlayerX = IriSP.jQuery("#Ldt-PlaceHolder").attr("left");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    76
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    77
  IriSP.jQuery( "#slider-range-min" ).slider( { //range: "min",
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    78
    value: 0,
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    79
    min: 1,
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    80
    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
    81
    step: 0.1,
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    82
    slide: function(event, ui) {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    83
      
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    84
      //__IriSP.jQuery("#amount").val(ui.value+" s");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    85
      //player.sendEvent('SEEK', ui.value)
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    86
      IriSP.MyApiPlayer.seek(ui.value);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    87
      //changePageUrlOffset(ui.value);
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    88
      //player.sendEvent('PAUSE')
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    89
    }
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    90
  } );
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    91
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    92
  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
    93
  IriSP.jQuery(".Ldt-Control1 button:first").button({
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    94
    icons: {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    95
      primary: 'ui-icon-play'
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    96
    },
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    97
    text: false
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    98
  }).click(IriSP.wrap(this, this.playEvent))
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
    99
    .next().button({
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   100
    icons: {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   101
      primary: 'ui-icon-seek-next'
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   102
    },
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   103
     text: false
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   104
  });
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   105
  IriSP.jQuery(".Ldt-Control2 button:first").button({
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   106
    icons: {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   107
      primary: 'ui-icon-search'//,
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   108
      //secondary: 'ui-icon-volume-off'
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   109
    },
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   110
    text: false
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   111
  }).next().button({
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   112
    icons: {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   113
      primary: 'ui-icon-volume-on'
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
     text: false
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   116
  });
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   117
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   118
  // /!\ PB A MODIFIER 
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   119
  //__IriSP.MyTags.draw();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   120
  IriSP.jQuery( "#ldt-CtrlPlay" ).attr( "style", "background-color:#CD21C24;" );
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   121
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   122
  IriSP.jQuery( "#Ldt-load-container" ).hide();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   123
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   124
  if( this._config.gui.mode=="radio" & IriSP.jQuery.browser.msie != true ) {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   125
    IriSP.jQuery( "#Ldtplayer1" ).attr( "height", "0" );
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   126
  }
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   127
  IriSP.trace( "__IriSP.createInterface" , "3" );
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   128
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   129
  IriSP.trace( "__IriSP.createInterface", "END" );
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   130
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   131
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   132
};
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   133
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   134
IriSP.PlayerWidget.prototype.playEvent = function() {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   135
   var status = this._Popcorn.media.paused;
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   136
      
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   137
  if ( status == true ){        
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   138
    this._Popcorn.play();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   139
  } else {
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   140
    this._Popcorn.pause();
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   141
  }
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   142
  
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   143
  this._Popcorn.trigger("mulz");
d7a7d7216371 lots of changes to the player widget...
hamidouk
parents: 66
diff changeset
   144
};