[refs #385] add dropdown menu to choose archive format
This commit is contained in:
parent
b281cdf65b
commit
5cfadcd723
|
@ -817,6 +817,15 @@ div#git_help_data p {
|
||||||
|
|
||||||
.zip {
|
.zip {
|
||||||
float: left;
|
float: left;
|
||||||
margin-left: 5px;
|
padding-left: 5px;
|
||||||
margin-top: 11px;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nav > li > a:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
background-color: #D6E4E1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
|
@ -95,7 +95,7 @@ class ProjectsController < ApplicationController
|
||||||
file = Tempfile.new fullname, 'tmp'
|
file = Tempfile.new fullname, 'tmp'
|
||||||
system("cd #{@project.path}; git archive --format=#{format} --prefix=#{name}/ #{treeish} #{format == 'tar' ? ' | gzip -9' : ''} > #{file.path}")
|
system("cd #{@project.path}; git archive --format=#{format} --prefix=#{name}/ #{treeish} #{format == 'tar' ? ' | gzip -9' : ''} > #{file.path}")
|
||||||
file.close
|
file.close
|
||||||
send_file file.path, :disposition => 'attachment', :type => "application/#{format == 'tar' ? 'x-tar' : 'zip'}",
|
send_file file.path, :disposition => 'attachment', :type => "application/#{format == 'tar' ? 'x-tar-gz' : 'zip'}",
|
||||||
:filename => fullname
|
:filename => fullname
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
.description-top
|
.description-top
|
||||||
.zip= link_to "TAR", archive_path(project.id, 'tar', @treeish)
|
%ul.nav.zip
|
||||||
|
%li#menu-archive.dropdown
|
||||||
|
%a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#menu-archive"}
|
||||||
|
ZIP
|
||||||
|
%b.caret
|
||||||
|
%ul.dropdown-menu
|
||||||
|
%li=link_to "tar.gz", archive_path(project.id, 'tar', @treeish)
|
||||||
|
%li=link_to "zip", archive_path(project.id, 'zip', @treeish)
|
||||||
|
|
||||||
= text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', :spellcheck => 'false', :readonly => true
|
= text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', :spellcheck => 'false', :readonly => true
|
||||||
.git_help ?
|
.git_help ?
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
/* ============================================================
|
||||||
|
* bootstrap-dropdown.js v2.0.2
|
||||||
|
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
|
||||||
|
* ============================================================
|
||||||
|
* Copyright 2012 Twitter, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ============================================================ */
|
||||||
|
|
||||||
|
|
||||||
|
!function( $ ){
|
||||||
|
|
||||||
|
"use strict"
|
||||||
|
|
||||||
|
/* DROPDOWN CLASS DEFINITION
|
||||||
|
* ========================= */
|
||||||
|
|
||||||
|
var toggle = '[data-toggle="dropdown"]'
|
||||||
|
, Dropdown = function ( element ) {
|
||||||
|
var $el = $(element).on('click.dropdown.data-api', this.toggle)
|
||||||
|
$('html').on('click.dropdown.data-api', function () {
|
||||||
|
$el.parent().removeClass('open')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Dropdown.prototype = {
|
||||||
|
|
||||||
|
constructor: Dropdown
|
||||||
|
|
||||||
|
, toggle: function ( e ) {
|
||||||
|
var $this = $(this)
|
||||||
|
, selector = $this.attr('data-target')
|
||||||
|
, $parent
|
||||||
|
, isActive
|
||||||
|
|
||||||
|
if (!selector) {
|
||||||
|
selector = $this.attr('href')
|
||||||
|
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||||
|
}
|
||||||
|
|
||||||
|
$parent = $(selector)
|
||||||
|
$parent.length || ($parent = $this.parent())
|
||||||
|
|
||||||
|
isActive = $parent.hasClass('open')
|
||||||
|
|
||||||
|
clearMenus()
|
||||||
|
!isActive && $parent.toggleClass('open')
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearMenus() {
|
||||||
|
$(toggle).parent().removeClass('open')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* DROPDOWN PLUGIN DEFINITION
|
||||||
|
* ========================== */
|
||||||
|
|
||||||
|
$.fn.dropdown = function ( option ) {
|
||||||
|
return this.each(function () {
|
||||||
|
var $this = $(this)
|
||||||
|
, data = $this.data('dropdown')
|
||||||
|
if (!data) $this.data('dropdown', (data = new Dropdown(this)))
|
||||||
|
if (typeof option == 'string') data[option].call($this)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$.fn.dropdown.Constructor = Dropdown
|
||||||
|
|
||||||
|
|
||||||
|
/* APPLY TO STANDARD DROPDOWN ELEMENTS
|
||||||
|
* =================================== */
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
$('html').on('click.dropdown.data-api', clearMenus)
|
||||||
|
$('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
|
||||||
|
})
|
||||||
|
|
||||||
|
}( window.jQuery );
|
|
@ -9,5 +9,6 @@
|
||||||
//= require cusel
|
//= require cusel
|
||||||
//= require bootstrap-modal
|
//= require bootstrap-modal
|
||||||
//= require bootstrap-button
|
//= require bootstrap-button
|
||||||
|
//= require bootstrap-dropdown
|
||||||
// require html5shiv
|
// require html5shiv
|
||||||
// require_tree .
|
// require_tree .
|
||||||
|
|
|
@ -299,3 +299,124 @@
|
||||||
.modal-footer .btn-group .btn + .btn {
|
.modal-footer .btn-group .btn + .btn {
|
||||||
margin-left: -1px;
|
margin-left: -1px;
|
||||||
}
|
}
|
||||||
|
.dropdown {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.dropdown-toggle {
|
||||||
|
*margin-bottom: -3px;
|
||||||
|
}
|
||||||
|
.dropdown-toggle:active,
|
||||||
|
.open .dropdown-toggle {
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
.caret {
|
||||||
|
display: inline-block;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
vertical-align: top;
|
||||||
|
border-left: 4px solid transparent;
|
||||||
|
border-right: 4px solid transparent;
|
||||||
|
border-top: 4px solid #000000;
|
||||||
|
opacity: 0.3;
|
||||||
|
filter: alpha(opacity=30);
|
||||||
|
content: "";
|
||||||
|
}
|
||||||
|
.dropdown .caret {
|
||||||
|
margin-top: 8px;
|
||||||
|
margin-left: 2px;
|
||||||
|
}
|
||||||
|
.dropdown:hover .caret,
|
||||||
|
.open.dropdown .caret {
|
||||||
|
opacity: 1;
|
||||||
|
filter: alpha(opacity=100);
|
||||||
|
}
|
||||||
|
.dropdown-menu {
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
z-index: 1000;
|
||||||
|
float: left;
|
||||||
|
display: none;
|
||||||
|
min-width: 160px;
|
||||||
|
padding: 4px 0;
|
||||||
|
margin: 0;
|
||||||
|
list-style: none;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-color: #ccc;
|
||||||
|
border-color: rgba(0, 0, 0, 0.2);
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px;
|
||||||
|
-webkit-border-radius: 0 0 5px 5px;
|
||||||
|
-moz-border-radius: 0 0 5px 5px;
|
||||||
|
border-radius: 0 0 5px 5px;
|
||||||
|
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||||
|
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||||
|
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
|
||||||
|
-webkit-background-clip: padding-box;
|
||||||
|
-moz-background-clip: padding;
|
||||||
|
background-clip: padding-box;
|
||||||
|
*border-right-width: 2px;
|
||||||
|
*border-bottom-width: 2px;
|
||||||
|
}
|
||||||
|
.dropdown-menu.pull-right {
|
||||||
|
right: 0;
|
||||||
|
left: auto;
|
||||||
|
}
|
||||||
|
.dropdown-menu .divider {
|
||||||
|
height: 1px;
|
||||||
|
margin: 8px 1px;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #e5e5e5;
|
||||||
|
border-bottom: 1px solid #ffffff;
|
||||||
|
*width: 100%;
|
||||||
|
*margin: -5px 0 5px;
|
||||||
|
}
|
||||||
|
.dropdown-menu a {
|
||||||
|
display: block;
|
||||||
|
padding: 3px 15px;
|
||||||
|
clear: both;
|
||||||
|
font-weight: normal;
|
||||||
|
line-height: 18px;
|
||||||
|
color: #333333;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.dropdown-menu li > a:hover,
|
||||||
|
.dropdown-menu .active > a,
|
||||||
|
.dropdown-menu .active > a:hover {
|
||||||
|
color: #ffffff;
|
||||||
|
text-decoration: none;
|
||||||
|
background-color: #0088cc;
|
||||||
|
}
|
||||||
|
.dropdown.open {
|
||||||
|
*z-index: 1000;
|
||||||
|
}
|
||||||
|
.dropdown.open .dropdown-toggle {
|
||||||
|
color: #ffffff;
|
||||||
|
background: #ccc;
|
||||||
|
background: rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
.dropdown.open .dropdown-menu {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.pull-right .dropdown-menu {
|
||||||
|
left: auto;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
.dropup .caret,
|
||||||
|
.navbar-fixed-bottom .dropdown .caret {
|
||||||
|
border-top: 0;
|
||||||
|
border-bottom: 4px solid #000000;
|
||||||
|
content: "\2191";
|
||||||
|
}
|
||||||
|
.dropup .dropdown-menu,
|
||||||
|
.navbar-fixed-bottom .dropdown .dropdown-menu {
|
||||||
|
top: auto;
|
||||||
|
bottom: 100%;
|
||||||
|
margin-bottom: 1px;
|
||||||
|
}
|
||||||
|
.typeahead {
|
||||||
|
margin-top: 2px;
|
||||||
|
-webkit-border-radius: 4px;
|
||||||
|
-moz-border-radius: 4px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
Loading…
Reference in New Issue