lobby: make it smooth too

This commit is contained in:
jean-emmanuel 2016-11-05 12:10:30 +01:00
parent 0322092504
commit bddf5f8fa7
2 changed files with 22 additions and 9 deletions

View file

@ -60,14 +60,16 @@ module.exports = {
sessionList: function(event,data){
var data = data || event
$('#lobby').append(`
var lobby = $(`
<div class="main">
<div class="header">
Open Stage Control
</div>
<div class="list"></div>
<div class="footer"></div>
</div>`)
</div>`),
list = lobby.find('.list'),
footer = lobby.find('.footer')
for (i in data) {
var max = 50
@ -79,27 +81,31 @@ module.exports = {
path = path.substr(0,Math.floor((path.length)/2)-(length-max)/2) + '...' + path.substr(Math.ceil((path.length)/2)+(length-max)/2, path.length)
}
$('#lobby .list').append('<a class="btn load" data-session="'+data[i]+'">'+file+' <em style="opacity:0.45">('+path+')</em><span>'+icon('remove')+'</span></a>')
list.append('<a class="btn load" data-session="'+data[i]+'">'+file+' <em style="opacity:0.45">('+path+')</em><span>'+icon('remove')+'</span></a>')
}
$('#lobby .footer').append('<a class="btn browse">'+icon('folder-open')+' Browse</a>')
$('#lobby .footer').append('<a class="btn new">'+icon('file-o')+' New</a>')
$('#lobby .load').click(function(e){
footer.append('<a class="btn browse">'+icon('folder-open')+' Browse</a>')
footer.append('<a class="btn new">'+icon('file-o')+' New</a>')
lobby.find('.load').click(function(e){
e.stopPropagation()
IPC.send('sessionOpen',{path:$(this).data('session')})
})
$('#lobby a span').click(function(e){
lobby.find('a span').click(function(e){
e.stopPropagation()
IPC.send('sessionRemoveFromHistory',$(this).parent().data('session'))
$(this).parents('a').remove()
})
$('#lobby .browse').click(function(e){
lobby.find('.browse').click(function(e){
e.stopPropagation()
actions.sessionBrowse()
})
$('#lobby .new').click(function(e){
lobby.find('.new').click(function(e){
e.stopPropagation()
init([{}],function(){$('#open-toggle, .enable-editor').click();$('.editor-root').trigger('mousedown.editor')})
})
$('#lobby').append(lobby)
setTimeout(()=>{
lobby.addClass('loaded')
})
},
sessionOpen: function(event,data){