src/js/widgets/playerWidget.js
author hamidouk
Wed, 14 Dec 2011 12:09:45 +0100
branchpopcorn-port
changeset 458 5bafddd9e3ba
parent 449 6e6b4a54776a
child 468 651528a4f795
permissions -rw-r--r--
fixed button display bug.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
109
be17a396d68b fix to the PlayerWidget constructor.
hamidouk
parents: 98
diff changeset
     1
IriSP.PlayerWidget = function(Popcorn, config, Serializer) {
be17a396d68b fix to the PlayerWidget constructor.
hamidouk
parents: 98
diff changeset
     2
  IriSP.Widget.call(this, Popcorn, config, Serializer);
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
     3
  
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
     4
  this._searchBlockOpen = false;
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
     5
  this._searchLastValue = "";
109
be17a396d68b fix to the PlayerWidget constructor.
hamidouk
parents: 98
diff changeset
     6
};
115
464e3e892915 forgot an inheritance line.
hamidouk
parents: 109
diff changeset
     7
464e3e892915 forgot an inheritance line.
hamidouk
parents: 109
diff changeset
     8
IriSP.PlayerWidget.prototype = new IriSP.Widget();
464e3e892915 forgot an inheritance line.
hamidouk
parents: 109
diff changeset
     9
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    10
IriSP.PlayerWidget.prototype.draw = function() {
153
43f6de365ed4 general code cleanup.
hamidouk
parents: 151
diff changeset
    11
  var self = this;
131
44c1170e0044 renames.
hamidouk
parents: 121
diff changeset
    12
  var width = this.width;
44c1170e0044 renames.
hamidouk
parents: 121
diff changeset
    13
	var height = this.height;
44c1170e0044 renames.
hamidouk
parents: 121
diff changeset
    14
	var heightS = this.height-20;
261
7e7a44d82a81 positionned correctly the search box - its position is now calculated in function
hamidouk
parents: 255
diff changeset
    15
	  
251
116c86db7e17 got rid of the radio and video templates - replaced them with the player.htm
hamidouk
parents: 250
diff changeset
    16
	var Player_templ = Mustache.to_html(IriSP.player_template, {"share_template" : IriSP.share_template});
116c86db7e17 got rid of the radio and video templates - replaced them with the player.htm
hamidouk
parents: 250
diff changeset
    17
  this.selector.append(Player_templ);		
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    18
    
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
    19
	this.selector.children(".Ldt-controler").width(width - 10);
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    20
	  		
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
    21
  this.selector.children(".Ldt-controler").show();
153
43f6de365ed4 general code cleanup.
hamidouk
parents: 151
diff changeset
    22
    
202
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    23
  // handle clicks by the user on the video.
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    24
  this._Popcorn.listen("play", IriSP.wrap(this, this.playButtonUpdater));
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    25
  this._Popcorn.listen("pause", IriSP.wrap(this, this.playButtonUpdater));
449
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
    26
  
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
    27
  this._Popcorn.listen("volumechange", IriSP.wrap(this, this.muteButtonUpdater));
440
bf9307640e55 slightly change the code the change the button.
hamidouk
parents: 416
diff changeset
    28
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    29
  this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.timeDisplayUpdater));
398
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
    30
  this._Popcorn.listen("IriSP.search.matchFound", IriSP.wrap(this, this.searchMatch));
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
    31
  this._Popcorn.listen("IriSP.search.noMatchFound", IriSP.wrap(this, this.searchNoMatch));
202
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    32
  
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
    33
  
311
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    34
  this.selector.find(".Ldt-CtrlPlay").click(function() { self.playHandler.call(self); });
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    35
  this.selector.find(".Ldt-CtrlNext").click(function() { });
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    36
  this.selector.find(".Ldt-CtrlSearch").click(function() { self.searchButtonHandler.call(self); });
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
    37
  
311
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    38
  this.selector.find('.Ldt-CtrlSound').click(function() { self.muteHandler.call(self); } );
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    39
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    40
  this.selector.find(".Ldt-CtrlPlay").attr( "style", "background-color:#CD21C24;" );
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
    41
  
