]> git.parisson.com Git - telemeta.git/commitdiff
Ajout deja ajoute dans liste
authormathieu <mathieu.boye28@gmail.com>
Tue, 3 May 2016 13:45:16 +0000 (15:45 +0200)
committermathieu <mathieu.boye28@gmail.com>
Tue, 3 May 2016 13:45:16 +0000 (15:45 +0200)
telemeta/static/telemeta/js/playlist.js
telemeta/templates/telemeta/mediaitem_detail.html

index 66e1eb6f755ad3408d1dbf7669f3a04241ec7859..9e53df5cc79b79704de56dd8b9b00732d62757f8 100644 (file)
 //default PopupDiv properties for playlists (mainly for css appearence)
 PopupDiv.popupClass = 'control component';
 PopupDiv.popupCss = {
-    'border':'1px solid #999',
-    'padding':'1ex'
+    'border': '1px solid #999',
+    'padding': '1ex'
 };
-PopupDiv.okButtonTitle =  'Ok';
-PopupDiv.okButtonClass =  'component_icon button icon_ok';
-PopupDiv.closeButtonTitle =  '';
-PopupDiv.closeButtonClass =  'markersdivDelete';
+PopupDiv.okButtonTitle = 'Ok';
+PopupDiv.okButtonClass = 'component_icon button icon_ok';
+PopupDiv.closeButtonTitle = '';
+PopupDiv.closeButtonClass = 'markersdivDelete';
 PopupDiv.defaultCloseOperation = 'remove';
 PopupDiv.focusable = true;
 PopupDiv.listItemClass = "component_icon list_item icon_playlist";
 
 
 var playlistUtils = {
-    playlists : [],
+    playlists: [],
 
-    addPlaylist: function(name, id){
+    addPlaylist: function (name, id) {
         this.playlists.push({
-            'name':name,
-            'id':id
+            'name': name,
+            'id': id
         });
     },
 
-    addEditPlaylist: function(id, title, description){
+    addEditPlaylist: function (id, title, description) {
         this.playlists.push({
             'id': id,
             'title': title,
@@ -58,26 +58,26 @@ var playlistUtils = {
         });
     },
 
-    showAdd: function(anchorElement){
+    showAdd: function (anchorElement) {
 
         var t = gettrans('title');
         var d = gettrans('description');
         var dd = {};
-        dd[t]='';
-        dd[d]='';
+        dd[t] = '';
+        dd[d] = '';
         var playlist = this;
         new PopupDiv({
-            'content':dd,
-            invoker:anchorElement,
-            showOk:true,
-            onOk:function(data){
-                if(!data[t] && !data[d]){
+            'content': dd,
+            invoker: anchorElement,
+            showOk: true,
+            onOk: function (data) {
+                if (!data[t] && !data[d]) {
                     return;
                 }
                 //convert language
                 playlist.add({
-                    'title':data[t],
-                    'description':data[d]
+                    'title': data[t],
+                    'description': data[d]
                 });
             }
         }).show();
@@ -88,45 +88,45 @@ var playlistUtils = {
      * Copied from Timeside.utils.uniqid (Timeside might NOT ALWAYS be loaded, see home.html when user is authenitcated)
      *
      */
-    uniqid : function() {
+    uniqid: function () {
         var d = new Date();
         return new String(d.getTime() + '' + Math.floor(Math.random() * 1000000)).substr(0, 18);
     },
 
-    add : function(dictionary){
+    add: function (dictionary) {
 
-        if(dictionary.public_id===undefined){
+        if (dictionary.public_id === undefined) {
             dictionary.public_id = this.uniqid();
         }
-        if(dictionary.user===undefined){
+        if (dictionary.user === undefined) {
             dictionary.user = CURRENT_USER_NAME;
         }
 
-        json([dictionary],'telemeta.add_playlist',function(){
+        json([dictionary], 'telemeta.add_playlist', function () {
             window.location.reload();
         });
     },
 
-    remove: function(id){
-        json([id],'telemeta.del_playlist',function(){
+    remove: function (id) {
+        json([id], 'telemeta.del_playlist', function () {
             window.location.reload();
         });
     },
 
-    removeResource: function(id, range_playlist){
-        json([id, range_playlist],'telemeta.del_playlist_resource',function(data){
-               var id = data.result;
-               window.location.pathname = '/desk/lists/open-list-' + id;
+    removeResource: function (id, range_playlist) {
+        json([id, range_playlist], 'telemeta.del_playlist_resource', function (data) {
+            var id = data.result;
+            window.location.pathname = '/desk/lists/open-list-' + id;
         });
     },
 
-    update : function(dictionary){
-        json([dictionary],'telemeta.update_playlist',function(){
-        window.location.reload();
+    update: function (dictionary) {
+        json([dictionary], 'telemeta.update_playlist', function () {
+            window.location.reload();
         });
     },
 
-    showEdit: function(anchorElement, id){
+    showEdit: function (anchorElement, id) {
 
         var t = gettrans('title');
         var d = gettrans('description');
@@ -134,79 +134,90 @@ var playlistUtils = {
         var playlist = this;
 
         var playlists = this.playlists;
-        for (var i=0; i< playlists.length; i++){
-            if (playlists[i].id == id){
+        for (var i = 0; i < playlists.length; i++) {
+            if (playlists[i].id == id) {
                 dd[t] = playlists[i].title;
                 dd[d] = playlists[i].description;
             }
         }
 
         new PopupDiv({
-            'content':dd,
-                    invoker:anchorElement,
-                    showOk:true,
-                    onOk:function(data){
-                        if(!data[t] && !data[d]){
-                            return;
-                        }
-                        //convert language
-                        playlist.update({
-                            'public_id': id,
-                            'title': data[t],
-                            'description': data[d],
-                        });
-                    }
+            'content': dd,
+            invoker: anchorElement,
+            showOk: true,
+            onOk: function (data) {
+                if (!data[t] && !data[d]) {
+                    return;
+                }
+                //convert language
+                playlist.update({
+                    'public_id': id,
+                    'title': data[t],
+                    'description': data[d],
+                });
+            }
         }).show();
     },
 
     /*shows the popup for adding a resource to a playlist*/
-    showAddResourceToPlaylist: function(anchorElement, resourceType, objectId, optionalOkMessage){
+    showAddResourceToPlaylist: function (anchorElement, resourceType, objectId, optionalOkMessage) {
         var ar = [];
         var playlists = this.playlists;
-        for(var i=0; i< playlists.length; i++){
+        for (var i = 0; i < playlists.length; i++) {
             ar.push(playlists[i].name);
         }
         var pl = this;
 
-        if(!ar.length){
+        if (!ar.length) {
             pl.showAdd(anchorElement);
         }
 
         //var addFcn = this.addResourceToPlaylist;
         new PopupDiv({
-            invoker:anchorElement,
+            invoker: anchorElement,
             content: ar,
-            onOk:function(data){
+            onOk: function (data) {
                 var val = data.selIndex;
                 var callbackok = undefined;
 
-                if(optionalOkMessage){
-                    callbackok = function(){
-                        var p =new PopupDiv({
-                            content : "<div class='component_icon icon_ok'>"+optionalOkMessage+"</div>",
-                            focusable: false
-
-                        });
-                        p.bind('show', function(){
-                            this.setTimeout('close',1500); //this refers to p
-                        });
-                        p.show();
+                if (optionalOkMessage) {
+                    callbackok = function () {
+                        localStorage['messOkPlaylist'] = optionalOkMessage;
+                        localStorage['displayOkPlaylist']=true;
+                        window.location.reload();
                     }
                 }
-                pl.addResourceToPlaylist.apply(pl,[playlists[val].id,resourceType,objectId,callbackok]);
+                pl.addResourceToPlaylist.apply(pl, [playlists[val].id, resourceType, objectId, callbackok]);
             }
         }).show();
 
     },
 
     //resourceType can be: 'collection', 'item', 'marker'
-    addResourceToPlaylist: function(playlistId,resourceType,objectId, callbackOnSuccess,callbackOnError){
+    addResourceToPlaylist: function (playlistId, resourceType, objectId, callbackOnSuccess, callbackOnError) {
         var send = {
-            'public_id':this.uniqid(),
-            'resource_type':resourceType,
-            'resource_id':objectId
+            'public_id': this.uniqid(),
+            'resource_type': resourceType,
+            'resource_id': objectId
         };
-        json([playlistId,send],'telemeta.add_playlist_resource',callbackOnSuccess,callbackOnError);
+        json([playlistId, send], 'telemeta.add_playlist_resource', callbackOnSuccess, callbackOnError);
+    },
+
+    messageOk: function () {
+        if (localStorage['displayOkPlaylist']) {
+            var p = new PopupDiv({
+                content: "<div class='component_icon icon_ok'>" + localStorage['messOkPlaylist']+ "</div>",
+                focusable: false
+
+            });
+            p.bind('show', function () {
+                this.setTimeout('close', 1500); //this refers to p
+            });
+            p.show();
+            localStorage.removeItem('displayOkPlaylist');
+            localStorage.removeItem('messOkPlaylist');
+        }
+
     }
 
 
index de2ed03265fc46a5ec684f1e81164a5210839ca7..c29ab7f42aa6018931f1fea10df8aa1e9603fb74 100644 (file)
                 if(anchor.length){
                     anchor.unbind('click').click(function(){
                         playlistUtils.showAddResourceToPlaylist(anchor,'item','{{item.id}}',gettrans('item added to the selected playlist'));
+                        //playlistUtils.showAddResourceToPlaylist(anchor,'item','{{item.id}}');
                         return false;
                     });
                 }
+
+                playlistUtils.messageOk();
             });
     {% endif %}
 </script>