Merge branch 'comment_multisubmit_fix'

This commit is contained in:
yafeilee 2014-04-04 13:58:56 +08:00
commit 4a3ab3c9e6
4 changed files with 14 additions and 10 deletions

View File

@ -9,5 +9,5 @@
@app.config(["$httpProvider", (provider) ->
provider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content')
provider.defaults.headers.common['Accept'] = 'application/json'
provider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
])

View File

@ -8,6 +8,7 @@
$scope.publish_success = null
$scope.submit = ->
$scope.submitting = true
comment = { content: $scope.content, name: $scope.name, email: $scope.email }
$http.post(url, comment)
.success (res)->
@ -18,10 +19,13 @@
else
$scope.publish_success = false
$scope.publish_fail_msg = res.message
$timeout ->
.error (data, status)->
$scope.publish_success = false
$scope.publish_fail_msg = '网络错误, 请重试, 错误码为: ' + status
.finally ->
$scope.submitting = false
$scope.timeout = $timeout ->
$timeout.cancel($scope.timeout)
$scope.publish_success = null
, 3*1000
.error (data)->
alert(data)
, 5*1000
]

View File

@ -10,7 +10,7 @@
i.fi-calendar
span
|{{ post.created_at }}
i.fi-list
i.fi-list-thumbnails
span
|{{ post.type }}
i.fi-pricetag-multiple

View File

@ -1,4 +1,4 @@
.row ng-controller="CommentsController"
.row ng-controller="CommentsController" ng-cloak=""
.small-12.large-9.large-centered.columns
form novalidate='' name='form'
.row
@ -8,10 +8,10 @@
.small-12.large-6.columns
= text_field_tag(:name, nil, placeholder: '你的名字', 'ng-model'=> 'name', 'ng-required'=> 'true')
= text_field_tag(:email, nil, placeholder: '你的邮箱', 'ng-model'=> 'email', 'ng-pattern'=>"/^.+@.+$/", 'ng-required'=>"true")
button.comment-submit ng-click="submit()" ng-disabled="form.$invalid" 发表
button.comment-submit ng-click="submit()" ng-disabled="form.$invalid || submitting" {{ submitting && '发表中' || '发表' }}
p.comment-success ng-show="publish_success" 发布成功
p.comment-fail ng-show="publish_success == false" 发布失败: {{ publish_fail_msg }}
.comment-diag ng-cloak=""
.comment-diag
.comment-wrapper ng-repeat=" comment in comments "
p.name
|{{ comment.name + " • " }}