modules_basic/compose.jsView |
---|
26 | 26 … | 'message_compose': true, |
27 | 27 … | 'mcss': true |
28 | 28 … | } |
29 | 29 … | |
30 | | - |
31 | | - opts can take |
32 | | - |
33 | | - placeholder: string. placeholder text, defaults to "Write a message" |
34 | | - prepublish: function. called before publishing a message. |
35 | | - shrink: boolean. set to false, to make composer not shrink (or hide controls) when unfocused. |
36 | | -*/ |
37 | | - |
38 | 30 … | exports.create = function (api) { |
39 | 31 … | return { |
40 | 32 … | message_compose, |
41 | 33 … | mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8') |
42 | 34 … | } |
43 | 35 … | |
44 | | - function message_compose (meta, opts, cb) { |
| 36 … | + |
| 37 … | + opts can take |
| 38 … | + |
| 39 … | + placeholder: string. placeholder text, defaults to "Write a message" |
| 40 … | + prepublish: function. called before publishing a message. |
| 41 … | + shrink: boolean. set to false, to make composer not shrink (or hide controls) when unfocused. |
| 42 … | + */ |
| 43 … | + |
| 44 … | + function message_compose (meta = {}, opts = {}, cb) { |
| 45 … | + if(!meta.type) throw new Error('message must have type') |
| 46 … | + |
45 | 47 … | if('function' === typeof cb) { |
46 | 48 … | if('function' === typeof opts) { |
47 | 49 … | opts = {prepublish: opts} |
48 | 50 … | } |
49 | 51 … | } |
50 | | - |
51 | | - if(!opts) opts = {} |
52 | 52 … | opts.prepublish = opts.prepublish || id |
53 | 53 … | |
54 | 54 … | var actions |
55 | | - meta = meta || {} |
56 | | - if(!meta.type) throw new Error('message must have type') |
57 | 55 … | |
58 | 56 … | var textArea = h('textarea', { |
59 | 57 … | placeholder: opts.placeholder || 'Write a message', |
60 | 58 … | className: opts.shrink === false ? '-expanded' : '-contracted' |