sibu 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/sibu/sibu.js.erb +5 -27
- data/app/assets/javascripts/tabs/van11y-accessible-tab-panel-aria.js +466 -0
- data/app/assets/stylesheets/sibu/defaults.scss +47 -0
- data/app/assets/stylesheets/sibu/sibu.css +0 -5
- data/app/controllers/sibu/pages_controller.rb +1 -1
- data/app/helpers/sibu/pages_helper.rb +1 -1
- data/app/models/sibu/site.rb +1 -1
- data/app/models/sibu/site_template.rb +8 -3
- data/app/views/layouts/sibu/edit_content.html.erb +7 -0
- data/app/views/sibu/pages/_media_edit_panel.html.erb +1 -1
- data/app/views/sibu/pages/_new_section_panel.html.erb +22 -6
- data/app/views/sibu/pages/edit_element.js.erb +8 -8
- data/app/views/sibu/pages/new_section.js.erb +15 -14
- data/lib/sibu/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1e386778852e44a0751ec065d259a3d02423e04
|
4
|
+
data.tar.gz: 63734db5d138f1a863428a8990c8abc901c6dbce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e82342f402b119115ed0fa6e76c2c1ba819847022ccb0ab45e890d8ddcc171b792b95287b99004b4b2c02122f152e1210f85677dff984e922beb4144b8c5a8cc
|
7
|
+
data.tar.gz: 168e70cca77e87181e289a5e624bfe60eadca752d35d95c80f31b66b4d68af3ba89409822fe1caadf1182e7af1ac3f767491051b27de47fada7ae950a08af645
|
@@ -2,6 +2,7 @@
|
|
2
2
|
//= require jquery_ujs
|
3
3
|
//= require sibu/common
|
4
4
|
//= require ../quill/quill
|
5
|
+
//= require ../tabs/van11y-accessible-tab-panel-aria
|
5
6
|
//= require_self
|
6
7
|
|
7
8
|
var Inline = Quill.import('blots/inline');
|
@@ -116,7 +117,6 @@ function initCustomCenter() {
|
|
116
117
|
var rect = e.target.getBoundingClientRect();
|
117
118
|
var x = e.clientX - rect.left;
|
118
119
|
var y = e.clientY - rect.top;
|
119
|
-
console.log('x : ' + x + ' - y : ' + y);
|
120
120
|
centerPos.css("top", y + "px");
|
121
121
|
centerPos.css("left", x + "px");
|
122
122
|
$("#element_class").val(`posx_${Math.floor((x / rect.width) * 10) * 10} posy_${Math.floor((y / rect.height) * 10) * 10}`);
|
@@ -138,32 +138,6 @@ function displayCurrentCenter(img, centerPos) {
|
|
138
138
|
centerPos.show();
|
139
139
|
}
|
140
140
|
|
141
|
-
|
142
|
-
//function initCropper(imgId) {
|
143
|
-
// var wrapper = $(".sibu_crop").first();
|
144
|
-
// var srcImg = $("#content_panel").find(".sb-editing img[data-id='" + imgId + "']").first();
|
145
|
-
// var srcContainer = srcImg.parent();
|
146
|
-
// var ratio = parseFloat(srcContainer.css("width")) / parseFloat(wrapper.css("width"));
|
147
|
-
// var wrapperHeight = Math.min(320, parseFloat(srcContainer.css("height")) / ratio) + "px";
|
148
|
-
// wrapper.css("height", wrapperHeight);
|
149
|
-
// return new Cropper(wrapper.find("img")[0], {
|
150
|
-
// crop: function(event) {
|
151
|
-
// var data = event.detail;
|
152
|
-
// var cropper = this.cropper;
|
153
|
-
// var imageData = cropper.getImageData();
|
154
|
-
// var previewWidth = parseFloat(srcContainer.css("width"));
|
155
|
-
// var imageScaledRatio = data.width / previewWidth;
|
156
|
-
// var width = imageData.naturalWidth / imageScaledRatio + 'px';
|
157
|
-
// var height = imageData.naturalHeight / imageScaledRatio + 'px';
|
158
|
-
// var marginLeft = -data.x / imageScaledRatio + 'px';
|
159
|
-
// var marginTop = -data.y / imageScaledRatio + 'px';
|
160
|
-
// // console.log("crop detail : " + JSON.stringify(data));
|
161
|
-
// // console.log('img data : ' + JSON.stringify(imageData));
|
162
|
-
// $("#element_style").val("width: " + width + "; height: " + height + "; margin-left: " + marginLeft + "; margin-top: " + marginTop +"; max-width: none; max-height: none;");
|
163
|
-
// }
|
164
|
-
// });
|
165
|
-
//}
|
166
|
-
|
167
141
|
function refreshAfterEdit(reload, sectionId) {
|
168
142
|
var baseUrl = window.location.href.split('?')[0];
|
169
143
|
if (reload) {
|
@@ -175,4 +149,8 @@ function refreshAfterEdit(reload, sectionId) {
|
|
175
149
|
} else {
|
176
150
|
window.history.replaceState(null, null, window.location.pathname);
|
177
151
|
}
|
152
|
+
}
|
153
|
+
|
154
|
+
function initSectionsPanel() {
|
155
|
+
|
178
156
|
}
|
@@ -0,0 +1,466 @@
|
|
1
|
+
/*
|
2
|
+
* ES2015 accessible tabs panel system, using ARIA
|
3
|
+
* Website: https://van11y.net/accessible-tab-panel/
|
4
|
+
* License MIT: https://github.com/nico3333fr/van11y-accessible-tab-panel-aria/blob/master/LICENSE
|
5
|
+
*/
|
6
|
+
'use strict';
|
7
|
+
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
9
|
+
|
10
|
+
(function (doc) {
|
11
|
+
|
12
|
+
'use strict';
|
13
|
+
|
14
|
+
var TABS_JS = 'js-tabs';
|
15
|
+
var TABS_JS_LIST = 'js-tablist';
|
16
|
+
var TABS_JS_LISTITEM = 'js-tablist__item';
|
17
|
+
var TABS_JS_LISTLINK = 'js-tablist__link';
|
18
|
+
var TABS_JS_CONTENT = 'js-tabcontent';
|
19
|
+
var TABS_JS_LINK_TO_TAB = 'js-link-to-tab';
|
20
|
+
|
21
|
+
var TABS_DATA_PREFIX_CLASS = 'data-tabs-prefix-class';
|
22
|
+
var TABS_DATA_HX = 'data-hx';
|
23
|
+
var TABS_DATA_GENERATED_HX_CLASS = 'data-tabs-generated-hx-class';
|
24
|
+
var TABS_DATA_EXISTING_HX = 'data-existing-hx';
|
25
|
+
|
26
|
+
var TABS_DATA_SELECTED_TAB = 'data-selected';
|
27
|
+
|
28
|
+
var TABS_PREFIX_IDS = 'label_';
|
29
|
+
|
30
|
+
var TABS_STYLE = 'tabs';
|
31
|
+
var TABS_LIST_STYLE = 'tabs__list';
|
32
|
+
var TABS_LISTITEM_STYLE = 'tabs__item';
|
33
|
+
var TABS_LINK_STYLE = 'tabs__link';
|
34
|
+
var TABS_CONTENT_STYLE = 'tabs__content';
|
35
|
+
|
36
|
+
var TABS_HX_DEFAULT_CLASS = 'invisible';
|
37
|
+
|
38
|
+
var TABS_ROLE_TABLIST = 'tablist';
|
39
|
+
var TABS_ROLE_TAB = 'tab';
|
40
|
+
var TABS_ROLE_TABPANEL = 'tabpanel';
|
41
|
+
var TABS_ROLE_PRESENTATION = 'presentation';
|
42
|
+
|
43
|
+
var ATTR_ROLE = 'role';
|
44
|
+
var ATTR_LABELLEDBY = 'aria-labelledby';
|
45
|
+
var ATTR_HIDDEN = 'aria-hidden';
|
46
|
+
var ATTR_CONTROLS = 'aria-controls';
|
47
|
+
var ATTR_SELECTED = 'aria-selected';
|
48
|
+
|
49
|
+
var DELAY_HASH_UPDATE = 1000;
|
50
|
+
|
51
|
+
var hash = window.location.hash.replace('#', '');
|
52
|
+
|
53
|
+
//const IS_OPENED_CLASS = 'is-opened';
|
54
|
+
|
55
|
+
var findById = function findById(id) {
|
56
|
+
return doc.getElementById(id);
|
57
|
+
};
|
58
|
+
|
59
|
+
var addClass = function addClass(el, className) {
|
60
|
+
if (el.classList) {
|
61
|
+
el.classList.add(className); // IE 10+
|
62
|
+
} else {
|
63
|
+
el.className += ' ' + className; // IE 8+
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
/*const removeClass = (el, className) => {
|
68
|
+
if (el.classList) {
|
69
|
+
el.classList.remove(className); // IE 10+
|
70
|
+
}
|
71
|
+
else {
|
72
|
+
el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' '); // IE 8+
|
73
|
+
}
|
74
|
+
}*/
|
75
|
+
|
76
|
+
var hasClass = function hasClass(el, className) {
|
77
|
+
if (el.classList) {
|
78
|
+
return el.classList.contains(className); // IE 10+
|
79
|
+
} else {
|
80
|
+
return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className); // IE 8+ ?
|
81
|
+
}
|
82
|
+
};
|
83
|
+
|
84
|
+
var setAttributes = function setAttributes(node, attrs) {
|
85
|
+
Object.keys(attrs).forEach(function (attribute) {
|
86
|
+
node.setAttribute(attribute, attrs[attribute]);
|
87
|
+
});
|
88
|
+
};
|
89
|
+
var unSelectLinks = function unSelectLinks(elts) {
|
90
|
+
elts.forEach(function (link_node) {
|
91
|
+
var _setAttributes;
|
92
|
+
|
93
|
+
setAttributes(link_node, (_setAttributes = {}, _defineProperty(_setAttributes, ATTR_SELECTED, 'false'), _defineProperty(_setAttributes, 'tabindex', '-1'), _setAttributes));
|
94
|
+
});
|
95
|
+
};
|
96
|
+
var unSelectContents = function unSelectContents(elts) {
|
97
|
+
elts.forEach(function (content_node) {
|
98
|
+
content_node.setAttribute(ATTR_HIDDEN, true);
|
99
|
+
});
|
100
|
+
};
|
101
|
+
|
102
|
+
var selectLink = function selectLink(el) {
|
103
|
+
var _setAttributes2;
|
104
|
+
|
105
|
+
var destination = findById(el.getAttribute(ATTR_CONTROLS));
|
106
|
+
setAttributes(el, (_setAttributes2 = {}, _defineProperty(_setAttributes2, ATTR_SELECTED, 'true'), _defineProperty(_setAttributes2, 'tabindex', '0'), _setAttributes2));
|
107
|
+
destination.removeAttribute(ATTR_HIDDEN);
|
108
|
+
setTimeout(function () {
|
109
|
+
el.focus();
|
110
|
+
}, 0);
|
111
|
+
// Note : removed to prevent conflicts when editing sibu elements
|
112
|
+
// setTimeout(function () {
|
113
|
+
// history.pushState(null, null, location.pathname + location.search + '#' + el.getAttribute(ATTR_CONTROLS));
|
114
|
+
// }, DELAY_HASH_UPDATE);
|
115
|
+
};
|
116
|
+
|
117
|
+
var selectLinkInList = function selectLinkInList(itemsList, linkList, contentList, param) {
|
118
|
+
var indice_trouve = undefined;
|
119
|
+
|
120
|
+
itemsList.forEach(function (itemNode, index) {
|
121
|
+
if (itemNode.querySelector('.' + TABS_JS_LISTLINK).getAttribute(ATTR_SELECTED) === 'true') {
|
122
|
+
indice_trouve = index;
|
123
|
+
}
|
124
|
+
});
|
125
|
+
unSelectLinks(linkList);
|
126
|
+
unSelectContents(contentList);
|
127
|
+
if (param === 'next') {
|
128
|
+
selectLink(linkList[indice_trouve + 1]);
|
129
|
+
setTimeout(function () {
|
130
|
+
linkList[indice_trouve + 1].focus();
|
131
|
+
}, 0);
|
132
|
+
}
|
133
|
+
if (param === 'prev') {
|
134
|
+
selectLink(linkList[indice_trouve - 1]);
|
135
|
+
setTimeout(function () {
|
136
|
+
linkList[indice_trouve - 1].focus();
|
137
|
+
}, 0);
|
138
|
+
}
|
139
|
+
};
|
140
|
+
|
141
|
+
/* gets an element el, search if it is child of parent class, returns id of the parent */
|
142
|
+
var searchParent = function searchParent(el, parentClass) {
|
143
|
+
var found = false;
|
144
|
+
var parentElement = el.parentNode;
|
145
|
+
while (parentElement && found === false) {
|
146
|
+
if (hasClass(parentElement, parentClass) === true) {
|
147
|
+
found = true;
|
148
|
+
} else {
|
149
|
+
parentElement = parentElement.parentNode;
|
150
|
+
}
|
151
|
+
}
|
152
|
+
if (found === true) {
|
153
|
+
return parentElement.getAttribute('id');
|
154
|
+
} else {
|
155
|
+
return '';
|
156
|
+
}
|
157
|
+
};
|
158
|
+
|
159
|
+
/** Find all tabs inside a container
|
160
|
+
* @param {Node} node Default document
|
161
|
+
* @return {Array}
|
162
|
+
*/
|
163
|
+
var $listTabs = function $listTabs() {
|
164
|
+
var node = arguments.length <= 0 || arguments[0] === undefined ? doc : arguments[0];
|
165
|
+
return [].slice.call(node.querySelectorAll('.' + TABS_JS));
|
166
|
+
};
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Build tooltips for a container
|
170
|
+
* @param {Node} node
|
171
|
+
*/
|
172
|
+
var attach = function attach(node) {
|
173
|
+
|
174
|
+
$listTabs(node).forEach(function (tabs_node) {
|
175
|
+
|
176
|
+
var iLisible = Math.random().toString(32).slice(2, 12);
|
177
|
+
var prefixClassName = tabs_node.hasAttribute(TABS_DATA_PREFIX_CLASS) === true ? tabs_node.getAttribute(TABS_DATA_PREFIX_CLASS) + '-' : '';
|
178
|
+
var hx = tabs_node.hasAttribute(TABS_DATA_HX) === true ? tabs_node.getAttribute(TABS_DATA_HX) : '';
|
179
|
+
var hxGeneratedClass = tabs_node.hasAttribute(TABS_DATA_GENERATED_HX_CLASS) === true ? tabs_node.getAttribute(TABS_DATA_GENERATED_HX_CLASS) : TABS_HX_DEFAULT_CLASS;
|
180
|
+
var existingHx = tabs_node.hasAttribute(TABS_DATA_EXISTING_HX) === true ? tabs_node.getAttribute(TABS_DATA_EXISTING_HX) : '';
|
181
|
+
var $tabList = [].slice.call(tabs_node.querySelectorAll('.' + TABS_JS_LIST));
|
182
|
+
var $tabListItems = [].slice.call(tabs_node.querySelectorAll('.' + TABS_JS_LISTITEM));
|
183
|
+
var $tabListLinks = [].slice.call(tabs_node.querySelectorAll('.' + TABS_JS_LISTLINK));
|
184
|
+
var $tabListPanels = [].slice.call(tabs_node.querySelectorAll('.' + TABS_JS_CONTENT));
|
185
|
+
var noTabSelected = true;
|
186
|
+
|
187
|
+
// container
|
188
|
+
addClass(tabs_node, prefixClassName + TABS_STYLE);
|
189
|
+
tabs_node.setAttribute('id', TABS_STYLE + iLisible);
|
190
|
+
|
191
|
+
// ul
|
192
|
+
$tabList.forEach(function (tabList) {
|
193
|
+
var _setAttributes3;
|
194
|
+
|
195
|
+
addClass(tabList, prefixClassName + TABS_LIST_STYLE);
|
196
|
+
setAttributes(tabList, (_setAttributes3 = {}, _defineProperty(_setAttributes3, ATTR_ROLE, TABS_ROLE_TABLIST), _defineProperty(_setAttributes3, 'id', TABS_LIST_STYLE + iLisible), _setAttributes3));
|
197
|
+
});
|
198
|
+
// li
|
199
|
+
$tabListItems.forEach(function (tabListItem, index) {
|
200
|
+
var _setAttributes4;
|
201
|
+
|
202
|
+
addClass(tabListItem, prefixClassName + TABS_LISTITEM_STYLE);
|
203
|
+
setAttributes(tabListItem, (_setAttributes4 = {}, _defineProperty(_setAttributes4, ATTR_ROLE, TABS_ROLE_PRESENTATION), _defineProperty(_setAttributes4, 'id', TABS_LISTITEM_STYLE + iLisible + '-' + (index + 1)), _setAttributes4));
|
204
|
+
});
|
205
|
+
// a
|
206
|
+
$tabListLinks.forEach(function (tabListLink) {
|
207
|
+
var _setAttributes5, _setAttributes6;
|
208
|
+
|
209
|
+
var idHref = tabListLink.getAttribute("href").replace('#', '');
|
210
|
+
var panelControlled = findById(idHref);
|
211
|
+
var linkText = tabListLink.innerText;
|
212
|
+
var panelSelected = tabListLink.hasAttribute(TABS_DATA_SELECTED_TAB) === true;
|
213
|
+
|
214
|
+
addClass(tabListLink, prefixClassName + TABS_LINK_STYLE);
|
215
|
+
setAttributes(tabListLink, (_setAttributes5 = {
|
216
|
+
'id': TABS_PREFIX_IDS + idHref
|
217
|
+
}, _defineProperty(_setAttributes5, ATTR_ROLE, TABS_ROLE_TAB), _defineProperty(_setAttributes5, ATTR_CONTROLS, idHref), _defineProperty(_setAttributes5, 'tabindex', '-1'), _defineProperty(_setAttributes5, ATTR_SELECTED, 'false'), _setAttributes5));
|
218
|
+
|
219
|
+
// panel controlled
|
220
|
+
setAttributes(panelControlled, (_setAttributes6 = {}, _defineProperty(_setAttributes6, ATTR_HIDDEN, 'true'), _defineProperty(_setAttributes6, ATTR_ROLE, TABS_ROLE_TABPANEL), _defineProperty(_setAttributes6, ATTR_LABELLEDBY, TABS_PREFIX_IDS + idHref), _setAttributes6));
|
221
|
+
addClass(panelControlled, prefixClassName + TABS_CONTENT_STYLE);
|
222
|
+
|
223
|
+
// if already selected
|
224
|
+
if (panelSelected && noTabSelected) {
|
225
|
+
noTabSelected = false;
|
226
|
+
setAttributes(tabListLink, _defineProperty({
|
227
|
+
'tabindex': '0'
|
228
|
+
}, ATTR_SELECTED, 'true'));
|
229
|
+
setAttributes(panelControlled, _defineProperty({}, ATTR_HIDDEN, 'false'));
|
230
|
+
}
|
231
|
+
|
232
|
+
// hx
|
233
|
+
if (hx !== '') {
|
234
|
+
var hx_node = document.createElement(hx);
|
235
|
+
hx_node.setAttribute('class', hxGeneratedClass);
|
236
|
+
hx_node.setAttribute('tabindex', '0');
|
237
|
+
hx_node.innerHTML = linkText;
|
238
|
+
panelControlled.insertBefore(hx_node, panelControlled.firstChild);
|
239
|
+
}
|
240
|
+
// existingHx
|
241
|
+
|
242
|
+
if (existingHx !== '') {
|
243
|
+
var $hx_existing = [].slice.call(panelControlled.querySelectorAll(existingHx + ':first-child'));
|
244
|
+
$hx_existing.forEach(function (hx_item) {
|
245
|
+
hx_item.setAttribute('tabindex', '0');
|
246
|
+
});
|
247
|
+
}
|
248
|
+
|
249
|
+
tabListLink.removeAttribute('href');
|
250
|
+
});
|
251
|
+
|
252
|
+
if (hash !== '') {
|
253
|
+
var nodeHashed = findById(hash);
|
254
|
+
if (nodeHashed !== null) {
|
255
|
+
// just in case of an dumb error
|
256
|
+
// search if hash is current tabs_node
|
257
|
+
if (tabs_node.querySelector('#' + hash) !== null) {
|
258
|
+
// search if hash is ON tabs
|
259
|
+
if (hasClass(nodeHashed, TABS_JS_CONTENT) === true) {
|
260
|
+
// unselect others
|
261
|
+
unSelectLinks($tabListLinks);
|
262
|
+
unSelectContents($tabListPanels);
|
263
|
+
// select this one
|
264
|
+
nodeHashed.removeAttribute(ATTR_HIDDEN);
|
265
|
+
var linkHashed = findById(TABS_PREFIX_IDS + hash);
|
266
|
+
setAttributes(linkHashed, _defineProperty({
|
267
|
+
'tabindex': '0'
|
268
|
+
}, ATTR_SELECTED, 'true'));
|
269
|
+
noTabSelected = false;
|
270
|
+
} else {
|
271
|
+
// search if hash is IN tabs
|
272
|
+
var panelParentId = searchParent(nodeHashed, TABS_JS_CONTENT);
|
273
|
+
if (panelParentId !== '') {
|
274
|
+
// unselect others
|
275
|
+
unSelectLinks($tabListLinks);
|
276
|
+
unSelectContents($tabListPanels);
|
277
|
+
// select this one
|
278
|
+
var panelParent = findById(panelParentId);
|
279
|
+
panelParent.removeAttribute(ATTR_HIDDEN);
|
280
|
+
var linkParent = findById(TABS_PREFIX_IDS + panelParentId);
|
281
|
+
setAttributes(linkParent, _defineProperty({
|
282
|
+
'tabindex': '0'
|
283
|
+
}, ATTR_SELECTED, 'true'));
|
284
|
+
noTabSelected = false;
|
285
|
+
}
|
286
|
+
}
|
287
|
+
}
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
// if no selected => select first
|
292
|
+
if (noTabSelected === true) {
|
293
|
+
setAttributes($tabListLinks[0], _defineProperty({
|
294
|
+
'tabindex': '0'
|
295
|
+
}, ATTR_SELECTED, 'true'));
|
296
|
+
var panelFirst = findById($tabListLinks[0].getAttribute(ATTR_CONTROLS));
|
297
|
+
panelFirst.removeAttribute(ATTR_HIDDEN);
|
298
|
+
}
|
299
|
+
});
|
300
|
+
};
|
301
|
+
|
302
|
+
/* listeners */
|
303
|
+
var bindListeners = function() {
|
304
|
+
['click', 'keydown'].forEach(function (eventName) {
|
305
|
+
//let isCtrl = false;
|
306
|
+
|
307
|
+
doc.body.addEventListener(eventName, function (e) {
|
308
|
+
|
309
|
+
// click on a tab link or on something IN a tab link
|
310
|
+
var parentLink = searchParent(e.target, TABS_JS_LISTLINK);
|
311
|
+
if ((hasClass(e.target, TABS_JS_LISTLINK) === true || parentLink !== '') && eventName === 'click') {
|
312
|
+
var linkSelected = hasClass(e.target, TABS_JS_LISTLINK) === true ? e.target : findById(parentLink);
|
313
|
+
var parentTabId = searchParent(e.target, TABS_JS);
|
314
|
+
var parentTab = findById(parentTabId);
|
315
|
+
//let $parentListItems = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_LISTITEM));
|
316
|
+
var $parentListLinks = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_LISTLINK));
|
317
|
+
var $parentListContents = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_CONTENT));
|
318
|
+
|
319
|
+
// aria selected false on all links
|
320
|
+
unSelectLinks($parentListLinks);
|
321
|
+
// add aria-hidden on all tabs contents
|
322
|
+
unSelectContents($parentListContents);
|
323
|
+
// add aria selected on selected link + show linked panel
|
324
|
+
selectLink(linkSelected);
|
325
|
+
|
326
|
+
e.preventDefault();
|
327
|
+
}
|
328
|
+
|
329
|
+
// Key down on tabs
|
330
|
+
if ((hasClass(e.target, TABS_JS_LISTLINK) === true || parentLink !== '') && eventName === 'keydown') {
|
331
|
+
//let linkSelected = hasClass( e.target, TABS_JS_LISTLINK) === true ? e.target : findById( parentLink );
|
332
|
+
var parentTabId = searchParent(e.target, TABS_JS);
|
333
|
+
var parentTab = findById(parentTabId);
|
334
|
+
var $parentListItems = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_LISTITEM));
|
335
|
+
var $parentListLinks = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_LISTLINK));
|
336
|
+
var $parentListContents = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_CONTENT));
|
337
|
+
var firstLink = $parentListItems[0].querySelector('.' + TABS_JS_LISTLINK);
|
338
|
+
var lastLink = $parentListItems[$parentListItems.length - 1].querySelector('.' + TABS_JS_LISTLINK);
|
339
|
+
|
340
|
+
// strike home on a tab => 1st tab
|
341
|
+
if (e.keyCode === 36) {
|
342
|
+
unSelectLinks($parentListLinks);
|
343
|
+
unSelectContents($parentListContents);
|
344
|
+
selectLink(firstLink);
|
345
|
+
|
346
|
+
e.preventDefault();
|
347
|
+
}
|
348
|
+
// strike end on a tab => last tab
|
349
|
+
else if (e.keyCode === 35) {
|
350
|
+
unSelectLinks($parentListLinks);
|
351
|
+
unSelectContents($parentListContents);
|
352
|
+
selectLink(lastLink);
|
353
|
+
|
354
|
+
e.preventDefault();
|
355
|
+
}
|
356
|
+
// strike up or left on the tab => previous tab
|
357
|
+
else if ((e.keyCode === 37 || e.keyCode === 38) && !e.ctrlKey) {
|
358
|
+
if (firstLink.getAttribute(ATTR_SELECTED) === 'true') {
|
359
|
+
unSelectLinks($parentListLinks);
|
360
|
+
unSelectContents($parentListContents);
|
361
|
+
selectLink(lastLink);
|
362
|
+
|
363
|
+
e.preventDefault();
|
364
|
+
} else {
|
365
|
+
selectLinkInList($parentListItems, $parentListLinks, $parentListContents, 'prev');
|
366
|
+
e.preventDefault();
|
367
|
+
}
|
368
|
+
}
|
369
|
+
// strike down or right in the tab => next tab
|
370
|
+
else if ((e.keyCode === 40 || e.keyCode === 39) && !e.ctrlKey) {
|
371
|
+
if (lastLink.getAttribute(ATTR_SELECTED) === 'true') {
|
372
|
+
unSelectLinks($parentListLinks);
|
373
|
+
unSelectContents($parentListContents);
|
374
|
+
selectLink(firstLink);
|
375
|
+
|
376
|
+
e.preventDefault();
|
377
|
+
} else {
|
378
|
+
selectLinkInList($parentListItems, $parentListLinks, $parentListContents, 'next');
|
379
|
+
e.preventDefault();
|
380
|
+
}
|
381
|
+
}
|
382
|
+
}
|
383
|
+
|
384
|
+
// Key down in tab panels
|
385
|
+
var parentTabPanelId = searchParent(e.target, TABS_JS_CONTENT);
|
386
|
+
if (parentTabPanelId !== '' && eventName === 'keydown') {
|
387
|
+
(function () {
|
388
|
+
var linkSelected = findById(findById(parentTabPanelId).getAttribute(ATTR_LABELLEDBY));
|
389
|
+
var parentTabId = searchParent(e.target, TABS_JS);
|
390
|
+
var parentTab = findById(parentTabId);
|
391
|
+
var $parentListItems = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_LISTITEM));
|
392
|
+
var $parentListLinks = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_LISTLINK));
|
393
|
+
var $parentListContents = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_CONTENT));
|
394
|
+
var firstLink = $parentListItems[0].querySelector('.' + TABS_JS_LISTLINK);
|
395
|
+
var lastLink = $parentListItems[$parentListItems.length - 1].querySelector('.' + TABS_JS_LISTLINK);
|
396
|
+
|
397
|
+
// strike up + ctrl => go to header
|
398
|
+
if (e.keyCode === 38 && e.ctrlKey) {
|
399
|
+
setTimeout(function () {
|
400
|
+
linkSelected.focus();
|
401
|
+
}, 0);
|
402
|
+
e.preventDefault();
|
403
|
+
}
|
404
|
+
// strike pageup + ctrl => go to prev header
|
405
|
+
if (e.keyCode === 33 && e.ctrlKey) {
|
406
|
+
// go to header
|
407
|
+
linkSelected.focus();
|
408
|
+
e.preventDefault();
|
409
|
+
// then previous
|
410
|
+
if (firstLink.getAttribute(ATTR_SELECTED) === 'true') {
|
411
|
+
unSelectLinks($parentListLinks);
|
412
|
+
unSelectContents($parentListContents);
|
413
|
+
selectLink(lastLink);
|
414
|
+
} else {
|
415
|
+
selectLinkInList($parentListItems, $parentListLinks, $parentListContents, 'prev');
|
416
|
+
}
|
417
|
+
}
|
418
|
+
// strike pagedown + ctrl => go to next header
|
419
|
+
if (e.keyCode === 34 && e.ctrlKey) {
|
420
|
+
// go to header
|
421
|
+
linkSelected.focus();
|
422
|
+
e.preventDefault();
|
423
|
+
// then next
|
424
|
+
if (lastLink.getAttribute(ATTR_SELECTED) === 'true') {
|
425
|
+
unSelectLinks($parentListLinks);
|
426
|
+
unSelectContents($parentListContents);
|
427
|
+
selectLink(firstLink);
|
428
|
+
} else {
|
429
|
+
selectLinkInList($parentListItems, $parentListLinks, $parentListContents, 'next');
|
430
|
+
}
|
431
|
+
}
|
432
|
+
})();
|
433
|
+
}
|
434
|
+
|
435
|
+
// click on a tab link
|
436
|
+
var parentLinkToPanelId = searchParent(e.target, TABS_JS_LINK_TO_TAB);
|
437
|
+
if ((hasClass(e.target, TABS_JS_LINK_TO_TAB) === true || parentLinkToPanelId !== '') && eventName === 'click') {
|
438
|
+
var panelSelectedId = hasClass(e.target, TABS_JS_LINK_TO_TAB) === true ? e.target.getAttribute('href').replace('#', '') : findById(parentLinkToPanelId).replace('#', '');
|
439
|
+
var panelSelected = findById(panelSelectedId);
|
440
|
+
var buttonPanelSelected = findById(panelSelected.getAttribute(ATTR_LABELLEDBY));
|
441
|
+
var parentTabId = searchParent(e.target, TABS_JS);
|
442
|
+
var parentTab = findById(parentTabId);
|
443
|
+
//let $parentListItems = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_LISTITEM));
|
444
|
+
var $parentListLinks = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_LISTLINK));
|
445
|
+
var $parentListContents = [].slice.call(parentTab.querySelectorAll('.' + TABS_JS_CONTENT));
|
446
|
+
|
447
|
+
unSelectLinks($parentListLinks);
|
448
|
+
unSelectContents($parentListContents);
|
449
|
+
selectLink(buttonPanelSelected);
|
450
|
+
|
451
|
+
e.preventDefault();
|
452
|
+
}
|
453
|
+
}, true);
|
454
|
+
});
|
455
|
+
};
|
456
|
+
|
457
|
+
var onLoad = function onLoad() {
|
458
|
+
attach();
|
459
|
+
bindListeners();
|
460
|
+
document.removeEventListener('DOMContentLoaded', onLoad);
|
461
|
+
};
|
462
|
+
|
463
|
+
document.addEventListener('DOMContentLoaded', onLoad);
|
464
|
+
|
465
|
+
window.van11yAccessibleTabPanelAria = attach;
|
466
|
+
})(document);
|
@@ -255,6 +255,8 @@ $sibu-color3 : #333 !default;
|
|
255
255
|
#sections_panel {
|
256
256
|
.sibu_sections {
|
257
257
|
padding: 2rem;
|
258
|
+
max-height: 60vh;
|
259
|
+
overflow-y: scroll;
|
258
260
|
|
259
261
|
> div {
|
260
262
|
> * {
|
@@ -277,6 +279,51 @@ $sibu-color3 : #333 !default;
|
|
277
279
|
}
|
278
280
|
}
|
279
281
|
}
|
282
|
+
|
283
|
+
.tabs__list {
|
284
|
+
margin: 0;
|
285
|
+
padding: 0;
|
286
|
+
}
|
287
|
+
.tabs__item {
|
288
|
+
display: inline-block;
|
289
|
+
> a {
|
290
|
+
text-decoration: none;
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
.tabs__link {
|
295
|
+
display: inline-block;
|
296
|
+
cursor: pointer;
|
297
|
+
margin-bottom: -2px;
|
298
|
+
padding: 1rem 2.5rem;
|
299
|
+
border-bottom: 4px solid transparent;
|
300
|
+
color: $sibu-color1;
|
301
|
+
text-decoration: none;
|
302
|
+
border-radius: 0 0 0 0;
|
303
|
+
transition: .25s;
|
304
|
+
transition-property: color, border, background-color;
|
305
|
+
font-size: 2rem;
|
306
|
+
&:focus {
|
307
|
+
border-bottom-color: $sibu-color2;
|
308
|
+
color: $sibu-color2;
|
309
|
+
outline: 0;
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
[aria-selected="true"].tabs__link {
|
314
|
+
border-bottom-color: $sibu-color2;
|
315
|
+
color: $sibu-color2;
|
316
|
+
outline: 0;
|
317
|
+
}
|
318
|
+
|
319
|
+
.tabs__content {
|
320
|
+
padding: 3rem 2rem;
|
321
|
+
background-color: white;
|
322
|
+
}
|
323
|
+
|
324
|
+
[aria-hidden="true"].tabs__content {
|
325
|
+
display: none;
|
326
|
+
}
|
280
327
|
}
|
281
328
|
|
282
329
|
.sibu_actions {
|
@@ -131,7 +131,7 @@ module Sibu
|
|
131
131
|
@after = params[:after]
|
132
132
|
@links = @site.pages_path_by_id
|
133
133
|
|
134
|
-
@site.site_template.
|
134
|
+
@site.site_template.available_sections.each do |t|
|
135
135
|
template_defaults = @site.site_template.templates ? (@site.site_template.templates[t["template"]] || {}) : {}
|
136
136
|
@page.sections << template_defaults.merge(t).to_h
|
137
137
|
end
|
data/app/models/sibu/site.rb
CHANGED
@@ -9,9 +9,14 @@ module Sibu
|
|
9
9
|
name.parameterize.gsub('-', '_')
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
12
|
+
def available_sections(path_prefix = 'app/views/shared')
|
13
|
+
sections_list = []
|
14
|
+
Dir.glob(File.join(Rails.root, "#{path_prefix}/#{path}/*/")).each do |dir|
|
15
|
+
cat = dir.split('/').last
|
16
|
+
sections_list += Dir.glob(dir + "*.erb").map {|f| f.split('/').last}.
|
17
|
+
map {|f| f[1..-1].gsub('.html.erb', '')}.map {|f| {"id" => "sibu_template_#{f}", "category" => cat, "template" => f}}
|
18
|
+
end
|
19
|
+
sections_list
|
15
20
|
end
|
16
21
|
end
|
17
22
|
end
|
@@ -90,6 +90,13 @@
|
|
90
90
|
|
91
91
|
function newSection(isAfter) {
|
92
92
|
var section = $(".sb-editing").first();
|
93
|
+
var sectionsPanel = $("#sections_panel");
|
94
|
+
sectionsPanel.html(
|
95
|
+
'<div class="sibu_panel sibu_view"><h2>Choix du type de section</h2></div>' +
|
96
|
+
'<div><div class="sibu_sections sibu_site_content" style="text-align: center;">Chargement en cours...</div></div>' +
|
97
|
+
'<div class="sibu_panel sibu_view"><div class="sibu_actions"><a href="#" onclick="cancelSectionsEdit(); return false;">Annuler</a></div></div>'
|
98
|
+
);
|
99
|
+
sectionsPanel.slideDown("fast");
|
93
100
|
$.ajax({
|
94
101
|
url: "<%= new_section_site_page_path(@site.id, @page.id) %>",
|
95
102
|
method: "GET",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
<p>Veuillez sélectionner une image.</p>
|
21
21
|
<% end %>
|
22
22
|
<div class="sibu_custom_center" style="display: <%= (@element["src"] == DEFAULT_IMG || @element["src"].blank?) ? 'none' : 'block' %>">
|
23
|
-
<%= check_box_tag('custom_center', true, !@element["class"].blank
|
23
|
+
<%= check_box_tag('custom_center', true, (!@element["class"].blank? && @element["class"].include?('posx')), id: 'custom_center', class: 'checkbox') %>
|
24
24
|
<%= label_tag 'custom_center', "Recentrer l'image" %>
|
25
25
|
</div>
|
26
26
|
<div class="sibu_center">
|
@@ -4,16 +4,32 @@
|
|
4
4
|
</div>
|
5
5
|
<div>
|
6
6
|
<div class="sibu_sections sibu_site_content">
|
7
|
-
<div id="<%= "#{@site.site_template.reference}_sections" %>">
|
8
|
-
<% sections_templates.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
<div id="<%= "#{@site.site_template.reference}_sections" %>" class="sibu_sections_tabs">
|
8
|
+
<% sections_by_category = sections_templates.group_by {|st| st['category']} %>
|
9
|
+
<div class="js-tabs">
|
10
|
+
<ul class="js-tablist" data-existing-hx="h3">
|
11
|
+
<% sections_by_category.keys.each do |cat| %>
|
12
|
+
<li class="js-tablist__item">
|
13
|
+
<a href="#<%= cat %>" class="js-tablist__link" data-selected="1"><%= t "sibu.section.category.#{cat}" %></a>
|
14
|
+
</li>
|
15
|
+
<% end %>
|
16
|
+
</ul>
|
17
|
+
<% sections_by_category.each_pair do |cat, sections| %>
|
18
|
+
<div id="<%= cat %>" class="js-tabcontent">
|
19
|
+
<h3 style="display: none;"><%= t "sibu.section.category.#{cat}" %></h3>
|
20
|
+
<% sections.each do |st| %>
|
21
|
+
<div data-sb-template="<%= st["template"] %>" data-sb-category="<%= st["category"] %>">
|
22
|
+
<%= render "shared/#{@site.section_template(st)}", sec: st %>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
13
28
|
</div>
|
14
29
|
</div>
|
15
30
|
<%= form_tag(create_section_site_page_path(@site.id, @page.id), method: :post, remote: true) do |f| %>
|
16
31
|
<%= hidden_field_tag 'section[template]', '' %>
|
32
|
+
<%= hidden_field_tag 'section[category]', '' %>
|
17
33
|
<%= hidden_field_tag :section_id, @section_id %>
|
18
34
|
<%= hidden_field_tag :after, @after%>
|
19
35
|
<%= hidden_field_tag :entity, @entity_type %>
|
@@ -46,29 +46,29 @@ editPanel.slideDown("fast", function() {
|
|
46
46
|
$(this).addClass('selected');
|
47
47
|
$("#element_src").val($(this).data("src"));
|
48
48
|
$("#element_alt").val($(this).data("alt"));
|
49
|
-
editPanel.find(".sibu_center").html('<img src="' + $("#element_src").val() + '"
|
49
|
+
editPanel.find(".sibu_center").html('<img src="' + $("#element_src").val() + '"/><div id="sibu_center_pos" style="display: none;">✕</div>');
|
50
50
|
editPanel.find(".sibu_selected_image > p:first-child").hide();
|
51
51
|
editPanel.find(".sibu_selected_image").find(".sibu_custom_center").show();
|
52
52
|
editPanel.find(".sibu_selected_image").find(".sibu_field").show();
|
53
53
|
if(customCenter.is(":checked")) {
|
54
|
-
|
54
|
+
customCenter.removeAttr("checked");
|
55
|
+
$("#element_class").val("");
|
56
|
+
$(".sibu_center").attr("style", "");
|
55
57
|
}
|
56
58
|
}
|
57
59
|
});
|
58
60
|
if(editPanel.find(".sibu_center img").size() > 0) {
|
59
61
|
if(customCenter.is(":checked")) {
|
60
|
-
|
62
|
+
initCustomCenter("<%= @element_id %>");
|
61
63
|
}
|
62
64
|
}
|
63
65
|
customCenter.change(function() {
|
64
66
|
if($(this).is(":checked")) {
|
65
|
-
|
67
|
+
initCustomCenter("<%= @element_id %>");
|
66
68
|
} else {
|
67
|
-
$("#
|
69
|
+
$("#element_class").val("");
|
68
70
|
$(".sibu_center").attr("style", "");
|
69
|
-
|
70
|
-
// cropper.destroy();
|
71
|
-
// }
|
71
|
+
$(".sibu_center > #sibu_center_pos").hide();
|
72
72
|
}
|
73
73
|
});
|
74
74
|
<% when 'link' %>
|
@@ -1,18 +1,19 @@
|
|
1
1
|
var sectionsPanel = $("#sections_panel");
|
2
|
-
sectionsPanel.
|
3
|
-
sectionsPanel.html("<%= j(render 'new_section_panel') %>");
|
4
|
-
|
5
|
-
sections.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
if (sectionsPanel.size()) {
|
3
|
+
sectionsPanel.html("<%= j(render 'new_section_panel') %>");
|
4
|
+
van11yAccessibleTabPanelAria($(".sibu_sections_tabs")[0]);
|
5
|
+
var sections = sectionsPanel.find(".sibu_sections [data-sb-template]");
|
6
|
+
sections.click(function() {
|
7
|
+
if(!$(this).hasClass('selected')) {
|
8
|
+
sections.removeClass('selected');
|
9
|
+
$(this).addClass('selected');
|
10
|
+
$("#section_template").val($(this).data("sb-template"));
|
11
|
+
$("#section_category").val($(this).data("sb-category"));
|
12
|
+
}
|
13
|
+
});
|
13
14
|
if(typeof initSectionsForm === "function") {
|
14
15
|
initSectionsForm();
|
15
16
|
}
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
document.body.style.overflow = "hidden";
|
18
|
+
sibuCallback("newSection");
|
19
|
+
}
|
data/lib/sibu/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sibu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Baptiste Vilain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- app/assets/javascripts/quill/quill.js
|
130
130
|
- app/assets/javascripts/sibu/common.js
|
131
131
|
- app/assets/javascripts/sibu/sibu.js.erb
|
132
|
+
- app/assets/javascripts/tabs/van11y-accessible-tab-panel-aria.js
|
132
133
|
- app/assets/stylesheets/cropper/cropper.css
|
133
134
|
- app/assets/stylesheets/quill/quill.snow.css
|
134
135
|
- app/assets/stylesheets/sibu/defaults.scss
|