summaryrefslogtreecommitdiff
blob: deda99710c1645a4c7f0cf04801417253ef6a007 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/**
 * This file is part of the Semantic Result Formats Media module
 * @see https://www.semantic-mediawiki.org/wiki/Help:Media_formats
 *
 * @section LICENSE
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 *
 * @file
 * @ignore
 *
 * @since 1.9
 * @ingroup SRF
 *
 * @licence GNU GPL v2+
 * @author mwjames
 */
( function( $, mw, srf ) {
	'use strict';

	/*jshint scripturl:true*/

	/**
	 * Helper method
	 * @ignore
	 */
	var h = mw.html;

	/**
	 * Internationalization (i18n) support
	 *
	 * @since 1.9
	 * @ignore
	 */
	var _i18n = {
		'previous' : mw.msg( 'srf-ui-mediaplayer-label-previous' ),
		'pause' : mw.msg( 'srf-ui-mediaplayer-label-pause' ),
		'play' : mw.msg( 'srf-ui-mediaplayer-label-play' ),
		'next' : mw.msg( 'srf-ui-mediaplayer-label-next' ),
		'stop' : mw.msg( 'srf-ui-mediaplayer-label-stop' ),
		'mute' : mw.msg( 'srf-ui-mediaplayer-label-mute' ),
		'unmute' : mw.msg( 'srf-ui-mediaplayer-label-unmute' ),
		'volumeMax' : mw.msg( 'srf-ui-mediaplayer-label-volume-max' ),
		'shuffle' : mw.msg( 'srf-ui-mediaplayer-label-shuffle' ),
		'shuffleOff' : mw.msg( 'srf-ui-mediaplayer-label-shuffle-off' ),
		'repeat' : mw.msg( 'srf-ui-mediaplayer-label-repeat' ),
		'repeatOff' : mw.msg( 'srf-ui-mediaplayer-label-repeat-off' ),
		'fullScreen' : mw.msg( 'srf-ui-mediaplayer-label-full-screen' ),
		'restoreScreen' : mw.msg( 'srf-ui-mediaplayer-label-restore-screen' )
	};

	/**
	 * Inheritance class for the srf.template constructor
	 *
	 * @since 1.9
	 *
	 * @class
	 * @abstract
	 */
	srf.template = srf.template || {};

	/**
	 * Base constructor for objects representing a template instance
	 *
	 * @since 1.9
	 *
	 * @class
	 * @constructor
	 * @extends srf.template
	 */
	srf.template.jplayer = {

		/**
		 * Placeholder for the media inspector
		 *
		 * @return object
		 */
		inspector : function( ID ) { return h.element( 'div', { 'id' : ID }, '' );
		},

		/**
		 * Audio player template
		 *
		 * @return object
		 */
		audio: {
			single : function( options ) { return h.element( 'div', { 'id' : options.playerId, 'class': 'jp-jplayer' } ) +
				h.element( 'div', { 'id' : options.containerId , 'class': 'jp-audio' },
					new h.Raw( h.element( 'div', { 'class': 'jp-type-single' },
						new h.Raw( h.element( 'div', { 'class': 'jp-gui jp-interface' },
							new h.Raw( h.element( 'ul', { 'class': 'jp-controls' },
								new h.Raw (
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-play' , 'tabindex' : 1, 'title': _i18n.play }, _i18n.play ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-pause' , 'tabindex' : 1, 'title': _i18n.pause }, _i18n.pause ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-stop' , 'tabindex' : 1, 'title': _i18n.stop }, _i18n.stop ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-mute' , 'tabindex' : 1, 'title' : _i18n.mute }, _i18n.mute ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-unmute' , 'tabindex' : 1, 'title': _i18n.unmute }, _i18n.unmute ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-volume-max' , 'tabindex' : 1, 'title': _i18n.volumeMax }, _i18n.volumeMax ) ) )
								) ) +
								// progress
								h.element( 'div', { 'class': 'jp-progress' }, new h.Raw ( h.element( 'div', { 'class': 'jp-seek-bar' }, new h.Raw ( h.element( 'div', { 'class': 'jp-play-bar' }, '' ) ) ) ) ) +
								// Volumn
								h.element( 'div', { 'class': 'jp-volume-bar' }, new h.Raw ( h.element( 'div', { 'class': 'jp-volume-bar-value' }, '' ) ) ) +
								// Time
								h.element( 'div', { 'class': 'jp-time-holder' },  new h.Raw (  h.element( 'div', { 'class': 'jp-current-time' }, '' ) + h.element( 'div', { 'class': 'jp-duration' }, '' ) ) ) +
								//
								h.element( 'ul', { 'class': 'jp-toggles' },
								new h.Raw (
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-repeat' , 'tabindex' : 1, 'title' : _i18n.repeat }, _i18n.repeat ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-repeat-off' , 'tabindex' : 1, 'title' : _i18n.repeatOff }, _i18n.repeatOff ) ) )
								) )
						) ) + h.element( 'div', { 'class': 'jp-playlist' }, new h.Raw( h.element( 'ul', {}, new h.Raw( h.element( 'li', {}, '' ) ) ) ) ) )
				) ) );
			},
			multi : function( options ) { return h.element( 'div', { 'id' : options.playerId, 'class': 'jp-jplayer' } ) +
				h.element( 'div', { 'id' : options.containerId , 'class': 'jp-audio' },
					new h.Raw( h.element( 'div', { 'class': 'jp-type-playlist' },
						new h.Raw( h.element( 'div', { 'class': 'jp-gui jp-interface' },
							new h.Raw( h.element( 'ul', { 'class': 'jp-controls' },
								new h.Raw (
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-previous' , 'tabindex' : 1, 'title': _i18n.previous }, _i18n.previous ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-play' , 'tabindex' : 1, 'title': _i18n.play }, _i18n.play ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-pause' , 'tabindex' : 1, 'title': _i18n.pause }, _i18n.pause ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-next' , 'tabindex' : 1, 'title': _i18n.next }, _i18n.next ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-stop' , 'tabindex' : 1, 'title': _i18n.stop }, _i18n.stop ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-mute' , 'tabindex' : 1, 'title' : _i18n.mute }, _i18n.mute ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-unmute' , 'tabindex' : 1, 'title': _i18n.unmute }, _i18n.unmute ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-volume-max' , 'tabindex' : 1, 'title': _i18n.volumeMax }, _i18n.volumeMax ) ) )
								) ) +
								// progress
								h.element( 'div', { 'class': 'jp-progress' }, new h.Raw ( h.element( 'div', { 'class': 'jp-seek-bar' }, new h.Raw ( h.element( 'div', { 'class': 'jp-play-bar' }, '' ) ) ) ) ) +
								// Volumn
								h.element( 'div', { 'class': 'jp-volume-bar' }, new h.Raw ( h.element( 'div', { 'class': 'jp-volume-bar-value' }, '' ) ) ) +
								// Time
								h.element( 'div', { 'class': 'jp-time-holder' },  new h.Raw (  h.element( 'div', { 'class': 'jp-current-time' }, '' ) + h.element( 'div', { 'class': 'jp-duration' }, '' ) ) ) +
								//
								h.element( 'ul', { 'class': 'jp-toggles' },
								new h.Raw (
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-shuffle' , 'tabindex' : 1, 'title' : _i18n.shuffle }, _i18n.shuffle ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-shuffle-off' , 'tabindex' : 1, 'title' : _i18n.shuffleOff }, _i18n.shuffleOff ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-repeat' , 'tabindex' : 1, 'title' : _i18n.repeat }, _i18n.repeat ) ) ) +
									h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-repeat-off' , 'tabindex' : 1, 'title' : _i18n.repeatOff }, _i18n.repeatOff ) ) )
								) )
						) ) + h.element( 'div', { 'class': 'jp-playlist' }, new h.Raw( h.element( 'ul', {}, new h.Raw( h.element( 'li', {}, '' ) ) ) ) ) )
				) ) );
			}
		},

		/**
		 * Video player template
		 *
		 * @return object
		 */
		video: {
			single : function( options ) { return h.element( 'div', { 'id' : options.containerId , 'class': 'jp-video' },
				new h.Raw(  h.element( 'div', { 'class': 'jp-type-single' },
					new h.Raw(
						h.element( 'div', { 'id': options.playerId, 'class': 'jp-jplayer' }  ) +
						h.element( 'div', { 'class': 'jp-gui' },
							new h.Raw(
								h.element( 'div', { 'class': 'jp-video-play' }, new h.Raw(  h.element( 'a', { 'href' :  'javascript:;', 'class' : 'jp-video-play-icon', 'tabindex' : 1 }, 'play' ) ) )+
								h.element( 'div', { 'class': 'jp-interface' },
								new h.Raw (
									// progress
									h.element( 'div', { 'class': 'jp-progress' }, new h.Raw ( h.element( 'div', { 'class': 'jp-seek-bar' }, new h.Raw ( h.element( 'div', { 'class': 'jp-play-bar' }, '' ) ) ) ) ) +
									h.element( 'div', { 'class': 'jp-current-time' }, '' ) +
									h.element( 'div', { 'class': 'jp-duration' }, '' ) +
									h.element( 'div', { 'class': 'jp-controls-holder' },
									new h.Raw( h.element( 'ul', { 'class': 'jp-controls' },
										new h.Raw (
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-play' , 'tabindex' : 1, 'title': _i18n.play }, _i18n.play ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-pause' , 'tabindex' : 1, 'title': _i18n.pause }, _i18n.pause ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-stop' , 'tabindex' : 1, 'title' : _i18n.stop }, _i18n.stop ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-mute' , 'tabindex' : 1, 'title' : _i18n.mute }, _i18n.mute ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-unmute' , 'tabindex' : 1, 'title' : _i18n.unmute }, _i18n.unmute ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-volume-max' , 'tabindex' : 1, 'title': _i18n.volumeMax }, _i18n.volumeMax ) ) )
									) ) + h.element( 'div', { 'class': 'jp-volume-bar' }, new h.Raw ( h.element( 'div', { 'class': 'jp-volume-bar-value' }, '' ) ) ) +
										h.element( 'ul', { 'class': 'jp-toggles' },
											new h.Raw (
												h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-full-screen' , 'tabindex' : 1, 'title' : _i18n.fullScreen }, _i18n.fullScreen ) ) ) +
												h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-restore-screen' , 'tabindex' : 1, 'title': _i18n.restoreScreen }, _i18n.restoreScreen ) ) ) +
												h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-repeat' , 'tabindex' : 1, 'title' : _i18n.repeat }, _i18n.repeat ) ) ) +
												h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-repeat-off' , 'tabindex' : 1, 'title': _i18n.repeatOff }, _i18n.repeatOff ) ) )
									) ) ) ) + h.element( 'div', { 'class': 'jp-title' }, new h.Raw( h.element( 'ul', {}, new h.Raw( h.element( 'li', {}, '' ) ) ) ) ) )
								) ) ) +
									h.element( 'div', { 'class': 'jp-playlist' }, new h.Raw( h.element( 'ul', {}, new h.Raw( h.element( 'li', {}, '' ) ) ) ) ) )
				) ) );
			},
			multi : function( options ) { return h.element( 'div', { 'id' : options.containerId , 'class': 'jp-video' },
				new h.Raw(  h.element( 'div', { 'class': 'jp-type-playlist' },
					new h.Raw(
						h.element( 'div', { 'id': options.playerId, 'class': 'jp-jplayer' }  ) +
						h.element( 'div', { 'class': 'jp-gui' },
							new h.Raw(
								h.element( 'div', { 'class': 'jp-video-play' }, new h.Raw(  h.element( 'a', { 'href' :  'javascript:;', 'class' : 'jp-video-play-icon', 'tabindex' : 1 }, 'play' ) ) )+
								h.element( 'div', { 'class': 'jp-interface' },
								new h.Raw (
									// progress
									h.element( 'div', { 'class': 'jp-progress' }, new h.Raw ( h.element( 'div', { 'class': 'jp-seek-bar' }, new h.Raw ( h.element( 'div', { 'class': 'jp-play-bar' }, '' ) ) ) ) ) +
									h.element( 'div', { 'class': 'jp-current-time' }, '' ) +
									h.element( 'div', { 'class': 'jp-duration' }, '' ) +
									h.element( 'div', { 'class': 'jp-controls-holder' },
									new h.Raw( h.element( 'ul', { 'class': 'jp-controls' },
										new h.Raw (
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-previous' , 'tabindex' : 1, 'title': _i18n.previous }, _i18n.previous ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-play' , 'tabindex' : 1, 'title': _i18n.play }, _i18n.play ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-pause' , 'tabindex' : 1, 'title': _i18n.pause }, _i18n.pause ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-next' , 'tabindex' : 1, 'title': _i18n.next }, _i18n.next ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-stop' , 'tabindex' : 1, 'title' : _i18n.stop }, _i18n.stop ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-mute' , 'tabindex' : 1, 'title' : _i18n.mute }, _i18n.mute ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-unmute' , 'tabindex' : 1, 'title' : _i18n.unmute }, _i18n.unmute ) ) ) +
											h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-volume-max' , 'tabindex' : 1, 'title': _i18n.volumeMax }, _i18n.volumeMax ) ) )
									)
								) + h.element( 'div', { 'class': 'jp-volume-bar' }, new h.Raw ( h.element( 'div', { 'class': 'jp-volume-bar-value' }, '' ) ) ) +
										h.element( 'ul', { 'class': 'jp-toggles' },
											new h.Raw (
												h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-full-screen' , 'tabindex' : 1, 'title' : _i18n.fullScreen }, _i18n.fullScreen ) ) ) +
												h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-restore-screen' , 'tabindex' : 1, 'title': _i18n.restoreScreen }, _i18n.restoreScreen ) ) ) +
												h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-shuffle' , 'tabindex' : 1, 'title' : _i18n.shuffle }, _i18n.shuffle ) ) ) +
												h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-shuffle-off' , 'tabindex' : 1, 'title': _i18n.shuffleOff }, _i18n.shuffleOff ) ) ) +
												h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-repeat' , 'tabindex' : 1, 'title' : _i18n.repeat }, _i18n.repeat ) ) ) +
												h.element( 'li', {}, new h.Raw( h.element( 'a', { 'href' : 'javascript:', 'class' : 'jp-repeat-off' , 'tabindex' : 1, 'title': _i18n.repeatOff }, _i18n.repeatOff ) ) )
										) ) ) ) + h.element( 'div', { 'class': 'jp-title' }, new h.Raw( h.element( 'ul', {}, new h.Raw( h.element( 'li', {}, '' ) ) ) ) ) )
							) )
						) + h.element( 'div', { 'class': 'jp-playlist' }, new h.Raw( h.element( 'ul', {}, new h.Raw( h.element( 'li', {}, '' ) ) ) ) ) )
				) ) );
			}
		}
	};

} )( jQuery, mediaWiki, semanticFormats );