-
Notifications
You must be signed in to change notification settings - Fork 190
Expand file tree
/
Copy pathyoutube.js
More file actions
30 lines (26 loc) · 904 Bytes
/
Copy pathyoutube.js
File metadata and controls
30 lines (26 loc) · 904 Bytes
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
(function(window, factory) {
if (typeof define === 'function' && define.amd) {
define(['lity'], function(lity) {
factory(lity);
});
} else if (typeof module === 'object' && typeof module.exports === 'object') {
factory(require('lity'));
} else {
factory(window.lity);
}
}(typeof window !== "undefined" ? window : this, function(lity) {
'use strict';
var _regex = /(youtube(-nocookie)?\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed\/?)?([\w-]{11})\?(.*)?/i;
lity.handlers('youtube', function(target, instance) {
var matches = _regex.exec(target);
if (!matches) {
return false;
}
return lity.iframe(
'https://www.youtube' + (matches[2] || '') + '.com/embed/' + matches[4] + '?autoplay=1',
instance,
matches[5],
target
);
});
}));