some refactoring to use this.selector instead of directly using jquery. popcorn-port
authorhamidouk
Fri, 21 Oct 2011 17:25:52 +0200
branchpopcorn-port
changeset 121 607f481ef4c3
parent 120 35d91e67e972
child 122 04bd1e2f9674
some refactoring to use this.selector instead of directly using jquery.
src/js/widgets/playerWidget.js
src/js/widgets/segmentsWidget.js
--- a/src/js/widgets/playerWidget.js	Fri Oct 21 17:25:22 2011 +0200
+++ b/src/js/widgets/playerWidget.js	Fri Oct 21 17:25:52 2011 +0200
@@ -1,6 +1,5 @@
 IriSP.PlayerWidget = function(Popcorn, config, Serializer) {
   IriSP.Widget.call(this, Popcorn, config, Serializer);
-  
 };
 
 IriSP.PlayerWidget.prototype = new IriSP.Widget();
@@ -11,49 +10,49 @@
 	var height = this._config.gui.height;
 	var heightS = this._config.gui.height-20;
 		
-	if( this._config.gui.mode=="radio" ){
+	if (this._config.gui.mode=="radio") {
 
 		//IriSP.jQuery( "#"+this._config.gui.container ).before(IriSP.search_template);
-		var radioPlayer = Mustache.to_html(IriSP.radio_template, {"share_template" : IriSP.share_template});    
-		IriSP.jQuery(radioPlayer).appendTo("#"+this._config.gui.container);
+		var radioPlayer = Mustache.to_html(IriSP.radio_template, {"share_template" : IriSP.share_template});
+    this.selector.append(radioPlayer);		
     
 		// special tricks for IE 7
-		if (IriSP.jQuery.browser.msie==true && IriSP.jQuery.browser.version=="7.0"){
+		if (IriSP.jQuery.browser.msie == true && IriSP.jQuery.browser.version == "7.0"){
 			//LdtSearchContainer
 			//__IriSP.jQuery("#LdtPlayer").attr("margin-top","50px");
-			IriSP.jQuery("#Ldt-Root").css("padding-top","25px");			
+			this.selector.children("#Ldt-Root").css("padding-top","25px");			
 		}
-	} else if(this._config.gui.mode=="video") {
+	} else if (this._config.gui.mode == "video") {
 	
 		var videoPlayer = Mustache.to_html(IriSP.video_template, {"share_template" : IriSP.share_template, "heightS" : heightS});
-		IriSP.jQuery(videoPlayer).appendTo("#"+this._config.gui.container);
+    this.selector.append(videoPlayer);		
 	}
 	
-	IriSP.jQuery("#Ldt-Annotations").width(width-(75*2));
-	IriSP.jQuery("#Ldt-Show-Arrow-container").width(width-(75*2));
-	IriSP.jQuery("#Ldt-ShowAnnotation-audio").width(width-10);
-	IriSP.jQuery("#Ldt-ShowAnnotation-video").width(width-10);
-	IriSP.jQuery("#Ldt-SaKeyword").width(width-10);
-	IriSP.jQuery("#Ldt-controler").width(width-10);
-	IriSP.jQuery("#Ldt-Control").attr("z-index","100");
-	IriSP.jQuery("#Ldt-controler").hide();
+	this.selector.children("#Ldt-Annotations").width(width - (75 * 2));
+	this.selector.children("#Ldt-Show-Arrow-container").width(width - (75 * 2));
+	this.selector.children("#Ldt-ShowAnnotation-audio").width(width - 10);
+	this.selector.children("#Ldt-ShowAnnotation-video").width(width - 10);
+	this.selector.children("#Ldt-SaKeyword").width(width - 10);
+	this.selector.children("#Ldt-controler").width(width - 10);
+	this.selector.children("#Ldt-Control").attr("z-index", "100");
+	this.selector.children("#Ldt-controler").hide();
 	
-	IriSP.jQuery(IriSP.annotation_loading_template).appendTo("#Ldt-ShowAnnotation-audio");
+  this.selector.children("#Ldt-ShowAnnotation-audio").append(IriSP.annotation_loading_template);	
 
 	if(this._config.gui.mode=='radio'){
-		IriSP.jQuery("#Ldt-load-container").attr("width",this._config.gui.width);
+		this.selector.children("#Ldt-load-container").attr("width",this._config.gui.width);
 	}
 	  		
-  IriSP.jQuery( "#Ldt-controler" ).show();
+  this.selector.children("#Ldt-controler").show();
   //__IriSP.jQuery("#Ldt-Root").css('display','visible');
-  IriSP.jQuery( "#Ldt-ShowAnnotation").click( function () { 
+  this.selector.children("#Ldt-ShowAnnotation").click( function () { 
      //__IriSP.jQuery(this).slideUp(); 
   } );
 
-  var LdtpPlayerY = IriSP.jQuery("#Ldt-PlaceHolder").attr("top");
-  var LdtpPlayerX = IriSP.jQuery("#Ldt-PlaceHolder").attr("left");
+  var LdtpPlayerY = this.selector.children("#Ldt-PlaceHolder").attr("top");
+  var LdtpPlayerX = this.selector.children("#Ldt-PlaceHolder").attr("left");
   
-  IriSP.jQuery( "#slider-range-min" ).slider( { //range: "min",
+  this.selector.find("#slider-range-min").slider( { //range: "min",
     value: 0,
     min: 1,
     max: this._serializer.currentMedia().meta["dc:duration"]/1000,//1:54:52.66 = 3600+3240+
@@ -70,8 +69,8 @@
     */
   } );
   
-  IriSP.jQuery("#amount").val(IriSP.jQuery("#slider-range-min").slider("value")+" s");
-  IriSP.jQuery(".Ldt-Control1 button:first").button({
+  this.selector.children("#amount").val(this.selector.children("#slider-range-min").slider("value")+" s");
+  this.selector.children(".Ldt-Control1 button:first").button({
     icons: {
       primary: 'ui-icon-play'
     },
@@ -83,7 +82,7 @@
     },
      text: false
   });
-  IriSP.jQuery(".Ldt-Control2 button:first").button({
+  this.selector.children(".Ldt-Control2 button:first").button({
     icons: {
       primary: 'ui-icon-search'//,
       //secondary: 'ui-icon-volume-off'
@@ -96,11 +95,9 @@
      text: false
   }).click(function() { _this.muteHandler.call(_this); } );
 
-  // /!\ PB A MODIFIER 
-  //__IriSP.MyTags.draw();
-  IriSP.jQuery( "#ldt-CtrlPlay" ).attr( "style", "background-color:#CD21C24;" );
+  this.selector.children("#ldt-CtrlPlay").attr( "style", "background-color:#CD21C24;" );
   
-  IriSP.jQuery( "#Ldt-load-container" ).hide();
+  this.selector.children("#Ldt-load-container").hide();
   
   if( this._config.gui.mode=="radio" & IriSP.jQuery.browser.msie != true ) {
     IriSP.jQuery( "#Ldtplayer1" ).attr( "height", "0" );
@@ -114,27 +111,27 @@
   
   if ( status == true ){        
     this._Popcorn.play();
-    IriSP.jQuery( ".ui-icon-play" ).css( "background-position", "-16px -160px" );
-    IriSP.jQuery( "#ldt-CtrlPlay" ).attr("title", "Play");
+    this.selector.children(".ui-icon-play").css( "background-position", "-16px -160px" );
+    this.selector.children("#ldt-CtrlPlay").attr("title", "Play");
   } else {
     this._Popcorn.pause();
-    IriSP.jQuery( ".ui-icon-play" ).css( "background-position","0px -160px" );
-    IriSP.jQuery( "#ldt-CtrlPlay" ).attr("title", "Pause");
+    this.selector.children(".ui-icon-play").css( "background-position","0px -160px" );
+    this.selector.children("#ldt-CtrlPlay").attr("title", "Pause");
   }  
 };
 
 IriSP.PlayerWidget.prototype.muteHandler = function() {
   if (!this._Popcorn.muted()) {    
       this._Popcorn.mute(true);
-      IriSP.jQuery(" .ui-icon-volume-on ").css("background-position", "-130px -160px");    
+      this.selector.children(" .ui-icon-volume-on ").css("background-position", "-130px -160px");    
     } else {
       this._Popcorn.mute(false);
-      IriSP.jQuery( ".ui-icon-volume-on" ).css("background-position", "-144px -160px" );
+      this.selector.children( ".ui-icon-volume-on" ).css("background-position", "-144px -160px" );
     }
 };
 
 IriSP.PlayerWidget.prototype.sliderUpdater = function() {  
   var currentPosition = this._Popcorn.currentTime();   
-	IriSP.jQuery( "#slider-range-min" ).slider( "value", currentPosition);		
+	this.selector.find( "#slider-range-min" ).slider( "value", currentPosition);		
 };
 
--- a/src/js/widgets/segmentsWidget.js	Fri Oct 21 17:25:22 2011 +0200
+++ b/src/js/widgets/segmentsWidget.js	Fri Oct 21 17:25:52 2011 +0200
@@ -32,9 +32,7 @@
           {"title" : divTitle, "begin" : begin, "end" : end,
           "description": annotation.content.description});
     
-        
-    IriSP.jQuery(annotationTemplate).appendTo("#Ldt-Annotations");
-    // TOOLTIP BUG ! 
+    IriSP.jQuery("#Ldt-Annotations").append(annotationTemplate);    
     
     IriSP.jQuery("#" + id).tooltip({ effect: 'slide'});