diff --git a/lib/meta.js b/lib/meta.js index 23e5fa08..1c2ab297 100644 --- a/lib/meta.js +++ b/lib/meta.js @@ -1,9 +1,4 @@ ;(function(){ - var root; - if(typeof window !== "undefined"){ root = window } - if(typeof global !== "undefined"){ root = global } - root = root || {}; - var console = root.console || {log: function(){}}; function USE(arg, req){ return req? require(arg) : arg.slice? USE[R(arg)] : function(mod, path){ arg(mod = {exports: {}}); @@ -13,8 +8,8 @@ return p.split('/').slice(-1).toString().replace('.js',''); } } - if(typeof module !== "undefined"){ var common = module } - + if(typeof module !== "undefined"){ var MODULE = module } + /* UNBUILD */ ;USE(function(module){ var noop = function(){}, u; @@ -23,14 +18,6 @@ var k = m.key = {}; k.meta = {17:17, 91:17, 93:17, 224:17, 18: 17}; // ALT added function withMeta(eve){ return eve.metaKey || eve.ctrlKey || eve.altKey } // ALT added - var defaults = { - 8: { // backspace: close root or go back on submenu - on: () => k.at == m.edit ? m.flip(false) : m.check('down', 'back') - }, - 27: { // esc: close and reset menu - up: () => k.wipe() - } - } k.down = function(eve){ var key = (k.eve = m.eve = eve).which = eve.which || eve.fake || eve.keyCode; if(eve.repeat){ return } @@ -54,8 +41,10 @@ } } m.flip = function(tmp){ + m.flip.active = true; ((tmp === false) || (!tmp && m.ui.board.is(':visible')))? m.close() : m.open(); + m.flip.active = false; } m.open = function(){ m.check.fired = null; @@ -86,7 +75,7 @@ else k.down.keys[key] = 1; } if('up' == how){ return } - if(at != next){ next.back = at } + if(at != next && !next.back){ next.back = at } (k.combo || (k.combo = [])).push(key); m.list(next, true); } @@ -112,9 +101,7 @@ if(k.styles) meta.ui.iniline($li[0], k.styles); }); if(opt){ m.flip(true) } - $ul.append($('
  • ').html('←').on('click', function(){ - m.list(at.back); - })); + $ul.append($('
  • ').html('←').on('click', back)); } m.ask = function(help, cb){ var $ul = $('#meta .meta-menu ul').empty(); @@ -123,8 +110,7 @@ eve.preventDefault(); cb($put.val()); $li.remove(); - //k.wipe(); - m.list(k.at); + k.wipe(); }); var $li = $('
  • ').append($form); $ul.append($li); @@ -139,7 +125,7 @@ m.tap = function(){ var on = $('.meta-on') .or($($(document.querySelectorAll(':hover')).get().reverse()).first()) - .or($(document.elementFromPoint(meta.tap.x||0, meta.tap.y||0))); + .or($(document.elementFromPoint(meta.tap.x, meta.tap.y))); return on; } meta.edit = function(e){ @@ -154,6 +140,13 @@ e.combow = path.join(','); // deprecate? m.list(k.at || meta.edit); } + function back(){ // close root or go back on submenu + k.at == m.edit ? m.flip(false) : m.check('down', 'back') + } + var defaults = { + 8: { on: back }, // backspace + 27: { up: k.wipe } // esc: close and reset menu + } $.extend(meta.edit, defaults) })(USE, './metaCore'); ;USE(function(module){ @@ -177,6 +170,14 @@ var $m = $('
    ').attr('id', 'meta'); $m.append($('').html('☰').addClass('meta-start')); $m.append($('
    ').addClass('meta-menu meta-none').append('
      ')); + $m.on('mouseenter', function(){ + if (meta.flip.active || meta.flip.is()) return; + meta.flip(); + }) + $m.on('mouseleave', function(){ + if (meta.flip.active || !meta.flip.is()) return; + meta.flip(false); + }) $(document.body).append($m); meta.ui.board = $('.meta-menu', $m); css({