]> git.parisson.com Git - telemeta.git/commitdiff
update
authorbalastegui <thomas.balastegui@gmail.com>
Thu, 12 May 2016 14:21:24 +0000 (16:21 +0200)
committerbalastegui <thomas.balastegui@gmail.com>
Thu, 12 May 2016 14:21:24 +0000 (16:21 +0200)
telemeta/locale
telemeta/static/telemeta/js/playlist.js
telemeta/templates/telemeta/lists.html

index ea6605ad78243d798d88f1ffc46c8f6bc507ce11..c043261bbe26298e2bea3ddb028332c78c9a6107 160000 (submodule)
@@ -1 +1 @@
-Subproject commit ea6605ad78243d798d88f1ffc46c8f6bc507ce11
+Subproject commit c043261bbe26298e2bea3ddb028332c78c9a6107
index e6c7860d82053691967926f3270998b5ff62e1a4..6d4190003e745f3c9b123cbeb923a7983350a484 100644 (file)
@@ -39,6 +39,9 @@ PopupDiv.defaultCloseOperation = 'remove';
 PopupDiv.focusable = true;
 PopupDiv.listItemClass = "component_icon list_item icon_playlist";
 
+var ID = ""; // ID var: used to edit playlist
+var TITLE = "";
+var DESCRIPTION = "";
 
 var playlistUtils = {
     playlists : [],
@@ -58,31 +61,43 @@ var playlistUtils = {
         });
     },
 
-    showAdd: function(anchorElement){
-
-        var t = gettrans('title');
-        var d = gettrans('description');
-        var dd = {};
-        dd[t]='';
-        dd[d]='';
+    addNewPlaylist: function(){
         var playlist = this;
-        new PopupDiv({
-            '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]
-                });
+        var t = $('#titleAdd').val();
+        var d = $('#descriptionAdd').val();
+        playlist.add({
+            'title': t,
+            'description': d,
+        });
+    },
+
+    // function to change global var ID (used when edit button is pressed)
+    editVar: function(id){
+        ID = id;
+        playlists = this.playlists;
+        for (var i=0; i<playlists.length; i++){
+            if (playlists[i].id == id){
+                $('#titleEdit').val(playlists[i].title);
+                $('#descriptionEdit').val(playlists[i].description);
             }
-        }).show();
 
+        }
+    },
+
+    editPlaylist: function(){
+        var playlist = this;
+        TITLE = $('#titleEdit').val();
+        DESCRIPTION = $('#descriptionEdit').val();
+        // Use of a function that convert params then use playlist.update
+        //playlist.updateConvert(ID, TITLE, DESCRIPTION);
+        playlist.update({
+            'public_id': ID,
+            'title': TITLE,
+            'description': DESCRIPTION,
+        });
+        ID = ""; // init ID
     },
+
     /**
      * Returns an uniqid by creating the current local time in millisecond + a random number. Used for markers and some json calls
      * Copied from Timeside.utils.uniqid (Timeside might NOT ALWAYS be loaded, see home.html when user is authenitcated)
@@ -125,49 +140,6 @@ var playlistUtils = {
         });
     },
 
-    showEdit: function(anchorElement, id){
-
-        var t = gettrans('title');
-        var d = gettrans('description');
-        var dd = {};
-        var playlist = this;
-
-        var playlists = this.playlists;
-        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],
-                        });
-                    }
-        }).show();
-    },
-
-    /*convert language*/
-    updateConvert: function(id, t, d) {
-        playlist = this;
-        playlist.update({
-            'public_id': id,
-            'title': t,
-            'description': d,
-        });
-    },
-
     /*shows the popup for adding a resource to a playlist*/
     showAddResourceToPlaylist: function(anchorElement, resourceType, objectId, optionalOkMessage){
         var ar = [];
index c80f6058438d95e797b97ef9cd49ee0705cc37fd..39167a09340d1310b5838eb69c906caf43a0b136 100644 (file)
 <script src="{{ STATIC_URL }}jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
 <script>
 
-    /**
-      * Added by Thomas Balastegui :
-      * function that get variables from the Add popup
-      * and create a new playlist
-      */
-    function addNewPlaylist() {
-        var title = document.getElementById('titleAdd').value;
-        var description = document.getElementById('descriptionAdd').value;
-        var p = playlistUtils;
-        p.add({
-         title,
-         description
-        });
-    }
-
-    var ID = ""; // ID var: used to edit playlist
-
-    // function to change global var ID (used when edit button is pressed)
-    function editVar(id) {
-        ID = id;
-    }
-
-    function editPlaylist() {
-        var title = document.getElementById('titleEdit').value;
-        var description = document.getElementById('descriptionEdit').value;
-        var p = playlistUtils;
-
-        // Use of a function that convert params then use playlist.update
-        p.updateConvert(ID, title, description);
-
-        ID = ""; // init ID
-    }
-
     {% for playlist in playlists %}
         playlistUtils.addEditPlaylist('{{playlist.playlist.public_id}}','{{ playlist.playlist.title }}','{{playlist.playlist.description}}');
     {% endfor %}
@@ -83,7 +50,7 @@
 
 <!--
  Added by Thomas Balastegui :
- modal popup display and use of addNewPlaylist()
+ modal popup display and use of addNewPlaylist() and editPlaylist()
 -->
 {% block content %}
     {% block modal %}
              <br><br>
             </div>
             <div class="modal-footer">
-              <button type="submit" name="submit" value="submit" class="btn btn-default" onclick="addNewPlaylist()">{% trans "Ok" %}</button>
+              <button type="submit" name="submit" value="submit" class="btn btn-default" onclick="playlistUtils.addNewPlaylist()">{% trans "Ok" %}</button>
               <button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
             </div>
         </div>
              <br><br>
             </div>
             <div class="modal-footer">
-              <button type="submit" name="submit" value="submit" class="btn btn-default" onclick="editPlaylist()">{% trans "Ok" %}</button>
+              <button type="submit" name="submit" value="submit" class="btn btn-default" onclick="playlistUtils.editPlaylist()">{% trans "Ok" %}</button>
               <button type="button" class="btn btn-default" data-dismiss="modal">{% trans "Close" %}</button>
             </div>
         </div>
             <tr>
                 <td style="border-bottom:1px solid #6A0307;color:#6A0307;font-size: 100%">{{ playlist.playlist.title }}</td>
                 <td style="width:86ex; padding-right: 0; border-bottom:1px solid #6A0307; text-align:right">
-                    <a href="#" id="{{playlist.playlist.public_id}}" onclick="editVar(this.id)" class="component_icon button icon_edit" data-toggle="modal" data-target="#edit">{% trans "Edit" %}</a>
+                    <a href="#" id="{{playlist.playlist.public_id}}" onclick="playlistUtils.editVar(this.id)" class="component_icon button icon_edit" data-toggle="modal" data-target="#edit">{% trans "Edit" %}</a>
                     <a href="{% url "telemeta-playlist-csv-export" playlist.playlist.public_id 'collections' %}" class="component_icon button icon_csv">CSV Collections</a>
                     <a href="{% url "telemeta-playlist-csv-export" playlist.playlist.public_id 'items' %}" class="component_icon button icon_csv">CSV Items</a>
                     <a href="#" id="{{playlist.playlist.public_id}}" onclick="if(confirm(gettrans('delete the playlist permanently?'))){playlistUtils.remove(this.id);};return false;" class="component_icon button icon_cancel">{% trans "Delete" %}</a>