# HG changeset patch # User cavaliet # Date 1334583894 -7200 # Node ID 05f75ca6b5de149daf4794f477f781a31f2aba7e # Parent 002a16ff171b67cec32f37df875827b8aa080d52 Add slide share widget. diff -r 002a16ff171b -r 05f75ca6b5de src/css/LdtPlayer.css --- a/src/css/LdtPlayer.css Thu Apr 12 18:41:11 2012 +0200 +++ b/src/css/LdtPlayer.css Mon Apr 16 15:44:54 2012 +0200 @@ -966,3 +966,12 @@ .Ldt-TagCloud-actif { color: #c000c0; } + +/* SlideShare Widget css */ +.Ldt-SlideShare { + font-family: "Arial","Verdana","sans-serif"; + font-size: 14px; +} +.Ldt-SlideShare .sync_links{ + text-align: right; +} diff -r 002a16ff171b -r 05f75ca6b5de src/js/serializers/JSONSerializer.js --- a/src/js/serializers/JSONSerializer.js Thu Apr 12 18:41:11 2012 +0200 +++ b/src/js/serializers/JSONSerializer.js Mon Apr 16 15:44:54 2012 +0200 @@ -440,4 +440,19 @@ val = this.getId("Publ"); return val; +}; + +/** return the id of the ligne de temps named "Slideshare" */ +IriSP.JSONSerializer.prototype.getSlideShareType = function() { + var val = this.getId("slideshare"); + if (typeof(val) === "undefined") + val = this.getId("Slides"); + if (typeof(val) === "undefined") + val = this.getId("Slide"); + if (typeof(val) === "undefined") + val = this.getId("slide-Share"); + if (typeof(val) === "undefined") + val = this.getId("slide Share"); + + return val; }; \ No newline at end of file diff -r 002a16ff171b -r 05f75ca6b5de src/js/widgets/slideShareWidget.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/js/widgets/slideShareWidget.js Mon Apr 16 15:44:54 2012 +0200 @@ -0,0 +1,325 @@ + +/** A widget to display slide show from embed slide share */ +IriSP.SlideShareWidget = function(Popcorn, config, Serializer) { + IriSP.Widget.call(this, Popcorn, config, Serializer); +}; + +IriSP.SlideShareWidget.prototype = new IriSP.Widget(); + +IriSP.SlideShareWidget.prototype.draw = function() { + var self = this; + + var templ = Mustache.to_html(IriSP.slideShareWidget_template); + this.selector.append(templ); + + // Synchro management + this._disableUpdate = false; + this.selector.find('.sync_on').click(function(event) { self.syncHandler.call(self, event); }); + this.selector.find('.sync_off').click(function(event) { self.unSyncHandler.call(self, event); }); + + // global variables used to keep the position and width of the zone. + this.zoneLeft = 0; + this.zoneWidth = 0; + // global variable to save the last slide url + this.lastSlide = ""; + this.containerDiv = this.selector.find('.SlideShareContainer'); + + // Update the slide from timeupdate event + this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.slideShareUpdater)); + + this._Popcorn.listen("IriSP.SlideShareWidget.show", IriSP.wrap(this, this.show)); + this._Popcorn.listen("IriSP.SlideShareWidget.hide", IriSP.wrap(this, this.hide)); + + // Get data from "slideshare" cutting/annotation-type + var annotations = this._serializer._data.annotations; + var view_type = this._serializer.getSlideShareType(); + if(typeof(view_type) === "undefined") { + return; + } + var i = 0; + this.segments_slides = []; + var nb_annot = annotations.length; + for (i = 0; i < nb_annot; i++) { + var annotation = annotations[i]; + /* filter the annotations whose type is not the one we want */ + if (view_type != "" && typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" + && annotation.meta["id-ref"] != view_type) { + continue; + } + this.segments_slides.push(annotation); + } +}; + +/* update the slider and the position marker as time passes */ +IriSP.SlideShareWidget.prototype.slideShareUpdater = function() { + // If it is asked not to synchronize, we do nothing + if(this._disableUpdate) + return; + + var self = this; + + // We search if a segments_slides is in the current timecode + var time = this._Popcorn.currentTime() * 1000; + var nb_slides = this.segments_slides.length; + var found = false; + for (i = 0; i < nb_slides; i++) { + var segment_slide = this.segments_slides[i]; + if(segment_slide.begin