Commit 7d56a51b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Js refactoring and ajax animation replaced

parent f1c534c6
...@@ -70,3 +70,7 @@ function showMenu() { ...@@ -70,3 +70,7 @@ function showMenu() {
function resetMenu() { function resetMenu() {
$(this).removeClass("hover"); $(this).removeClass("hover");
} }
function slugify(text) {
return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase();
}
...@@ -31,10 +31,12 @@ var MergeRequest = { ...@@ -31,10 +31,12 @@ var MergeRequest = {
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: $(".merge-diffs-tab").attr("data-url"), url: $(".merge-diffs-tab").attr("data-url"),
beforeSend: function(){ $('.status').addClass("loading")},
complete: function(){ complete: function(){
MergeRequest.diffs_loaded = true; MergeRequest.diffs_loaded = true;
$(".merge_request_notes").hide(); $(".merge_request_notes").hide();
$(".dashboard-loader").hide()}, $('.status').removeClass("loading");
},
dataType: "script"}); dataType: "script"});
} }
} }
function Projects() {
$("#project_name").live("change", function(){
var slug = slugify($(this).val());
$("#project_code").val(slug);
$("#project_path").val(slug);
});
$('.new_project, .edit_project').live('ajax:before', function() {
$('.project_new_holder, .project_edit_holder').hide();
$('.ajax_loader').show();
});
$('form #project_default_branch').chosen();
}
...@@ -589,7 +589,7 @@ table a code { ...@@ -589,7 +589,7 @@ table a code {
.loading { .loading {
margin:20px auto; margin:20px auto;
background: url(ajax-loader-facebook.gif) no-repeat center center; background: url(ajax_loader.gif) no-repeat center center;
width:40px; width:40px;
height:40px; height:40px;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Issues Issues
%span.rss-icon %span.rss-icon
= link_to project_issues_path(@project, :atom, { :private_token => current_user.private_token }) do = link_to project_issues_path(@project, :atom, { :private_token => current_user.private_token }) do
= image_tag "Rss-UI.PNG", :width => 22, :title => "feed" = image_tag "Rss-UI.PNG", :width => 16, :title => "feed"
- if can? current_user, :write_issue, @project - if can? current_user, :write_issue, @project
= link_to new_project_issue_path(@project), :class => "right btn small", :title => "New Issue", :remote => true do = link_to new_project_issue_path(@project), :class => "right btn small", :title => "New Issue", :remote => true do
......
...@@ -73,12 +73,11 @@ ...@@ -73,12 +73,11 @@
= link_to "#diffs", "data-url" => diffs_project_merge_request_path(@project, @merge_request), :class => "merge-diffs-tab tab" do = link_to "#diffs", "data-url" => diffs_project_merge_request_path(@project, @merge_request), :class => "merge-diffs-tab tab" do
Diff Diff
%img{:src => "/assets/ajax-loader-facebook.gif", :class => "dashboard-loader"}
.merge_request_notes#notes= render "notes/notes", :tid => @merge_request.id, :tt => "merge_request" .merge_request_notes#notes= render "notes/notes", :tid => @merge_request.id, :tt => "merge_request"
.merge-request-diffs .merge-request-diffs
.status
:javascript :javascript
$(function(){ $(function(){
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
.clearfix .clearfix
= f.label :description = f.label :description
.input .input
= f.text_area :description, :placeholder => "project description", :class => "xlarge", :rows => 4 = f.text_area :description, :placeholder => "project description", :class => "xxlarge", :rows => 5
%p.hint Markdown is enabled. %p.hint Markdown is enabled.
%br %br
......
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
location.href = "#{project_path(@project, :notice => 'Project was successfully created.')}"; location.href = "#{project_path(@project, :notice => 'Project was successfully created.')}";
- else - else
:plain :plain
$('.project_new_holder').show();
$("#new_project").replaceWith("#{escape_javascript(render('form'))}"); $("#new_project").replaceWith("#{escape_javascript(render('form'))}");
$('.ajax_loader').hide(); $('.ajax_loader').hide();
= render "project_head" = render "project_head"
%h3 Edit Project .project_edit_holder
%hr %h3 Edit Project
= render "projects/form" %hr
%div{ :class => "ajax_loader", :style => "display:none;height:200px;"} = render "projects/form"
%div.ajax_loader.hide
%center %center
= image_tag "ajax-loader.gif", :class => "append-bottom" %div.padded= image_tag "ajax_loader.gif"
%h3.prepend-top Saving project & repository. Please wait... %h3.prepend-top Saving project & repository. Please wait...
:javascript :javascript
$(function(){ $(function(){ new Projects(); });
$("#project_name").live("change", function(){
var slug = slugify($(this).val());
$("#project_code").val(slug);
$("#project_path").val(slug);
});
});
function slugify(text) {
return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase();
}
$(function(){
$('.edit_project').live('ajax:before', function() {
$(this).hide();
$('.ajax_loader').show();
});
$('form #project_default_branch').chosen();
})
%h3 New Project .project_new_holder
%hr %h3 New Project
= render 'form' %hr
%div{ :class => "ajax_loader", :style => "display:none;height:200px;"} = render 'form'
%div.ajax_loader.hide
%center %center
= image_tag "ajax-loader.gif", :class => "append-bottom" %div.padded= image_tag "ajax_loader.gif"
%h3.prepend-top Creating project & repository. Please wait for few minutes %h3.prepend-top Creating project & repository. Please wait for few minutes
:javascript :javascript
$(function(){ $(function(){ new Projects(); });
$("#project_name").live("change", function(){
var slug = slugify($(this).val());
$("#project_code").val(slug);
$("#project_path").val(slug);
});
});
function slugify(text) {
return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase();
}
$(function(){
$('.new_project').live('ajax:before', function() {
$(this).hide();
$('.ajax_loader').show();
});
$('form #project_default_branch').chosen();
})
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
location.href = "#{edit_project_path(@project, :notice => 'Project was successfully updated.')}"; location.href = "#{edit_project_path(@project, :notice => 'Project was successfully updated.')}";
- else - else
:plain :plain
$('.project_edit_holder').show();
$(".edit_project").replaceWith("#{escape_javascript(render('form'))}"); $(".edit_project").replaceWith("#{escape_javascript(render('form'))}");
$('.ajax_loader').hide(); $('.ajax_loader').hide();
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