311
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    42
  var searchButtonPos = this.selector.find(".Ldt-CtrlSearch").position();
261
7e7a44d82a81 positionned correctly the search box - its position is now calculated in function
hamidouk
parents: 255
diff changeset
    43
  var searchBox = Mustache.to_html(IriSP.search_template, {margin_left : searchButtonPos.left + "px"});
7e7a44d82a81 positionned correctly the search box - its position is now calculated in function
hamidouk
parents: 255
diff changeset
    44
  this.selector.append(searchBox);
7e7a44d82a81 positionned correctly the search box - its position is now calculated in function
hamidouk
parents: 255
diff changeset
    45
  
331
ef3447aa6920 player widget now sends a special message when the mouse is hovering it.
hamidouk
parents: 311
diff changeset
    46
  // trigger an IriSP.PlayerWidget.MouseOver to the widgets that are interested (i.e : sliderWidget)
ef3447aa6920 player widget now sends a special message when the mouse is hovering it.
hamidouk
parents: 311
diff changeset
    47
  this.selector.hover(function() { self._Popcorn.trigger("IriSP.PlayerWidget.MouseOver"); }, 
ef3447aa6920 player widget now sends a special message when the mouse is hovering it.
hamidouk
parents: 311
diff changeset
    48
                      function() { self._Popcorn.trigger("IriSP.PlayerWidget.MouseOut"); });
458
5bafddd9e3ba fixed button display bug.
hamidouk
parents: 449
diff changeset
    49
 
5bafddd9e3ba fixed button display bug.
hamidouk
parents: 449
diff changeset
    50
  this.muteButtonUpdater(); /* some player - jwplayer notable - save the state of the mute button between sessions */
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    51
};
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    52
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    53
/* Update the elasped time div */
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    54
IriSP.PlayerWidget.prototype.timeDisplayUpdater = function() {
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    55
  
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    56
  if (this._previousSecond === undefined)
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    57
    this._previousSecond = this._Popcorn.roundTime();
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    58
  
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    59
  else {
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    60
    /* we're still in the same second, so it's not necessary to update time */
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    61
    if (this._Popcorn.roundTime() == this._previousSecond)
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    62
      return;
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    63
      
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    64
  }
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    65
  
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    66
  // we get it at each call because it may change.
296
10ecc65d945c fixed total duration display bug.
hamidouk
parents: 295
diff changeset
    67
  var duration = +this._serializer.currentMedia().meta["dc:duration"] / 1000; 
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    68
  var totalTime = IriSP.secondsToTime(duration);
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    69
  var elapsedTime = IriSP.secondsToTime(this._Popcorn.currentTime());
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    70
  
338
3ff4499f79bb WIP - graphical integration.
hamidouk
parents: 331
diff changeset
    71
  this.selector.find(".Ldt-ElapsedTime").html(elapsedTime.toString());
3ff4499f79bb WIP - graphical integration.
hamidouk
parents: 331
diff changeset
    72
  this.selector.find(".Ldt-TotalTime").html(totalTime.toString());
255
af3adcf7cb20 added an elapsed time display to the player widget.
hamidouk
parents: 251
diff changeset
    73
  this._previousSecond = this._Popcorn.roundTime();
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    74
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    75
202
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    76
/* update the icon of the button - separate function from playHandler
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    77
   because in some cases (for instance, when the user directly clicks on
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    78
   the jwplayer window) we have to change the icon without playing/pausing
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    79
*/
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
    80
IriSP.PlayerWidget.prototype.playButtonUpdater = function() {
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    81
  var status = this._Popcorn.media.paused;
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    82
  
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    83
  if ( status == true ){        
311
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    84
    this.selector.find(".Ldt-CtrlPlay").attr("title", "Play");
416
f3237cce149e play/pause functionality now works correctly.
hamidouk
parents: 398
diff changeset
    85
   
f3237cce149e play/pause functionality now works correctly.
hamidouk
parents: 398
diff changeset
    86
    // we use templToHTML because it has some predefined
f3237cce149e play/pause functionality now works correctly.
hamidouk
parents: 398
diff changeset
    87
    // vars like where to get the images
440
bf9307640e55 slightly change the code the change the button.
hamidouk
parents: 416
diff changeset
    88
    var templ = IriSP.templToHTML("url({{img_dir}}/play_sprite.png)");
416
f3237cce149e play/pause functionality now works correctly.
hamidouk
parents: 398
diff changeset
    89
    this.selector.find(".Ldt-CtrlPlay").css("background-image", templ);
f3237cce149e play/pause functionality now works correctly.
hamidouk
parents: 398
diff changeset
    90
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    91
  } else {
311
43a1b7d95317 WIP - integrating the various changes samuel requested.
hamidouk
parents: 296
diff changeset
    92
    this.selector.find(".Ldt-CtrlPlay").attr("title", "Pause");
416
f3237cce149e play/pause functionality now works correctly.
hamidouk
parents: 398
diff changeset
    93
f3237cce149e play/pause functionality now works correctly.
hamidouk
parents: 398
diff changeset
    94
    // we use templToHTML because it has some predefined
f3237cce149e play/pause functionality now works correctly.
hamidouk
parents: 398
diff changeset
    95
    // vars like where to get the images
440
bf9307640e55 slightly change the code the change the button.
hamidouk
parents: 416
diff changeset
    96
    var templ = IriSP.templToHTML("url({{img_dir}}/pause_sprite.png)");
416
f3237cce149e play/pause functionality now works correctly.
hamidouk
parents: 398
diff changeset
    97
    this.selector.find(".Ldt-CtrlPlay").css("background-image", templ);
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
    98
  }  
440
bf9307640e55 slightly change the code the change the button.
hamidouk
parents: 416
diff changeset
    99
bf9307640e55 slightly change the code the change the button.
hamidouk
parents: 416
diff changeset
   100
  return;
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   101
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   102
202
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   103
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   104
IriSP.PlayerWidget.prototype.playHandler = function() {
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   105
  var status = this._Popcorn.media.paused;
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   106
  
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   107
  if ( status == true ){        
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   108
    this._Popcorn.play();   
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   109
  } else {
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   110
    this._Popcorn.pause();
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   111
  }  
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   112
};
2e0205ee7ca9 patch to respond to update the player widget when the user clicks directly on
hamidouk
parents: 163
diff changeset
   113
98
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   114
IriSP.PlayerWidget.prototype.muteHandler = function() {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   115
  if (!this._Popcorn.muted()) {    
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   116
      this._Popcorn.mute(true);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   117
    } else {
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   118
      this._Popcorn.mute(false);
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   119
    }
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   120
};
ed4ac18baf07 broke the widgets.js in multiple files.
hamidouk
parents:
diff changeset
   121
449
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   122
IriSP.PlayerWidget.prototype.muteButtonUpdater = function() {
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   123
  var status = this._Popcorn.media.muted;
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   124
  
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   125
  if ( status == true ){        
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   126
    this.selector.find(".Ldt-CtrlSound").attr("title", "Unmute");
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   127
   
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   128
    // we use templToHTML because it has some predefined
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   129
    // vars like where to get the images
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   130
    var templ = IriSP.templToHTML("url({{img_dir}}/sound_sprite.png)");
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   131
    this.selector.find(".Ldt-CtrlSound").css("background-image", templ);
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   132
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   133
  } else {
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   134
    this.selector.find(".Ldt-CtrlSound").attr("title", "Mute");
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   135
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   136
    // we use templToHTML because it has some predefined
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   137
    // vars like where to get the images
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   138
    var templ = IriSP.templToHTML("url({{img_dir}}/mute_sprite.png)");
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   139
    this.selector.find(".Ldt-CtrlSound").css("background-image", templ);
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   140
  }  
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   141
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   142
  return;
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   143
};
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   144
6e6b4a54776a added a function to update the icon when the player is muted.
hamidouk
parents: 446
diff changeset
   145
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   146
IriSP.PlayerWidget.prototype.searchButtonHandler = function() {
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   147
    var self = this;
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   148
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   149
    /* show the search field if it is not shown */
261
7e7a44d82a81 positionned correctly the search box - its position is now calculated in function
hamidouk
parents: 255
diff changeset
   150
  	if ( this._searchBlockOpen == false ) {      
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   151
      this.selector.find(".LdtSearch").show(100);
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   152
      
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   153
      this.selector.find(".LdtSearchInput").css('background-color','#fff');
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   154
      this.selector.find(".LdtSearchInput").focus();
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   155
      this.selector.find(".LdtSearchInput").attr('value', this._searchLastValue);      
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   156
      this._Popcorn.trigger("IriSP.search", this._searchLastValue); // trigger the search to make it more natural.
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   157
      
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   158
      this._searchBlockOpen = true;           
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   159
      this.selector.find(".LdtSearchInput").bind('keyup', null, function() { self.searchHandler.call(self); } );
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   160
      
398
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   161
      // we need this variable because some widget can find a match in
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   162
      // their data while at the same time other's don't. As we want the
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   163
      // search field to become green when there's a match, we need a 
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   164
      // variable to remember that we had one.
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   165
      this._positiveMatch = false;
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   166
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   167
      // tell the world the field is open
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   168
      this._Popcorn.trigger("IriSP.search.open");
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   169
      
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   170
	} else {
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   171
      this._searchLastValue = this.selector.find(".LdtSearchInput").attr('value');
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   172
      this.selector.find(".LdtSearchInput").attr('value','');
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   173
      this.selector.find(".LdtSearch").hide(100);
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   174
      
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   175
      // unbind the watcher event.
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   176
      this.selector.find(".LdtSearchInput").unbind('keypress set');
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   177
      this._searchBlockOpen = false;
398
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   178
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   179
      this._positiveMatch = false;
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   180
      
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   181
      this._Popcorn.trigger("IriSP.search.closed");
145
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   182
  }
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   183
};
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   184
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   185
/* this handler is called whenever the content of the search
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   186
   field changes */
b477c9430d36 tests and implementation of the search button for the player.
hamidouk
parents: 131
diff changeset
   187
IriSP.PlayerWidget.prototype.searchHandler = function() {
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   188
  this._searchLastValue = this.selector.find(".LdtSearchInput").attr('value');
398
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   189
  this._positiveMatch = false;
154
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   190
  
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   191
  // do nothing if the search field is empty, instead of highlighting everything.
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   192
  if (this._searchLastValue == "") {
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   193
    this._Popcorn.trigger("IriSP.search.cleared");
355
d8df77c40676 fixed search field coloring.
hamidouk
parents: 338
diff changeset
   194
    this.selector.find(".LdtSearchInput").css('background-color','');
154
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   195
  } else {
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   196
    this._Popcorn.trigger("IriSP.search", this._searchLastValue);
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 153
diff changeset
   197
  }
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   198
};
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   199
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   200
/*
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   201
  handler for the IriSP.search.found message, which is sent by some views when they
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   202
  highlight a match.
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   203
*/
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   204
IriSP.PlayerWidget.prototype.searchMatch = function() {
398
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   205
  this._positiveMatch = true;
250
41683e7cb17a updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents: 226
diff changeset
   206
  this.selector.find(".LdtSearchInput").css('background-color','#e1ffe1');
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   207
}
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   208
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   209
/* the same, except that no value could be found */
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   210
IriSP.PlayerWidget.prototype.searchNoMatch = function() {
398
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   211
  if (this._positiveMatch !== true)
d1883378b822 renamed search signal.
hamidouk
parents: 355
diff changeset
   212
    this.selector.find(".LdtSearchInput").css('background-color', "#d62e3a");
151
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   213
}
dc2ff4c87490 some tweaking to make the search function more user-friendly.
hamidouk
parents: 145
diff changeset
   214