Anton Shestakov <av6@dwimlabs.net>, Mon, 02 Jan 2017 01:46:02 +0800
index: make input fields below contact list and chat log look separate
coffee/forms.coffee
Permissions: -rw-r--r--
class Tram.RegistrationForm extends Backbone.Model validate: (attrs, options) -> @unset('username-errors') @unset('password1-errors') @unset('password2-errors') if (attrs.username ? '').trim() is '' @set('username-errors', ['This field is required.']) if (attrs.password1 ? '') is '' @set('password1-errors', ['This field is required.']) if (attrs.password1 ? '') isnt (attrs.password2 ? '') @set('password2-errors', ['Passwords must match.']) else if (attrs.password2 ? '') is '' @set('password2-errors', ['This field is required.']) return @has('username-errors') or @has('password1-errors') or @has('password2-errors') class Tram.ProfileForm extends Backbone.Model validate: (attrs, options) -> file = $('#avatar').get(0).files[0] if not file.type.match('image/.*')? ae.push("File doesn't look like an image.") ae.push('File is too big.') @set('avatar-errors', ae) return @has('avatar-errors') class Tram.ConnectionForm extends Backbone.Model validate: (attrs, options) -> @unset('username-errors') @unset('password-errors') if (attrs.username ? '').trim() is '' @set('username-errors', ['This field is required.']) if (attrs.password ? '') is '' @set('password-errors', ['This field is required.']) return @has('username-errors') or @has('password-errors') $form.find('input').on 'keydown', (e) -> if (not @required or @value isnt '') and e.keyCode is 13 index = $form.find('input').index(@) $next = $form.find('input').eq(index + 1) $form.find('button').trigger('click')