|
1 | 1 | django.jQuery(function ($) {
|
2 |
| - 'use strict'; |
3 |
| - // select private_key/certificate field text on click |
4 |
| - $('.field-certificate, .field-private_key').find(".readonly").on('click', function () { |
5 |
| - var range, selection; |
6 |
| - if (window.getSelection) { |
7 |
| - selection = window.getSelection(); |
8 |
| - range = document.createRange(); |
9 |
| - range.selectNodeContents(this); |
10 |
| - selection.removeAllRanges(); |
11 |
| - selection.addRange(range); |
12 |
| - } else if (document.body.createTextRange) { |
13 |
| - range = document.body.createTextRange(); |
14 |
| - range.moveToElementText(this); |
15 |
| - range.select(); |
16 |
| - } |
| 2 | + "use strict"; |
| 3 | + // select private_key/certificate field text on click |
| 4 | + $(".field-certificate, .field-private_key") |
| 5 | + .find(".readonly") |
| 6 | + .on("click", function () { |
| 7 | + var range, selection; |
| 8 | + if (window.getSelection) { |
| 9 | + selection = window.getSelection(); |
| 10 | + range = document.createRange(); |
| 11 | + range.selectNodeContents(this); |
| 12 | + selection.removeAllRanges(); |
| 13 | + selection.addRange(range); |
| 14 | + } else if (document.body.createTextRange) { |
| 15 | + range = document.body.createTextRange(); |
| 16 | + range.moveToElementText(this); |
| 17 | + range.select(); |
| 18 | + } |
17 | 19 | });
|
18 |
| - var changePopupPage = new RegExp(/\d\/change\/\?/); |
19 |
| - var url = window.location.href; |
20 |
| - var operationType = $('.field-operation_type select'); |
21 |
| - // enable switcher only in add forms |
22 |
| - if (!operationType.length || $('form .deletelink-box').length > 0 || changePopupPage.test(url)) { |
23 |
| - $('.field-operation_type').hide(); |
24 |
| - return; |
| 20 | + var changePopupPage = new RegExp(/\d\/change\/\?/); |
| 21 | + var url = window.location.href; |
| 22 | + var operationType = $(".field-operation_type select"); |
| 23 | + // enable switcher only in add forms |
| 24 | + if ( |
| 25 | + !operationType.length || |
| 26 | + $("form .deletelink-box").length > 0 || |
| 27 | + changePopupPage.test(url) |
| 28 | + ) { |
| 29 | + $(".field-operation_type").hide(); |
| 30 | + return; |
| 31 | + } |
| 32 | + // function for operation_type switcher |
| 33 | + var showFields = function () { |
| 34 | + // define fields for each operation |
| 35 | + var importFields = $( |
| 36 | + ".form-row:not(.field-certificate, .field-operation_type, " + |
| 37 | + ".field-private_key, .field-name, .field-ca, .field-passphrase)", |
| 38 | + ), |
| 39 | + newFields = $(".form-row:not(.field-certificate, .field-private_key)"), |
| 40 | + defaultFields = $(".form-row:not(.field-operation_type)"), |
| 41 | + allFields = $(".form-row"), |
| 42 | + value = operationType.val(); |
| 43 | + if (value === "-") { |
| 44 | + allFields.show(); |
| 45 | + defaultFields.hide(); |
25 | 46 | }
|
26 |
| - // function for operation_type switcher |
27 |
| - var showFields = function () { |
28 |
| - // define fields for each operation |
29 |
| - var importFields = $('.form-row:not(.field-certificate, .field-operation_type, ' + |
30 |
| - '.field-private_key, .field-name, .field-ca, .field-passphrase)'), |
31 |
| - newFields = $('.form-row:not(.field-certificate, .field-private_key)'), |
32 |
| - defaultFields = $('.form-row:not(.field-operation_type)'), |
33 |
| - allFields = $('.form-row'), |
34 |
| - value = operationType.val(); |
35 |
| - if (value === '-') { |
36 |
| - allFields.show(); |
37 |
| - defaultFields.hide(); |
38 |
| - } |
39 |
| - if (value === 'new') { |
40 |
| - allFields.hide(); |
41 |
| - newFields.show(); |
42 |
| - } |
43 |
| - if (value === 'import') { |
44 |
| - allFields.show(); |
45 |
| - importFields.hide(); |
46 |
| - } |
47 |
| - }; |
| 47 | + if (value === "new") { |
| 48 | + allFields.hide(); |
| 49 | + newFields.show(); |
| 50 | + } |
| 51 | + if (value === "import") { |
| 52 | + allFields.show(); |
| 53 | + importFields.hide(); |
| 54 | + } |
| 55 | + }; |
| 56 | + showFields(); |
| 57 | + operationType.on("change", function (e) { |
48 | 58 | showFields();
|
49 |
| - operationType.on('change', function (e) { |
50 |
| - showFields(); |
51 |
| - }); |
| 59 | + }); |
52 | 60 | });
|
0 commit comments