From 6dc8a91eaccead1c0c315e009b3824ac14026543 Mon Sep 17 00:00:00 2001 From: riccardo Date: Fri, 11 Feb 2011 17:39:46 +0100 Subject: [PATCH] Fixed m::arkers add/edit/remove, as well as server get/save. Graphical Layout still to be optimized --- telemeta/htdocs/css/telemeta.css | 8 + telemeta/htdocs/timeside/skins/lab/style.css | 2 + telemeta/htdocs/timeside/src/controller.js | 35 +- telemeta/htdocs/timeside/src/markermap.js | 369 +++++++++++------- .../telemeta_default/mediaitem_detail.html | 13 +- telemeta/web/base.py | 7 +- 6 files changed, 262 insertions(+), 172 deletions(-) diff --git a/telemeta/htdocs/css/telemeta.css b/telemeta/htdocs/css/telemeta.css index 729100a7..e3be051e 100644 --- a/telemeta/htdocs/css/telemeta.css +++ b/telemeta/htdocs/css/telemeta.css @@ -744,3 +744,11 @@ a.image-link { margin: 0; padding: 1em; } + +/*.ts-marker-button { + border: solid #00190a 1px; + padding: .5ex .5ex .5ex .5ex; + background-color:#00890a; + color: #ffffff; + font-weight: bold; +}*/ diff --git a/telemeta/htdocs/timeside/skins/lab/style.css b/telemeta/htdocs/timeside/skins/lab/style.css index 5dcd3539..a8626c54 100755 --- a/telemeta/htdocs/timeside/skins/lab/style.css +++ b/telemeta/htdocs/timeside/skins/lab/style.css @@ -114,3 +114,5 @@ height: 30px; } + + diff --git a/telemeta/htdocs/timeside/src/controller.js b/telemeta/htdocs/timeside/src/controller.js index 56f6b4d2..9a1be290 100644 --- a/telemeta/htdocs/timeside/src/controller.js +++ b/telemeta/htdocs/timeside/src/controller.js @@ -16,17 +16,17 @@ TimeSide(function($N) { soundProvider: null, map: null }); -// if (this.cfg.player && !$N.isInstanceOf(this.cfg.player, 'Player')) { -// this.cfg.player = new $N.Player(this.cfg.player); -// } - //this._setupPlayer(); - this.loadHTTP(); + if (this.cfg.player && !$N.isInstanceOf(this.cfg.player, 'Player')) { + this.cfg.player = new $N.Player(this.cfg.player); + } + this._setupPlayer(); + }, _setupPlayer: function() { - if (this.cfg.player && !$N.isInstanceOf(this.cfg.player, 'Player')) { - this.cfg.player = new $N.Player(this.cfg.player); - } +// if (this.cfg.player && !$N.isInstanceOf(this.cfg.player, 'Player')) { +// this.cfg.player = new $N.Player(this.cfg.player); +// } this.attach(this.updateMarkersDiv); this.cfg.player .setSoundProvider(this.cfg.soundProvider) @@ -38,6 +38,7 @@ TimeSide(function($N) { .observe('markermove', this.attach(this._onMarkerMove)) .draw(); + this.loadHTTP(); }, @@ -49,16 +50,14 @@ TimeSide(function($N) { _onMarkerMove: function(e, data) { if (this.cfg.map) { - //this.refreshMarkersText(this.cfg.map); this.cfg.map.move(this.cfg.map.byId(data.id), data.offset); - //this.updateMarkersDiv(this.cfg.map, data.offset); } }, _onMarkerAdd: function(e, data) { if (this.cfg.map) { //this.refreshMarkersText(this.cfg.map); - this.cfg.map.add(data.offset, ''); + this.cfg.map.addNew(data.offset, ''); //this.updateMarkersDiv(this.cfg.map, data.offset); } @@ -89,17 +88,17 @@ TimeSide(function($N) { var result = data.result; for(var i =0; i< result.length; i++){ -// var marker = { -// id: result[i].public_id, -// offset: result[i].time, -// desc: result[i].description -// }; - map.add(result[i].time, result[i].description); + var marker = { + id: result[i].public_id, + offset: result[i].time, + desc: result[i].description + }; + map.add(marker); } } } - me._setupPlayer(); + //me._setupPlayer(); } }); var g = 9; diff --git a/telemeta/htdocs/timeside/src/markermap.js b/telemeta/htdocs/timeside/src/markermap.js index 28c711dd..b72eddb0 100644 --- a/telemeta/htdocs/timeside/src/markermap.js +++ b/telemeta/htdocs/timeside/src/markermap.js @@ -48,64 +48,55 @@ TimeSide(function($N, $J) { return index; }, - _reorder: function(selectedMarkerOffset) { - //selectedMarkerOffset is the offset of the marker whose textarea - //must be selected. It can be undefined - //first of all, assign to each marker its text. - //we could assign it onchange, but that event is NOT fired when the textarea changes. - //so we doit it here - var div = this.divContainer; - var m = this.markers; - - if(div){ - var divChildren = div.childNodes; - if(divChildren){ - var l = Math.min(divChildren.length, m.length); - for(var i=0; ioldIndex){ + newIndex--; + } + if(newIndex==oldIndex){ + return; + } + var l = this.markers.length; + this.markers.splice(oldIndex,1); + this.markers.splice(newIndex,0,marker); + //The .detach() method is the same as .remove(), except that .detach() keeps + //all jQuery data associated with the removed elements. + //This method is useful when removed elements are to be reinserted into the DOM at a later time. + marker.div.detach(); + if(newIndex==l-1){ + this.divContainer.append(marker.div); + }else{ + $( this.divContainer.children()[newIndex] ).before(marker.div); + } + $($( marker.div.children()[1] )).focus(); + + var i1= Math.min(oldIndex,newIndex); + var i2= Math.max(oldIndex,newIndex); + //var mrks = this.markers; + + this.fireRefreshLabels(i1,i2+1); + + + + + //this._reorder(offset); }, - getPrevious: function(offset, skip) { - var marker = null; - if (!skip) { - skip = 0; + fireRefreshLabels: function(firstIndex,lastIndex){ + if(lastIndex<=firstIndex){ + return; + } + for (var i=firstIndex; i m.offset && !(skip--)) { - marker = m; - return false; - } - }); - return marker; }, - getNext: function(offset, skip) { - var marker = null; - if (!skip) { - skip = 0; + insertionIndex: function(marker){ + var index = 0; + var l = this.markers.length; + while (index') - .css({ - color:'#fff', - backgroundColor:'#009', - width: '2ex', - textAlign: 'center', - fontFamily: 'monospace' - }) - .html(i+1); - - var timeSpan = $J('') - .css({ - marginLeft:'1ex' - }); - - - var header = $J('
') - .append(label) - .append(timeSpan); - - text = $J('