Created
July 26, 2012 12:45
-
-
Save ivan-hilckov/3181831 to your computer and use it in GitHub Desktop.
model_openid_test.coffee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Elections.Model.Openid extends Elections.Model.Base | |
| url: "/auth/open_id" | |
| validation: | |
| openid_url: [{ | |
| required: true | |
| pattern: /^(https?:\/\/)?([\w\.]+)\.([a-z]{2,6}\.?)(\/[\w\.]*)*\/?$/ | |
| msg: "Введите OpenID" | |
| }] | |
| save: -> | |
| xhr = super | |
| xhr.always => | |
| @errorСatcher( xhr ) | |
| return xhr | |
| errorСatcher: ( xhr ) -> | |
| switch xhr.status | |
| when 422 | |
| if JSON.parse( xhr.responseText ).error_type is "connection_failed" | |
| @.trigger "invalid", "openid_url", "Неверный OpenID" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment