{"action":"closed","issue":{"url":"https://api.github.com/repos/adamsilver/kitty/issues/3","repository_url":"https://api.github.com/repos/adamsilver/kitty","labels_url":"https://api.github.com/repos/adamsilver/kitty/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/adamsilver/kitty/issues/3/comments","events_url":"https://api.github.com/repos/adamsilver/kitty/issues/3/events","html_url":"https://github.com/adamsilver/kitty/issues/3","id":156253493,"number":3,"title":"kitty form validator kid","user":{"login":"adamsilver","id":37163,"avatar_url":"https://avatars.githubusercontent.com/u/37163?v=3","gravatar_id":"","url":"https://api.github.com/users/adamsilver","html_url":"https://github.com/adamsilver","followers_url":"https://api.github.com/users/adamsilver/followers","following_url":"https://api.github.com/users/adamsilver/following{/other_user}","gists_url":"https://api.github.com/users/adamsilver/gists{/gist_id}","starred_url":"https://api.github.com/users/adamsilver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamsilver/subscriptions","organizations_url":"https://api.github.com/users/adamsilver/orgs","repos_url":"https://api.github.com/users/adamsilver/repos","events_url":"https://api.github.com/users/adamsilver/events{/privacy}","received_events_url":"https://api.github.com/users/adamsilver/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-05-23T10:55:25Z","updated_at":"2016-06-27T09:09:42Z","closed_at":"2016-06-27T09:09:42Z","body":"kidly.views.FormValidatorView = function(form) {\r\n    kidly.views.FormValidatorView.superConstructor.apply(this, arguments);\r\n    // this.errorSummaryContainer = $(\".errorSummary\");\r\n    // this.errorLink = document.getElementById('errorSummaryLink');\r\n    // this.errorSummaryContainer.on('click', 'a.error', $.proxy(this, 'onErrorClicked'));\r\n    $(this.form).on(\"submit\", $.proxy(this, \"onFormSubmit\"));\r\n};\r\n\r\nkidly.utilities.inherit(kidly.views.FormValidatorView, kidly.views.BaseFormValidatorView);\r\n\r\nkidly.views.FormValidatorView.prototype.onFormSubmit = function (e) {\r\n    this.clearInlineErrors();\r\n    // this.hideErrorSummary();\r\n    if(!this.validate()) {\r\n        e.preventDefault();\r\n        // this.showErrorSummary();\r\n        this.showInlineErrors();\r\n    } else {\r\n        this.fire('submittedSuccessfully', e);\r\n    }\r\n};\r\n\r\nkidly.views.FormValidatorView.prototype.showInlineErrors = function() {\r\n    var errors = this.getErrors();\r\n    for (var i = 0, j = errors.length; i < j; i++) {\r\n        this.showInlineError(errors[i]);\r\n    }\r\n};\r\n\r\nkidly.views.FormValidatorView.prototype.showInlineError = function (error) {\r\n    var errorSpan = '<span class=\"errorIndicator\"> Error</span>';\r\n    var control = $(\"#\" + error.controlName);\r\n    var groupControl = control.parents(\".groupControl\");\r\n    var standardControl = control.parents(\".standardControl\");\r\n    var legend;\r\n    var label;\r\n    if(groupControl.length) {\r\n        legend = groupControl.find(\"legend\");\r\n        legend.append(errorSpan);\r\n        groupControl.append('<div class=\"errorMessage\">,p>'+error.message+'</p></div>');\r\n    } else if(standardControl.length) {\r\n        label = standardControl.find(\".indicator label\");\r\n        label.append(errorSpan);\r\n        standardControl.append('<div class=\"errorMessage\"><p>'+error.message+'</p></div>');\r\n    }\r\n};\r\n\r\nkidly.views.FormValidatorView.prototype.clearInlineErrors = function () {\r\n    $(this.form).find(\".errorIndicator\").remove();\r\n    $(this.form).find(\".errorMessage\").remove();\r\n};\r\n\r\n// kidly.views.FormValidatorView.prototype.onErrorClicked = function(e) {\r\n//     e.preventDefault();\r\n//     var href = e.target.href;\r\n//     href = href.substring(href.indexOf(\"#\")+1, href.length);\r\n//     document.getElementById(href).focus();\r\n// };\r\n\r\nkidly.views.FormValidatorView.prototype.showErrorSummary = function (errors) {\r\n    // this.errorSummaryContainer.html(this.getErrorSummaryHtml(errors));\r\n    // this.errorSummaryContainer.removeClass('hide');\r\n    //this.errorLink.focus();\r\n};\r\n\r\n// kidly.views.FormValidatorView.prototype.getErrorSummaryHtml = function() {\r\n//     var errors = this.getErrors(),\r\n//         html = '<p>' + 'There are errors:' + '</p>';\r\n//     html += '<ul>';\r\n//     for (var i = 0, j = errors.length; i < j; i++) {\r\n//         var error = errors[i];\r\n//         html += '<li>';\r\n//         html +=     '<a class=\"error\" href=\"#' + error.controlName +  '\">';\r\n//         html +=         error.message;\r\n//         html +=     '</a>';\r\n//         html += '</li>';\r\n//     }\r\n//     html += '</ul>';\r\n//     return html;\r\n// };\r\n\r\n// kidly.views.FormValidatorView.prototype.hideErrorSummary = function() {\r\n//     this.errorSummaryContainer.addClass('hide');\r\n// };\r\n"}}
{"actor":{"display_login":"adamsilver"}}