~lambdacircus-maint/lambdacircus/969924-visual-design

« back to all changes in this revision

Viewing changes to templates/default-layout.coffee

  • Committer: Jonathan Jacobs
  • Date: 2012-04-01 15:53:12 UTC
  • Revision ID: korpse@slipgate.za.net-20120401155312-57n0o9c0c7p8egzy
Voting click spam prevention.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
                FlyingCircus.router.navigate(@pathname, trigger: true)
34
34
                event.preventDefault()
35
35
            if @model.voted
36
 
                @disableVoting()
 
36
                @disableVoting(true)
 
37
                @hideVoting()
37
38
            return @
38
39
        remove: =>
39
40
            @$el.remove()
41
42
            'click button.vote-up':   'voteUp'
42
43
            'click button.vote-down': 'voteDown'
43
44
        voteUp: ->
 
45
            @disableVoting(true)
44
46
            d = @model.voteUp()
45
47
            d.fail (f) =>
46
48
                @flash()
 
49
                @disableVoting(false)
47
50
        voteDown: ->
 
51
            @disableVoting(true)
48
52
            d = @model.voteDown()
49
53
            d.fail (f) =>
50
54
                @flash()
 
55
                @disableVoting(false)
51
56
        flash: (cssClass='error-flash') ->
52
57
            el = $('<div />').addClass(cssClass)
53
58
            @$el.find('.quote').append(el)
54
59
            el.fadeIn(200).fadeOut(600).queue(() ->
55
60
                el.remove()
56
61
                el.dequeue())
57
 
        disableVoting: ->
 
62
        disableVoting: (disabled=true) ->
 
63
            @$el.find('.controls button').prop('disabled', disabled)
 
64
        hideVoting: ->
58
65
            controls = @$el.find('.controls')
59
66
            buttons = controls.find('button')
60
67
            controls.css opacity: 1
61
 
            buttons.prop('disabled', true)
62
68
            buttons.fadeOut 200
63
69
            controls.find('.voted').fadeIn 200
64
70