Skip to content

Commit 60f895f

Browse files
committed
Merge pull request coderwall#272 from rohitpaulk/fix-follow-buttons
Fix follow buttons [#482]
2 parents 953b63b + 5cc66b6 commit 60f895f

File tree

9 files changed

+18
-108
lines changed

9 files changed

+18
-108
lines changed

app/assets/javascripts/backbone/views/ProtipGridView.js.coffee

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,12 @@ window.ProtipGridView = Backbone.View.extend(
9898
this.followingUsers = $('#x-following-users').data('users')
9999
this.followingTeams = $('#x-following-teams').data('teams')
100100

101-
markFollowings: ->
102-
$(follow).addClass('followed') for follow in $('.x-protip-pane .follow') when follow.attributes['data-value'].value in eval('this.following' + $(follow).data('follow-type'))
103-
104101
updateFollowList: (e)->
105102
list = eval('this.following' + $(e.target).data('follow-type'))
106103
entity = $(e.target).data('value')
107104
if $(e.target).hasClass('followed') then (list.filter (val) ->
108105
val is entity)
109106
else
110-
list.push entity
111-
this.markFollowed(e.target)
112-
113-
markFollowed: (el)->
114-
unless $(el).data('follow-type') == 'Network'
115-
$(el).toggleClass('followed')
107+
list.push entity
116108

117-
)
109+
)

app/assets/javascripts/backbone/views/ProtipView.js.coffee

Lines changed: 0 additions & 69 deletions
This file was deleted.

app/assets/javascripts/protips-grid.js.coffee

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#= require highlight/language
33
#= require backbone/routers/ProtipRouter
44
#= require backbone/views/ProtipGridView
5-
#= require backbone/views/ProtipView
65
#= require protips
76
$ ->
87
Backbone.history.start({pushState: true})

app/assets/javascripts/protips.js.coffee

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Place all the behaviors and hooks related to the matching controller here.
2-
# All this logic will automatically be available in application.js.
31
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
42
#= require marked
53
#= require highlight/highlight
@@ -63,6 +61,7 @@ window.initializeProtip = ->
6361
handle_redirect(response)
6462

6563
e.preventDefault()
64+
markFollowings()
6665
registerToggles()
6766
enableSearchBox()
6867
registerMoreHistory()
@@ -210,6 +209,12 @@ uploadFinished = (i, file, response, time)->
210209
$('#protip_body').val $('#protip_body').val() + markdown
211210
$("#dropzone").removeClass 'upload-in-progress'
212211

212+
getFollowings = (type)->
213+
$('#x-following-' + type.toLowerCase()).data(type.toLowerCase())
214+
215+
markFollowings = ->
216+
$(follow).addClass('followed') for follow in $('.x-protip-pane .follow') when follow.attributes['data-value'].value in getFollowings($(follow).data('follow-type'))
217+
213218
window.registerToggles = ->
214219
$('.upvote,.small-upvote').on 'click', ->
215220
if $(@).not('.upvoted').length == 1
@@ -219,16 +224,14 @@ window.registerToggles = ->
219224
$(@).toggleClass('flagged')
220225
$('.user-flag').on 'click', ->
221226
$(@).addClass('user-flagged')
222-
$('.queue').on 'click', ->
223-
$(@).toggleClass('queued')
224227
$('.feature').on 'click', ->
225228
$(@).toggleClass('featured')
226229
$('.like').on 'click', ->
227230
$(@).addClass('liked')
228231
$(@).removeClass('not-liked')
229-
$('.follow-user').on 'click', ->
230-
$(@).addClass('following-user')
231-
$(@).removeClass('follow-user')
232+
$('.follow').on 'click', (e)->
233+
unless $(e.target).data('follow-type') == 'Network'
234+
$(e.target).toggleClass('followed')
232235

233236
enableSearchBox = ->
234237
$('.slidedown').on 'click', (e)->

app/assets/stylesheets/new-new-home.scss

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -503,21 +503,6 @@
503503
}
504504
}
505505
}
506-
.queue {
507-
&:before {
508-
content: "l";
509-
}
510-
&:after {
511-
content: "Queue for Hackernews";
512-
}
513-
background-position: 0px -14px;
514-
&.queued {
515-
&:after {
516-
content: "Queued for Hackernews";
517-
}
518-
color: #e68b42 !important;
519-
}
520-
}
521506
.reviewed {
522507
color: #fff;
523508
&:before {

app/controllers/protips_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class ProtipsController < ApplicationController
22

33
before_action :access_required, only: [:new, :create, :edit, :update, :destroy, :me]
44
before_action :require_skills_first, only: [:new, :create]
5-
before_action :lookup_protip, only: %i(show edit update destroy upvote tag flag queue feature delete_tag)
5+
before_action :lookup_protip, only: %i(show edit update destroy upvote tag flag feature delete_tag)
66
before_action :reformat_tags, only: [:create, :update]
77
before_action :verify_ownership, only: [:edit, :update, :destroy]
88
before_action :ensure_single_tag, only: [:subscribe, :unsubscribe]

app/views/layouts/protip.html.haml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
%canvas.blur{ src: image_path(users_background_image) }
2929
= yield
3030

31+
#x-following-users.hide{'data-users' => current_user.following_users.map(&:username)}
32+
#x-following-networks.hide{'data-networks' => current_user.following_networks.map(&:slug)}
33+
#x-following-teams.hide{'data-teams' => current_user.teams_being_followed.map(&:name)}
34+
3135
- unless is_admin?
3236
:javascript
3337
window.console.log = function(){}
3438

35-
= javascript_include_tag 'jquery'
3639
= javascript_include_tag 'application'
37-
= javascript_include_tag 'jquery_ujs'
3840
= render partial: 'shared/mixpanel_properties'
3941
= javascript_include_tag 'highlight/highlight.js'
4042
= javascript_include_tag 'highlight/language.js'

app/views/protips/show.js.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
$('#x-active-preview-pane').append('<%= escape_javascript(render partial: 'cacheable_protip', locals: { protip: @protip, mode: (@mode || params[:mode]), include_comments: true, job: @job }) %> ');
22
$('.dark-screen').height($('#x-active-preview-pane').height());
33
registerProtipClickOff();
4-
protipGrid.markFollowings();
4+
hljs.highlightBlock($('#x-active-preview-pane')[0]);
55
window.initializeProtip();
6-
hljs.highlightBlock($('#x-active-preview-pane')[0])

app/views/shared/_footer.html.haml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
%li
2424
:erb
2525
<a href="https://mixpanel.com/f/partner"><img src="https://mixpanel.com/site_media/images/partner/badge_light.png" alt="Real Time Web Analytics" /></a>
26-
= javascript_include_tag 'jquery'
2726
= javascript_include_tag 'application'
2827
= render partial: 'shared/mixpanel_properties'
2928
= yield :javascript

0 commit comments

Comments
 (0)