BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ad1aa517
Commit
ad1aa517
authored
Sep 09, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add "enable" and "disable" jQuery functions
Handles (un)setting the disabled attribute and adding/removing the 'disabled' class
parent
3b89f140
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
main.js.coffee
app/assets/javascripts/main.js.coffee
+14
-5
note.js
app/assets/javascripts/note.js
+2
-2
No files found.
app/assets/javascripts/main.js.coffee
View file @
ad1aa517
...
...
@@ -12,26 +12,27 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) ->
field
=
$
(
field_selector
)
closest_submit
=
field
.
closest
(
"form"
).
find
(
button_selector
)
closest_submit
.
attr
(
"disabled"
,
"disabled"
).
addClass
(
"disabled"
)
if
field
.
val
()
is
""
closest_submit
.
disable
(
)
if
field
.
val
()
is
""
field
.
on
"keyup"
,
->
if
$
(
this
).
val
()
is
""
closest_submit
.
attr
(
"disabled"
,
"disabled"
).
addClass
"disabled"
closest_submit
.
disable
()
else
closest_submit
.
removeAttr
(
"disabled"
).
removeClass
"disabled"
closest_submit
.
enable
()
$
->
$
(
".one_click_select"
).
live
'click'
,
->
$
(
this
).
select
()
# Disable form buttons while a form is submitting
$
(
'body'
).
on
'ajax:complete, ajax:beforeSend, submit'
,
'form'
,
(
e
)
->
buttons
=
$
(
'[type="submit"]'
,
this
)
switch
e
.
type
when
'ajax:beforeSend'
,
'submit'
buttons
.
attr
(
'disabled'
,
'disabled'
)
buttons
.
disable
(
)
else
buttons
.
removeAttr
(
'disabled'
)
buttons
.
enable
(
)
# Show/Hide the profile menu when hovering the account box
$
(
'.account-box'
).
hover
->
$
(
this
).
toggleClass
(
'hover'
)
...
...
@@ -81,4 +82,12 @@ $ ->
$
.
extend
default_options
,
options
_chosen
.
apply
this
,
[
default_options
]
# Disable an element and add the 'disabled' Bootstrap class
$
.
fn
.
extend
disable
:
->
$
(
this
).
attr
(
'disabled'
,
'disabled'
).
addClass
(
'disabled'
)
# Enable an element and remove the 'disabled' Bootstrap class
$
.
fn
.
extend
enable
:
->
$
(
this
).
removeAttr
(
'disabled'
).
removeClass
(
'disabled'
)
)(
jQuery
)
app/assets/javascripts/note.js
View file @
ad1aa517
...
...
@@ -25,11 +25,11 @@ var NoteList = {
$
(
this
).
closest
(
'li'
).
fadeOut
();
});
$
(
".note-form-holder"
).
live
(
"ajax:before"
,
function
(){
$
(
".submit_note"
).
attr
(
"disabled"
,
"disabled"
);
$
(
".submit_note"
).
disable
()
})
$
(
".note-form-holder"
).
live
(
"ajax:complete"
,
function
(){
$
(
".submit_note"
).
removeAttr
(
"disabled"
);
$
(
".submit_note"
).
enable
()
})
disableButtonIfEmptyField
(
".note-text"
,
".submit_note"
);
...
...
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