Commit 3ef0a625ac656e64861df912492dc3b8febb66c3
1 parent
36ea8645
Exists in
spb-stable
and in
3 other branches
Applications js to coffee
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
154 additions
and
153 deletions
Show diff stats
app/assets/javascripts/application.js
... | ... | @@ -1,33 +0,0 @@ |
1 | -// This is a manifest file that'll be compiled into including all the files listed below. | |
2 | -// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically | |
3 | -// be included in the compiled file accessible from http://example.com/assets/application.js | |
4 | -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | |
5 | -// the compiled file. | |
6 | -// | |
7 | -//= require jquery | |
8 | -//= require jquery.ui.all | |
9 | -//= require jquery_ujs | |
10 | -//= require jquery.cookie | |
11 | -//= require jquery.endless-scroll | |
12 | -//= require jquery.highlight | |
13 | -//= require jquery.history | |
14 | -//= require jquery.waitforimages | |
15 | -//= require jquery.atwho | |
16 | -//= require jquery.scrollto | |
17 | -//= require jquery.blockUI | |
18 | -//= require turbolinks | |
19 | -//= require jquery.turbolinks | |
20 | -//= require bootstrap | |
21 | -//= require modernizr | |
22 | -//= require select2 | |
23 | -//= require raphael | |
24 | -//= require g.raphael-min | |
25 | -//= require g.bar-min | |
26 | -//= require branch-graph | |
27 | -//= require highlightjs.min | |
28 | -//= require ace/ace | |
29 | -//= require_tree . | |
30 | -//= require d3 | |
31 | -//= require underscore | |
32 | -//= require nprogress | |
33 | -//= require nprogress-turbolinks |
... | ... | @@ -0,0 +1,154 @@ |
1 | +# This is a manifest file that'll be compiled into including all the files listed below. | |
2 | +# Add new JavaScript/Coffee code in separate files in this directory and they'll automatically | |
3 | +# be included in the compiled file accessible from http://example.com/assets/application.js | |
4 | +# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | |
5 | +# the compiled file. | |
6 | +# | |
7 | +#= require jquery | |
8 | +#= require jquery.ui.all | |
9 | +#= require jquery_ujs | |
10 | +#= require jquery.cookie | |
11 | +#= require jquery.endless-scroll | |
12 | +#= require jquery.highlight | |
13 | +#= require jquery.history | |
14 | +#= require jquery.waitforimages | |
15 | +#= require jquery.atwho | |
16 | +#= require jquery.scrollto | |
17 | +#= require jquery.blockUI | |
18 | +#= require turbolinks | |
19 | +#= require jquery.turbolinks | |
20 | +#= require bootstrap | |
21 | +#= require modernizr | |
22 | +#= require select2 | |
23 | +#= require raphael | |
24 | +#= require g.raphael-min | |
25 | +#= require g.bar-min | |
26 | +#= require branch-graph | |
27 | +#= require highlightjs.min | |
28 | +#= require ace/ace | |
29 | +#= require d3 | |
30 | +#= require underscore | |
31 | +#= require nprogress | |
32 | +#= require nprogress-turbolinks | |
33 | +#= require_tree . | |
34 | + | |
35 | +window.slugify = (text) -> | |
36 | + text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase() | |
37 | + | |
38 | +window.ajaxGet = (url) -> | |
39 | + $.ajax({type: "GET", url: url, dataType: "script"}) | |
40 | + | |
41 | +window.showAndHide = (selector) -> | |
42 | + | |
43 | +window.errorMessage = (message) -> | |
44 | + ehtml = $("<p>") | |
45 | + ehtml.addClass("error_message") | |
46 | + ehtml.html(message) | |
47 | + ehtml | |
48 | + | |
49 | +window.split = (val) -> | |
50 | + return val.split( /,\s*/ ) | |
51 | + | |
52 | +window.extractLast = (term) -> | |
53 | + return split( term ).pop() | |
54 | + | |
55 | +# Disable button if text field is empty | |
56 | +window.disableButtonIfEmptyField = (field_selector, button_selector) -> | |
57 | + field = $(field_selector) | |
58 | + closest_submit = field.closest("form").find(button_selector) | |
59 | + | |
60 | + closest_submit.disable() if field.val() is "" | |
61 | + | |
62 | + field.on "input", -> | |
63 | + if $(@).val() is "" | |
64 | + closest_submit.disable() | |
65 | + else | |
66 | + closest_submit.enable() | |
67 | + | |
68 | +window.sanitize = (str) -> | |
69 | + return str.replace(/<(?:.|\n)*?>/gm, '') | |
70 | + | |
71 | +window.linkify = (str) -> | |
72 | + exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig | |
73 | + return str.replace(exp,"<a href='$1'>$1</a>") | |
74 | + | |
75 | +window.simpleFormat = (str) -> | |
76 | + linkify(sanitize(str).replace(/\n/g, '<br />')) | |
77 | + | |
78 | +window.unbindEvents = -> | |
79 | + $(document).unbind('scroll') | |
80 | + $(document).off('scroll') | |
81 | + | |
82 | +document.addEventListener("page:fetch", unbindEvents) | |
83 | + | |
84 | +$ -> | |
85 | + # Click a .one_click_select field, select the contents | |
86 | + $(".one_click_select").on 'click', -> $(@).select() | |
87 | + | |
88 | + $('.remove-row').bind 'ajax:success', -> | |
89 | + $(this).closest('li').fadeOut() | |
90 | + | |
91 | + # Initialize select2 selects | |
92 | + $('select.select2').select2(width: 'resolve', dropdownAutoWidth: true) | |
93 | + | |
94 | + # Initialize tooltips | |
95 | + $('.has_tooltip').tooltip() | |
96 | + | |
97 | + # Bottom tooltip | |
98 | + $('.has_bottom_tooltip').tooltip(placement: 'bottom') | |
99 | + | |
100 | + # Form submitter | |
101 | + $('.trigger-submit').on 'change', -> | |
102 | + $(@).parents('form').submit() | |
103 | + | |
104 | + $("abbr.timeago").timeago() | |
105 | + $('.js-timeago').timeago() | |
106 | + | |
107 | + # Flash | |
108 | + if (flash = $(".flash-container")).length > 0 | |
109 | + flash.click -> $(@).fadeOut() | |
110 | + flash.show() | |
111 | + setTimeout (-> flash.fadeOut()), 5000 | |
112 | + | |
113 | + # Disable form buttons while a form is submitting | |
114 | + $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> | |
115 | + buttons = $('[type="submit"]', @) | |
116 | + | |
117 | + switch e.type | |
118 | + when 'ajax:beforeSend', 'submit' | |
119 | + buttons.disable() | |
120 | + else | |
121 | + buttons.enable() | |
122 | + | |
123 | + # Show/Hide the profile menu when hovering the account box | |
124 | + $('.account-box').hover -> $(@).toggleClass('hover') | |
125 | + | |
126 | + # Focus search field by pressing 's' key | |
127 | + $(document).keypress (e) -> | |
128 | + # Don't do anything if typing in an input | |
129 | + return if $(e.target).is(":input") | |
130 | + | |
131 | + switch e.which | |
132 | + when 115 | |
133 | + $("#search").focus() | |
134 | + e.preventDefault() | |
135 | + when 63 | |
136 | + new Shortcuts() | |
137 | + e.preventDefault() | |
138 | + | |
139 | + | |
140 | + # Commit show suppressed diff | |
141 | + $(".diff-content").on "click", ".supp_diff_link", -> | |
142 | + $(@).next('table').show() | |
143 | + $(@).remove() | |
144 | + | |
145 | +(($) -> | |
146 | + # Disable an element and add the 'disabled' Bootstrap class | |
147 | + $.fn.extend disable: -> | |
148 | + $(@).attr('disabled', 'disabled').addClass('disabled') | |
149 | + | |
150 | + # Enable an element and remove the 'disabled' Bootstrap class | |
151 | + $.fn.extend enable: -> | |
152 | + $(@).removeAttr('disabled').removeClass('disabled') | |
153 | + | |
154 | +)(jQuery) | ... | ... |
app/assets/javascripts/main.js.coffee
... | ... | @@ -1,120 +0,0 @@ |
1 | -window.slugify = (text) -> | |
2 | - text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase() | |
3 | - | |
4 | -window.ajaxGet = (url) -> | |
5 | - $.ajax({type: "GET", url: url, dataType: "script"}) | |
6 | - | |
7 | -window.showAndHide = (selector) -> | |
8 | - | |
9 | -window.errorMessage = (message) -> | |
10 | - ehtml = $("<p>") | |
11 | - ehtml.addClass("error_message") | |
12 | - ehtml.html(message) | |
13 | - ehtml | |
14 | - | |
15 | -window.split = (val) -> | |
16 | - return val.split( /,\s*/ ) | |
17 | - | |
18 | -window.extractLast = (term) -> | |
19 | - return split( term ).pop() | |
20 | - | |
21 | -# Disable button if text field is empty | |
22 | -window.disableButtonIfEmptyField = (field_selector, button_selector) -> | |
23 | - field = $(field_selector) | |
24 | - closest_submit = field.closest("form").find(button_selector) | |
25 | - | |
26 | - closest_submit.disable() if field.val() is "" | |
27 | - | |
28 | - field.on "input", -> | |
29 | - if $(@).val() is "" | |
30 | - closest_submit.disable() | |
31 | - else | |
32 | - closest_submit.enable() | |
33 | - | |
34 | -window.sanitize = (str) -> | |
35 | - return str.replace(/<(?:.|\n)*?>/gm, '') | |
36 | - | |
37 | -window.linkify = (str) -> | |
38 | - exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig | |
39 | - return str.replace(exp,"<a href='$1'>$1</a>") | |
40 | - | |
41 | -window.simpleFormat = (str) -> | |
42 | - linkify(sanitize(str).replace(/\n/g, '<br />')) | |
43 | - | |
44 | -window.unbindEvents = -> | |
45 | - $(document).unbind('scroll') | |
46 | - $(document).off('scroll') | |
47 | - | |
48 | -document.addEventListener("page:fetch", unbindEvents) | |
49 | - | |
50 | -$ -> | |
51 | - # Click a .one_click_select field, select the contents | |
52 | - $(".one_click_select").on 'click', -> $(@).select() | |
53 | - | |
54 | - $('.remove-row').bind 'ajax:success', -> | |
55 | - $(this).closest('li').fadeOut() | |
56 | - | |
57 | - # Initialize select2 selects | |
58 | - $('select.select2').select2(width: 'resolve', dropdownAutoWidth: true) | |
59 | - | |
60 | - # Initialize tooltips | |
61 | - $('.has_tooltip').tooltip() | |
62 | - | |
63 | - # Bottom tooltip | |
64 | - $('.has_bottom_tooltip').tooltip(placement: 'bottom') | |
65 | - | |
66 | - # Form submitter | |
67 | - $('.trigger-submit').on 'change', -> | |
68 | - $(@).parents('form').submit() | |
69 | - | |
70 | - $("abbr.timeago").timeago() | |
71 | - $('.js-timeago').timeago() | |
72 | - | |
73 | - # Flash | |
74 | - if (flash = $(".flash-container")).length > 0 | |
75 | - flash.click -> $(@).fadeOut() | |
76 | - flash.show() | |
77 | - setTimeout (-> flash.fadeOut()), 5000 | |
78 | - | |
79 | - # Disable form buttons while a form is submitting | |
80 | - $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> | |
81 | - buttons = $('[type="submit"]', @) | |
82 | - | |
83 | - switch e.type | |
84 | - when 'ajax:beforeSend', 'submit' | |
85 | - buttons.disable() | |
86 | - else | |
87 | - buttons.enable() | |
88 | - | |
89 | - # Show/Hide the profile menu when hovering the account box | |
90 | - $('.account-box').hover -> $(@).toggleClass('hover') | |
91 | - | |
92 | - # Focus search field by pressing 's' key | |
93 | - $(document).keypress (e) -> | |
94 | - # Don't do anything if typing in an input | |
95 | - return if $(e.target).is(":input") | |
96 | - | |
97 | - switch e.which | |
98 | - when 115 | |
99 | - $("#search").focus() | |
100 | - e.preventDefault() | |
101 | - when 63 | |
102 | - new Shortcuts() | |
103 | - e.preventDefault() | |
104 | - | |
105 | - | |
106 | - # Commit show suppressed diff | |
107 | - $(".diff-content").on "click", ".supp_diff_link", -> | |
108 | - $(@).next('table').show() | |
109 | - $(@).remove() | |
110 | - | |
111 | -(($) -> | |
112 | - # Disable an element and add the 'disabled' Bootstrap class | |
113 | - $.fn.extend disable: -> | |
114 | - $(@).attr('disabled', 'disabled').addClass('disabled') | |
115 | - | |
116 | - # Enable an element and remove the 'disabled' Bootstrap class | |
117 | - $.fn.extend enable: -> | |
118 | - $(@).removeAttr('disabled').removeClass('disabled') | |
119 | - | |
120 | -)(jQuery) |