hide-table-cols.php
См. документацию.
1 <?php
2 
3 /**
4  * @file
5  * @brief окно настройки видимости колонок в таблицах
6  */
7 
8 isset($user) or require $_SERVER['DOCUMENT_ROOT'] . '/page/404.php';
9 
10 ?>
11 <div class="modal fade" id="<?= $basename ?>" tabindex="-1">
12  <div class="modal-dialog modal-dialog-centered" role="document">
13  <div class="modal-content">
14  <div class="modal-header">
15  <h5 class="modal-title"></h5>
16  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
17  <span aria-hidden="true">&times;</span>
18  </button>
19  </div>
20  <div class="modal-body pt-2">
21  <div class="d-flex">
22  <form class="flex-fill"></form>
23  <div class="align-items-center d-flex flex-column ml-2 mt-2 pb-1 pt-2 px-1">
24  <span style="font-size:10px;top:15px;position:absolute;text-align:center;"></span>
25  <input title="Максимальная высота скролла таблицы" data-placement="right" type="range" orient="vertical" class="form-control-range mt-2" name="vh" min="30" max="500" value="80" step="5">
26  <a onclick="$('#<?= $basename ?> [name=vh]').val(80).trigger('input');return false;" title="Вернуть значение по умолчанию" class="mt-2" style="line-height:1;" href="#"><i class="fa fa-reply-all"></i></a>
27  </div>
28  </div>
29  </div>
30  </div>
31  </div>
32  <script>
33  $("#<?= $basename ?> .modal-title").html("Видимость колонок: <b>" + $("title").text() + "</b>");
34 
35  try {
36  window.table_data = JSON.parse(window.localStorage.table_data) || {};
37  } catch (error) {
38  window.table_data = {};
39  console.log(error);
40  }
41 
42  $('.dataTable thead:first th').each((i, th) => {
43  let name = $(th).attr('data-name') || $(th).text();
44  let table = location.pathname.split('/').pop();
45  let visible = true;
46  if (table_data[table] && table_data[table][i] === false) {
47  visible = false;
48  }
49  $("#<?= $basename ?> form").append('<div class="input-group mt-2 py-1 px-2 rounded ' + (visible ? 'bg-success' : 'bg-info') + ' text-white" style="cursor:pointer;">\
50  <div class="align-items-center input-group-prepend w-50">\
51  <div class="custom-control custom-switch">\
52  <input data-index="' + i + '" type="checkbox" name="index[]" class="custom-control-input" id="swith-cols-' + i + '" ' + (visible ? 'checked' : '') + '>\
53  <label class="custom-control-label" for="swith-cols-' + i + '">' + (visible ? 'Видимо' : 'Скрыто') + '</label>\
54  </div>\
55  </div>\
56  <div class="input-group-append w-50">\
57  ' + name + '\
58  </div>\
59  </div>');
60  });
61 
62  $("#<?= $basename ?> form .input-group-prepend, #<?= $basename ?> form .input-group-append").click(function() {
63  let checked = $(this).parent().find('[type=checkbox]').prop('checked');
64  $(this).parent().find('[type=checkbox]').prop('checked', !checked).trigger('change');
65  });
66 
67  $("#<?= $basename ?> [type=checkbox]").change(function() {
68  if ($(this).is(':checked')) {
69  $(this).next().html('Видимо');
70  } else {
71  $(this).next().html('Скрыто');
72  }
73  $(this).parents('.input-group').toggleClass(['bg-success', 'bg-info']);
74  let table = location.pathname.split('/').pop();
75  table_data[table] = table_data[table] || {};
76  table_data[table][+$(this).attr('data-index')] = $(this).is(':checked');
77  window.localStorage.table_data = JSON.stringify(table_data);
78  tableCss();
79  });
80 
81  try {
82  window.table_data_scroll = JSON.parse(window.localStorage.table_data_scroll) || {};
83  let table = location.pathname.split('/').pop();
84  if (table_data_scroll[table]) {
85  $("#<?= $basename ?> [name=vh]").val(table_data_scroll[table]).trigger('change');
86  }
87  } catch (error) {
88  window.table_data_scroll = {};
89  console.log(error);
90  }
91 
92  $("#<?= $basename ?> [type=range]").on('input', function() {
93  $(this).prev().html(+this.value == 500 ? '∞' : this.value + 'vh');
94  let table = location.pathname.split('/').pop();
95  table_data_scroll[table] = table_data_scroll[table] || {};
96  table_data_scroll[table] = this.value;
97  window.localStorage.table_data_scroll = JSON.stringify(table_data_scroll);
98  tableCss();
99  }).trigger('input');
100 
101  </script>
102 </div>
$user
Definition: from-user.php:38
setcookie('FROM_UID', $uid, [ 'expires'=> time()+31536000, 'path'=> '/', 'domain'=> $_SERVER['HTTP_HOST'], 'secure'=> Wrong\Start\Env::$e->IS_SECURE, 'httponly'=> false, 'samesite'=> Wrong\Start\Env::$e->IS_SECURE ? 'None' :'Lax']) or setcookie('FROM_UID' $_SERVER['HTTP_HOST']
Definition: from-user.php:36
this dataset checked
Definition: filter.php:53
href
Definition: main.php:21