git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit f32aaca1352e9cd82c3584608228beda59e2a946

update edit to work with @ev's css

Dominic Tarr committed on 7/24/2016, 2:51:46 AM
Parent: dfad07a874095b2ba27c2b055153cda877a79ded

Files changed

modules/avatar-edit.jschanged
modules/avatar-edit.jsView
@@ -14,14 +14,15 @@
1414 var confirm = plugs.first(exports.message_confirm = [])
1515 var sbot_blobs_add = plugs.first(exports.sbot_blobs_add = [])
1616 var blob_url = plugs.first(exports.blob_url = [])
1717 var sbot_links = plugs.first(exports.sbot_links = [])
18+var avatar_name = plugs.first(exports.avatar_name = [])
1819
1920 function crop (d, cb) {
2021 var data
2122 var canvas = hypercrop(h('img', {src: d}))
2223
23- return h('div.avatar_pic',
24+ return h('div.row.avatar_pic',
2425 canvas,
2526 //canvas.selection,
2627 h('div.avatar_pic__controls',
2728 h('button', 'okay', {onclick: function () {
@@ -38,71 +39,73 @@
3839
3940 var img = h('img', {src: blob_url(default_avatar)})
4041 var lb = hyperlightbox()
4142 var name_input = h('input', {placeholder: 'rename'})
42- var name = h('h2.avatar__name')
43+ var name = avatar_name(id)
4344 var selected = null
4445
4546 getAvatar({links: sbot_links}, self_id, id, function (err, avatar) {
4647 if (err) return console.error(err)
4748 //don't show user has already selected an avatar.
4849 if(selected) return
4950 if(ref.isBlob(avatar.image))
5051 img.src = blob_url(avatar.image)
51- name.textContent = avatar.name
5252 })
5353
54-
55- return h('div',
54+ return h('div.row.profile',
5655 lb,
57- name,
5856 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,
7360
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+ })
9294 })
95+ )
96+ }
97+ else if(input.value) //name only
98+ confirm({
99+ type: 'about',
100+ about: id,
101+ name: name_input.value || undefined,
93102 })
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+ )
106108 )
107109 }
108110
111+

Built with git-ssb-web