merge with @jussiry + correct HUD display

This commit is contained in:
Mark Nadal 2019-11-22 14:20:09 -08:00
commit eece7f91ac

View File

@ -17,6 +17,7 @@
/* UNBUILD */
;USE(function(module){
var noop = function(){}, u;
$.fn.or = function(s){ return this.length ? this : $(s||'body') };
var m = window.meta = {edit:[]};
@ -35,14 +36,13 @@
if(!eve.fake && key === k.last){ return }; k.last = key; // jussi: polyfilling eve.repeat?
if(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length && !$(eve.target).closest('#meta').length){
// if(k.meta[key]){ k.down.meta = key = -1 }
// if(!k.down.meta){ return }
// prevent typing with meta open
if(meta.flip.is() && !withMeta(eve)) eve.preventDefault()
if(!meta.flip.is() && !withMeta(eve)){ // cancel meta/hud during text input UNLESS hud is open OR cmd key is held down.
return;
}
//if(k.meta[key]){ k.down.meta = key = -1 }
//if(!k.down.meta){ return }
// hmmm?
// if(!k.meta[key] && !meta.flip.is()) return // aserwed
//if(!k.meta[key] && !meta.flip.is()) return // aserwed
}
m.check('on', key, k.at || (k.at = m.edit));
if(k.meta[key]){
@ -53,7 +53,7 @@
}
k.up = function(eve){ var tmp;
var key = (k.eve = m.eve = eve).which = eve.which || eve.fake || eve.keyCode;
if(!m.flip.is() && !k.meta[key]){ return } // ADDED cancel non-open events when closed TODO make optional
//if(!m.flip.is() && !k.meta[key]){ return } // ADDED cancel non-open events when closed TODO make optional
// if(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length){
// if(k.meta[key]){
// k.down.meta = null;
@ -168,18 +168,18 @@
;USE(function(module){
/* UI */
meta.ui = {
blink: function(){ // hint visually that action has happened
blink: function(){ // hint visually that action has happened
$('#meta').css('transition', 'none').css('background', 'none')
setTimeout(function(){
$('#meta')[0].style.transition = null
$('#meta')[0].style.background = null
$('#meta')[0].style.transition = null
$('#meta')[0].style.background = null
})
},
depth: function(n){
if (n) {
$('#meta').css('background', 'hsl(60, 100%,'+(85-(n*10))+'%)');
$('#meta').css('background', 'hsl(60, 100%,'+(85-(n*10))+'%)');
} else {
$('#meta')[0].style.background = null
$('#meta')[0].style.background = null
}
}
}
@ -237,7 +237,8 @@
'border-radius': '1em',
'margin-left': '0.25em',
'margin-top': '0.25em',
'float': 'right'
'float': 'right',
'cursor': 'pointer'
},
'#meta a': {color: 'black'},
// '#meta:hover': {opacity: 1},
@ -275,6 +276,7 @@
})(USE, './metaUI');
;USE(function(module){
// include basic text editing by default.
var monotype = window.monotype || function(){console.log("monotype needed")};
var m = meta;
@ -421,29 +423,34 @@
})(USE, './metaText');
;USE(function(module){
var m = meta, k = m.key;
$(window).on('blur', k.wipe.bind(null, false)).on('focus', k.wipe.bind(null, false));
$(window).on('focus', k.wipe.bind(null, false)); // .on('blur', k.wipe.bind(null, false))
$(document).on('mousedown mousemove mouseup', function(eve){
m.tap.eve = eve;
m.tap.x = eve.pageX||0;
m.tap.y = eve.pageY||0;
m.tap.on = $(eve.target);
})
/*// Setting m.tap.edit has been commented, so should never end up here?
.on('mousedown touchstart', function(eve){
var tmp = m.tap.edit;
if(!tmp || !tmp.on){ return }
tmp.on(eve);
m.tap.edit = null;
});*/
// Setting m.tap.edit has been commented, so should never end up here?
//.on('mousedown touchstart', function(eve){
// var tmp = m.tap.edit;
// if(!tmp || !tmp.on){ return }
// tmp.on(eve);
// m.tap.edit = null;
//});
//$(document).on('touchstart', '#meta .meta-start', function(eve){ m.tap.stun = true });
$(document).on('click', '#meta .meta-menu li', function(eve){
var combo = $(this).data().combo;
eve.fake = eve.which = combo && combo.slice(-1)[0].charCodeAt(0);
var [start, end] = 'ontouchstart' in window
? ['touchstart', 'touchend']
: ['mousedown', 'mouseup']
$(document).on(start, '#meta .meta-menu li', function(eve){
var combo = $(this).data().combo;
eve.fake = eve.which = combo && combo.slice(-1)[0].charCodeAt(0);
eve.tap = true;
k.down(eve); k.up(eve);
return;
k.down(eve);
$(document).one(end, () => k.up(eve))
return;
// if(m.tap.stun){ return m.tap.stun = false }
// if(!(eve.fake = eve.which = (($(this).text().match(/[A-Z]/)||{})[0]||'').toUpperCase().charCodeAt(0))){ return }
// eve.tap = true;
@ -452,6 +459,11 @@
});
$(document).on('keydown', k.down).on('keyup', k.up);
$('#meta').on('click', function(ev) {
if (ev.target.tagName == 'LI' || ev.target.tagName == 'UL') return
meta.flip()
})
//$(document).on('select contextmenu keyup mouseup', '[contenteditable=true]', m.text.on);