| author | hamidouk |
| Wed, 16 Nov 2011 10:54:13 +0100 | |
| branch | popcorn-port |
| changeset 251 | 116c86db7e17 |
| parent 250 | 41683e7cb17a |
| child 255 | af3adcf7cb20 |
| permissions | -rw-r--r-- |
| 109 | 1 |
IriSP.PlayerWidget = function(Popcorn, config, Serializer) { |
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 | 6 |
}; |
| 115 | 7 |
|
8 |
IriSP.PlayerWidget.prototype = new IriSP.Widget(); |
|
9 |
||
| 98 | 10 |
IriSP.PlayerWidget.prototype.draw = function() { |
| 153 | 11 |
var self = this; |
| 131 | 12 |
var width = this.width; |
13 |
var height = this.height; |
|
14 |
var heightS = this.height-20; |
|
|
145
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
15 |
|
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
16 |
var searchBox = Mustache.to_html(IriSP.search_template); |
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
17 |
this.selector.append(searchBox); |
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
18 |
|
|
251
116c86db7e17
got rid of the radio and video templates - replaced them with the player.htm
hamidouk
parents:
250
diff
changeset
|
19 |
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
|
20 |
this.selector.append(Player_templ); |
| 98 | 21 |
|
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
22 |
this.selector.children(".Ldt-controler").width(width - 10); |
|
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
23 |
/* |
|
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
24 |
this.selector.children("#Ldt-Control").attr("z-index", "100"); |
|
121
607f481ef4c3
some refactoring to use this.selector instead of directly using jquery.
hamidouk
parents:
115
diff
changeset
|
25 |
this.selector.children("#Ldt-controler").hide(); |
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
26 |
*/ |
| 98 | 27 |
|
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
28 |
this.selector.children(".Ldt-controler").show(); |
| 98 | 29 |
|
|
121
607f481ef4c3
some refactoring to use this.selector instead of directly using jquery.
hamidouk
parents:
115
diff
changeset
|
30 |
var LdtpPlayerY = this.selector.children("#Ldt-PlaceHolder").attr("top"); |
|
607f481ef4c3
some refactoring to use this.selector instead of directly using jquery.
hamidouk
parents:
115
diff
changeset
|
31 |
var LdtpPlayerX = this.selector.children("#Ldt-PlaceHolder").attr("left"); |
| 153 | 32 |
|
|
202
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
33 |
// 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
|
34 |
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
|
35 |
this._Popcorn.listen("pause", 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
|
36 |
|
|
121
607f481ef4c3
some refactoring to use this.selector instead of directly using jquery.
hamidouk
parents:
115
diff
changeset
|
37 |
this.selector.children("#amount").val(this.selector.children("#slider-range-min").slider("value")+" s"); |
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
38 |
|
|
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
39 |
this.selector.find(".ldt-CtrlPlay").button({ |
| 98 | 40 |
icons: { |
41 |
primary: 'ui-icon-play' |
|
42 |
}, |
|
43 |
text: false |
|
| 153 | 44 |
}).click(function() { self.playHandler.call(self); }) |
| 98 | 45 |
.next().button({ |
46 |
icons: { |
|
47 |
primary: 'ui-icon-seek-next' |
|
48 |
}, |
|
49 |
text: false |
|
50 |
}); |
|
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
51 |
|
|
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
52 |
this.selector.find(".ldt-CtrlSearch").button({ |
| 98 | 53 |
icons: { |
54 |
primary: 'ui-icon-search'//, |
|
55 |
//secondary: 'ui-icon-volume-off' |
|
56 |
}, |
|
57 |
text: false |
|
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
58 |
}).click(function() { self.searchButtonHandler.call(self); }); |
|
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
59 |
|
|
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
60 |
this.selector.find('.ldt-CtrlSound').button({ |
| 98 | 61 |
icons: { |
62 |
primary: 'ui-icon-volume-on' |
|
63 |
}, |
|
64 |
text: false |
|
| 153 | 65 |
}).click(function() { self.muteHandler.call(self); } ); |
| 98 | 66 |
|
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
67 |
this.selector.find(".ldt-CtrlPlay").attr( "style", "background-color:#CD21C24;" ); |
| 98 | 68 |
|
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
69 |
// this.selector.children("#Ldt-load-container").hide(); |
| 98 | 70 |
|
| 131 | 71 |
if( this._config.mode=="radio" & IriSP.jQuery.browser.msie != true ) { |
| 98 | 72 |
IriSP.jQuery( "#Ldtplayer1" ).attr( "height", "0" ); |
73 |
} |
|
74 |
||
| 153 | 75 |
|
| 98 | 76 |
}; |
77 |
||
|
202
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
78 |
/* 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
|
79 |
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
|
80 |
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
|
81 |
*/ |
|
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
82 |
IriSP.PlayerWidget.prototype.playButtonUpdater = function() { |
| 98 | 83 |
var status = this._Popcorn.media.paused; |
84 |
|
|
85 |
if ( status == true ){ |
|
|
163
3ecb643627de
some conversions to use this.selector.find instead of .children().
hamidouk
parents:
154
diff
changeset
|
86 |
this.selector.find(".ui-icon-play").css( "background-position", "-16px -160px" ); |
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
87 |
this.selector.find(".ldt-CtrlPlay").attr("title", "Play"); |
| 98 | 88 |
} else { |
|
163
3ecb643627de
some conversions to use this.selector.find instead of .children().
hamidouk
parents:
154
diff
changeset
|
89 |
this.selector.find(".ui-icon-play").css( "background-position","0px -160px" ); |
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
90 |
this.selector.find(".ldt-CtrlPlay").attr("title", "Pause"); |
| 98 | 91 |
} |
92 |
}; |
|
93 |
||
|
202
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
94 |
|
|
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
95 |
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
|
96 |
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
|
97 |
|
|
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
98 |
this.playButtonUpdater(); |
|
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
99 |
|
|
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
100 |
if ( status == true ){ |
|
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
101 |
this._Popcorn.play(); |
|
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
102 |
} else { |
|
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
103 |
this._Popcorn.pause(); |
|
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
104 |
} |
|
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
105 |
}; |
|
2e0205ee7ca9
patch to respond to update the player widget when the user clicks directly on
hamidouk
parents:
163
diff
changeset
|
106 |
|
| 98 | 107 |
IriSP.PlayerWidget.prototype.muteHandler = function() { |
108 |
if (!this._Popcorn.muted()) { |
|
109 |
this._Popcorn.mute(true); |
|
|
163
3ecb643627de
some conversions to use this.selector.find instead of .children().
hamidouk
parents:
154
diff
changeset
|
110 |
this.selector.find(" .ui-icon-volume-on ").css("background-position", "-130px -160px"); |
| 98 | 111 |
} else { |
112 |
this._Popcorn.mute(false); |
|
|
163
3ecb643627de
some conversions to use this.selector.find instead of .children().
hamidouk
parents:
154
diff
changeset
|
113 |
this.selector.find( ".ui-icon-volume-on" ).css("background-position", "-144px -160px" ); |
| 98 | 114 |
} |
115 |
}; |
|
116 |
||
|
145
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
117 |
IriSP.PlayerWidget.prototype.searchButtonHandler = function() { |
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
118 |
var self = this; |
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
119 |
|
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
120 |
/* show the search field if it is not shown */ |
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
121 |
if ( this._searchBlockOpen == false ) { |
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
122 |
this.selector.find( ".ui-icon-search" ).css( "background-position", "-144px -112px" ); |
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
123 |
|
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
124 |
this.selector.find(".LdtSearch").show(100); |
|
145
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
125 |
|
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
126 |
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
|
127 |
this.selector.find(".LdtSearchInput").focus(); |
|
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
128 |
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
|
129 |
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
|
130 |
|
|
145
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
131 |
this._searchBlockOpen = true; |
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
132 |
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
|
133 |
|
|
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
134 |
// tell the world the field is open |
|
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
135 |
this._Popcorn.trigger("IriSP.search.open"); |
|
145
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
136 |
|
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
137 |
} else { |
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
138 |
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
|
139 |
this.selector.find(".LdtSearchInput").attr('value',''); |
|
145
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
140 |
this.selector.find(".ui-icon-search").css("background-position","-160px -112px"); |
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
141 |
this.selector.find(".LdtSearch").hide(100); |
|
145
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
142 |
|
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
143 |
// unbind the watcher event. |
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
144 |
this.selector.find(".LdtSearchInput").unbind('keypress set'); |
|
145
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
145 |
this._searchBlockOpen = false; |
|
151
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
146 |
|
|
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
147 |
this._Popcorn.trigger("IriSP.search.closed"); |
|
145
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 |
}; |
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
150 |
|
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
151 |
/* 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
|
152 |
field changes */ |
|
b477c9430d36
tests and implementation of the search button for the player.
hamidouk
parents:
131
diff
changeset
|
153 |
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
|
154 |
this._searchLastValue = this.selector.find(".LdtSearchInput").attr('value'); |
|
154
6e115a094858
another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents:
153
diff
changeset
|
155 |
|
|
6e115a094858
another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents:
153
diff
changeset
|
156 |
// 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
|
157 |
if (this._searchLastValue == "") { |
|
6e115a094858
another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents:
153
diff
changeset
|
158 |
this._Popcorn.trigger("IriSP.search.cleared"); |
|
6e115a094858
another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents:
153
diff
changeset
|
159 |
} else { |
|
6e115a094858
another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents:
153
diff
changeset
|
160 |
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
|
161 |
} |
|
151
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
162 |
}; |
|
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
163 |
|
|
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
164 |
/* |
|
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
165 |
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
|
166 |
highlight a match. |
|
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
167 |
*/ |
|
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
168 |
IriSP.PlayerWidget.prototype.searchMatch = function() { |
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
169 |
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
|
170 |
} |
|
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
171 |
|
|
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
172 |
/* 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
|
173 |
IriSP.PlayerWidget.prototype.searchNoMatch = function() { |
|
250
41683e7cb17a
updated the playerWidget to use classes instead of id's in its elements.
hamidouk
parents:
226
diff
changeset
|
174 |
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
|
175 |
} |
|
dc2ff4c87490
some tweaking to make the search function more user-friendly.
hamidouk
parents:
145
diff
changeset
|
176 |