Permalink
Browse files

Convert all inline JS to use content_for :script_on_load

  • Loading branch information...
riyad committed Dec 22, 2012
1 parent 5f1a385 commit db3ce5bf7badc2e46f60963fcd612c8ab5819d69
Showing with 116 additions and 136 deletions.
  1. +3 −5 app/views/admin/groups/show.html.haml
  2. +2 −6 app/views/admin/projects/_form.html.haml
  3. +2 −5 app/views/commit/show.html.haml
  4. +2 −4 app/views/commits/show.html.haml
  5. +2 −3 app/views/compare/_form.html.haml
  6. +4 −2 app/views/dashboard/index.html.haml
  7. +5 −4 app/views/devise/sessions/_new_ldap.html.haml
  8. +4 −4 app/views/groups/search.html.haml
  9. +3 −2 app/views/groups/show.html.haml
  10. +2 −3 app/views/issues/_form.html.haml
  11. +2 −3 app/views/issues/index.html.haml
  12. +10 −9 app/views/keys/new.html.haml
  13. +2 −3 app/views/layouts/_init_auto_complete.html.haml
  14. +2 −3 app/views/layouts/_search.html.haml
  15. +2 −3 app/views/merge_requests/_form.html.haml
  16. +2 −4 app/views/merge_requests/_show.html.haml
  17. +2 −3 app/views/merge_requests/diffs.html.haml
  18. +3 −4 app/views/merge_requests/index.html.haml
  19. +3 −5 app/views/merge_requests/show/_how_to_merge.html.haml
  20. +4 −4 app/views/milestones/_form.html.haml
  21. +2 −3 app/views/notes/_notes_with_form.html.haml
  22. +2 −3 app/views/notes/_per_line_form.html.haml
  23. +2 −3 app/views/notes/_reversed_notes_with_form.html.haml
  24. +3 −2 app/views/projects/edit.html.haml
  25. +8 −7 app/views/projects/graph.html.haml
  26. +3 −2 app/views/projects/new.html.haml
  27. +3 −2 app/views/projects/show.html.haml
  28. +2 −3 app/views/repositories/stats.html.haml
  29. +4 −4 app/views/search/show.html.haml
  30. +6 −6 app/views/snippets/_form.html.haml
  31. +2 −4 app/views/team_members/_team.html.haml
  32. +3 −3 app/views/team_members/show.html.haml
  33. +3 −4 app/views/tree/_tree.html.haml
  34. +12 −11 app/views/tree/edit.html.haml
