diff -r b0cb7132accb -r c04283d7d1ef src/js/widgets/polemicWidget.js --- a/src/js/widgets/polemicWidget.js Thu Nov 03 13:08:49 2011 +0100 +++ b/src/js/widgets/polemicWidget.js Thu Nov 03 13:09:30 2011 +0100 @@ -44,14 +44,16 @@ // variable // yMax + + var self = this; var yCoef = 2; // coef for height of 1 tweet var frameSize = 5; // frame size var margin = 1; // marge between frame var lineSize = this.width; // timeline pixel width var nbrframes = lineSize/frameSize; // frame numbers var numberOfTweet = 0; // number of tweet overide later - var duration = config.duration; // timescale width - var frameLenght = lineSize/frameSize; // frame timescale + var duration = +this._serializer.currentMedia().meta["dc:duration"]; // timescale width + var frameLenght = lineSize/frameSize; // frame timescale var timeline; var colors = new Array("","#1D973D","#C5A62D","#CE0A15","#036AAE","#585858"); @@ -131,13 +133,10 @@ } - // Refactoring (parametere) ************************************************************ - // load tweets send in parameters - __IriSP.jQuery.ajax({ - dataType: "jsonp", - url:config.metadata, - success : function(json){ - trace("load",""); + this._serializer.sync(function(data) { loaded_callback.call(self, data) }); + + function loaded_callback (json) { + // get current view (the first ???) view = json.views[0]; @@ -148,8 +147,8 @@ } RAWTweets = json.annotations; - __IriSP.jQuery.each(json.annotations, function(i,item) { - + for(var i = 0; i < json.annotations.length; i++) { + var item = json.annotations[i]; var MyTime = Math.floor(item.begin/duration*lineSize); var Myframe = Math.floor(MyTime/lineSize*frameLenght); @@ -167,7 +166,7 @@ for(var j=0; j0){Report();} - } - }); + }; function pourcent(value,max){ var myPourcentage = Math.round(value/max*1000)/10; @@ -329,9 +327,9 @@ console.log("tweets conversationel nsp: "+pourcent(tweetConversationel.length-tweetConversationelSP,tweetConversationel.length)); } function tweetsStats(){ - for(var i=0; imax){max=moy;} + + if (moy > max) { + max = moy; + } } var tweetDrawed = new Array(); @@ -489,36 +489,39 @@ // DRAW TWEETS ============================================ for(var i=0; i y) { + this.yMax = y; + } + + var e = this.paper.rect(x, y, frameSize - margin, TweetHeight /* height */).attr({stroke:"#00","stroke-width":0.1, fill: colors[j]}); + addEheight += TweetHeight; e.time= frames[i].mytweetsID[k].timeframe; e.title= frames[i].mytweetsID[k].title; - e.mouseover(function () { - //this.attr({stroke:"#fff","stroke-width":5}); - //this.toFront(); - }).mouseout(function () { + + e.mouseover(function(element) { return function (event) { + // event.clientX and event.clientY are to raphael what event.pageX and pageY are to jquery. + self.TooltipWidget.show.call(self.TooltipWidget, element.title, "#fefefe", event.clientX - 106, event.clientY - 160); + element.displayed = true; + }}(e)).mouseout(function(element) { return function () { + self.TooltipWidget.hide.call(self); //this.attr({stroke:"#00","stroke-width":0.1}); - }).mousedown(function () { - __IriSP.MyApiPlayer.seek(this.time/1000); + }}(e)).mousedown(function () { + self._Popcorn.currentTime(this.time/1000); // FIXME: update ? }); __IriSP.jQuery(e.node).attr('id', 't'+k+''); __IriSP.jQuery(e.node).attr('title', frames[i].mytweetsID[k].title); __IriSP.jQuery(e.node).attr('begin', frames[i].mytweetsID[k].timeframe); - var tempPosition = {x:i*frameSize,y:config.heightmax-addEheight}; + var tempPosition = {x:i*frameSize,y: this.heightmax-addEheight}; addTip(e.node, frames[i].mytweetsID[k].title,colors[j],tempPosition); //frames[i].mytweetsID.pop(); } @@ -529,13 +532,13 @@ } // DRAW UI :: resize border and bgd - heightOfChart = (yMax-(config.height-yMax)); - PaperBackground = paper.rect(0,yMax, this.width,heightOfChart).attr({fill:"#fff","stroke-width":0.1,opacity: 0.1}); - PaperBorder = paper.rect(0,yMax,this.width,1).attr({fill:"#fff",stroke: "none",opacity: 1}); - PaperSlider = paper.rect(0,20,1,heightOfChart).attr({fill:"#fc00ff",stroke: "none",opacity: 1}); + var heightOfChart = (this.yMax-(this.height- this.yMax)); + var PaperBackground = this.paper.rect(0, this.yMax, this.width,heightOfChart).attr({fill:"#fff","stroke-width":0.1,opacity: 0.1}); + var PaperBorder = this.paper.rect(0, this.yMax,this.width,1).attr({fill:"#fff",stroke: "none",opacity: 1}); + var PaperSlider = this.paper.rect(0,20,1,heightOfChart).attr({fill:"#fc00ff",stroke: "none",opacity: 1}); // decalage - tweetSelection = paper.rect(-100,-100,5,5).attr({fill:"#fff",stroke: "none",opacity: 1}); + tweetSelection = this.paper.rect(-100,-100,5,5).attr({fill:"#fff",stroke: "none",opacity: 1}); PaperSlider.toFront(); PaperBackground.toBack(); @@ -544,7 +547,7 @@ if(typeof(PaperSlider) !== 'undefined' ) { PaperSlider.toFront(); } - Report(); + Report.call(this); } @@ -570,7 +573,7 @@ // AddTip ****************************************************************************** function addTip(node, txt,color,tempPosition){ - __IriSP.jQuery(node).mouseover(function(){ + IriSP.jQuery(node).mouseover(function(){ tipText = txt; //tip.hide();//fadeIn(0); tipColor = color;