mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Move toggles js code to static
This commit is contained in:
30
netbox/project-static/js/interface_toggles.js
Normal file
30
netbox/project-static/js/interface_toggles.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Toggle the display of IP addresses under interfaces
|
||||||
|
$('button.toggle-ips').click(function() {
|
||||||
|
var selected = $(this).attr('selected');
|
||||||
|
if (selected) {
|
||||||
|
$('#interfaces_table tr.ipaddresses').hide();
|
||||||
|
} else {
|
||||||
|
$('#interfaces_table tr.ipaddresses').show();
|
||||||
|
}
|
||||||
|
$(this).attr('selected', !selected);
|
||||||
|
$(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Inteface filtering
|
||||||
|
$('input.interface-filter').on('input', function() {
|
||||||
|
var filter = new RegExp(this.value);
|
||||||
|
|
||||||
|
for (interface of $(this).closest('form').find('tbody > tr')) {
|
||||||
|
// Slice off 'interface_' at the start of the ID
|
||||||
|
if (filter && filter.test(interface.id.slice(10))) {
|
||||||
|
// Match the toggle in case the filter now matches the interface
|
||||||
|
$(interface).find('input:checkbox[name=pk]').prop('checked', $('input.toggle').prop('checked'));
|
||||||
|
$(interface).show();
|
||||||
|
} else {
|
||||||
|
// Uncheck to prevent actions from including it when it doesn't match
|
||||||
|
$(interface).find('input:checkbox[name=pk]').prop('checked', false);
|
||||||
|
$(interface).hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
@ -903,35 +903,8 @@ function toggleConnection(elem) {
|
|||||||
$(".cable-toggle").click(function() {
|
$(".cable-toggle").click(function() {
|
||||||
return toggleConnection($(this));
|
return toggleConnection($(this));
|
||||||
});
|
});
|
||||||
// Toggle the display of IP addresses under interfaces
|
|
||||||
$('button.toggle-ips').click(function() {
|
|
||||||
var selected = $(this).attr('selected');
|
|
||||||
if (selected) {
|
|
||||||
$('#interfaces_table tr.ipaddresses').hide();
|
|
||||||
} else {
|
|
||||||
$('#interfaces_table tr.ipaddresses').show();
|
|
||||||
}
|
|
||||||
$(this).attr('selected', !selected);
|
|
||||||
$(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$('input.interface-filter').on('input', function() {
|
|
||||||
var filter = new RegExp(this.value);
|
|
||||||
|
|
||||||
for (interface of $(this).closest('form').find('tbody > tr')) {
|
|
||||||
// Slice off 'interface_' at the start of the ID
|
|
||||||
if (filter && filter.test(interface.id.slice(10))) {
|
|
||||||
// Match the toggle in case the filter now matches the interface
|
|
||||||
$(interface).find('input:checkbox[name=pk]').prop('checked', $('input.toggle').prop('checked'));
|
|
||||||
$(interface).show();
|
|
||||||
} else {
|
|
||||||
// Uncheck to prevent actions from including it when it doesn't match
|
|
||||||
$(interface).find('input:checkbox[name=pk]').prop('checked', false);
|
|
||||||
$(interface).hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
<script src="{% static 'js/interface_toggles.js' %}?v{{ settings.VERSION }}"></script>
|
||||||
<script src="{% static 'js/graphs.js' %}?v{{ settings.VERSION }}"></script>
|
<script src="{% static 'js/graphs.js' %}?v{{ settings.VERSION }}"></script>
|
||||||
<script src="{% static 'js/secrets.js' %}?v{{ settings.VERSION }}"></script>
|
<script src="{% static 'js/secrets.js' %}?v{{ settings.VERSION }}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% extends '_base.html' %}
|
{% extends '_base.html' %}
|
||||||
{% load custom_links %}
|
{% load custom_links %}
|
||||||
|
{% load static %}
|
||||||
{% load helpers %}
|
{% load helpers %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
@ -315,34 +316,5 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block javascript %}
|
{% block javascript %}
|
||||||
<script type="text/javascript">
|
<script src="{% static 'js/interface_toggles.js' %}?v{{ settings.VERSION }}"></script>
|
||||||
// Toggle the display of IP addresses under interfaces
|
|
||||||
$('button.toggle-ips').click(function() {
|
|
||||||
var selected = $(this).attr('selected');
|
|
||||||
if (selected) {
|
|
||||||
$('#interfaces_table tr.ipaddresses').hide();
|
|
||||||
} else {
|
|
||||||
$('#interfaces_table tr.ipaddresses').show();
|
|
||||||
}
|
|
||||||
$(this).attr('selected', !selected);
|
|
||||||
$(this).children('span').toggleClass('glyphicon-check glyphicon-unchecked');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$('input.interface-filter').on('input', function() {
|
|
||||||
var filter = new RegExp(this.value);
|
|
||||||
|
|
||||||
for (interface of $(this).closest('form').find('tbody > tr')) {
|
|
||||||
// Slice off 'interface_' at the start of the ID
|
|
||||||
if (filter && filter.test(interface.id.slice(10))) {
|
|
||||||
// Match the toggle in case the filter now matches the interface
|
|
||||||
$(interface).find('input:checkbox[name=pk]').prop('checked', $('input.toggle').prop('checked'));
|
|
||||||
$(interface).show();
|
|
||||||
} else {
|
|
||||||
// Uncheck to prevent actions from including it when it doesn't match
|
|
||||||
$(interface).find('input:checkbox[name=pk]').prop('checked', false);
|
|
||||||
$(interface).hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Reference in New Issue
Block a user