{"action":"created","comment":{"url":"https://api.github.com/repos/npm/pivotal-ui/pulls/comments/70297365","id":70297365,"diff_hunk":"@@ -61,5 +38,49 @@ var handleInput = function handleInput(e) {\n       input.setCustomValidity('');\n     }\n   }\n-  reflectValidity(input);\n+  this.reflectValidity(input);\n+};\n+\n+var ValidatedForm = function ValidatedForm(el) {\n+  this.form = $(el);\n+  this.inputs = this.form.find(\"input\");\n+  this.submitButton = this.form.find(\"[type='submit']\");\n+\n+  this.form.attr(\"novalidate\", \"\");\n+\n+  if(!this.form[0].checkValidity()){\n+    this.submitButton.attr(\"disabled\", \"\");\n+  }\n };\n+\n+ValidatedForm.prototype.addListeners = function addListners() {\n+  this.form.on(\"submit\", handleSubmit.bind(this));\n+  this.form.on(\"input\", handleInput.bind(this));\n+  this.form.on(\"click\", \"input[type='checkbox'], input[type='radio']\", handleInput.bind(this));\n+  this.form.on(\"focusout\", handleBlur.bind(this));\n+};\n+\n+ValidatedForm.prototype.reflectValidity = function reflectValidity(input){\n+  if(!input.checkValidity()) {\n+    removeError(input);\n+    addError(input);\n+  } else {\n+    removeError(input);\n+  }\n+\n+  if(this.form[0].checkValidity()){\n+    this.submitButton.removeAttr(\"disabled\");\n+  } else {\n+    this.submitButton.attr(\"disabled\", \"\");\n+  }\n+};\n+\n+$(function(){\n+  var forms = $(\"form[data-validate]\");\n+\n+  $.each(forms, function(idx, form){\n+    var vf = new ValidatedForm(form);\n+    vf.addListeners();","path":"src/pivotal-ui/components/forms/validator.js","position":102,"original_position":102,"commit_id":"4cf2a73149021a328f1b7b3a009acb21b80aa2d5","original_commit_id":"4cf2a73149021a328f1b7b3a009acb21b80aa2d5","user":{"login":"jefflembeck","id":109699,"avatar_url":"https://avatars.githubusercontent.com/u/109699?v=3","gravatar_id":"","url":"https://api.github.com/users/jefflembeck","html_url":"https://github.com/jefflembeck","followers_url":"https://api.github.com/users/jefflembeck/followers","following_url":"https://api.github.com/users/jefflembeck/following{/other_user}","gists_url":"https://api.github.com/users/jefflembeck/gists{/gist_id}","starred_url":"https://api.github.com/users/jefflembeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jefflembeck/subscriptions","organizations_url":"https://api.github.com/users/jefflembeck/orgs","repos_url":"https://api.github.com/users/jefflembeck/repos","events_url":"https://api.github.com/users/jefflembeck/events{/privacy}","received_events_url":"https://api.github.com/users/jefflembeck/received_events","type":"User","site_admin":false},"body":"I'd like to separate all the concerns for testing so every line of the constructor method is testable.","created_at":"2016-07-11T17:08:56Z","updated_at":"2016-07-11T17:08:56Z","html_url":"https://github.com/npm/pivotal-ui/pull/225#discussion_r70297365","pull_request_url":"https://api.github.com/repos/npm/pivotal-ui/pulls/225","_links":{"self":{"href":"https://api.github.com/repos/npm/pivotal-ui/pulls/comments/70297365"},"html":{"href":"https://github.com/npm/pivotal-ui/pull/225#discussion_r70297365"},"pull_request":{"href":"https://api.github.com/repos/npm/pivotal-ui/pulls/225"}}},"pull_request":{"url":"https://api.github.com/repos/npm/pivotal-ui/pulls/225","id":76988446,"html_url":"https://github.com/npm/pivotal-ui/pull/225","diff_url":"https://github.com/npm/pivotal-ui/pull/225.diff","patch_url":"https://github.com/npm/pivotal-ui/pull/225.patch","issue_url":"https://api.github.com/repos/npm/pivotal-ui/issues/225","number":225,"state":"open","locked":false,"title":"fix(forms): Update validation forms","user":{"login":"jefflembeck","id":109699,"avatar_url":"https://avatars.githubusercontent.com/u/109699?v=3","gravatar_id":"","url":"https://api.github.com/users/jefflembeck","html_url":"https://github.com/jefflembeck","followers_url":"https://api.github.com/users/jefflembeck/followers","following_url":"https://api.github.com/users/jefflembeck/following{/other_user}","gists_url":"https://api.github.com/users/jefflembeck/gists{/gist_id}","starred_url":"https://api.github.com/users/jefflembeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jefflembeck/subscriptions","organizations_url":"https://api.github.com/users/jefflembeck/orgs","repos_url":"https://api.github.com/users/jefflembeck/repos","events_url":"https://api.github.com/users/jefflembeck/events{/privacy}","received_events_url":"https://api.github.com/users/jefflembeck/received_events","type":"User","site_admin":false},"body":"This fix includes:\n\n- If a form is not valid, the submit button is disabled\n- Refactoring to OOJS for easier testing","created_at":"2016-07-11T17:02:45Z","updated_at":"2016-07-11T17:08:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"53cd146e703951ed0a32b1ba0fa321fbfbdabd9c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/npm/pivotal-ui/pulls/225/commits","review_comments_url":"https://api.github.com/repos/npm/pivotal-ui/pulls/225/comments","review_comment_url":"https://api.github.com/repos/npm/pivotal-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/npm/pivotal-ui/issues/225/comments","statuses_url":"https://api.github.com/repos/npm/pivotal-ui/statuses/4cf2a73149021a328f1b7b3a009acb21b80aa2d5","head":{"label":"npm:validator-disable-submit","ref":"validator-disable-submit","sha":"4cf2a73149021a328f1b7b3a009acb21b80aa2d5","user":{"login":"npm","id":6078720,"avatar_url":"https://avatars.githubusercontent.com/u/6078720?v=3","gravatar_id":"","url":"https://api.github.com/users/npm","html_url":"https://github.com/npm","followers_url":"https://api.github.com/users/npm/followers","following_url":"https://api.github.com/users/npm/following{/other_user}","gists_url":"https://api.github.com/users/npm/gists{/gist_id}","starred_url":"https://api.github.com/users/npm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npm/subscriptions","organizations_url":"https://api.github.com/users/npm/orgs","repos_url":"https://api.github.com/users/npm/repos","events_url":"https://api.github.com/users/npm/events{/privacy}","received_events_url":"https://api.github.com/users/npm/received_events","type":"Organization","site_admin":false},"repo":{"id":50528473,"name":"pivotal-ui","full_name":"npm/pivotal-ui","owner":{"login":"npm","id":6078720,"avatar_url":"https://avatars.githubusercontent.com/u/6078720?v=3","gravatar_id":"","url":"https://api.github.com/users/npm","html_url":"https://github.com/npm","followers_url":"https://api.github.com/users/npm/followers","following_url":"https://api.github.com/users/npm/following{/other_user}","gists_url":"https://api.github.com/users/npm/gists{/gist_id}","starred_url":"https://api.github.com/users/npm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npm/subscriptions","organizations_url":"https://api.github.com/users/npm/orgs","repos_url":"https://api.github.com/users/npm/repos","events_url":"https://api.github.com/users/npm/events{/privacy}","received_events_url":"https://api.github.com/users/npm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/npm/pivotal-ui","description":"","fork":true,"url":"https://api.github.com/repos/npm/pivotal-ui","forks_url":"https://api.github.com/repos/npm/pivotal-ui/forks","keys_url":"https://api.github.com/repos/npm/pivotal-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/npm/pivotal-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/npm/pivotal-ui/teams","hooks_url":"https://api.github.com/repos/npm/pivotal-ui/hooks","issue_events_url":"https://api.github.com/repos/npm/pivotal-ui/issues/events{/number}","events_url":"https://api.github.com/repos/npm/pivotal-ui/events","assignees_url":"https://api.github.com/repos/npm/pivotal-ui/assignees{/user}","branches_url":"https://api.github.com/repos/npm/pivotal-ui/branches{/branch}","tags_url":"https://api.github.com/repos/npm/pivotal-ui/tags","blobs_url":"https://api.github.com/repos/npm/pivotal-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/npm/pivotal-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/npm/pivotal-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/npm/pivotal-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/npm/pivotal-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/npm/pivotal-ui/languages","stargazers_url":"https://api.github.com/repos/npm/pivotal-ui/stargazers","contributors_url":"https://api.github.com/repos/npm/pivotal-ui/contributors","subscribers_url":"https://api.github.com/repos/npm/pivotal-ui/subscribers","subscription_url":"https://api.github.com/repos/npm/pivotal-ui/subscription","commits_url":"https://api.github.com/repos/npm/pivotal-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/npm/pivotal-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/npm/pivotal-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/npm/pivotal-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/npm/pivotal-ui/contents/{+path}","compare_url":"https://api.github.com/repos/npm/pivotal-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/npm/pivotal-ui/merges","archive_url":"https://api.github.com/repos/npm/pivotal-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/npm/pivotal-ui/downloads","issues_url":"https://api.github.com/repos/npm/pivotal-ui/issues{/number}","pulls_url":"https://api.github.com/repos/npm/pivotal-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/npm/pivotal-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/npm/pivotal-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/npm/pivotal-ui/labels{/name}","releases_url":"https://api.github.com/repos/npm/pivotal-ui/releases{/id}","deployments_url":"https://api.github.com/repos/npm/pivotal-ui/deployments","created_at":"2016-01-27T18:28:21Z","updated_at":"2016-06-16T21:57:25Z","pushed_at":"2016-07-11T17:02:46Z","git_url":"git://github.com/npm/pivotal-ui.git","ssh_url":"git@github.com:npm/pivotal-ui.git","clone_url":"https://github.com/npm/pivotal-ui.git","svn_url":"https://github.com/npm/pivotal-ui","homepage":"styleguide.cfapps.io","size":38347,"stargazers_count":4,"watchers_count":4,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":4,"forks":3,"open_issues":4,"watchers":4,"default_branch":"master"}},"base":{"label":"npm:master","ref":"master","sha":"cbec517eca8c396556a05ecb64f241b558cb7cce","user":{"login":"npm","id":6078720,"avatar_url":"https://avatars.githubusercontent.com/u/6078720?v=3","gravatar_id":"","url":"https://api.github.com/users/npm","html_url":"https://github.com/npm","followers_url":"https://api.github.com/users/npm/followers","following_url":"https://api.github.com/users/npm/following{/other_user}","gists_url":"https://api.github.com/users/npm/gists{/gist_id}","starred_url":"https://api.github.com/users/npm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npm/subscriptions","organizations_url":"https://api.github.com/users/npm/orgs","repos_url":"https://api.github.com/users/npm/repos","events_url":"https://api.github.com/users/npm/events{/privacy}","received_events_url":"https://api.github.com/users/npm/received_events","type":"Organization","site_admin":false},"repo":{"id":50528473,"name":"pivotal-ui","full_name":"npm/pivotal-ui","owner":{"login":"npm","id":6078720,"avatar_url":"https://avatars.githubusercontent.com/u/6078720?v=3","gravatar_id":"","url":"https://api.github.com/users/npm","html_url":"https://github.com/npm","followers_url":"https://api.github.com/users/npm/followers","following_url":"https://api.github.com/users/npm/following{/other_user}","gists_url":"https://api.github.com/users/npm/gists{/gist_id}","starred_url":"https://api.github.com/users/npm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npm/subscriptions","organizations_url":"https://api.github.com/users/npm/orgs","repos_url":"https://api.github.com/users/npm/repos","events_url":"https://api.github.com/users/npm/events{/privacy}","received_events_url":"https://api.github.com/users/npm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/npm/pivotal-ui","description":"","fork":true,"url":"https://api.github.com/repos/npm/pivotal-ui","forks_url":"https://api.github.com/repos/npm/pivotal-ui/forks","keys_url":"https://api.github.com/repos/npm/pivotal-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/npm/pivotal-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/npm/pivotal-ui/teams","hooks_url":"https://api.github.com/repos/npm/pivotal-ui/hooks","issue_events_url":"https://api.github.com/repos/npm/pivotal-ui/issues/events{/number}","events_url":"https://api.github.com/repos/npm/pivotal-ui/events","assignees_url":"https://api.github.com/repos/npm/pivotal-ui/assignees{/user}","branches_url":"https://api.github.com/repos/npm/pivotal-ui/branches{/branch}","tags_url":"https://api.github.com/repos/npm/pivotal-ui/tags","blobs_url":"https://api.github.com/repos/npm/pivotal-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/npm/pivotal-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/npm/pivotal-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/npm/pivotal-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/npm/pivotal-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/npm/pivotal-ui/languages","stargazers_url":"https://api.github.com/repos/npm/pivotal-ui/stargazers","contributors_url":"https://api.github.com/repos/npm/pivotal-ui/contributors","subscribers_url":"https://api.github.com/repos/npm/pivotal-ui/subscribers","subscription_url":"https://api.github.com/repos/npm/pivotal-ui/subscription","commits_url":"https://api.github.com/repos/npm/pivotal-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/npm/pivotal-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/npm/pivotal-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/npm/pivotal-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/npm/pivotal-ui/contents/{+path}","compare_url":"https://api.github.com/repos/npm/pivotal-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/npm/pivotal-ui/merges","archive_url":"https://api.github.com/repos/npm/pivotal-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/npm/pivotal-ui/downloads","issues_url":"https://api.github.com/repos/npm/pivotal-ui/issues{/number}","pulls_url":"https://api.github.com/repos/npm/pivotal-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/npm/pivotal-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/npm/pivotal-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/npm/pivotal-ui/labels{/name}","releases_url":"https://api.github.com/repos/npm/pivotal-ui/releases{/id}","deployments_url":"https://api.github.com/repos/npm/pivotal-ui/deployments","created_at":"2016-01-27T18:28:21Z","updated_at":"2016-06-16T21:57:25Z","pushed_at":"2016-07-11T17:02:46Z","git_url":"git://github.com/npm/pivotal-ui.git","ssh_url":"git@github.com:npm/pivotal-ui.git","clone_url":"https://github.com/npm/pivotal-ui.git","svn_url":"https://github.com/npm/pivotal-ui","homepage":"styleguide.cfapps.io","size":38347,"stargazers_count":4,"watchers_count":4,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":4,"forks":3,"open_issues":4,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/npm/pivotal-ui/pulls/225"},"html":{"href":"https://github.com/npm/pivotal-ui/pull/225"},"issue":{"href":"https://api.github.com/repos/npm/pivotal-ui/issues/225"},"comments":{"href":"https://api.github.com/repos/npm/pivotal-ui/issues/225/comments"},"review_comments":{"href":"https://api.github.com/repos/npm/pivotal-ui/pulls/225/comments"},"review_comment":{"href":"https://api.github.com/repos/npm/pivotal-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/npm/pivotal-ui/pulls/225/commits"},"statuses":{"href":"https://api.github.com/repos/npm/pivotal-ui/statuses/4cf2a73149021a328f1b7b3a009acb21b80aa2d5"}}}}
{"actor":{"display_login":"jefflembeck"}}