Commit f32aaca1352e9cd82c3584608228beda59e2a946
update edit to work with @ev's css
Dominic Tarr committed on 7/24/2016, 2:51:46 AMParent: dfad07a874095b2ba27c2b055153cda877a79ded
Files changed
modules/avatar-edit.js | changed |
modules/avatar-edit.js | ||
---|---|---|
@@ -14,14 +14,15 @@ | ||
14 | 14 | var confirm = plugs.first(exports.message_confirm = []) |
15 | 15 | var sbot_blobs_add = plugs.first(exports.sbot_blobs_add = []) |
16 | 16 | var blob_url = plugs.first(exports.blob_url = []) |
17 | 17 | var sbot_links = plugs.first(exports.sbot_links = []) |
18 | +var avatar_name = plugs.first(exports.avatar_name = []) | |
18 | 19 | |
19 | 20 | function crop (d, cb) { |
20 | 21 | var data |
21 | 22 | var canvas = hypercrop(h('img', {src: d})) |
22 | 23 | |
23 | - return h('div.avatar_pic', | |
24 | + return h('div.row.avatar_pic', | |
24 | 25 | canvas, |
25 | 26 | //canvas.selection, |
26 | 27 | h('div.avatar_pic__controls', |
27 | 28 | h('button', 'okay', {onclick: function () { |
@@ -38,71 +39,73 @@ | ||
38 | 39 | |
39 | 40 | var img = h('img', {src: blob_url(default_avatar)}) |
40 | 41 | var lb = hyperlightbox() |
41 | 42 | var name_input = h('input', {placeholder: 'rename'}) |
42 | - var name = h('h2.avatar__name') | |
43 | + var name = avatar_name(id) | |
43 | 44 | var selected = null |
44 | 45 | |
45 | 46 | getAvatar({links: sbot_links}, self_id, id, function (err, avatar) { |
46 | 47 | if (err) return console.error(err) |
47 | 48 | //don't show user has already selected an avatar. |
48 | 49 | if(selected) return |
49 | 50 | if(ref.isBlob(avatar.image)) |
50 | 51 | img.src = blob_url(avatar.image) |
51 | - name.textContent = avatar.name | |
52 | 52 | }) |
53 | 53 | |
54 | - | |
55 | - return h('div', | |
54 | + return h('div.row.profile', | |
56 | 55 | lb, |
57 | - name, | |
58 | 56 | img, |
59 | - name_input, | |
60 | - hyperfile.asDataURL(function (data) { | |
61 | - var el = crop(data, function (err, data) { | |
62 | - if(data) { | |
63 | - img.src = data | |
64 | - selected = dataurl.parse(data) | |
65 | - } | |
66 | - lb.close() | |
67 | - }) | |
68 | - lb.show(el) | |
69 | - }), | |
70 | - h('button', 'update', {onclick: function () { | |
71 | - if(name_input.value) | |
72 | - name.textContent = name_input.value | |
57 | + h('div.column.profile__info', | |
58 | + h('strong', name), | |
59 | + name_input, | |
73 | 60 | |
74 | - if(selected) { | |
75 | - pull( | |
76 | - pull.once(selected.data), | |
77 | - sbot_blobs_add(function (err, hash) { | |
78 | - //TODO. Alerts are EVIL. | |
79 | - //I use them only in a moment of weakness. | |
80 | - if(err) return alert(err.stack) | |
81 | - confirm({ | |
82 | - type: 'about', | |
83 | - about: id, | |
84 | - name: name_input.value || undefined, | |
85 | - image: { | |
86 | - link: hash, | |
87 | - size: selected.data.length, | |
88 | - type: selected.mimetype, | |
89 | - width: 512, | |
90 | - height: 512 | |
91 | - } | |
61 | + hyperfile.asDataURL(function (data) { | |
62 | + var el = crop(data, function (err, data) { | |
63 | + if(data) { | |
64 | + img.src = data | |
65 | + selected = dataurl.parse(data) | |
66 | + } | |
67 | + lb.close() | |
68 | + }) | |
69 | + lb.show(el) | |
70 | + }), | |
71 | + h('button', 'update', {onclick: function () { | |
72 | + if(name_input.value) | |
73 | + name.textContent = name_input.value | |
74 | + | |
75 | + if(selected) { | |
76 | + pull( | |
77 | + pull.once(selected.data), | |
78 | + sbot_blobs_add(function (err, hash) { | |
79 | + //TODO. Alerts are EVIL. | |
80 | + //I use them only in a moment of weakness. | |
81 | + if(err) return alert(err.stack) | |
82 | + confirm({ | |
83 | + type: 'about', | |
84 | + about: id, | |
85 | + name: name_input.value || undefined, | |
86 | + image: { | |
87 | + link: hash, | |
88 | + size: selected.data.length, | |
89 | + type: selected.mimetype, | |
90 | + width: 512, | |
91 | + height: 512 | |
92 | + } | |
93 | + }) | |
92 | 94 | }) |
95 | + ) | |
96 | + } | |
97 | + else if(input.value) //name only | |
98 | + confirm({ | |
99 | + type: 'about', | |
100 | + about: id, | |
101 | + name: name_input.value || undefined, | |
93 | 102 | }) |
94 | - ) | |
95 | - } | |
96 | - else if(input.value) //name only | |
97 | - confirm({ | |
98 | - type: 'about', | |
99 | - about: id, | |
100 | - name: name_input.value || undefined, | |
101 | - }) | |
102 | - else | |
103 | - //another moment of weakness | |
104 | - alert('must select a name or image') | |
105 | - }}) | |
103 | + else | |
104 | + //another moment of weakness | |
105 | + alert('must select a name or image') | |
106 | + }}) | |
107 | + ) | |
106 | 108 | ) |
107 | 109 | } |
108 | 110 | |
111 | + |
Built with git-ssb-web