mediaelement_rails 0.5.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +6 -0
- data/MIT-LICENSE +1 -1
- data/README.md +8 -3
- data/app/assets/images/mediaelement_rails/bigplay.svg +0 -0
- data/app/assets/images/mediaelement_rails/controls.svg +0 -0
- data/app/assets/javascripts/mediaelement_rails/mediaelement.js +195 -125
- data/app/assets/javascripts/mediaelement_rails/mediaelementplayer.js +434 -364
- data/app/assets/plugins/mediaelement_rails/flashmediaelement-cdn.swf +0 -0
- data/app/assets/plugins/mediaelement_rails/flashmediaelement.swf +0 -0
- data/app/assets/stylesheets/mediaelement_rails/mediaelementplayer.css.erb +71 -51
- data/app/assets/stylesheets/mediaelement_rails/mejs-skins.css.erb +6 -0
- data/lib/mediaelement_rails/version.rb +1 -1
- data/mediaelement_rails.gemspec +6 -5
- data/mediaelement_rails.thor +2 -2
- metadata +74 -99
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e6de3b42c57e45c1a61a60d8ec98c0fd66ee2df4
|
4
|
+
data.tar.gz: df336f0708e2a50975aa669cd3956ffbb109b89d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c8ebde5252b5680454c8e8cb7fb8e45fcaaf71251aee75c617c95f0971915e2bafb1a9fb67828dae8e185843e11b1b550e3f1d310b828f90358e12fdce0cfbb
|
7
|
+
data.tar.gz: b3776c5c16c5176593279a4d7b3d6959def7d73eb429b261c9612134403fdeae489aa7d739ded0c34a4897c51ec2bf300e47526a542e09893515bd61e75541a6
|
data/CHANGELOG.md
ADDED
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MediaelementRails #
|
2
2
|
|
3
|
-
This neat project brings the cool [MediaElement.js](http://mediaelementjs.com/) (HTML5/Flash/Silverlight video player) to the Rails asset pipeline. __*NOTE:*__ This gem requires jquery, which shouldn't be an issue.
|
3
|
+
This neat project brings the cool [MediaElement.js](http://mediaelementjs.com/) 2.13.2 (HTML5/Flash/Silverlight video player) to the Rails asset pipeline. __*NOTE:*__ This gem requires jquery to be included, which shouldn't be an issue.
|
4
4
|
|
5
5
|
## All you have to do is: ##
|
6
6
|
|
@@ -34,7 +34,7 @@ Load the Mediaelement CSS in your `application.css`:
|
|
34
34
|
|
35
35
|
## Wanna use MediaElement (not the player) only? ##
|
36
36
|
|
37
|
-
This is easy as hell too!
|
37
|
+
This is easy as hell too!
|
38
38
|
Don't include any CSS and include the following in your `application.js` to get it working:
|
39
39
|
|
40
40
|
``` javascript
|
@@ -45,4 +45,9 @@ Don't include any CSS and include the following in your `application.js` to get
|
|
45
45
|
|
46
46
|
Nothing special! This project includes all assets you might need.
|
47
47
|
|
48
|
-
|
48
|
+
## Todo ##
|
49
|
+
|
50
|
+
- Add support for `flashmediaelement-cdn.swf` for cases when the assets are hosted on a different domain than the rails application.
|
51
|
+
- Setup [appraisal](https://github.com/thoughtbot/appraisal) gem to test against rails 3.x and 4.x
|
52
|
+
|
53
|
+
This project rocks and uses MIT-LICENSE.
|
File without changes
|
File without changes
|
@@ -7,7 +7,7 @@
|
|
7
7
|
* for browsers that don't understand HTML5 or can't play the provided codec
|
8
8
|
* Can play MP4 (H.264), Ogg, WebM, FLV, WMV, WMA, ACC, and MP3
|
9
9
|
*
|
10
|
-
* Copyright 2010-
|
10
|
+
* Copyright 2010-2013, John Dyer (http://j.hn)
|
11
11
|
* License: MIT
|
12
12
|
*
|
13
13
|
*/
|
@@ -15,7 +15,8 @@
|
|
15
15
|
var mejs = mejs || {};
|
16
16
|
|
17
17
|
// version number
|
18
|
-
mejs.version = '2.
|
18
|
+
mejs.version = '2.13.2';
|
19
|
+
|
19
20
|
|
20
21
|
// player number (for missing, same id attr)
|
21
22
|
mejs.meIndex = 0;
|
@@ -37,7 +38,6 @@ mejs.plugins = {
|
|
37
38
|
]
|
38
39
|
};
|
39
40
|
|
40
|
-
|
41
41
|
/*
|
42
42
|
Utility methods
|
43
43
|
*/
|
@@ -57,27 +57,47 @@ mejs.Utility = {
|
|
57
57
|
var
|
58
58
|
i = 0,
|
59
59
|
j,
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
codePath = '',
|
61
|
+
testname = '',
|
62
|
+
slashPos,
|
63
|
+
filenamePos,
|
64
|
+
scriptUrl,
|
65
|
+
scriptPath,
|
66
|
+
scriptFilename,
|
63
67
|
scripts = document.getElementsByTagName('script'),
|
64
68
|
il = scripts.length,
|
65
69
|
jl = scriptNames.length;
|
66
|
-
|
70
|
+
|
71
|
+
// go through all <script> tags
|
67
72
|
for (; i < il; i++) {
|
68
|
-
|
73
|
+
scriptUrl = scripts[i].src;
|
74
|
+
slashPos = scriptUrl.lastIndexOf('/');
|
75
|
+
if (slashPos > -1) {
|
76
|
+
scriptFilename = scriptUrl.substring(slashPos + 1);
|
77
|
+
scriptPath = scriptUrl.substring(0, slashPos + 1);
|
78
|
+
} else {
|
79
|
+
scriptFilename = scriptUrl;
|
80
|
+
scriptPath = '';
|
81
|
+
}
|
82
|
+
|
83
|
+
// see if any <script> tags have a file name that matches the
|
69
84
|
for (j = 0; j < jl; j++) {
|
70
|
-
|
71
|
-
|
72
|
-
|
85
|
+
testname = scriptNames[j];
|
86
|
+
filenamePos = scriptFilename.indexOf(testname);
|
87
|
+
if (filenamePos > -1) {
|
88
|
+
codePath = scriptPath;
|
73
89
|
break;
|
74
90
|
}
|
75
91
|
}
|
76
|
-
|
92
|
+
|
93
|
+
// if we found a path, then break and return it
|
94
|
+
if (codePath !== '') {
|
77
95
|
break;
|
78
96
|
}
|
79
97
|
}
|
80
|
-
|
98
|
+
|
99
|
+
// send the best path back
|
100
|
+
return codePath;
|
81
101
|
},
|
82
102
|
secondsToTimeCode: function(time, forceHours, showFrameCount, fps) {
|
83
103
|
//add framecount
|
@@ -297,13 +317,14 @@ mejs.MediaFeatures = {
|
|
297
317
|
t.isiOS = t.isiPhone || t.isiPad;
|
298
318
|
t.isAndroid = (ua.match(/android/i) !== null);
|
299
319
|
t.isBustedAndroid = (ua.match(/android 2\.[12]/) !== null);
|
300
|
-
t.
|
320
|
+
t.isBustedNativeHTTPS = (location.protocol === 'https:' && (ua.match(/android [12]\./) !== null || ua.match(/macintosh.* version.* safari/) !== null));
|
321
|
+
t.isIE = (nav.appName.toLowerCase().indexOf("microsoft") != -1 || nav.appName.toLowerCase().match(/trident/gi) !== null);
|
301
322
|
t.isChrome = (ua.match(/chrome/gi) !== null);
|
302
323
|
t.isFirefox = (ua.match(/firefox/gi) !== null);
|
303
324
|
t.isWebkit = (ua.match(/webkit/gi) !== null);
|
304
|
-
t.isGecko = (ua.match(/gecko/gi) !== null) && !t.isWebkit;
|
325
|
+
t.isGecko = (ua.match(/gecko/gi) !== null) && !t.isWebkit && !t.isIE;
|
305
326
|
t.isOpera = (ua.match(/opera/gi) !== null);
|
306
|
-
t.hasTouch = ('ontouchstart' in window);
|
327
|
+
t.hasTouch = ('ontouchstart' in window); // && window.ontouchstart != null); // this breaks iOS 7
|
307
328
|
|
308
329
|
// borrowed from Modernizr
|
309
330
|
t.svg = !! document.createElementNS &&
|
@@ -316,35 +337,62 @@ mejs.MediaFeatures = {
|
|
316
337
|
|
317
338
|
t.supportsMediaTag = (typeof v.canPlayType !== 'undefined' || t.isBustedAndroid);
|
318
339
|
|
340
|
+
// Fix for IE9 on Windows 7N / Windows 7KN (Media Player not installer)
|
341
|
+
try{
|
342
|
+
v.canPlayType("video/mp4");
|
343
|
+
}catch(e){
|
344
|
+
t.supportsMediaTag = false;
|
345
|
+
}
|
346
|
+
|
319
347
|
// detect native JavaScript fullscreen (Safari/Firefox only, Chrome still fails)
|
320
348
|
|
321
349
|
// iOS
|
322
350
|
t.hasSemiNativeFullScreen = (typeof v.webkitEnterFullscreen !== 'undefined');
|
323
351
|
|
324
|
-
//
|
352
|
+
// W3C
|
353
|
+
t.hasNativeFullscreen = (typeof v.requestFullscreen !== 'undefined');
|
354
|
+
|
355
|
+
// webkit/firefox/IE11+
|
325
356
|
t.hasWebkitNativeFullScreen = (typeof v.webkitRequestFullScreen !== 'undefined');
|
326
357
|
t.hasMozNativeFullScreen = (typeof v.mozRequestFullScreen !== 'undefined');
|
358
|
+
t.hasMsNativeFullScreen = (typeof v.msRequestFullscreen !== 'undefined');
|
327
359
|
|
328
|
-
t.hasTrueNativeFullScreen = (t.hasWebkitNativeFullScreen || t.hasMozNativeFullScreen);
|
360
|
+
t.hasTrueNativeFullScreen = (t.hasWebkitNativeFullScreen || t.hasMozNativeFullScreen || t.hasMsNativeFullScreen);
|
329
361
|
t.nativeFullScreenEnabled = t.hasTrueNativeFullScreen;
|
362
|
+
|
363
|
+
// Enabled?
|
330
364
|
if (t.hasMozNativeFullScreen) {
|
331
|
-
t.nativeFullScreenEnabled =
|
365
|
+
t.nativeFullScreenEnabled = document.mozFullScreenEnabled;
|
366
|
+
} else if (t.hasMsNativeFullScreen) {
|
367
|
+
t.nativeFullScreenEnabled = document.msFullscreenEnabled;
|
332
368
|
}
|
333
369
|
|
334
|
-
|
335
|
-
if (this.isChrome) {
|
370
|
+
if (t.isChrome) {
|
336
371
|
t.hasSemiNativeFullScreen = false;
|
337
372
|
}
|
338
373
|
|
339
374
|
if (t.hasTrueNativeFullScreen) {
|
340
|
-
t.fullScreenEventName = (t.hasWebkitNativeFullScreen) ? 'webkitfullscreenchange' : 'mozfullscreenchange';
|
341
375
|
|
376
|
+
t.fullScreenEventName = '';
|
377
|
+
if (t.hasWebkitNativeFullScreen) {
|
378
|
+
t.fullScreenEventName = 'webkitfullscreenchange';
|
379
|
+
|
380
|
+
} else if (t.hasMozNativeFullScreen) {
|
381
|
+
t.fullScreenEventName = 'mozfullscreenchange';
|
382
|
+
|
383
|
+
} else if (t.hasMsNativeFullScreen) {
|
384
|
+
t.fullScreenEventName = 'MSFullscreenChange';
|
385
|
+
}
|
342
386
|
|
343
387
|
t.isFullScreen = function() {
|
344
388
|
if (v.mozRequestFullScreen) {
|
345
389
|
return d.mozFullScreen;
|
390
|
+
|
346
391
|
} else if (v.webkitRequestFullScreen) {
|
347
392
|
return d.webkitIsFullScreen;
|
393
|
+
|
394
|
+
} else if (v.hasMsNativeFullScreen) {
|
395
|
+
return d.msFullscreenElement !== null;
|
348
396
|
}
|
349
397
|
}
|
350
398
|
|
@@ -352,16 +400,26 @@ mejs.MediaFeatures = {
|
|
352
400
|
|
353
401
|
if (t.hasWebkitNativeFullScreen) {
|
354
402
|
el.webkitRequestFullScreen();
|
403
|
+
|
355
404
|
} else if (t.hasMozNativeFullScreen) {
|
356
405
|
el.mozRequestFullScreen();
|
406
|
+
|
407
|
+
} else if (t.hasMsNativeFullScreen) {
|
408
|
+
el.msRequestFullscreen();
|
409
|
+
|
357
410
|
}
|
358
411
|
}
|
359
412
|
|
360
413
|
t.cancelFullScreen = function() {
|
361
414
|
if (t.hasWebkitNativeFullScreen) {
|
362
415
|
document.webkitCancelFullScreen();
|
416
|
+
|
363
417
|
} else if (t.hasMozNativeFullScreen) {
|
364
418
|
document.mozCancelFullScreen();
|
419
|
+
|
420
|
+
} else if (t.hasMsNativeFullScreen) {
|
421
|
+
document.msExitFullscreen();
|
422
|
+
|
365
423
|
}
|
366
424
|
}
|
367
425
|
|
@@ -544,7 +602,7 @@ mejs.PluginMediaElement.prototype = {
|
|
544
602
|
|
545
603
|
positionFullscreenButton: function(x,y,visibleAndAbove) {
|
546
604
|
if (this.pluginApi != null && this.pluginApi.positionFullscreenButton) {
|
547
|
-
this.pluginApi.positionFullscreenButton(x,y,visibleAndAbove);
|
605
|
+
this.pluginApi.positionFullscreenButton(Math.floor(x),Math.floor(y),visibleAndAbove);
|
548
606
|
}
|
549
607
|
},
|
550
608
|
|
@@ -756,6 +814,10 @@ mejs.MediaPluginBridge = {
|
|
756
814
|
bufferedTime,
|
757
815
|
pluginMediaElement = this.pluginMediaElements[id];
|
758
816
|
|
817
|
+
if(!pluginMediaElement){
|
818
|
+
return;
|
819
|
+
}
|
820
|
+
|
759
821
|
// fake event object to mimic real HTML media event.
|
760
822
|
e = {
|
761
823
|
type: eventName,
|
@@ -800,6 +862,8 @@ mejs.MediaElementDefaults = {
|
|
800
862
|
plugins: ['flash','silverlight','youtube','vimeo'],
|
801
863
|
// shows debug errors on screen
|
802
864
|
enablePluginDebug: false,
|
865
|
+
// use plugin for browsers that have trouble with Basic Authentication on HTTPS sites
|
866
|
+
httpsBasicAuthSite: false,
|
803
867
|
// overrides the type specified, useful for dynamic instantiation
|
804
868
|
type: '',
|
805
869
|
// path to Flash and Silverlight plugins
|
@@ -810,6 +874,10 @@ mejs.MediaElementDefaults = {
|
|
810
874
|
flashStreamer: '',
|
811
875
|
// turns on the smoothing filter in Flash
|
812
876
|
enablePluginSmoothing: false,
|
877
|
+
// enabled pseudo-streaming (seek) on .mp4 files
|
878
|
+
enablePseudoStreaming: false,
|
879
|
+
// start query parameter sent to server for pseudo-streaming
|
880
|
+
pseudoStreamingStartQueryParam: 'start',
|
813
881
|
// name of silverlight file
|
814
882
|
silverlightName: 'silverlightmediaelement.xap',
|
815
883
|
// default if the <video width> is not specified
|
@@ -966,7 +1034,7 @@ mejs.HtmlMediaElementShim = {
|
|
966
1034
|
|
967
1035
|
|
968
1036
|
// test for native playback first
|
969
|
-
if (supportsMediaTag && (options.mode === 'auto' || options.mode === 'auto_plugin' || options.mode === 'native')) {
|
1037
|
+
if (supportsMediaTag && (options.mode === 'auto' || options.mode === 'auto_plugin' || options.mode === 'native') && !(mejs.MediaFeatures.isBustedNativeHTTPS && options.httpsBasicAuthSite === true)) {
|
970
1038
|
|
971
1039
|
if (!isMediaTag) {
|
972
1040
|
|
@@ -1075,7 +1143,7 @@ mejs.HtmlMediaElementShim = {
|
|
1075
1143
|
|
1076
1144
|
getTypeFromFile: function(url) {
|
1077
1145
|
url = url.split('?')[0];
|
1078
|
-
var ext = url.substring(url.lastIndexOf('.') + 1);
|
1146
|
+
var ext = url.substring(url.lastIndexOf('.') + 1).toLowerCase();
|
1079
1147
|
return (/(mp4|m4v|ogg|ogv|webm|webmv|flv|wmv|mpeg|mov)/gi.test(ext) ? 'video' : 'audio') + '/' + this.getTypeFromExtension(ext);
|
1080
1148
|
},
|
1081
1149
|
|
@@ -1110,9 +1178,13 @@ mejs.HtmlMediaElementShim = {
|
|
1110
1178
|
errorContainer.style.height = htmlMediaElement.height + 'px';
|
1111
1179
|
} catch (e) {}
|
1112
1180
|
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1181
|
+
if (options.customError) {
|
1182
|
+
errorContainer.innerHTML = options.customError;
|
1183
|
+
} else {
|
1184
|
+
errorContainer.innerHTML = (poster !== '') ?
|
1185
|
+
'<a href="' + playback.url + '"><img src="' + poster + '" width="100%" height="100%" /></a>' :
|
1186
|
+
'<a href="' + playback.url + '"><span>' + mejs.i18n.t('Download File') + '</span></a>';
|
1187
|
+
}
|
1116
1188
|
|
1117
1189
|
htmlMediaElement.parentNode.insertBefore(errorContainer, htmlMediaElement);
|
1118
1190
|
htmlMediaElement.style.display = 'none';
|
@@ -1154,8 +1226,8 @@ mejs.HtmlMediaElementShim = {
|
|
1154
1226
|
}
|
1155
1227
|
|
1156
1228
|
if (playback.isVideo) {
|
1157
|
-
width = (options.videoWidth > 0) ? options.videoWidth : (htmlMediaElement.getAttribute('width') !== null) ? htmlMediaElement.getAttribute('width') : options.defaultVideoWidth;
|
1158
|
-
height = (options.videoHeight > 0) ? options.videoHeight : (htmlMediaElement.getAttribute('height') !== null) ? htmlMediaElement.getAttribute('height') : options.defaultVideoHeight;
|
1229
|
+
width = (options.pluginWidth > 0) ? options.pluginWidth : (options.videoWidth > 0) ? options.videoWidth : (htmlMediaElement.getAttribute('width') !== null) ? htmlMediaElement.getAttribute('width') : options.defaultVideoWidth;
|
1230
|
+
height = (options.pluginHeight > 0) ? options.pluginHeight : (options.videoHeight > 0) ? options.videoHeight : (htmlMediaElement.getAttribute('height') !== null) ? htmlMediaElement.getAttribute('height') : options.defaultVideoHeight;
|
1159
1231
|
|
1160
1232
|
// in case of '%' make sure it's encoded
|
1161
1233
|
width = mejs.Utility.encodeUrl(width);
|
@@ -1192,7 +1264,8 @@ mejs.HtmlMediaElementShim = {
|
|
1192
1264
|
'startvolume=' + options.startVolume,
|
1193
1265
|
'timerrate=' + options.timerRate,
|
1194
1266
|
'flashstreamer=' + options.flashStreamer,
|
1195
|
-
'height=' + height
|
1267
|
+
'height=' + height,
|
1268
|
+
'pseudostreamstart=' + options.pseudoStreamingStartQueryParam];
|
1196
1269
|
|
1197
1270
|
if (playback.url !== null) {
|
1198
1271
|
if (playback.method == 'flash') {
|
@@ -1207,6 +1280,9 @@ mejs.HtmlMediaElementShim = {
|
|
1207
1280
|
if (options.enablePluginSmoothing) {
|
1208
1281
|
initVars.push('smoothing=true');
|
1209
1282
|
}
|
1283
|
+
if (options.enablePseudoStreaming) {
|
1284
|
+
initVars.push('pseudostreaming=true');
|
1285
|
+
}
|
1210
1286
|
if (controls) {
|
1211
1287
|
initVars.push('controls=true'); // shows controls in the plugin if desired
|
1212
1288
|
}
|
@@ -1242,6 +1318,7 @@ mejs.HtmlMediaElementShim = {
|
|
1242
1318
|
'<param name="wmode" value="transparent" />' +
|
1243
1319
|
'<param name="allowScriptAccess" value="always" />' +
|
1244
1320
|
'<param name="allowFullScreen" value="true" />' +
|
1321
|
+
'<param name="scale" value="default" />' +
|
1245
1322
|
'</object>';
|
1246
1323
|
|
1247
1324
|
} else {
|
@@ -1260,6 +1337,7 @@ mejs.HtmlMediaElementShim = {
|
|
1260
1337
|
'flashvars="' + initVars.join('&') + '" ' +
|
1261
1338
|
'width="' + width + '" ' +
|
1262
1339
|
'height="' + height + '" ' +
|
1340
|
+
'scale="default"' +
|
1263
1341
|
'class="mejs-shim"></embed>';
|
1264
1342
|
}
|
1265
1343
|
break;
|
@@ -1289,7 +1367,7 @@ mejs.HtmlMediaElementShim = {
|
|
1289
1367
|
|
1290
1368
|
// DEMO Code. Does NOT work.
|
1291
1369
|
case 'vimeo':
|
1292
|
-
//
|
1370
|
+
//
|
1293
1371
|
|
1294
1372
|
pluginMediaElement.vimeoid = playback.url.substr(playback.url.lastIndexOf('/')+1);
|
1295
1373
|
|
@@ -1310,6 +1388,8 @@ mejs.HtmlMediaElementShim = {
|
|
1310
1388
|
}
|
1311
1389
|
// hide original element
|
1312
1390
|
htmlMediaElement.style.display = 'none';
|
1391
|
+
// prevent browser from autoplaying when using a plugin
|
1392
|
+
htmlMediaElement.removeAttribute('autoplay');
|
1313
1393
|
|
1314
1394
|
// FYI: options.success will be fired by the MediaPluginBridge
|
1315
1395
|
|
@@ -1375,7 +1455,7 @@ mejs.YouTubeApi = {
|
|
1375
1455
|
loadIframeApi: function() {
|
1376
1456
|
if (!this.isIframeStarted) {
|
1377
1457
|
var tag = document.createElement('script');
|
1378
|
-
tag.src = "
|
1458
|
+
tag.src = "//www.youtube.com/player_api";
|
1379
1459
|
var firstScriptTag = document.getElementsByTagName('script')[0];
|
1380
1460
|
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
1381
1461
|
this.isIframeStarted = true;
|
@@ -1493,7 +1573,7 @@ mejs.YouTubeApi = {
|
|
1493
1573
|
*/
|
1494
1574
|
|
1495
1575
|
var specialIEContainer,
|
1496
|
-
youtubeUrl = '
|
1576
|
+
youtubeUrl = '//www.youtube.com/apiplayer?enablejsapi=1&playerapiid=' + settings.pluginId + '&version=3&autoplay=0&controls=0&modestbranding=1&loop=0';
|
1497
1577
|
|
1498
1578
|
if (mejs.MediaFeatures.isIE) {
|
1499
1579
|
|
@@ -1592,30 +1672,26 @@ window.mejs = mejs;
|
|
1592
1672
|
window.MediaElement = mejs.MediaElement;
|
1593
1673
|
|
1594
1674
|
/*!
|
1595
|
-
* Adds Internationalization and localization to
|
1596
|
-
*
|
1597
|
-
* What is the concept beyond i18n?
|
1598
|
-
* http://en.wikipedia.org/wiki/Internationalization_and_localization
|
1675
|
+
* Adds Internationalization and localization to mediaelement.
|
1599
1676
|
*
|
1677
|
+
* This file does not contain translations, you have to add the manually.
|
1678
|
+
* The schema is always the same: me-i18n-locale-[ISO_639-1 Code].js
|
1600
1679
|
*
|
1601
|
-
*
|
1602
|
-
* strings into other languages.
|
1680
|
+
* Examples are provided both for german and chinese translation.
|
1603
1681
|
*
|
1604
|
-
* Default translations are not available, you have to add them
|
1605
|
-
* through locale objects which are named exactly as the langcode
|
1606
|
-
* they stand for. The default language is always english (en).
|
1607
1682
|
*
|
1683
|
+
* What is the concept beyond i18n?
|
1684
|
+
* http://en.wikipedia.org/wiki/Internationalization_and_localization
|
1608
1685
|
*
|
1609
|
-
*
|
1610
|
-
*
|
1686
|
+
* What langcode should i use?
|
1687
|
+
* http://en.wikipedia.org/wiki/ISO_639-1
|
1611
1688
|
*
|
1612
1689
|
*
|
1613
|
-
*
|
1690
|
+
* License?
|
1614
1691
|
*
|
1615
1692
|
* The i18n file uses methods from the Drupal project (drupal.js):
|
1616
1693
|
* - i18n.methods.t() (modified)
|
1617
1694
|
* - i18n.methods.checkPlain() (full copy)
|
1618
|
-
* - i18n.methods.formatString() (full copy)
|
1619
1695
|
*
|
1620
1696
|
* The Drupal project is (like mediaelementjs) licensed under GPLv2.
|
1621
1697
|
* - http://drupal.org/licensing/faq/#q1
|
@@ -1626,19 +1702,17 @@ window.MediaElement = mejs.MediaElement;
|
|
1626
1702
|
* @author
|
1627
1703
|
* Tim Latz (latz.tim@gmail.com)
|
1628
1704
|
*
|
1629
|
-
* @see
|
1630
|
-
* me-i18n-locale.js
|
1631
1705
|
*
|
1632
1706
|
* @params
|
1633
|
-
* - $ - zepto || jQuery ..
|
1634
1707
|
* - context - document, iframe ..
|
1635
1708
|
* - exports - CommonJS, window ..
|
1636
1709
|
*
|
1637
1710
|
*/
|
1638
|
-
;(function(
|
1711
|
+
;(function(context, exports, undefined) {
|
1639
1712
|
"use strict";
|
1640
1713
|
var i18n = {
|
1641
1714
|
"locale": {
|
1715
|
+
"language" : '',
|
1642
1716
|
"strings" : {}
|
1643
1717
|
},
|
1644
1718
|
"methods" : {}
|
@@ -1647,20 +1721,19 @@ window.MediaElement = mejs.MediaElement;
|
|
1647
1721
|
|
1648
1722
|
|
1649
1723
|
/**
|
1650
|
-
* Get
|
1651
|
-
*
|
1652
|
-
* @see: i18n.methods.t()
|
1724
|
+
* Get language, fallback to browser's language if empty
|
1653
1725
|
*/
|
1654
|
-
i18n.
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1726
|
+
i18n.getLanguage = function () {
|
1727
|
+
var language = i18n.locale.language || window.navigator.userLanguage || window.navigator.language;
|
1728
|
+
// convert to iso 639-1 (2-letters, lower case)
|
1729
|
+
return language.substr(0, 2).toLowerCase();
|
1658
1730
|
};
|
1659
1731
|
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1732
|
+
// i18n fixes for compatibility with WordPress
|
1733
|
+
if ( typeof mejsL10n != 'undefined' ) {
|
1734
|
+
i18n.locale.language = mejsL10n.language;
|
1735
|
+
}
|
1736
|
+
|
1664
1737
|
|
1665
1738
|
|
1666
1739
|
/**
|
@@ -1684,74 +1757,28 @@ window.MediaElement = mejs.MediaElement;
|
|
1684
1757
|
return str;
|
1685
1758
|
};
|
1686
1759
|
|
1687
|
-
/**
|
1688
|
-
* Replace placeholders with sanitized values in a string.
|
1689
|
-
*
|
1690
|
-
* @param str
|
1691
|
-
* A string with placeholders.
|
1692
|
-
* @param args
|
1693
|
-
* An object of replacements pairs to make. Incidences of any key in this
|
1694
|
-
* array are replaced with the corresponding value. Based on the first
|
1695
|
-
* character of the key, the value is escaped and/or themed:
|
1696
|
-
* - !variable: inserted as is
|
1697
|
-
* - @variable: escape plain text to HTML (i18n.methods.checkPlain)
|
1698
|
-
* - %variable: escape text and theme as a placeholder for user-submitted
|
1699
|
-
* content (checkPlain + <em class="placeholder" > )
|
1700
|
-
*
|
1701
|
-
* @see i18n.methods.t()
|
1702
|
-
*/
|
1703
|
-
i18n.methods.formatString = function(str, args) {
|
1704
|
-
// Transform arguments before inserting them.
|
1705
|
-
for (var key in args) {
|
1706
|
-
switch (key.charAt(0)) {
|
1707
|
-
// Escaped only.
|
1708
|
-
case '@':
|
1709
|
-
args[key] = i18n.methods.checkPlain(args[key]);
|
1710
|
-
break;
|
1711
|
-
// Pass-through.
|
1712
|
-
case '!':
|
1713
|
-
break;
|
1714
|
-
// Escaped and placeholder.
|
1715
|
-
case '%':
|
1716
|
-
default:
|
1717
|
-
args[key] = '<em class="placeholder">' + i18n.methods.checkPlain(args[key]) + '</em>';
|
1718
|
-
break;
|
1719
|
-
}
|
1720
|
-
str = str.replace(key, args[key]);
|
1721
|
-
}
|
1722
|
-
return str;
|
1723
|
-
};
|
1724
|
-
|
1725
1760
|
/**
|
1726
1761
|
* Translate strings to the page language or a given language.
|
1727
1762
|
*
|
1728
|
-
* See the documentation of the server-side t() function for further details.
|
1729
1763
|
*
|
1730
1764
|
* @param str
|
1731
1765
|
* A string containing the English string to translate.
|
1732
|
-
* @param args
|
1733
|
-
* An object of replacements pairs to make after translation. Incidences
|
1734
|
-
* of any key in this array are replaced with the corresponding value.
|
1735
|
-
* See i18n.methods.formatString().
|
1736
1766
|
*
|
1737
1767
|
* @param options
|
1738
1768
|
* - 'context' (defaults to the default context): The context the source string
|
1739
1769
|
* belongs to.
|
1740
1770
|
*
|
1741
1771
|
* @return
|
1742
|
-
* The translated string.
|
1772
|
+
* The translated string, escaped via i18n.methods.checkPlain()
|
1743
1773
|
*/
|
1744
|
-
i18n.methods.t = function (str,
|
1774
|
+
i18n.methods.t = function (str, options) {
|
1745
1775
|
|
1746
1776
|
// Fetch the localized version of the string.
|
1747
1777
|
if (i18n.locale.strings && i18n.locale.strings[options.context] && i18n.locale.strings[options.context][str]) {
|
1748
1778
|
str = i18n.locale.strings[options.context][str];
|
1749
1779
|
}
|
1750
1780
|
|
1751
|
-
|
1752
|
-
str = i18n.methods.formatString(str, args);
|
1753
|
-
}
|
1754
|
-
return str;
|
1781
|
+
return i18n.methods.checkPlain(str);
|
1755
1782
|
};
|
1756
1783
|
|
1757
1784
|
|
@@ -1761,35 +1788,47 @@ window.MediaElement = mejs.MediaElement;
|
|
1761
1788
|
* @see i18n.methods.t()
|
1762
1789
|
* @throws InvalidArgumentException
|
1763
1790
|
*/
|
1764
|
-
i18n.t = function(str,
|
1791
|
+
i18n.t = function(str, options) {
|
1765
1792
|
|
1766
1793
|
if (typeof str === 'string' && str.length > 0) {
|
1767
1794
|
|
1768
|
-
// check every time due
|
1795
|
+
// check every time due language can change for
|
1769
1796
|
// different reasons (translation, lang switcher ..)
|
1770
|
-
var
|
1797
|
+
var language = i18n.getLanguage();
|
1771
1798
|
|
1772
1799
|
options = options || {
|
1773
|
-
"context" :
|
1800
|
+
"context" : language
|
1774
1801
|
};
|
1775
1802
|
|
1776
|
-
return i18n.methods.t(str,
|
1803
|
+
return i18n.methods.t(str, options);
|
1777
1804
|
}
|
1778
1805
|
else {
|
1779
1806
|
throw {
|
1780
1807
|
"name" : 'InvalidArgumentException',
|
1781
1808
|
"message" : 'First argument is either not a string or empty.'
|
1782
|
-
}
|
1809
|
+
};
|
1783
1810
|
}
|
1784
1811
|
};
|
1785
1812
|
|
1786
1813
|
// end i18n
|
1787
1814
|
exports.i18n = i18n;
|
1788
|
-
}(
|
1815
|
+
}(document, mejs));
|
1816
|
+
|
1817
|
+
// i18n fixes for compatibility with WordPress
|
1818
|
+
;(function(exports, undefined) {
|
1819
|
+
|
1820
|
+
"use strict";
|
1821
|
+
|
1822
|
+
if ( typeof mejsL10n != 'undefined' ) {
|
1823
|
+
exports[mejsL10n.language] = mejsL10n.strings;
|
1824
|
+
}
|
1825
|
+
|
1826
|
+
}(mejs.i18n.locale.strings));
|
1827
|
+
|
1789
1828
|
/*!
|
1790
1829
|
* This is a i18n.locale language object.
|
1791
1830
|
*
|
1792
|
-
|
1831
|
+
* German translation by Tim Latz, latz.tim@gmail.com
|
1793
1832
|
*
|
1794
1833
|
* @author
|
1795
1834
|
* Tim Latz (latz.tim@gmail.com)
|
@@ -1804,11 +1843,42 @@ window.MediaElement = mejs.MediaElement;
|
|
1804
1843
|
|
1805
1844
|
"use strict";
|
1806
1845
|
|
1807
|
-
exports.de
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1846
|
+
if (typeof exports.de === 'undefined') {
|
1847
|
+
exports.de = {
|
1848
|
+
"Fullscreen" : "Vollbild",
|
1849
|
+
"Go Fullscreen" : "Vollbild an",
|
1850
|
+
"Turn off Fullscreen" : "Vollbild aus",
|
1851
|
+
"Close" : "Schließen"
|
1852
|
+
};
|
1853
|
+
}
|
1813
1854
|
|
1814
1855
|
}(mejs.i18n.locale.strings));
|
1856
|
+
/*!
|
1857
|
+
* This is a i18n.locale language object.
|
1858
|
+
*
|
1859
|
+
* Traditional chinese translation by Tim Latz, latz.tim@gmail.com
|
1860
|
+
*
|
1861
|
+
* @author
|
1862
|
+
* Tim Latz (latz.tim@gmail.com)
|
1863
|
+
*
|
1864
|
+
* @see
|
1865
|
+
* me-i18n.js
|
1866
|
+
*
|
1867
|
+
* @params
|
1868
|
+
* - exports - CommonJS, window ..
|
1869
|
+
*/
|
1870
|
+
;(function(exports, undefined) {
|
1871
|
+
|
1872
|
+
"use strict";
|
1873
|
+
|
1874
|
+
if (typeof exports.zh === 'undefined') {
|
1875
|
+
exports.zh = {
|
1876
|
+
"Fullscreen" : "全螢幕",
|
1877
|
+
"Go Fullscreen" : "全屏模式",
|
1878
|
+
"Turn off Fullscreen" : "退出全屏模式",
|
1879
|
+
"Close" : "關閉"
|
1880
|
+
};
|
1881
|
+
}
|
1882
|
+
|
1883
|
+
}(mejs.i18n.locale.strings));
|
1884
|
+
|