@@ -79,8 +79,8 @@
.form-actions
= submit_tag 'Add', class: "btn primary"
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
var modal = $('.change-owner-holder');
$('.change-owner-link').bind("click", function(){
$(this).hide();
@@ -89,6 +89,4 @@
$('.change-owner-cancel-link').bind("click", function(){
modal.hide();
$('.change-owner-link').show();
- })
- })
-
+ });
@@ -61,10 +61,6 @@
= f.submit 'Save Project', class: "btn save-btn"
= link_to 'Cancel', admin_projects_path, class: "btn cancel-btn"
-
-
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
new Projects();
- })
-
@@ -3,9 +3,8 @@
= render "notes/notes_with_form", tid: @commit.id, tt: "commit"
= render "notes/per_line_form"
-
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
PerLineNotes.init();
var w, h;
$('.diff_file').each(function(){
@@ -19,7 +18,5 @@
, h = event.currentTarget.naturalHeight;
$('.image.diff_added .image-info', this).append(' | <b>W:</b> ' + w + 'px | <b>H:</b> ' + h + 'px');
}, this));
-
});
-
});
@@ -10,8 +10,6 @@
.loading{ style: "display:none;"}
- if @commits.count == @limit
- :javascript
- $(function(){
+ - content_for :script_on_load do
+ :plain
CommitsList.init("#{@ref}", #{@limit});
- });
-
@@ -26,8 +26,8 @@
-:javascript
- $(function() {
+- content_for :script_on_load do
+ :plain
var availableTags = #{@project.ref_names.to_json};
$("#from, #to").autocomplete({
@@ -36,4 +36,3 @@
});
disableButtonIfEmptyField('#to', '.commits-compare-btn');
- });
@@ -7,5 +7,7 @@
- else
= render "zero_authorized_projects"
-:javascript
- $(function(){ Pager.init(20); });
+
+- content_for :script_on_load do
+ :plain
+ Pager.init(20);
@@ -11,10 +11,11 @@
%br/
%hr/
%a#other_form_toggle{:href => "#", :onclick => "javascript:$('#new_user').toggle();"} Other Sign in
- :javascript
- $(function() {
- $('#new_user').toggle();
- });
+
+- content_for :script_on_load do
+ :plain
+ $('#new_user').toggle();
+
= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => "login-box" }) do |f|
= f.text_field :email, :class => "text top", :placeholder => "Email"
= f.password_field :password, :class => "text bottom", :placeholder => "Password"
@@ -69,7 +69,7 @@
%tr
%td
%h4.nothing_here_message No Issues
- :javascript
- $(function() {
- $(".search_results .term").highlight("#{params[:search]}");
- })
+
+- content_for :script_on_load do
+ :plain
+ $(".search_results .term").highlight("#{params[:search]}");
@@ -25,5 +25,6 @@
= link_to "Blog", "http://blog.gitlabhq.com"
= link_to "@gitlabhq", "https://twitter.com/gitlabhq"
-:javascript
- $(function(){ Pager.init(20); });
+- content_for :script_on_load do
+ :plain
+ Pager.init(20);
@@ -53,8 +53,8 @@
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
$("#issue_label_list")
.bind( "keydown", function( event ) {
if ( event.keyCode === $.ui.keyCode.TAB &&
@@ -80,5 +80,4 @@
return false;
}
});
- });
@@ -58,7 +58,6 @@
%ul#issues-table.well-list.issues_table
= render "issues"
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
issuesPage();
- })
@@ -2,13 +2,14 @@
%hr
= render 'form'
-:javascript
- $('#key_key').on('keyup', function(){
- var title = $('#key_title'),
- val = $('#key_key').val(),
- key_mail = val.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+|\.[a-zA-Z0-9._-]+)/gi);
+- content_for :script_on_load do
+ :plain
+ $('#key_key').on('keyup', function(){
+ var title = $('#key_title'),
+ val = $('#key_key').val(),
+ key_mail = val.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+|\.[a-zA-Z0-9._-]+)/gi);
- if( key_mail && key_mail.length > 0 && title.val() == '' ){
- $('#key_title').val( key_mail );
- }
- });
+ if( key_mail && key_mail.length > 0 && title.val() == '' ){
+ $('#key_title').val( key_mail );
+ }
+ });
@@ -1,5 +1,5 @@
-:javascript
- $(function() {
+- content_for :script_on_load do
+ :plain
GitLab.GfmAutoComplete.Members.url = "#{ "/api/v3/projects/#{@project.id}/members" if @project }";
GitLab.GfmAutoComplete.Members.params.private_token = "#{current_user.private_token}";
@@ -14,4 +14,3 @@
});
GitLab.GfmAutoComplete.setup();
- });
@@ -2,10 +2,9 @@
= form_tag search_path, method: :get, class: 'navbar-form pull-left' do |f|
= text_field_tag "search", nil, placeholder: "Search", class: "search-input"
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
$("#search").autocomplete({
source: #{raw search_autocomplete_source},
select: function(event, ui) { location.href = ui.item.url }
});
- });
@@ -56,8 +56,8 @@
= link_to project_merge_request_path(@project, @merge_request), class: "btn cancel-btn" do
Cancel
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
disableButtonIfEmptyField("#merge_request_title", ".save-btn");
var source_branch = $("#merge_request_source_branch");
var target_branch = $("#merge_request_target_branch");
@@ -72,4 +72,3 @@
target_branch.live("change", function() {
$.get("#{branch_to_project_merge_requests_path(@project)}", {ref: $(this).val() });
});
- });
@@ -25,8 +25,8 @@
= render "notes/per_line_form"
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
MergeRequest.init({
url_to_automerge_check: "#{automerge_check_project_merge_request_path(@project, @merge_request)}",
check_enable: #{@merge_request.state == MergeRequest::UNCHECKED ? "true" : "false"},
@@ -40,5 +40,3 @@
$('.can_be_merged').hide();
$('.merge_in_progress').show();
})
- })
-
@@ -1,6 +1,5 @@
= render "show"
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
PerLineNotes.init();
- });
@@ -42,7 +42,6 @@
.span4.right
%span.cgray.right #{@merge_requests.total_count} merge requests for this filter
-:javascript
- $(function() {
- merge_requestsPage();
- })
+- content_for :script_on_load do
+ :plain
+ merge_requestsPage();
@@ -10,15 +10,13 @@
git merge origin/#{@merge_request.source_branch}
git push origin #{@merge_request.target_branch}
-
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
var modal = $('#modal_merge_info').modal({modal: true, show:false});
$('.how_to_merge_link').bind("click", function(){
modal.show();
});
$('.modal-header .close').bind("click", function(){
modal.hide();
- })
- })
+ });
@@ -39,11 +39,11 @@
= link_to "Cancel", project_milestone_path(@project, @milestone), class: "btn cancel-btn"
-:javascript
- $(function() {
+- content_for :script_on_load do
+ :plain
disableButtonIfEmptyField("#milestone_title", ".save-btn");
$( ".datepicker" ).datepicker({
dateFormat: "yy-mm-dd",
onSelect: function(dateText, inst) { $("#milestone_due_date").val(dateText) }
- }).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $('#milestone_due_date').val()));
- });
+ }).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $('#milestone_due_date').val()));
+ });
@@ -5,7 +5,6 @@
- if can? current_user, :write_note, @project
= render "notes/common_form"
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
NoteList.init("#{tid}", "#{tt}", "#{project_notes_path(@project)}");
- });
@@ -31,10 +31,9 @@
= check_box_tag :notify_author, 1 , @note.noteable_type == "Commit"
%span Commit author
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
$(".per_line_form .hide-button").bind("click", function(){
$('.per_line_form').hide();
return false;
});
- });
@@ -5,7 +5,6 @@
%ul.reversed#notes-list
.notes-status
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
NoteList.init("#{tid}", "#{tt}", "#{project_notes_path(@project)}");
- });
@@ -8,5 +8,6 @@
= image_tag "ajax_loader.gif"
%h3 Saving project. Please wait a few minutes
-:javascript
- $(function(){ new Projects(); });
+- content_for :script_on_load do
+ :plain
+ new Projects();
@@ -6,11 +6,12 @@
#holder.graph
.loading.loading-gray
-:javascript
- var branch_graph;
- $(function(){
- branch_graph = new BranchGraph($("#holder"), {
- url: '#{url_for controller: 'projects', action: 'graph', format: :json}',
- commit_url: '#{url_for controller: 'projects', action: 'show'}/commits/%s'
+- content_for :script do
+ :plain
+ var branch_graph;
+ $(function(){
+ branch_graph = new BranchGraph($("#holder"), {
+ url: '#{url_for controller: 'projects', action: 'graph', format: :json}',
+ commit_url: '#{url_for controller: 'projects', action: 'show'}/commits/%s'
+ });
});
- });
@@ -8,5 +8,6 @@
= image_tag "ajax_loader.gif"
%h3 Creating project &amp; repository. Please wait a few minutes
-:javascript
- $(function(){ new Projects(); });
+- content_for :script_on_load do
+ :plain
+ new Projects();
@@ -4,5 +4,6 @@
.content_list= render @events
.loading.hide
-:javascript
- $(function(){ Pager.init(20); });
+- content_for :script_on_load do
+ :plain
+ Pager.init(20);
@@ -27,8 +27,8 @@
= author.commits
-:javascript
- $(function(){
+- content_for :script_on_load do
+ :plain
var labels = [#{@graph.labels.to_json}];
var commits = [#{@graph.commits.join(', ')}];
var r = Raphael('activity-chart');
@@ -38,4 +38,3 @@
[commits],
{colors:["#456"]}
).label(labels, true);
- })
@@ -86,7 +86,7 @@
%tr
%td
%h4.nothing_here_message No wiki pages
- :javascript
- $(function() {
- $(".search_results .term").highlight("#{params[:search]}");
- })
+
+- content_for :script_on_load do
+ :plain
+ $(".search_results .term").highlight("#{params[:search]}");
Oops, something went wrong.

0 comments on commit db3ce5b

Please sign in to comment.