Anton Shestakov <av6@dwimlabs.net>, Wed, 01 Jun 2016 21:26:22 +0800
index: expand, but also deduplicate existence checks for previous and contact
js/forms.js
Permissions: -rw-r--r--
// Generated by CoffeeScript 1.10.0 var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; Tram.RegistrationForm = (function(superClass) { extend(RegistrationForm, superClass); function RegistrationForm() { return RegistrationForm.__super__.constructor.apply(this, arguments); RegistrationForm.prototype.defaults = { RegistrationForm.prototype.validate = function(attrs, options) { var ref, ref1, ref2, ref3, ref4; this.unset('username-errors'); this.unset('password1-errors'); this.unset('password2-errors'); if (((ref = attrs.username) != null ? ref : '').trim() === '') { this.set('username-errors', ['This field is required.']); if (((ref1 = attrs.password1) != null ? ref1 : '') === '') { this.set('password1-errors', ['This field is required.']); if (((ref2 = attrs.password1) != null ? ref2 : '') !== ((ref3 = attrs.password2) != null ? ref3 : '')) { this.set('password2-errors', ['Passwords must match.']); } else if (((ref4 = attrs.password2) != null ? ref4 : '') === '') { this.set('password2-errors', ['This field is required.']); return this.has('username-errors') || this.has('password1-errors') || this.has('password2-errors'); Tram.ProfileForm = (function(superClass) { extend(ProfileForm, superClass); return ProfileForm.__super__.constructor.apply(this, arguments); ProfileForm.prototype.defaults = { ProfileForm.prototype.validate = function(attrs, options) { this.unset('avatar-errors'); file = $('#avatar').get(0).files[0]; if (file.type.match('image/.*') == null) { ae.push("File doesn't look like an image."); if (file.size > 64 * 1024) { ae.push('File is too big.'); this.set('avatar-errors', ae); return this.has('avatar-errors'); Tram.ConnectionForm = (function(superClass) { extend(ConnectionForm, superClass); function ConnectionForm() { return ConnectionForm.__super__.constructor.apply(this, arguments); ConnectionForm.prototype.defaults = { ConnectionForm.prototype.validate = function(attrs, options) { this.unset('username-errors'); this.unset('password-errors'); this.unset('auth-errors'); if (((ref = attrs.username) != null ? ref : '').trim() === '') { this.set('username-errors', ['This field is required.']); if (((ref1 = attrs.password) != null ? ref1 : '') === '') { this.set('password-errors', ['This field is required.']); return this.has('username-errors') || this.has('password-errors'); $.fn.streamline = function() { return this.each(function() { return $form.find('input').on('keydown', function(e) { if ((!this.required || this.value !== '') && e.keyCode === 13) { index = $form.find('input').index(this); $next = $form.find('input').eq(index + 1); if ($next.length !== 0) { return $form.find('button').trigger('click'); //# sourceMappingURL=forms.js.map