Skip to content

Commit

Permalink
Merge pull request #26 from R9295/auto-select
Browse files Browse the repository at this point in the history
Automatically select certificate and private_key on click #25
  • Loading branch information
nemesifier committed Dec 23, 2017
2 parents a60b0f8 + 945470a commit f8d3182
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django_x509/base/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class AbstractCaAdmin(BaseAdmin):
'modified']

class Media:
js = ('django-x509/js/switcher.js',)
js = ('django-x509/js/x509-admin.js',)


class AbstractCertAdmin(BaseAdmin):
Expand Down Expand Up @@ -121,7 +121,7 @@ class AbstractCertAdmin(BaseAdmin):
actions = ['revoke_action']

class Media:
js = ('django-x509/js/switcher.js',)
js = ('django-x509/js/x509-admin.js',)

def ca_url(self, obj):
url = reverse('admin:{0}_ca_change'.format(self.opts.app_label), args=[obj.ca.id])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
django.jQuery(function ($) {
'use strict';
// select private_key/certificate field text on click
$('.field-certificate, .field-private_key').find(".readonly").on('click', function () {
var range, selection;
if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(this);
selection.removeAllRanges();
selection.addRange(range);
} else if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(this);
range.select();
}
});
var operationType = $('.field-operation_type select');
// enable switcher only in add forms
if (!operationType.length || $('form .deletelink-box').length > 0) {
Expand Down

0 comments on commit f8d3182

Please sign in to comment.