mirror of
https://github.com/amark/gun.git
synced 2025-06-06 14:16:44 +00:00
click open, mouse button drag, open canceld disabled
This commit is contained in:
parent
22547099bd
commit
b41022ca91
26
lib/meta.js
26
lib/meta.js
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
/* UNBUILD */
|
/* UNBUILD */
|
||||||
;USE(function(module){
|
;USE(function(module){
|
||||||
|
|
||||||
var noop = function(){}, u;
|
var noop = function(){}, u;
|
||||||
$.fn.or = function(s){ return this.length ? this : $(s||'body') };
|
$.fn.or = function(s){ return this.length ? this : $(s||'body') };
|
||||||
var m = window.meta = {edit:[]};
|
var m = window.meta = {edit:[]};
|
||||||
@ -29,8 +30,7 @@
|
|||||||
if(eve.repeat){ return }
|
if(eve.repeat){ return }
|
||||||
var key = (k.eve = m.eve = eve).which = eve.which || eve.fake || eve.keyCode;
|
var key = (k.eve = m.eve = eve).which = eve.which || eve.fake || eve.keyCode;
|
||||||
|
|
||||||
// ADDED
|
//if(!m.flip.is() && !k.meta[key]){ return } // cancel non-open events when closed TODO make optional
|
||||||
if(!m.flip.is() && !k.meta[key]){ return } // cancel non-open events when closed TODO make optional
|
|
||||||
if(!k.meta[key] && withMeta(eve) && !k.at[key]) { return m.flip(false) } // cancel and close when no action and "meta key" held down (e.g. ctrl+c)
|
if(!k.meta[key] && withMeta(eve) && !k.at[key]) { return m.flip(false) } // cancel and close when no action and "meta key" held down (e.g. ctrl+c)
|
||||||
|
|
||||||
if(!eve.fake && key === k.last){ return }; k.last = key; // jussi: polyfilling eve.repeat?
|
if(!eve.fake && key === k.last){ return }; k.last = key; // jussi: polyfilling eve.repeat?
|
||||||
@ -53,7 +53,7 @@
|
|||||||
}
|
}
|
||||||
k.up = function(eve){ var tmp;
|
k.up = function(eve){ var tmp;
|
||||||
var key = (k.eve = m.eve = eve).which = eve.which || eve.fake || eve.keyCode;
|
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(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length){
|
||||||
// if(k.meta[key]){
|
// if(k.meta[key]){
|
||||||
// k.down.meta = null;
|
// k.down.meta = null;
|
||||||
@ -236,7 +236,8 @@
|
|||||||
'border-radius': '1em',
|
'border-radius': '1em',
|
||||||
'margin-left': '0.25em',
|
'margin-left': '0.25em',
|
||||||
'margin-top': '0.25em',
|
'margin-top': '0.25em',
|
||||||
'float': 'right'
|
'float': 'right',
|
||||||
|
'cursor': 'pointer'
|
||||||
},
|
},
|
||||||
'#meta a': {color: 'black'},
|
'#meta a': {color: 'black'},
|
||||||
// '#meta:hover': {opacity: 1},
|
// '#meta:hover': {opacity: 1},
|
||||||
@ -274,6 +275,7 @@
|
|||||||
|
|
||||||
})(USE, './metaUI');
|
})(USE, './metaUI');
|
||||||
;USE(function(module){
|
;USE(function(module){
|
||||||
|
|
||||||
// include basic text editing by default.
|
// include basic text editing by default.
|
||||||
var monotype = window.monotype || function(){console.log("monotype needed")};
|
var monotype = window.monotype || function(){console.log("monotype needed")};
|
||||||
var m = meta;
|
var m = meta;
|
||||||
@ -420,7 +422,7 @@
|
|||||||
})(USE, './metaText');
|
})(USE, './metaText');
|
||||||
;USE(function(module){
|
;USE(function(module){
|
||||||
var m = meta, k = m.key;
|
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){
|
//$(document).on('mousedown mousemove mouseup', function(eve){
|
||||||
// m.tap.eve = eve;
|
// m.tap.eve = eve;
|
||||||
// m.tap.x = eve.pageX||0;
|
// m.tap.x = eve.pageX||0;
|
||||||
@ -437,11 +439,16 @@
|
|||||||
|
|
||||||
//$(document).on('touchstart', '#meta .meta-start', function(eve){ m.tap.stun = true });
|
//$(document).on('touchstart', '#meta .meta-start', function(eve){ m.tap.stun = true });
|
||||||
|
|
||||||
$(document).on('click', '#meta .meta-menu li', function(eve){
|
var [start, end] = 'ontouchstart' in window
|
||||||
|
? ['touchstart', 'touchend']
|
||||||
|
: ['mousedown', 'mouseup']
|
||||||
|
|
||||||
|
$(document).on(start, '#meta .meta-menu li', function(eve){
|
||||||
var combo = $(this).data().combo;
|
var combo = $(this).data().combo;
|
||||||
eve.fake = eve.which = combo && combo.slice(-1)[0].charCodeAt(0);
|
eve.fake = eve.which = combo && combo.slice(-1)[0].charCodeAt(0);
|
||||||
eve.tap = true;
|
eve.tap = true;
|
||||||
k.down(eve); k.up(eve);
|
k.down(eve);
|
||||||
|
$(document).one(end, () => k.up(eve))
|
||||||
return;
|
return;
|
||||||
// if(m.tap.stun){ return m.tap.stun = false }
|
// if(m.tap.stun){ return m.tap.stun = false }
|
||||||
// if(!(eve.fake = eve.which = (($(this).text().match(/[A-Z]/)||{})[0]||'').toUpperCase().charCodeAt(0))){ return }
|
// if(!(eve.fake = eve.which = (($(this).text().match(/[A-Z]/)||{})[0]||'').toUpperCase().charCodeAt(0))){ return }
|
||||||
@ -451,6 +458,11 @@
|
|||||||
});
|
});
|
||||||
$(document).on('keydown', k.down).on('keyup', k.up);
|
$(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);
|
//$(document).on('select contextmenu keyup mouseup', '[contenteditable=true]', m.text.on);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user