Commit 93f162c2 authored by Gautam Chitnis's avatar Gautam Chitnis

Alteration (playlist): Implement bus message passing for all playlist functions

This commit implements bus message passing for all the methods in playlist component.

Gautam C.
parent b68b42c2
......@@ -76,7 +76,7 @@
</div>
</div>
<div id="playlistNavMobile" class="playlistNavMobile" onclick="app.$refs.plist.openPlaylist()">
<div id="playlistNavMobile" class="playlistNavMobile" onclick="bus.$emit('openPlaylist');">
Playlist
</div>
......
......@@ -6,6 +6,6 @@ function toggleRepeat()
function removeCurrent()
{
sendCommand(0,"command=pl_delete&id="+data.children[0].children[0].id);
app.$refs.plist.removeItem(data.children[0].children[0].id);
app.$refs.plist.refreshPlaylist();
bus.$emit('removeItem',data.children[0].children[0].id);
bus.$emit('refreshPlaylist');
}
\ No newline at end of file
......@@ -30,13 +30,32 @@ Vue.component('playlist', {
},
created: function()
{
bus.$on('playlistClose', function()
bus.$on('openPlaylist', function()
{
this.openPlaylist();
}.bind(this));
bus.$on('closePlaylist', function()
{
console.log("bus event");
this.closePlaylist();
}.bind(this));
bus.$on('populatePlaylist', function()
{
this.populatePlaylist();
}.bind(this));
bus.$on('removeItem', function(id)
{
this.removeItem(id);
}.bind(this));
bus.$on('refreshPlaylist', function()
{
this.refreshPlaylist();
}.bind(this));
this.refreshPlaylist();
}
});
......@@ -44,6 +63,6 @@ $(document).click(function(e){
var container = $("#playlistNav");
if($(window).width() <= 480 && !container.is(e.target) && container.has(e.target).length === 0 && container.css("width") != "0px"){
bus.$emit('playlistClose');
bus.$emit('closePlaylist');
}
});
\ No newline at end of file
......@@ -15,7 +15,7 @@ function sendCommand(mode, params) {
data: params,
success: function (data, status, jqXHR) {
jsonData = data;
app.$refs.plist.populatePlaylist();
bus.$emit('populatePlaylist');
}
});
} else if(mode == 2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment