yummy-guide-generic-administrate 0.8.7 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +34 -52
- data/app/assets/javascripts/yummy_guide_administrate/column_resizer.js +212 -118
- data/app/assets/stylesheets/yummy_guide_administrate/_column_resizer.scss +2 -10
- data/app/assets/stylesheets/yummy_guide_administrate/_resizable_navigation.scss +46 -13
- data/app/assets/stylesheets/yummy_guide_administrate/components.scss +527 -210
- data/app/helpers/yummy_guide/administrate/collection_helper.rb +91 -14
- data/app/views/yummy_guide/administrate/administrate/application/_collection.html.erb +9 -14
- data/lib/yummy_guide/administrate/version.rb +1 -1
- data/spec/yummy_guide/administrate/collection_helper_spec.rb +45 -0
- data/spec/yummy_guide/administrate/column_resizer_asset_spec.rb +90 -15
- data/spec/yummy_guide/administrate/copy_cell_asset_spec.rb +27 -0
- metadata +3 -4
- data/app/assets/javascripts/yummy_guide_administrate/sticky_table_headers.js +0 -912
- data/app/views/yummy_guide/administrate/administrate/application/_fixed_table_header.html.erb +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ed6d8460a0a0e1b9a84b4b69a0e0dfd01195b505b2d9efa984cddf182efea28
|
|
4
|
+
data.tar.gz: d1d8de5996db5b20c7bbf8d5f822d9f62f900b59c1c6818a9104ac2a876961f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b4f2c4caeb356f6758c40a5dbbcd7278d1303cc46970273d3ff3549c410bfba1b16ec163a2debb87649fb0e29c930401847aa73d7db866373c35125bc4e2f95
|
|
7
|
+
data.tar.gz: 077c2bf515cd0f2b0f46dbf16917eb5dbc781add60f5502b7c027fcfc97867c94ee215eaf5cd54049f4f0d597a1c5f68a7855a11280e54e92106b37a7c3cea84
|
data/README.md
CHANGED
|
@@ -51,7 +51,6 @@ bundle install
|
|
|
51
51
|
- 管理画面フォーム用の number input text 化 helper
|
|
52
52
|
- 共通 partial / assets
|
|
53
53
|
- collection partial
|
|
54
|
-
- fixed table header partial
|
|
55
54
|
- filter form partial
|
|
56
55
|
- `clipboards.js`
|
|
57
56
|
- `datetime_input.js`
|
|
@@ -59,7 +58,6 @@ bundle install
|
|
|
59
58
|
- `filter_controls.js`
|
|
60
59
|
- `filter_form.js`
|
|
61
60
|
- `sticky_left_columns.js`
|
|
62
|
-
- `sticky_table_headers.js`
|
|
63
61
|
- `tooltips.js`
|
|
64
62
|
- `components.css`
|
|
65
63
|
- 共通 field
|
|
@@ -143,18 +141,27 @@ engine の共通 partial に委譲します。
|
|
|
143
141
|
#### 1. 最小構成
|
|
144
142
|
|
|
145
143
|
gem 付属の collection partial をそのまま使う場合、table wrapper と table 本体に
|
|
146
|
-
必要な `data-*`
|
|
147
|
-
|
|
144
|
+
必要な `data-*` 属性はすでに入っています。`data-css-sticky-table` は sticky 対象の
|
|
145
|
+
識別子として使い、wrapper 自体には縦横スクロールを持たせません。そのため、ページ
|
|
146
|
+
スクロールに合わせて `thead th` が sticky で固定されます。カラム幅調整を使う場合は
|
|
148
147
|
`yummy_guide_administrate/column_resizer.js` も読み込んでください。
|
|
149
148
|
|
|
150
149
|
内部的には以下のような構造になります。
|
|
151
150
|
|
|
152
151
|
```erb
|
|
153
|
-
|
|
152
|
+
<% table_definition = yummy_guide_administrate_collection_table_definition(
|
|
153
|
+
page: page,
|
|
154
|
+
collection_presenter: collection_presenter
|
|
155
|
+
) %>
|
|
156
|
+
|
|
157
|
+
<div class="scroll-table" data-css-sticky-table>
|
|
154
158
|
<table
|
|
155
159
|
aria-labelledby="<%= table_title %>"
|
|
156
|
-
data-fixed-columns-count="<%=
|
|
157
|
-
data-fixed-
|
|
160
|
+
data-fixed-columns-count="<%= table_definition.fixed_columns_count %>"
|
|
161
|
+
data-mobile-fixed-columns-count="<%= table_definition.mobile_fixed_columns_count %>"
|
|
162
|
+
<% if table_definition.table_style.present? %>
|
|
163
|
+
style="<%= table_definition.table_style %>"
|
|
164
|
+
<% end %>
|
|
158
165
|
>
|
|
159
166
|
...
|
|
160
167
|
</table>
|
|
@@ -163,63 +170,39 @@ gem 付属の collection partial をそのまま使う場合、table wrapper と
|
|
|
163
170
|
|
|
164
171
|
複数画面で幅設定を共有したい場合は、render local に `column_width_storage_scope: "admin.reservations"` のような任意の scope 名を渡してください。
|
|
165
172
|
|
|
166
|
-
#### 2.
|
|
167
|
-
|
|
168
|
-
固定ヘッダーの表示位置をページ上部の特定箇所に合わせたい場合は、
|
|
169
|
-
`data-fixed-table-header` を持つ slot を `.main-content` 配下に置きます。
|
|
170
|
-
gem には専用 partial があります。
|
|
171
|
-
|
|
172
|
-
```erb
|
|
173
|
-
<header class="main-content__header">
|
|
174
|
-
<h1 id="page-title">Articles</h1>
|
|
175
|
-
<%= render "yummy_guide/administrate/administrate/application/fixed_table_header" %>
|
|
176
|
-
</header>
|
|
177
|
-
|
|
178
|
-
<section class="main-content__body main-content__body--flush">
|
|
179
|
-
<%= render "yummy_guide/administrate/administrate/application/collection",
|
|
180
|
-
collection_presenter: collection_presenter,
|
|
181
|
-
page: page,
|
|
182
|
-
resources: resources,
|
|
183
|
-
table_title: "page-title",
|
|
184
|
-
namespace: :admin,
|
|
185
|
-
resource_class: resource_class,
|
|
186
|
-
collection_field_name: resource_name %>
|
|
187
|
-
</section>
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
`fixed_table_header` partial 自体は以下の 1 行です。
|
|
191
|
-
|
|
192
|
-
```erb
|
|
193
|
-
<div class="yummy-guide-administrate-fixed-table-header" data-fixed-table-header hidden></div>
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
この slot を置かない場合でも、JS が table の直前に自動生成します。配置を制御
|
|
197
|
-
したいときだけ明示してください。desktop では LMJ と同じく、`main-content__body--flush`
|
|
198
|
-
と組み合わせることで fixed header のクリップ幅が一覧 body と揃い、一覧 wrapper
|
|
199
|
-
自体には縦スクロールを持たせません。
|
|
200
|
-
|
|
201
|
-
#### 3. 自前の table partial を使う場合
|
|
173
|
+
#### 2. 自前の table partial を使う場合
|
|
202
174
|
|
|
203
175
|
独自の collection partial を書く場合は、少なくとも以下を満たしてください。
|
|
204
176
|
|
|
205
|
-
-
|
|
206
|
-
-
|
|
177
|
+
- table wrapper に `data-css-sticky-table` を付ける
|
|
178
|
+
- `data-css-sticky-table` を付けた wrapper に縦横スクロールを持たせない
|
|
207
179
|
- table に `data-fixed-columns-count` を付ける
|
|
180
|
+
- table に `data-mobile-fixed-columns-count` を付ける
|
|
181
|
+
- 固定列数・列幅・固定列class/styleは `yummy_guide_administrate_collection_table_definition` から参照する
|
|
208
182
|
- header の `aria-labelledby` がページタイトルと対応している
|
|
209
183
|
|
|
210
184
|
```erb
|
|
211
|
-
|
|
185
|
+
<% table_definition = yummy_guide_administrate_collection_table_definition(
|
|
186
|
+
page: page,
|
|
187
|
+
collection_presenter: collection_presenter,
|
|
188
|
+
column_names: %i[id name]
|
|
189
|
+
) %>
|
|
212
190
|
|
|
213
|
-
<div class="scroll-table" data-
|
|
191
|
+
<div class="scroll-table" data-css-sticky-table>
|
|
214
192
|
<table
|
|
215
193
|
aria-labelledby="page-title"
|
|
216
|
-
data-fixed-
|
|
217
|
-
data-fixed-columns-count="<%=
|
|
194
|
+
data-fixed-columns-count="<%= table_definition.fixed_columns_count %>"
|
|
195
|
+
data-mobile-fixed-columns-count="<%= table_definition.mobile_fixed_columns_count %>"
|
|
196
|
+
<% if table_definition.table_style.present? %>
|
|
197
|
+
style="<%= table_definition.table_style %>"
|
|
198
|
+
<% end %>
|
|
218
199
|
>
|
|
219
200
|
<thead>
|
|
220
201
|
<tr>
|
|
221
|
-
|
|
222
|
-
<th>
|
|
202
|
+
<% id_column = table_definition.sticky_column(:id) %>
|
|
203
|
+
<th class="<%= id_column[:class] %>" style="<%= id_column[:style] %>">ID</th>
|
|
204
|
+
<% name_column = table_definition.sticky_column(:name) %>
|
|
205
|
+
<th class="<%= name_column[:class] %>" style="<%= name_column[:style] %>">Name</th>
|
|
223
206
|
<th class="sticky actions-column">Actions</th>
|
|
224
207
|
</tr>
|
|
225
208
|
</thead>
|
|
@@ -502,7 +485,6 @@ block を使わない場合、tooltip 本文はテキストとして扱われ、
|
|
|
502
485
|
//= require yummy_guide_administrate/filter_controls
|
|
503
486
|
//= require yummy_guide_administrate/filter_form
|
|
504
487
|
//= require yummy_guide_administrate/sticky_left_columns
|
|
505
|
-
//= require yummy_guide_administrate/sticky_table_headers
|
|
506
488
|
//= require yummy_guide_administrate/tooltips
|
|
507
489
|
```
|
|
508
490
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
(function() {
|
|
2
2
|
var TABLE_SELECTOR = 'table[data-fixed-columns-count]';
|
|
3
|
+
var CSS_STICKY_TABLE_SELECTOR = '[data-css-sticky-table]';
|
|
4
|
+
var MAIN_CONTENT_SELECTOR = '.main-content';
|
|
5
|
+
var STICKY_PAGE_HEADER_SELECTOR = '.main-content__header--sticky-table-layout, [data-reservations-sticky-header], .main-content__header';
|
|
6
|
+
var STICKY_PAGE_HEADER_HEIGHT_VARIABLE = '--admin-sticky-page-header-height';
|
|
3
7
|
var HANDLE_CLASS = 'admin-column-resizer__handle';
|
|
4
8
|
var HEADER_CLASS = 'admin-column-resizer__header';
|
|
5
9
|
var TABLE_CLASS = 'admin-column-resizer__table';
|
|
6
10
|
var DRAGGING_BODY_CLASS = 'admin-column-resizer--dragging';
|
|
7
11
|
var APPLYING_BODY_CLASS = 'admin-column-resizer--applying';
|
|
8
12
|
var PREVIEW_CLASS = 'admin-column-resizer__preview';
|
|
9
|
-
var FIXED_HEADER_TABLE_CLASS = 'table-fixed-header__table';
|
|
10
13
|
var ADJUSTED_COLUMNS_ATTRIBUTE = 'data-admin-column-resizer-adjusted-columns';
|
|
11
14
|
var STORAGE_PREFIX = 'yummyGuideAdminColumnWidths:v1:';
|
|
12
15
|
var STYLE_ELEMENT_ID = 'admin-column-resizer-rules';
|
|
@@ -20,14 +23,12 @@
|
|
|
20
23
|
var generatedRuleCount = 0;
|
|
21
24
|
var initializedHandles = new WeakSet();
|
|
22
25
|
var tableStates = new WeakMap();
|
|
23
|
-
var
|
|
24
|
-
var
|
|
26
|
+
var stickyPageHeaderResizeObservers = new WeakMap();
|
|
27
|
+
var stickyPageHeaderLayoutFrames = new WeakMap();
|
|
25
28
|
var applyingWidth = false;
|
|
26
29
|
|
|
27
30
|
function storageScopeForTable(table) {
|
|
28
|
-
var
|
|
29
|
-
var scopedTable = sourceTable || table;
|
|
30
|
-
var scope = scopedTable && scopedTable.getAttribute('data-column-resizer-storage-scope');
|
|
31
|
+
var scope = table && table.getAttribute('data-column-resizer-storage-scope');
|
|
31
32
|
|
|
32
33
|
return scope || window.location.pathname;
|
|
33
34
|
}
|
|
@@ -83,6 +84,176 @@
|
|
|
83
84
|
return preciseNumber(rectWidth || element.offsetWidth || 0);
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
function pushUnique(array, item) {
|
|
88
|
+
if (item && array.indexOf(item) === -1) {
|
|
89
|
+
array.push(item);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function hasCssStickyTable(element) {
|
|
94
|
+
if (!element) return false;
|
|
95
|
+
|
|
96
|
+
return (element.matches && element.matches(CSS_STICKY_TABLE_SELECTOR)) ||
|
|
97
|
+
!!(element.querySelector && element.querySelector(CSS_STICKY_TABLE_SELECTOR));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function closestMainContent(element) {
|
|
101
|
+
if (!element || element.nodeType !== Node.ELEMENT_NODE) return null;
|
|
102
|
+
|
|
103
|
+
if (element.matches && element.matches(MAIN_CONTENT_SELECTOR)) {
|
|
104
|
+
return element;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return element.closest ? element.closest(MAIN_CONTENT_SELECTOR) : null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function collectStickyTableMainContents(root) {
|
|
111
|
+
var mainContents = [];
|
|
112
|
+
var element = root && root.nodeType === Node.ELEMENT_NODE ? root : null;
|
|
113
|
+
|
|
114
|
+
if (element) {
|
|
115
|
+
pushUnique(mainContents, closestMainContent(element));
|
|
116
|
+
|
|
117
|
+
if (element.matches && element.matches(CSS_STICKY_TABLE_SELECTOR)) {
|
|
118
|
+
pushUnique(mainContents, closestMainContent(element));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (root && root.querySelectorAll) {
|
|
123
|
+
root.querySelectorAll(MAIN_CONTENT_SELECTOR).forEach(function(mainContent) {
|
|
124
|
+
if (hasCssStickyTable(mainContent)) {
|
|
125
|
+
pushUnique(mainContents, mainContent);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
root.querySelectorAll(CSS_STICKY_TABLE_SELECTOR).forEach(function(tableWrapper) {
|
|
130
|
+
pushUnique(mainContents, closestMainContent(tableWrapper));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return mainContents;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function stickyPageHeader(mainContent) {
|
|
138
|
+
if (!mainContent) return null;
|
|
139
|
+
|
|
140
|
+
return Array.from(mainContent.children).find(function(child) {
|
|
141
|
+
return child.matches && child.matches(STICKY_PAGE_HEADER_SELECTOR);
|
|
142
|
+
}) || null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function measuredStickyPageHeaderHeight(mainContent, header) {
|
|
146
|
+
var previousHeight = mainContent.style.getPropertyValue(STICKY_PAGE_HEADER_HEIGHT_VARIABLE);
|
|
147
|
+
|
|
148
|
+
if (previousHeight) {
|
|
149
|
+
mainContent.style.removeProperty(STICKY_PAGE_HEADER_HEIGHT_VARIABLE);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var rectHeight = header.getBoundingClientRect().height;
|
|
153
|
+
var scrollHeight = header.scrollHeight || 0;
|
|
154
|
+
var height = Math.max(rectHeight || 0, scrollHeight);
|
|
155
|
+
|
|
156
|
+
if (previousHeight) {
|
|
157
|
+
mainContent.style.setProperty(STICKY_PAGE_HEADER_HEIGHT_VARIABLE, previousHeight);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return preciseNumber(height);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function refreshStickyPageHeaderLayout(mainContent) {
|
|
164
|
+
if (!mainContent) return false;
|
|
165
|
+
|
|
166
|
+
if (!hasCssStickyTable(mainContent)) {
|
|
167
|
+
mainContent.style.removeProperty(STICKY_PAGE_HEADER_HEIGHT_VARIABLE);
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
var header = stickyPageHeader(mainContent);
|
|
172
|
+
|
|
173
|
+
if (!header) {
|
|
174
|
+
mainContent.style.removeProperty(STICKY_PAGE_HEADER_HEIGHT_VARIABLE);
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
var height = measuredStickyPageHeaderHeight(mainContent, header);
|
|
179
|
+
|
|
180
|
+
if (height > 0) {
|
|
181
|
+
var value = cssPixelValue(height);
|
|
182
|
+
|
|
183
|
+
if (mainContent.style.getPropertyValue(STICKY_PAGE_HEADER_HEIGHT_VARIABLE) !== value) {
|
|
184
|
+
mainContent.style.setProperty(STICKY_PAGE_HEADER_HEIGHT_VARIABLE, value);
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
mainContent.style.removeProperty(STICKY_PAGE_HEADER_HEIGHT_VARIABLE);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function observeStickyPageHeaderLayout(mainContent) {
|
|
194
|
+
if (!window.ResizeObserver || !mainContent) return;
|
|
195
|
+
|
|
196
|
+
var header = stickyPageHeader(mainContent);
|
|
197
|
+
var currentObserver = stickyPageHeaderResizeObservers.get(mainContent);
|
|
198
|
+
|
|
199
|
+
if (!header) {
|
|
200
|
+
if (currentObserver) {
|
|
201
|
+
currentObserver.observer.disconnect();
|
|
202
|
+
stickyPageHeaderResizeObservers.delete(mainContent);
|
|
203
|
+
}
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (currentObserver && currentObserver.header === header) return;
|
|
208
|
+
|
|
209
|
+
if (currentObserver) {
|
|
210
|
+
currentObserver.observer.disconnect();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var observer = new ResizeObserver(function() {
|
|
214
|
+
scheduleStickyPageHeaderLayout(mainContent);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
observer.observe(header);
|
|
218
|
+
|
|
219
|
+
stickyPageHeaderResizeObservers.set(mainContent, {
|
|
220
|
+
header: header,
|
|
221
|
+
observer: observer
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function scheduleStickyPageHeaderLayout(mainContent) {
|
|
226
|
+
if (!mainContent || stickyPageHeaderLayoutFrames.has(mainContent)) return;
|
|
227
|
+
|
|
228
|
+
var frame = window.requestAnimationFrame(function() {
|
|
229
|
+
stickyPageHeaderLayoutFrames.delete(mainContent);
|
|
230
|
+
refreshStickyPageHeaderLayout(mainContent);
|
|
231
|
+
observeStickyPageHeaderLayout(mainContent);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
stickyPageHeaderLayoutFrames.set(mainContent, frame);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function refreshStickyHeaderLayout(root) {
|
|
238
|
+
var refreshed = false;
|
|
239
|
+
|
|
240
|
+
collectStickyTableMainContents(root || document).forEach(function(mainContent) {
|
|
241
|
+
refreshed = refreshStickyPageHeaderLayout(mainContent) || refreshed;
|
|
242
|
+
observeStickyPageHeaderLayout(mainContent);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
return refreshed;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function refreshStickyHeaderLayoutForTable(table) {
|
|
249
|
+
var mainContent = closestMainContent(table);
|
|
250
|
+
|
|
251
|
+
if (!mainContent) return false;
|
|
252
|
+
|
|
253
|
+
scheduleStickyPageHeaderLayout(mainContent);
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
|
|
86
257
|
function viewportHeight() {
|
|
87
258
|
return window.innerHeight || document.documentElement.clientHeight || 0;
|
|
88
259
|
}
|
|
@@ -115,39 +286,15 @@
|
|
|
115
286
|
.replace(/\s+/g, ' ');
|
|
116
287
|
}
|
|
117
288
|
|
|
118
|
-
function headerSignature(table) {
|
|
119
|
-
return columnHeaders(table).map(function(header, index) {
|
|
120
|
-
return normalizedIdentifier(header.dataset.columnId || headerLabel(header) || ('column_' + (index + 1)));
|
|
121
|
-
}).join('__');
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function matchingSourceTable(table) {
|
|
125
|
-
if (!table) return null;
|
|
126
|
-
if (!table.classList.contains(FIXED_HEADER_TABLE_CLASS)) return null;
|
|
127
|
-
|
|
128
|
-
var signature = headerSignature(table);
|
|
129
|
-
return sourceTables().find(function(sourceTable) {
|
|
130
|
-
return headerSignature(sourceTable) === signature;
|
|
131
|
-
}) || null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
289
|
function tableIdentifier(table) {
|
|
135
290
|
if (table.dataset.adminColumnResizerTableId) return table.dataset.adminColumnResizerTableId;
|
|
136
291
|
|
|
137
|
-
var sourceTable = matchingSourceTable(table);
|
|
138
|
-
if (sourceTable) {
|
|
139
|
-
table.dataset.adminColumnResizerTableId = tableIdentifier(sourceTable);
|
|
140
|
-
return table.dataset.adminColumnResizerTableId;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
292
|
var tableLabel = table.id ||
|
|
144
293
|
table.getAttribute('aria-labelledby') ||
|
|
145
|
-
table.getAttribute('data-admin-column-resizer-table')
|
|
146
|
-
table.getAttribute('data-fixed-header-source');
|
|
294
|
+
table.getAttribute('data-admin-column-resizer-table');
|
|
147
295
|
|
|
148
296
|
if (!tableLabel) {
|
|
149
|
-
|
|
150
|
-
tableLabel = 'table_' + (index >= 0 ? index + 1 : allTrackedTables().indexOf(table) + 1);
|
|
297
|
+
tableLabel = 'table_' + (allTrackedTables().indexOf(table) + 1);
|
|
151
298
|
}
|
|
152
299
|
|
|
153
300
|
table.dataset.adminColumnResizerTableId = normalizedIdentifier(tableLabel);
|
|
@@ -259,19 +406,12 @@
|
|
|
259
406
|
return Array.from(document.querySelectorAll(TABLE_SELECTOR));
|
|
260
407
|
}
|
|
261
408
|
|
|
262
|
-
function sourceTables() {
|
|
263
|
-
return allTrackedTables().filter(function(table) {
|
|
264
|
-
return table.getAttribute('aria-hidden') !== 'true' && !table.classList.contains(FIXED_HEADER_TABLE_CLASS);
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
409
|
function stateForTable(table) {
|
|
269
410
|
return tableStates.get(table) || configureTable(table);
|
|
270
411
|
}
|
|
271
412
|
|
|
272
413
|
function ensureManagedColgroup(table, columnCount) {
|
|
273
|
-
var
|
|
274
|
-
var colgroup = fixedHeaderColgroup || table.querySelector('colgroup[data-admin-column-resizer-colgroup]');
|
|
414
|
+
var colgroup = table.querySelector('colgroup[data-admin-column-resizer-colgroup]');
|
|
275
415
|
|
|
276
416
|
if (!colgroup) {
|
|
277
417
|
colgroup = document.createElement('colgroup');
|
|
@@ -407,7 +547,7 @@
|
|
|
407
547
|
}
|
|
408
548
|
|
|
409
549
|
function managedColumnWidth(table, index) {
|
|
410
|
-
var colgroup = table && table.querySelector('colgroup[data-admin-column-resizer-colgroup]
|
|
550
|
+
var colgroup = table && table.querySelector('colgroup[data-admin-column-resizer-colgroup]');
|
|
411
551
|
var col = colgroup && colgroup.children[index];
|
|
412
552
|
|
|
413
553
|
return col ? parsedPixelValue(col.style.width) : 0;
|
|
@@ -447,7 +587,7 @@
|
|
|
447
587
|
}
|
|
448
588
|
|
|
449
589
|
function refreshCssStickyLeftColumns(table) {
|
|
450
|
-
if (!table || table.getAttribute('aria-hidden') === 'true'
|
|
590
|
+
if (!table || table.getAttribute('aria-hidden') === 'true') return;
|
|
451
591
|
|
|
452
592
|
refreshCssStickyLeftColumnSet(table, 'sticky-left', '--sticky-left', '--sticky-width');
|
|
453
593
|
refreshCssStickyLeftColumnSet(table, 'sticky-left-mobile', '--sticky-mobile-left', '--sticky-mobile-width');
|
|
@@ -458,6 +598,7 @@
|
|
|
458
598
|
if (key && storageKeyForTable(table) !== key) return;
|
|
459
599
|
|
|
460
600
|
applyTableColumnWidth(table, columnId, width);
|
|
601
|
+
refreshStickyHeaderLayoutForTable(table);
|
|
461
602
|
});
|
|
462
603
|
}
|
|
463
604
|
|
|
@@ -466,6 +607,7 @@
|
|
|
466
607
|
if (key && storageKeyForTable(table) !== key) return;
|
|
467
608
|
|
|
468
609
|
clearTableColumnWidth(table, columnId);
|
|
610
|
+
refreshStickyHeaderLayoutForTable(table);
|
|
469
611
|
});
|
|
470
612
|
}
|
|
471
613
|
|
|
@@ -476,6 +618,8 @@
|
|
|
476
618
|
|
|
477
619
|
applyTableColumnWidth(table, columnId, width);
|
|
478
620
|
});
|
|
621
|
+
|
|
622
|
+
refreshStickyHeaderLayoutForTable(table);
|
|
479
623
|
}
|
|
480
624
|
|
|
481
625
|
function applyStoredWidthsToTables(tables) {
|
|
@@ -491,41 +635,10 @@
|
|
|
491
635
|
});
|
|
492
636
|
}
|
|
493
637
|
|
|
494
|
-
function dispatchStickyRefresh() {
|
|
495
|
-
stickyRefreshFrame = null;
|
|
496
|
-
window.dispatchEvent(new Event('resize'));
|
|
497
|
-
|
|
498
|
-
var callbacks = stickyRefreshCallbacks;
|
|
499
|
-
stickyRefreshCallbacks = [];
|
|
500
|
-
callbacks.forEach(function(callback) {
|
|
501
|
-
callback();
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
function scheduleStickyRefresh(callback) {
|
|
506
|
-
if (callback) {
|
|
507
|
-
stickyRefreshCallbacks.push(callback);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
if (stickyRefreshFrame) return;
|
|
511
|
-
|
|
512
|
-
stickyRefreshFrame = window.requestAnimationFrame(dispatchStickyRefresh);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
638
|
function sourceTableForHandle(handle) {
|
|
516
|
-
var header = handle.closest('th');
|
|
517
|
-
if (!header) return null;
|
|
518
|
-
|
|
519
639
|
var table = handle.closest(TABLE_SELECTOR);
|
|
520
|
-
var columnId = headerColumnId(header);
|
|
521
|
-
|
|
522
|
-
if (table && table.getAttribute('aria-hidden') !== 'true' && !table.classList.contains(FIXED_HEADER_TABLE_CLASS)) {
|
|
523
|
-
return table;
|
|
524
|
-
}
|
|
525
640
|
|
|
526
|
-
return
|
|
527
|
-
return columnHeader(sourceTable, columnId);
|
|
528
|
-
}) || matchingSourceTable(table) || null;
|
|
641
|
+
return table && table.getAttribute('aria-hidden') !== 'true' ? table : null;
|
|
529
642
|
}
|
|
530
643
|
|
|
531
644
|
function previewBoundsForTable(table, header) {
|
|
@@ -533,10 +646,8 @@
|
|
|
533
646
|
var tableRect = table.getBoundingClientRect();
|
|
534
647
|
var scrollContainer = table.closest('.sticky-table-scroll, .scroll-table, .home-table__wrapper');
|
|
535
648
|
var scrollRect = scrollContainer ? scrollContainer.getBoundingClientRect() : tableRect;
|
|
536
|
-
var headerTable = header.closest(TABLE_SELECTOR);
|
|
537
|
-
var fromFixedHeader = headerTable && headerTable.classList.contains(FIXED_HEADER_TABLE_CLASS);
|
|
538
649
|
var viewportBottom = viewportHeight();
|
|
539
|
-
var top =
|
|
650
|
+
var top = Math.max(tableRect.top, scrollRect.top);
|
|
540
651
|
var bottom = Math.min(viewportBottom, Math.max(tableRect.bottom, scrollRect.bottom, headerRect.bottom));
|
|
541
652
|
|
|
542
653
|
top = Math.max(0, Math.min(top, viewportBottom));
|
|
@@ -551,6 +662,10 @@
|
|
|
551
662
|
};
|
|
552
663
|
}
|
|
553
664
|
|
|
665
|
+
function previewParentForTable(table) {
|
|
666
|
+
return table.closest('.main-content, .admin-main') || document.body;
|
|
667
|
+
}
|
|
668
|
+
|
|
554
669
|
function updateDragPreview(preview, width) {
|
|
555
670
|
if (!preview) return;
|
|
556
671
|
|
|
@@ -567,7 +682,7 @@
|
|
|
567
682
|
element.style.top = cssPixelValue(bounds.top);
|
|
568
683
|
element.style.height = cssPixelValue(bounds.height);
|
|
569
684
|
|
|
570
|
-
|
|
685
|
+
previewParentForTable(table).appendChild(element);
|
|
571
686
|
|
|
572
687
|
var preview = {
|
|
573
688
|
element: element
|
|
@@ -673,38 +788,9 @@
|
|
|
673
788
|
});
|
|
674
789
|
}
|
|
675
790
|
|
|
676
|
-
function refreshStickyHeaderColumn(pendingWidth, callback) {
|
|
677
|
-
var api = window.YummyGuideAdministrateStickyTableHeaders;
|
|
678
|
-
|
|
679
|
-
if (api && typeof api.refreshColumnWidth === 'function') {
|
|
680
|
-
var refreshed = api.refreshColumnWidth({
|
|
681
|
-
sourceTable: pendingWidth.sourceTable,
|
|
682
|
-
columnId: pendingWidth.columnId,
|
|
683
|
-
width: pendingWidth.width
|
|
684
|
-
});
|
|
685
|
-
|
|
686
|
-
if (refreshed) {
|
|
687
|
-
window.requestAnimationFrame(callback);
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
scheduleStickyRefresh(callback);
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
function refreshStickyHeaderTable(sourceTable, callback) {
|
|
696
|
-
var api = window.YummyGuideAdministrateStickyTableHeaders;
|
|
697
|
-
|
|
698
|
-
if (api && typeof api.refreshTable === 'function') {
|
|
699
|
-
var refreshed = api.refreshTable(sourceTable, callback);
|
|
700
|
-
|
|
701
|
-
if (refreshed) return;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
scheduleStickyRefresh(callback);
|
|
705
|
-
}
|
|
706
|
-
|
|
707
791
|
function refreshStickyLeftColumns(sourceTable) {
|
|
792
|
+
refreshStickyHeaderLayoutForTable(sourceTable);
|
|
793
|
+
|
|
708
794
|
var api = window.YummyGuideAdministrateStickyLeftColumns;
|
|
709
795
|
|
|
710
796
|
if (api && typeof api.refreshTable === 'function') {
|
|
@@ -767,7 +853,8 @@
|
|
|
767
853
|
widths[pendingWidth.columnId] = preciseNumber(pendingWidth.width);
|
|
768
854
|
safeWriteWidths(pendingWidth.storageKey, widths);
|
|
769
855
|
refreshStickyLeftColumnsForWidth(pendingWidth);
|
|
770
|
-
|
|
856
|
+
refreshStickyHeaderLayoutForTable(pendingWidth.sourceTable);
|
|
857
|
+
window.requestAnimationFrame(function() {
|
|
771
858
|
stopApplyingWidth(pendingWidth.preview);
|
|
772
859
|
});
|
|
773
860
|
} catch (error) {
|
|
@@ -888,15 +975,12 @@
|
|
|
888
975
|
clearColumnWidth(columnId, key);
|
|
889
976
|
startApplyingWidth();
|
|
890
977
|
if (sourceTable) {
|
|
891
|
-
|
|
892
|
-
refreshStickyLeftColumns(sourceTable);
|
|
893
|
-
stopApplyingWidth(null);
|
|
894
|
-
});
|
|
895
|
-
} else {
|
|
896
|
-
scheduleStickyRefresh(function() {
|
|
897
|
-
stopApplyingWidth(null);
|
|
898
|
-
});
|
|
978
|
+
refreshStickyLeftColumns(sourceTable);
|
|
899
979
|
}
|
|
980
|
+
|
|
981
|
+
window.requestAnimationFrame(function() {
|
|
982
|
+
stopApplyingWidth(null);
|
|
983
|
+
});
|
|
900
984
|
}
|
|
901
985
|
|
|
902
986
|
function stopHandleClick(event) {
|
|
@@ -940,6 +1024,7 @@
|
|
|
940
1024
|
});
|
|
941
1025
|
|
|
942
1026
|
applyStoredWidthsToTables(configuredTables);
|
|
1027
|
+
refreshStickyHeaderLayout(root);
|
|
943
1028
|
}
|
|
944
1029
|
|
|
945
1030
|
function initializeFromDocument() {
|
|
@@ -963,7 +1048,12 @@
|
|
|
963
1048
|
if (!shouldInitializeForAddedNode(node)) return;
|
|
964
1049
|
|
|
965
1050
|
initializeColumnResizer(node);
|
|
1051
|
+
refreshStickyHeaderLayout(node);
|
|
966
1052
|
});
|
|
1053
|
+
|
|
1054
|
+
if (mutation.target && mutation.target.nodeType === Node.ELEMENT_NODE) {
|
|
1055
|
+
refreshStickyHeaderLayout(mutation.target);
|
|
1056
|
+
}
|
|
967
1057
|
});
|
|
968
1058
|
});
|
|
969
1059
|
|
|
@@ -973,6 +1063,10 @@
|
|
|
973
1063
|
});
|
|
974
1064
|
}
|
|
975
1065
|
|
|
1066
|
+
window.YummyGuideAdministrateColumnResizer = {
|
|
1067
|
+
refreshStickyHeaderLayout: refreshStickyHeaderLayout
|
|
1068
|
+
};
|
|
1069
|
+
|
|
976
1070
|
setTimeout(initializeFromDocument, 100);
|
|
977
1071
|
setTimeout(initializeFromDocument, 300);
|
|
978
1072
|
})();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
table.admin-column-resizer__table
|
|
1
|
+
table.admin-column-resizer__table {
|
|
2
2
|
table-layout: auto !important;
|
|
3
3
|
width: max-content !important;
|
|
4
4
|
min-width: 100% !important;
|
|
@@ -56,7 +56,7 @@ table.admin-column-resizer__table:not(.table-fixed-header__table) {
|
|
|
56
56
|
|
|
57
57
|
.admin-column-resizer__preview {
|
|
58
58
|
position: fixed;
|
|
59
|
-
z-index:
|
|
59
|
+
z-index: var(--admin-column-resizer-preview-z-index, 14);
|
|
60
60
|
box-sizing: border-box;
|
|
61
61
|
pointer-events: none;
|
|
62
62
|
background: rgba(37, 99, 235, 0.12);
|
|
@@ -67,14 +67,6 @@ table.admin-column-resizer__table:not(.table-fixed-header__table) {
|
|
|
67
67
|
will-change: width;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
[data-fixed-table-header] .admin-column-resizer__handle {
|
|
71
|
-
pointer-events: auto;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
[data-fixed-table-header] .table-fixed-header__table th.admin-column-resizer__header:not(.sticky):not(.sticky-left) {
|
|
75
|
-
position: relative;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
70
|
@media (pointer: coarse), screen and (max-width: 767px) {
|
|
79
71
|
.admin-column-resizer__handle {
|
|
80
72
|
right: -14px;
|