general code cleanup. popcorn-port
authorhamidouk
Wed, 26 Oct 2011 15:46:19 +0200
branchpopcorn-port
changeset 153 43f6de365ed4
parent 152 5950ab2855a8
child 154 6e115a094858
general code cleanup.
src/js/widgets/playerWidget.js
unittests/tests/playerWidget.js
--- a/src/js/widgets/playerWidget.js	Wed Oct 26 15:19:40 2011 +0200
+++ b/src/js/widgets/playerWidget.js	Wed Oct 26 15:46:19 2011 +0200
@@ -8,7 +8,7 @@
 IriSP.PlayerWidget.prototype = new IriSP.Widget();
 
 IriSP.PlayerWidget.prototype.draw = function() {
-  var _this = this;
+  var self = this;
   var width = this.width;
 	var height = this.height;
 	var heightS = this.height-20;
@@ -17,14 +17,11 @@
   this.selector.append(searchBox);
   
 	if (this._config.mode=="radio") {
-
-		//IriSP.jQuery( "#"+this._config.container ).before(IriSP.search_template);
 		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"){
-			//LdtSearchContainer
 			//__IriSP.jQuery("#LdtPlayer").attr("margin-top","50px");
 			this.selector.children("#Ldt-Root").css("padding-top","25px");			
 		}
@@ -64,24 +61,24 @@
     max: this._serializer.currentMedia().meta["dc:duration"]/1000,//1:54:52.66 = 3600+3240+
     step: 0.1,
     slide: function(event, ui) {     
-      _this._Popcorn.currentTime(ui.value);
+      self._Popcorn.currentTime(ui.value);
     },
     /* change event is similar to slide, but it happens when the slider position is 
-       modified programatically. We use it for unit tests */
-    /*   
-    change: function(event, ui) {     
-      _this._Popcorn.currentTime(ui.value);
+       modified programatically. We use it for unit tests */       
+    change: function(event, ui) {      
+      self._Popcorn.trigger("test.fixture", ui.value);
     }
-    */
+    
   } );
   
+  this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
   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'
     },
     text: false
-  }).click(function() { _this.playHandler.call(_this); })
+  }).click(function() { self.playHandler.call(self); })
     .next().button({
     icons: {
       primary: 'ui-icon-seek-next'
@@ -94,13 +91,13 @@
       //secondary: 'ui-icon-volume-off'
     },
     text: false
-  }).click(function() { _this.searchButtonHandler.call(_this); })
+  }).click(function() { self.searchButtonHandler.call(self); })
     .next().button({
     icons: {
       primary: 'ui-icon-volume-on'
     },
      text: false
-  }).click(function() { _this.muteHandler.call(_this); } );
+  }).click(function() { self.muteHandler.call(self); } );
 
   this.selector.children("#ldt-CtrlPlay").attr( "style", "background-color:#CD21C24;" );
   
@@ -110,7 +107,7 @@
     IriSP.jQuery( "#Ldtplayer1" ).attr( "height", "0" );
   }
 
-  this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
+
 };
 
 IriSP.PlayerWidget.prototype.playHandler = function() {
@@ -166,9 +163,7 @@
 	} else {
       this._searchLastValue = this.selector.find("#LdtSearchInput").attr('value');
       this.selector.find("#LdtSearchInput").attr('value','');
-      //IriSP.SearchClean();
       this.selector.find(".ui-icon-search").css("background-position","-160px -112px");
-      //__IriSP.jQuery("#LdtSearch").animate({height:0},250);
       this.selector.find("#LdtSearch").hide(100);
       
       // unbind the watcher event.
--- a/unittests/tests/playerWidget.js	Wed Oct 26 15:19:40 2011 +0200
+++ b/unittests/tests/playerWidget.js	Wed Oct 26 15:46:19 2011 +0200
@@ -52,8 +52,8 @@
     
     */
     
-    IriSP.jQuery("#ldt-CtrlPlay").trigger("click");    
-    IriSP.jQuery("#ldt-CtrlPlay").trigger("click");
+    player.selector.find("#ldt-CtrlPlay").trigger("click");    
+    player.selector.find("#ldt-CtrlPlay").trigger("click");
     ok(player.playHandler.calledTwice, "play handler called");
     ok(spy_callback2.calledOnce, "test if pause callback has been called");                                                                    
   });
@@ -68,26 +68,22 @@
     player.draw();
        
     // IriSP.jQuery("#ldt-CtrlSound").trigger("click");    
-    IriSP.jQuery(".Ldt-Control2 button:first").next().trigger("click");    
+    player.selector.find(".Ldt-Control2 button:first").next().trigger("click");    
     ok(this.Popcorn.muted(), "the player is muted");
     
-    IriSP.jQuery("#ldt-CtrlSound").trigger("click");
+    player.selector.find("#ldt-CtrlSound").trigger("click");
     ok(!this.Popcorn.muted(), "the player is un muted");         
     ok(spy_handler.called, "handling function has been called");                                                                                                                                        
   });
 
   test("test slider seeking", function() {    
-  /* FIXME: because of a bug in popcorn, this test doesn't pass
     var player = new IriSP.PlayerWidget(this.Popcorn, this.config, this.ser);    
     player.draw();    
     
     var spy_callback = this.spy();
-    this.Popcorn.listen("seeked", spy_callback);       
-    IriSP.jQuery("#slider-range-min").slider("value", 30);
-    
-    ok(spy_callback.called, "handling function has been called twice");
-  */
-  ok(true, "WARNING : slider is not tested");
+    player._Popcorn.listen("test.fixture", spy_callback);       
+    player.selector.find("#slider-range-min").slider("value", 30);
+    ok(spy_callback.called, "handling function has been called");
   });
   
   test("test search button event handler", function() {