From 2ea64d8775137e5b275a0db8b014da22db8d5f65 Mon Sep 17 00:00:00 2001 From: riccardo Date: Wed, 11 May 2011 12:42:52 +0200 Subject: [PATCH] updated some playlist utilities --- telemeta/htdocs/timeside/src/divmarker.js | 6 +- telemeta/htdocs/timeside/src/playlist.js | 95 +++++++++---------- .../telemeta_default/collection_detail.html | 4 +- .../telemeta_default/mediaitem_detail.html | 2 +- 4 files changed, 54 insertions(+), 53 deletions(-) diff --git a/telemeta/htdocs/timeside/src/divmarker.js b/telemeta/htdocs/timeside/src/divmarker.js index 038d1217..99cda947 100644 --- a/telemeta/htdocs/timeside/src/divmarker.js +++ b/telemeta/htdocs/timeside/src/divmarker.js @@ -5,6 +5,9 @@ * License: GNU General Public License version 2.0 */ +/** + * Class for showing/editing a marker on details. + */ var MarkerMapDiv = TimesideArray.extend({ init:function(){ this._super(); @@ -254,8 +257,7 @@ var MarkerMapDiv = TimesideArray.extend({ }) e_addplaylistButton.unbind('click').bind('click',function(evtObj_){ - playlistUtils.showAddToPlaylist(e_addplaylistButton,'marker',""+marker.id,gettrans('marker added to the selected playlist')); - //playlistUtils.showPopupAddToPlaylist(evtObj_,'marker',""+marker.id,gettrans('marker added to the selected playlist')); + playlistUtils.showAddResourceToPlaylist(e_addplaylistButton,'marker',""+marker.id,gettrans('marker added to the selected playlist')); return false; }); diff --git a/telemeta/htdocs/timeside/src/playlist.js b/telemeta/htdocs/timeside/src/playlist.js index ed320d9e..a68ddd4c 100644 --- a/telemeta/htdocs/timeside/src/playlist.js +++ b/telemeta/htdocs/timeside/src/playlist.js @@ -34,51 +34,6 @@ var playlistUtils = { }); }, - - /*shows the popup for adding an item to the playlist*/ - showAddToPlaylist: function(anchorElement,resourceType,objectId, optionalOkMessage){ - var ar = []; - var playlists = this.playlists; - for(var i=0; i< playlists.length; i++){ - ar.push({ - 'html':playlists[i].name, - 'class':"component_icon list_item icon_playlist" - }); - } - if(!ar.length){ - return; - } - var addFcn = this.addToPlaylist; - new PopupDiv({ - invoker:anchorElement, - content: ar, - ok:function(data){ - var val = data.selIndex; - consolelog(data); - var callbackok = undefined; - if(optionalOkMessage){ - callbackok = function(){ - var p =new PopupDiv({ - content : "
"+optionalOkMessage+"
", - focusable: false - - }); - p.bind('show', function(){ - this.closeLater(1500); - }); - p.show(); - } - } - addFcn(playlists[val].id,resourceType,objectId,callbackok); - - - } - }).show(); - - }, - - - showAdd: function(anchorElement){ var t = gettrans('title'); @@ -109,7 +64,7 @@ var playlistUtils = { add : function(dictionary){ if(dictionary.public_id===undefined){ - dictionary.public_id = uniqid(); + dictionary.public_id = uniqid(); //defined in application.js } if(dictionary.user===undefined){ dictionary.user = CURRENT_USER_NAME; @@ -132,9 +87,53 @@ var playlistUtils = { window.location.reload(); }); }, - + + + /*shows the popup for adding a resource to a playlist*/ + showAddResourceToPlaylist: function(anchorElement,resourceType,objectId, optionalOkMessage){ + var ar = []; + var playlists = this.playlists; + for(var i=0; i< playlists.length; i++){ + ar.push({ + 'html':playlists[i].name, + 'class':"component_icon list_item icon_playlist" + }); + } + if(!ar.length){ + return; + } + var addFcn = this.addResourceToPlaylist; + new PopupDiv({ + invoker:anchorElement, + content: ar, + ok:function(data){ + var val = data.selIndex; + consolelog(data); + var callbackok = undefined; + if(optionalOkMessage){ + callbackok = function(){ + var p =new PopupDiv({ + content : "
"+optionalOkMessage+"
", + focusable: false + + }); + p.bind('show', function(){ + this.closeLater(1500); //this refers to p + }); + p.show(); + } + } + addFcn(playlists[val].id,resourceType,objectId,callbackok); + + + } + }).show(); + + }, + //resourceType can be: 'collection', 'item', 'marker' - addToPlaylist: function(playlistId,resourceType,objectId, callbackOnSuccess,callbackOnError){ + //addResource RENAME TODO!!!! + addResourceToPlaylist: function(playlistId,resourceType,objectId, callbackOnSuccess,callbackOnError){ consolelog(playlistId) var send = { 'public_id':uniqid(), diff --git a/telemeta/templates/telemeta_default/collection_detail.html b/telemeta/templates/telemeta_default/collection_detail.html index de882e2c..7a086ec0 100644 --- a/telemeta/templates/telemeta_default/collection_detail.html +++ b/telemeta/templates/telemeta_default/collection_detail.html @@ -19,8 +19,8 @@ {% if collection %} var anchor = jQuery('#_add_to_playlist'); if(anchor.length){ - anchor.click(function(evtObj_){ - p.showPopupAddToPlaylist(evtObj_,'collection','{{collection.public_id}}',gettrans('collection added to the selected playlist'));return false; + anchor.click(function(){ + p.showAddResourceToPlaylist(anchor,'collection','{{collection.public_id}}',gettrans('collection added to the selected playlist'));return false; }); } {% endif %} diff --git a/telemeta/templates/telemeta_default/mediaitem_detail.html b/telemeta/templates/telemeta_default/mediaitem_detail.html index 7b649da4..067db0e0 100644 --- a/telemeta/templates/telemeta_default/mediaitem_detail.html +++ b/telemeta/templates/telemeta_default/mediaitem_detail.html @@ -36,7 +36,7 @@ var anchor = jQuery('#_add_to_playlist'); if(anchor.length){ anchor.unbind('click').click(function(){ - p.showAddToPlaylist(anchor,'item','{{item.public_id}}',gettrans('item added to the selected playlist')); + p.showAddResourceToPlaylist(anchor,'item','{{item.public_id}}',gettrans('item added to the selected playlist')); return false; }); } -- 2.39.5