Created
July 26, 2012 12:46
-
-
Save ivan-hilckov/3181837 to your computer and use it in GitHub Desktop.
model_openid
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
| # # Openid Model | |
| # Валидирует и отправляет форму на сервер | |
| 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 = @always( super ) | |
| return xhr | |
| always: ( xhr ) -> | |
| console.log "always==>", xhr | |
| xhr.always => | |
| switch xhr.status | |
| when 422 | |
| if JSON.parse( xhr.responseText ).error_type is "connection_failed" | |
| @.trigger "invalid", "openid_url", "Неверный OpenID" | |
| return xhr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment