Skip to content

Commit

Permalink
Render a hidden form field for a single channel
Browse files Browse the repository at this point in the history
  • Loading branch information
nickstenning committed Feb 25, 2016
1 parent e3d3194 commit ae93c74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
10 changes: 5 additions & 5 deletions lib/assets/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ var body = document.body;
var request = superagent;

// elements
var select = body.querySelector('select');
var input = body.querySelector('input');
var coc = body.querySelector('input[name=coc]');
var form = body.querySelector('form#invite');
var channel = form.elements['channel'];
var email = form.elements['email'];
var coc = form.elements['coc'];
var button = body.querySelector('button');

// remove loading state
Expand All @@ -18,8 +19,7 @@ body.addEventListener('submit', function(ev){
button.disabled = true;
button.className = '';
button.innerHTML = 'Please Wait';
var channel = select ? select.value : null;
invite(channel, coc && coc.checked ? 1 : 0, input.value, function(err, msg){
invite(channel.value, coc && coc.checked ? 1 : 0, email.value, function(err, msg){
if (err) {
button.removeAttribute('disabled');
button.className = 'error';
Expand Down
19 changes: 12 additions & 7 deletions lib/splash.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ export default function splash({ path, name, org, coc, logo, active, total, chan
]
: [dom('b.total', total), ' users are registered so far.']
),
dom('form',
// channel selection when there are multiple
channels && channels.length > 1 && dom('select.form-item name=channel',
channels.map(channel => {
return dom('option', { value: channel, text: channel });
})
dom('form id=invite',
channels && (
channels.length > 1
// channel selection when there are multiple
? dom('select.form-item name=channel',
channels.map(channel => {
return dom('option', { value: channel, text: channel });
})
)
// otherwise a fixed channel
: dom('input type=hidden name=channel', { value: channels[0] })
),
dom('input.form-item type=email placeholder=you@yourdomain.com '
dom('input.form-item type=email name=email placeholder=you@yourdomain.com '
+ (!iframe ? 'autofocus' : '')),
coc && dom('.coc',
dom('label',
Expand Down

0 comments on commit ae93c74

Please sign in to comment.