# HG changeset patch # User hamidouk # Date 1326814206 -3600 # Node ID 3c34dc8347818b6f82e0afe51832efad13e1d326 # Parent f47353222ac077da8e7cc7b54f88341fdebecde6 a whole lotta bugfixes. diff -r f47353222ac0 -r 3c34dc834781 src/ldt/ldt/static/ldt/js/LdtPlayer-release.js --- a/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js Mon Jan 16 16:57:49 2012 +0100 +++ b/src/ldt/ldt/static/ldt/js/LdtPlayer-release.js Tue Jan 17 16:30:06 2012 +0100 @@ -1182,7 +1182,7 @@ var currentTime = +time; jwplayer( IriSP.PopcornReplacement._container ).seek( currentTime ); IriSP.PopcornReplacement.__delay_seek_signal = true; - //return jwplayer(IriSP.PopcornReplacement._container).getPosition(); + IriSP.PopcornReplacement.trigger("seeked"); return currentTime; } }; @@ -1280,9 +1280,6 @@ } - if (IriSP.PopcornReplacement.__delay_seek_signal === true) { - IriSP.PopcornReplacement.trigger("seeked"); - } IriSP.PopcornReplacement.trigger("timeupdate"); }; @@ -1435,24 +1432,39 @@ }; /** returns an url to share on facebook */ -IriSP.mkFbUrl = function(url) { - return "http://www.facebook.com/share.php?u=" + "I'm watching " + url; +IriSP.mkFbUrl = function(url, text) { + if (typeof(text) === "undefined") + text = "I'm watching "; + + return "http://www.facebook.com/share.php?u=" + IriSP.encodeURI(text) + IriSP.shorten_url(url); }; /** returns an url to share on twitter */ -IriSP.mkTweetUrl = function(url) { - return "http://twitter.com/home?status=" + "I'm sharing " + url; +IriSP.mkTweetUrl = function(url, text) { + if (typeof(text) === "undefined") + text = "I'm watching "; + + return "http://twitter.com/home?status=" + IriSP.encodeURI(text) + IriSP.shorten_url(url); }; /** returns an url to share on google + */ -IriSP.mkGplusUrl = function(url) { +IriSP.mkGplusUrl = function(url, text) { return ""; }; /** test if a value is null or undefined */ IriSP.null_or_undefined = function(val) { return (typeof(val) === "undefined" || val === null); -} +}; + +/** issue a call to an url shortener and return the shortened url */ +IriSP.shorten_url = function(url) { + if (IriSP.config.shortener.hasOwnProperty("shortening_function")) + return IriSP.config.shortener.shortening_function(url); + + return url; +}; + /* for ie compatibility if (Object.prototype.__defineGetter__&&!Object.defineProperty) { Object.defineProperty=function(obj,prop,desc) { @@ -1589,8 +1601,13 @@ "popcorn.youtube": IriSP.libdir + "popcorn.youtube.js" }; -//Player Configuration -IriSP.config = undefined; +//Configuration for the player and utility functions. +IriSP.config = {}; + +IriSP.config.shortener = { + // function to call to shorten an url. + //shortening_function : IriSP.platform_shorten_url +}; IriSP.widgetsDefaults = { "LayoutManager" : {spacer_div_height : "0px" }, @@ -2150,10 +2167,9 @@ var offsettime = pageoffset.substring( 2 ); this._Popcorn.currentTime( parseFloat( offsettime ) ); } - } else if ( pageoffset.substring(0, 2) === "a=") { + } else if ( pageoffset.substring(0, 3) === "id=") { // annotation - var annotationId = pageoffset.substring( 2 ); - + var annotationId = pageoffset.substring( 3 ); // there's no better way than that because // of possible race conditions this._serializer.sync(IriSP.wrap(this, function() { @@ -2188,7 +2204,7 @@ } splitArr = window.location.href.split( "#" ) - history.replaceState( {}, "", splitArr[0] + "#a=" + annotationId); + history.replaceState( {}, "", splitArr[0] + "#id=" + annotationId); window.setTimeout(function() { _this.mutex = false }, 50); }; @@ -2211,6 +2227,7 @@ if (typeof(annotation) !== "undefined") { this._Popcorn.currentTime(annotation.begin / 1000); + this._Popcorn.trigger("IriSP.Mediafragment.showAnnotation", annotationId); } window.setTimeout(function() { _this.mutex = false }, 50); @@ -2349,10 +2366,10 @@ var fb_link = defaults.fb_link; var tw_link = defaults.tw_link; var gplus_link = defaults.gplus_link; - var url = document.location.href + "#a=" + annotation.id; - this.selector.find(".Ldt-fbShare").attr("href", fb_link + IriSP.encodeURI(text) + IriSP.encodeURI(url)); - this.selector.find(".Ldt-TwShare").attr("href", tw_link + IriSP.encodeURI(text) + IriSP.encodeURI(url)); - this.selector.find(".Ldt-GplusShare").attr("href", fb_link + IriSP.encodeURI(text) + IriSP.encodeURI(url)); + var url = document.location.href + "#id=" + annotation.id; + this.selector.find(".Ldt-fbShare").attr("href", IriSP.mkFbUrl(url, text)); + this.selector.find(".Ldt-TwShare").attr("href", IriSP.mkTweetUrl(url, text)); + this.selector.find(".Ldt-GplusShare").attr("href", IriSP.mkGplusUrl(url, text)); }; IriSP.AnnotationsWidget.prototype.clearWidget = function() { @@ -2696,16 +2713,17 @@ this.selector.find(".Ldt-createAnnotation-waitScreen").show(); }; -IriSP.createAnnotationWidget.prototype.showEndScreen = function() { +IriSP.createAnnotationWidget.prototype.showEndScreen = function(annotation) { this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide(); if (this.cinecast_version) { this.selector.find(".Ldt-createAnnotation-Title").parent().show(); } - var twStatus = IriSP.mkTweetUrl(document.location.href); - var gpStatus = IriSP.mkGplusUrl(document.location.href); - var fbStatus = IriSP.mkFbUrl(document.location.href); + var url = document.location.href + "id=" + annotation.id; + var twStatus = IriSP.mkTweetUrl(url); + var gpStatus = IriSP.mkGplusUrl(url); + var fbStatus = IriSP.mkFbUrl(url); this.selector.find(".Ldt-createAnnotation-endScreen-TweetLink").attr("href", twStatus); this.selector.find(".Ldt-createAnnotation-endScreen-FbLink").attr("href", fbStatus); @@ -2770,7 +2788,7 @@ annotation["end"] = this._currentAnnotation.end; } } else { - var duration = +this._serializer.currentMedia().meta["dc:duration"]; + var duration = +this._serializer.currentMedia().meta["dc:duration"]; annotation["begin"] = +((duration * (this.sliceLeft / 100)).toFixed(0)); annotation["end"] = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0)); } @@ -2815,7 +2833,7 @@ /* set up a basic view */ var tmp_view = {"dc:contributor": "perso", "dc:creator": "perso", "dc:title": "Contributions", "id": json.annotations[0].type} - console.log(tmp_view); + this._serializer._data["annotation-types"].push(tmp_view); } @@ -2830,9 +2848,9 @@ // everything is shared so there's no need to propagate the change _this._serializer._data.annotations.push(annotation); - console.log(_this._serializer._data); + _this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation", annotation); - callback(); + callback(annotation); }), error: function(jqXHR, textStatus, errorThrown) { @@ -3218,6 +3236,7 @@ this._Popcorn.listen("IriSP.search.cleared", IriSP.wrap(this, this.searchFieldClearedHandler)); this.selector.mouseleave(IriSP.wrap(this, function() { self.TooltipWidget.hide.call(self.TooltipWidget); })); this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater)); + this._Popcorn.listen("IriSP.Mediafragment.showAnnotation", IriSP.wrap(this, this.showAnnotation)); for(var i = 0; i < json.annotations.length; i++) { var item = json.annotations[i]; @@ -3370,11 +3389,15 @@ addEheight += TweetHeight; + /* stick a lot of things into e because that's the easiest way + to do it */ e.color = colors[j]; e.time = frames[i].mytweetsID[k].timeframe; e.title = frames[i].mytweetsID[k].title; e.id = frames[i].mytweetsID[k].cinecast_id; - + var pos = IriSP.jQuery(e.node).offset(); + e.x = pos.left; + e.y = pos.top; this.svgElements[e.id] = e; IriSP.jQuery(e.node).mouseenter(function(element) { return function (event) { @@ -3489,6 +3512,12 @@ }; +IriSP.PolemicWidget.prototype.showAnnotation = function(id) { + if (this.svgElements.hasOwnProperty(id)) { + var e = this.svgElements[id]; + this.TooltipWidget.show(e.title, e.attr("fill"), e.x - 103, e.y - 160); + } +}; IriSP.SegmentsWidget = function(Popcorn, config, Serializer) { var self = this; @@ -4088,7 +4117,7 @@ IriSP.SparklineWidget.prototype.handleNewAnnotation = function(annotation) { var num_columns = (this.selector.width()) / IriSP.widgetsDefaults["SparklineWidget"].column_width; var duration = +this._serializer.currentMedia().meta["dc:duration"]; - var time_step = duration / num_columns; /* the time interval between two columns */ + var time_step = Math.round(duration / num_columns); /* the time interval between two columns */ var begin = +annotation.begin; var index = Math.floor(begin / time_step); @@ -4128,7 +4157,12 @@ this.selector.find(".tipcolor").css("background-color", color); this._displayedText = text; this.selector.find(".tiptext").text(text); - //this.selector.find(".tip").css("left", x).css("top", y); + + if (x < 0) + x = 0; + if (y < 0) + y = 0; + this.selector.find(".tip").css("left", x).css("top", y); this.selector.find(".tip").show(); this._shown = true;