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