Skip to content

Commit 93c66a9

Browse files
committed
fixing autoresizing, cleaning up js, and fixed hearting on a protip view
1 parent fe87046 commit 93c66a9

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

app/assets/javascripts/application.js.coffee

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,20 @@
1717
#= require react_ujs
1818
#= require_tree .
1919

20-
@promptUserSignInOn401 = (xhr) ->
21-
if xhr.status == 401
22-
window.location.replace('/signin')
23-
return
24-
2520
$ ->
2621
$.ajaxSetup error: (xhr, status, err) ->
2722
promptUserSignInOn401(xhr)
2823
return
2924

30-
# $.ajaxSetup statusCode: 401: ->
31-
# window.location.replace('/signin')
32-
# return
25+
$('textarea').on 'input', resizeTextAreaForContent
3326

34-
# $(document).bind "ajax:error", (event, jqXHR, ajaxSettings, thrownError) ->
35-
# if jqXHR.status == 401 # thrownError is 'Unauthorized'
36-
# window.location.replace('/signin')
27+
@promptUserSignInOn401 = (xhr) ->
28+
if xhr.status == 401
29+
window.location.replace('/signin')
30+
return
3731

38-
# resize text areas to adjust for space
39-
$('textarea').on 'input', ->
40-
textarea_to_resize = this
41-
textarea_new_hight = textarea_to_resize.scrollHeight
42-
textarea_to_resize.style.cssText = 'height:auto;'
43-
textarea_to_resize.style.cssText = 'height:' + textarea_new_hight + 'px'
32+
@resizeTextAreaForContent = ->
33+
textarea_to_resize = this
34+
textarea_new_hight = textarea_to_resize.scrollHeight
35+
textarea_to_resize.style.cssText = 'height:auto;'
36+
textarea_to_resize.style.cssText = 'height:' + textarea_new_hight + 'px'

app/assets/javascripts/components/ProtipHeart.es6.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ProtipHeart extends React.Component {
88
}
99

1010
componentDidMount() {
11-
const userLikes = JSON.parse($('#signed-in-user-liked-payload').html() || '[]')
11+
const userLikes = JSON.parse($('#signed-in-user-liked-payload').html()) || []
1212
console.log(userLikes)
1313
if (userLikes.indexOf(this.props.id) > -1) {
1414
this.setState({hearted: true})

app/views/protips/show.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
-if signed_in?
55
#signed-in-user-liked-payload.hide=current_user.likes?(@protip) && [dom_id(@protip)]
6-
6+
-# .hide
77
-# - meta description: protip_summary
88
-# - meta og: { description: protip_summary }
99
-# - meta og: { image: users_image_path(@protip.user) }

0 commit comments

Comments
 (0)