|
921
|
1 |
/* TODO: Add Slide synchronization */ |
|
|
2 |
|
|
|
3 |
IriSP.Widgets.Slideshare = function(player, config) { |
|
|
4 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
5 |
this.lastSlide = { |
|
|
6 |
presentation: "", |
|
|
7 |
slide: 0 |
|
|
8 |
} |
|
|
9 |
this.embedObject = null; |
|
|
10 |
this.oembedCache = {} |
|
|
11 |
} |
|
|
12 |
|
|
|
13 |
IriSP.Widgets.Slideshare.prototype = new IriSP.Widgets.Widget(); |
|
|
14 |
|
|
|
15 |
IriSP.Widgets.Slideshare.prototype.defaults = { |
|
|
16 |
annotation_type: "slide", |
|
|
17 |
sync: true, |
|
|
18 |
embed_width: 400, |
|
|
19 |
embed_height: 300 |
|
|
20 |
} |
|
|
21 |
|
|
|
22 |
IriSP.Widgets.Slideshare.prototype.messages = { |
|
|
23 |
fr: { |
|
|
24 |
slides_ : "Diapositives :" |
|
|
25 |
}, |
|
|
26 |
en: { |
|
|
27 |
slides_ : "Slides:" |
|
|
28 |
} |
|
|
29 |
} |
|
|
30 |
|
|
|
31 |
IriSP.Widgets.Slideshare.prototype.template = |
|
|
32 |
'<div class="Ldt-SlideShare"><h2>{{l10n.slides_}}</h2><hr /><div class="Ldt-SlideShare-Container"></div></div>'; |
|
|
33 |
|
|
|
34 |
IriSP.Widgets.Slideshare.prototype.draw = function() { |
|
|
35 |
var _hide = false; |
|
|
36 |
if (typeof this.annotation_type !== "undefined" && this.annotation_type) { |
|
|
37 |
var _annType = this.source.getAnnotationTypes().searchByTitle(this.annotation_type); |
|
|
38 |
_hide = !_annType.length; |
|
|
39 |
} |
|
|
40 |
if (_hide) { |
|
|
41 |
this.$.hide(); |
|
|
42 |
} else { |
|
|
43 |
this.renderTemplate(); |
|
|
44 |
this.$container = this.$.find(".Ldt-SlideShare-Container"); |
|
957
|
45 |
this.onMediaEvent("timeupdate","onTimeupdate"); |
|
|
46 |
this.onTimeupdate(0); |
|
921
|
47 |
} |
|
|
48 |
} |
|
|
49 |
|
|
957
|
50 |
IriSP.Widgets.Slideshare.prototype.onTimeupdate = function(_time) { |
|
921
|
51 |
var _list = this.getWidgetAnnotationsAtTime(); |
|
|
52 |
if (_list.length) { |
|
|
53 |
var _description = _list[0].description, |
|
|
54 |
_isurl = /^https?:\/\//.test(_description), |
|
|
55 |
_presentation = _description.replace(/#.*$/,''), |
|
|
56 |
_slidematch = _description.match(/(#|\?|&)id=(\d+)/), |
|
|
57 |
_slide = parseInt(_slidematch && _slidematch.length > 2 ? _slidematch[2] : 1), |
|
|
58 |
_this = this; |
|
|
59 |
if (_presentation !== this.lastSlide.presentation) { |
|
|
60 |
if (_isurl) { |
|
|
61 |
if (typeof this.oembedCache[_presentation] === "undefined") { |
|
|
62 |
var _ajaxUrl = "http://www.slideshare.net/api/oembed/1?url=" |
|
|
63 |
+ encodeURIComponent(_presentation) |
|
|
64 |
+ "&format=jsonp&callback=?"; |
|
|
65 |
IriSP.jQuery.getJSON(_ajaxUrl, function(_oembedData) { |
|
|
66 |
var _presmatch = _oembedData.html.match(/doc=([a-z0-9\-_%]+)/i); |
|
|
67 |
if (_presmatch && _presmatch.length > 1) { |
|
|
68 |
_this.oembedCache[_presentation] = _presmatch[1]; |
|
|
69 |
_this.insertSlideshare(_presmatch[1], _slide); |
|
|
70 |
} |
|
|
71 |
}); |
|
|
72 |
} else { |
|
|
73 |
this.insertSlideshare(this.oembedCache[_presentation], _slide); |
|
|
74 |
} |
|
|
75 |
} else { |
|
|
76 |
this.insertSlideshare(_presentation, _slide); |
|
|
77 |
} |
|
|
78 |
} |
|
|
79 |
if (_slide != this.lastSlide.slide && this.sync && this.embedObject && typeof this.embedObject.jumpTo === "function") { |
|
|
80 |
this.embedObject.jumpTo(parseInt(_slide)); |
|
|
81 |
} |
|
|
82 |
this.lastSlide = { |
|
|
83 |
presentation: _presentation, |
|
|
84 |
slide: _slide |
|
|
85 |
} |
|
|
86 |
} else { |
|
|
87 |
if (this.lastSlide.presentation) { |
|
|
88 |
this.$container.hide(); |
|
|
89 |
this.lastSlide = { |
|
|
90 |
presentation: "", |
|
|
91 |
slide: 0 |
|
|
92 |
} |
|
|
93 |
} |
|
|
94 |
} |
|
|
95 |
} |
|
|
96 |
|
|
|
97 |
IriSP.Widgets.Slideshare.prototype.insertSlideshare = function(_presentation, _slide) { |
|
|
98 |
if (this.lastEmbedded === _presentation) { |
|
|
99 |
if (this.embedObject && typeof this.embedObject.jumpTo === "function") { |
|
|
100 |
this.embedObject.jumpTo(parseInt(_slide)); |
|
|
101 |
} |
|
|
102 |
} else { |
|
|
103 |
this.lastEmbedded = _presentation; |
|
|
104 |
var _id = IriSP.Model.getUID(), |
|
|
105 |
_params = { |
|
|
106 |
allowScriptAccess: "always" |
|
|
107 |
} |
|
|
108 |
_atts = { |
|
|
109 |
id: _id |
|
|
110 |
}, |
|
|
111 |
_flashvars = { |
|
|
112 |
doc : _presentation, |
|
|
113 |
startSlide : _slide |
|
|
114 |
}; |
|
|
115 |
this.$container.html('<div id="' + _id + '"></div>'); |
|
|
116 |
swfobject.embedSWF( |
|
|
117 |
"http://static.slidesharecdn.com/swf/ssplayer2.swf", |
|
|
118 |
_id, |
|
|
119 |
this.embed_width, |
|
|
120 |
this.embed_height, |
|
|
121 |
"8", |
|
|
122 |
null, |
|
|
123 |
_flashvars, |
|
|
124 |
_params, |
|
|
125 |
_atts |
|
|
126 |
); |
|
|
127 |
this.embedObject = document.getElementById(_id); |
|
|
128 |
} |
|
|
129 |
this.$container.show(); |
|
|
130 |
} |