Commit bddebc2c1c0600b889bc609f0f07eba6087ce56f
hide compose controls when textarea is not focused
Dominic Tarr committed on 6/20/2016, 2:59:33 AMParent: b5c29f60805936095ac67ab8d047006f7de94d56
Files changed
modules/compose.js | changed |
modules/compose.js | ||
---|---|---|
@@ -14,30 +14,31 @@ | ||
14 | 14 | var file_input = plugs.first(exports.file_input = []) |
15 | 15 | |
16 | 16 | exports.suggest = [] |
17 | 17 | |
18 | -//this decorator expects to be the first | |
19 | - | |
20 | 18 | function id (e) { return e } |
21 | 19 | |
22 | 20 | exports.message_compose = function (meta, prepublish, cb) { |
23 | 21 | if('function' !== typeof prepublish) |
24 | 22 | sbot = prepublish, prepublish = id |
23 | + var accessories | |
25 | 24 | meta = meta || {} |
26 | 25 | if(!meta.type) throw new Error('message must have type') |
27 | 26 | var ta = h('textarea') |
28 | 27 | |
29 | 28 | var blur |
30 | 29 | ta.addEventListener('focus', function () { |
31 | 30 | clearTimeout(blur) |
32 | 31 | ta.style.height = '200px' |
32 | + accessories.style.display = 'block' | |
33 | 33 | }) |
34 | 34 | ta.addEventListener('blur', function () { |
35 | 35 | //don't shrink right away, so there is time |
36 | 36 | //to click the publish button. |
37 | 37 | clearTimeout(blur) |
38 | 38 | blur = setTimeout(function () { |
39 | 39 | ta.style.height = '50px' |
40 | + accessories.style.display = 'none' | |
40 | 41 | }, 200) |
41 | 42 | }) |
42 | 43 | |
43 | 44 | ta.addEventListener('keydown', function (ev) { |
@@ -62,9 +63,11 @@ | ||
62 | 63 | |
63 | 64 | |
64 | 65 | var composer = |
65 | 66 | h('div', h('div.column', ta, |
66 | - h('div.row', | |
67 | + accessories = h('div.row', | |
68 | + //hidden until you focus the textarea | |
69 | + {style: {display: 'none'}}, | |
67 | 70 | file_input(function (file) { |
68 | 71 | files.push(file) |
69 | 72 | |
70 | 73 | var embed = file.type.indexOf('image/') === 0 ? '!' : '' |
@@ -94,4 +97,5 @@ | ||
94 | 97 | return composer |
95 | 98 | |
96 | 99 | } |
97 | 100 | |
101 | + |
Built with git-ssb-web