Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jz
CCCROC
Commits
ae04d3b2
Commit
ae04d3b2
authored
Jul 13, 2015
by
Oliver Feldt
Browse files
Pulled JavaScript in application.js file instead of inlining it
parent
effb50a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
data/ccc_roc/assets/javascripts/application.js
View file @
ae04d3b2
...
...
@@ -56,6 +56,54 @@ jQuery.each( [ "put", "delete" ], function( i, method ) {
};
});
function
prepare_radio_form
(
radio
)
{
}
function
fetch_checkouts
(
radio
)
{
$
(
"
#checkouts tbody
"
).
empty
();
$
.
getJSON
(
"
/checkouts
"
,
{
radio_id
:
radio
.
name
},
function
(
response
)
{
var
checkouts
=
response
;
var
source
=
$
(
"
#checkout-template
"
).
html
();
var
template
=
Handlebars
.
compile
(
source
);
$
(
"
#checkouts tbody
"
).
empty
();
for
(
var
index
=
0
;
index
<
checkouts
.
length
;
index
++
)
{
var
context
=
{
angel
:
checkouts
[
index
].
angel
,
checkout
:
checkouts
[
index
]
};
$
(
"
#checkouts tbody
"
).
append
(
template
(
context
));
}
}
);
}
$
(
"
#radios tbody tr td
"
).
on
(
"
click
"
,
function
(
e
)
{
var
radio_item
=
$
(
e
.
target
).
parent
();
var
radio
=
{
name
:
radio_item
.
data
(
"
name
"
),
angel
:
radio_item
.
data
(
"
angel
"
)
};
$
(
"
#radio_form input[name='radio_id']
"
).
val
(
radio
.
name
);
$
(
"
#radio_form input[name='angel']
"
).
val
(
radio
.
angel
);
if
(
radio
.
angel
===
undefined
)
{
$
(
"
#radio_form button[name='return']
"
).
addClass
(
"
disabled
"
);
}
else
{
$
(
"
#radio_form button[name='return']
"
).
removeClass
(
"
disabled
"
);
}
var
switch_button_text
=
radio
.
angel
===
undefined
?
"
Set Angel
"
:
"
Switch Angel
"
;
$
(
"
#radio_form button[name='switch']
"
).
html
(
switch_button_text
);
$
(
"
#radio .modal-header
"
).
addClass
(
radio
.
angel
!==
undefined
?
"
info
"
:
"
success
"
);
$
(
"
#radio .modal-header
"
).
removeClass
(
radio
.
angel
===
undefined
?
"
info
"
:
"
success
"
);
$
(
"
#radio_header
"
).
html
(
radio
.
name
);
$
(
"
#radio
"
).
modal
(
"
show
"
);
fetch_checkouts
(
radio
);
});
$
(
"
#search_form
"
).
on
(
"
submit
"
,
function
(
e
)
{
var
radio_id
=
$
(
"
#radio_id
"
).
val
();
$
(
"
#search_form input
"
).
prop
(
'
readonly
'
,
true
);
...
...
@@ -86,25 +134,7 @@ $("#search_form").on("submit", function(e) {
$
(
"
#radio .modal-header
"
).
removeClass
(
angel
===
null
?
"
info
"
:
"
success
"
);
$
(
"
#radio_header
"
).
html
(
radio
.
name
);
$
(
"
#radio
"
).
modal
(
"
show
"
);
$
(
"
#checkouts tbody
"
).
empty
();
$
.
getJSON
(
"
/checkouts
"
,
{
radio_id
:
radio
.
name
},
function
(
response
)
{
var
checkouts
=
response
;
var
source
=
$
(
"
#checkout-template
"
).
html
();
var
template
=
Handlebars
.
compile
(
source
);
$
(
"
#checkouts tbody
"
).
empty
();
for
(
var
index
=
0
;
index
<
checkouts
.
length
;
index
++
)
{
var
context
=
{
angel
:
checkouts
[
index
].
angel
,
checkout
:
checkouts
[
index
]
};
$
(
"
#checkouts tbody
"
).
append
(
template
(
context
));
}
}
);
fetch_checkouts
(
radio
);
}
}
).
always
(
function
()
{
...
...
@@ -199,45 +229,6 @@ $("#new_radio").on("submit", function(e) {
e
.
preventDefault
();
});
$
(
"
#radios
"
).
on
(
"
click
"
,
function
(
e
)
{
var
radio_item
=
$
(
e
.
target
).
parent
();
var
radio
=
{
name
:
radio_item
.
data
(
"
name
"
),
angel
:
radio_item
.
data
(
"
angel
"
)
};
$
(
"
#radio_form input[name='radio_id']
"
).
val
(
radio
.
name
);
$
(
"
#radio_form input[name='angel']
"
).
val
(
radio
.
angel
);
var
switch_button_text
=
radio
.
angel
===
undefined
?
"
Set Angel
"
:
"
Switch Angel
"
;
if
(
radio
.
angel
===
undefined
)
{
$
(
"
#radio_form button[name='return']
"
).
addClass
(
"
disabled
"
);
}
else
{
$
(
"
#radio_form button[name='return']
"
).
removeClass
(
"
disabled
"
);
}
$
(
"
#radio_form button[name='switch']
"
).
html
(
switch_button_text
);
$
(
"
#radio_header
"
).
html
(
radio
.
name
);
$
(
"
#radio .modal-header
"
).
addClass
(
radio
.
angel
!==
undefined
?
"
info
"
:
"
success
"
);
$
(
"
#radio .modal-header
"
).
removeClass
(
radio
.
angel
===
undefined
?
"
info
"
:
"
success
"
);
$
(
"
#radio
"
).
modal
(
"
show
"
);
$
.
getJSON
(
"
/checkouts
"
,
{
radio_id
:
radio
.
name
},
function
(
response
)
{
var
checkouts
=
response
;
var
source
=
$
(
"
#checkout-template
"
).
html
();
var
template
=
Handlebars
.
compile
(
source
);
$
(
"
#checkouts tbody
"
).
empty
();
for
(
var
index
=
0
;
index
<
checkouts
.
length
;
index
++
)
{
var
context
=
{
angel
:
checkouts
[
index
].
angel
,
checkout
:
checkouts
[
index
]
};
$
(
"
#checkouts tbody
"
).
append
(
template
(
context
));
}
}
)
});
$
(
"
#radio_form input[name='angel']
"
).
on
(
"
focus
"
,
function
()
{
$
(
this
).
data
(
"
value
"
,
$
(
this
).
val
());
$
(
this
).
val
(
""
);
...
...
Write
Preview
Supports
Markdown
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