main: read-only mode (disables, editor and session history)

This commit is contained in:
jean-emmanuel 2017-03-21 08:19:21 +01:00
parent f8b8a566c5
commit 0899f5bc5e
9 changed files with 73 additions and 23 deletions

View file

@ -1,6 +1,5 @@
var {widgetManager} = require('./managers'),
ipc = require('./ipc'),
{Fader} = require('./widgets/sliders/fader')
ipc = require('./ipc')
module.exports = {
@ -146,7 +145,7 @@ module.exports = {
})
$('.editor').append(f)
},
editorDisable: function(){
editorDisable: function(permanent){
$('.widget.ui-resizable').resizable('destroy')
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
$('.editing').removeClass('editing')
@ -157,6 +156,13 @@ module.exports = {
$('body').removeClass('editor-enabled')
$('#grid-width-input').remove()
EDITING = false
if (permanent) {
$('.editor .btn').remove()
$('.editor .title').html($('.editor .title').html() + ' (disabled)').addClass('disabled')
module.exports.editorEnable = ()=>{}
READ_ONLY = true
}
},
traversingDisable: function(){
$('.traversingEnable, .traversingDisable').toggleClass('on')

View file

@ -35,36 +35,54 @@ var callbacks = module.exports = {
footer = lobby.find('.footer')
for (i in data) {
var max = 50
var path = data[i],
file = path.split('\\').pop().split('/').pop(),
length = data[i].length
path = path.replace(file,'')
if (length > max - 3) {
path = path.substr(0,Math.floor((path.length)/2)-(length-max)/2) + '...' + path.substr(Math.ceil((path.length)/2)+(length-max)/2, path.length)
}
list.append('<a class="btn load" data-session="'+data[i]+'">'+file+' <em style="opacity:0.45">('+path+')</em><span>'+icon('remove')+'</span></a>')
if (!READ_ONLY) {
}
list.append(`
<a class="btn load" data-session="${data[i]}">
${file}<em style="opacity:0.45">(${path})</em>
${READ_ONLY? '' : '<span>'+icon('remove')+'</span>'}
</a>
`)
}
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.find('a span').click(function(e){
e.stopPropagation()
ipc.send('sessionRemoveFromHistory',$(this).parent().data('session'))
$(this).parents('a').remove()
})
lobby.find('.browse').click(function(e){
e.stopPropagation()
actions.sessionBrowse()
})
lobby.find('.new').click(function(e){
e.stopPropagation()
module.exports.sessionNew()
})
if (!READ_ONLY) {
lobby.find('a span').click(function(e){
e.stopPropagation()
ipc.send('sessionRemoveFromHistory',$(this).parent().data('session'))
$(this).parents('a').remove()
})
footer.append('<a class="btn browse">'+icon('folder-open')+' Browse</a>')
footer.append('<a class="btn new">'+icon('file-o')+' New</a>')
lobby.find('.browse').click(function(e){
e.stopPropagation()
actions.sessionBrowse()
})
lobby.find('.new').click(function(e){
e.stopPropagation()
module.exports.sessionNew()
})
}
$('#lobby').append(lobby)
setTimeout(()=>{
lobby.addClass('loaded')
@ -99,6 +117,10 @@ var callbacks = module.exports = {
},150)
},
editorDisable: function(data){
actions.editorDisable(data.permanent)
},
error: function(data){
utils.createPopup(icon('warning')+'&nbsp;'+data.title,data.text,true)
},

View file

@ -9,6 +9,9 @@ var callbacks = {
if (name == 'edit_soft') return callbacks['/EDIT_SOFT'](args)
},
'/EDIT': function(args) {
if (READ_ONLY) return
var [id, json] = args,
newdata = JSON.parse(json),
containers = widgetManager.getWidgetById(id)
@ -25,6 +28,9 @@ var callbacks = {
}
},
'/EDIT_SOFT': function(args) {
if (READ_ONLY) return
var [id, json] = args,
newdata = JSON.parse(json),
containers = widgetManager.getWidgetById(id)

View file

@ -5,6 +5,7 @@ STATE = []
CLIPBOARD = null
EDITING = false
READ_ONLY = false
TABS = {}

View file

@ -83,6 +83,9 @@
flex-grow: 2;
padding: 10rem;
position: relative;
&.disabled {
color:var(--color-text-fade);
}
&:before {
content:"";
position: absolute;