-Subproject commit ea6605ad78243d798d88f1ffc46c8f6bc507ce11
+Subproject commit c043261bbe26298e2bea3ddb028332c78c9a6107
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 : [],
});
},
- 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)
});
},
- 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 = [];
<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 %}
<!--
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>