From: riccardo Date: Fri, 25 Mar 2011 18:51:45 +0000 (+0100) Subject: added "add to playlist" in collections. Still to implement add to playlist for markers X-Git-Tag: 1.1~327 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=dc48189883c1eb4d22b328cac23b9f173dd990c6;p=telemeta.git added "add to playlist" in collections. Still to implement add to playlist for markers --- diff --git a/telemeta/htdocs/css/telemeta.css b/telemeta/htdocs/css/telemeta.css index 66940834..88116c5f 100644 --- a/telemeta/htdocs/css/telemeta.css +++ b/telemeta/htdocs/css/telemeta.css @@ -981,6 +981,7 @@ a.image-link { margin-bottom: 1ex; } +/*----------------------------------*/ .mediaitem_button, .mediaitem_button:visited, .mediaitem_button:link{ @@ -1007,9 +1008,8 @@ a.image-link { padding:4px 8px 4px 8px !important; } .mediaitem_button_edit{ - background-image: url('/images/edit_page.png'); - - } + background-image: url('/images/edit_page.png'); +} .mediaitem_button_copy{ background-image: url('/images/copy_page.png'); } diff --git a/telemeta/htdocs/js/application.js b/telemeta/htdocs/js/application.js index ff1787f3..f3d50718 100644 --- a/telemeta/htdocs/js/application.js +++ b/telemeta/htdocs/js/application.js @@ -97,20 +97,34 @@ $(document).ready(function() { setSelectedMenu(); }); -//function to communicate with the server -//param: the data to be sent or retrieved. Recognized types: -// string, boolean number, dictionary of recognized types (including sub-dictionaries) and -// arrays of recognized types (including sub-arrays). param will be converted to string, escaping quotes newlines -// and backslashes if necessary. -//method: the json method, eg "telemeta.update_marker" -//onSuccesFcn(data, textStatus, jqXHR) +//**************************************************************************** +//global function to senbd/retrieve data with the server +// +//param: the data to be sent or retrieved. +// param will be converted to string, escaping quotes newlines and backslashes if necessary. +// param can be a javascript string, boolean, number, dictionary and array. +// If dictionary or array, it must contain only the above mentioned recognized types. +// So, eg, {[" a string"]} is fine, {[/asd/]} not +// +//method: the json method, eg "telemeta.update_marker". See base.py +// +//onSuccesFcn(data, textStatus, jqXHR) OPTIONAL // A function to be called if the request succeeds. // The function gets passed three arguments: // The data returned from the server, formatted according to the dataType parameter; // a string describing the status; // and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object -//showAlertError: if true, on error a msg dialog box is shown -var json = function(param,method,onSuccessFcn,showAlertOnError){ +// +//onErrorFcn(jqXHR, textStatus, errorThrown) OPTIONAL. --If missing, default dialog error is shown-- +// A function to be called if the request fails. +// The function receives three arguments: +// The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, +// a string describing the type of error that occurred and +// an optional exception object, if one occurred. +// Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". +//**************************************************************************** + +var json = function(param,method,onSuccessFcn,onErrorFcn){ //this function converts a javascript object to a string var toString_ = function(string){ if(typeof string == "string"){ @@ -168,14 +182,18 @@ var json = function(param,method,onSuccessFcn,showAlertOnError){ } }, error: function(jqXHR, textStatus, errorThrown){ - if(showAlertOnError){ - var details = "\n(no further info available)"; - if(jqXHR) { - details="\nThe server responded witha status of "+jqXHR.status+" ("+ - jqXHR.statusText+")\n\nDetails (request responseText):\n"+jqXHR.responseText; - } - alert("ERROR: Failed to save"+details); + if(onErrorFcn){ + onErrorFcn(jqXHR, textStatus, errorThrown); + return; + } + //default: + var details = "\n(no further info available)"; + if(jqXHR) { + details="\nThe server responded witha status of "+jqXHR.status+" ("+ + jqXHR.statusText+")\n\nDetails (request responseText):\n"+jqXHR.responseText; } + alert("ERROR: Failed to save"+details); + } }); @@ -223,7 +241,7 @@ var popup={ divsToDelete:null, toggleBind: function(element, functionE){ var clickNamespace = "click.popup__"; - var keydownNamespace = "keydown.popup__"; + var keydownNamespace = "keyup.popup__"; element.unbind(clickNamespace); element.unbind(keydownNamespace); if(functionE){ @@ -363,7 +381,10 @@ var popup={ height: max(20, (windowH + wdow.scrollTop() -position.top- shadowOffset)) } //position div and size: - var divPadding = {left: div.outerWidth()-div.width(), top:div.outerHeight()-div.height()}; //setting width on a div means the width(), + var divPadding = { + left: div.outerWidth()-div.width(), + top:div.outerHeight()-div.height() + }; //setting width on a div means the width(), //but calculations here are made according to outerWidth(true), so we need this variable (se below) div.css({ @@ -411,7 +432,7 @@ var popup={ }); div.show(300, function(){ //400: basically in between fast (200) and slow (600) //position div shadow: - divShadow.css({ + divShadow.css({ 'top': (position.top+shadowOffset), 'left': (position.left+shadowOffset), 'width': div.outerWidth(true), @@ -454,14 +475,15 @@ var popup={ p.hide(); return false; }; + var onOk= function(){ if(callbackOnOk){ var ret = {}; var inputs = table.find("input"); - for(var ipt in inputs){ - var i = $(ipt); - ret[i.attr('name')] = i.val(); - } + $J.each(inputs, function(key,value){ + var v = $J(value); + ret[v.attr('name')] = v.val(); + }); callbackOnOk(ret); return false; }else{ diff --git a/telemeta/htdocs/timeside/src/playlist.js b/telemeta/htdocs/timeside/src/playlist.js index 92e33f4d..9057fd8b 100644 --- a/telemeta/htdocs/timeside/src/playlist.js +++ b/telemeta/htdocs/timeside/src/playlist.js @@ -1,6 +1,6 @@ -var playlist = { +var playlistUtils = { // add : function(event){ // @@ -68,25 +68,25 @@ var playlist = { dictionary.user = CURRENT_USER_NAME; } - json(dictionary,'telemeta.add_playlist',function(){ + json([dictionary],'telemeta.add_playlist',function(){ window.location.reload(); - },true); + }); }, remove: function(id){ json([id],'telemeta.del_playlist',function(){ window.location.reload(); - },true); + }); }, removeResource: function(id){ json([id],'telemeta.del_playlist_resource',function(){ window.location.reload(); - },true); + }); }, //resourceType can be: 'collection', 'item', 'marker' - addToPlaylist: function(elementInvoker, playlistId,resourceType,objectId){ + addToPlaylist: function(playlistId,resourceType,objectId){ var send = { 'public_id':uniqid(), 'resource_type':resourceType, @@ -96,20 +96,9 @@ var playlist = { var p = popup; p.show(jQuery('
').html('Ok')); setTimeout(function(){p.hide()},600); - },true); + }); } -// ,add:function(title){ -// if(title instanceof String) -// -// var pl = [{"public_id":new Date().getTime(), "title":title, "description":"", user:"admin"}]; -// json(pl,'telemeta.add_playlist',alert('done'),true); -//} } -//varf(); -//function varf(){ -// playlist.add('myplaylist'); -//} - diff --git a/telemeta/templates/telemeta_default/collection_detail.html b/telemeta/templates/telemeta_default/collection_detail.html index fceff2cf..a273a14b 100644 --- a/telemeta/templates/telemeta_default/collection_detail.html +++ b/telemeta/templates/telemeta_default/collection_detail.html @@ -6,6 +6,13 @@ {% block extra_javascript %} + + {% endblock %} {% if collection %} @@ -19,9 +26,15 @@ {% trans "Copy" %} {% endif %} {% if user.is_authenticated %} - {% trans "Add to playlist" %} + {% trans "Add to playlist" %} + {% endif %} - {% endblock tools %} + {% endblock tools %}
@@ -46,6 +59,7 @@ var so = new SWFObject('{% url telemeta-swf "mp3player.swf" %}','playlist','362','200','7'); so.addVariable("file","{% url telemeta-collection-xspf collection.public_id %}"); so.addVariable("displayheight","0"); + so.addParam("wmode", "opaque"); so.write('collection_player_c'); diff --git a/telemeta/templates/telemeta_default/home.html b/telemeta/templates/telemeta_default/home.html index e75d0a54..12da88e6 100644 --- a/telemeta/templates/telemeta_default/home.html +++ b/telemeta/templates/telemeta_default/home.html @@ -7,9 +7,8 @@ {% endblock %} @@ -119,7 +118,7 @@ {% endif %} - {% trans "Delete" %} + {% trans "Delete" %} {% endfor %} diff --git a/telemeta/templates/telemeta_default/mediaitem_detail.html b/telemeta/templates/telemeta_default/mediaitem_detail.html index 5d3616c7..ab8665d3 100644 --- a/telemeta/templates/telemeta_default/mediaitem_detail.html +++ b/telemeta/templates/telemeta_default/mediaitem_detail.html @@ -25,7 +25,7 @@ set_player_image_url('{% url telemeta-item-visualize item.public_id,visualizer_id,"WIDTH","HEIGHT" %}'); load_player({{ item.approx_duration.as_seconds }}); jQuery(document).ready(function(){ - var content = $('#_a_p_5638').clone(true,true); + var content = $('#_popup_add_to_playlist').clone(true,true); $('#_add_to_playlist').click(function(e){return popup.show(content,e)}); }); @@ -45,10 +45,10 @@ {% if user.is_authenticated %} {% trans "Add to playlist" %} -