BigW Consortium Gitlab

Commit 316dd9c8 by Dmitriy Zaporozhets

Merge pull request #9819 from huacnlee/do-not-use-coffeescript-in-view

Replace CoffeeScript block into JavaScript in Views.
parents 7199e9ef 18cb430f
......@@ -31,5 +31,5 @@
= f.submit 'Save', class: 'btn btn-save js-save-button'
= link_to "Cancel", admin_labels_path, class: 'btn btn-cancel'
:coffeescript
new Labels
:javascript
new Labels();
......@@ -11,15 +11,17 @@
.controls.pull-left.prepend-top-10
= submit_tag "Validate", class: 'btn btn-success submit-yml'
%p.text-center.loading
%i.fa.fa-refresh.fa-spin
.results.prepend-top-20
:coffeescript
$(".loading").hide()
$('form').bind 'ajax:beforeSend', ->
$(".loading").show()
$('form').bind 'ajax:complete', ->
$(".loading").hide()
:javascript
$(".loading").hide();
$('form').bind('ajax:beforeSend', function() {
$(".loading").show();
});
$('form').bind('ajax:complete', function() {
$(".loading").hide();
});
......@@ -36,7 +36,8 @@
= paginate @members, theme: 'gitlab'
:coffeescript
$('form.member-search-form').on 'submit', (event) ->
event.preventDefault()
Turbolinks.visit @.action + '?' + $(@).serialize()
:javascript
$('form.member-search-form').on('submit', function(event) {
event.preventDefault();
Turbolinks.visit(this.action + '?' + $(this).serialize());
});
......@@ -222,8 +222,8 @@
:javascript
$('.js-more-help-button').click(function(e){
$(this).remove()
$('.hidden-shortcut').show()
e.preventDefault()
$('.js-more-help-button').click(function (e) {
$(this).remove()l
$('.hidden-shortcut').show();
e.preventDefault();
});
......@@ -66,5 +66,5 @@
again.
:coffeescript
new ImporterStatus("#{jobs_import_bitbucket_path}", "#{import_bitbucket_path}")
:javascript
new ImporterStatus("#{jobs_import_bitbucket_path}", "#{import_bitbucket_path}");
......@@ -22,7 +22,7 @@
%strong Map a FogBugz account ID to a GitLab user
%p
Selecting a GitLab user will add a link to the GitLab user in the descriptions
of issues and comments (e.g. "By <a href="#">@johnsmith</a>"). It will also
of issues and comments (e.g. "By <a href="#">@johnsmith</a>"). It will also
associate and/or assign these issues and comments with the selected user.
.table-holder
......@@ -46,5 +46,5 @@
.form-actions
= submit_tag 'Continue to the next step', class: 'btn btn-create'
:coffeescript
new UsersSelect()
:javascript
new UsersSelect();
......@@ -48,5 +48,5 @@
%td.import-actions.job-status
= button_tag "Import", class: "btn js-add-to-import"
:coffeescript
new ImporterStatus("#{jobs_import_fogbugz_path}", "#{import_fogbugz_path}")
:javascript
new ImporterStatus("#{jobs_import_fogbugz_path}", "#{import_fogbugz_path}");
......@@ -43,5 +43,5 @@
%td.import-actions.job-status
= button_tag "Import", class: "btn js-add-to-import"
:coffeescript
new ImporterStatus("#{jobs_import_github_path}", "#{import_github_path}")
:javascript
new ImporterStatus("#{jobs_import_github_path}", "#{import_github_path}");
......@@ -43,5 +43,5 @@
%td.import-actions.job-status
= button_tag "Import", class: "btn js-add-to-import"
:coffeescript
new ImporterStatus("#{jobs_import_gitlab_path}", "#{import_gitlab_path}")
:javascript
new ImporterStatus("#{jobs_import_gitlab_path}", "#{import_gitlab_path}");
......@@ -43,5 +43,5 @@
%td.import-actions.job-status
= button_tag "Import", class: "btn js-add-to-import"
:coffeescript
new ImporterStatus("#{jobs_import_gitorious_path}", "#{import_gitorious_path}")
:javascript
new ImporterStatus("#{jobs_import_gitorious_path}", "#{import_gitorious_path}");
......@@ -67,5 +67,5 @@
= link_to "import flow", new_import_google_code_path
again.
:coffeescript
new ImporterStatus("#{jobs_import_google_code_path}", "#{import_google_code_path}")
:javascript
new ImporterStatus("#{jobs_import_google_code_path}", "#{import_google_code_path}");
......@@ -25,6 +25,6 @@
:javascript
$('.search-input').on('keyup', function(e) {
if (e.keyCode == 27) {
$('.search-input').blur()
$('.search-input').blur();
}
})
});
......@@ -8,5 +8,5 @@
.content_list{:"data-href" => activity_project_path(@project)}
= spinner
:coffeescript
new Activities()
:javascript
new Activities();
......@@ -21,5 +21,5 @@
= submit_tag "Create directory", class: 'btn btn-primary btn-create'
= link_to "Cancel", '#', class: "btn btn-cancel", "data-dismiss" => "modal"
:coffeescript
:javascript
disableButtonIfAnyEmptyField($("#dir-create-form"), ".form-control", ".btn-create");
......@@ -26,6 +26,6 @@
= button_tag button_title, class: 'btn btn-small btn-primary btn-upload-file', id: 'submit-all'
= link_to "Cancel", '#', class: "btn btn-cancel", "data-dismiss" => "modal"
:coffeescript
disableButtonIfEmptyField $('.blob-file-upload-form-js').find('#commit_message'), '.btn-upload-file'
new BlobFileDropzone($('.blob-file-upload-form-js'), '#{method}')
:javascript
disableButtonIfEmptyField($('.blob-file-upload-form-js').find('#commit_message'), '.btn-upload-file');
new BlobFileDropzone($('.blob-file-upload-form-js'), '#{method}');
......@@ -4,11 +4,13 @@
%span.count
= @project.star_count
:coffeescript
$('.project-home-panel .toggle-star').on 'ajax:success', (e, data, status, xhr) ->
$(@).replaceWith(data.html)
.on 'ajax:error', (e, xhr, status, error) ->
new Flash('Star toggle failed. Try again later.', 'alert')
:javascript
$('.project-home-panel .toggle-star').on('ajax:success', function (e, data, status, xhr) {
$(this).replaceWith(data.html);
})
.on('ajax:error', function (e, xhr, status, error) {
new Flash('Star toggle failed. Try again later.', 'alert');
});
- else
= link_to new_user_session_path, class: 'btn has_tooltip star-btn', title: 'You must sign in to star a project' do
......
......@@ -55,5 +55,5 @@
%pre.commit-description
= preserve(gfm(escape_once(@commit.description)))
:coffeescript
$(".commit-info-row.branches").load("#{branches_namespace_project_commit_path(@project.namespace, @project, @commit.id)}")
:javascript
$(".commit-info-row.branches").load("#{branches_namespace_project_commit_path(@project.namespace, @project, @commit.id)}");
......@@ -49,26 +49,24 @@
Commits per weekday
%canvas#weekday-chart
:coffeescript
responsiveChart = (selector, data) ->
options = { "scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2, maintainAspectRatio: false }
:javascript
var responsiveChart = function (selector, data) {
var options = { "scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2, maintainAspectRatio: false };
// get selector by context
var ctx = selector.get(0).getContext("2d");
// pointing parent container to make chart.js inherit its width
var container = $(selector).parent();
var generateChart = function() {
selector.attr('width', $(container).width());
return new Chart(ctx).Bar(data, options);
};
// enabling auto-resizing
$(window).resize(generateChart);
return generateChart();
};
# get selector by context
ctx = selector.get(0).getContext("2d")
# pointing parent container to make chart.js inherit its width
container = $(selector).parent()
generateChart = ->
selector.attr('width', $(container).width())
new Chart(ctx).Bar(data, options)
# enabling auto-resizing
$(window).resize( generateChart )
generateChart()
chartData = (keys, values) ->
data = {
var chartData = function (keys, values) {
var data = {
labels : keys,
datasets : [{
fillColor : "rgba(220,220,220,0.5)",
......@@ -78,13 +76,15 @@
barDatasetSpacing: 1,
data : values
}]
}
};
return data;
};
hourData = chartData(#{@commits_per_time.keys.to_json}, #{@commits_per_time.values.to_json})
responsiveChart($('#hour-chart'), hourData)
var hourData = chartData(#{@commits_per_time.keys.to_json}, #{@commits_per_time.values.to_json});
responsiveChart($('#hour-chart'), hourData);
dayData = chartData(#{@commits_per_week_days.keys.to_json}, #{@commits_per_week_days.values.to_json})
responsiveChart($('#weekday-chart'), dayData)
var dayData = chartData(#{@commits_per_week_days.keys.to_json}, #{@commits_per_week_days.values.to_json});
responsiveChart($('#weekday-chart'), dayData);
monthData = chartData(#{@commits_per_month.keys.to_json}, #{@commits_per_month.values.to_json})
responsiveChart($('#month-chart'), monthData)
var monthData = chartData(#{@commits_per_month.keys.to_json}, #{@commits_per_month.values.to_json});
responsiveChart($('#month-chart'), monthData);
......@@ -28,18 +28,21 @@
:coffeescript
$.ajax
:javascript
$.ajax({
type: "GET",
url: location.href,
success: (data) ->
graph = new ContributorsStatGraph()
graph.init(data)
dataType: "json",
success: function (data) {
var graph = new ContributorsStatGraph();
graph.init(data);
$("#brush_change").change ->
graph.change_date_header()
graph.redraw_authors()
$("#brush_change").change(function(){
graph.change_date_header();
graph.redraw_authors();
});
$(".stat-graph").fadeIn();
$(".loading-graph").hide();
dataType: "json"
}
});
......@@ -77,12 +77,13 @@
});
:coffeescript
$(".merge-request-form").on 'submit', ->
if $("#merge_request_source_branch").val() is "" or $('#merge_request_target_branch').val() is ""
$(".mr-compare-errors").html("You must select source and target branch to proceed")
$(".mr-compare-errors").fadeIn()
event.preventDefault()
return
:javascript
$(".merge-request-form").on('submit', function () {
if ($("#merge_request_source_branch").val() === "" || $('#merge_request_target_branch').val() === "") {
$(".mr-compare-errors").html("You must select source and target branch to proceed");
$(".mr-compare-errors").fadeIn();
event.preventDefault();
return;
}
});
......@@ -38,6 +38,7 @@
= icon("times-circle")
Could not connect to the CI server. Please check your settings and try again.
:coffeescript
$ ->
merge_request_widget.getCiStatus()
:javascript
$(function() {
merge_request_widget.getCiStatus();
});
......@@ -15,7 +15,7 @@
- elsif can_remove_branch?(@merge_request.source_project, @merge_request.source_branch)
.remove_source_branch_widget
%p
%p
= succeed '.' do
The changes were merged into
%span.label-branch= @merge_request.target_branch
......@@ -25,7 +25,7 @@
Remove Source Branch
.remove_source_branch_widget.failed.hide
%p
%p
Failed to remove source branch '#{@merge_request.source_branch}'.
.remove_source_branch_in_progress.hide
......@@ -33,17 +33,20 @@
= icon('spinner spin')
Removing source branch '#{@merge_request.source_branch}'. Please wait. This page will be automatically reload.
:coffeescript
$('.remove_source_branch').on 'click', ->
$('.remove_source_branch_widget').hide()
$('.remove_source_branch_in_progress').show()
$(".remove_source_branch").on "ajax:success", (e, data, status, xhr) ->
location.reload()
$(".remove_source_branch").on "ajax:error", (e, data, status, xhr) ->
$('.remove_source_branch_widget').hide()
$('.remove_source_branch_in_progress').hide()
$('.remove_source_branch_widget.failed').show()
:javascript
$('.remove_source_branch').on('click', function() {
$('.remove_source_branch_widget').hide();
$('.remove_source_branch_in_progress').show();
});
$(".remove_source_branch").on("ajax:success", function (e, data, status, xhr) {
location.reload();
});
$(".remove_source_branch").on("ajax:error", function (e, data, status, xhr) {
$('.remove_source_branch_widget').hide();
$('.remove_source_branch_in_progress').hide();
$('.remove_source_branch_widget.failed').show();
});
......@@ -20,8 +20,9 @@
text: @merge_request.merge_commit_message,
rows: 14, hint: true
:coffeescript
$('.accept-mr-form').on 'ajax:before', ->
btn = $('.accept_merge_request')
btn.disable()
btn.html("<i class='fa fa-spinner fa-spin'></i> Merge in progress")
:javascript
$('.accept-mr-form').on('ajax:before', function() {
var btn = $('.accept_merge_request');
btn.disable();
btn.html("<i class='fa fa-spinner fa-spin'></i> Merge in progress");
});
......@@ -2,6 +2,8 @@
= icon("spinner spin")
Checking ability to merge automatically&hellip;
:coffeescript
$ ->
merge_request_widget.getMergeStatus()
:javascript
$(function() {
merge_request_widget.getMergeStatus();
});
......@@ -124,9 +124,11 @@
Creating project &amp; repository.
%p Please wait a moment, this page will automatically refresh when ready.
:coffeescript
$('.how_to_import_link').bind 'click', (e) ->
e.preventDefault()
import_modal = $(this).next(".modal").show()
$('.modal-header .close').bind 'click', ->
$(".modal").hide()
:javascript
$('.how_to_import_link').bind('click', function (e) {
e.preventDefault();
var import_modal = $(this).next(".modal").show();
});
$('.modal-header .close').bind('click', function() {
$(".modal").hide();
});
......@@ -29,7 +29,8 @@
- if @group
= render "group_members", members: @group_members
:coffeescript
$('form.member-search-form').on 'submit', (event) ->
event.preventDefault()
Turbolinks.visit @.action + '?' + $(@).serialize()
:javascript
$('form.member-search-form').on('submit', function (event) {
event.preventDefault();
Turbolinks.visit(this.action + '?' + $(this).serialize());
});
......@@ -45,6 +45,6 @@
.description-block.subscribed{class: ( 'hidden' unless subscribed )}
You're receiving notifications because you're subscribed to this thread.
:coffeescript
new Subscription("#{toggle_subscription_path(issuable)}")
new IssuableContext()
:javascript
new Subscription("#{toggle_subscription_path(issuable)}");
new IssuableContext();
......@@ -60,9 +60,9 @@
= hidden_field_tag :state_event, params[:state_event]
= button_tag "Update issues", class: "btn update_selected_issues btn-save"
:coffeescript
new UsersSelect()
$('form.filter-form').on 'submit', (event) ->
event.preventDefault()
Turbolinks.visit @.action + '&' + $(@).serialize()
:javascript
new UsersSelect();
$('form.filter-form').on('submit', function (event) {
event.preventDefault();
Turbolinks.visit(this.action + '&' + $(this).serialize());
});
......@@ -17,5 +17,5 @@
= link_to '#', class: 'js-expand' do
Show all
:coffeescript
new ProjectsList()
:javascript
new ProjectsList();
......@@ -115,5 +115,5 @@
projects: @projects.sort_by(&:star_count).reverse,
projects_limit: 10, stars: true, avatar: true
:coffeescript
$(".user-calendar").load("#{user_calendar_path}")
:javascript
$(".user-calendar").load("#{user_calendar_path}");
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