Skip to content

Commit

Permalink
Merge pull request #680 from anjali-dhanuka/JsStandards
Browse files Browse the repository at this point in the history
update javscript according to standards
  • Loading branch information
kamsuri authored May 22, 2018
2 parents 39285b6 + f5150aa commit 3b60ce1
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion vms/administrator/templates/administrator/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
<label class="control-label">
{% trans "Organization" %}
</label>
<select id="select" class="form-control" name="organization_name" onchange="hide_organization()">
<select id="select" class="form-control" name="organization_name" onchange="hideOrganization()">
<option value="0">-- {% trans "None" %} --</option>
{% for organization in organization_list %}
{% if administrator.organization %}
Expand Down
2 changes: 1 addition & 1 deletion vms/job/templates/job/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{% trans "Event:" %}
</label>
<div class="col-md-8">
<select class="form-control" name="event_id" id="events" onchange="update_event_dates()">
<select class="form-control" name="event_id" id="events" onchange="updateEventDates()">
{% for event in event_list %}
{% if event == last_event %}
<option value="{{ event.id }}" start_date="{{ event.start_date }}" end_date="{{ event.end_date }}" selected="selected">{{ event.name }}</option>
Expand Down
2 changes: 1 addition & 1 deletion vms/job/templates/job/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{% trans "Event:" %}
</label>
<div class="col-md-8">
<select class="form-control" name="event_id" id="events" onchange="update_event_dates()">
<select class="form-control" name="event_id" id="events" onchange="updateEventDates()">
{% for event in event_list %}
{% if event.name == job.event.name %}
<option selected value="{{ event.id }}" start_date="{{ event.start_date }}" end_date="{{ event.end_date }}">{{ event.name }}</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ <h2>{% trans "Sign Up" %}</h2>
<label class="control-label">
{% trans "Organization" %}
</label>
<select id="select" class="form-control" name="organization_name" onchange="hide_organization()">
<select id="select" class="form-control" name="organization_name" onchange="hideOrganization()">
<option value="0">-- {% trans "Select Organization" %} --</option>
{% for organization in organization_list %}
<option value="{{ organization.id }}">{{ organization.name }}</option>
Expand Down Expand Up @@ -321,7 +321,7 @@ <h2>{% trans "Sign Up" %}</h2>
</div>
</div>
{% endif %}
<script type="text/javascript" src="{% static 'vms/js/hide_organization.js' %}"></script>
<script type="text/javascript" src="{% static 'vms/js/hide-organization.js' %}"></script>
<button type="submit" class="btn btn-lg btn-primary btn-block">{% trans "Create Account" %}</button>
<!--<p>
Already have an account? Then please <a href="{% url 'authentication:login_process' %}">sign in</a>.
Expand Down
4 changes: 2 additions & 2 deletions vms/registration/templates/registration/signup_volunteer.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ <h2>{% trans "Sign Up" %}</h2>
<label class="control-label">
{% trans "Organization" %}
</label>
<select id="select" class="form-control" name="organization_name" onchange="hide_organization()">
<select id="select" class="form-control" name="organization_name" onchange="hideOrganization()">
<option value="0">-- {% trans "Select Organization" %} --</option>
{% for organization in organization_list %}
<option value="{{ organization.id }}">{{ organization.name }}</option>
Expand Down Expand Up @@ -347,7 +347,7 @@ <h2>{% trans "Sign Up" %}</h2>
</div>
</div>
{% endif %}
<script type="text/javascript" src="{% static 'vms/js/hide_organization.js' %}"></script>
<script type="text/javascript" src="{% static 'vms/js/hide-organization.js' %}"></script>
{% if volunteer_form.websites.errors %}
<div id="div_id_websites" class="form-group has-error">
<label class="control-label" for="id_websites">
Expand Down
10 changes: 10 additions & 0 deletions vms/vms/static/vms/js/hide-organization.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** Hides textbox for unlisted organization if a listed organization is selected */
function hideOrganization(){
var value = $('#select').val();
if (value !== '0') {
$("#div_id_unlisted_organization").toggle();
} else {
$("#div_id_unlisted_organization").toggle();
}
}
hideOrganization();
8 changes: 0 additions & 8 deletions vms/vms/static/vms/js/hide_organization.js

This file was deleted.

19 changes: 10 additions & 9 deletions vms/vms/static/vms/js/timepicker.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
$(function() {
$('#datetimepicker1').datetimepicker({
pickDate: false,
pickSeconds: false
});
$('#datetimepicker1').datetimepicker({
pickDate: false,
pickSeconds: false
});
});

$(function() {
$('#datetimepicker2').datetimepicker({
pickDate: false,
pickSeconds: false
});
$(function() {
$('#datetimepicker2').datetimepicker({
pickDate: false,
pickSeconds: false
});
});
17 changes: 9 additions & 8 deletions vms/vms/static/vms/js/update-event-dates.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
function update_event_dates(){
var event_list = document.getElementById("events");
var selected_event = event_list.options[event_list.selectedIndex];
var start_date = selected_event.getAttribute("start_date");
var end_date = selected_event.getAttribute("end_date");
document.getElementById("start_date_here").innerHTML = start_date;
document.getElementById("end_date_here").innerHTML = end_date;
/** Shows start and end dates of selected event while creating/editing jobs */
function updateEventDates() {
var eventList = document.getElementById("events");
var selectedEvent = eventList.options[eventList.selectedIndex];
var startDate = selectedEvent.getAttribute("start_date");
var endDate = selectedEvent.getAttribute("end_date");
document.getElementById("start_date_here").innerHTML = startDate;
document.getElementById("end_date_here").innerHTML = endDate;
}
update_event_dates();
updateEventDates();
4 changes: 2 additions & 2 deletions vms/volunteer/templates/volunteer/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
{% trans "Select your organization:" %}
</label>
<div class="col-md-8">
<select id="select" class="form-control" name="organization_name" onchange="hide_organisation()">
<select id="select" class="form-control" name="organization_name" onchange="hideOrganization()">
<option value="0">-- {% trans "None" %} --</option>
{% for organization in organization_list %}
{% if volunteer.organization_id %}
Expand Down Expand Up @@ -251,7 +251,7 @@
<input class="form-control" type="text" placeholder="{% blocktrans %}Organization{% endblocktrans %}" name="unlisted_organization" value="{% if form.unlisted_organization.value %}{{ form.unlisted_organization.value }}{% endif %}">
</div>
</div>
<script type="text/javascript" src="{% static 'vms/js/hide_organization.js' %}"></script>
<script type="text/javascript" src="{% static 'vms/js/hide-organization.js' %}"></script>
{% endif %}
{% if form.websites.errors %}
<div class="form-group has-error">
Expand Down

0 comments on commit 3b60ce1

Please sign in to comment.