🔥 removed jquery everywhere except from editor
This commit is contained in:
parent
983555c33c
commit
cbafb4e32f
65 changed files with 766 additions and 534 deletions
|
|
@ -15,7 +15,6 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<div id="lobby"></div>
|
||||
<div id="container"></div>
|
||||
<div id="sidepanel"></div>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,23 @@
|
|||
var DomParserFragment = document.createRange()
|
||||
DomParserFragment.selectNode(document.body)
|
||||
var DomParserFragment,
|
||||
readyCallbacks = []
|
||||
|
||||
module.exports = {
|
||||
|
||||
init: function() {
|
||||
|
||||
DomParserFragment = document.createRange()
|
||||
DomParserFragment.selectNode(document.body)
|
||||
|
||||
for (var i in readyCallbacks) {
|
||||
readyCallbacks[i]()
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
ready: function(callback) {
|
||||
readyCallbacks.push(callback)
|
||||
},
|
||||
|
||||
dispatchEvent: function(element, name, data) {
|
||||
|
||||
var event = new CustomEvent(name, {
|
||||
|
|
@ -32,6 +47,8 @@ module.exports = {
|
|||
var context = b ? a : document,
|
||||
selector = b || a
|
||||
|
||||
if (selector.indexOf('>') == 0) selector = ':scope ' + selector
|
||||
|
||||
var nodes = context.querySelectorAll(selector)
|
||||
return NodeList.prototype.forEach ? nodes : [...nodes]
|
||||
|
||||
|
|
@ -45,8 +62,17 @@ module.exports = {
|
|||
|
||||
each: function(context, selector, callback) {
|
||||
|
||||
return module.exports.get(context, selector).forEach(callback)
|
||||
var nodes = module.exports.get(context, selector)
|
||||
|
||||
nodes.forEach(callback)
|
||||
|
||||
return nodes
|
||||
|
||||
},
|
||||
|
||||
index: function(element) {
|
||||
var parent = element.parentNode
|
||||
return parent ? Array.prototype.indexOf.call(parent.children, element) : -1
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ class ContextMenu {
|
|||
constructor(){
|
||||
|
||||
this.menu = null
|
||||
this.event = 'fake-click.editor'
|
||||
this.event = 'fake-click'
|
||||
this.root = 'body'
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
var editObject = function(){editObject = require('./edit-objects').editObject; editObject(...arguments)},
|
||||
purgeStores = require('./purge'),
|
||||
{iconify} = require('../utils'),
|
||||
{iconify} = require('../ui/utils'),
|
||||
widgetManager = require('../managers/widgets'),
|
||||
resize = require('../events/resize'),
|
||||
stateManager = require('../managers/state'),
|
||||
parser = require('../parser')
|
||||
|
||||
var updateWidget = function(widget, options = {}) {
|
||||
|
||||
// save state
|
||||
var scroll = $('#sidepanel').scrollTop(),
|
||||
var sidepanel = DOM.get('#sidepanel')[0],
|
||||
scroll = sidepanel.scrollTop,
|
||||
oldWidgets = widget.childrenHashes.concat(widget.hash),
|
||||
wScroll = {}
|
||||
|
||||
|
|
@ -32,13 +34,13 @@ var updateWidget = function(widget, options = {}) {
|
|||
// widget
|
||||
var newWidget = parser.parse([widget.props], widget.parentNode, widget.parent)
|
||||
|
||||
widget.container.replaceWith(newWidget.container)
|
||||
widget.container.parentNode.replaceChild(newWidget.container, widget.container)
|
||||
|
||||
if (newWidget.props.type == 'tab') newWidget.parent.trigger('tab-created', [{widget: widget}])
|
||||
|
||||
$('.editor-root').attr('data-widget', $('.root-container').attr('data-widget'))
|
||||
DOM.get('.editor-root')[0].setAttribute('data-widget', DOM.get('.root-container')[0].getAttribute('data-widget'))
|
||||
|
||||
newWidget.container.trigger('resize')
|
||||
resize.check(newWidget.container)
|
||||
|
||||
|
||||
// restore state
|
||||
|
|
@ -56,7 +58,7 @@ var updateWidget = function(widget, options = {}) {
|
|||
editObject(newWidget, {refresh: true})
|
||||
}
|
||||
|
||||
$('#sidepanel').scrollTop(scroll)
|
||||
sidepanel.scrollTop = scroll
|
||||
|
||||
|
||||
// return updated node
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var updateWidget = require('./data-workers').updateWidget,
|
||||
var {updateWidget} = require('./data-workers'),
|
||||
{widgets, categories} = require('../widgets/'),
|
||||
{icon} = require('../utils'),
|
||||
{icon} = require('../ui/utils'),
|
||||
defaults = {}
|
||||
|
||||
for (var k in widgets) {
|
||||
|
|
@ -19,7 +19,7 @@ var editClean = function(){
|
|||
|
||||
var editObject = function(widget, options = {}){
|
||||
|
||||
var container = widget.container,
|
||||
var container = $(widget.container),
|
||||
data = widget.props
|
||||
|
||||
if (!options.refresh && (container.hasClass('editing'))) return
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var {updateWidget, incrementWidget} = require('./data-workers'),
|
||||
{editObject, editClean} = require('./edit-objects'),
|
||||
createPopup = require('../utils').createPopup,
|
||||
Popup = require('../ui/popup'),
|
||||
{widgets, categories} = require('../widgets/'),
|
||||
widgetManager = require('../managers/widgets'),
|
||||
ContextMenu = require('./context-menu')
|
||||
|
|
@ -20,7 +20,7 @@ var handleClick = function(event) {
|
|||
if (!widget) return
|
||||
|
||||
var container = widget.container,
|
||||
index = container.index(),
|
||||
index = DOM.index(container),
|
||||
data = widget.props,
|
||||
type = widget.props.type == 'tab' ? 'tab' : 'widget'
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ var handleClick = function(event) {
|
|||
|
||||
if (event.type!='fake-right-click') return
|
||||
|
||||
if (container.hasClass('root-container')) {
|
||||
if (container.classList.contains('root-container')) {
|
||||
menu.open(eventData,{
|
||||
'<i class="fa fa-plus"></i> Add tab': function(){
|
||||
data.tabs.push({})
|
||||
|
|
@ -64,7 +64,7 @@ var handleClick = function(event) {
|
|||
var newData = incrementWidget(JSON.parse(CLIPBOARD))
|
||||
|
||||
|
||||
if (!$(eventData.target).hasClass('tablink')) {
|
||||
if (!eventData.target.classList.contains('tablink')) {
|
||||
newData.top = clickY
|
||||
newData.left= clickX
|
||||
} else {
|
||||
|
|
@ -78,7 +78,7 @@ var handleClick = function(event) {
|
|||
'<i class="fa fa-clone"></i> Clone':function(){
|
||||
data.widgets = data.widgets || []
|
||||
var newData = JSON.parse(CLIPBOARD)
|
||||
if (!$(eventData.target).hasClass('tablink')) {
|
||||
if (!eventData.target.classList.contains('tablink')) {
|
||||
newData.top = clickY
|
||||
newData.left= clickX
|
||||
} else {
|
||||
|
|
@ -99,7 +99,7 @@ var handleClick = function(event) {
|
|||
actions['<i class="fa fa-plus"></i> Add widget'][category][wtype] = function(){
|
||||
data.widgets = data.widgets || []
|
||||
var newData = {type:wtype}
|
||||
if (!$(eventData.target).hasClass('tablink')) {
|
||||
if (!eventData.target.classList.contains('tablink')) {
|
||||
newData.top = clickY
|
||||
newData.left= clickX
|
||||
}
|
||||
|
|
@ -122,13 +122,19 @@ var handleClick = function(event) {
|
|||
}
|
||||
|
||||
actions['<i class="fa fa-trash"></i> Delete'] = function(){
|
||||
var popup = createPopup('Are you sure ?',`
|
||||
<div class="actions">
|
||||
<a class="btn warning confirm-delete">DELETE</a>
|
||||
<a class="btn cancel-delete">CANCEL</a>
|
||||
</div>
|
||||
`)
|
||||
$('.confirm-delete').click(function(){
|
||||
var popup = new Popup({
|
||||
title: 'Are you sure ?',
|
||||
content:`
|
||||
<div class="actions">
|
||||
<a class="btn warning confirm-delete">DELETE</a>
|
||||
<a class="btn cancel-delete">CANCEL</a>
|
||||
</div>`,
|
||||
closable: false,
|
||||
escKey: true,
|
||||
enterKey: function(){DOM.get(this.html, '.confirm-delete')[0].click()}
|
||||
})
|
||||
|
||||
DOM.get(popup.html, '.confirm-delete')[0].addEventListener('click', function(){
|
||||
popup.close()
|
||||
|
||||
if (widget.props.type != 'tab') {
|
||||
|
|
@ -139,13 +145,10 @@ var handleClick = function(event) {
|
|||
|
||||
updateWidget(widget.parent)
|
||||
})
|
||||
$('.cancel-delete').click(function(){
|
||||
|
||||
DOM.get(popup.html, '.cancel-delete')[0].addEventListener('click', function(){
|
||||
popup.close()
|
||||
})
|
||||
$(document).on('keydown.popup', function(e){
|
||||
if (e.keyCode==13) $('.confirm-delete').click()
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,18 +73,9 @@ function pointerUpHandler(event) {
|
|||
}
|
||||
|
||||
|
||||
function triggerWidgetEvent(target, name, event) {
|
||||
if (target !== null && target._widget) {
|
||||
target._widget.trigger(name, [event])
|
||||
} else if (target !== null) {
|
||||
triggerWidgetEvent(target.closest('.drag-event'), name, event)
|
||||
}
|
||||
}
|
||||
// Move / Up Filter
|
||||
|
||||
|
||||
// Move / Up handlers
|
||||
|
||||
function capturedMoveHandler(event) {
|
||||
function pointerMoveFilter(event) {
|
||||
|
||||
if (targets[event.pointerId] !== undefined) {
|
||||
pointerMoveHandler.call(targets[event.pointerId], event)
|
||||
|
|
@ -92,7 +83,7 @@ function capturedMoveHandler(event) {
|
|||
|
||||
}
|
||||
|
||||
function capturedUpHandler(event) {
|
||||
function pointerUpFilter(event) {
|
||||
|
||||
if (targets[event.pointerId] !== undefined) {
|
||||
pointerUpHandler.call(targets[event.pointerId], event)
|
||||
|
|
@ -114,21 +105,26 @@ function mouseMultiWrapper(event) {
|
|||
mouseDownHandler(event)
|
||||
}
|
||||
|
||||
document.addEventListener('mousemove', (event)=>{
|
||||
function mouseMoveCapture(event) {
|
||||
event.pointerId = 'mouse'
|
||||
event.inertia = event.ctrlKey ? 10 : 1
|
||||
capturedMoveHandler(event)
|
||||
}, true)
|
||||
pointerMoveFilter(event)
|
||||
}
|
||||
|
||||
document.addEventListener('mouseup', (event)=>{
|
||||
function mouseUpCapture(event){
|
||||
if ((event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents) || event.button == 2) return
|
||||
event.pointerId = 'mouse'
|
||||
capturedUpHandler(event)
|
||||
}, true)
|
||||
pointerUpFilter(event)
|
||||
}
|
||||
|
||||
|
||||
// Touch events wrappers
|
||||
|
||||
function touchMultiWrapper(event) {
|
||||
event.multitouch = true
|
||||
touchDownHandler(event)
|
||||
}
|
||||
|
||||
function touchDownHandler(event) {
|
||||
for (var i in event.changedTouches) {
|
||||
if (isNaN(i) || !event.changedTouches[i]) continue
|
||||
|
|
@ -144,12 +140,7 @@ function touchDownHandler(event) {
|
|||
}
|
||||
}
|
||||
|
||||
function touchMultiWrapper(event) {
|
||||
event.multitouch = true
|
||||
touchDownHandler(event)
|
||||
}
|
||||
|
||||
document.addEventListener('touchmove', (event)=>{
|
||||
function touchMoveCapture(event) {
|
||||
for (var i in event.changedTouches) {
|
||||
if (isNaN(i) || !event.changedTouches[i]) continue
|
||||
var touchEvent = event.changedTouches[i]
|
||||
|
|
@ -166,18 +157,39 @@ document.addEventListener('touchmove', (event)=>{
|
|||
}
|
||||
|
||||
touchEvent.pointerId = touchEvent.identifier
|
||||
capturedMoveHandler(touchEvent)
|
||||
pointerMoveFilter(touchEvent)
|
||||
}
|
||||
}, true)
|
||||
}
|
||||
|
||||
DOM.addEventListener(document, 'touchend touchcancel', (event)=>{
|
||||
function touchUpCapture(event) {
|
||||
for (var i in event.changedTouches) {
|
||||
if (isNaN(i) || !event.changedTouches[i]) continue
|
||||
var touchEvent = event.changedTouches[i]
|
||||
touchEvent.pointerId = touchEvent.identifier
|
||||
capturedUpHandler(touchEvent)
|
||||
pointerUpFilter(touchEvent)
|
||||
}
|
||||
}, true)
|
||||
}
|
||||
|
||||
// Callback trigger
|
||||
|
||||
function triggerWidgetEvent(target, name, event) {
|
||||
if (target !== null && target._drag_widget) {
|
||||
target._drag_widget.trigger(name, [event])
|
||||
} else if (target !== null) {
|
||||
triggerWidgetEvent(target.closest('.drag-event'), name, event)
|
||||
}
|
||||
}
|
||||
|
||||
// init
|
||||
|
||||
DOM.ready(()=>{
|
||||
|
||||
document.addEventListener('mousemove', mouseMoveCapture, true)
|
||||
document.addEventListener('mouseup', mouseUpCapture, true)
|
||||
document.addEventListener('touchmove', touchMoveCapture, true)
|
||||
DOM.addEventListener(document, 'touchend touchcancel', touchUpCapture, true)
|
||||
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
|
||||
|
|
@ -194,7 +206,7 @@ module.exports = {
|
|||
|
||||
var {element, multitouch} = options
|
||||
|
||||
element._widget = this
|
||||
element._drag_widget = this
|
||||
element.style.touchAction = 'none'
|
||||
element.classList.add('drag-event')
|
||||
|
||||
|
|
@ -219,15 +231,15 @@ module.exports = {
|
|||
return
|
||||
}
|
||||
|
||||
element._widget = this
|
||||
delete element._drag_widget
|
||||
element.style.touchAction = ''
|
||||
element.classList.remove('drag-event')
|
||||
|
||||
if (multitouch) {
|
||||
element.removeEventListener('touchstart', touchMultiWrapper)
|
||||
element.removeEventListener('touchstart', touchMultiWrapper, supportsPassive ? { passive: true } : false)
|
||||
element.removeEventListener('mousedown', mouseMultiWrapper)
|
||||
} else {
|
||||
element.removeEventListener('touchstart', touchDownHandler)
|
||||
element.removeEventListener('touchstart', touchDownHandler, supportsPassive ? { passive: true } : false)
|
||||
element.removeEventListener('mousedown', mouseDownHandler)
|
||||
}
|
||||
|
||||
|
|
@ -246,8 +258,8 @@ module.exports = {
|
|||
|
||||
element.addEventListener('disableTraversingGestures', ()=>{
|
||||
|
||||
element.removeEventListener('mousedown', makeEventTraversing)
|
||||
element.removeEventListener('touchstart', makeEventTraversing)
|
||||
element.removeEventListener('mousedown', makeEventTraversing, supportsPassive ? { passive: true, capture:true } : true)
|
||||
element.removeEventListener('touchstart', makeEventTraversing, supportsPassive ? { passive: true, capture:true } : true)
|
||||
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ var WolfyEventEmitter = require('wolfy87-eventemitter'),
|
|||
customEvents = {}
|
||||
|
||||
customEvents['draginit'] = customEvents['drag'] = customEvents['dragend'] = require('./drag')
|
||||
customEvents['resize'] = require('./resize')
|
||||
|
||||
module.exports = class EventEmitter extends WolfyEventEmitter {
|
||||
|
||||
|
|
|
|||
65
src/browser/js/app/events/resize.js
Normal file
65
src/browser/js/app/events/resize.js
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
var elements = []
|
||||
|
||||
function checkResizes(context){
|
||||
// Iterate over all elements to which the 'resize' event is bound.
|
||||
var resizedElems = [],
|
||||
cachedStyles = []
|
||||
for (var i = elements.length - 1; i >= 0; i--) {
|
||||
var elem = elements[i]
|
||||
|
||||
if (!context.contains(elem)) continue
|
||||
|
||||
var style = window.getComputedStyle(elem),
|
||||
width = parseInt(style['width']) - parseInt(style['padding-left']) - parseInt(style['padding-right']),
|
||||
height = parseInt(style['height']) - parseInt(style['padding-top']) - parseInt(style['padding-bottom'])
|
||||
|
||||
if (!width) continue
|
||||
|
||||
// If element size has changed since the last time, update the element
|
||||
// data store and trigger the 'resize' event.
|
||||
if ( width != elem.resizedataw || height != elem.resizedatah ) {
|
||||
elem.resizedataw = width
|
||||
elem.resizedatah = height
|
||||
resizedElems.push(elem)
|
||||
cachedStyles.push(style)
|
||||
}
|
||||
}
|
||||
for (var i = resizedElems.length - 1; i >= 0; i--) {
|
||||
resizedElems[i]._resize_widget.trigger('resize', [{
|
||||
width: resizedElems[i].resizedataw,
|
||||
height: resizedElems[i].resizedatah,
|
||||
style:cachedStyles[i],
|
||||
stopPropagation: true
|
||||
}])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
window.addEventListener('resize', ()=>{checkResizes(document)})
|
||||
|
||||
module.exports = {
|
||||
|
||||
setup: function(options) {
|
||||
|
||||
if (!options) return
|
||||
if (elements.indexOf(options.element) == -1) {
|
||||
elements.push(options.element)
|
||||
options.element._resize_widget = this
|
||||
}
|
||||
|
||||
},
|
||||
teardown: function() {
|
||||
|
||||
if (!options) return
|
||||
elements.push(options.element)
|
||||
|
||||
if (elements.indexOf(options.element) == -1) {
|
||||
elements.splice(elements.indexOf(options.element), 1)
|
||||
delete options.element._resize_widget
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
check: checkResizes
|
||||
|
||||
}
|
||||
|
|
@ -33,6 +33,5 @@ window.$ = require('jquery/dist/jquery.slim.min.js')
|
|||
require('./events/click')
|
||||
|
||||
require('../libs/jquery.ui')
|
||||
require('../libs/jquery.resize')
|
||||
|
||||
require('cardinal-spline-js/curve.js')
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
var utils = require('../utils'),
|
||||
icon = utils.icon,
|
||||
var utils = require('../ui/utils'),
|
||||
osc = require('../osc'),
|
||||
session = require('../managers/session'),
|
||||
widgetManager = require('../managers/widgets'),
|
||||
state = require('../managers/state'),
|
||||
editor = require('../editor/')
|
||||
|
||||
|
|
@ -60,16 +60,17 @@ var callbacks = module.exports = {
|
|||
},
|
||||
|
||||
error: function(data){
|
||||
utils.createPopup(icon('warning') + ' Error', data, true)
|
||||
utils.createPopup(utils.icon('warning') + ' Error', data, true)
|
||||
},
|
||||
|
||||
reloadCss: function(){
|
||||
var queryString = '?reload=' + new Date().getTime()
|
||||
$('link[rel="stylesheet"][hot-reload]').each(function () {
|
||||
this.href = this.href.replace(/\?.*|$/, queryString)
|
||||
DOM.each(document, 'link[rel="stylesheet"][hot-reload]', (el)=>{
|
||||
el.href = el.href.replace(/\?.*|$/, queryString)
|
||||
})
|
||||
|
||||
setTimeout(()=>{
|
||||
$('canvas').trigger('resize',[0,0,true])
|
||||
widgetManager.getWidgetById('root')[0].reCreateWidget()
|
||||
},100)
|
||||
|
||||
GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue("--grid-width")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ var ipc = require('../ipc/'),
|
|||
parser = require('../parser'),
|
||||
state = require('./state'),
|
||||
editor = require('../editor/'),
|
||||
{loading, createPopup, icon} = require('../utils'),
|
||||
Popup = require('../ui/popup'),
|
||||
lobby = require('../ui/lobby'),
|
||||
{loading, icon} = require('../ui/utils'),
|
||||
{saveAs} = require('file-saver')
|
||||
|
||||
|
||||
|
|
@ -16,9 +18,14 @@ var SessionManager = class SessionManager {
|
|||
|
||||
load(session, callback) {
|
||||
|
||||
$('#lobby').hide()
|
||||
$('#container').empty()
|
||||
var p = loading('Loading session file...')
|
||||
var container = DOM.get('#container')[0]
|
||||
|
||||
container.classList.remove('show')
|
||||
container.innerHTML = ''
|
||||
|
||||
lobby.close()
|
||||
|
||||
var loader = loading('Loading session file...')
|
||||
|
||||
setTimeout(()=>{
|
||||
try {
|
||||
|
|
@ -32,27 +39,25 @@ var SessionManager = class SessionManager {
|
|||
throw 'Malformed session file'
|
||||
}
|
||||
|
||||
parser.parse(this.session,$('#container'))
|
||||
parser.parse(this.session, DOM.get('#container')[0])
|
||||
} catch (err) {
|
||||
p.close()
|
||||
$('#lobby').show()
|
||||
createPopup(icon('warning')+' Parsing error', err,true)
|
||||
loader.close()
|
||||
lobby.open()
|
||||
new Popup({title:icon('warning')+' Parsing error', content: err, closable:true})
|
||||
throw err
|
||||
}
|
||||
|
||||
state.set(state.get(), false)
|
||||
$('#lobby').remove()
|
||||
editor.disable()
|
||||
$(window).resize()
|
||||
DOM.dispatchEvent(window, 'resize')
|
||||
|
||||
setTimeout(function(){
|
||||
p.close()
|
||||
if (!callback) return
|
||||
setTimeout(function(){
|
||||
callback()
|
||||
},25)
|
||||
},25)
|
||||
},25)
|
||||
setTimeout(()=>{
|
||||
loader.close()
|
||||
container.classList.add('show')
|
||||
if (callback) callback()
|
||||
}, 25)
|
||||
|
||||
}, 25)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -69,82 +74,65 @@ var SessionManager = class SessionManager {
|
|||
|
||||
list(data) {
|
||||
|
||||
var lobby = $(`
|
||||
<div class="main">
|
||||
<div class="header">
|
||||
${PACKAGE.productName}
|
||||
</div>
|
||||
<div class="list"></div>
|
||||
<div class="footer"></div>
|
||||
</div>`),
|
||||
list = lobby.find('.list'),
|
||||
footer = lobby.find('.footer'),
|
||||
self = this
|
||||
|
||||
for (let 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)
|
||||
}
|
||||
|
||||
if (!READ_ONLY) {
|
||||
}
|
||||
list.append(`
|
||||
lobby.list.appendChild(DOM.create(`
|
||||
<a href="#" tabIndex="0" class="btn load" data-session="${data[i]}">
|
||||
${file} <em style="opacity:0.45">(${path})</em>
|
||||
${READ_ONLY? '' : '<span>'+icon('times')+'</span>'}
|
||||
</a>
|
||||
`)
|
||||
`))
|
||||
|
||||
}
|
||||
|
||||
lobby.find('.load').click(function(e){
|
||||
lobby.list.addEventListener('click', function(e){
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
ipc.send('sessionOpen',{path:$(this).data('session')})
|
||||
}).on('mousedown touchstart', function(e){
|
||||
if (e.type == 'mousedown') e.preventDefault()
|
||||
$(this).blur()
|
||||
e.target.blur()
|
||||
if (e.target.hasAttribute('data-session')) {
|
||||
ipc.send('sessionOpen',{path:e.target.getAttribute('data-session')})
|
||||
} else if (!READ_ONLY && e.target.tagName == 'span') {
|
||||
ipc.send('sessionRemoveFromHistory',e.target.parentNode.getAttribute('data-session'))
|
||||
lobby.list.removeChild(e.target.parentNode)
|
||||
}
|
||||
})
|
||||
|
||||
if (!READ_ONLY) {
|
||||
|
||||
lobby.find('a span').click(function(e){
|
||||
var brw = lobby.footer.appendChild(DOM.create('<a href="#" tabindex="0" class="btn browse">'+icon('folder-open')+' Browse</a>'))
|
||||
var nws = lobby.footer.appendChild(DOM.create('<a href="#" tabindex="0" class="btn new">'+icon('file')+' New</a>'))
|
||||
|
||||
brw.addEventListener('click', (e)=>{
|
||||
e.stopPropagation()
|
||||
ipc.send('sessionRemoveFromHistory',$(this).parent().data('session'))
|
||||
$(this).parents('a').remove()
|
||||
this.browse()
|
||||
})
|
||||
brw.addEventListener('mousedown touchstart', function(e){
|
||||
if (e.type == 'mousedown') e.preventDefault()
|
||||
e.target.blur()
|
||||
})
|
||||
|
||||
footer.append('<a href="#" tabindex="0" class="btn browse">'+icon('folder-open')+' Browse</a>')
|
||||
footer.append('<a href="#" tabindex="0" class="btn new">'+icon('file')+' New</a>')
|
||||
|
||||
lobby.find('.browse').click((e)=>{
|
||||
nws.addEventListener('click', (e)=>{
|
||||
e.stopPropagation()
|
||||
self.browse()
|
||||
}).on('mousedown touchstart', function(e){
|
||||
if (e.type == 'mousedown') e.preventDefault()
|
||||
$(this).blur()
|
||||
this.create()
|
||||
})
|
||||
lobby.find('.new').click(function(e){
|
||||
e.stopPropagation()
|
||||
self.create()
|
||||
}).on('mousedown touchstart', function(e){
|
||||
nws.addEventListener('mousedown touchstart', (e)=>{
|
||||
if (e.type == 'mousedown') e.preventDefault()
|
||||
$(this).blur()
|
||||
e.target.blur()
|
||||
})
|
||||
}
|
||||
|
||||
$('#lobby').append(lobby)
|
||||
|
||||
setTimeout(()=>{
|
||||
lobby.addClass('loaded')
|
||||
})
|
||||
lobby.open()
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -158,9 +146,10 @@ var SessionManager = class SessionManager {
|
|||
|
||||
browse() {
|
||||
|
||||
var prompt = $('<input type="file" accept=".js, .json"/>')
|
||||
var prompt = DOM.create('<input type="file" accept=".js, .json"/>')
|
||||
|
||||
prompt.click()
|
||||
prompt.on('change',function(e){
|
||||
prompt.addEventListener('change',function(e){
|
||||
var reader = new FileReader(),
|
||||
file = e.target.files[0]
|
||||
|
||||
|
|
@ -177,9 +166,8 @@ var SessionManager = class SessionManager {
|
|||
|
||||
create() {
|
||||
this.load([{}],function(){
|
||||
$('.enable-editor').click()
|
||||
$('#open-toggle').trigger('fake-click')
|
||||
$('.editor-root').trigger('fake-click')
|
||||
require('../ui/sidepanel').open()
|
||||
editor.enable()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,11 +72,10 @@ var StateManager = class StateManager {
|
|||
|
||||
load() {
|
||||
|
||||
var prompt = $('<input type="file" accept=".state"/>')
|
||||
var prompt = DOM.create('<input type="file" accept=".state"/>')
|
||||
|
||||
prompt.click()
|
||||
|
||||
prompt.on('change',(e)=>{
|
||||
prompt.addEventListener('change',function(e){
|
||||
|
||||
var reader = new FileReader()
|
||||
|
||||
|
|
|
|||
|
|
@ -245,7 +245,11 @@ var WidgetManager = class WidgetManager extends EventEmitter {
|
|||
|
||||
getWidgetByElement(e, filter = '') {
|
||||
var element = (e instanceof $ ? e[0] : e).closest('[data-widget]' + filter)
|
||||
if (element) return this.widgets[element.getAttribute('data-widget')]
|
||||
if (element) {
|
||||
return element._widget_instance ?
|
||||
element._widget_instance :
|
||||
this.widgets[element.getAttribute('data-widget')]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var widgetManager = require('./managers/widgets'),
|
||||
stateManager = require('./managers/state'),
|
||||
{iconify} = require('./utils')
|
||||
{iconify} = require('./ui/utils')
|
||||
|
||||
var Parser = class Parser {
|
||||
|
||||
|
|
@ -68,20 +68,20 @@ var Parser = class Parser {
|
|||
}
|
||||
|
||||
// create container
|
||||
var widgetContainer = $(`
|
||||
var widgetContainer = DOM.create(`
|
||||
<div class="widget ${props.type}-container">
|
||||
<div class="label"></div>
|
||||
<div class="label"></div>
|
||||
</div>
|
||||
`)
|
||||
`)
|
||||
|
||||
// create widget
|
||||
var widgetInner = new this.widgets[props.type]({props:props, container:widgetContainer, parent:parentWidget, parentNode:parentNode})
|
||||
|
||||
widgetContainer[0].appendChild(widgetInner.widget[0])
|
||||
widgetContainer.appendChild(widgetInner.widget)
|
||||
|
||||
widgetManager.addWidget(widgetInner)
|
||||
|
||||
widgetContainer[0].setAttribute('data-widget', widgetInner.hash)
|
||||
widgetContainer.setAttribute('data-widget', widgetInner.hash)
|
||||
|
||||
widgetInner.created()
|
||||
|
||||
|
|
@ -107,18 +107,18 @@ var Parser = class Parser {
|
|||
styleL = widgetInner.getProp('left') && widgetInner.getProp('left') != 'auto'|| widgetInner.getProp('left') == 0 ?`left: ${geometry.left};` : '',
|
||||
styleT = widgetInner.getProp('top') && widgetInner.getProp('top') != 'auto'|| widgetInner.getProp('top') == 0 ? `top: ${geometry.top};` : ''
|
||||
|
||||
if (styleL.length || styleT.length) widgetContainer.addClass('absolute-position')
|
||||
if (styleL.length || styleT.length) widgetContainer.classList.add('absolute-position')
|
||||
|
||||
// Hide label if false
|
||||
if (widgetInner.getProp('label')===false) {
|
||||
widgetContainer.addClass('nolabel')
|
||||
widgetContainer.classList.add('nolabel')
|
||||
} else {
|
||||
// Generate label, iconify if starting with "icon:"
|
||||
var label = widgetInner.getProp('label') == 'auto'?
|
||||
widgetInner.getProp('id'):
|
||||
iconify(widgetInner.getProp('label'))
|
||||
|
||||
widgetContainer.find('> .label').html(label)
|
||||
DOM.get(widgetContainer, '> .label')[0].innerHTML = label
|
||||
}
|
||||
|
||||
// parse css
|
||||
|
|
@ -137,17 +137,17 @@ var Parser = class Parser {
|
|||
})
|
||||
|
||||
// apply styles
|
||||
widgetContainer[0].setAttribute('style', styleW + styleH + styleL + styleT + css)
|
||||
widgetContainer.setAttribute('style', styleW + styleH + styleL + styleT + css)
|
||||
|
||||
// apply scoped css
|
||||
if (scopedCss.length) {
|
||||
widgetContainer.attr('id', 'widget-' + widgetInner.hash)
|
||||
widgetContainer.setAttribute('id', 'widget-' + widgetInner.hash)
|
||||
scopedCss = scopedCss.split('&').join('#widget-' + widgetInner.hash)
|
||||
widgetContainer.prepend(`<style>${scopedCss}</style>`)
|
||||
widgetContainer.insertBefore(DOM.create(`<style>${scopedCss}</style>`), widgetInner.widget)
|
||||
}
|
||||
|
||||
// Set custom css color variable
|
||||
if (widgetInner.getProp('color') && widgetInner.getProp('color')!='auto') widgetContainer[0].style.setProperty('--color-custom',widgetInner.getProp('color'))
|
||||
if (widgetInner.getProp('color') && widgetInner.getProp('color')!='auto') widgetContainer.style.setProperty('--color-custom',widgetInner.getProp('color'))
|
||||
|
||||
// set widget's initial state
|
||||
if (widgetInner.getProp('value') !== '' && widgetInner.setValue) {
|
||||
|
|
@ -156,7 +156,7 @@ var Parser = class Parser {
|
|||
}
|
||||
|
||||
// Append the widget to its parent
|
||||
parentNode[0].appendChild(widgetContainer[0])
|
||||
parentNode.appendChild(widgetContainer)
|
||||
}
|
||||
|
||||
// Editor needs to get the container object
|
||||
|
|
|
|||
|
|
@ -142,7 +142,9 @@ var callbacks = {
|
|||
for (let id of args) {
|
||||
let ws = widgetManager.getWidgetById(id)
|
||||
for (let w of ws) {
|
||||
$(`.tablink[data-widget="${w.hash}"]`).trigger('fake-click')
|
||||
DOM.each(document, `.tablink[data-widget="${w.hash}"]`, (el)=>{
|
||||
DOM.dispatchEvent(el, 'fake-click')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
require('./zoom')
|
||||
require('./lobby').create()
|
||||
require('./sidepanel')
|
||||
49
src/browser/js/app/ui/lobby.js
Normal file
49
src/browser/js/app/ui/lobby.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
class Lobby {
|
||||
|
||||
constructor() {
|
||||
|
||||
this.state = 0
|
||||
|
||||
}
|
||||
|
||||
create() {
|
||||
|
||||
this.html = DOM.create(`
|
||||
<div id="lobby">
|
||||
<div class="main">
|
||||
<div class="header">
|
||||
${PACKAGE.productName}
|
||||
</div>
|
||||
<div class="list"></div>
|
||||
<div class="footer"></div>
|
||||
</div>
|
||||
</div>
|
||||
`)
|
||||
|
||||
this.main = DOM.get(this.html, '.main')[0]
|
||||
this.list = DOM.get(this.html, '.list')[0]
|
||||
this.footer = DOM.get(this.html, '.footer')[0]
|
||||
|
||||
}
|
||||
|
||||
open() {
|
||||
if (this.state) return
|
||||
this.state = 1
|
||||
document.body.appendChild(this.html)
|
||||
setTimeout(()=>{
|
||||
this.main.classList.add('show')
|
||||
})
|
||||
}
|
||||
|
||||
close() {
|
||||
if (!this.state) return
|
||||
this.state = 0
|
||||
this.main.classList.remove('show')
|
||||
document.body.removeChild(this.html)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var lobby = new Lobby()
|
||||
|
||||
module.exports = lobby
|
||||
60
src/browser/js/app/ui/popup.js
Normal file
60
src/browser/js/app/ui/popup.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
var {icon} = require('./utils')
|
||||
|
||||
module.exports = class Popup {
|
||||
|
||||
constructor(options) {
|
||||
|
||||
this.closable = options.closable
|
||||
this.escKey = options.closable || options.escKey
|
||||
this.enterKey = options.enterKey
|
||||
this.content = options.content
|
||||
this.title = options.title
|
||||
|
||||
this.html = DOM.create(`
|
||||
<div class="popup show">
|
||||
<div class="popup-wrapper">
|
||||
<div class="popup-title ${this.closable? 'closable' : ''}">${this.title}${this.closable? `<span class="closer">${module.exports.icon('times')}</span>` : ''}</div>
|
||||
<div class="popup-content">
|
||||
${this.content}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`)
|
||||
|
||||
if (this.closable) {
|
||||
DOM.get(this.html, '.popup-title .closer')[0].addEventListener('fake-click', ()=>{
|
||||
this.close()
|
||||
})
|
||||
}
|
||||
|
||||
if (this.escKey) {
|
||||
this.escKeyHandler = ((e)=>{
|
||||
if (e.keyCode==27) this.close()
|
||||
}).bind(this)
|
||||
}
|
||||
|
||||
if (this.enterKey) {
|
||||
this.enterKeyHandler = ((e)=>{
|
||||
if (e.keyCode == 13) this.enterKey.call(this, e)
|
||||
}).bind(this)
|
||||
}
|
||||
|
||||
this.open()
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
close() {
|
||||
if (this.escKey) document.removeEventListener('keydown', this.escKeyHandler)
|
||||
if (this.enterKey) document.removeEventListener('keydown', this.enterKeyHandler)
|
||||
document.body.removeChild(this.html)
|
||||
}
|
||||
|
||||
open() {
|
||||
if (this.escKey) document.addEventListener('keydown', this.escKeyHandler)
|
||||
if (this.enterKey) document.addEventListener('keydown', this.enterKeyHandler)
|
||||
document.body.appendChild(this.html)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
var state = require('../managers/state'),
|
||||
session = require('../managers/session'),
|
||||
editor = require('../editor/'),
|
||||
icon = require('../utils').icon,
|
||||
{icon} = require('./utils'),
|
||||
fullscreen = require('screenfull'),
|
||||
{enableTraversingGestures, disableTraversingGestures} = require('../events/drag')
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ for (let i in sidepanelData) {
|
|||
let actionData = data.actions[j],
|
||||
element = DOM.create(`<a class="btn ${actionData.class || ''}">${actionData.title}</a>`)
|
||||
|
||||
if (actionData.action) element.addEventListener('fake-click', actionData.action)
|
||||
if (actionData.action) element.addEventListener('click', actionData.action)
|
||||
|
||||
wrapper.appendChild(element)
|
||||
}
|
||||
|
|
@ -166,13 +166,16 @@ if (fullscreen.enabled) {
|
|||
|
||||
function sidepanelOpen() {
|
||||
|
||||
DOM.get('#open-toggle, #sidepanel, #container').forEach((el)=>{
|
||||
DOM.get('#open-toggle, #sidepanel').forEach((el)=>{
|
||||
el.classList.add('sidepanel-open')
|
||||
})
|
||||
|
||||
setTimeout(function(){
|
||||
$(window).resize()
|
||||
}, 275)
|
||||
DOM.get('#container')[0].classList.add('sidepanel-open')
|
||||
setTimeout(function(){
|
||||
DOM.dispatchEvent(window, 'resize')
|
||||
}, 25)
|
||||
}, 250)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +186,7 @@ function sidepanelClose() {
|
|||
})
|
||||
|
||||
setTimeout(function(){
|
||||
$(window).resize()
|
||||
DOM.dispatchEvent(window, 'resize')
|
||||
}, 25)
|
||||
|
||||
}
|
||||
|
|
|
|||
19
src/browser/js/app/ui/utils.js
Normal file
19
src/browser/js/app/ui/utils.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
var Popup = require('./popup')
|
||||
|
||||
module.exports = {
|
||||
|
||||
loading: function(title){
|
||||
return new Popup({
|
||||
title: title,
|
||||
content: '<p><div class="spinner"></div></p>',
|
||||
closable: false
|
||||
})
|
||||
},
|
||||
icon: function(i) {
|
||||
return `<i class="fa fa-fw fa-${i}"></i>`
|
||||
},
|
||||
iconify:function(string){
|
||||
return String(string).replace(/\^[^\s]*/g,(x)=>{return module.exports.icon(x.substring(1))})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ document.addEventListener('mousewheel', function(event) {
|
|||
PXSCALE = parseFloat(d)+parseFloat(PXSCALE)
|
||||
document.documentElement.style.setProperty('font-size', PXSCALE + 'px')
|
||||
|
||||
$(window).resize()
|
||||
DOM.dispatchEvent(window, 'resize')
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -17,6 +17,6 @@ document.addEventListener('keydown', function(event){
|
|||
PXSCALE = INITIALZOOM
|
||||
document.documentElement.style.setProperty('font-size', PXSCALE + 'px')
|
||||
|
||||
$(window).resize()
|
||||
DOM.dispatchEvent(window, 'resize')
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
module.exports = {
|
||||
|
||||
createPopup: function(title,content,closable) {
|
||||
|
||||
var popup = $(`
|
||||
<div class="popup">
|
||||
<div class="popup-wrapper">
|
||||
<div class="popup-title ${closable? 'closable' : ''}">${title}${closable? `<span class="closer">${module.exports.icon('times')}</span>` : ''}</div>
|
||||
<div class="popup-content"></div>
|
||||
</div>
|
||||
</div>`),
|
||||
closer = popup.find('.popup-title .closer')
|
||||
|
||||
if (closable) {
|
||||
closer.click(function(){
|
||||
popup.close()
|
||||
})
|
||||
$(document).on('keydown.popup', function(e){
|
||||
if (e.keyCode==27) popup.close()
|
||||
})
|
||||
}
|
||||
|
||||
popup.close = function(){
|
||||
$(document).off('.popup')
|
||||
popup.remove()
|
||||
}
|
||||
|
||||
popup.find('.popup-content').append(content)
|
||||
$('body').append(popup)
|
||||
|
||||
return popup
|
||||
},
|
||||
loading: function(title){
|
||||
return module.exports.createPopup(title,'<p><div class="spinner"></div></p>', false)
|
||||
},
|
||||
icon: function(i) {
|
||||
return `<i class="fa fa-fw fa-${i}"></i>`
|
||||
},
|
||||
iconify:function(string){
|
||||
return String(string).replace(/\^[^\s]*/g,(x)=>{return module.exports.icon(x.substring(1))})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
var _widgets_base = require('../common/_widgets_base'),
|
||||
{iconify} = require('../../utils')
|
||||
{iconify} = require('../../ui/utils')
|
||||
|
||||
module.exports = class Dropdown extends _widgets_base {
|
||||
|
||||
|
|
@ -42,24 +42,24 @@ module.exports = class Dropdown extends _widgets_base {
|
|||
|
||||
super({...options, html: '<div class="select"></div>'})
|
||||
|
||||
this.select = $(`<select></select>`).appendTo(this.widget)
|
||||
this.select = this.widget.appendChild(DOM.create(`<select></select>`))
|
||||
|
||||
this.values = []
|
||||
|
||||
var i = 0
|
||||
for (var k in this.getProp('values')) {
|
||||
this.values[i] = this.getProp('values')[k]
|
||||
this.select.append(`<option value="${i}">${iconify(parseFloat(k) != k ? k : this.getProp("values")[k])}</option>`)
|
||||
this.select.innerHTML += `<option value="${i}">${iconify(parseFloat(k) != k ? k : this.getProp("values")[k])}</option>`
|
||||
i++
|
||||
}
|
||||
|
||||
this.select.change(()=>{
|
||||
this.setValue(this.values[this.select[0].selectedIndex], {sync:true, send:true, fromLocal:true})
|
||||
this.select.addEventListener('change', ()=>{
|
||||
this.setValue(this.values[this.select.selectedIndex], {sync:true, send:true, fromLocal:true})
|
||||
})
|
||||
|
||||
this.value = undefined
|
||||
this.select[0].selectedIndex = -1
|
||||
this.container.addClass('noselect')
|
||||
this.select.selectedIndex = -1
|
||||
this.container.classList.add('noselect')
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -72,12 +72,12 @@ module.exports = class Dropdown extends _widgets_base {
|
|||
if (!options.fromLocal) this.select[0].selectedIndex = i
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.changed(options)
|
||||
this.container.removeClass('noselect')
|
||||
this.container.classList.remove('noselect')
|
||||
} else {
|
||||
this.value = undefined
|
||||
this.select[0].selectedIndex = -1
|
||||
if (options.sync) this.changed(options)
|
||||
this.container.addClass('noselect')
|
||||
this.container.classList.add('noselect')
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -50,13 +50,11 @@ module.exports = class Push extends _widgets_base {
|
|||
this.on('draginit',()=>{
|
||||
if (this.active) return
|
||||
this.setValuePrivate(this.getProp('on'),{send:true,sync:true})
|
||||
}, {element: this.widget[0]})
|
||||
}, {element: this.widget})
|
||||
|
||||
this.on('dragend',()=>{
|
||||
this.setValuePrivate(this.getProp('off'),{send:true,sync:true})
|
||||
}, {element: this.widget[0]})
|
||||
|
||||
this.classHolders = this.widget.add(this.container)
|
||||
}, {element: this.widget})
|
||||
|
||||
this.value = this.getProp('off')
|
||||
|
||||
|
|
@ -76,14 +74,14 @@ module.exports = class Push extends _widgets_base {
|
|||
|
||||
if (typeof v == 'object' && v !== null) v = v.value
|
||||
if (v===this.getProp('on') || (this.getProp('on') != null && v === this.getProp('on').value && v !== undefined)) {
|
||||
this.widget.addClass('active')
|
||||
this.widget.classList.add('active')
|
||||
this.active = 1
|
||||
this.lastChanged = 'active'
|
||||
this.updateValue()
|
||||
if (options.send) this.sendValue(v)
|
||||
if (options.sync) this.changed(options)
|
||||
} else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) {
|
||||
this.widget.removeClass('active')
|
||||
this.widget.classList.remove('active')
|
||||
this.active = 0
|
||||
this.lastChanged = 'active'
|
||||
this.updateValue()
|
||||
|
|
@ -101,13 +99,15 @@ module.exports = class Push extends _widgets_base {
|
|||
}
|
||||
if (typeof v == 'object' && v !== null) v = v.value
|
||||
if (v===this.getProp('on') || (this.getProp('on') != null && v === this.getProp('on').value && v !== undefined)) {
|
||||
this.classHolders.addClass('on')
|
||||
this.widget.classList.add('on')
|
||||
this.container.classList.add('on')
|
||||
this.state = 1
|
||||
if (options.send) this.sendValue(v)
|
||||
this.lastChanged = 'state'
|
||||
if (options.sync) this.changed(options)
|
||||
} else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) {
|
||||
this.classHolders.removeClass('on')
|
||||
this.widget.classList.remove('on')
|
||||
this.container.classList.remove('on')
|
||||
this.state = 0
|
||||
if (options.send) this.sendValue(v)
|
||||
this.lastChanged = 'state'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
var _widgets_base = require('../common/_widgets_base'),
|
||||
{iconify} = require('../../utils'),
|
||||
$document = $(document)
|
||||
{iconify} = require('../../ui/utils')
|
||||
|
||||
module.exports = class Switch extends _widgets_base {
|
||||
|
||||
|
|
@ -47,7 +46,7 @@ module.exports = class Switch extends _widgets_base {
|
|||
super({...options, html: '<div class="switch"></div>'})
|
||||
|
||||
|
||||
if (this.getProp('horizontal')) this.widget.addClass('horizontal')
|
||||
if (this.getProp('horizontal')) this.widget.classList.add('horizontal')
|
||||
|
||||
this.values = []
|
||||
|
||||
|
|
@ -60,7 +59,9 @@ module.exports = class Switch extends _widgets_base {
|
|||
var label = isArray ? this.getProp('values')[k]: k
|
||||
if (this.getProp('showValues') && !isArray) label = label + ': ' + this.getProp('values')[k]
|
||||
|
||||
$(`<div class="value"> ${iconify(label)}</div>`).data({value:this.getProp('values')[k]}).appendTo(this.widget)
|
||||
this.widget.appendChild(DOM.create(`
|
||||
<div class="value"> ${iconify(label)}</div>
|
||||
`))
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -69,10 +70,10 @@ module.exports = class Switch extends _widgets_base {
|
|||
this.on('draginit',(e)=>{
|
||||
|
||||
var index = 0,
|
||||
node = e.changedTarget || e.target
|
||||
node = e.target
|
||||
|
||||
while ( (node = node.previousSibling) ) {
|
||||
if (node.nodeType != 3 || !/^\s*$/.test(node.data)) {
|
||||
if (node.nodeType != 3) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
|
@ -81,21 +82,22 @@ module.exports = class Switch extends _widgets_base {
|
|||
|
||||
if (value!=this.value || this.value===undefined) this.setValue(value,{sync:true,send:true})
|
||||
|
||||
}, {element: this.widget[0]})
|
||||
}, {element: this.widget})
|
||||
|
||||
}
|
||||
|
||||
setValue(v,options={}) {
|
||||
|
||||
var i = this.values.indexOf(v)
|
||||
|
||||
DOM.each(this.widget, '.on', (el)=>{el.classList.remove('on')})
|
||||
|
||||
if (i!=-1) {
|
||||
this.value = this.values[i]
|
||||
this.widget.find('.on').removeClass('on')
|
||||
this.widget.find('.value').eq(i).addClass('on')
|
||||
DOM.get(this.widget, '.value')[i].classList.add('on')
|
||||
if (options.send) this.sendValue(this.value)
|
||||
if (options.sync) this.changed(options)
|
||||
} else {
|
||||
this.widget.find('.on').removeClass('on')
|
||||
this.value = undefined
|
||||
if (options.sync) this.changed(options)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ module.exports = class Toggle extends _widgets_base {
|
|||
this.state = 0
|
||||
this.active = false
|
||||
|
||||
if (this.getProp('led')) this.container.addClass('led')
|
||||
if (this.getProp('led')) this.container.classList.add('led')
|
||||
|
||||
if (this.getProp('doubleTap')) {
|
||||
|
||||
|
|
@ -65,16 +65,14 @@ module.exports = class Toggle extends _widgets_base {
|
|||
this.active = true
|
||||
var newVal = this.state?this.getProp('off'):this.getProp('on')
|
||||
this.setValue(newVal,{sync:true,send:true})
|
||||
}, {element: this.widget[0]})
|
||||
}, {element: this.widget})
|
||||
|
||||
this.on('dragend',()=>{
|
||||
this.active = false
|
||||
}, {element: this.widget[0]})
|
||||
}, {element: this.widget})
|
||||
|
||||
}
|
||||
|
||||
this.classHolders = this.widget.add(this.container)
|
||||
|
||||
this.value = this.getProp('off')
|
||||
|
||||
}
|
||||
|
|
@ -82,12 +80,14 @@ module.exports = class Toggle extends _widgets_base {
|
|||
setValue(v,options={}) {
|
||||
|
||||
if (v===this.getProp('on') || (this.getProp('on') != null && v.value === this.getProp('on').value && v.value !== undefined)) {
|
||||
this.classHolders.addClass('on')
|
||||
this.widget.classList.add('on')
|
||||
this.container.classList.add('on')
|
||||
this.state = 1
|
||||
this.value = this.getProp('on')
|
||||
if (options.send) this.sendValue()
|
||||
} else if (v===this.getProp('off') || (this.getProp('off') != null && v.value === this.getProp('off').value && v.value !== undefined)) {
|
||||
this.classHolders.removeClass('on')
|
||||
this.widget.classList.remove('on')
|
||||
this.container.classList.remove('on')
|
||||
this.state = 0
|
||||
this.value = this.getProp('off')
|
||||
if (options.send) this.sendValue()
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ module.exports = class _canvas_base extends _widgets_base {
|
|||
|
||||
super(options)
|
||||
|
||||
this.canvas = this.widget.find('canvas')
|
||||
this.ctx = this.canvas[0].getContext('2d')
|
||||
this.canvas = DOM.get(this.widget, 'canvas')[0]
|
||||
this.ctx = this.canvas.getContext('2d')
|
||||
|
||||
this.height = undefined
|
||||
this.width = undefined
|
||||
|
|
@ -79,7 +79,7 @@ module.exports = class _canvas_base extends _widgets_base {
|
|||
this.colors = {}
|
||||
this.textColor = getComputedStyle(document.documentElement).getPropertyValue('--color-text-fade')
|
||||
|
||||
this.canvas.on('resize',this.resizeHandleProxy.bind(this))
|
||||
this.on('resize', this.resizeHandleProxy.bind(this), {element: this.canvas})
|
||||
|
||||
this.ctx.arc = (x, y, r, s, e, c)=>{
|
||||
|
||||
|
|
@ -95,19 +95,18 @@ module.exports = class _canvas_base extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
resizeHandle(e, width, height, checkColors){
|
||||
resizeHandle(event){
|
||||
|
||||
var width = width,
|
||||
height = height,
|
||||
var {width, height, style, checkColors} = event,
|
||||
ratio = CANVAS_SCALING * this.scaling
|
||||
|
||||
if (width && height) {
|
||||
|
||||
this.height=height
|
||||
this.width=width
|
||||
this.height = height
|
||||
this.width = width
|
||||
|
||||
this.canvas[0].setAttribute('width',width * ratio)
|
||||
this.canvas[0].setAttribute('height',height * ratio)
|
||||
this.canvas.setAttribute('width', width * ratio)
|
||||
this.canvas.setAttribute('height', height * ratio)
|
||||
|
||||
this.clearRect = []
|
||||
|
||||
|
|
@ -118,8 +117,6 @@ module.exports = class _canvas_base extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
var style = getComputedStyle(this.widget[0])
|
||||
|
||||
if (!this.visible || checkColors) {
|
||||
this.visible = true
|
||||
this.colors.custom = style.getPropertyValue('--color-custom')
|
||||
|
|
|
|||
|
|
@ -5,6 +5,12 @@ var EventEmitter = require('../../events/event-emitter'),
|
|||
updateWidget = function(){ updateWidget = require('../../editor/data-workers').updateWidget; updateWidget(...arguments)}
|
||||
|
||||
|
||||
var fallbackContainer
|
||||
|
||||
DOM.ready(()=>{
|
||||
fallbackContainer = DOM.create('<div></div>')
|
||||
})
|
||||
|
||||
module.exports = class _widgets_base extends EventEmitter {
|
||||
|
||||
static defaults() {
|
||||
|
|
@ -22,16 +28,17 @@ module.exports = class _widgets_base extends EventEmitter {
|
|||
|
||||
super()
|
||||
|
||||
this.container = options.container
|
||||
this.widget = $(options.html)
|
||||
this.container = options.container || fallbackContainer
|
||||
this.widget = DOM.create(options.html)
|
||||
this.props = options.props
|
||||
this.parent = options.parent
|
||||
this.parentNode = options.parentNode
|
||||
this.hash = _widgets_base.createHash()
|
||||
this.childrenHashes = []
|
||||
|
||||
if (this.container) {
|
||||
this.container.attr('data-widget', this.hash)
|
||||
if (options.container) {
|
||||
this.container.setAttribute('data-widget', this.hash)
|
||||
this.container._widget_instance = this
|
||||
}
|
||||
|
||||
// Turn preArgs into array
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ module.exports = class Clone extends _widgets_base {
|
|||
|
||||
this.cloneLock = true
|
||||
|
||||
this.widget.empty()
|
||||
this.container.removeClass(this.cloneClass)
|
||||
this.widget.innerHTML = ''
|
||||
if (this.cloneClass) this.container.classList.remove(this.cloneClass)
|
||||
purge(this.childrenHashes)
|
||||
|
||||
var widgets = widget ? [widget] : widgetManager.getWidgetById(this.getProp('widgetId'))
|
||||
|
|
@ -75,12 +75,12 @@ module.exports = class Clone extends _widgets_base {
|
|||
|
||||
if (!(widgets[i].parent && widgets[i].parent.getProp('type') == 'clone')) {
|
||||
|
||||
this.cloneClass = widgets[i].container.attr('class').match(/[^\s]*-container/)[0]
|
||||
this.container.addClass(this.cloneClass)
|
||||
this.cloneClass = widgets[i].container.getAttribute('class').match(/[^\s]*-container/)[0]
|
||||
this.container.classList.add(this.cloneClass)
|
||||
|
||||
parser.parse([{..._widgets_base.deepCopy(widgets[i].props), ...this.getProp('props')}], this.widget, this)
|
||||
|
||||
this.widget.find('.widget').addClass('not-editable')
|
||||
DOM.each(this.widget, '.widget', (el)=>{el.classList.add('not-editable')})
|
||||
|
||||
widgets[i].once(`widget-created.${this.hash}`, (e)=>{
|
||||
this.createClone()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
var Panel = require('./panel'),
|
||||
{icon, iconify} = require('../../utils'),
|
||||
{icon, iconify} = require('../../ui/utils'),
|
||||
doubletab = require('../mixins/double_tap')
|
||||
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ module.exports = class Modal extends Panel {
|
|||
|
||||
super(options)
|
||||
|
||||
this.popup = $(`
|
||||
this.popup = DOM.create(`
|
||||
<div class="popup">
|
||||
<div class="popup-wrapper">
|
||||
<div class="popup-title closable"><span class="popup-label"></span><span class="closer">${icon('times')}</span></div>
|
||||
|
|
@ -66,38 +66,41 @@ module.exports = class Modal extends Panel {
|
|||
</div>
|
||||
`)
|
||||
|
||||
this.popup.appendTo(this.container).hide()
|
||||
|
||||
this.container.appendChild(this.popup)
|
||||
|
||||
// convert dimensions / coordinates to rem
|
||||
var width = parseFloat(this.getProp('popupWidth'))==this.getProp('popupWidth')?parseFloat(this.getProp('popupWidth'))+'rem' : this.getProp('popupWidth'),
|
||||
height = parseFloat(this.getProp('popupHeight'))==this.getProp('popupHeight')?parseFloat(this.getProp('popupHeight'))+'rem' : this.getProp('popupHeight')
|
||||
|
||||
this.popup[0].style.setProperty('--width', width)
|
||||
this.popup[0].style.setProperty('--height', height)
|
||||
this.popup.style.setProperty('--width', width)
|
||||
this.popup.style.setProperty('--height', height)
|
||||
|
||||
this.popup.find('.closer').on('fake-click',(e)=>{
|
||||
DOM.get(this.popup, '.closer')[0].addEventListener('fake-click', (e)=>{
|
||||
this.setValue(0, {sync:true, send:true})
|
||||
})
|
||||
|
||||
this.light = $('<div class="toggle"></div>').appendTo(this.container)
|
||||
this.light = this.container.appendChild(DOM.create('<div class="toggle"></div>'))
|
||||
|
||||
if (this.getProp('doubleTap')) {
|
||||
doubletab(this.light, ()=>{
|
||||
this.setValue(1, {sync:true, send:true})
|
||||
})
|
||||
} else {
|
||||
this.light.on('fake-click',(e)=>{
|
||||
this.light.addEventListener('fake-click',(e)=>{
|
||||
this.setValue(1, {sync:true, send:true})
|
||||
})
|
||||
}
|
||||
|
||||
this.popup.on('fake-click',(e)=>{
|
||||
if (e.target == this.popup[0] && this.value == 1) {
|
||||
this.popup.addEventListener('fake-click',(e)=>{
|
||||
if (e.target == this.popup && this.value == 1) {
|
||||
this.setValue(0, {sync:true, send:true})
|
||||
}
|
||||
})
|
||||
|
||||
this.escapeKeyHandler = ((e)=>{
|
||||
if (e.keyCode==27) this.setValue(0, {sync:true, send:true})
|
||||
}).bind(this)
|
||||
|
||||
this.parentScroll = [0,0]
|
||||
this.value = 0
|
||||
this.init = false
|
||||
|
|
@ -109,23 +112,23 @@ module.exports = class Modal extends Panel {
|
|||
this.value = v ? 1 : 0
|
||||
|
||||
if (!this.init && this.value) {
|
||||
var label = this.getProp('popupLabel') ? iconify(this.getProp('popupLabel')) : this.container.find('> .label').html()
|
||||
this.popup.find('.popup-title .popup-label').html(label)
|
||||
this.widget.detach().appendTo(this.popup.find('.popup-content'))
|
||||
var label = this.getProp('popupLabel') ? iconify(this.getProp('popupLabel')) : DOM.get(this.container, '> .label')[0].innerHTML
|
||||
DOM.get(this.popup, '.popup-title .popup-label')[0].innerHTML = label
|
||||
DOM.get(this.popup, '.popup-content')[0].appendChild(this.widget)
|
||||
this.init = true
|
||||
}
|
||||
|
||||
this.fixScrolling()
|
||||
this.popup.classList.toggle('show', this.value)
|
||||
this.container.classList.toggle('on', this.value)
|
||||
this.light.classList.toggle('on', this.value)
|
||||
|
||||
this.popup.toggle(this.value?true:false)
|
||||
this.container.add(this.light).toggleClass('on', this.value?true:false)
|
||||
this.bindEscKey(this.value)
|
||||
|
||||
if (this.value) {
|
||||
$(window).resize()
|
||||
DOM.dispatchEvent(window, 'resize')
|
||||
}
|
||||
|
||||
if (!this.init || this.value) this.fixStacking()
|
||||
if (!this.init && this.value) this.init = true
|
||||
if (this.init) this.fixParents()
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.changed(options)
|
||||
|
|
@ -136,36 +139,43 @@ module.exports = class Modal extends Panel {
|
|||
bindEscKey(set) {
|
||||
|
||||
if (set) {
|
||||
$(document).on('keydown.' + this.hash, (e)=>{
|
||||
if (e.keyCode==27) this.setValue(0, {sync:true, send:true})
|
||||
})
|
||||
document.addEventListener('keydown', this.escapeKeyHandler)
|
||||
} else {
|
||||
$(document).off('keydown.' + this.hash)
|
||||
document.removeEventListener('keydown', this.escapeKeyHandler)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this.bindEscKey(false)
|
||||
this.setValue(0)
|
||||
super.onRemove()
|
||||
}
|
||||
|
||||
fixScrolling() {
|
||||
if (this.value) {
|
||||
var c = this.container.parents('.panel.tab').first()
|
||||
this.parentScroll = [c.scrollLeft(), c.scrollTop()]
|
||||
c.scrollTop(0).scrollLeft(0).css('overflow','hidden')
|
||||
} else {
|
||||
this.container.parents('.panel.tab').first().css('overflow','').scrollLeft(this.parentScroll[0]).scrollTop(this.parentScroll[1])
|
||||
}
|
||||
}
|
||||
fixParents() {
|
||||
|
||||
fixStacking() {
|
||||
if (this.value) {
|
||||
this.container.parents('.widget').css('z-index','initial')
|
||||
} else {
|
||||
this.container.parents('.widget').css('z-index','')
|
||||
var parent = this.parent,
|
||||
scrollFixed = false
|
||||
|
||||
while (parent && parent.props) {
|
||||
|
||||
// scroll
|
||||
if (!scrollFixed && parent.getProp('type') == 'tab') {
|
||||
if (this.value) {
|
||||
this.parentScroll = [parent.widget.scrollLeft, parent.widget.scrollTop]
|
||||
}
|
||||
parent.widget.scrollLeft = this.value ? 0 : this.parentScroll[0]
|
||||
parent.widget.scrolTop = this.value ? 0 : this.parentScroll[1]
|
||||
parent.widget.style.overflow = this.value ? 'hidden' : ''
|
||||
scrollFixed = true
|
||||
}
|
||||
|
||||
// stacking
|
||||
parent.container.style.zIndex = this.value ? 'initial' : ''
|
||||
|
||||
parent = parent.parent
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var _widgets_base = require('../common/_widgets_base'),
|
||||
autolayout = require('autolayout/dist/autolayout.kiwi.js'),
|
||||
{iconify} = require('../../utils'),
|
||||
{iconify} = require('../../ui/utils'),
|
||||
editObject = function(){editObject = require('../../editor/edit-objects').editObject; editObject(...arguments)},
|
||||
widgetManager = require('../../managers/widgets'),
|
||||
parser = require('../../parser')
|
||||
|
|
@ -58,9 +58,9 @@ module.exports = class Panel extends _widgets_base {
|
|||
|
||||
super({...options, html: '<div class="panel"></div>'})
|
||||
|
||||
if (this.getProp('scroll') === false) this.widget.addClass('noscroll')
|
||||
if (this.getProp('border') === false) this.container.addClass('noborder')
|
||||
if (this.getProp('tabs') && this.getProp('tabs').length) this.widget.addClass('has-tabs')
|
||||
if (this.getProp('scroll') === false) this.widget.classList.add('noscroll')
|
||||
if (this.getProp('border') === false) this.container.classList.add('noborder')
|
||||
if (this.getProp('tabs') && this.getProp('tabs').length) this.widget.classList.add('has-tabs')
|
||||
|
||||
|
||||
this.value = -1
|
||||
|
|
@ -68,15 +68,18 @@ module.exports = class Panel extends _widgets_base {
|
|||
|
||||
if (this.getProp('tabs') && this.getProp('tabs').length) {
|
||||
|
||||
this.navigation = $('<div class="navigation"><ul class="tablist"></ul></div>').prependTo(this.widget).find('.tablist')
|
||||
this.wrapper = $('<div class="tabs-wrapper"></div>').appendTo(this.widget)
|
||||
this.widget.appendChild(DOM.create('<div class="navigation"><ul class="tablist"></ul></div>'))
|
||||
this.navigation = DOM.get(this.widget, '.tablist')[0]
|
||||
|
||||
this.wrapper = this.widget.appendChild(DOM.create('<div class="tabs-wrapper"></div>'))
|
||||
|
||||
parser.parse(this.getProp('tabs'), this.wrapper, this, true)
|
||||
this.createNavigation()
|
||||
|
||||
this.navigation.on('fake-click', (e)=>{
|
||||
this.navigation.addEventListener('fake-click', (e)=>{
|
||||
if (!e.target.hasAttribute('data-widget')) return
|
||||
this.setValue($(e.target).index(), {sync: true, send:this.value != $(e.target).index()})
|
||||
var index = DOM.index(e.target)
|
||||
this.setValue(index, {sync: true, send:this.value != index})
|
||||
})
|
||||
|
||||
this.on('tab-created', (e)=>{
|
||||
|
|
@ -98,17 +101,21 @@ module.exports = class Panel extends _widgets_base {
|
|||
|
||||
createNavigation() {
|
||||
|
||||
this.navigation.empty()
|
||||
this.navigation.innerHTML = ''
|
||||
this.tabs = []
|
||||
|
||||
var tabs = this.wrapper.find('> .widget')
|
||||
var html = ''
|
||||
DOM.each(this.wrapper, '> .widget', (tab)=>{
|
||||
|
||||
for (let tab of tabs) {
|
||||
let widget = widgetManager.getWidgetByElement(tab),
|
||||
style = widget.getProp('color') == 'auto' ? '' : `style="--color-custom:${widget.getProp('color')}"`
|
||||
|
||||
this.tabs.push(widget)
|
||||
this.navigation.append(`<li class="tablink" data-widget="${widget.hash}" ${style}><a><span>${$(tab).find('> .label').html()}</span></a></li>`)
|
||||
}
|
||||
html += `<li class="tablink" data-widget="${widget.hash}" ${style}><a><span>${DOM.get(tab, '> .label')[0].innerHTML}</span></a></li>`
|
||||
|
||||
})
|
||||
|
||||
this.navigation.innerHTML = html
|
||||
|
||||
this.setValue(this.value)
|
||||
|
||||
|
|
@ -116,7 +123,7 @@ module.exports = class Panel extends _widgets_base {
|
|||
|
||||
parseLayout() {
|
||||
|
||||
var children = this.widget.find('> .widget')
|
||||
var children = DOM.get(this.widget, '> .widget')
|
||||
|
||||
try {
|
||||
|
||||
|
|
@ -127,17 +134,14 @@ module.exports = class Panel extends _widgets_base {
|
|||
this.layout = new autolayout.View({
|
||||
constraints: autolayout.VisualFormat.parse(layout.split('\\n').join('\n').split(' ').join(''), {extended: true}),
|
||||
spacing: this.getProp('spacing')
|
||||
});
|
||||
|
||||
this.widget.on('resize',(e, w, h)=>{
|
||||
if (!w) {
|
||||
var w = this.widget.width(),
|
||||
h = this.widget.height()
|
||||
}
|
||||
this.layout.setSize(w,h)
|
||||
this.applyLayout()
|
||||
})
|
||||
|
||||
this.on('resize',(event)=>{
|
||||
if (!event.width) return
|
||||
this.layout.setSize(event.width, event.height)
|
||||
this.applyLayout()
|
||||
}, {element: this.widget})
|
||||
|
||||
} catch(err) {
|
||||
throw `Visual Format Language error in ${this.getProp('id')}.layout: ${err.message} (line ${err.line})`
|
||||
}
|
||||
|
|
@ -145,23 +149,25 @@ module.exports = class Panel extends _widgets_base {
|
|||
}
|
||||
|
||||
applyLayout() {
|
||||
this.widget.find('> .widget').each((i,widget)=>{
|
||||
DOM.each(this.widget, '> .widget', (widget)=>{
|
||||
|
||||
var widget = widgetManager.getWidgetByElement(widget),
|
||||
id = widget.getProp('id')
|
||||
|
||||
if (!this.layout.subViews[id]) return
|
||||
|
||||
widget.container.addClass('absolute-position').css({'min-height':'auto','min-width':'auto'})
|
||||
widget.container.classList.add('absolute-position')
|
||||
widget.container.style.minHeight = 'auto'
|
||||
widget.container.style.minWidth = 'auto'
|
||||
|
||||
for (var prop of ['height', 'width', 'top', 'left']) {
|
||||
delete widget.props[prop]
|
||||
widget.container.css(prop, this.layout.subViews[id][prop] + 'px')
|
||||
widget.container.style[prop] = this.layout.subViews[id][prop] + 'px'
|
||||
}
|
||||
|
||||
if (widget.container.hasClass('editing')) editObject(widget, {refresh:true})
|
||||
if (widget.container.classList.contains('editing')) editObject(widget, {refresh:true})
|
||||
|
||||
$(window).resize()
|
||||
DOM.dispatchEvent(window, 'resize')
|
||||
|
||||
})
|
||||
}
|
||||
|
|
@ -176,15 +182,13 @@ module.exports = class Panel extends _widgets_base {
|
|||
this.tabs[i].hide()
|
||||
}
|
||||
|
||||
this.tabs[v].show()
|
||||
|
||||
this.value = v
|
||||
|
||||
$(window).resize()
|
||||
|
||||
}
|
||||
|
||||
this.navigation.find('li').removeClass('on').eq(v).addClass('on')
|
||||
this.tabs[v].show()
|
||||
DOM.each(this.navigation, 'li', (el)=>{el.classList.remove('on')})[v].classList.add('on')
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.changed(options)
|
||||
|
|
@ -195,10 +199,10 @@ module.exports = class Panel extends _widgets_base {
|
|||
scroll(s) {
|
||||
|
||||
if (!s) {
|
||||
return [this.widget.scrollLeft(), this.widget.scrollTop()]
|
||||
return [this.widget.scrollLeft, this.widget.scrollTop]
|
||||
} else {
|
||||
this.widget.scrollLeft(s[0])
|
||||
this.widget.scrollTop(s[1])
|
||||
this.widget.scrollLeft = s[0]
|
||||
this.widget.scrollTop = s[1]
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
var Panel = require('./panel'),
|
||||
{iconify} = require('../../utils'),
|
||||
{iconify} = require('../../ui/utils'),
|
||||
Tab = require('./tab'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
|
||||
|
|
@ -47,8 +47,11 @@ module.exports = class Root extends Panel {
|
|||
super(options)
|
||||
|
||||
this.parent = widgetManager
|
||||
this.widget.addClass('root')
|
||||
this.widget.find('> .navigation').addClass('main')
|
||||
this.widget.classList.add('root')
|
||||
|
||||
DOM.each(this.widget, '> .navigation', (el)=>{
|
||||
el.classList.add('main')
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +59,11 @@ module.exports = class Root extends Panel {
|
|||
|
||||
super.createNavigation()
|
||||
|
||||
this.navigation.append(`<li class="not-editable"><a id="open-toggle" class="${$('#sidepanel').hasClass('sidepanel-open')?'sidepanel-open':''}">${iconify('^bars')}</a></li>`)
|
||||
this.navigation.appendChild(DOM.create(`
|
||||
<li class="not-editable">
|
||||
<a id="open-toggle" class="${DOM.get('#sidepanel')[0].classList.contains('sidepanel-open')?'sidepanel-open':''}">${iconify('^bars')}</a>
|
||||
</li>
|
||||
`))
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ module.exports = class Strip extends Panel {
|
|||
|
||||
super(options)
|
||||
|
||||
this.widget[0].style.setProperty('--spacing', this.getProp('spacing'))
|
||||
this.widget.style.setProperty('--spacing', this.getProp('spacing'))
|
||||
|
||||
this.container.addClass(this.getProp('horizontal') ? 'horizontal' : 'vertical')
|
||||
this.container.addClass(this.getProp('stretch') ? 'stretch' : '')
|
||||
this.container.classList.add(this.getProp('horizontal') ? 'horizontal' : 'vertical')
|
||||
if (this.getProp('stretch')) this.container.classList.add('stretch')
|
||||
|
||||
this.setValue = undefined
|
||||
this.getValue = undefined
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
var Panel = require('./panel'),
|
||||
resize = require('../../events/resize'),
|
||||
editClean = function(){editClean = require('../../editor/edit-objects').editClean; editClean(...arguments)}
|
||||
|
||||
|
||||
|
|
@ -46,22 +47,27 @@ module.exports = class Tab extends Panel {
|
|||
|
||||
super(options)
|
||||
|
||||
this.widget.addClass('tab')
|
||||
this.container.classList.add('show')
|
||||
this.widget.classList.add('tab')
|
||||
|
||||
this.detached = false
|
||||
|
||||
}
|
||||
|
||||
hide() {
|
||||
if (this.detached) return
|
||||
if (EDITING) editClean()
|
||||
this.widget.detach()
|
||||
this.container.hide()
|
||||
this.container.removeChild(this.widget)
|
||||
this.container.classList.remove('show')
|
||||
this.detached = true
|
||||
|
||||
}
|
||||
show() {
|
||||
this.container.show().append(this.widget)
|
||||
if (!this.detached) return
|
||||
this.container.appendChild(this.widget)
|
||||
this.container.classList.add('show')
|
||||
this.detached = false
|
||||
resize.check(this.widget)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
var {iconify} = require('../../utils'),
|
||||
var {iconify} = require('../../ui/utils'),
|
||||
_widgets_base = require('../common/_widgets_base'),
|
||||
_canvas_base = require('../common/_canvas_base'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
|
|
@ -57,18 +57,20 @@ module.exports = class Input extends _canvas_base {
|
|||
this.stringValue = ''
|
||||
|
||||
if (this.getProp('vertical')) {
|
||||
this.widget.addClass('vertical')
|
||||
this.widget.classList.add('vertical')
|
||||
}
|
||||
|
||||
if (this.getProp('editable')) {
|
||||
this.canvas.attr('tabindex', 0)
|
||||
this.canvas.on('focus', this.focus.bind(this))
|
||||
this.input = $('<input></input>')
|
||||
|
||||
this.input.on('change', (e)=>{
|
||||
e.stopPropagation()
|
||||
this.canvas.setAttribute('tabindex', 0)
|
||||
this.canvas.addEventListener('focus', this.focus.bind(this))
|
||||
this.input = DOM.create('<input></input>')
|
||||
this.input.addEventListener('blur', (e)=>{
|
||||
this.blur(false)
|
||||
})
|
||||
this.input.addEventListener('keydown', (e)=>{
|
||||
if (e.keyCode==13) this.blur()
|
||||
if (e.keyCode==27) this.blur(false)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
if (this.getProp('widgetId').length) {
|
||||
|
|
@ -79,26 +81,12 @@ module.exports = class Input extends _canvas_base {
|
|||
|
||||
}
|
||||
|
||||
resizeHandle() {
|
||||
|
||||
super.resizeHandle(...arguments)
|
||||
|
||||
}
|
||||
|
||||
focus() {
|
||||
|
||||
this.canvas.attr('tabindex','-1')
|
||||
this.input
|
||||
.val(this.stringValue)
|
||||
.prependTo(this.widget)
|
||||
.focus()
|
||||
.on('blur', (e)=>{
|
||||
this.blur(false)
|
||||
})
|
||||
.on('keydown', (e)=>{
|
||||
if (e.keyCode==13) this.blur()
|
||||
if (e.keyCode==27) this.blur(false)
|
||||
})
|
||||
this.canvas.setAttribute('tabindex','-1')
|
||||
this.input.value = this.stringValue
|
||||
this.widget.insertBefore(this.input, this.canvas)
|
||||
this.input.focus()
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -106,15 +94,14 @@ module.exports = class Input extends _canvas_base {
|
|||
|
||||
if (change) this.inputChange()
|
||||
|
||||
this.input.off('blur keydown')
|
||||
this.canvas.attr('tabindex','0')
|
||||
this.input.detach()
|
||||
this.canvas.setAttribute('tabindex','0')
|
||||
if (this.input.parentNode == this.widget) this.widget.removeChild(input)
|
||||
|
||||
}
|
||||
|
||||
inputChange() {
|
||||
|
||||
this.setValue(this.input.val(), {sync:true, send:true})
|
||||
this.setValue(this.input.value, {sync:true, send:true})
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -133,9 +120,9 @@ module.exports = class Input extends _canvas_base {
|
|||
|
||||
}
|
||||
|
||||
resizeHandle(){
|
||||
resizeHandle(event){
|
||||
|
||||
super.resizeHandle(...arguments)
|
||||
super.resizeHandle(event)
|
||||
|
||||
if (this.getProp('vertical')){
|
||||
this.ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
var _widgets_base = require('../common/_widgets_base'),
|
||||
widgetManager = require('../../managers/widgets'),
|
||||
{math} = require('../utils'),
|
||||
{iconify} = require('../../utils'),
|
||||
{iconify} = require('../../ui/utils'),
|
||||
keyboardJS = require('keyboardjs')
|
||||
|
||||
module.exports = class Keys extends _widgets_base {
|
||||
|
|
@ -52,7 +52,7 @@ module.exports = class Keys extends _widgets_base {
|
|||
|
||||
if (this.getProp('binding') && (this.keydownString || this.keyupString)) {
|
||||
|
||||
this.widget.append(`<span>${this.getProp('binding')}</span>`)
|
||||
this.widget.appendChild(DOM.create(`<span>${this.getProp('binding')}</span>`))
|
||||
|
||||
this.keydownHandler = this.keydownString ? this.keydown.bind(this) : this.showKeydown.bind(this)
|
||||
this.keyupHandler = this.keyupString ? this.keyup.bind(this) : this.showKeyup.bind(this)
|
||||
|
|
@ -110,7 +110,7 @@ module.exports = class Keys extends _widgets_base {
|
|||
|
||||
showKeydown(){
|
||||
|
||||
this.widget[0].style.setProperty('--opacity', 1)
|
||||
this.widget.style.setProperty('--opacity', 1)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ module.exports = class Keys extends _widgets_base {
|
|||
|
||||
showKeyup(){
|
||||
|
||||
this.widget[0].style.setProperty('--opacity', 0.75)
|
||||
this.widget.style.setProperty('--opacity', 0.75)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ module.exports = class Formula extends _widgets_base {
|
|||
parent:this, parentNode:this.widget
|
||||
})
|
||||
|
||||
this.widget.append(this.input.widget)
|
||||
this.widget.appendChild(this.input.widget)
|
||||
|
||||
this.linkedWidgets = []
|
||||
|
||||
|
|
@ -94,10 +94,6 @@ module.exports = class Formula extends _widgets_base {
|
|||
widgetManager.on(`change.${this.hash}`,this.syncHandle.bind(this))
|
||||
this.updateValue({options:{}})
|
||||
|
||||
this.input.widget.on('change', (e)=>{
|
||||
e.stopPropagation()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ module.exports = class _matrices_base extends _widgets_base {
|
|||
|
||||
if (e.widget == this) return
|
||||
|
||||
this.value[e.widget.container.index()] = e.widget.getValue()
|
||||
this.value[DOM.index(e.widget.container)] = e.widget.getValue()
|
||||
this.changed(e.options)
|
||||
|
||||
})
|
||||
|
||||
if (this.getProp('traversing')) enableTraversingGestures(this.widget[0])
|
||||
if (this.getProp('traversing')) enableTraversingGestures(this.widget)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,13 +51,16 @@ module.exports = class Keyboard extends _matrices_base {
|
|||
|
||||
var strData = JSON.stringify(options.props),
|
||||
pattern = 'wbwbwwbwbwbw',
|
||||
wCount = 0
|
||||
whiteKeys = 0, whiteKeys2 = 0, i
|
||||
|
||||
for (var i = this.start; i < this.keys + this.start && i < 108; i++) {
|
||||
for (i = this.start; i < this.keys + this.start && i < 108; i++) {
|
||||
if (pattern[i % 12] == 'w') whiteKeys++
|
||||
}
|
||||
|
||||
for (i = this.start; i < this.keys + this.start && i < 108; i++) {
|
||||
|
||||
var data = JSON.parse(strData)
|
||||
|
||||
|
||||
data.top = data.left = data.height = data.width = 'auto'
|
||||
data.type = 'push'
|
||||
data.id = this.getProp('id') + '/' + i
|
||||
|
|
@ -67,29 +70,22 @@ module.exports = class Keyboard extends _matrices_base {
|
|||
data.css = ''
|
||||
|
||||
var key = parser.parse([data], this.widget, this)
|
||||
key.container[0].classList.add('not-editable')
|
||||
key.container.classList.add('not-editable')
|
||||
|
||||
if (pattern[i % 12] == 'w') {
|
||||
key.container.addClass('white')
|
||||
wCount++
|
||||
key.container.classList.add('white')
|
||||
key.container.style.width = `${100/whiteKeys}%`
|
||||
whiteKeys2++
|
||||
} else {
|
||||
key.container.addClass('black').data('wCount',wCount)
|
||||
|
||||
key.container.classList.add('black')
|
||||
key.container.style.width = `${60 / whiteKeys}%`
|
||||
key.container.style.left = `${100 / whiteKeys * (whiteKeys2 - 3/10)}%`
|
||||
}
|
||||
|
||||
this.value[i-this.start] = this.getProp('off')
|
||||
|
||||
}
|
||||
|
||||
this.widget.find('.widget.white').css('width',`${100/wCount}%`)
|
||||
this.widget.find('.widget.black').each(function(){
|
||||
$(this).css({
|
||||
'width':`${100/wCount * 6/10}%`,
|
||||
'left':`${100/wCount * ($(this).data('wCount') - 3/10)}%`
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,11 +65,11 @@ module.exports = class Multifader extends _matrices_base {
|
|||
this.strips = parseInt(this.getProp('strips'))
|
||||
|
||||
if (this.getProp('horizontal')) {
|
||||
this.widget.addClass('horizontal')
|
||||
this.widget.classList.add('horizontal')
|
||||
}
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
this.widget.addClass('compact')
|
||||
this.widget.classList.add('compact')
|
||||
}
|
||||
|
||||
var strData = JSON.stringify(options.props)
|
||||
|
|
@ -88,9 +88,7 @@ module.exports = class Multifader extends _matrices_base {
|
|||
data.css = ''
|
||||
|
||||
var fader = parser.parse([data], this.widget, this)
|
||||
fader.container[0].classList.add('not-editable')
|
||||
|
||||
if (this.getProp('traversing')) fader.container.find('canvas').off('drag')
|
||||
fader.container.classList.add('not-editable')
|
||||
|
||||
this.value[i-this.start] = this.getProp('range').min
|
||||
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ module.exports = class Multipush extends _matrices_base {
|
|||
|
||||
super(options)
|
||||
|
||||
this.widget[0].style.setProperty('--columns', this.getProp('matrix')[0])
|
||||
this.widget[0].style.setProperty('--rows', this.getProp('matrix')[1])
|
||||
this.widget[0].style.setProperty('--spacing', this.getProp('spacing') + 'rem')
|
||||
this.widget.style.setProperty('--columns', this.getProp('matrix')[0])
|
||||
this.widget.style.setProperty('--rows', this.getProp('matrix')[1])
|
||||
this.widget.style.setProperty('--spacing', this.getProp('spacing') + 'rem')
|
||||
|
||||
var strData = JSON.stringify(options.props)
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ module.exports = class Multipush extends _matrices_base {
|
|||
data.css = ''
|
||||
|
||||
var push = parser.parse([data], this.widget, this)
|
||||
push.container[0].classList.add('not-editable')
|
||||
push.container.classList.add('not-editable')
|
||||
|
||||
this.value[i-this.start] = this.getProp('off')
|
||||
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ module.exports = class Multitoggle extends _matrices_base {
|
|||
|
||||
super(options)
|
||||
|
||||
this.widget[0].style.setProperty('--columns', this.getProp('matrix')[0])
|
||||
this.widget[0].style.setProperty('--rows', this.getProp('matrix')[1])
|
||||
this.widget[0].style.setProperty('--spacing', this.getProp('spacing') + 'rem')
|
||||
this.widget.style.setProperty('--columns', this.getProp('matrix')[0])
|
||||
this.widget.style.setProperty('--rows', this.getProp('matrix')[1])
|
||||
this.widget.style.setProperty('--spacing', this.getProp('spacing') + 'rem')
|
||||
|
||||
var strData = JSON.stringify(options.props)
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ module.exports = class Multitoggle extends _matrices_base {
|
|||
data.css = ''
|
||||
|
||||
var toggle = parser.parse([data], this.widget, this)
|
||||
toggle.container[0].classList.add('not-editable')
|
||||
toggle.container.classList.add('not-editable')
|
||||
|
||||
this.value[i-this.start] = this.getProp('off')
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ module.exports = (element, callback)=>{
|
|||
lastTapY,
|
||||
touchId
|
||||
|
||||
element[0].addEventListener('fake-click', (event)=>{
|
||||
element.addEventListener('fake-click', (event)=>{
|
||||
|
||||
var tapTime = new Date().getTime(),
|
||||
tapLength = tapTime - lastTapTime,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
module.exports = (self, element)=>{
|
||||
module.exports = (self, options)=>{
|
||||
|
||||
var sendTouchState = self.getProp('touchAddress') && self.getProp('touchAddress').length
|
||||
|
||||
self.touched = 0
|
||||
self.setValueTouchedQueue = undefined
|
||||
|
||||
element.on('draginit',(e)=>{
|
||||
self.on('draginit',(e)=>{
|
||||
self.touched += 1
|
||||
if (self.touched == 1 && sendTouchState)
|
||||
self.sendValue({
|
||||
|
|
@ -13,9 +13,9 @@ module.exports = (self, element)=>{
|
|||
v:1,
|
||||
split:false
|
||||
})
|
||||
})
|
||||
}, options)
|
||||
|
||||
element.on('dragend', (e, data, traversing)=>{
|
||||
self.on('dragend', (e)=>{
|
||||
if (self.touched == 1) {
|
||||
self.touched = 0
|
||||
|
||||
|
|
@ -34,8 +34,8 @@ module.exports = (self, element)=>{
|
|||
|
||||
} else if (self.touched > 1){
|
||||
self.touched -= 1
|
||||
if (traversing) self.touched = 1
|
||||
if (e.traversing) self.touched = 1
|
||||
}
|
||||
})
|
||||
}, options)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
var _canvas_base = require('../common/_canvas_base'),
|
||||
touchstate = require('../mixins/touch_state')
|
||||
var _canvas_base = require('../common/_canvas_base')
|
||||
|
||||
module.exports = class _pads_base extends _canvas_base {
|
||||
|
||||
|
|
@ -15,12 +14,10 @@ module.exports = class _pads_base extends _canvas_base {
|
|||
|
||||
super({...options, html: html})
|
||||
|
||||
this.wrapper = this.widget.find('.wrapper')
|
||||
this.wrapper = DOM.get(this.widget, '.wrapper')[0]
|
||||
|
||||
this.pointSize = parseInt(this.getProp('pointSize'))
|
||||
this.widget[0].style.setProperty('--pointSize', this.pointSize + 'rem')
|
||||
|
||||
touchstate(this, this.wrapper)
|
||||
this.widget.style.setProperty('--pointSize', this.pointSize + 'rem')
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
var _pads_base = require('./_pads_base'),
|
||||
Xy = require('./xy'),
|
||||
{clip} = require('../utils')
|
||||
{clip} = require('../utils'),
|
||||
touchstate = require('../mixins/touch_state')
|
||||
|
||||
|
||||
var xyDefaults = Xy.defaults()
|
||||
|
||||
|
|
@ -94,7 +96,7 @@ module.exports = class MultiXy extends _pads_base {
|
|||
input:false
|
||||
}, parent: this})
|
||||
this.pads[i].sendValue = ()=>{}
|
||||
this.wrapper.append(this.pads[i].widget)
|
||||
this.wrapper.appendChild(this.pads[i].widget)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -138,7 +140,7 @@ module.exports = class MultiXy extends _pads_base {
|
|||
|
||||
this.pads[id].trigger('draginit', [e])
|
||||
|
||||
}, {element: this.wrapper[0], multitouch: true})
|
||||
}, {element: this.wrapper, multitouch: true})
|
||||
|
||||
this.on('drag',(e)=>{
|
||||
|
||||
|
|
@ -153,9 +155,9 @@ module.exports = class MultiXy extends _pads_base {
|
|||
this.pads[i].trigger('dragend', [e])
|
||||
delete this.touchMap[e.pointerId]
|
||||
|
||||
}, {element: this.wrapper[0], multitouch: true})
|
||||
|
||||
}, {element: this.wrapper, multitouch: true})
|
||||
|
||||
touchstate(this, {element: this.wrapper, multitouch: true})
|
||||
|
||||
this.on('change',(e)=>{
|
||||
if (e.widget == this) return
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ var _pads_base = require('./_pads_base'),
|
|||
Xy = require('./xy'),
|
||||
Fader = require('./_fake_fader'),
|
||||
{clip, hsbToRgb, rgbToHsb} = require('../utils'),
|
||||
Input = require('../inputs/input')
|
||||
Input = require('../inputs/input'),
|
||||
touchstate = require('../mixins/touch_state')
|
||||
|
||||
var faderDefaults = Fader.defaults(),
|
||||
xyDefaults = Xy.defaults()
|
||||
|
|
@ -59,7 +60,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
: [this.getProp('address') + '/r', this.getProp('address') + '/g', this.getProp('address') + '/b']
|
||||
: false
|
||||
|
||||
this.hueWrapper = $(`<div class="hue-wrapper"></div>`).appendTo(this.widget)
|
||||
this.hueWrapper = this.widget.appendChild(DOM.create(`<div class="hue-wrapper"></div>`))
|
||||
|
||||
this.hue = new Fader({props:{
|
||||
...faderDefaults,
|
||||
|
|
@ -74,7 +75,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
}, cancelDraw: false})
|
||||
this.hue.margin = this.pointSize
|
||||
this.hue.sendValue = ()=>{}
|
||||
this.hueWrapper.append(this.hue.widget)
|
||||
this.hueWrapper.appendChild(this.hue.widget)
|
||||
|
||||
this.pad = new Xy({props:{
|
||||
...xyDefaults,
|
||||
|
|
@ -88,7 +89,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
input:false
|
||||
}})
|
||||
this.pad.sendValue = ()=>{}
|
||||
this.wrapper.append(this.pad.widget)
|
||||
this.wrapper.appendChild(this.pad.widget)
|
||||
|
||||
|
||||
this.value = []
|
||||
|
|
@ -104,6 +105,8 @@ module.exports = class Rgb extends _pads_base {
|
|||
this.dragHandle()
|
||||
})
|
||||
|
||||
touchstate(this, {element: this.wrapper, multitouch: true})
|
||||
|
||||
if (this.getProp('input')) {
|
||||
|
||||
this.input = new Input({
|
||||
|
|
@ -174,7 +177,7 @@ module.exports = class Rgb extends _pads_base {
|
|||
if (!options.nohue && !options.dragged) {
|
||||
var hue = hsbToRgb({h:this.hsb.h,s:100,b:100}),
|
||||
hueStr = `rgb(${Math.round(hue.r)},${Math.round(hue.g)},${Math.round(hue.b)})`
|
||||
this.canvas[0].setAttribute('style',`background-color:${hueStr}`)
|
||||
this.canvas.setAttribute('style',`background-color:${hueStr}`)
|
||||
this.hue.setValue(this.hsb.h, {sync: false, send:false, dragged:false})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ var _pads_base = require('./_pads_base'),
|
|||
Fader = require('./_fake_fader'),
|
||||
{clip} = require('../utils'),
|
||||
doubletab = require('../mixins/double_tap'),
|
||||
Input = require('../inputs/input')
|
||||
Input = require('../inputs/input'),
|
||||
touchstate = require('../mixins/touch_state')
|
||||
|
||||
var faderDefaults = Fader.defaults()
|
||||
|
||||
|
|
@ -103,8 +104,8 @@ module.exports = class Xy extends _pads_base {
|
|||
|
||||
this.value = [this.faders.x.value, this.faders.y.value]
|
||||
|
||||
this.wrapper.append(this.faders.x.widget)
|
||||
this.wrapper.append(this.faders.y.widget)
|
||||
this.wrapper.appendChild(this.faders.x.widget)
|
||||
this.wrapper.appendChild(this.faders.y.widget)
|
||||
|
||||
this.faders.x.on('change',(e)=>{
|
||||
e.stopPropagation = true
|
||||
|
|
@ -118,13 +119,13 @@ module.exports = class Xy extends _pads_base {
|
|||
this.faders.x.trigger('draginit', [e])
|
||||
this.faders.y.trigger('draginit', [e])
|
||||
this.dragHandle()
|
||||
}, {element: this.wrapper[0]})
|
||||
}, {element: this.wrapper})
|
||||
|
||||
this.on('drag',(e)=>{
|
||||
this.faders.x.trigger('drag', [e])
|
||||
this.faders.y.trigger('drag', [e])
|
||||
this.dragHandle()
|
||||
}, {element: this.wrapper[0]})
|
||||
}, {element: this.wrapper})
|
||||
|
||||
this.on('dragend', (e)=>{
|
||||
this.faders.x.trigger('dragend', [e])
|
||||
|
|
@ -132,7 +133,9 @@ module.exports = class Xy extends _pads_base {
|
|||
if (this.getProp('spring')) {
|
||||
this.setValue([this.faders.x.springValue,this.faders.y.springValue],{sync:true,send:true,fromLocal:true})
|
||||
}
|
||||
}, {element: this.wrapper[0]})
|
||||
}, {element: this.wrapper})
|
||||
|
||||
touchstate(this, {element: this.wrapper})
|
||||
|
||||
if (this.getProp('doubleTap')) {
|
||||
doubletab(this.wrapper, ()=>{
|
||||
|
|
@ -146,7 +149,7 @@ module.exports = class Xy extends _pads_base {
|
|||
props:{...Input.defaults(), precision:this.getProp('precision'), unit:this.getProp('unit')},
|
||||
parent:this, parentNode:this.widget
|
||||
})
|
||||
this.widget.append(this.input.widget)
|
||||
this.widget.appendChild(this.input.widget)
|
||||
this.input.on('change', (e)=>{
|
||||
e.stopPropagation = true
|
||||
this.setValue(this.input.getValue(), {sync:true, send:true})
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ module.exports = class Led extends _widgets_base {
|
|||
|
||||
super({...options, html: html})
|
||||
|
||||
if (!this.getProp('border')) this.container.addClass('noborder')
|
||||
if (!this.getProp('border')) this.container.classList.add('noborder')
|
||||
|
||||
this.widget[0].style.setProperty('background-size', this.getProp('size'))
|
||||
this.widget[0].style.setProperty('background-position', this.getProp('position'))
|
||||
this.widget[0].style.setProperty('background-repeat', this.getProp('repeat'))
|
||||
this.widget.style.setProperty('background-size', this.getProp('size'))
|
||||
this.widget.style.setProperty('background-position', this.getProp('position'))
|
||||
this.widget.style.setProperty('background-repeat', this.getProp('repeat'))
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ module.exports = class Led extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
this.widget[0].style.setProperty('background-image', `url(${this.value}${cache_query})`)
|
||||
this.widget.style.setProperty('background-image', `url(${this.value}${cache_query})`)
|
||||
|
||||
if (options.sync) this.changed(options)
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ module.exports = class Led extends _widgets_base {
|
|||
|
||||
if (typeof v != 'number') return
|
||||
this.value = v
|
||||
this.widget[0].style.setProperty('--opacity', mapToScale(v,[this.getProp('range').min,this.getProp('range').max],[0,1],false,this.getProp('logScale'),true))
|
||||
this.widget.style.setProperty('--opacity', mapToScale(v,[this.getProp('range').min,this.getProp('range').max],[0,1],false,this.getProp('logScale'),true))
|
||||
|
||||
if (options.sync) this.changed(options)
|
||||
|
||||
|
|
|
|||
|
|
@ -52,10 +52,9 @@ module.exports = class Meter extends Fader {
|
|||
|
||||
super(options)
|
||||
|
||||
this.widget.addClass('meter')
|
||||
.off('mousewheel')
|
||||
this.widget.classList.add('meter')
|
||||
|
||||
this.canvas.off('draginit drag')
|
||||
this.off(/drag(.*)?/)
|
||||
|
||||
if (this.getProp('widgetId').length) widgetManager.on(`change.${this.hash}`,this.syncHandle.bind(this))
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ module.exports = class Rbgled extends _widgets_base {
|
|||
|
||||
this.value = v
|
||||
|
||||
this.widget[0].style.setProperty('--color-led', c)
|
||||
this.widget.style.setProperty('--color-led', c)
|
||||
|
||||
if (options.sync) this.changed(options)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
var {iconify} = require('../../utils'),
|
||||
var {iconify} = require('../../ui/utils'),
|
||||
_widgets_base = require('../common/_widgets_base'),
|
||||
widgetManager = require('../../managers/widgets')
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ module.exports = class Text extends _widgets_base {
|
|||
|
||||
super({...options, html: '<div class="text"></div>'})
|
||||
|
||||
if (this.getProp('vertical')) this.widget.addClass('vertical')
|
||||
if (this.getProp('vertical')) this.widget.classList.add('vertical')
|
||||
|
||||
this.defaultValue = this.getProp('value') || ( this.getProp('label')===false ?
|
||||
this.getProp('id'):
|
||||
|
|
@ -81,7 +81,7 @@ module.exports = class Text extends _widgets_base {
|
|||
setValue(v, options={}) {
|
||||
|
||||
this.value = v==null ? this.defaultValue : v
|
||||
this.widget.html(iconify(String(this.value).replace(/\n/g,'<br/>')))
|
||||
this.widget.innerHTML = iconify(String(this.value).replace(/\n/g,'<br/>'))
|
||||
|
||||
if (options.sync) this.changed(options)
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
|
||||
super({...options, html: html})
|
||||
|
||||
this.wrapper = this.widget.find('.wrapper')
|
||||
this.wrapper = DOM.get(this.widget, '.wrapper')[0]
|
||||
|
||||
this.value = undefined
|
||||
this.percent = 0
|
||||
|
|
@ -60,13 +60,14 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
|
||||
}
|
||||
|
||||
touchstate(this, this.wrapper)
|
||||
|
||||
this.wrapper.on('mousewheel',this.mousewheelHandleProxy.bind(this))
|
||||
this.wrapper.addEventListener('mousewheel',this.mousewheelHandleProxy.bind(this))
|
||||
|
||||
this.on('draginit', this.draginitHandleProxy.bind(this), {element:this.wrapper[0]})
|
||||
this.on('drag', this.dragHandleProxy.bind(this), {element:this.wrapper[0]})
|
||||
this.on('dragend', this.dragendHandleProxy.bind(this), {element:this.wrapper[0]})
|
||||
this.on('draginit', this.draginitHandleProxy.bind(this), {element:this.wrapper})
|
||||
this.on('drag', this.dragHandleProxy.bind(this), {element:this.wrapper})
|
||||
this.on('dragend', this.dragendHandleProxy.bind(this), {element:this.wrapper})
|
||||
|
||||
touchstate(this, {element: this.wrapper})
|
||||
|
||||
|
||||
if (this.getProp('input')) {
|
||||
|
|
@ -81,14 +82,14 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
parent:this, parentNode:this.widget
|
||||
})
|
||||
|
||||
this.widget.append(this.input.widget)
|
||||
this.widget.appendChild(this.input.widget)
|
||||
this.input.on('change', (e)=>{
|
||||
e.stopPropagation = true
|
||||
this.setValue(this.input.getValue(), {sync:true, send:true})
|
||||
this.showValue()
|
||||
})
|
||||
|
||||
this.widget.on('fake-right-click',function(e){
|
||||
this.widget.addEventListener('fake-right-click',function(e){
|
||||
if (!EDITING) {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
|
|
@ -126,14 +127,14 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
|
||||
}
|
||||
|
||||
mousewheelHandle(e, data, traversing) {
|
||||
mousewheelHandle(e) {
|
||||
|
||||
if (e.originalEvent.wheelDeltaX) return
|
||||
if (e.wheelDeltaX) return
|
||||
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
var direction = e.originalEvent.wheelDelta / Math.abs(e.originalEvent.wheelDelta),
|
||||
var direction = e.wheelDelta / Math.abs(e.wheelDelta),
|
||||
increment = e.ctrlKey?0.25:1
|
||||
|
||||
this.percent = clip(this.percent + Math.max(increment,10/Math.pow(10,this.precision + 1)) * direction, [0,100])
|
||||
|
|
@ -157,10 +158,11 @@ module.exports = class _sliders_base extends _canvas_base {
|
|||
|
||||
}
|
||||
|
||||
resizeHandle(e, width, height, checkColors) {
|
||||
resizeHandle(event) {
|
||||
|
||||
var {style, checkColors} = event
|
||||
|
||||
if (!this.visible || checkColors) {
|
||||
var style = getComputedStyle(this.widget[0])
|
||||
this.colors.track = style.getPropertyValue('--color-track')
|
||||
this.colors.gauge = style.getPropertyValue('--color-gauge')
|
||||
this.colors.knob = style.getPropertyValue('--color-knob')
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ module.exports = class Encoder extends _widgets_base {
|
|||
`
|
||||
super({...options, html: html})
|
||||
|
||||
this.wrapper = this.widget.find('.wrapper')
|
||||
this.wrapper = DOM.get(this.widget, '.wrapper')[0]
|
||||
this.ticks = Math.abs(parseInt(this.getProp('ticks')))
|
||||
|
||||
this.knob = new EncoderKnob({props:{
|
||||
|
|
@ -99,8 +99,11 @@ module.exports = class Encoder extends _widgets_base {
|
|||
pips:false,
|
||||
}, parent: this})
|
||||
|
||||
this.wrapper.append(this.knob.widget.addClass('drag-knob'))
|
||||
this.wrapper.append(this.display.widget.addClass('display-knob'))
|
||||
this.knob.widget.classList.add('drag-knob')
|
||||
this.display.widget.classList.add('display-knob')
|
||||
|
||||
this.wrapper.appendChild(this.knob.widget)
|
||||
this.wrapper.appendChild(this.display.widget)
|
||||
|
||||
this.knob.setValue(this.ticks/2)
|
||||
this.display.setValue(this.ticks/2)
|
||||
|
|
@ -135,7 +138,7 @@ module.exports = class Encoder extends _widgets_base {
|
|||
|
||||
this.knob.on('draginit', (e)=>{
|
||||
if (this.getProp('touchAddress') && this.getProp('touchAddress').length
|
||||
&& e.target == this.wrapper[0])
|
||||
&& e.target == this.wrapper)
|
||||
this.sendValue({
|
||||
address:this.getProp('touchAddress'),
|
||||
v:1
|
||||
|
|
@ -150,7 +153,7 @@ module.exports = class Encoder extends _widgets_base {
|
|||
}
|
||||
if (
|
||||
this.getProp('touchAddress') && this.getProp('touchAddress').length
|
||||
&& e.target == this.wrapper[0]
|
||||
&& e.target == this.wrapper
|
||||
) {
|
||||
this.sendValue({
|
||||
address:this.getProp('touchAddress'),
|
||||
|
|
@ -171,7 +174,7 @@ module.exports = class Encoder extends _widgets_base {
|
|||
|
||||
}
|
||||
|
||||
this.wrapper.on('mousewheel', (e)=>{
|
||||
this.wrapper.addEventListener('mousewheel', (e)=>{
|
||||
|
||||
if (e.originalEvent.wheelDeltaX || e.originalEvent.wheelDelta == 0) return
|
||||
|
||||
|
|
|
|||
|
|
@ -59,21 +59,22 @@ module.exports = class Fader extends _sliders_base {
|
|||
|
||||
super(options)
|
||||
|
||||
this.widget.addClass('fader')
|
||||
this.widget.classList.add('fader')
|
||||
this.margin = 22
|
||||
|
||||
|
||||
if (this.getProp('horizontal')) {
|
||||
this.widget.add(this.container).addClass('horizontal')
|
||||
this.widget.classList.add('horizontal')
|
||||
this.container.classList.add('horizontal')
|
||||
}
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
this.widget.addClass('compact')
|
||||
this.widget.classList.add('compact')
|
||||
this.margin = 0
|
||||
}
|
||||
|
||||
if (this.getProp('alignRight') && !this.getProp('horizontal')) {
|
||||
this.widget.addClass('align-right')
|
||||
this.widget.classList.add('align-right')
|
||||
}
|
||||
|
||||
if (this.getProp('meter')) {
|
||||
|
|
@ -91,16 +92,16 @@ module.exports = class Fader extends _sliders_base {
|
|||
dashed:true
|
||||
}
|
||||
var meter = parser.parse([data],this.wrapper, this.parent)
|
||||
meter.container[0].classList.add('not-editable')
|
||||
meter.container.classList.add('not-editable')
|
||||
|
||||
this.widget[0].classList.add('has-meter')
|
||||
this.widget.classList.add('has-meter')
|
||||
}
|
||||
|
||||
if (this.getProp('pips')) {
|
||||
|
||||
this.widget.addClass('has-pips')
|
||||
this.widget.classList.add('has-pips')
|
||||
|
||||
var pips = $('<div class="pips"></div>').appendTo(this.wrapper)
|
||||
var pips = this.wrapper.appendChild(DOM.create('<div class="pips"></div>'))
|
||||
var pipTexts = {}
|
||||
for (var k in this.rangeKeys) {
|
||||
pipTexts[this.rangeKeys[k]]=this.rangeLabels[k]
|
||||
|
|
@ -119,7 +120,7 @@ module.exports = class Fader extends _sliders_base {
|
|||
`
|
||||
pipsInner = pipsInner + add
|
||||
}
|
||||
pips[0].innerHTML = pipsInner
|
||||
pips.innerHTML = pipsInner
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -165,20 +166,20 @@ module.exports = class Fader extends _sliders_base {
|
|||
|
||||
}
|
||||
|
||||
resizeHandle(e, width, height, checkColors) {
|
||||
resizeHandle(event) {
|
||||
|
||||
var ratio = CANVAS_SCALING * this.scaling
|
||||
var {width, height, style} = event,
|
||||
ratio = CANVAS_SCALING * this.scaling
|
||||
|
||||
if (this.getProp('compact')) {
|
||||
if (this.getProp('horizontal')) {
|
||||
super.resizeHandle(e, width, 1 / ratio, checkColors)
|
||||
event.height = 1 / ratio
|
||||
} else {
|
||||
super.resizeHandle(e, 1 / ratio, height, checkColors)
|
||||
}
|
||||
} else {
|
||||
super.resizeHandle(...arguments)
|
||||
}
|
||||
|
||||
super.resizeHandle(event)
|
||||
|
||||
if (this.getProp('horizontal')){
|
||||
this.ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
this.ctx.rotate(-Math.PI/2)
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ module.exports = class Knob extends _sliders_base {
|
|||
|
||||
super(options)
|
||||
|
||||
this.widget.addClass('knob')
|
||||
this.widget.classList.add('knob')
|
||||
|
||||
this.widget.addClass('compact')
|
||||
this.widget.classList.add('compact')
|
||||
|
||||
this.lastOffsetX = 0
|
||||
this.lastOffsetY = 0
|
||||
|
|
@ -134,7 +134,7 @@ module.exports = class Knob extends _sliders_base {
|
|||
|
||||
this.minDimension = Math.min(this.width, this.height)
|
||||
|
||||
this.wrapper[0].style.top = (this.minDimension) * this.lostHeightFactor - (this.getProp('label') === false ? 0 : this.gaugeWidth / 4) + 'px'
|
||||
this.wrapper.style.top = (this.minDimension) * this.lostHeightFactor - (this.getProp('label') === false ? 0 : this.gaugeWidth / 4) + 'px'
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
var {clip} = require('../utils'),
|
||||
_widgets_base = require('../common/_widgets_base'),
|
||||
Fader = require('./fader'),
|
||||
Input = require('../inputs/input')
|
||||
Input = require('../inputs/input'),
|
||||
touchstate = require('../mixins/touch_state')
|
||||
|
||||
var faderDefaults = Fader.defaults()
|
||||
|
||||
|
|
@ -209,6 +210,7 @@ module.exports = class Range extends _widgets_base {
|
|||
|
||||
precision:2,
|
||||
address:'auto',
|
||||
touchAddress:'',
|
||||
preArgs:[],
|
||||
split:false,
|
||||
target:[]
|
||||
|
|
@ -232,7 +234,7 @@ module.exports = class Range extends _widgets_base {
|
|||
: [this.getProp('address') + '/low', this.getProp('address') + '/high']
|
||||
: false
|
||||
|
||||
this.wrapper = this.widget.find('.wrapper')
|
||||
this.wrapper = DOM.get(this.widget, '.wrapper')[0]
|
||||
|
||||
this.faders = [
|
||||
new RangeFader({props:{
|
||||
|
|
@ -271,8 +273,8 @@ module.exports = class Range extends _widgets_base {
|
|||
}, cancelDraw: false, parent: this})
|
||||
]
|
||||
|
||||
this.wrapper.append(this.faders[0].widget)
|
||||
this.wrapper.append(this.faders[1].widget)
|
||||
this.wrapper.appendChild(this.faders[0].widget)
|
||||
this.wrapper.appendChild(this.faders[1].widget)
|
||||
|
||||
this.on('change',(e)=>{
|
||||
|
||||
|
|
@ -329,14 +331,14 @@ module.exports = class Range extends _widgets_base {
|
|||
|
||||
this.faders[id].trigger('draginit', [e])
|
||||
|
||||
}, {element: this.wrapper[0], multitouch: true})
|
||||
}, {element: this.wrapper, multitouch: true})
|
||||
|
||||
this.on('drag',(e)=>{
|
||||
|
||||
var i = this.touchMap[e.pointerId]
|
||||
this.faders[i].trigger('drag', [e])
|
||||
|
||||
}, {element: this.wrapper[0], multitouch: true})
|
||||
}, {element: this.wrapper, multitouch: true})
|
||||
|
||||
this.on('dragend',(e)=>{
|
||||
|
||||
|
|
@ -344,8 +346,9 @@ module.exports = class Range extends _widgets_base {
|
|||
this.faders[i].trigger('dragend', [e])
|
||||
delete this.touchMap[e.pointerId]
|
||||
|
||||
}, {element: this.wrapper[0], multitouch: true})
|
||||
}, {element: this.wrapper, multitouch: true})
|
||||
|
||||
touchstate(this, {element: this.wrapper, multitouch: true})
|
||||
|
||||
if (this.getProp('input')) {
|
||||
|
||||
|
|
@ -357,14 +360,14 @@ module.exports = class Range extends _widgets_base {
|
|||
},
|
||||
parent:this, parentNode:this.widget,
|
||||
})
|
||||
this.widget.append(this.input.widget)
|
||||
this.widget.appendChild(this.input.widget)
|
||||
this.input.on('change', (e)=>{
|
||||
e.stopPropagation = true
|
||||
this.setValue(this.input.getValue(), {sync:true, send:true})
|
||||
this.showValue()
|
||||
})
|
||||
|
||||
this.widget.on('fake-right-click',function(e){
|
||||
this.widget.addEventListener('fake-right-click',function(e){
|
||||
if (!EDITING) {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
|
|
@ -376,16 +379,17 @@ module.exports = class Range extends _widgets_base {
|
|||
|
||||
|
||||
if (this.getProp('horizontal')) {
|
||||
this.widget.add(this.container).addClass('horizontal')
|
||||
this.widget.classList.add('horizontal')
|
||||
this.container.classList.add('horizontal')
|
||||
}
|
||||
if (this.getProp('alignRight') && !this.getProp('horizontal')) {
|
||||
this.widget.addClass('align-right')
|
||||
this.widget.classList.add('align-right')
|
||||
}
|
||||
if (this.getProp('compact')) {
|
||||
this.widget.addClass('compact')
|
||||
this.widget.classList.add('compact')
|
||||
}
|
||||
if (this.getProp('pips')) {
|
||||
this.widget.addClass('has-pips')
|
||||
this.widget.classList.add('has-pips')
|
||||
}
|
||||
|
||||
this.setValue([
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ module.exports = class Crossfader extends Switcher {
|
|||
|
||||
this.fader.sendValue = ()=>{}
|
||||
|
||||
this.widget.append($('<div class="fader-container"></div>').append(this.fader.widget))
|
||||
this.widget.appendChild(DOM.create('<div class="fader-container"></div>')).appendChild(this.fader.widget)
|
||||
|
||||
this.fader.on('change', (e)=>{
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ module.exports = class Switcher extends _switchers_base {
|
|||
|
||||
super({...options, html: '<div class="switcher"></div>'})
|
||||
|
||||
if (this.getProp('horizontal')) this.widget.addClass('horizontal')
|
||||
if (this.getProp('horizontal')) this.widget.classList.add('horizontal')
|
||||
|
||||
this.switch = new Switch({props:{
|
||||
...switchDefaults,
|
||||
|
|
@ -57,7 +57,7 @@ module.exports = class Switcher extends _switchers_base {
|
|||
|
||||
this.switch.sendValue = ()=>{}
|
||||
|
||||
this.widget.append(this.switch.widget)
|
||||
this.widget.appendChild(this.switch.widget)
|
||||
|
||||
this.switch.on('change', (e)=>{
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,21 @@
|
|||
|
||||
require('./app/globals')
|
||||
require('./app/sourcemap')
|
||||
|
||||
var ipc = require('./app/ipc/'),
|
||||
osc = require('./app/osc'),
|
||||
parser = require('./app/parser'),
|
||||
{loading} = require('./app/ui/utils')
|
||||
|
||||
ipc.init()
|
||||
osc.init()
|
||||
parser.init()
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
|
||||
require('./app/globals')
|
||||
require('./app/sourcemap')
|
||||
|
||||
var ipc = require('./app/ipc/'),
|
||||
osc = require('./app/osc'),
|
||||
parser = require('./app/parser'),
|
||||
{loading} = require('./app/utils')
|
||||
|
||||
ipc.init()
|
||||
osc.init()
|
||||
parser.init()
|
||||
|
||||
DOM.init()
|
||||
LOADING = loading('Connecting server...')
|
||||
require('./app/ui')
|
||||
require('./app/ui/init')
|
||||
ipc.send('ready')
|
||||
|
||||
})
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ body {
|
|||
flex-direction: column;
|
||||
background:var(--color-bg);
|
||||
padding:2rem;
|
||||
opacity: 0;
|
||||
&.show {
|
||||
opacity: 1;
|
||||
}
|
||||
&.sidepanel-open {
|
||||
right:var(--sidepanel-size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ body {
|
|||
flex-direction: column;
|
||||
opacity: 0;
|
||||
transition: opacity .25s;
|
||||
&.loaded {
|
||||
&.show {
|
||||
opacity: 1;
|
||||
overflow: auto;
|
||||
}
|
||||
|
|
@ -199,6 +199,9 @@ body {
|
|||
&:hover {
|
||||
color:var(--color-accent);
|
||||
}
|
||||
i {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -482,11 +485,13 @@ body {
|
|||
right:0;
|
||||
bottom:0;
|
||||
padding:10%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
z-index:1000000;
|
||||
transform: translate3d(0,0,0);
|
||||
|
||||
display: none;
|
||||
&.show {
|
||||
display: flex;
|
||||
}
|
||||
&:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
|
|
|
|||
|
|
@ -270,6 +270,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
.tab-container {
|
||||
display: none;
|
||||
&.show {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
.clone-container {
|
||||
width: 100rem;
|
||||
height: 100rem;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue