mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
making more changes, still broken
This commit is contained in:
parent
aad7f679a7
commit
cc040cc733
3 changed files with 53 additions and 18 deletions
|
@ -9,12 +9,15 @@ var helper = {};
|
||||||
// make sure we don't override existing jquery
|
// make sure we don't override existing jquery
|
||||||
jsLibraries.jquery = `if(typeof $ === 'undefined') {\n${code}\n}`;
|
jsLibraries.jquery = `if(typeof $ === 'undefined') {\n${code}\n}`;
|
||||||
|
|
||||||
$.get('/tests/frontend/lib/sendkeys.js').done((code) => {
|
$.get('/tests/frontend/lib/bililiteRange.js').done((code) => {
|
||||||
jsLibraries.sendkeys = code;
|
jsLibraries.bililiteRange = code;
|
||||||
|
|
||||||
|
$.get('/tests/frontend/lib/jquery.sendkeys.js').done((code) => {
|
||||||
|
jsLibraries.sendkeys = code;
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
helper.randomString = function randomString(len) {
|
helper.randomString = function randomString(len) {
|
||||||
|
@ -41,6 +44,7 @@ var helper = {};
|
||||||
win.execScript && win.execScript('null');
|
win.execScript && win.execScript('null');
|
||||||
|
|
||||||
win.eval(jsLibraries.jquery);
|
win.eval(jsLibraries.jquery);
|
||||||
|
win.eval(jsLibraries.bililiteRange);
|
||||||
win.eval(jsLibraries.sendkeys);
|
win.eval(jsLibraries.sendkeys);
|
||||||
|
|
||||||
win.$.window = win;
|
win.$.window = win;
|
||||||
|
|
|
@ -666,3 +666,4 @@ bililiteRange.createOption = function (name, desc = {}){
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
30
tests/frontend/lib/jquery.sendkeys.js
Normal file
30
tests/frontend/lib/jquery.sendkeys.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
(function($){
|
||||||
|
|
||||||
|
$.fn.sendkeys = function (x){
|
||||||
|
return this.each( function(){
|
||||||
|
bililiteRange(this).bounds('selection').sendkeys(x).select();
|
||||||
|
this.focus();
|
||||||
|
});
|
||||||
|
}; // sendkeys
|
||||||
|
|
||||||
|
// add a default handler for keydowns so that we can send keystrokes, even though code-generated events
|
||||||
|
// are untrusted (http://www.w3.org/TR/DOM-Level-3-Events/#trusted-events)
|
||||||
|
// documentation of special event handlers is at http://learn.jquery.com/events/event-extensions/
|
||||||
|
$.event.special.keydown = $.event.special.keydown || {};
|
||||||
|
$.event.special.keydown._default = function (evt){
|
||||||
|
if (evt.isTrusted) return false;
|
||||||
|
if (evt.key == null) return false; // nothing to print. Use the keymap plugin to set this
|
||||||
|
if (evt.ctrlKey || evt.altKey || evt.metaKey) return false; // only deal with printable characters.
|
||||||
|
var target = evt.target;
|
||||||
|
if (target.isContentEditable || target.nodeName == 'INPUT' || target.nodeName == 'TEXTAREA') {
|
||||||
|
// only insert into editable elements
|
||||||
|
var key = evt.key;
|
||||||
|
if (key.length > 1 && key.charAt(0) != '{') key = '{'+key+'}'; // sendkeys notation
|
||||||
|
$(target).sendkeys(key);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})(jQuery)
|
Loading…
Add table
Add a link
Reference in a new issue