Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove some more inline js #391

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions devices/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,6 @@ class DeviceLend(PermissionRequiredMixin, FormView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['actionstring'] = "Mark device as lend"
context['form_scripts'] = "$('#id_owner').select2();"
if "device" in self.request.POST:
deviceid = self.request.POST["device"]
if deviceid != "":
Expand Down Expand Up @@ -860,7 +859,6 @@ def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)

# Add in a QuerySet of all the books
context['form_scripts'] = "$('#id_owner').select2();"
context["breadcrumbs"] = [
(reverse("device-list"), _("Devices")),
(reverse("device-detail", kwargs={"pk": self.device.pk}), self.device.name),
Expand Down
6 changes: 6 additions & 0 deletions static/js/lagerregal.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,10 @@
}
});
});

$(function() {
if (document.location.hash) {
$('[data-toggle="tab"][href="' + document.location.hash + '"]').tab('show') ;
}
});
})();
1 change: 0 additions & 1 deletion templates/devices/base_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,4 @@ <h3>{% trans "Help" %}</h3>
}).done(response);
}
});
{% autoescape off %}{{ form_scripts }}{% endautoescape %}
{% endblock %}
16 changes: 0 additions & 16 deletions templates/devices/detail/device_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -429,22 +429,6 @@ <h4>{% trans "Installed software from backend providers" %}</h4>
{% block scriptend %}
{% include "devices/detail/device_detail.js" with device_id=device.id provided_data=provided_data %}
$(function() {
$("#id_ipaddresses").on("change", function(e) {
if ($(this).val()) {
$("#submitipaddress").removeClass("disabled");
} else {
$("#submitipaddress").addClass("disabled");
}
});

$("#id_tags").on("change", function(e) {
if ($(this).val()) {
$("#submittags").removeClass("disabled");
} else {
$("#submittags").addClass("disabled");
}
});

$("#id_mailtemplate").change(function() {
if ($(this).val() !== "") {
$.ajax({
Expand Down
2 changes: 1 addition & 1 deletion templates/devices/detail/device_ipaddress_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{% csrf_token %}
<div class="form-group">{{ ipaddressform.ipaddresses }}</div>
<div class="text-right">
<button type="submit" class="btn btn-success btn-sm disabled" id="submitipaddress">
<button type="submit" class="btn btn-success btn-sm" id="submitipaddress">
<i class="fa fa-plus"></i> {% trans "Assign Addresses" %}
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/devices/detail/device_tags_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% csrf_token %}
<div class="form-group">{{ tagform.tags }}</div>
<div class="text-right">
<button type="submit" class="btn btn-success btn-sm disabled" id="submittags">
<button type="submit" class="btn btn-success btn-sm" id="submittags">
<i class="fa fa-plus"></i> {% trans "Assign Tags" %}
</button>
</div>
Expand Down
2 changes: 0 additions & 2 deletions templates/devicetypes/type_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,4 @@
});
}
});

{% autoescape off %}{{ form_scripts }}{% endautoescape %}
{% endblock %}
27 changes: 1 addition & 26 deletions templates/users/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ <h5>{% trans "User doesn't own any IP-Addresses." %}</h5>
{% csrf_token %}
<div class="form-group">{{ ipaddressform.ipaddresses }}</div>
<div class="text-right">
<button type="submit" class="btn btn-success btn-sm disabled" id="submitipaddress">
<button type="submit" class="btn btn-success btn-sm" id="submitipaddress">
<i class="fa fa-plus"></i> {% trans "Assign Addresses" %}
</button>
</div>
Expand Down Expand Up @@ -309,28 +309,3 @@ <h5>{% trans "User hasn't edited anything." %}</h5>
{% include "snippets/modals/avatarView.html" with modalname="avatarModal" avatarpath=profileuser.avatar.url %}
{% endif %}
{% endblock %}

{% block scriptend %}
$("#id_ipaddresses").on("change", function(e) {
if ($(this).val()) {
$("#submitipaddress").removeClass("disabled");
} else {
$("#submitipaddress").addClass("disabled");
}
});

$(function() {
var $affix = $(".affix-container");
var $parent = $affix.parent();
var resize = function() {
$affix.width($parent.width());
};
$(window).resize(resize);
resize();

var url = document.location.toString();
if (url.match('#')) {
$('.nav-tabs a[href=#'+url.split('#')[1]+']').tab('show') ;
}
});
{% endblock %}