Merge remote-tracking branch 'ui/master'

This commit is contained in:
Zaid Abdulla committed 2018-12-27 22:22:44 -08:00
commit 4530967b6b
70 files changed
+10951 -8

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
"use strict";
import m from "mithril";
import * as overlay from "./overlay";
const component = {
view: vnode => {
const text = vnode.attrs.text;
const element = vnode.attrs.element || "span";
function overflowed(_vnode) {
if (_vnode.dom.classList.contains("long-text-overflowed")) return;
_vnode.dom.classList.add("long-text-overflowed");
_vnode.dom.onclick = e => {
overlay.open(() => {
return m("textarea.long-text", {
value: text,
cols: 80,
rows: 24,
readonly: "",
oncreate: vnode2 => {
vnode2.dom.focus();
vnode2.dom.select();
}
});
});
// prevent index page selection
e.stopPropagation();
m.redraw();
};
}
return m(
element,
{
oncreate: vnode2 => {
if (vnode2.dom.clientWidth !== vnode2.dom.scrollWidth)
overflowed(vnode2);
},
onupdate: vnode2 => {
if (vnode2.dom.clientWidth === vnode2.dom.scrollWidth) {
vnode2.dom.classList.remove("long-text-overflowed");
vnode2.dom.onclick = null;
} else {
overflowed(vnode2);
}
},
class: "long-text",
title: text
},
text
);
}
};
export default component;