Commit ed12a65c authored by Tobias Schmidt's avatar Tobias Schmidt

Default arch download default to amd64

Remove the popular option as it only included a single item.
parent 4f04f9da
......@@ -36,8 +36,8 @@ title: Download
<div class="panel panel-default download-selection">
<div class="panel-body">
Operating system <%= dropdown(:os, Downloads.operating_systems) %>
Architecture <%= dropdown(:arch, Downloads.architectures) %>
Operating system <%= dropdown(:os, Downloads.operating_systems, :popular, popular: %w(darwin linux windows)) %>
Architecture <%= dropdown(:arch, Downloads.architectures, :amd64) %>
</div>
</div>
......
......@@ -24,21 +24,3 @@ module BlogHelper
end
end
include BlogHelper
module DownloadHelper
def format_bytes(bytes)
'%.2f MiB' % (bytes.to_f / 1024 / 1024)
end
def dropdown(name, items)
caption = %(<span class="caption">all</span> <span class="caret"></span>)
button = %(<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">#{caption}</button>)
default = %(<li><a href="#">all</a></li><li><a href="#">popular</a></li><li role="separator" class="divider"></li>)
list = %(<ul class="dropdown-menu">#{default} #{items.map { |i| %(<li><a href="#">#{i}</a></li>) }.join('') }</ul>)
%(<div class="btn-group #{name}">#{button} #{list}</div>)
end
end
include DownloadHelper
......@@ -114,4 +114,25 @@ module Downloads
@data['size']
end
end
module Helper
def format_bytes(bytes)
'%.2f MiB' % (bytes.to_f / 1024 / 1024)
end
def dropdown(name, items, default, groups = {})
additional = groups.map do |name, items|
%(<li data-group="#{items.join(' ')}"><a href="#">#{name}</a></li>)
end.join('')
caption = %(<span class="caption">#{default}</span> <span class="caret"></span>)
button = %(<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">#{caption}</button>)
header = %(<li><a href="#">all</a></li>#{additional}<li role="separator" class="divider"></li>)
list = %(<ul class="dropdown-menu">#{header} #{items.map { |i| %(<li><a href="#">#{i}</a></li>) }.join('') }</ul>)
%(<div class="btn-group #{name}">#{button} #{list}</div>)
end
end
end
include Downloads::Helper
......@@ -20,23 +20,25 @@ $(document).ready(function() {
$(this).replaceWith(link);
});
var selected = function(value, want, popular) {
var selected = function(value, want, group) {
switch(want) {
case 'all':
return true;
case 'popular':
return popular.indexOf(value) > -1;
default:
if (group.length > 0) {
return group.indexOf(value) > -1;
}
return value === want;
}
}
var selectDownloads = function() {
var os = $('.download-selection .os .caption').text();
var osGroup = $('.download-selection .os li:contains("'+os+'")').data("group");
var arch = $('.download-selection .arch .caption').text();
$('.downloads tbody tr').each(function() {
if (selected($(this).data('os').toString(), os, ['darwin', 'linux', 'windows'])
&& selected($(this).data('arch').toString(), arch, ['amd64'])) {
if (selected($(this).data('os').toString(), os, osGroup !== undefined ? osGroup.split(' ') : [])
&& selected($(this).data('arch').toString(), arch, [])) {
$(this).show();
} else {
$(this).hide();
......@@ -44,7 +46,6 @@ $(document).ready(function() {
});
};
$('.download-selection button .caption').text('popular');
selectDownloads();
$('.download-selection a').on('click', function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment