| author | ymh <ymh.work@gmail.com> |
| Tue, 22 Oct 2024 07:03:54 +0200 | |
| changeset 1076 | 510fd2a482f4 |
| parent 1072 | ac1eacb3aa33 |
| permissions | -rw-r--r-- |
| 921 | 1 |
/* TODO: Add Slide synchronization */ |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
2 |
import slideshareStyles from "./Slideshare.module.css"; |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
3 |
import jQuery from "jquery"; |
| 921 | 4 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
5 |
const Slideshare = function(ns) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
6 |
return class extends ns.Widgets.Widget { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
7 |
constructor(player, config) { |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
8 |
super(player, config); |
| 1013 | 9 |
}; |
| 921 | 10 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
11 |
static defaults = { |
| 921 | 12 |
annotation_type: "slide", |
13 |
sync: true, |
|
| 1013 | 14 |
}; |
| 921 | 15 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
16 |
static messages = { |
| 921 | 17 |
fr: { |
|
988
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
965
diff
changeset
|
18 |
slides_ : "Diapositives" |
| 921 | 19 |
}, |
20 |
en: { |
|
|
988
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
965
diff
changeset
|
21 |
slides_ : "Slides" |
| 921 | 22 |
} |
| 1013 | 23 |
}; |
| 921 | 24 |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
25 |
static template = |
| 921 | 26 |
'<div class="Ldt-SlideShare"><h2>{{l10n.slides_}}</h2><hr /><div class="Ldt-SlideShare-Container"></div></div>'; |
27 |
||
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
28 |
draw() { |
| 965 | 29 |
|
30 |
function insertSlideshare(_presentation, _slide) { |
|
31 |
if (_lastEmbedded === _presentation) { |
|
|
988
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
965
diff
changeset
|
32 |
if (_embedObject && typeof _embedObject.jumpTo === "function") { |
| 965 | 33 |
_embedObject.jumpTo(parseInt(_slide)); |
34 |
} |
|
35 |
} else { |
|
36 |
_lastEmbedded = _presentation; |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
37 |
var _id = ns.Model.getUID(), |
| 965 | 38 |
_params = { |
39 |
allowScriptAccess: "always" |
|
| 1013 | 40 |
}, |
| 965 | 41 |
_atts = { |
42 |
id: _id |
|
43 |
}, |
|
44 |
_flashvars = { |
|
45 |
doc : _presentation, |
|
46 |
startSlide : _slide |
|
47 |
}; |
|
48 |
$container.html('<div id="' + _id + '"></div>'); |
|
49 |
swfobject.embedSWF( |
|
50 |
"http://static.slidesharecdn.com/swf/ssplayer2.swf", |
|
51 |
_id, |
|
52 |
_this.embed_width, |
|
53 |
_this.embed_height, |
|
54 |
"8", |
|
55 |
null, |
|
56 |
_flashvars, |
|
57 |
_params, |
|
58 |
_atts |
|
59 |
); |
|
60 |
_embedObject = document.getElementById(_id); |
|
61 |
} |
|
62 |
$container.show(); |
|
| 921 | 63 |
} |
| 965 | 64 |
|
65 |
var _annotations = this.getWidgetAnnotations(); |
|
66 |
if (!_annotations.length) { |
|
| 921 | 67 |
this.$.hide(); |
68 |
} else { |
|
69 |
this.renderTemplate(); |
|
| 965 | 70 |
var _lastPres = "", |
71 |
_embedObject = null, |
|
72 |
_oembedCache = {}, |
|
|
988
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
965
diff
changeset
|
73 |
_lastEmbedded = "", |
| 1013 | 74 |
_this = this, |
|
988
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
965
diff
changeset
|
75 |
$container = this.$.find(".Ldt-SlideShare-Container"); |
|
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
965
diff
changeset
|
76 |
|
|
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
965
diff
changeset
|
77 |
this.embed_width = this.embed_width || $container.innerWidth(); |
|
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
965
diff
changeset
|
78 |
this.embed_height = this.embed_height || Math.floor(this.embed_width * 3/4); |
|
eefd336335f9
Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents:
965
diff
changeset
|
79 |
|
| 965 | 80 |
_annotations.forEach(function(_a) { |
81 |
_a.on("leave", function() { |
|
82 |
$container.hide(); |
|
83 |
_lastPres = ""; |
|
84 |
}); |
|
85 |
_a.on("enter", function() { |
|
86 |
var _description = _a.description, |
|
87 |
_isurl = /^https?:\/\//.test(_description), |
|
88 |
_presentation = _description.replace(/#.*$/,''), |
|
89 |
_slidematch = _description.match(/(#|\?|&)id=(\d+)/), |
|
90 |
_slide = parseInt(_slidematch && _slidematch.length > 2 ? _slidematch[2] : 1); |
|
91 |
if (_presentation !== _lastPres) { |
|
92 |
if (_isurl) { |
|
93 |
if (typeof _oembedCache[_presentation] === "undefined") { |
|
94 |
var _ajaxUrl = "http://www.slideshare.net/api/oembed/1?url=" |
|
95 |
+ encodeURIComponent(_presentation) |
|
96 |
+ "&format=jsonp&callback=?"; |
|
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
97 |
jQuery.getJSON(_ajaxUrl, function(_oembedData) { |
| 965 | 98 |
var _presmatch = _oembedData.html.match(/doc=([a-z0-9\-_%]+)/i); |
99 |
if (_presmatch && _presmatch.length > 1) { |
|
100 |
_oembedCache[_presentation] = _presmatch[1]; |
|
101 |
insertSlideshare(_presmatch[1], _slide); |
|
102 |
} |
|
103 |
}); |
|
104 |
} else { |
|
105 |
insertSlideshare(_oembedCache[_presentation], _slide); |
|
106 |
} |
|
107 |
} else { |
|
108 |
insertSlideshare(_presentation, _slide); |
|
109 |
} |
|
110 |
} |
|
111 |
if (_this.sync && _embedObject && typeof _embedObject.jumpTo === "function") { |
|
112 |
_embedObject.jumpTo(parseInt(_slide)); |
|
113 |
} |
|
114 |
_lastPres = _presentation; |
|
115 |
|
|
| 1013 | 116 |
}); |
117 |
}); |
|
| 921 | 118 |
} |
| 1013 | 119 |
}; |
|
1072
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
120 |
}} |
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
121 |
|
|
ac1eacb3aa33
Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
122 |
export { Slideshare, slideshareStyles }; |