mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
commit
8dc043c44f
104
lib/meta.js
104
lib/meta.js
@ -1,22 +1,27 @@
|
||||
;(function(){
|
||||
function USE(arg, req){
|
||||
return req? require(arg) : arg.slice? USE[R(arg)] : function(mod, path){
|
||||
arg(mod = {exports: {}});
|
||||
USE[R(path)] = mod.exports;
|
||||
}
|
||||
function R(p){
|
||||
return p.split('/').slice(-1).toString().replace('.js','');
|
||||
}
|
||||
}
|
||||
|
||||
/* UNBUILD */
|
||||
;USE(function(module){
|
||||
var noop = function(){}, u;
|
||||
$.fn.or = function(s){ return this.length ? this : $(s||'body') };
|
||||
var m = window.meta = {edit:[]};
|
||||
var k = m.key = {};
|
||||
k.meta = {17:17, 91:17, 93:17, 224:17};
|
||||
k.down = function(eve){
|
||||
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: {}});
|
||||
USE[R(path)] = mod.exports;
|
||||
}
|
||||
function R(p){
|
||||
return p.split('/').slice(-1).toString().replace('.js','');
|
||||
}
|
||||
}
|
||||
if(typeof module !== "undefined"){ var common = module }
|
||||
|
||||
;USE(function(module){
|
||||
var noop = function(){}, u;
|
||||
$.fn.or = function(s){ return this.length ? this : $(s||'body') };
|
||||
var m = window.meta = {edit:[]};
|
||||
var k = m.key = {};
|
||||
k.meta = {17:17, 91:17, 93:17, 224:17};
|
||||
k.down = function(eve){
|
||||
if(eve.repeat){ return }
|
||||
var key = (k.eve = m.eve = eve).which = eve.which || eve.fake || eve.keyCode;
|
||||
if(!eve.fake && key === k.last){ return } k.last = key;
|
||||
@ -30,8 +35,8 @@
|
||||
m.list(k.at.back || m.edit);
|
||||
if(k.at && !k.at.back){ m.flip() }
|
||||
}
|
||||
}
|
||||
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;
|
||||
if(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length){
|
||||
if(k.meta[key]){
|
||||
@ -44,18 +49,18 @@
|
||||
if($(':focus').closest('#meta').length){ return }
|
||||
m.check('up', key);
|
||||
if(-1 === key || 27 === eve.which){ k.wipe() }
|
||||
}
|
||||
m.flip = function(tmp){
|
||||
}
|
||||
m.flip = function(tmp){
|
||||
var board = $('#meta .meta-menu');
|
||||
((tmp === false) || (!tmp && board.is(':visible')))?
|
||||
board.addClass('meta-none')
|
||||
: board.removeClass('meta-none');
|
||||
}
|
||||
m.flip.is = function(){
|
||||
}
|
||||
m.flip.is = function(){
|
||||
return $('#meta .meta-menu').is(':visible');
|
||||
}
|
||||
m.flip.wait = 500;
|
||||
m.check = function(how, key, at){
|
||||
}
|
||||
m.flip.wait = 500;
|
||||
m.check = function(how, key, at){
|
||||
at = k.at || m.edit;
|
||||
var edit = at[key];
|
||||
if(!edit){ return }
|
||||
@ -75,8 +80,8 @@
|
||||
if('up' != how){ return }
|
||||
if(at != edit){ edit.back = at }
|
||||
m.list(edit, true);
|
||||
}
|
||||
m.list = function(at, opt){
|
||||
}
|
||||
m.list = function(at, opt){
|
||||
if(!at){ return m.flip(false) }
|
||||
var l = [];
|
||||
$.each(at, function(i,k){ 'back' != i && k.combo && k.name && l.push(k) });
|
||||
@ -98,8 +103,8 @@
|
||||
$ul.append($('<li>').html('←').one('click', function(){
|
||||
m.list(k.at = at.back);
|
||||
}));
|
||||
}
|
||||
m.ask = function(help, cb){
|
||||
}
|
||||
m.ask = function(help, cb){
|
||||
var $ul = $('#meta .meta-menu ul').empty();
|
||||
var $put = $('<input>').attr('id', 'meta-ask').attr('placeholder', help);
|
||||
var $form = $('<form>').append($put).on('submit', function(eve){
|
||||
@ -112,20 +117,20 @@
|
||||
$ul.append($li);
|
||||
m.flip(true);
|
||||
$put.focus();
|
||||
}
|
||||
k.wipe = function(opt){
|
||||
}
|
||||
k.wipe = function(opt){
|
||||
k.down.meta = false;
|
||||
k.combo = [];
|
||||
if(!opt){ m.flip(false) }
|
||||
m.list(k.at = m.edit);
|
||||
};
|
||||
m.tap = function(){
|
||||
};
|
||||
m.tap = function(){
|
||||
var on = $('.meta-on')
|
||||
.or($($(document.querySelectorAll(':hover')).get().reverse()).first())
|
||||
.or($(document.elementFromPoint(meta.tap.x, meta.tap.y)));
|
||||
return on;
|
||||
}
|
||||
meta.edit = function(edit){
|
||||
}
|
||||
meta.edit = function(edit){
|
||||
var tmp = edit.combow = [];
|
||||
$.each(edit.combo || (edit.combo = []), function(i,k){
|
||||
if(!k || !k.length){ if('number' == typeof k){ tmp.push(k) } return }
|
||||
@ -135,10 +140,12 @@
|
||||
$.each(tmp, function(i,k){ at = at[k] = (++i >= l)? edit : at[k] || {} });
|
||||
edit.combow = edit.combow.join(',');
|
||||
m.list(meta.edit);
|
||||
}
|
||||
})(USE, './metaCore');
|
||||
|
||||
;USE(function(module){try{
|
||||
}
|
||||
|
||||
|
||||
})(USE, './metaCore');
|
||||
;USE(function(module){
|
||||
try{
|
||||
/* UI */
|
||||
if(meta.css){ return }
|
||||
var $m = $('<div>').attr('id', 'meta');
|
||||
@ -228,8 +235,9 @@
|
||||
tag.innerHTML = tmp;
|
||||
document.body.appendChild(tag);
|
||||
}
|
||||
}catch(e){}})(USE, './metaUI');
|
||||
|
||||
}catch(e){}
|
||||
|
||||
})(USE, './metaUI');
|
||||
;USE(function(module){
|
||||
// include basic text editing by default.
|
||||
var monotype = window.monotype || function(){console.log("monotype needed")};
|
||||
@ -372,10 +380,11 @@
|
||||
on: function(eve){ meta.text.editor('fontSize', 7) },
|
||||
up: function(){}
|
||||
});
|
||||
|
||||
|
||||
})(USE, './metaText');
|
||||
|
||||
|
||||
;USE(function(module){
|
||||
var m = meta, k = m.key;
|
||||
$(window).on('blur', k.wipe).on('focus', k.wipe);
|
||||
$(document).on('mousedown mousemove mouseup', function(eve){
|
||||
m.tap.eve = eve;
|
||||
@ -398,6 +407,7 @@
|
||||
});
|
||||
$(document).on('keydown', k.down).on('keyup', k.up);
|
||||
$(document).on('select contextmenu keyup mouseup', '[contenteditable=true]', m.text.on);
|
||||
|
||||
|
||||
})(USE, './metaEvents');
|
||||
|
||||
}());
|
||||
}());
|
||||
|
Loading…
x
Reference in New Issue
Block a user