commit
8c1b83cffe
|
@ -1,11 +0,0 @@
|
|||
$(document).ready(function(){
|
||||
$('input#user_force_random_password').on('change', function(elem) {
|
||||
var elems = $('#user_password, #user_password_confirmation');
|
||||
|
||||
if ($(this).attr('checked')) {
|
||||
elems.val('').attr('disabled', true);
|
||||
} else {
|
||||
elems.removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
});
|
8
app/assets/javascripts/admin.js.coffee
Normal file
8
app/assets/javascripts/admin.js.coffee
Normal file
|
@ -0,0 +1,8 @@
|
|||
$ ->
|
||||
$('input#user_force_random_password').on 'change', (elem) ->
|
||||
elems = $('#user_password, #user_password_confirmation')
|
||||
|
||||
if $(@).attr 'checked'
|
||||
elems.val('').attr 'disabled', true
|
||||
else
|
||||
elems.removeAttr 'disabled'
|
|
@ -17,134 +17,3 @@
|
|||
//= require raphael
|
||||
//= require branch-graph
|
||||
//= require_tree .
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$(".one_click_select").live("click", function(){
|
||||
$(this).select();
|
||||
});
|
||||
|
||||
$('body').on('ajax:complete, ajax:beforeSend, submit', 'form', function(e){
|
||||
var buttons = $('[type="submit"]', this);
|
||||
switch( e.type ){
|
||||
case 'ajax:beforeSend':
|
||||
case 'submit':
|
||||
buttons.attr('disabled', 'disabled');
|
||||
break;
|
||||
case ' ajax:complete':
|
||||
default:
|
||||
buttons.removeAttr('disabled');
|
||||
break;
|
||||
}
|
||||
})
|
||||
|
||||
$(".account-box").mouseenter(showMenu);
|
||||
$(".account-box").mouseleave(resetMenu);
|
||||
|
||||
$("#projects-list .project").live('click', function(e){
|
||||
if(e.target.nodeName != "A" && e.target.nodeName != "INPUT") {
|
||||
location.href = $(this).attr("url");
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Focus search field by pressing 's' key
|
||||
*/
|
||||
$(document).keypress(function(e) {
|
||||
if( $(e.target).is(":input") ) return;
|
||||
switch(e.which) {
|
||||
case 115: focusSearch();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Commit show suppressed diff
|
||||
*
|
||||
*/
|
||||
$(".supp_diff_link").bind("click", function() {
|
||||
showDiff(this);
|
||||
});
|
||||
|
||||
/**
|
||||
* Note markdown preview
|
||||
*
|
||||
*/
|
||||
$(document).on('click', '#preview-link', function(e) {
|
||||
$('#preview-note').text('Loading...');
|
||||
|
||||
var previewLinkText = ($(this).text() == 'Preview' ? 'Edit' : 'Preview');
|
||||
$(this).text(previewLinkText);
|
||||
|
||||
var note = $('#note_note').val();
|
||||
if (note.trim().length === 0) { note = 'Nothing to preview'; }
|
||||
$.post($(this).attr('href'), {note: note}, function(data) {
|
||||
$('#preview-note').html(data);
|
||||
});
|
||||
|
||||
$('#preview-note, #note_note').toggle();
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
function focusSearch() {
|
||||
$("#search").focus();
|
||||
}
|
||||
|
||||
function updatePage(data){
|
||||
$.ajax({type: "GET", url: location.href, data: data, dataType: "script"});
|
||||
}
|
||||
|
||||
function showMenu() {
|
||||
$(this).toggleClass('hover');
|
||||
}
|
||||
|
||||
function resetMenu() {
|
||||
$(this).removeClass("hover");
|
||||
}
|
||||
|
||||
function slugify(text) {
|
||||
return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase();
|
||||
}
|
||||
|
||||
function showDiff(link) {
|
||||
$(link).next('table').show();
|
||||
$(link).remove();
|
||||
}
|
||||
|
||||
(function($){
|
||||
var _chosen = $.fn.chosen;
|
||||
$.fn.extend({
|
||||
chosen: function(options) {
|
||||
var default_options = {'search_contains' : 'true'};
|
||||
$.extend(default_options, options);
|
||||
return _chosen.apply(this, [default_options]);
|
||||
}})
|
||||
})(jQuery);
|
||||
|
||||
|
||||
function ajaxGet(url) {
|
||||
$.ajax({type: "GET", url: url, dataType: "script"});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable button if text field is empty
|
||||
*/
|
||||
function disableButtonIfEmtpyField(field_selector, button_selector) {
|
||||
field = $(field_selector);
|
||||
if(field.val() == "") {
|
||||
field.closest("form").find(button_selector).attr("disabled", "disabled").addClass("disabled");
|
||||
}
|
||||
|
||||
field.on('keyup', function(){
|
||||
var field = $(this);
|
||||
var closest_submit = field.closest("form").find(button_selector);
|
||||
if(field.val() == "") {
|
||||
closest_submit.attr("disabled", "disabled").addClass("disabled");
|
||||
} else {
|
||||
closest_submit.removeAttr("disabled").removeClass("disabled");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
function initGraphNav() {
|
||||
$(".graph svg").css("position", "relative");
|
||||
$("body").bind("keyup", function(e) {
|
||||
if(e.keyCode == 37) { // left
|
||||
$(".graph svg").animate({ left: "+=400" });
|
||||
} else if(e.keyCode == 39) { // right
|
||||
$(".graph svg").animate({ left: "-=400" });
|
||||
}
|
||||
});
|
||||
}
|
10
app/assets/javascripts/graph.js.coffee
Normal file
10
app/assets/javascripts/graph.js.coffee
Normal file
|
@ -0,0 +1,10 @@
|
|||
initGraphNav = ->
|
||||
$('.graph svg').css 'position', 'relative'
|
||||
|
||||
$('body').bind 'keyup', (e) ->
|
||||
if e.keyCode is 37 # left
|
||||
$('.graph svg').animate left: '+=400'
|
||||
else if e.keyCode is 39 # right
|
||||
$('.graph svg').animate left: '-=400'
|
||||
|
||||
window.initGraphNav = initGraphNav
|
|
@ -1,11 +0,0 @@
|
|||
var Loader = {
|
||||
img_src: "/assets/ajax-loader.gif",
|
||||
|
||||
html:
|
||||
function(width) {
|
||||
img = $("<img>");
|
||||
img.attr("width", width);
|
||||
img.attr("src", this.img_src);
|
||||
return img;
|
||||
}
|
||||
}
|
5
app/assets/javascripts/loader.js.coffee
Normal file
5
app/assets/javascripts/loader.js.coffee
Normal file
|
@ -0,0 +1,5 @@
|
|||
Loader =
|
||||
html: (width) ->
|
||||
$('<img>').attr src: '/assets/ajax-loader.gif', width: width
|
||||
|
||||
window.Loader = Loader
|
130
app/assets/javascripts/main.js
Normal file
130
app/assets/javascripts/main.js
Normal file
|
@ -0,0 +1,130 @@
|
|||
$(document).ready(function(){
|
||||
|
||||
$(".one_click_select").live("click", function(){
|
||||
$(this).select();
|
||||
});
|
||||
|
||||
$('body').on('ajax:complete, ajax:beforeSend, submit', 'form', function(e){
|
||||
var buttons = $('[type="submit"]', this);
|
||||
switch( e.type ){
|
||||
case 'ajax:beforeSend':
|
||||
case 'submit':
|
||||
buttons.attr('disabled', 'disabled');
|
||||
break;
|
||||
case ' ajax:complete':
|
||||
default:
|
||||
buttons.removeAttr('disabled');
|
||||
break;
|
||||
}
|
||||
})
|
||||
|
||||
$(".account-box").mouseenter(showMenu);
|
||||
$(".account-box").mouseleave(resetMenu);
|
||||
|
||||
$("#projects-list .project").live('click', function(e){
|
||||
if(e.target.nodeName != "A" && e.target.nodeName != "INPUT") {
|
||||
location.href = $(this).attr("url");
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Focus search field by pressing 's' key
|
||||
*/
|
||||
$(document).keypress(function(e) {
|
||||
if( $(e.target).is(":input") ) return;
|
||||
switch(e.which) {
|
||||
case 115: focusSearch();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Commit show suppressed diff
|
||||
*
|
||||
*/
|
||||
$(".supp_diff_link").bind("click", function() {
|
||||
showDiff(this);
|
||||
});
|
||||
|
||||
/**
|
||||
* Note markdown preview
|
||||
*
|
||||
*/
|
||||
$(document).on('click', '#preview-link', function(e) {
|
||||
$('#preview-note').text('Loading...');
|
||||
|
||||
var previewLinkText = ($(this).text() == 'Preview' ? 'Edit' : 'Preview');
|
||||
$(this).text(previewLinkText);
|
||||
|
||||
var note = $('#note_note').val();
|
||||
if (note.trim().length === 0) { note = 'Nothing to preview'; }
|
||||
$.post($(this).attr('href'), {note: note}, function(data) {
|
||||
$('#preview-note').html(data);
|
||||
});
|
||||
|
||||
$('#preview-note, #note_note').toggle();
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
function focusSearch() {
|
||||
$("#search").focus();
|
||||
}
|
||||
|
||||
function updatePage(data){
|
||||
$.ajax({type: "GET", url: location.href, data: data, dataType: "script"});
|
||||
}
|
||||
|
||||
function showMenu() {
|
||||
$(this).toggleClass('hover');
|
||||
}
|
||||
|
||||
function resetMenu() {
|
||||
$(this).removeClass("hover");
|
||||
}
|
||||
|
||||
function slugify(text) {
|
||||
return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase();
|
||||
}
|
||||
|
||||
function showDiff(link) {
|
||||
$(link).next('table').show();
|
||||
$(link).remove();
|
||||
}
|
||||
|
||||
(function($){
|
||||
var _chosen = $.fn.chosen;
|
||||
$.fn.extend({
|
||||
chosen: function(options) {
|
||||
var default_options = {'search_contains' : 'true'};
|
||||
$.extend(default_options, options);
|
||||
return _chosen.apply(this, [default_options]);
|
||||
}})
|
||||
})(jQuery);
|
||||
|
||||
|
||||
function ajaxGet(url) {
|
||||
$.ajax({type: "GET", url: url, dataType: "script"});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable button if text field is empty
|
||||
*/
|
||||
function disableButtonIfEmtpyField(field_selector, button_selector) {
|
||||
field = $(field_selector);
|
||||
if(field.val() == "") {
|
||||
field.closest("form").find(button_selector).attr("disabled", "disabled").addClass("disabled");
|
||||
}
|
||||
|
||||
field.on('keyup', function(){
|
||||
var field = $(this);
|
||||
var closest_submit = field.closest("form").find(button_selector);
|
||||
if(field.val() == "") {
|
||||
closest_submit.attr("disabled", "disabled").addClass("disabled");
|
||||
} else {
|
||||
closest_submit.removeAttr("disabled").removeClass("disabled");
|
||||
}
|
||||
})
|
||||
}
|
|
@ -1,21 +1,20 @@
|
|||
window.Projects = ->
|
||||
$("#project_name").live "change", ->
|
||||
slug = slugify($(this).val())
|
||||
$("#project_code").val(slug)
|
||||
$("#project_path").val(slug)
|
||||
$('#project_name').on 'change', ->
|
||||
slug = slugify $(@).val()
|
||||
$('#project_code').val slug
|
||||
|
||||
$(".new_project, .edit_project").live "ajax:before", ->
|
||||
$(".project_new_holder, .project_edit_holder").hide()
|
||||
$(".save-project-loader").show()
|
||||
$('.new_project, .edit_project').on 'ajax:before', ->
|
||||
$('.project_new_holder, .project_edit_holder').hide()
|
||||
$('.save-project-loader').show()
|
||||
|
||||
$("form #project_default_branch").chosen()
|
||||
disableButtonIfEmtpyField "#project_name", ".project-submit"
|
||||
$('form #project_default_branch').chosen()
|
||||
disableButtonIfEmtpyField '#project_name', '.project-submit'
|
||||
|
||||
# Git clone panel switcher
|
||||
$ ->
|
||||
scope = $('.project_clone_holder')
|
||||
scope = $ '.project_clone_holder'
|
||||
if scope.length > 0
|
||||
$('a, button', scope).click ->
|
||||
$('a, button', scope).removeClass('active')
|
||||
$(this).addClass('active')
|
||||
$('#project_clone', scope).val($(this).data('clone'))
|
||||
$('a, button', scope).removeClass 'active'
|
||||
$(@).addClass 'active'
|
||||
$('#project_clone', scope).val $(@).data 'clone'
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
$(document).ready(function(){
|
||||
$("#snippets-table .snippet").live('click', function(e){
|
||||
if(e.target.nodeName != "A" && e.target.nodeName != "INPUT") {
|
||||
location.href = $(this).attr("url");
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
6
app/assets/javascripts/snippets.js.coffee
Normal file
6
app/assets/javascripts/snippets.js.coffee
Normal file
|
@ -0,0 +1,6 @@
|
|||
$ ->
|
||||
$('#snippets-table .snippet').live 'click', (e) ->
|
||||
if e.target.nodeName isnt 'A' and e.target.nodeName isnt 'INPUT'
|
||||
location.href = $(@).attr 'url'
|
||||
e.stopPropagation()
|
||||
false
|
|
@ -1,8 +0,0 @@
|
|||
function backToMembers(){
|
||||
$("#new_team_member").hide("slide", { direction: "right" }, 150, function(){
|
||||
$("#team-table").show("slide", { direction: "left" }, 150, function() {
|
||||
$("#new_team_member").remove();
|
||||
$(".add_new").show();
|
||||
});
|
||||
});
|
||||
}
|
|
@ -64,19 +64,14 @@ class CommitsController < ApplicationController
|
|||
@commit.to_patch,
|
||||
type: "text/plain",
|
||||
disposition: 'attachment',
|
||||
filename: (@commit.id.to_s + ".patch")
|
||||
filename: "#{@commit.id.patch}"
|
||||
)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def load_refs
|
||||
if params[:ref].blank?
|
||||
@branch = params[:branch].blank? ? nil : params[:branch]
|
||||
@tag = params[:tag].blank? ? nil : params[:tag]
|
||||
@ref = @branch || @tag || @project.try(:default_branch) || 'master'
|
||||
else
|
||||
@ref = params[:ref]
|
||||
end
|
||||
@ref ||= params[:ref].presence || params[:branch].presence || params[:tag].presence
|
||||
@ref ||= @ref || @project.try(:default_branch) || 'master'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue