Anton Shestakov <av6@dwimlabs.net>, Wed, 01 Nov 2017 00:50:57 +0800
Makefile: use file targets more, results in incremental building
Less work to do when only some files get changed, but more work when building
from scratch. But, multiple compilers can run in parallel.
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')