From 3b2a076c06ffdb3b4c9bcd9109a4e261173cfe7c Mon Sep 17 00:00:00 2001 From: riccardo Date: Wed, 15 Jun 2011 12:48:42 +0200 Subject: [PATCH] several code modifications and optimizations --- telemeta/htdocs/js/divmarker.js | 6 +- telemeta/htdocs/js/playerLoader.js | 61 +-- telemeta/htdocs/js/playlist.js | 2 +- telemeta/htdocs/js/popupdiv.js | 307 +++----------- telemeta/htdocs/timeside/js/markermap.js | 79 ++-- telemeta/htdocs/timeside/js/player.js | 402 ++++++++++++------- telemeta/htdocs/timeside/js/ruler.js | 107 +++-- telemeta/htdocs/timeside/js/timeside.js | 2 +- telemeta/htdocs/timeside/skins/lab/style.css | 67 +--- 9 files changed, 479 insertions(+), 554 deletions(-) diff --git a/telemeta/htdocs/js/divmarker.js b/telemeta/htdocs/js/divmarker.js index ea12a6cb..1b6b50e0 100644 --- a/telemeta/htdocs/js/divmarker.js +++ b/telemeta/htdocs/js/divmarker.js @@ -59,7 +59,7 @@ Timeside.classes.MarkerMapDiv = Timeside.classes.TimesideArray.extend({ this.stretch(div.find('.markersdivDescription')); return div; }, - //overridden + //overridden. Do not call explicitly, use marker map.move move: function(from, to, newOffset){ //call super method @@ -83,7 +83,6 @@ Timeside.classes.MarkerMapDiv = Timeside.classes.TimesideArray.extend({ this.each(Math.min(from,realIndex),Math.max(from,realIndex)+1, function(i, div){ setIdx.apply(t,[div,i]); }); - this.setOffset(me[realIndex],newOffset); //TODO: create a function? @@ -160,7 +159,7 @@ Timeside.classes.MarkerMapDiv = Timeside.classes.TimesideArray.extend({ }, - +//TODO: what is doing this method here? setFocus: function(index,value){ // this.each(function(i,div){ // if(i==index && value){ @@ -179,6 +178,7 @@ Timeside.classes.MarkerMapDiv = Timeside.classes.TimesideArray.extend({ var e_indexLabel = div.find('.ts-marker'); var e_offsetLabel =div.find('.markersdivOffset'); e_indexLabel.add(e_offsetLabel).unbind('click').click(function(){ + //Timeside.player.moveMarker(index,0.2);return; //just a try me.setFocus(index,true); me.fire('focus', { 'index': index diff --git a/telemeta/htdocs/js/playerLoader.js b/telemeta/htdocs/js/playerLoader.js index 1f9b5095..30fb55c8 100644 --- a/telemeta/htdocs/js/playerLoader.js +++ b/telemeta/htdocs/js/playerLoader.js @@ -104,8 +104,7 @@ function loadPlayer(analizerUrl, soundUrl, soundImgSize, itemId, visualizers, cu end('SoundManager is not responding. Try to:\n - Reload the page\n - Empty the cache (see browser preferences) and reload the page\n - Restart the browser'); },maxTime); - // var playerDiv = $J('#player'); - // var markersUI = $J("#markers_div_id"); + @@ -134,10 +133,7 @@ function loadPlayer(analizerUrl, soundUrl, soundImgSize, itemId, visualizers, cu analyzerContentArray.push(elm.attr('unit')); analyzerContentArray.push(''); }); - - - - + //loaded analizer, loading player //msgElm.html('Loading markers...'); @@ -319,6 +315,14 @@ function loadPlayer(analizerUrl, soundUrl, soundImgSize, itemId, visualizers, cu $J('#analyzer_div_id').find('table').find('tbody:last').append(analyzerContentArray.join("")); //setting up the select tag + + player.bind('waitShown', function(data){ + visualizersSelectElement.hide(); + }); + player.bind('waitHidden', function(data){ + visualizersSelectElement.css('display','inline-block'); + }); + //assigning event on select: visualizersSelectElement.change( function (){ @@ -328,20 +332,14 @@ function loadPlayer(analizerUrl, soundUrl, soundImgSize, itemId, visualizers, cu var ch = control.height(); var margin = 3; visualizersSelectElement.css({ - 'display':'inline-block', + 'display': 'inline-block', 'height':(ch-2*margin)+'px', 'position':'absolute', 'top':margin+'px', 'right':margin, 'margin':0 - }); - player.bind('waiting', function(data){ - if(data.value){ //is waiting - visualizersSelectElement.hide(); - return; - } - visualizersSelectElement.css('display','inline-block'); - }); + }).hide(); //hide it to be sure. We could check player.isImgRefreshing but we have to think about event queue... + control.append(visualizersSelectElement); //Eventually, do 3 last things: //1) call end (without arguments simply clears the wait span and avoid subsequent calls to end(msg) to @@ -372,7 +370,7 @@ function loadPlayer(analizerUrl, soundUrl, soundImgSize, itemId, visualizers, cu var popupdiv = new PopupDiv({ focusable: false, titleClass: 'markersdivTitle', - showClose:false, + showClose:true, bounds: { top:0.4, left:0.1, @@ -383,19 +381,20 @@ function loadPlayer(analizerUrl, soundUrl, soundImgSize, itemId, visualizers, cu defaultCloseOperation: 'hide' }); var popupShowFunction = function(data){ -// if(popupTimeoutId !== undefined){ -// cT(popupTimeoutId); -// } -// popupTimeoutId=undefined; - popupdiv.refresh(data.marker.desc,data.marker.title); - if(!popupdiv.isShowing()){ - popupdiv.show(); - } -// var index = data.index; -// if(index+1 == map.length || map.toArray()[index+1].offset-data.marker.offset>3){ -// popupTimeoutId = popupdiv.setTimeout('close',3000); -// } - }; + // if(popupTimeoutId !== undefined){ + // cT(popupTimeoutId); + // } + // popupTimeoutId=undefined; + + popupdiv.refresh(data.marker.desc,data.marker.title); + if(!popupdiv.isShowing()){ + popupdiv.show(); + } + // var index = data.index; + // if(index+1 == map.length || map.toArray()[index+1].offset-data.marker.offset>3){ + // popupTimeoutId = popupdiv.setTimeout('close',3000); + // } + }; if(POPUP_TIMEOUT<0){ player.bind('markerCrossed',popupShowFunction); }else{ @@ -408,7 +407,9 @@ function loadPlayer(analizerUrl, soundUrl, soundImgSize, itemId, visualizers, cu popupTimeoutId=undefined; popupShowFunction(data); var index = data.index; - if(index+1 == map.length || map.toArray()[index+1].offset-data.marker.offset>3){ + //consolelog(data); + //consolelog(index+') '+data.marker.offset+' | '+(map.toArray()[index+1].offset+' - '+data.timeMarginInSec)); + if(index+1 == map.length || map.toArray()[index+1].offset-data.marker.offset-data.timeMarginInSec>3){ popupTimeoutId = popupdiv.setTimeout('close',3000); } //consolelog('firing markercrossed'); diff --git a/telemeta/htdocs/js/playlist.js b/telemeta/htdocs/js/playlist.js index 5ad09ae1..a5ce12d2 100644 --- a/telemeta/htdocs/js/playlist.js +++ b/telemeta/htdocs/js/playlist.js @@ -139,7 +139,7 @@ var playlistUtils = { }); p.bind('show', function(){ - this.closeLater(1500); //this refers to p + this.setTimeout('close',1500); //this refers to p }); p.show(); } diff --git a/telemeta/htdocs/js/popupdiv.js b/telemeta/htdocs/js/popupdiv.js index ad5c39b4..e8720ba2 100644 --- a/telemeta/htdocs/js/popupdiv.js +++ b/telemeta/htdocs/js/popupdiv.js @@ -59,7 +59,7 @@ * (popup.close() is called, see below) * showOk (false): determines whether or not an ok button should be shown at the bottom of the popup. The ok button is an tag whose * click will trigger the popup.onOk callback (see below). This parameter should always be true for form filling popup (see PopupDiv.content above) and when onOk is specified (see below) - * okButtonTitle ('Ok'): self-explanatory + * okButtonTitle ('Ok') [see note4]: self-explanatory * onOk (null): callback. callback to be executed when the ok button is pressed. When specified, showOk must be set to true. * The callback takes as argument a dictionary that the popup will build by retrieving all