|
@@ -1,155 +1,190 @@
|
|
;(function(){
|
|
;(function(){
|
|
- var noop = function(){}, u;
|
|
|
|
- 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;
|
|
|
|
- if(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length){
|
|
|
|
- if(k.meta[key]){ k.down.meta = key = -1 }
|
|
|
|
- if(!k.down.meta){ return }
|
|
|
|
|
|
+ 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 }
|
|
|
|
+
|
|
|
|
+ /* 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}; // ctrl met
|
|
|
|
+
|
|
|
|
+ function withMeta(eve){ return eve.metaKey || eve.ctrlKey }
|
|
|
|
+
|
|
|
|
+ k.down = function(eve){
|
|
|
|
+ if(eve.repeat){ return }
|
|
|
|
+ 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(!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 && $(eve.target).closest('input, textarea, [contenteditable=true]').length && !$(eve.target).closest('#meta').length){
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+ m.check('on', key, k.at || (k.at = m.edit));
|
|
|
|
+ if(k.meta[key]){
|
|
|
|
+ // m.list(k.at.back || m.edit);
|
|
|
|
+ // if(k.at){ m.flip() } // && !k.at.back
|
|
|
|
+ m.flip()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- (k.combo || (k.combo = [])).push(key);
|
|
|
|
- m.check('on', key, k.at || (k.at = m.edit));
|
|
|
|
- if(k.meta[key]){
|
|
|
|
- m.list(k.at.back || m.edit);
|
|
|
|
- if(k.at && !k.at.back){ m.flip() }
|
|
|
|
|
|
+ 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(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length){
|
|
|
|
+ // if(k.meta[key]){
|
|
|
|
+ // k.down.meta = null;
|
|
|
|
+ // key = -1;
|
|
|
|
+ // } else
|
|
|
|
+ // if(!k.down.meta){ return }
|
|
|
|
+ // }
|
|
|
|
+ k.last = null;
|
|
|
|
+ // if($(':focus').closest('#meta').length){ return }
|
|
|
|
+ m.check('up', key);
|
|
|
|
+ if(27 === eve.which){ k.wipe() } // -1 === key ||
|
|
}
|
|
}
|
|
- }
|
|
|
|
- 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]){
|
|
|
|
- k.down.meta = null;
|
|
|
|
- key = -1;
|
|
|
|
- } else
|
|
|
|
- if(!k.down.meta){ return }
|
|
|
|
|
|
+ m.flip = function(tmp){
|
|
|
|
+ var board = $('#meta .meta-menu');
|
|
|
|
+ ((tmp === false) || (!tmp && board.is(':visible')))?
|
|
|
|
+ board.addClass('meta-none')
|
|
|
|
+ : board.removeClass('meta-none');
|
|
}
|
|
}
|
|
- k.last = null;
|
|
|
|
- if($(':focus').closest('#meta').length){ return }
|
|
|
|
- m.check('up', key);
|
|
|
|
- if(-1 === key || 27 === eve.which){ k.wipe() }
|
|
|
|
- }
|
|
|
|
- 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(){
|
|
|
|
- return $('#meta .meta-menu').is(':visible');
|
|
|
|
- }
|
|
|
|
- m.flip.wait = 500;
|
|
|
|
- m.check = function(how, key, at){
|
|
|
|
- at = k.at || m.edit;
|
|
|
|
- var edit = at[key];
|
|
|
|
- if(!edit){ return }
|
|
|
|
- var tmp = k.eve || noop;
|
|
|
|
- if(tmp.preventDefault){ tmp.preventDefault() }
|
|
|
|
- if(edit[how]){
|
|
|
|
- if(tmp.fake && !edit.fake){
|
|
|
|
- m.tap.edit = edit;
|
|
|
|
- } else {
|
|
|
|
- edit[how](m.eve);
|
|
|
|
- /*if(k.at !== m.edit && 'up' === how){
|
|
|
|
- if(k.down.meta){ m.list(k.at = m.edit) }
|
|
|
|
- else { k.wipe() }
|
|
|
|
- }*/
|
|
|
|
|
|
+ m.flip.is = function(){
|
|
|
|
+ return $('#meta .meta-menu').is(':visible');
|
|
|
|
+ }
|
|
|
|
+ m.flip.wait = 500;
|
|
|
|
+ m.check = function(how, key, at){
|
|
|
|
+ at = k.at || m.edit;
|
|
|
|
+ var next = at[key];
|
|
|
|
+ if(!next){ return }
|
|
|
|
+ var tmp = k.eve || noop;
|
|
|
|
+ if(tmp.preventDefault){ tmp.preventDefault()} // prevent typing (etc) when action found
|
|
|
|
+ if(next[how]){
|
|
|
|
+ //if(tmp.fake && !next.fake){
|
|
|
|
+ //m.tap.next = next;
|
|
|
|
+ //} else {
|
|
|
|
+ next[how](m.eve);
|
|
|
|
+ meta.ui.blink()
|
|
|
|
+ /*if(k.at !== m.next && 'up' === how){
|
|
|
|
+ if(k.down.meta){ m.list(k.at = m.next) }
|
|
|
|
+ else { k.wipe() }
|
|
|
|
+ }*/
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
|
|
+ if('up' == how){ return }
|
|
|
|
+ if(at != next){ next.back = at }
|
|
|
|
+ (k.combo || (k.combo = [])).push(key);
|
|
|
|
+ m.list(next, true);
|
|
}
|
|
}
|
|
- if('up' != how){ return }
|
|
|
|
- if(at != edit){ edit.back = at }
|
|
|
|
- m.list(edit, true);
|
|
|
|
- }
|
|
|
|
- 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) });
|
|
|
|
- if(!l.length){ return }
|
|
|
|
- k.at = at;
|
|
|
|
- l = l.sort(function(a,b){
|
|
|
|
- a = a.combo.slice(-1)[0] || 0;
|
|
|
|
- if(a.length){ a = a.toUpperCase().charCodeAt(0) }
|
|
|
|
- b = b.combo.slice(-1)[0] || 0;
|
|
|
|
- if(b.length){ b = b.toUpperCase().charCodeAt(0) }
|
|
|
|
- return (a < b)? -1 : 1;
|
|
|
|
- });
|
|
|
|
- var $ul = $('#meta .meta-menu ul')
|
|
|
|
- $ul.children('li').addClass('meta-none').hide(); setTimeout(function(){ $ul.children('.meta-none').remove() },250); // necessary fix for weird bug glitch
|
|
|
|
- $.each(l, function(i, k){
|
|
|
|
- $ul.append($('<li>').text(k.name));
|
|
|
|
- });
|
|
|
|
- if(opt){ m.flip(true) }
|
|
|
|
- $ul.append($('<li>').html('←').one('click', function(){
|
|
|
|
- m.list(k.at = at.back);
|
|
|
|
- }));
|
|
|
|
- }
|
|
|
|
- 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){
|
|
|
|
- eve.preventDefault();
|
|
|
|
- cb($put.val());
|
|
|
|
- $li.remove();
|
|
|
|
- k.wipe();
|
|
|
|
- });
|
|
|
|
- var $li = $('<li>').append($form);
|
|
|
|
- $ul.append($li);
|
|
|
|
- m.flip(true);
|
|
|
|
- $put.focus();
|
|
|
|
- }
|
|
|
|
- k.wipe = function(opt){
|
|
|
|
- k.down.meta = false;
|
|
|
|
- k.combo = [];
|
|
|
|
- if(!opt){ m.flip(false) }
|
|
|
|
- m.list(k.at = m.edit);
|
|
|
|
- };
|
|
|
|
- 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;
|
|
|
|
- }
|
|
|
|
- $(window).on('blur', k.wipe).on('focus', k.wipe);
|
|
|
|
- $(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);
|
|
|
|
- }).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){
|
|
|
|
- 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;
|
|
|
|
- k.down(eve);
|
|
|
|
- k.up(eve);
|
|
|
|
- });
|
|
|
|
- $(document).on('keydown', k.down).on('keyup', k.up);
|
|
|
|
- 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 }
|
|
|
|
- tmp.push(k.toUpperCase().charCodeAt(0));
|
|
|
|
- });
|
|
|
|
- var at = meta.edit, l = edit.combo.length;
|
|
|
|
- $.each(tmp, function(i,k){ at = at[k] = (++i >= l)? edit : at[k] || {} });
|
|
|
|
- edit.combow = edit.combow.join(',');
|
|
|
|
- m.list(meta.edit);
|
|
|
|
- }
|
|
|
|
- $.fn.or = function(s){ return this.length ? this : $(s||'body') };
|
|
|
|
- ;(function(){try{
|
|
|
|
|
|
+ m.list = function(at, opt){
|
|
|
|
+ if(!at){ return m.flip(false) }
|
|
|
|
+ // m.ui.depth(m.key.combo ? m.key.combo.length : 0)
|
|
|
|
+ var l = [];
|
|
|
|
+ $.each(at, function(i,k){ 'back' != i && k.combo && k.name && l.push(k) });
|
|
|
|
+ if(!l.length){ return }
|
|
|
|
+ k.at = at;
|
|
|
|
+ l = l.sort(function(a,b){
|
|
|
|
+ a = a.combo.slice(-1)[0] || 0;
|
|
|
|
+ if(a.length){ a = a.toUpperCase().charCodeAt(0) }
|
|
|
|
+ b = b.combo.slice(-1)[0] || 0;
|
|
|
|
+ if(b.length){ b = b.toUpperCase().charCodeAt(0) }
|
|
|
|
+ return (a < b)? -1 : 1;
|
|
|
|
+ });
|
|
|
|
+ var $ul = $('#meta .meta-menu ul')
|
|
|
|
+ $ul.children('li').addClass('meta-none').hide(); setTimeout(function(){ $ul.children('.meta-none').remove() },250); // necessary fix for weird bug glitch
|
|
|
|
+ $.each(l, function(i, k){
|
|
|
|
+ $ul.append($('<li>').text(k.name).data(k));
|
|
|
|
+ });
|
|
|
|
+ if(opt){ m.flip(true) }
|
|
|
|
+ $ul.append($('<li>').html('←').on('click', function(){
|
|
|
|
+ // m.key.combo.pop()
|
|
|
|
+ m.list(at.back);
|
|
|
|
+ }));
|
|
|
|
+ }
|
|
|
|
+ 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){
|
|
|
|
+ eve.preventDefault();
|
|
|
|
+ cb($put.val());
|
|
|
|
+ $li.remove();
|
|
|
|
+ //k.wipe();
|
|
|
|
+ m.list(k.at);
|
|
|
|
+ });
|
|
|
|
+ var $li = $('<li>').append($form);
|
|
|
|
+ $ul.append($li);
|
|
|
|
+ m.flip(true);
|
|
|
|
+ $put.focus();
|
|
|
|
+ }
|
|
|
|
+ k.wipe = function(opt){
|
|
|
|
+ // k.down.meta = false;
|
|
|
|
+ k.combo = [];
|
|
|
|
+ if(!opt){ m.flip(false) }
|
|
|
|
+ m.list(k.at = m.edit);
|
|
|
|
+ };
|
|
|
|
+ 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)));
|
|
|
|
+ return on;
|
|
|
|
+ }
|
|
|
|
+ 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 }
|
|
|
|
+ tmp.push(k.toUpperCase().charCodeAt(0));
|
|
|
|
+ });
|
|
|
|
+ var at = meta.edit, l = edit.combo.length;
|
|
|
|
+ $.each(tmp, function(i,k){ at = at[k] = (++i >= l)? edit : at[k] || {} });
|
|
|
|
+ edit.combow = edit.combow.join(',');
|
|
|
|
+ m.list(k.at || meta.edit);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ })(USE, './metaCore');
|
|
|
|
+ ;USE(function(module){
|
|
/* UI */
|
|
/* UI */
|
|
- if(meta.css){ return }
|
|
|
|
|
|
+ meta.ui = {
|
|
|
|
+ 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
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ depth: function(n){
|
|
|
|
+ if (n) {
|
|
|
|
+ $('#meta').css('background', 'hsl(60, 100%,'+(85-(n*10))+'%)');
|
|
|
|
+ } else {
|
|
|
|
+ $('#meta')[0].style.background = null
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
var $m = $('<div>').attr('id', 'meta');
|
|
var $m = $('<div>').attr('id', 'meta');
|
|
- $m.append($('<span>').text('+').addClass('meta-start'));
|
|
|
|
|
|
+ $m.append($('<span>').html('☰').addClass('meta-start'));
|
|
$m.append($('<div>').addClass('meta-menu meta-none').append('<ul>'));
|
|
$m.append($('<div>').addClass('meta-menu meta-none').append('<ul>'));
|
|
$(document.body).append($m);
|
|
$(document.body).append($m);
|
|
css({
|
|
css({
|
|
@@ -161,7 +196,7 @@
|
|
background: 'white',
|
|
background: 'white',
|
|
'font-size': '18pt',
|
|
'font-size': '18pt',
|
|
'font-family': 'Tahoma, arial',
|
|
'font-family': 'Tahoma, arial',
|
|
- 'box-shadow': '0px 0px 1px #000044',
|
|
|
|
|
|
+ //'box-shadow': '0px 0px 1px #000044',
|
|
'border-radius': '1em',
|
|
'border-radius': '1em',
|
|
'text-align': 'center',
|
|
'text-align': 'center',
|
|
'z-index': 999999,
|
|
'z-index': 999999,
|
|
@@ -202,25 +237,26 @@
|
|
'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},
|
|
'#meta .meta-menu ul:before': {
|
|
'#meta .meta-menu ul:before': {
|
|
content: "' '",
|
|
content: "' '",
|
|
display: 'block',
|
|
display: 'block',
|
|
'min-height': '15em',
|
|
'min-height': '15em',
|
|
height: '50vh'
|
|
height: '50vh'
|
|
},
|
|
},
|
|
- '#meta li': {
|
|
|
|
- background: 'white',
|
|
|
|
- padding: '0.5em 1em',
|
|
|
|
- 'border-radius': '1em',
|
|
|
|
- 'margin-left': '0.25em',
|
|
|
|
- 'margin-top': '0.25em',
|
|
|
|
- 'float': 'right'
|
|
|
|
- },
|
|
|
|
- '#meta:hover .meta-menu': {display: 'block'}
|
|
|
|
|
|
+ // '#meta li': {
|
|
|
|
+ // background: 'white',
|
|
|
|
+ // padding: '0.5em 1em',
|
|
|
|
+ // 'border-radius': '1em',
|
|
|
|
+ // 'margin-left': '0.25em',
|
|
|
|
+ // 'margin-top': '0.25em',
|
|
|
|
+ // 'float': 'right'
|
|
|
|
+ // },
|
|
|
|
+ // '#meta:hover .meta-menu': {display: 'block'}
|
|
});
|
|
});
|
|
function css(css){
|
|
function css(css){
|
|
var tmp = '';
|
|
var tmp = '';
|
|
@@ -233,10 +269,14 @@
|
|
});
|
|
});
|
|
var tag = document.createElement('style');
|
|
var tag = document.createElement('style');
|
|
tag.innerHTML = tmp;
|
|
tag.innerHTML = tmp;
|
|
- document.body.appendChild(tag);
|
|
|
|
|
|
+ $m.append(tag)
|
|
}
|
|
}
|
|
- }catch(e){}}());
|
|
|
|
- ;(function(){
|
|
|
|
|
|
+ //}catch(e){}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ })(USE, './metaUI');
|
|
|
|
+ ;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;
|
|
@@ -256,7 +296,6 @@
|
|
return ((tmp = window.getSelection) && tmp().toString()) ||
|
|
return ((tmp = window.getSelection) && tmp().toString()) ||
|
|
((tmp = document.selection) && tmp.createRange().text) || '';
|
|
((tmp = document.selection) && tmp.createRange().text) || '';
|
|
}
|
|
}
|
|
- $(document).on('select contextmenu keyup mouseup', '[contenteditable=true]', m.text.on);
|
|
|
|
m.text.editor = function(opt, as){ var tmp;
|
|
m.text.editor = function(opt, as){ var tmp;
|
|
if(!opt){ return }
|
|
if(!opt){ return }
|
|
opt = (typeof opt == 'string')? {edit: opt} : opt.tag? opt : {tag: opt};
|
|
opt = (typeof opt == 'string')? {edit: opt} : opt.tag? opt : {tag: opt};
|
|
@@ -266,7 +305,7 @@
|
|
r.restore();
|
|
r.restore();
|
|
if(document.execCommand(cmd, null, as||null)){
|
|
if(document.execCommand(cmd, null, as||null)){
|
|
if(m.text.range){ m.text.range = monotype() }
|
|
if(m.text.range){ m.text.range = monotype() }
|
|
- return;
|
|
|
|
|
|
+ return meta.flip(false); // ADDED meta.flip
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(!opt.tag){ return }
|
|
if(!opt.tag){ return }
|
|
@@ -379,5 +418,54 @@
|
|
on: function(eve){ meta.text.editor('fontSize', 7) },
|
|
on: function(eve){ meta.text.editor('fontSize', 7) },
|
|
up: function(){}
|
|
up: function(){}
|
|
});
|
|
});
|
|
- }());
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ })(USE, './metaText');
|
|
|
|
+ ;USE(function(module){
|
|
|
|
+ var m = meta, k = m.key;
|
|
|
|
+ $(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;
|
|
|
|
+ //});
|
|
|
|
+
|
|
|
|
+ //$(document).on('touchstart', '#meta .meta-start', function(eve){ m.tap.stun = true });
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+ $(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;
|
|
|
|
+ // k.down(eve);
|
|
|
|
+ // k.up(eve);
|
|
|
|
+ });
|
|
|
|
+ $(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);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ })(USE, './metaEvents');
|
|
}());
|
|
}());
|