Commit 31a07b52 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

added floor selection to js and broke out js to separate file to load on both...

added floor selection to js and broke out js to separate file to load on both housing selection field templates
parent b2c7be62
<script>
// this is not loaded from /static/js because scope problems with document.ready
// toggle room selection availability
// can see if on campus, cannot see if not on campus
$(document).ready(function() {
var $radio = $('input:radio[name=on_campus]');
// when first rendering the page
if($radio.filter('[value=False]').is(':checked')) {
$("#lives-on-campus").hide();
} else {
$("#lives-on-campus").show();
}
// if student changes the value
$($radio.filter('[value=False]').click(function(){
$("#lives-on-campus").slideUp();
}));
$($radio.filter('[value=True]').click(function(){
$("#lives-on-campus").slideDown();
}));
// housing object chaining
$("#building").chained("#neighborhood");
$("#floor").chained("#building");
$("#room").chained("#floor");
});
// find the floor and room in which a student is staying in
// and select it for them on page load
// this allows us to cache the list of rooms
// note that this is outside of the document.ready function
// as it needs to happen after the selectors have been chained
// floor is selected first and then room
floorSelection();
roomSelection();
function floorSelection(){
var selectedFloor = "{{ request.user.student.room.floor.pk }}";
$("#floor").val(selectedFloor)
.find("option[value=" + selectedFloor + "]").attr('selected', true);
}
function roomSelection(){
var selectedRoom = "{{ request.user.student.room.pk }}";
$("#room").val(selectedRoom)
.find("option[value=" + selectedRoom + "]").attr('selected', true);
}
</script>
......@@ -261,37 +261,6 @@
{% endblock content %}
{% block javascript %}
<script type="text/javascript" src="/static/js/jquery.chained.min.js"></script>
<script>
// toggle room selection availability
// can see if on campus, cannot see if not on campus
$(document).ready(function() {
var $radio = $('input:radio[name=on_campus]');
// when first rendering the page
if($radio.filter('[value=False]').is(':checked')) {
$("#lives-on-campus").hide();
} else {
$("#lives-on-campus").show();
}
// if student changes the value
$($radio.filter('[value=False]').click(function(){
$("#lives-on-campus").slideUp();
}));
$($radio.filter('[value=True]').click(function(){
$("#lives-on-campus").slideDown();
}));
// find the room a student is staying in and select it for them on page load
// this allows us to cache the list of rooms
var selectedRoom = "{{ request.user.student.room.pk }}";
$("#room").val(selectedRoom)
.find("option[value=" + selectedRoom + "]").attr('selected', true);
});
$("#lives-on-campus").hide();
// room selection
$("#building").chained("#neighborhood");
$("#floor").chained("#building");
$("#room").chained("#floor");
</script>
<script type="text/javascript" src="/static/js/jquery.chained.min.js"></script>
{% include 'room_selection_script.html' %}
{% endblock javascript %}
......@@ -120,36 +120,6 @@
{% endblock content %}
{% block javascript %}
<script type="text/javascript" src="/static/js/jquery.chained.min.js"></script>
<script>
// toggle room selection availability
// can see if on campus, cannot see if not on campus
$(document).ready(function() {
var $radio = $('input:radio[name=on_campus]');
// when first rendering the page
if($radio.filter('[value=False]').is(':checked')) {
$("#lives-on-campus").hide();
} else {
$("#lives-on-campus").show();
}
// if student changes the value
$($radio.filter('[value=False]').click(function(){
$("#lives-on-campus").slideUp();
}));
$($radio.filter('[value=True]').click(function(){
$("#lives-on-campus").slideDown();
}));
// find the room a student is staying in and select if for them on page load
// this allows us to cache the list of rooms
var selectedRoom = "{{ request.user.student.room.pk }}";
$("#room").val(selectedRoom)
.find("option[value=" + selectedRoom + "]").attr('selected', true);
});
$("#lives-on-campus").hide();
// room selection
$("#building").chained("#neighborhood");
$("#floor").chained("#building");
$("#room").chained("#floor");
</script>
<script type="text/javascript" src="/static/js/jquery.chained.min.js"></script>
{% include 'room_selection_script.html' %}
{% endblock javascript %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment