0

I'm trying to convert the following JavaScript into CoffeeScript:

$(window).afterResize( function() {

        var adjusted_window_height = $(window).height() - $('header').height() - $('footer').height();
        var vid_width = $('#section').width();
        var vid_height = adjusted_window_height - 20;
        var vid_margin = (adjusted_window_height - vid_height)/2;

        $('iframe.vimeo_player').css({
            width: vid_width,
            height: vid_height
        });

        if(vid_margin > 0){
            $('iframe.vimeo_player').css('margin-top',vid_margin+'px');
        }

        //Adjusts for scroll-bar follies 
        if($('iframe.vimeo_player').width() < $('#section').width()){
            $('iframe.vimeo_player').css({
                width: $('#section').width(),
                height: $(window).height() - $('header').height() - $('footer').height() - 20
            });
        }

}, true, 200 );

And the fact I'm passing in a function as the first argument of a function call is messing everything up. Can anyone point me in the right direction?

1 Answer 1

1

Replace function with -> as coffeescript requires. You'll also need to remove var statents

$(window).afterResize ->  
   foo()
, true
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.