Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
46921e69
Commit
46921e69
authored
Oct 10, 2012
by
Nihad Abbasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup main.coffee
parent
b1ef7d7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
app/assets/javascripts/main.js.coffee
app/assets/javascripts/main.js.coffee
+16
-16
No files found.
app/assets/javascripts/main.js.coffee
View file @
46921e69
...
@@ -7,7 +7,7 @@ window.slugify = (text) ->
...
@@ -7,7 +7,7 @@ window.slugify = (text) ->
window
.
ajaxGet
=
(
url
)
->
window
.
ajaxGet
=
(
url
)
->
$
.
ajax
({
type
:
"GET"
,
url
:
url
,
dataType
:
"script"
})
$
.
ajax
({
type
:
"GET"
,
url
:
url
,
dataType
:
"script"
})
# Disable button if text field is empty
# Disable button if text field is empty
window
.
disableButtonIfEmptyField
=
(
field_selector
,
button_selector
)
->
window
.
disableButtonIfEmptyField
=
(
field_selector
,
button_selector
)
->
field
=
$
(
field_selector
)
field
=
$
(
field_selector
)
closest_submit
=
field
.
closest
(
"form"
).
find
(
button_selector
)
closest_submit
=
field
.
closest
(
"form"
).
find
(
button_selector
)
...
@@ -15,21 +15,21 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) ->
...
@@ -15,21 +15,21 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) ->
closest_submit
.
disable
()
if
field
.
val
()
is
""
closest_submit
.
disable
()
if
field
.
val
()
is
""
field
.
on
"keyup"
,
->
field
.
on
"keyup"
,
->
if
$
(
this
).
val
()
is
""
if
$
(
@
).
val
()
is
""
closest_submit
.
disable
()
closest_submit
.
disable
()
else
else
closest_submit
.
enable
()
closest_submit
.
enable
()
$
->
$
->
# Click a .one_click_select field, select the contents
# Click a .one_click_select field, select the contents
$
(
".one_click_select"
).
live
'click'
,
->
$
(
this
).
select
()
$
(
".one_click_select"
).
on
'click'
,
->
$
(
@
).
select
()
# Initialize chosen selects
# Initialize chosen selects
$
(
'select.chosen'
).
chosen
()
$
(
'select.chosen'
).
chosen
()
# Disable form buttons while a form is submitting
# Disable form buttons while a form is submitting
$
(
'body'
).
on
'ajax:complete, ajax:beforeSend, submit'
,
'form'
,
(
e
)
->
$
(
'body'
).
on
'ajax:complete, ajax:beforeSend, submit'
,
'form'
,
(
e
)
->
buttons
=
$
(
'[type="submit"]'
,
this
)
buttons
=
$
(
'[type="submit"]'
,
@
)
switch
e
.
type
switch
e
.
type
when
'ajax:beforeSend'
,
'submit'
when
'ajax:beforeSend'
,
'submit'
...
@@ -38,7 +38,7 @@ $ ->
...
@@ -38,7 +38,7 @@ $ ->
buttons
.
enable
()
buttons
.
enable
()
# Show/Hide the profile menu when hovering the account box
# Show/Hide the profile menu when hovering the account box
$
(
'.account-box'
).
hover
->
$
(
this
).
toggleClass
(
'hover'
)
$
(
'.account-box'
).
hover
->
$
(
@
).
toggleClass
(
'hover'
)
# Focus search field by pressing 's' key
# Focus search field by pressing 's' key
$
(
document
).
keypress
(
e
)
->
$
(
document
).
keypress
(
e
)
->
...
@@ -52,22 +52,22 @@ $ ->
...
@@ -52,22 +52,22 @@ $ ->
# Commit show suppressed diff
# Commit show suppressed diff
$
(
".supp_diff_link"
).
bind
"click"
,
->
$
(
".supp_diff_link"
).
bind
"click"
,
->
$
(
this
).
next
(
'table'
).
show
()
$
(
@
).
next
(
'table'
).
show
()
$
(
this
).
remove
()
$
(
@
).
remove
()
# Note markdown preview
# Note markdown preview
$
(
document
).
on
'click'
,
'#preview-link'
,
(
e
)
->
$
(
document
).
on
'click'
,
'#preview-link'
,
(
e
)
->
$
(
'#preview-note'
).
text
(
'Loading...'
)
$
(
'#preview-note'
).
text
'Loading...'
previewLinkText
=
if
$
(
this
).
text
()
==
'Preview'
then
'Edit'
else
'Preview'
previewLinkText
=
if
$
(
@
).
text
()
is
'Preview'
then
'Edit'
else
'Preview'
$
(
this
).
text
(
previewLinkText
)
$
(
@
).
text
previewLinkText
note
=
$
(
'#note_note'
).
val
()
note
=
$
(
'#note_note'
).
val
()
if
note
.
trim
().
length
==
0
if
note
.
trim
().
length
is
0
$
(
'#preview-note'
).
text
(
"Nothing to preview."
)
$
(
'#preview-note'
).
text
'Nothing to preview.'
else
else
$
.
post
$
(
this
).
attr
(
'href'
),
{
note
:
note
},
(
data
)
->
$
.
post
$
(
@
).
attr
(
'href'
),
{
note
:
note
},
(
data
)
->
$
(
'#preview-note'
).
html
(
data
)
$
(
'#preview-note'
).
html
(
data
)
$
(
'#preview-note, #note_note'
).
toggle
()
$
(
'#preview-note, #note_note'
).
toggle
()
...
@@ -79,14 +79,14 @@ $ ->
...
@@ -79,14 +79,14 @@ $ ->
$
.
fn
.
extend
chosen
:
(
options
)
->
$
.
fn
.
extend
chosen
:
(
options
)
->
default_options
=
search_contains
:
"true"
default_options
=
search_contains
:
"true"
$
.
extend
default_options
,
options
$
.
extend
default_options
,
options
_chosen
.
apply
this
,
[
default_options
]
_chosen
.
apply
@
,
[
default_options
]
# Disable an element and add the 'disabled' Bootstrap class
# Disable an element and add the 'disabled' Bootstrap class
$
.
fn
.
extend
disable
:
->
$
.
fn
.
extend
disable
:
->
$
(
this
).
attr
(
'disabled'
,
'disabled'
).
addClass
(
'disabled'
)
$
(
@
).
attr
(
'disabled'
,
'disabled'
).
addClass
(
'disabled'
)
# Enable an element and remove the 'disabled' Bootstrap class
# Enable an element and remove the 'disabled' Bootstrap class
$
.
fn
.
extend
enable
:
->
$
.
fn
.
extend
enable
:
->
$
(
this
).
removeAttr
(
'disabled'
).
removeClass
(
'disabled'
)
$
(
@
).
removeAttr
(
'disabled'
).
removeClass
(
'disabled'
)
)(
jQuery
)
)(
jQuery
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment