-
Notifications
You must be signed in to change notification settings - Fork 1
/
edu.js
87 lines (77 loc) · 3.2 KB
/
edu.js
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
/**
* @package filter_edusharing
* @copyright metaVentis GmbH — http://metaventis.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
(function(jquery) {
!function () {
function a(a, b) {
var c = void 0 !== window.pageYOffset ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop,
d = document.documentElement.clientHeight, e = c + d;
b = b || 0;
var f = a.getBoundingClientRect();
if (0 === f.height) return !1;
var g = f.top + c - b, h = f.bottom + c + b;
return h > c && e > g
}
jquery.expr[":"]["near-viewport"] = function (b, c, d) {
var e = parseInt(d[3]) || 0;
return a(b, e)
}
}();
jquery.ajaxSetup({cache: false});
var videoFormat = 'webm';
var v = document.createElement('video');
if (v.canPlayType && v.canPlayType('video/mp4').replace(/no/, '')) {
videoFormat = 'mp4';
}
function renderEsObject(esObject, wrapper) {
var url = esObject.attr("data-url") + '&videoFormat=' + videoFormat;
let width = 'auto';
const urlParams = new URLSearchParams(url);
if(urlParams.get('width')){
width = urlParams.get('width');
}
if (typeof wrapper == 'undefined')
var wrapper = esObject.parent();
//alert(url);
jquery.get(url, function (data) {
wrapper.html('').append(data).css({display: 'none', height: 'auto', width: 'auto'}).fadeIn('slow', 'linear');
if (data.toLowerCase().indexOf('data-view="lock"') >= 0)
setTimeout(function () {
renderEsObject(esObject, wrapper);
}, 1111);
});
esObject.removeAttr("data-type");
}
jquery(window).scroll(function () {
jquery("div[data-type='esObject']:near-viewport(400)").each(function () {
renderEsObject(jquery(this));
})
});
jquery(document).ready(function() {
jquery("div[data-type='esObject']:near-viewport(400)").each(function () {
renderEsObject(jquery(this));
})
jquery("body").click(function (e) {
if (jquery(e.target).closest(".edusharing_metadata").length) {
//clicked inside ".edusharing_metadata" - do nothing
} else if (jquery(e.target).closest(".edusharing_metadata_toggle_button").length) {
jquery(".edusharing_metadata").fadeOut('fast');
toggle_button = jquery(e.target);
metadata = toggle_button.parent().find(".edusharing_metadata");
if (metadata.hasClass('open')) {
metadata.toggleClass('open');
metadata.fadeOut('fast');
} else {
jquery(".edusharing_metadata").removeClass('open');
metadata.toggleClass('open');
metadata.fadeIn('fast');
}
} else {
jquery(".edusharing_metadata").fadeOut('fast');
jquery(".edusharing_metadata").removeClass('open');
}
})
});
})( jQuery );