Source: themes/ess-dive/views/DownloadButtonView.js

/*global define */
define(['jquery', 'underscore', 'backbone', 'models/SolrResult', 'views/BaseDownloadButtonView'],
    function ($, _, Backbone, SolrResult, BaseDownloadButtonView) {
        'use strict';

        /*
         * DownloadButton extends the MetacatUI DownloadButtonView and names is BaseDownloadButtonView
         *
         * 
         */
        var DownloadButtonView = BaseDownloadButtonView.extend({

            /**
             * Override the model to disable login link if user is not authenticated
             */
            render: function () {

                if (!MetacatUI.appUserModel.get("loggedIn")) {

                    // Set the login button as disabled
                    this.$el.attr("disabled","disabled");


                    if(this.model.type == "Package"){
                        this.$el.text("Login to Download")
                                .addClass("btn-primary");
                    }
                    //For individual DataONEObjects
                    else{
                        this.$el.text("Download");
                    }

                    this.$el.addClass("tooltip-this")
						.attr("disabled", "disabled")
						.attr("data-title", "Login with your Orcid to download." +
                            " If you do not have an Orcid, click 'Sign in with Orcid' and follow the registration instructions.")
						.attr("data-placement", "top")
						.attr("data-trigger", "hover")
						.attr("data-container", "body")

                }
                /**
                 * Override the model to disable the download function if user is not authenticated
                 */
                else {

                    // Call the base class function
                    // This will render the button
                    BaseDownloadButtonView.prototype.render.apply(this);
                }

            },
            download: function(e){

                if (MetacatUI.appUserModel.get("loggedIn")) {
                    // Call the base class function
                    // This will render the button
                    BaseDownloadButtonView.prototype.download.apply(this, [e]);
                }

            }
        });

        return DownloadButtonView;
    });