Sha256: 43c502890a7e63b78e00742333c59af7d2859eb029232024681fdb4f827657ce

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

$(document).ready(function(){

    //CREATE PAGE METHODS
    var page = {
        init: function() {
            this.buttons = $('#main-nav a');

            this.activateNav();
            this.disableDemoButtons();
        },

        activateNav: function() {
            var that = this;

            this.buttons.click(function(e) {
                e.preventDefault();
                var currentButton = $(e.currentTarget);
                var buttonId = currentButton.attr('href');

                //DESELECT ALL BUTTONS & SELECT CURRRENT ONE
                that.buttons.parent().removeClass('selected');
                currentButton.parent().addClass('selected');

                //ANIMATE SCROLL EFFECT
                $("html, body").animate({
                    scrollTop: $(buttonId).offset().top - 100
                }, 'slow');

            });
        },

        disableDemoButtons: function() {
            $('.showcase .button').on('click', function(e) {
                e.preventDefault();
            });
        }
    };

    //INITIALIZE PAGE
    page.init();
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
buttons-rails-0.0.2 vendor/assets/javascripts/buttons-rails.js
buttons-rails-0.0.1 vendor/assets/javascripts/buttons-rails/main.js