Editor rewritten !
- right click menu (copy/cut/paste/delete) - code splitted - using event delegation - many little improvements - still looks a bit messy...
This commit is contained in:
parent
91250b068a
commit
2d0c548fee
15 changed files with 760 additions and 621 deletions
File diff suppressed because one or more lines are too long
|
|
@ -4,6 +4,8 @@ WIDGETS = {}
|
|||
WIDGETS_LINKED = {}
|
||||
WIDGETS_ID_BY_PATH = {}
|
||||
SESSION = []
|
||||
CLIPBOARD = null
|
||||
EDITING = false
|
||||
|
||||
MISC = {
|
||||
iterators: {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
var editor = require('./editor')
|
||||
|
||||
module.exports = {
|
||||
|
||||
stateQuickSave: function(preset){
|
||||
|
|
@ -153,7 +151,23 @@ module.exports = {
|
|||
return popup
|
||||
},
|
||||
|
||||
editorEnable: editor.enable,
|
||||
editorDisable: editor.disable
|
||||
editorEnable: function(){
|
||||
$('.editor-root').attr('data-tab','#container').removeClass('disabled')
|
||||
$('.enable-editor').addClass('on')
|
||||
$('.disable-editor').removeClass('on')
|
||||
|
||||
EDITING = true
|
||||
},
|
||||
editorDisable: function(){
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
$('.editing').removeClass('editing')
|
||||
$('.editor-root').addClass('disabled')
|
||||
$('.editor-container').remove()
|
||||
$('.disable-editor').addClass('on')
|
||||
$('.enable-editor').removeClass('on')
|
||||
|
||||
EDITING = false
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,505 +0,0 @@
|
|||
var widgets = require('./widgets'),
|
||||
widgetOptions = widgets.widgetOptions,
|
||||
sync = widgets.sync,
|
||||
parsewidgets = require('./parser').widgets
|
||||
|
||||
|
||||
function getdata(obj){
|
||||
var path = []
|
||||
|
||||
do {
|
||||
if (obj.hasClass('widget')) {
|
||||
path.unshift(obj.index())
|
||||
path.unshift('widgets')
|
||||
} else if (obj.hasClass('tab')){
|
||||
path.unshift(obj.index())
|
||||
path.unshift('tabs')
|
||||
} else if (obj.attr('id')=='container') {
|
||||
break
|
||||
}
|
||||
|
||||
} while(obj = obj.parent() )
|
||||
|
||||
path.splice(0,1)
|
||||
|
||||
for (var i=0,obj=SESSION, path=path, len=path.length; i<len; i++){
|
||||
obj = obj[path[i]];
|
||||
};
|
||||
return obj;
|
||||
|
||||
}
|
||||
|
||||
module.exports.enable = function(){
|
||||
|
||||
var actions = require('./actions'),
|
||||
stateGet = actions.stateGet,
|
||||
stateSet = actions.stateSet,
|
||||
init = require('./init'),
|
||||
ui = require('./ui')
|
||||
|
||||
module.exports.disable()
|
||||
$('.editor').append('<div class="editor-container"></div>')
|
||||
var enableEditor = module.exports.enable
|
||||
$('.widget').on('mousedown.editor touchstart.editor',function(e){
|
||||
e.stopPropagation()
|
||||
|
||||
|
||||
var container = $(this),
|
||||
parent = container.parent(),
|
||||
index = container.index(),
|
||||
data = getdata(container),
|
||||
form = $('<div class="form"></div>')
|
||||
|
||||
if (container.hasClass('editing')) return
|
||||
|
||||
$('.editing').removeClass('editing')
|
||||
container.addClass('editing')
|
||||
|
||||
var updateWidget = function(){
|
||||
var scroll = $('#sidepanel').scrollTop()
|
||||
|
||||
var state = stateGet()
|
||||
|
||||
var newContainer = parsewidgets([data],parent)
|
||||
|
||||
stateSet(state,false)
|
||||
|
||||
container.replaceWith(newContainer)
|
||||
|
||||
enableEditor()
|
||||
sync()
|
||||
newContainer.children().first().trigger('mousedown.editor')
|
||||
$('#sidepanel').scrollTop(scroll)
|
||||
|
||||
if (data.tabs && data.tabs.length) ui.init()
|
||||
|
||||
}
|
||||
|
||||
var handleTarget
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$(this).resizable({
|
||||
handles:'s, e, se',
|
||||
helper: "ui-helper",
|
||||
start: function(event, ui){
|
||||
handleTarget = $(event.originalEvent.target);
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-s')) data.height = Math.max(ui.size.height,30)
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-e')) data.width = Math.max(ui.size.width,30)
|
||||
updateWidget()
|
||||
},
|
||||
snap:'.tab.on .widget, .tab.on',
|
||||
snapTolerance:5
|
||||
})
|
||||
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
if (data.hasOwnProperty('top')) {
|
||||
$(this).draggable({
|
||||
stop: function( event, ui ) {
|
||||
event.preventDefault()
|
||||
data.top = ui.helper.position().top + $(this).parent().scrollTop()
|
||||
data.left = ui.helper.position().left + $(this).parent().scrollLeft()
|
||||
ui.helper.remove()
|
||||
updateWidget()
|
||||
},
|
||||
handle:'.ui-draggable-handle',
|
||||
snap:'.tab.on .widget, .tab.on',
|
||||
snapTolerance:5,
|
||||
helper:function(){return $('<div class="ui-helper"></div>').css({height:$(this).outerHeight(),width:$(this).outerWidth()})}
|
||||
// containment:'parent'
|
||||
}).append('<div class="ui-draggable-handle"></div>')
|
||||
}
|
||||
|
||||
for (i in widgetOptions[data.type]) {
|
||||
if (i.indexOf('separator')!=-1) {
|
||||
$(`<div class="separator"><span>${widgetOptions[data.type][i]}</span></div>`).appendTo(form)
|
||||
continue
|
||||
} else if (data[i]===undefined) {
|
||||
continue
|
||||
}
|
||||
if (i!='widgets' && i!='tabs') {
|
||||
var type = typeof data[i],
|
||||
d = type == 'object'?JSON.stringify(data[i]):data[i],
|
||||
label = $(`<label>${i}</label>`).appendTo(form),
|
||||
input
|
||||
|
||||
if (i=='type') {
|
||||
input = $(`
|
||||
<select class="input" data-type="${type}" title="${i}"/>
|
||||
`)
|
||||
for (t in widgetOptions) {
|
||||
var selected = t==d?'selected=':''
|
||||
input.append(`
|
||||
<option ${selected} value="${t}">${t}</option>
|
||||
`)
|
||||
}
|
||||
select = $('<div class="select-wrapper"></div>').append(input)
|
||||
select.appendTo(form)
|
||||
} else if (typeof widgetOptions[data.type][i]=='boolean') {
|
||||
input = $(`
|
||||
<input class="checkbox" data-type="${type}" value='${d}' title="${i}"/>
|
||||
`)
|
||||
input.click(function(){
|
||||
$(this).val(!eval($(this).val())).trigger('change')
|
||||
})
|
||||
input.appendTo(form)
|
||||
|
||||
} else {
|
||||
input = $(`
|
||||
<input data-type="${type}" value='${d}' title="${i}"/>
|
||||
`)
|
||||
input.appendTo(form)
|
||||
}
|
||||
|
||||
|
||||
input.on('change',function(){
|
||||
var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
|
||||
data[$(this).attr('title')]= v=='true'||v=='false'?eval(v):v
|
||||
if (v=='') delete data[$(this).attr('title')]
|
||||
updateWidget()
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
if (data.widgets && (!data.tabs || data.tabs.length==0)) {
|
||||
|
||||
var list = $('<ul class="input"></ul>')
|
||||
|
||||
for (i in data.widgets) {
|
||||
var label = data.widgets[i].label!='auto'&&data.widgets[i].label!=false?data.widgets[i].label:data.widgets[i].id
|
||||
var item = $(`<li data-index="${i}" class="sortables" data-id="${data.widgets[i].id}"><a class="btn small">${label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(function(){
|
||||
container.find('.widget').first().parent().children('.widget').eq($(this).attr('data-index')).trigger('mousedown.editor')
|
||||
})
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(){
|
||||
data.widgets.splice($(this).parent().attr('data-index'),1)
|
||||
updateWidget()
|
||||
})
|
||||
}
|
||||
|
||||
list.sortable({start:function(){$(this).sortable( "refreshPositions" )},forcePlaceholderSize: true, items: '.sortables'}).on('sortupdate',function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.widgets.splice(newIndex, 0, data.widgets.splice(prevIndex, 1)[0])
|
||||
|
||||
updateWidget()
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data.widgets = data.widgets || []
|
||||
data.widgets.push({})
|
||||
|
||||
updateWidget()
|
||||
})
|
||||
|
||||
$('<label>widgets</label>').appendTo(form)
|
||||
list.appendTo(form)
|
||||
|
||||
}
|
||||
|
||||
if (data.tabs && (!data.widgets || data.widgets.length==0)) {
|
||||
//tabs
|
||||
var list = $('<ul class="input"></ul>')
|
||||
|
||||
for (i in data.tabs) {
|
||||
var label = data.tabs[i].label
|
||||
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(function(){
|
||||
var id = container.find('.tab').first().parent().children('.tab').eq($(this).attr('data-index')).attr('id')
|
||||
$(`a[data-tab="#${id}"]`).trigger('mousedown.editor')
|
||||
})
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(){
|
||||
data.tabs.splice($(this).parent().attr('data-index'),1)
|
||||
updateWidget()
|
||||
})
|
||||
}
|
||||
|
||||
list.sortable({start:function(){$(this).sortable( "refreshPositions" )},forcePlaceholderSize: true, items: '.sortables'}).on('sortupdate',function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.tabs.splice(newIndex, 0, data.tabs.splice(prevIndex, 1)[0])
|
||||
|
||||
updateWidget()
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data.tabs = data.tabs || []
|
||||
data.tabs.push({})
|
||||
|
||||
updateWidget()
|
||||
})
|
||||
$('<label>tabs</label>').appendTo(form)
|
||||
list.appendTo(form)
|
||||
}
|
||||
|
||||
$('.editor-container').html(form)
|
||||
})
|
||||
|
||||
|
||||
$('a[data-tab]').on('mousedown.editor touchstart.editor',function(e){
|
||||
e.stopPropagation()
|
||||
|
||||
var link = $(this),
|
||||
container = $(link.attr('data-tab')),
|
||||
parent = container.parent(),
|
||||
index = container.index(),
|
||||
data = getdata(container),
|
||||
form = $('<div class="form"></div>')
|
||||
|
||||
$('.editing').removeClass('editing')
|
||||
link.addClass('editing')
|
||||
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
|
||||
var ontab = []
|
||||
$('.tab.on').each(function(i){
|
||||
ontab.push($(this).attr('id'))
|
||||
})
|
||||
ontab.splice(ontab.indexOf(container.attr('id')),1)
|
||||
ontab.push(container.attr('id'))
|
||||
|
||||
var updateTab = function() {
|
||||
var scroll = $('#sidepanel').scrollTop()
|
||||
|
||||
var state = stateGet()
|
||||
|
||||
container.empty()
|
||||
parsewidgets(data.widgets,container)
|
||||
|
||||
stateSet(state,false)
|
||||
|
||||
enableEditor()
|
||||
sync()
|
||||
|
||||
link.trigger('mousedown.editor')
|
||||
|
||||
$('#sidepanel').scrollTop(scroll)
|
||||
}
|
||||
|
||||
var updateSession = function(){
|
||||
var scroll = $('#sidepanel').scrollTop()
|
||||
|
||||
var state = stateGet()
|
||||
|
||||
init(SESSION,function(){
|
||||
stateSet(state,false)
|
||||
enableEditor()
|
||||
for (i in ontab) {
|
||||
$(`a[data-tab="#${ontab[i]}"]`).click()
|
||||
}
|
||||
$('#sidepanel').scrollTop(scroll)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
for (i in data) {
|
||||
if (i!='widgets' && i!='tabs') {
|
||||
var type = typeof data[i]
|
||||
var d = type == 'object'?JSON.stringify(data[i]):data[i]
|
||||
var input = $(`
|
||||
<label>${i}</label>
|
||||
<input data-type="${type}" value='${d}' title="${i}"/>
|
||||
`)
|
||||
input.appendTo(form)
|
||||
input.on('change',function(){
|
||||
var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
|
||||
data[$(this).attr('title')]= v=='true'||v=='false'?eval(v):v
|
||||
if (v=='') delete data[$(this).attr('title')]
|
||||
updateSession()
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
if (!data.tabs || data.tabs.length==0) {
|
||||
|
||||
var list = $('<ul class="input"></ul>')
|
||||
|
||||
for (i in data.widgets) {
|
||||
var label = data.widgets[i].label!='auto'&&data.widgets[i].label!=false?data.widgets[i].label:data.widgets[i].id
|
||||
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(function(){
|
||||
container.find('.widget').first().parent().children('.widget').eq($(this).attr('data-index')).trigger('mousedown.editor')
|
||||
})
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(){
|
||||
data.widgets.splice($(this).parent().attr('data-index'),1)
|
||||
updateTab()
|
||||
})
|
||||
}
|
||||
|
||||
list.sortable({start:function(){$(this).sortable( "refreshPositions" )},forcePlaceholderSize: true, items: '.sortables'}).on('sortupdate',function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.widgets.splice(newIndex, 0, data.widgets.splice(prevIndex, 1)[0])
|
||||
|
||||
updateTab()
|
||||
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data.widgets = data.widgets || []
|
||||
data.widgets.push({})
|
||||
|
||||
updateTab()
|
||||
})
|
||||
$('<label>widgets</label>').appendTo(form)
|
||||
list.appendTo(form)
|
||||
|
||||
}
|
||||
|
||||
if (!data.widgets || data.widgets.length==0) {
|
||||
//tabs
|
||||
var list = $('<ul class="input"></ul>')
|
||||
|
||||
for (i in data.tabs) {
|
||||
var label = data.tabs[i].label
|
||||
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(function(){
|
||||
var id = container.find('.tab').first().parent().children('.tab').eq($(this).attr('data-index')).attr('id')
|
||||
$(`a[data-tab="#${id}"]`).trigger('mousedown.editor')
|
||||
})
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(){
|
||||
data.tabs.splice($(this).parent().attr('data-index'),1)
|
||||
updateSession()
|
||||
})
|
||||
}
|
||||
|
||||
list.sortable({start:function(){$(this).sortable( "refreshPositions" )},forcePlaceholderSize: true, items: '.sortables'}).on('sortupdate',function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.tabs.splice(newIndex, 0, data.tabs.splice(prevIndex, 1)[0])
|
||||
|
||||
updateSession()
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data.tabs = data.tabs || []
|
||||
data.tabs.push({})
|
||||
|
||||
updateSession()
|
||||
})
|
||||
$('<label>tabs</label>').appendTo(form)
|
||||
list.appendTo(form)
|
||||
}
|
||||
|
||||
$('.editor-container').html(form)
|
||||
})
|
||||
|
||||
$('.editor-root').removeClass('disabled').on('click.editor',function(e){
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
|
||||
var data = SESSION,
|
||||
form = $('<div class="form"></div>'),
|
||||
container = $('#container')
|
||||
|
||||
$('.editing').removeClass('editing')
|
||||
$(this).addClass('editing')
|
||||
|
||||
var ontab = []
|
||||
$('.tab.on').each(function(i){
|
||||
ontab.push($(this).attr('id'))
|
||||
})
|
||||
ontab.splice(ontab.indexOf(container.attr('id')),1)
|
||||
ontab.push(container.attr('id'))
|
||||
|
||||
|
||||
var updateSession = function(){
|
||||
var scroll = $('#sidepanel').scrollTop()
|
||||
|
||||
var state = stateGet()
|
||||
|
||||
init(SESSION,function(){
|
||||
stateSet(state,false)
|
||||
enableEditor()
|
||||
for (i in ontab) {
|
||||
$(`a[data-tab="#${ontab[i]}"]`).trigger('mousedown.editor')
|
||||
}
|
||||
$('.editor-root').click()
|
||||
$('#sidepanel').scrollTop(scroll)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
var list = $('<ul class="input"></ul>')
|
||||
|
||||
for (i in data) {
|
||||
var label = data[i].label
|
||||
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(function(){
|
||||
var id = $('#container > .content > .tab').eq($(this).attr('data-index')).attr('id')
|
||||
$(`a[data-tab="#${id}"]`).trigger('mousedown.editor')
|
||||
})
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(){
|
||||
data.splice($(this).parent().attr('data-index'),1)
|
||||
updateSession()
|
||||
})
|
||||
}
|
||||
|
||||
list.sortable({start:function(){$(this).sortable( "refreshPositions" )},forcePlaceholderSize: true, items: '.sortables'}).on('sortupdate',function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.splice(newIndex, 0, data.splice(prevIndex, 1)[0])
|
||||
|
||||
updateSession()
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data = data || []
|
||||
data.push({})
|
||||
|
||||
updateSession()
|
||||
})
|
||||
$('<label>tabs</label>').appendTo(form)
|
||||
list.appendTo(form)
|
||||
|
||||
|
||||
$('.editor-container').html(form)
|
||||
})
|
||||
|
||||
$('.editor-container').html(`
|
||||
<p class="help">
|
||||
Click on a widget or on a tab's title to edit
|
||||
</p>
|
||||
`)
|
||||
$('.enable-editor').addClass('on')
|
||||
$('.disable-editor').removeClass('on')
|
||||
}
|
||||
|
||||
module.exports.disable = function(){
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
|
||||
$('a[data-tab], .widget, .editor-root').off('.editor')
|
||||
|
||||
$('.editor-root').addClass('disabled')
|
||||
$('.enable-editor').removeClass('on')
|
||||
$('.disable-editor').addClass('on')
|
||||
$('.editing').removeClass('editing')
|
||||
|
||||
$('.editor .editor-container').remove()
|
||||
}
|
||||
56
browser/js/app/editor/context-menu.js
Normal file
56
browser/js/app/editor/context-menu.js
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
var correctPosition = function (m, parent){
|
||||
var pos = m.offset(),
|
||||
width = m.outerWidth(),
|
||||
height = m.outerHeight(),
|
||||
totalWidth = $('body').outerWidth(),
|
||||
totalHeight = $('body').outerHeight(),
|
||||
leftAdjust = parent=='body'?0:parent.outerWidth()-2
|
||||
|
||||
if (width + pos.left > totalWidth) {
|
||||
m.css({'margin-left':totalWidth-(width + pos.left + leftAdjust)})
|
||||
}
|
||||
if (height + pos.top > totalHeight) {
|
||||
m.css({'margin-top':totalHeight-(height + pos.top)})
|
||||
}
|
||||
}
|
||||
|
||||
var menu = function(e,actions,parent){
|
||||
|
||||
var m = $('<div class="context-menu"></div>')
|
||||
if (parent=='body') {
|
||||
m.css({top:e.pageY+'px',left:e.pageX+'px'})
|
||||
}
|
||||
|
||||
for (label in actions) {
|
||||
|
||||
if (typeof actions[label] == 'object') {
|
||||
|
||||
var item = $(`<div class="item has-sub" tabIndex="1">${label}</div>`).appendTo(m).on('touchstart mousedown',function(e){e.stopPropagation()})
|
||||
menu(e,actions[label],item)
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
$(`<div class="item">${label}</div>`).on('mousedown.editor touchstart.editor',function(){
|
||||
var callback = actions[label]
|
||||
return function(e){
|
||||
callback()
|
||||
$('.context-menu').remove()
|
||||
}
|
||||
}()).appendTo(m)
|
||||
}
|
||||
}
|
||||
|
||||
m.appendTo(parent)
|
||||
|
||||
|
||||
|
||||
if (parent=='body') {
|
||||
correctPosition(m,parent)
|
||||
} else {
|
||||
parent.hover(function(){correctPosition(m,parent)})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = menu
|
||||
94
browser/js/app/editor/data-workers.js
Normal file
94
browser/js/app/editor/data-workers.js
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
var widgets = require('../widgets'),
|
||||
widgetOptions = widgets.widgetOptions,
|
||||
sync = widgets.sync,
|
||||
parser = require('../parser')
|
||||
parsewidgets = parser.widgets,
|
||||
parsetabs = parser.tabs,
|
||||
ui = require('../ui'),
|
||||
actions = require('../actions'),
|
||||
sidepanelCreateToggle = require('../sidepanel').createToggle,
|
||||
editObject = function(a,b){require('./edit-objects').editObject(a,b,true)},
|
||||
editSession = function(a,b){require('./edit-objects').editSession(a,b,true)}
|
||||
|
||||
|
||||
var getObjectData = function(obj){
|
||||
var path = []
|
||||
|
||||
do {
|
||||
if (obj[0].classList.contains('widget')) {
|
||||
path.unshift(obj.index())
|
||||
path.unshift('widgets')
|
||||
} else if (obj[0].classList.contains('tab')){
|
||||
path.unshift(obj.index())
|
||||
path.unshift('tabs')
|
||||
} else if (obj[0].getAttribute('id')=='container') {
|
||||
break
|
||||
}
|
||||
|
||||
} while(obj = obj.parent() )
|
||||
|
||||
path.splice(0,1)
|
||||
|
||||
for (var i=0,obj=SESSION, path=path, len=path.length; i<len; i++){
|
||||
obj = obj[path[i]]
|
||||
}
|
||||
|
||||
return obj
|
||||
|
||||
}
|
||||
|
||||
var updateDom = function(container,data) {
|
||||
|
||||
// save state
|
||||
var scroll = $('#sidepanel').scrollTop(),
|
||||
state = actions.stateGet()
|
||||
|
||||
|
||||
|
||||
if (container.hasClass('widget')) {
|
||||
// widget
|
||||
var newContainer = parsewidgets([data],container.parent())
|
||||
container.replaceWith(newContainer)
|
||||
|
||||
editObject(newContainer,data)
|
||||
|
||||
} else if (container.hasClass('tab')) {
|
||||
// tab
|
||||
var newContainer = container.empty()
|
||||
|
||||
if (data.widgets && data.widgets.length) parsewidgets(data.widgets,container)
|
||||
if (data.tabs && data.tabs.length) parsetabs(data.tabs,container)
|
||||
|
||||
$(`a[data-tab="#${container.attr('id')}"]`).html(`<span>${data.label}</span></a>`)
|
||||
|
||||
editObject(newContainer,data)
|
||||
|
||||
} else if (container.attr('id')=='container') {
|
||||
// session
|
||||
var newContainer = $('#container')
|
||||
container.empty()
|
||||
parsetabs(data,container,true)
|
||||
|
||||
editSession(newContainer,data)
|
||||
sidepanelCreateToggle()
|
||||
|
||||
}
|
||||
|
||||
|
||||
// restore state
|
||||
|
||||
actions.stateSet(state,false)
|
||||
sync()
|
||||
ui.tabs()
|
||||
ui.scrolls()
|
||||
$('#sidepanel').scrollTop(scroll)
|
||||
|
||||
// return updated node
|
||||
return newContainer
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
updateDom:updateDom,
|
||||
getObjectData:getObjectData
|
||||
}
|
||||
282
browser/js/app/editor/edit-objects.js
Normal file
282
browser/js/app/editor/edit-objects.js
Normal file
|
|
@ -0,0 +1,282 @@
|
|||
var updateDom = require('./data-workers').updateDom,
|
||||
widgetOptions = require('../widgets').widgetOptions
|
||||
|
||||
var editObject = function(container, data, refresh){
|
||||
|
||||
if (!refresh && (container.hasClass('editing') || $(`a[data-tab="#${container.attr('id')}"]`).hasClass('editing'))) return
|
||||
|
||||
$('.editing').removeClass('editing')
|
||||
$(`a[data-tab="#${container.attr('id')}"]`).addClass('editing').click()
|
||||
$(container).addClass('editing')
|
||||
|
||||
$('.editor-container').remove()
|
||||
$('.editor').append('<div class="editor-container"></div>')
|
||||
var form = $('<div class="form"></div>').appendTo('.editor-container')
|
||||
|
||||
var isWidget = container.hasClass('widget')
|
||||
|
||||
var params = isWidget?widgetOptions[data.type]:{label:''}
|
||||
|
||||
for (i in params) {
|
||||
|
||||
if (i.indexOf('separator')!=-1) {
|
||||
$(`<div class="separator"><span>${params[i]}</span></div>`).appendTo(form)
|
||||
continue
|
||||
} else if (data[i]===undefined) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Common options edit
|
||||
if (i!='widgets' && i!='tabs') {
|
||||
|
||||
var type = typeof data[i],
|
||||
value = type == 'object'?JSON.stringify(data[i]):data[i],
|
||||
label = $(`<label>${i}</label>`).appendTo(form),
|
||||
input
|
||||
|
||||
if (i=='type') {
|
||||
|
||||
input = $(`<select class="input" data-type="${type}" title="${i}"/>`)
|
||||
|
||||
for (t in widgetOptions) {
|
||||
input.append(`<option ${t==value?'selected=':''} value="${t}">${t}</option>`)
|
||||
}
|
||||
select = $('<div class="select-wrapper"></div>').append(input)
|
||||
select.appendTo(form)
|
||||
|
||||
} else if (typeof params[i]=='boolean') {
|
||||
|
||||
input = $(`<input class="checkbox" data-type="${type}" value='${value}' title="${i}"/>`)
|
||||
input.click(function(){
|
||||
$(this).val(!eval($(this).val())).trigger('change')
|
||||
})
|
||||
input.appendTo(form)
|
||||
|
||||
} else {
|
||||
|
||||
input = $(`<input data-type="${type}" value='${value}' title="${i}"/>`)
|
||||
input.appendTo(form)
|
||||
|
||||
}
|
||||
|
||||
|
||||
input.on('change',function(){
|
||||
var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
|
||||
data[$(this).attr('title')]= v=='true'||v=='false'?eval(v):v
|
||||
if (v=='') delete data[$(this).attr('title')]
|
||||
updateDom(container,data)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// widget list edit
|
||||
if (((isWidget&&widgetOptions[data.type].widgets) || (container.hasClass('tab'))) && (!data.tabs||!data.tabs.length)) {
|
||||
|
||||
var list = $('<ul class="input"></ul>')
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.widget').first().siblings().addBack().eq(i).trigger('mousedown.editor')
|
||||
}
|
||||
}
|
||||
|
||||
for (i in data.widgets) {
|
||||
|
||||
|
||||
var item = $(`<li data-index="${i}" class="sortables" data-id="${data.widgets[i].id}"><a class="btn small">${data.widgets[i].id||data.widgets[i].label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(editItem(i))
|
||||
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(e){
|
||||
e.stopPropagation()
|
||||
data.widgets.splice($(this).parent().attr('data-index'),1)
|
||||
updateDom(container,data)
|
||||
})
|
||||
}
|
||||
|
||||
list.sortable({
|
||||
forcePlaceholderSize: true,
|
||||
items: '.sortables',
|
||||
start:function(){$(this).sortable( "refreshPositions" )},
|
||||
update: function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.widgets.splice(newIndex, 0, data.widgets.splice(prevIndex, 1)[0])
|
||||
|
||||
updateDom(container,data)
|
||||
}
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data.widgets = data.widgets || []
|
||||
data.widgets.push({})
|
||||
|
||||
updateDom(container,data)
|
||||
})
|
||||
|
||||
$('<label>widgets</label>').appendTo(form)
|
||||
list.appendTo(form)
|
||||
|
||||
}
|
||||
|
||||
// tab list edit
|
||||
if (((isWidget&&widgetOptions[data.type].tabs) || (container.hasClass('tab'))) && (!data.widgets||!data.widgets.length)) {
|
||||
//tabs
|
||||
var list = $('<ul class="input"></ul>')
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.tab').first().siblings().addBack().eq(i).trigger('mousedown.editor')
|
||||
}
|
||||
}
|
||||
|
||||
for (i in data.tabs) {
|
||||
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${data.tabs[i].label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(editItem(i))
|
||||
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(e){
|
||||
e.stopPropagation()
|
||||
data.tabs.splice($(this).parent().attr('data-index'),1)
|
||||
updateDom(container,data)
|
||||
})
|
||||
}
|
||||
|
||||
list.sortable({
|
||||
start:function(){$(this).sortable( "refreshPositions" )},
|
||||
forcePlaceholderSize: true,
|
||||
items: '.sortables',
|
||||
update: function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.tabs.splice(newIndex, 0, data.tabs.splice(prevIndex, 1)[0])
|
||||
|
||||
updateDom(container,data)
|
||||
}
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data.tabs = data.tabs || []
|
||||
data.tabs.push({})
|
||||
|
||||
updateDom(container,data)
|
||||
})
|
||||
$('<label>tabs</label>').appendTo(form)
|
||||
list.appendTo(form)
|
||||
}
|
||||
|
||||
|
||||
$('.widget.ui-resizable').resizable('destroy')
|
||||
if (data.hasOwnProperty('width')) {
|
||||
var handleTarget
|
||||
container.resizable({
|
||||
handles:'s, e, se',
|
||||
helper: "ui-helper",
|
||||
start: function(event, ui){
|
||||
handleTarget = $(event.originalEvent.target)
|
||||
},
|
||||
stop: function( event, ui ) {
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-s')) data.height = Math.max(ui.size.height,30)
|
||||
if (handleTarget.hasClass('ui-resizable-se') || handleTarget.hasClass('ui-resizable-e')) data.width = Math.max(ui.size.width,30)
|
||||
updateDom(container,data)
|
||||
},
|
||||
snap:'.tab.on .widget, .tab.on',
|
||||
snapTolerance:5
|
||||
})
|
||||
}
|
||||
|
||||
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
|
||||
if (data.hasOwnProperty('top')) {
|
||||
container.draggable({
|
||||
stop: function( event, ui ) {
|
||||
event.preventDefault()
|
||||
data.top = ui.helper.position().top + container.parent().scrollTop()
|
||||
data.left = ui.helper.position().left + container.parent().scrollLeft()
|
||||
ui.helper.remove()
|
||||
updateDom(container,data)
|
||||
},
|
||||
handle:'.ui-draggable-handle',
|
||||
snap:'.tab.on .widget, .tab.on',
|
||||
snapTolerance:5,
|
||||
helper:function(){return $('<div class="ui-helper"></div>').css({height:container.outerHeight(),width:container.outerWidth()})}
|
||||
}).append('<div class="ui-draggable-handle"></div>')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var editSession = function(container,data,refresh){
|
||||
|
||||
if (!refresh && $('.editor-root').hasClass('editing')) return
|
||||
|
||||
$('.editing').removeClass('editing')
|
||||
$('.editor-root').addClass('editing')
|
||||
|
||||
$('.editor-container').remove()
|
||||
$('.editor').append('<div class="editor-container"></div>')
|
||||
|
||||
|
||||
var form = $('<div class="form"></div>').appendTo('.editor-container'),
|
||||
list = $('<ul class="input"></ul>')
|
||||
|
||||
var editItem = function(i) {
|
||||
return function(){
|
||||
container.find('.tab').first().siblings().addBack().eq(i).trigger('mousedown.editor')
|
||||
}
|
||||
}
|
||||
|
||||
for (i in data) {
|
||||
var item = $(`<li data-index="${i}" class="sortables"><a class="btn small">${data[i].label}</a></li>`)
|
||||
.appendTo(list)
|
||||
.click(editItem(i))
|
||||
|
||||
var remove = $('<span><i class="fa fa-remove"></i></span>')
|
||||
.appendTo(item)
|
||||
.click(function(e){
|
||||
e.stopPropagation()
|
||||
data.splice($(this).parent().attr('data-index'),1)
|
||||
updateDom(container,data)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
list.sortable({
|
||||
start:function(){$(this).sortable( "refreshPositions" )},
|
||||
forcePlaceholderSize: true,
|
||||
items: '.sortables',
|
||||
update: function(e,ui){
|
||||
var prevIndex = $(ui.item).attr('data-index')
|
||||
var newIndex = $(ui.item).index()
|
||||
|
||||
data.splice(newIndex, 0, data.splice(prevIndex, 1)[0])
|
||||
|
||||
updateDom(container,data)
|
||||
}
|
||||
})
|
||||
|
||||
var add = $(`<li><a class="btn small">+</a></li>`).appendTo(list).click(function(){
|
||||
data = data || []
|
||||
data.push({})
|
||||
|
||||
updateDom(container,data)
|
||||
})
|
||||
|
||||
$('<label>tabs</label>').appendTo(form)
|
||||
list.appendTo(form)
|
||||
|
||||
|
||||
$('.editor-container').append(form)
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
editObject:editObject,
|
||||
editSession:editSession
|
||||
}
|
||||
127
browser/js/app/editor/init.js
Normal file
127
browser/js/app/editor/init.js
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
var data = require('./data-workers'),
|
||||
getObjectData = data.getObjectData,
|
||||
updateDom = data.updateDom,
|
||||
edit = require('./edit-objects'),
|
||||
editObject = edit.editObject,
|
||||
editSession = edit.editSession,
|
||||
createPopup = require('../utils').createPopup,
|
||||
widgetOptions = require('../widgets').widgetOptions,
|
||||
menu = require('./context-menu')
|
||||
|
||||
|
||||
|
||||
var init = function(){
|
||||
|
||||
|
||||
$('body').off('.editor').on('mousedown.editor touchstart.editor',function(e){
|
||||
|
||||
if (!EDITING) return
|
||||
|
||||
$('.context-menu').remove()
|
||||
|
||||
var target = $(e.target).is('.widget, .tab, [data-tab]')?
|
||||
$(e.target):
|
||||
$(e.target).closest('.widget, .tab, a[data-tab]')
|
||||
|
||||
if (!target.length) return
|
||||
|
||||
var container = target.attr('data-tab')?$(target.attr('data-tab')):target,
|
||||
type = target.hasClass('widget')?'widget':'tab',
|
||||
parent = container.parent(),
|
||||
index = container.index(),
|
||||
data = getObjectData(container)
|
||||
|
||||
if (container.attr('id')=='container') {
|
||||
editSession(container,SESSION)
|
||||
return
|
||||
}
|
||||
|
||||
editObject(container,data)
|
||||
|
||||
if (e.button!=2) return
|
||||
|
||||
var actions = {}
|
||||
|
||||
// actions['<i class="fa fa-edit"></i> Edit'] = function(){editObject(container,data)}
|
||||
|
||||
if (type=='widget') actions['<i class="fa fa-copy"></i> Copy'] = function(){CLIPBOARD=data}
|
||||
|
||||
if (type=='widget') actions['<i class="fa fa-cut"></i> Cut'] = function(){
|
||||
CLIPBOARD=JSON.parse(JSON.stringify(data))
|
||||
var parentContainer = container.parents('.widget, .tab, #container').first()
|
||||
parentData = getObjectData(parentContainer)
|
||||
|
||||
parentData.widgets.splice(container.index(),1)
|
||||
updateDom(parentContainer,parentData)
|
||||
}
|
||||
|
||||
if (((type=='widget'&&widgetOptions[data.type].widgets) || (type=='tab')) && (!data.tabs||!data.tabs.length)) {
|
||||
|
||||
if (CLIPBOARD!=null) actions['<i class="fa fa-paste"></i> Paste'] = function(){
|
||||
data.widgets = data.widgets || []
|
||||
data.widgets.push(JSON.parse(JSON.stringify(CLIPBOARD)))
|
||||
updateDom(container,data)
|
||||
}
|
||||
|
||||
actions['<i class="fa fa-plus"></i> Add widget'] = {}
|
||||
var createFunction = function(widgetType,container,data){
|
||||
return function() {
|
||||
data.widgets = data.widgets || []
|
||||
data.widgets.push({type:widgetType})
|
||||
updateDom(container,data)
|
||||
}
|
||||
}
|
||||
for (widgetType in widgetOptions) {
|
||||
actions['<i class="fa fa-plus"></i> Add widget'][widgetType] = createFunction(widgetType,container,data)
|
||||
}
|
||||
|
||||
}
|
||||
if (((type=='widget'&&widgetOptions[data.type].tabs) || (type=='tab')) && (!data.widgets||!data.widgets.length)) {
|
||||
|
||||
actions['<i class="fa fa-plus"></i> Add tab'] = function(){
|
||||
data.tabs = data.tabs || []
|
||||
data.tabs.push({})
|
||||
updateDom(container,data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
actions['<i class="fa fa-trash"></i> Delete'] = function(){
|
||||
var popup = createPopup('Are you sure ?',`
|
||||
<div class="actions">
|
||||
<div class="btn warning confirm-delete">DELETE</div>
|
||||
<div class="btn cancel-delete">CANCEL</div>
|
||||
</div>
|
||||
`)
|
||||
$('.confirm-delete').click(function(){
|
||||
popup.close()
|
||||
var parentContainer = container.parents('.widget, .tab, #container').first()
|
||||
parentData = getObjectData(parentContainer)
|
||||
|
||||
if (type=='widget') {
|
||||
parentData.widgets.splice(container.index(),1)
|
||||
} else if (type=='tab' && parentContainer.attr('id')!='container') {
|
||||
parentData.tabs.splice(container.index(),1)
|
||||
} else {
|
||||
parentData.splice(container.index(),1)
|
||||
}
|
||||
|
||||
updateDom(parentContainer,parentData)
|
||||
})
|
||||
$('.cancel-delete').click(function(){
|
||||
popup.close()
|
||||
})
|
||||
$(document).on('keydown.popup', function(e){
|
||||
if (e.keyCode==13) $('.confirm-delete').click()
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
menu(e,actions,'body')
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
module.exports = init
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
var parsetabs = require('./parser').tabs,
|
||||
ui = require('./ui'),
|
||||
sync = require('./widgets').sync,
|
||||
disableEditor = require('./editor').disable
|
||||
editorDisable = require('./actions').editorDisable
|
||||
|
||||
module.exports = function(session,callback) {
|
||||
|
||||
|
|
@ -11,7 +11,8 @@ module.exports = function(session,callback) {
|
|||
|
||||
ui.init()
|
||||
|
||||
disableEditor()
|
||||
editorDisable()
|
||||
require('./editor/init')()
|
||||
|
||||
sync()
|
||||
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ module.exports.tabs = function(data,parent,main){
|
|||
tabContent.data(tabData)
|
||||
|
||||
|
||||
if (tabData.tabs) {
|
||||
if (tabData.tabs && tabData.tabs.length) {
|
||||
module.exports.tabs(tabData.tabs,parent=tabContent)
|
||||
} else if (tabData.widgets) {
|
||||
} else if (tabData.widgets && tabData.widgets.length) {
|
||||
module.exports.widgets(tabData.widgets,tabContent)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,17 +101,21 @@ var sidepanel = function(data){
|
|||
|
||||
}(data)
|
||||
|
||||
module.exports = function() {
|
||||
|
||||
$('#sidepanel').append(sidepanel)
|
||||
|
||||
var toggle = function(){
|
||||
$(`<a id="open-toggle">${icon('navicon')}</a>`).appendTo('#container').click(function(){
|
||||
$('#open-toggle, #sidepanel, #container').toggleClass('sidepanel-open')
|
||||
})
|
||||
|
||||
// in case where are hot loading a session
|
||||
if ($('#sidepanel').hasClass('sidepanel-open')) {
|
||||
$('#open-toggle, #container').addClass('sidepanel-open')
|
||||
}
|
||||
$('#open-toggle, #sidepanel, #container').toggleClass('sidepanel-open')
|
||||
})
|
||||
|
||||
// in case where are hot loading a session
|
||||
if ($('#sidepanel').hasClass('sidepanel-open')) {
|
||||
$('#open-toggle, #container').addClass('sidepanel-open')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
init:function(){
|
||||
$('#sidepanel').append(sidepanel)
|
||||
toggle()
|
||||
},
|
||||
createToggle:toggle
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
var actions = require('./actions'),
|
||||
icon = require('./utils').icon
|
||||
|
||||
var sidepanel = require('./sidepanel')
|
||||
var sidepanel = require('./sidepanel').init
|
||||
|
||||
// Tabs...
|
||||
var tabs = function() {
|
||||
|
|
@ -73,5 +73,7 @@ module.exports = {
|
|||
sidepanel()
|
||||
tabs()
|
||||
scrolls()
|
||||
}
|
||||
},
|
||||
tabs:tabs,
|
||||
scrolls:scrolls
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ module.exports = {
|
|||
|
||||
|
||||
popup.close = function(){
|
||||
$(document).unbind('keydown.popup')
|
||||
$(document).unbind('.popup')
|
||||
popup.remove()
|
||||
}
|
||||
|
||||
|
|
@ -29,6 +29,7 @@ module.exports = {
|
|||
})
|
||||
|
||||
|
||||
|
||||
return popup
|
||||
},
|
||||
icon: function(i) {
|
||||
|
|
|
|||
|
|
@ -99,8 +99,6 @@ input {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
html, body {
|
||||
height:100%;
|
||||
overflow:hidden;
|
||||
|
|
@ -133,6 +131,7 @@ body {
|
|||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
box-shadow: 0 0 0 1rem $color-border, 0 0 0 100rem rgba($color-text,.05) inset;
|
||||
}
|
||||
|
|
@ -140,6 +139,9 @@ body {
|
|||
padding:8rem;
|
||||
padding-right: 15rem;
|
||||
}
|
||||
&.warning {
|
||||
background:firebrick;
|
||||
}
|
||||
&.disabled {
|
||||
pointer-events: none;
|
||||
color:$color-text-fade;
|
||||
|
|
@ -239,6 +241,8 @@ body {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#sidepanel {
|
||||
position:absolute;
|
||||
z-index: 999999;
|
||||
|
|
@ -268,45 +272,20 @@ body {
|
|||
li {
|
||||
display:block;
|
||||
margin-bottom:5rem;
|
||||
position: relative;
|
||||
background:$color-fg;
|
||||
position: relative;
|
||||
&:last-child {
|
||||
margin-bottom: 0
|
||||
}
|
||||
.title {
|
||||
padding-bottom:15rem;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
flex-wrap:wrap;
|
||||
a {
|
||||
min-width:33.33%;
|
||||
flex-grow:3;
|
||||
padding:10rem;
|
||||
display: block;
|
||||
text-align: center;
|
||||
&.on {
|
||||
pointer-events: none;
|
||||
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
border-top:2rem solid $color-accent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.btn + span {
|
||||
position: absolute;
|
||||
right:0rem;
|
||||
top:0rem;
|
||||
padding:8rem;
|
||||
color:$color-text-fade;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
color:$color-text;
|
||||
}
|
||||
|
|
@ -328,8 +307,33 @@ body {
|
|||
}
|
||||
}
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
flex-wrap:wrap;
|
||||
a {
|
||||
min-width:33.33%;
|
||||
flex-grow:3;
|
||||
padding:10rem;
|
||||
display: block;
|
||||
text-align: center;
|
||||
&.on {
|
||||
pointer-events: none;
|
||||
|
||||
.editing {
|
||||
&:after {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
border-top:2rem solid $color-accent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.widget.editing {
|
||||
z-index: 11!important;
|
||||
}
|
||||
.widget.editing:after, a.editing:before {
|
||||
|
|
@ -343,6 +347,113 @@ body {
|
|||
pointer-events: none;
|
||||
}
|
||||
|
||||
.context-menu {
|
||||
position:fixed;
|
||||
z-index: 999999999;
|
||||
background: $color-raised-top;
|
||||
box-shadow: 0 0 4rem 0 $color-border;
|
||||
.context-menu {
|
||||
position: absolute;
|
||||
left:100%;
|
||||
top:0;
|
||||
opacity:0;
|
||||
pointer-events: none;
|
||||
margin-left: 2rem;
|
||||
&:before {
|
||||
content:"";
|
||||
position: absolute;
|
||||
top:0;
|
||||
bottom:0;
|
||||
left:-2rem;
|
||||
width:2rem;
|
||||
}
|
||||
}
|
||||
> .item {
|
||||
padding: 10rem 15rem 10rem 10rem;
|
||||
position:relative;
|
||||
cursor: pointer;
|
||||
i {
|
||||
margin-right:5rem;
|
||||
width: 15rem;
|
||||
text-align: center;
|
||||
}
|
||||
&:hover, &:focus {
|
||||
> .context-menu {
|
||||
pointer-events: auto;
|
||||
opacity: 1;
|
||||
}
|
||||
background:$color-raised;
|
||||
}
|
||||
&.has-sub:before {
|
||||
content:"\f105";
|
||||
display: block;
|
||||
font-family: FontAwseome;
|
||||
float:right;
|
||||
margin-top: 1rem;
|
||||
margin-right:-10rem;
|
||||
padding-left: 10rem;
|
||||
font-size:17rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ui-resizable-handle {
|
||||
position: absolute;
|
||||
z-index: 1000000;
|
||||
&.ui-resizable-se {
|
||||
bottom: 5rem;
|
||||
right: 5rem;
|
||||
width:15rem;
|
||||
height:15rem;
|
||||
border-right: 1rem solid $color-accent;
|
||||
border-bottom: 1rem solid $color-accent;
|
||||
cursor: se-resize;
|
||||
}
|
||||
&.ui-resizable-e {
|
||||
top: 50%;
|
||||
margin-top:-7.5rem;
|
||||
right: 5rem;
|
||||
width:15rem;
|
||||
height:15rem;
|
||||
border-right: 1rem solid $color-accent;
|
||||
cursor: e-resize;
|
||||
}
|
||||
&.ui-resizable-s {
|
||||
bottom: 5rem;
|
||||
left: 50%;
|
||||
margin-left:-7.5rem;
|
||||
width:15rem;
|
||||
height:15rem;
|
||||
border-bottom: 1rem solid $color-accent;
|
||||
cursor: s-resize;
|
||||
}
|
||||
}
|
||||
|
||||
.ui-helper {
|
||||
border: 1rem dashed $color-accent;
|
||||
background: rgba($color-accent,.25);
|
||||
min-width:30rem!important;
|
||||
min-height:30rem!important;
|
||||
z-index: 12!important;
|
||||
opacity: 1!important;
|
||||
}
|
||||
.ui-draggable-handle {
|
||||
position: absolute;
|
||||
position: absolute;
|
||||
top: 5rem;
|
||||
left: 5rem;
|
||||
right: 5rem;
|
||||
z-index: 100000;
|
||||
cursor: -webkit-grab;
|
||||
height:25rem;
|
||||
border:1rem solid $color-accent;
|
||||
border-radius: 3rem;
|
||||
&:active {
|
||||
cursor:-webkit-grabbing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
a {
|
||||
|
|
@ -518,7 +629,7 @@ a {
|
|||
padding:10%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background:rgba($color-text,.5);
|
||||
background:rgba($color-bg,.5);
|
||||
z-index:1000000;
|
||||
.popup-title {
|
||||
position: relative;
|
||||
|
|
@ -538,7 +649,7 @@ a {
|
|||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
background:$color-fg;
|
||||
width:100%;
|
||||
width:auto;
|
||||
max-width:600rem;
|
||||
margin:0 auto;
|
||||
position: relative;
|
||||
|
|
@ -548,7 +659,7 @@ a {
|
|||
height:100%;
|
||||
width:100%;
|
||||
padding:10rem;
|
||||
overflow-y:scroll;
|
||||
overflow-y:auto;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
|
|
@ -760,61 +871,6 @@ a {
|
|||
}
|
||||
}
|
||||
|
||||
.ui-resizable-handle {
|
||||
position: absolute;
|
||||
z-index: 1000000;
|
||||
&.ui-resizable-se {
|
||||
bottom: 5rem;
|
||||
right: 5rem;
|
||||
width:15rem;
|
||||
height:15rem;
|
||||
border-right: 1rem solid $color-accent;
|
||||
border-bottom: 1rem solid $color-accent;
|
||||
cursor: se-resize;
|
||||
}
|
||||
&.ui-resizable-e {
|
||||
top: 50%;
|
||||
margin-top:-7.5rem;
|
||||
right: 5rem;
|
||||
width:15rem;
|
||||
height:15rem;
|
||||
border-right: 1rem solid $color-accent;
|
||||
cursor: e-resize;
|
||||
}
|
||||
&.ui-resizable-s {
|
||||
bottom: 5rem;
|
||||
left: 50%;
|
||||
margin-left:-7.5rem;
|
||||
width:15rem;
|
||||
height:15rem;
|
||||
border-bottom: 1rem solid $color-accent;
|
||||
cursor: s-resize;
|
||||
}
|
||||
}
|
||||
|
||||
.ui-helper {
|
||||
border: 1rem dashed $color-accent;
|
||||
background: rgba($color-accent,.25);
|
||||
min-width:30rem!important;
|
||||
min-height:30rem!important;
|
||||
z-index: 12!important;
|
||||
opacity: 1!important;
|
||||
}
|
||||
.ui-draggable-handle {
|
||||
position: absolute;
|
||||
position: absolute;
|
||||
top: 5rem;
|
||||
left: 5rem;
|
||||
right:5rem;
|
||||
z-index: 100000;
|
||||
cursor: -webkit-grab;
|
||||
height:25rem;
|
||||
border:1rem solid $color-accent;
|
||||
&:active {
|
||||
cursor:-webkit-grabbing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* STRIP (contains any widgets) */
|
||||
|
||||
|
|
|
|||
|
|
@ -982,8 +982,8 @@
|
|||
"css": ""
|
||||
}
|
||||
],
|
||||
"label": "Strips",
|
||||
},
|
||||
"label": "Strips"
|
||||
},
|
||||
{
|
||||
"widgets": [
|
||||
{
|
||||
|
|
@ -1305,8 +1305,8 @@
|
|||
"css": ""
|
||||
}
|
||||
],
|
||||
"label": "Pads",
|
||||
},
|
||||
"label": "Pads"
|
||||
},
|
||||
{
|
||||
"label": "Multiple tabs",
|
||||
"tabs": [
|
||||
|
|
@ -1408,7 +1408,8 @@
|
|||
],
|
||||
"tabs": [],
|
||||
"id": "panel_1",
|
||||
"label": "panel_1"
|
||||
"label": "panel_1",
|
||||
"stretch": false
|
||||
},
|
||||
{
|
||||
"type": "panel",
|
||||
|
|
@ -1576,10 +1577,14 @@
|
|||
"pan": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "Unnamed"
|
||||
}
|
||||
],
|
||||
"id": "panel_2",
|
||||
"label": "panel_2"
|
||||
"label": "panel_2",
|
||||
"stretch": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue