git ssb

16+

Dominic / patchbay



Commit ad23c51739a9c39fa2d90bfddd96180e3ed7e167

Merge branch 'master' of ssb://%s9mSFATE4RGyJx9wgH22lBrvD4CgUQW4yeguSWWjtqc=.sha256

Ev Bogue committed on 9/19/2016, 12:33:05 AM
Parent: 48f815c98ba097ec6e2176c0b6727e86e8c74c2a
Parent: d51b8fed651af505d28c0cf396cc706e6bd0e9af

Files changed

modules/compose.jschanged
modules/private.jschanged
modules/public.jschanged
modules/thread.jschanged
package.jsonchanged
modules/compose.jsView
@@ -1,4 +1,5 @@
1 +'use strict'
12 var h = require('hyperscript')
23 var u = require('../util')
34 var suggest = require('suggest-box')
45 var cont = require('cont')
@@ -16,35 +17,54 @@
1617 exports.suggest = []
1718
1819 function id (e) { return e }
1920
20-exports.message_compose = function (meta, prepublish, cb) {
21- if('function' !== typeof prepublish)
22- sbot = prepublish, prepublish = id
21 +/*
22 + opts can take
23 +
24 + placeholder: string. placeholder text, defaults to "Write a message"
25 + prepublish: function. called before publishing a message.
26 + shrink: boolean. set to false, to make composer not shrink (or hide controls) when unfocused.
27 +*/
28 +
29 +exports.message_compose = function (meta, opts, cb) {
30 + if('function' === typeof cb) {
31 + if('function' === typeof opts)
32 + opts = {prepublish: opts}
33 + }
34 +
35 + if(!opts) opts = {}
36 + opts.prepublish = opts.prepublish || id
37 +
2338 var accessories
2439 meta = meta || {}
2540 if(!meta.type) throw new Error('message must have type')
26- var ta = h('textarea', {placeholder: 'Write a message'})
27-
28- var blur
29- ta.addEventListener('focus', function () {
30- clearTimeout(blur)
31- if(!ta.value) {
32- ta.style.height = '200px'
33- }
34- accessories.style.display = 'block'
41 + var ta = h('textarea', {
42 + placeholder: opts.placeholder || 'Write a message',
43 + style: {height: opts.shrink === false ? '200px' : ''}
3544 })
36- ta.addEventListener('blur', function () {
37- //don't shrink right away, so there is time
38- //to click the publish button.
39- clearTimeout(blur)
40- blur = setTimeout(function () {
41- if(ta.value) return
42- ta.style.height = '50px'
43- accessories.style.display = 'none'
44- }, 200)
45- })
4645
46 + if(opts.shrink !== false) {
47 + var blur
48 + ta.addEventListener('focus', function () {
49 + clearTimeout(blur)
50 + if(!ta.value) {
51 + ta.style.height = '200px'
52 + }
53 + accessories.style.display = 'block'
54 + })
55 + ta.addEventListener('blur', function () {
56 + //don't shrink right away, so there is time
57 + //to click the publish button.
58 + clearTimeout(blur)
59 + blur = setTimeout(function () {
60 + if(ta.value) return
61 + ta.style.height = '50px'
62 + accessories.style.display = 'none'
63 + }, 200)
64 + })
65 + }
66 +
4767 ta.addEventListener('keydown', function (ev) {
4868 if(ev.keyCode === 13 && ev.ctrlKey) publish()
4969 })
5070
@@ -67,9 +87,9 @@
6787 }
6888 return mention
6989 })
7090 try {
71- meta = prepublish(meta)
91 + meta = opts.prepublish(meta)
7292 } catch (err) {
7393 publishBtn.disabled = false
7494 if (cb) cb(err)
7595 else alert(err.message)
@@ -92,9 +112,9 @@
92112 var composer =
93113 h('div.compose', h('div.column', ta,
94114 accessories = h('div.row.compose__controls',
95115 //hidden until you focus the textarea
96- {style: {display: 'none'}},
116 + {style: {display: opts.shrink === false ? '' : 'none'}},
97117 file_input(function (file) {
98118 files.push(file)
99119 filesById[file.link] = file
100120
@@ -125,4 +145,6 @@
125145 return composer
126146
127147 }
128148
149 +
150 +
modules/private.jsView
@@ -33,17 +33,21 @@
3333
3434
3535 var id = require('../keys').id
3636 var compose = message_compose(
37- {type: 'post', recps: [], private: true},
38- function (msg) {
39- msg.recps = [id].concat(msg.mentions).filter(function (e) {
40- return ref.isFeed('string' === typeof e ? e : e.link)
41- })
42- if(!msg.recps.length)
43- throw new Error('cannot make private message without recipients - just mention the user in an at reply in the message you send')
44- return msg
45- })
37 + {type: 'post', recps: [], private: true},
38 + {
39 + prepublish: function (msg) {
40 + msg.recps = [id].concat(msg.mentions).filter(function (e) {
41 + return ref.isFeed('string' === typeof e ? e : e.link)
42 + })
43 + if(!msg.recps.length)
44 + throw new Error('cannot make private message without recipients - just mention the user in an at reply in the message you send')
45 + return msg
46 + },
47 + placeholder: 'Write a private message'
48 + }
49 + )
4650
4751 var content = h('div.column.scroller__content')
4852 var div = h('div.column.scroller',
4953 {style: {'overflow':'auto'}},
@@ -78,4 +82,6 @@
7882 return avatar_image_link('string' == typeof id ? id : id.link, 'thumbnail')
7983 }))
8084 }
8185
86 +
87 +
modules/public.jsView
@@ -15,9 +15,9 @@
1515 var content = h('div.column.scroller__content')
1616 var div = h('div.column.scroller',
1717 {style: {'overflow':'auto'}},
1818 h('div.scroller__wrapper',
19- message_compose({type: 'post'}), //header
19 + message_compose({type: 'post'}, {placeholder: 'Write a public message'}),
2020 content
2121 )
2222 )
2323
modules/thread.jsView
@@ -49,9 +49,9 @@
4949 })
5050
5151 }
5252
53-exports.screen_view = function (id, sbot) {
53 +exports.screen_view = function (id) {
5454 if(ref.isMsg(id)) {
5555 var meta = {
5656 type: 'post',
5757 root: id,
@@ -62,9 +62,9 @@
6262 var div = h('div.column.scroller',
6363 {style: {'overflow-y': 'auto'}},
6464 h('div.scroller__wrapper',
6565 content,
66- message_compose(meta)
66 + message_compose(meta, {shrink: false, placeholder: 'Write a reply'})
6767 )
6868 )
6969
7070 pull(
package.jsonView
@@ -1,8 +1,8 @@
11 {
22 "name": "patchbay",
33 "description": "a pluggable patchwork",
4- "version": "3.1.0",
4 + "version": "3.1.1",
55 "homepage": "https://github.com/dominictarr/patchbay",
66 "repository": {
77 "type": "git",
88 "url": "git://github.com/dominictarr/patchbay.git"

Built with git-ssb-web