1
0
mirror of https://github.com/github/choosealicense.com synced 2024-12-22 04:40:09 +01:00

made partial for license overview sections

This commit is contained in:
Jason Long 2013-11-06 11:24:34 -05:00
parent 246cbc8d65
commit f28894d905
6 changed files with 88 additions and 57 deletions

View File

@ -0,0 +1,49 @@
<div class="license-family cf">
<div class="license-family-heading">
<h3 class="license-family-name"><a href="{{ page.permalink }}">{% if page.family-title %}{{ page.family-title }}{% else %}{{ page.title }}{% endif %}</a></h3>
<p class="license-family-description">{{ page.description }}</p>
</div>
<div class="license-details">
<div class="license-variations js-license-variations">
<!-- always show this div, even w/o variations, for proper spacing -->
<ul class="nav-pills js-nav-pills">
<li class="active"><a href="#" data-selected-tab="variation-gpl-v2">GPL v2</a></li>
<li><a href="#" data-selected-tab="variation-gpl-v3">GPL v3</a></li>
<li><a href="#" data-selected-tab="variation-affero-gpl">Affero GPL</a></li>
</ul>
</div>
<div class="variation-tab variation-gpl-v2 js-variation-tab active">
<table class='license-rules'>
<tr>
{% assign types = "required|permitted|forbidden" | split: "|" %}
{% for type in types %}
<th class="label">{{ type | capitalize }}</th>
{% endfor %}
</tr>
<tr>
{% for type in types %}
<td>
<ul class="license-{{ type }}">
{% for req in page[type] %}
<li class="{{ req }}">{{ site.rules[type][req].label }}</li>
{% endfor %}
</ul>
</td>
{% endfor %}
</tr>
</table>
<p class="small"><a href="{{ page.permalink }}">View full GPL v2 license »</a></p>
</div>
<div class="variation-tab variation-gpl-v3 js-variation-tab">
GPL v3 table
<p class="small"><a href="{{ page.permalink }}">View full GPL v3 license »</a></p>
</div>
<div class="variation-tab variation-affero-gpl js-variation-tab">
Affero GPL table
<p class="small"><a href="{{ page.permalink }}">View full Affero GPL license »</a></p>
</div>
</div>
</div>

View File

@ -425,6 +425,14 @@ strong {
color: #f7f4ef;
}
.variation-tab {
display: none;
}
.variation-tab.active {
display: block;
}
.small {
font-size: 90%;
}

View File

@ -36,6 +36,7 @@ class Choosealicense
constructor: ->
@initTooltips()
@initClipboard()
@initLicenseVariationNav()
# Init tooltip action
initTooltips: ->
@ -92,5 +93,18 @@ class Choosealicense
clipboardComplete: (client, args) ->
@innerText = "Copied!"
# Initializes pill navigation for license variations
initLicenseVariationNav: ->
$(".js-nav-pills a").click (e) ->
selectedTab = $(this).data('selected-tab')
nav = $(this).closest('.js-nav-pills')
nav.find('li').removeClass('active')
nav.closest('.js-license-variations').siblings('.js-variation-tab').removeClass('active')
$(this).parent('li').addClass('active')
$('.' + selectedTab).addClass('active')
e.preventDefault()
$ ->
new Choosealicense()

View File

@ -40,6 +40,7 @@
function Choosealicense() {
this.initTooltips();
this.initClipboard();
this.initLicenseVariationNav();
}
Choosealicense.prototype.initTooltips = function() {
@ -106,6 +107,19 @@
return this.innerText = "Copied!";
};
Choosealicense.prototype.initLicenseVariationNav = function() {
return $(".js-nav-pills a").click(function(e) {
var nav, selectedTab;
selectedTab = $(this).data('selected-tab');
nav = $(this).closest('.js-nav-pills');
nav.find('li').removeClass('active');
nav.closest('.js-license-variations').siblings('.js-variation-tab').removeClass('active');
$(this).parent('li').addClass('active');
$('.' + selectedTab).addClass('active');
return e.preventDefault();
});
};
return Choosealicense;
})();

View File

@ -11,45 +11,7 @@ class: license-types
{% for page in site.pages %}
{% if page.layout == "license" %}
{% if page.featured %}
<div class="license-family cf">
<div class="license-family-heading">
<h3 class="license-family-name"><a href="{{ page.permalink }}">{% if page.family-title %}{{ page.family-title }}{% else %}{{ page.title }}{% endif %}</a></h3>
<p class="license-family-description">{{ page.description }}</p>
</div>
<div class="license-details">
<div class="license-variations">
{% comment %} always show this div, even w/o variations, for proper spacing {% endcomment %}
<ul class="nav-pills">
<li class="active"><a href="#">GPL v2</a></li>
<li><a href="#">GPL v3</a></li>
<li><a href="#">Affero GPL</a></li>
</ul>
</div>
<table class='license-rules'>
<tr>
{% assign types = "required|permitted|forbidden" | split: "|" %}
{% for type in types %}
<th class="label">{{ type | capitalize }}</th>
{% endfor %}
</tr>
<tr>
{% for type in types %}
<td>
<ul class="license-{{ type }}">
{% for req in page[type] %}
<li class="{{ req }}">{{ site.rules[type][req].label }}</li>
{% endfor %}
</ul>
</td>
{% endfor %}
</tr>
</table>
<p class="small"><a href="{{ page.permalink }}">View full GPL v2 license »</a></p>
</div>
</div>
{% include license-overview.html %}
{% endif %}
{% endif %}
{% endfor %}
@ -63,23 +25,7 @@ class: license-types
{% for page in site.pages %}
{% if page.layout == "license" %}
{% if page.featured != true and page.hide-from-license-list != true %}
<h3 class="license-family-name"><a href="{{ page.permalink }}">{% if page.family-title %}{{ page.family-title }}{% else %}{{ page.title }}{% endif %}</a></h3>
<p class="license-family-description">{{ page.description }} <a href="{{ page.permalink }}">View full license »</a></p>
<table class='license-rules'>
{% assign types = "required|permitted|forbidden" | split: "|" %}
{% for type in types %}
<tr>
<td class="label">{{ type | capitalize }}</td>
<td>
<ul class="license-{{ type }}">
{% for req in page[type] %}
<li class="{{ req }}">{{ site.rules[type][req].label }}</li>
{% endfor %}
</ul>
</td>
</tr>
{% endfor %}
</table>
{% include license-overview.html %}
{% endif %}
{% endif %}
{% endfor %}

View File

@ -6,7 +6,7 @@ layout: license
permalink: /licenses/gpl-v2/
source: http://www.gnu.org/licenses/gpl-2.0.txt
description: GPL is the most widely used free software license and has a strong copyleft requirement. When distributing derived works, the source code of the work must be made available under the same license. There are multiple variants of the GPL each with different requirements, <a href="gpl-v2/">GPL v2</a>, <a href="gpl-v3/">GPL v3</a>, and <a href="agpl/">Affero GPL</a>.
description: GPL is the most widely used free software license and has a strong copyleft requirement. When distributing derived works, the source code of the work must be made available under the same license. There are multiple variants of the GPL each with different requirements.
featured: true