| @@ -3,44 +3,21 @@ | ||
| 3 | 3 | "use strict"; |
| 4 | 4 | |
| 5 | 5 | $(document).on('change', 'select[name="hh_x_frame_options_value"]', function () { |
| 6 | 6 | var $el = $('input[name="hh_x_frame_options_domain"]'), |
| 7 | - readOnly = $(this).find('option:selected').val() != 'allow-from'; | |
| 7 | + disabled = $(this).find('option:selected').val() != 'allow-from' || this.disabled; | |
| 8 | 8 | if ($el.length) { |
| 9 | - $el.prop('readOnly', readOnly).toggle(!readOnly); | |
| 9 | + $el.prop('disabled', disabled).toggle(!disabled); | |
| 10 | 10 | } |
| 11 | - }).on('change', 'select[name="hh_x_xxs_protection_value"]', function (e) { | |
| 12 | - var $el = $('input[name="hh_x_xxs_protection_uri"]'), | |
| 13 | - readOnly = $(this).find('option:selected').val() != '1; report='; | |
| 14 | - if ($el.length) { | |
| 15 | - $el.prop('readOnly', readOnly).toggle(!readOnly); | |
| 16 | - } | |
| 17 | - }).on('change', 'select[name="hh_x_powered_by_option"]', function () { | |
| 18 | - var $el = $('input[name="hh_x_powered_by_value"]'), | |
| 19 | - readOnly = $(this).find('option:selected').val() != 'set'; | |
| 20 | - if ($el.length) { | |
| 21 | - $el.prop('readOnly', readOnly).toggle(!readOnly); | |
| 22 | - } | |
| 23 | 11 | }).on('change', 'select[name="hh_access_control_allow_origin_value"]', function () { |
| 24 | 12 | var $el = $('input[name="hh_access_control_allow_origin_url"]'), |
| 25 | - readOnly = $(this).find('option:selected').val() != 'origin'; | |
| 13 | + disabled = $(this).find('option:selected').val() != 'origin' || this.disabled; | |
| 26 | 14 | if ($el.length) { |
| 27 | - $el.prop('readOnly', readOnly);//.toggle(!readOnly); | |
| 15 | + $el.prop('disabled', disabled).toggle(!disabled); | |
| 28 | 16 | } |
| 29 | - if (readOnly) { | |
| 30 | - $(".hh-acao").addClass("hh-hidden"); | |
| 31 | - } else { | |
| 32 | - $(".hh-acao").removeClass("hh-hidden"); | |
| 33 | - } | |
| 34 | - }).on('change', 'select[name="hh_timing_allow_origin_value"]', function () { | |
| 35 | - var $el = $('input[name="hh_timing_allow_origin_url"]'), | |
| 36 | - readOnly = $(this).find('option:selected').val() != 'origin'; | |
| 37 | - if ($el.length) { | |
| 38 | - $el.prop('readOnly', readOnly).toggle(!readOnly); | |
| 39 | - } | |
| 40 | 17 | }).on('change', '.http-header', function () { |
| 41 | 18 | var $this = $(this), |
| 42 | - $el = $this.closest('table').find('.http-header-value'); | |
| 19 | + $el = $this.closest('tr').find('.http-header-value'); | |
| 43 | 20 | |
| 44 | 21 | if (!$el.length) { |
| 45 | 22 | return; |
| 46 | 23 | } |
| @@ -45,120 +22,15 @@ | ||
| 45 | 22 | return; |
| 46 | 23 | } |
| 47 | 24 | |
| 48 | 25 | if (Number($this.val()) === 1) { |
| 49 | - $el.prop('readOnly', false).removeAttr('readonly').removeClass('readonly'); | |
| 26 | + $el.prop('disabled', false); | |
| 50 | 27 | } else { |
| 51 | - $el.prop('readOnly', true).addClass('readonly'); | |
| 28 | + $el.prop('disabled', true); | |
| 52 | 29 | } |
| 53 | 30 | }).on('change', 'input[name="hh_x_frame_options"]', function () { |
| 54 | 31 | $('select[name="hh_x_frame_options_value"]').trigger('change'); |
| 55 | - }).on('change', 'input[name="hh_x_powered_by"]', function () { | |
| 56 | - $('select[name="hh_x_powered_by_option"]').trigger('change'); | |
| 57 | 32 | }).on('change', 'input[name="hh_access_control_allow_origin"]', function () { |
| 58 | 33 | $('select[name="hh_access_control_allow_origin_value"]').trigger('change'); |
| 59 | - }).on('change', 'input[name="hh_timing_allow_origin"]', function () { | |
| 60 | - $('select[name="hh_timing_allow_origin_value"]').trigger('change'); | |
| 61 | - }).on('submit', '#frmIspect', function (e) { | |
| 62 | - e.preventDefault(); | |
| 63 | - var $this = $(this), | |
| 64 | - $box = $('#hh-result').empty(); | |
| 65 | - $.post($this.attr('action'), $this.serialize()).done(function (data) { | |
| 66 | - $box.html(data); | |
| 67 | - }); | |
| 68 | - return false; | |
| 69 | - }).on('change', '#authentication', function () { | |
| 70 | - var $a = $('#box-authentication'); | |
| 71 | - if (this.checked) { | |
| 72 | - $a.show(); | |
| 73 | - } else { | |
| 74 | - $a.hide(); | |
| 75 | - } | |
| 76 | - }).on('click', '#hh-btn-add-header', function () { | |
| 77 | - $(this).closest('tr').before('<tr> \ | |
| 78 | - <td><input type="text" name="hh_custom_headers_value[name][]" class="http-header-value" placeholder="X-Custom-Name"></td> \ | |
| 79 | - <td><input type="text" name="hh_custom_headers_value[value][]" class="http-header-value" placeholder="' + hh.lbl_value + '"></td> \ | |
| 80 | - <td><button type="button" class="button button-small hh-btn-delete-header" title="' + hh.lbl_delete + '">x</button></td> \ | |
| 81 | - </tr>'); | |
| 82 | - }).on('click', '#hh-btn-add-endpoint', function () { | |
| 83 | - var $this = $(this), | |
| 84 | - index = Math.ceil(Math.random() * 9999), | |
| 85 | - $table = $this.closest("table"), | |
| 86 | - $clone = $table.find("tr:nth-child(2)").clone(), | |
| 87 | - name = $table.find("tr:nth-last-child(2)").find(":input:first").attr("name"), | |
| 88 | - m = name.match(/^hh_report_to_value\[(\d+)\]/), | |
| 89 | - index = Number(m[1]) + 1; | |
| 90 | - | |
| 91 | - $clone.find('input[type="text"]').val(""); | |
| 92 | - $clone.find('input[type="checkbox"]').prop("checked", false); | |
| 93 | - $clone.find("option:first").prop("selected", true); | |
| 94 | - $clone.find("td:last").html('<button type="button" class="button button-small hh-btn-delete-endpoint" title="' + hh.lbl_delete + '">x</button>'); | |
| 95 | - $clone.find(":input").each(function () { | |
| 96 | - this.name = this.name.replace('[0]', '[' + index + ']'); | |
| 97 | - }); | |
| 98 | - | |
| 99 | - $this.closest('tr').before($clone); | |
| 100 | - }).on('click', '.hh-btn-delete-header, .hh-btn-delete-endpoint, .hh-btn-delete-origin, .hh-btn-delete-user', function () { | |
| 101 | - $(this).closest('tr').remove(); | |
| 102 | - }).on("click", ".hh-btn-add-origin", function () { | |
| 103 | - $(this).closest('tr').before('<tr class="hh-acao"> \ | |
| 104 | - <td> </td> \ | |
| 105 | - <td><input type="text" name="hh_access_control_allow_origin_url[]" class="http-header-value" placeholder="http://domain.com" size="35" /></td> \ | |
| 106 | - <td><button type="button" class="button button-small hh-btn-delete-origin" title="' + hh.lbl_delete + '">x</button></td> \ | |
| 107 | - </tr>'); | |
| 108 | - }).on("click", ".hh-btn-add-user", function () { | |
| 109 | - $(this).closest('tr').before('<tr> \ | |
| 110 | - <td> </td> \ | |
| 111 | - <td><input type="text" name="hh_www_authenticate_user[]" class="http-header-value" /></td> \ | |
| 112 | - <td><input type="text" name="hh_www_authenticate_pswd[]" class="http-header-value" /></td> \ | |
| 113 | - <td><button type="button" class="button button-small hh-btn-delete-user" title="' + hh.lbl_delete + '">x</button></td> \ | |
| 114 | - </tr>'); | |
| 115 | - }).on("click", ".hh-btn-import-choose", function () { | |
| 116 | - $("#hh-import-file").trigger("click"); | |
| 117 | - }).on("change", "#hh-import-file", function () { | |
| 118 | - $("#hh-import-name").html(this.files[0].name); | |
| 119 | - }).on("change", 'select[name^="hh_feature_policy_value"]', function () { | |
| 120 | - var $this = $(this), | |
| 121 | - value = $this.find("option:selected").val(), | |
| 122 | - $input = $this.siblings('input[name^="hh_feature_policy_origin"]'); | |
| 123 | - if (value === "'self'" || value === "origin(s)") { | |
| 124 | - $input.show(); | |
| 125 | - } else { | |
| 126 | - $input.hide(); | |
| 127 | - } | |
| 128 | - }); | |
| 129 | - | |
| 130 | - $('.hh-tabs').on('click', 'ul a', function (e) { | |
| 131 | - e.preventDefault(); | |
| 132 | - | |
| 133 | - var $this = $(this); | |
| 134 | - $($this.attr('href')) | |
| 135 | - .removeClass('hh-hidden').addClass('hh-tab-active').attr('aria-hidden', 'false').attr('aria-expanded', 'true') | |
| 136 | - .siblings('div').addClass('hh-hidden').removeClass('hh-tab-active').attr('aria-hidden', 'true').attr('aria-expanded', 'false'); | |
| 137 | - $this.closest('li') | |
| 138 | - .addClass('hh-active').attr('aria-selected', 'true').attr('tabindex', 0) | |
| 139 | - .siblings('li').removeClass('hh-active').attr('aria-selected', 'false').attr('tabindex', -1); | |
| 140 | - }).each(function () { | |
| 141 | - var $this = $(this), | |
| 142 | - $ul = $this.children('ul').attr('role', 'tablist'), | |
| 143 | - $li = $ul.children('li').attr('role', 'tab') | |
| 144 | - .not(':first').attr('aria-selected', 'false').attr('tabindex', -1) | |
| 145 | - .end().eq(0).attr('aria-selected', 'true').attr('tabindex', 0) | |
| 146 | - .end(), | |
| 147 | - $a = $li.find('a').attr('role', 'presentation').attr('tabindex', -1), | |
| 148 | - $div = $this.children('div').attr('role', 'tabpanel') | |
| 149 | - .not(':first').attr('aria-hidden', 'true').attr('aria-expanded', 'false') | |
| 150 | - .end().eq(0).attr('aria-hidden', 'false').attr('aria-expanded', 'true') | |
| 151 | - .end(); | |
| 152 | - | |
| 153 | - $li.each(function (i) { | |
| 154 | - var $this = $(this), | |
| 155 | - id = 'hh-tabs-' + Math.ceil(Math.random() * 999999) + '-' + i, | |
| 156 | - $a = $this.attr('aria-labelledby', id).find('a').attr('id', id), | |
| 157 | - href = $a.attr('href'); | |
| 158 | - $this.attr('aria-controls', href.substring(1)).attr('aria-labelledby', id); | |
| 159 | - $(href).attr('aria-labelledby', id); | |
| 160 | - }); | |
| 161 | - | |
| 162 | 34 | }); |
| 163 | 35 | }); |
| 164 | 36 | })(jQuery); |