license-selector.underscore 5.78 KB
Newer Older
1
<div class="wrapper-license">
2
    <h3 class="label setting-label">
3
        <%= gettext("License Type") %>
4 5
    </h3>
    <ul class="license-types">
6 7
        <% var link_start_tpl = '<a href="{url}" target="_blank">'; %>
        <% _.each(licenseInfo, function(license, licenseType) { %>
8
            <li class="license-type" data-license="<%- licenseType %>">
9 10
                <button name="license-<%- licenseType %>"
                        class="action license-button <% if(model.type === licenseType) { print("is-selected"); } %>"
11
                        aria-pressed="<%- (model.type === licenseType).toString() %>"
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
                        <% if (license.tooltip) { %>data-tooltip="<%- license.tooltip %>"<% } %>>
                    <%- license.name %>
                </button>
                <p class="tip">
                    <% if(license.url) { %>
                        <a href="<%- license.url %>" target="_blank">
                            <%= gettext("Learn more about {license_name}")
                                        .replace("{license_name}", license.name)
                            %>
                        </a>
                    <% } else { %>
                        &nbsp;
                    <% } %>
                </p>
            </li>
        <% }) %>
    </ul>
29 30 31

<% var license = licenseInfo[model.type]; %>
<% if(license && !_.isEmpty(license.options)) { %>
32
    <div class="wrapper-license-options">
33
        <h4 class="label setting-label">
34
            <%- gettext("Options for {license_name}").replace("{license_name}", license.name) %>
35
        </h4>
36 37 38 39
        <p class='tip tip-inline'>
            <%- gettext("The following options are available for the {license_name} license.")
                        .replace("{license_name}", license.name) %>
        </p>
40
        <ul class="license-options">
41 42 43 44
            <% _.each(license.option_order, function(optionKey) { %>
                <% var optionInfo = license.options[optionKey]; %>
                <% if (optionInfo.type == "boolean") { %>
                    <% var optionSelected = model.options[optionKey]; %>
45
                    <% var optionDisabled = optionInfo.disabled %>
46
                    <li data-option="<%- optionKey %>"
47 48 49
                        class="action-item license-option
                               <% if (optionSelected) { print("is-selected"); } %>
                               <% if (optionDisabled) { print("is-disabled"); } else { print("is-clickable"); } %>"
50
                    >
51 52 53 54 55 56 57 58
                        <input type="checkbox"
                               id="<%- model.type %>-<%- optionKey %>"
                               name="<%- model.type %>-<%- optionKey %>"
                               aria-describedby="<%- optionKey %>-explanation"
                               <% if(optionSelected) { print('checked="checked"'); } %>
                               <% if(optionDisabled) { print('disabled="disabled"'); } %>
                        />
                        <label for="<%- model.type %>-<%- optionKey %>" class="option-name">
59
                            <%- optionInfo.name %>
60 61 62 63
                        </label>
                        <div id="<%- optionKey %>-explanation" class="explanation">
                            <%- optionInfo.help %>
                        </div>
64 65 66 67 68
                    </li>
                <% } // could implement other types here %>
            <% }) %>
        </ul>
    </div>
69 70 71
<% } %>

<% if (showPreview) { %>
72
    <div class="wrapper-license-preview">
73
        <h4 class="label setting-label">
74
            <%= gettext("License Display") %>
75
        </h4>
76
        <p class="tip">
77
            <%= gettext("The following message will be displayed at the bottom of the courseware pages within your course:") %>
78
        </p>
79
        <div class="license-preview">
80 81 82 83 84 85 86 87 88 89 90 91 92 93
        <% // keep this synchronized with the contents of common/templates/license.html %>
        <% if (model.type === "all-rights-reserved") { %>
            © <span class="license-text"><%= gettext("All Rights Reserved") %></span>
        <% } else if (model.type === "creative-commons") {
             var possible = ["by", "nc", "nd", "sa"];
             var enabled = _.filter(possible, function(option) {
                 return model.options[option] === true || model.options[option.toUpperCase()] === true;
             });
             var version = model.options.ver || "4.0";
             if (_.isEmpty(enabled)) {
                    enabled = ["zero"];
                    version = model.options.ver || "1.0";
             }
        %>
94
            <a rel="license" href="https://creativecommons.org/licenses/<%- enabled.join("-") %>/<%- version %>/">
95 96 97 98 99
            <% if (previewButton) { %>
                <img src="https://licensebuttons.net/l/<%- enabled.join("-") %>/<%- version %>/<%- typeof buttonSize == "string" ? buttonSize : "88x31" %>.png"
                    alt="<%- typeof licenseString == "string" ? licenseString : "" %>"
                    />
            <% } else { %>
100 101
	        <% //<span> must come before <i> icon or else spacing gets messed up %>
                <span class="sr">gettext("Creative Commons licensed content, with terms as follow:")&nbsp;</span><i aria-hidden="true" class="icon-cc"></i>
102
                <% _.each(enabled, function(option) { %>
103
                        <span class="sr"><%- license.options[option.toUpperCase()].name %>&nbsp;</span><i aria-hidden="true" class="icon-cc-<%- option %>"></i>
104 105 106 107 108
                <% }); %>
                <span class="license-text"><%= gettext("Some Rights Reserved") %></span>
            <% } %>
        <% } else { %>
            <%= typeof licenseString == "string" ? licenseString : "" %>
109 110
            <% // Default to ARR license %>
            © <span class="license-text"><%= gettext("All Rights Reserved") %></span>
111 112 113
        <% } %>
        </a>
    </div>
114 115
<% } %>
</div>