open pad links when clicking in readOnly mode
This commit is contained in:
parent
35867001cb
commit
dc7db074e8
@ -299,6 +299,13 @@ define([
|
||||
|
||||
var DD = new DiffDom(diffOptions);
|
||||
|
||||
var openLink = function (e) {
|
||||
var el = e.currentTarget;
|
||||
if (!el || el.nodeName !== 'A') { return; }
|
||||
var href = el.getAttribute('href');
|
||||
if (href) { window.open(href, '_blank'); }
|
||||
};
|
||||
|
||||
// apply patches, and try not to lose the cursor in the process!
|
||||
var applyHjson = function (shjson) {
|
||||
var userDocStateDom = hjsonToDom(JSON.parse(shjson));
|
||||
@ -308,6 +315,11 @@ define([
|
||||
}
|
||||
var patch = (DD).diff(inner, userDocStateDom);
|
||||
(DD).apply(inner, patch);
|
||||
if (readOnly) {
|
||||
var $links = $(inner).find('a');
|
||||
// off so that we don't end up with multiple identical handlers
|
||||
$links.off('click', openLink).on('click', openLink);
|
||||
}
|
||||
};
|
||||
|
||||
var stringifyDOM = module.stringifyDOM = function (dom) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user