Sha256: 89ebc79167588bf0d31217ab1b93e652d250b103fb88e49ee9a0d6bfeeff2000

Contents?: true

Size: 1.38 KB

Versions: 62

Compression:

Stored size: 1.38 KB

Contents

/**
 * Appends a `.back-to-top-button` component to the document's body.
 *
 * @namespace WORKAREA.backToTopButton
 */
WORKAREA.registerModule('backToTopButton', (function () {
    'use strict';

    var backToTopButton = JST['workarea/storefront/templates/back_to_top_button'],

        toggleBackToTop = function (direction) {
            $('#back-to-top-button')
            .toggleClass('back-to-top-button--visible', direction === 'down');
        },

        initWaypoint = function (element) {
            $(element).data('backToTopWaypoint', new Waypoint({
                element: element,
                handler: toggleBackToTop,
                offset: WORKAREA.config.backToTopButton.waypointOffset
            }));
        },

        injectButton = function (index, element) {
            $('#main_content').append(backToTopButton());
            return element;
        },

        setup = _.flow(injectButton, initWaypoint),

        /**
         * Add a `data-back-to-top-button` attribute to any element that should
         * be used as a Waypoint trigger that conditionally displays a global
         * "Back To Top" button UI.
         *
         * @method
         * @name init
         * @memberof WORKAREA.backToTopButton
         */
        init = function ($scope) {
            $('[data-back-to-top-button]', $scope).each(setup);
        };

    return {
        init: init
    };
}()));

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-storefront-3.5.15 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.4.36 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.5.14 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.4.35 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.5.13 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.4.34 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.5.12 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.4.33 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.5.11 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.5.10 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.4.32 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.5.9 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.4.31 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.5.8 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.4.30 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.5.7 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.4.29 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.5.6 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.4.28 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js
workarea-storefront-3.5.5 app/assets/javascripts/workarea/storefront/modules/back_to_top_button.js