alchemy-widget 0.1.6 → 0.2.0
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.
- package/CHANGELOG.md +9 -0
- package/assets/stylesheets/{alchemy-widgets.scss → alchemy_widgets.scss} +158 -48
- package/bootstrap.js +4 -2
- package/element/00-widget_base_element.js +96 -4
- package/element/05-widget_element.js +4 -13
- package/element/10-container_elements.js +15 -15
- package/element/11-alchemy_widgets_list_element.js +2 -2
- package/element/20-add_area_element.js +22 -22
- package/element/table_of_contents_element.js +104 -8
- package/element/widget_actionbar_element.js +92 -0
- package/element/widget_context_element.js +39 -23
- package/element/widget_toolbar_element.js +295 -50
- package/helper/widget_action.js +10 -10
- package/helper/widgets/00-widget.js +54 -18
- package/helper/widgets/01-container.js +7 -7
- package/helper/widgets/05-list.js +1 -1
- package/helper/widgets/alchemy_field_widget.js +112 -0
- package/helper/widgets/alchemy_form_widget.js +183 -0
- package/helper/widgets/alchemy_table_widget.js +71 -0
- package/helper/widgets/alchemy_tabs_widget.js +195 -0
- package/helper/widgets/header.js +3 -3
- package/helper/widgets/markdown.js +17 -10
- package/helper/widgets/sourcecode.js +4 -4
- package/helper/widgets/table_of_contents.js +2 -2
- package/helper/widgets_helper.js +26 -0
- package/package.json +3 -2
- package/view/elements/table_of_contents.hwk +23 -9
- package/view/form/inputs/edit/widget.hwk +2 -2
- package/view/form/inputs/edit/widgets.hwk +2 -2
- package/view/widget/elements/al_widget_toolbar.hwk +49 -0
- package/view/widget/widget_config.hwk +7 -4
- package/assets/stylesheets/alchemy-widget-symbols.scss +0 -191
|
@@ -1,92 +1,337 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
2
|
+
* The al-widget-toolbar element
|
|
3
3
|
*
|
|
4
4
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
5
|
-
* @since 0.
|
|
6
|
-
* @version 0.
|
|
5
|
+
* @since 0.2.0
|
|
6
|
+
* @version 0.2.0
|
|
7
7
|
*/
|
|
8
|
-
let Toolbar = Function.inherits('Alchemy.Element.
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
let Toolbar = Function.inherits('Alchemy.Element.Form.Stateful', 'Alchemy.Element.Widget', 'WidgetToolbar');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The stylesheet to load for this element
|
|
12
|
+
*
|
|
13
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
14
|
+
* @since 0.2.0
|
|
15
|
+
* @version 0.2.0
|
|
16
|
+
*/
|
|
17
|
+
Toolbar.setStylesheetFile('alchemy_widgets');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Set the custom element prefix
|
|
21
|
+
*
|
|
22
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
23
|
+
* @since 0.2.0
|
|
24
|
+
* @version 0.2.0
|
|
25
|
+
*/
|
|
26
|
+
Toolbar.setStatic('custom_element_prefix', 'al');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The template to use for the content of this element
|
|
30
|
+
*
|
|
31
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
32
|
+
* @since 0.2.0
|
|
33
|
+
* @version 0.2.0
|
|
34
|
+
*/
|
|
35
|
+
Toolbar.setTemplateFile('widget/elements/al_widget_toolbar');
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The start-edit button
|
|
39
|
+
*
|
|
40
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
41
|
+
* @since 0.2.0
|
|
42
|
+
* @version 0.2.0
|
|
43
|
+
*/
|
|
44
|
+
Toolbar.addElementGetter('button_start', 'al-button.start-edit');
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The stop-edit button
|
|
48
|
+
*
|
|
49
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
50
|
+
* @since 0.2.0
|
|
51
|
+
* @version 0.2.0
|
|
52
|
+
*/
|
|
53
|
+
Toolbar.addElementGetter('button_stop', 'al-button.stop-edit');
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The stop-and-save button
|
|
57
|
+
*
|
|
58
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
59
|
+
* @since 0.2.0
|
|
60
|
+
* @version 0.2.0
|
|
61
|
+
*/
|
|
62
|
+
Toolbar.addElementGetter('button_stop_and_save', 'al-button.stop-and-save');
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The save-all button
|
|
66
|
+
*
|
|
67
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
68
|
+
* @since 0.2.0
|
|
69
|
+
* @version 0.2.0
|
|
70
|
+
*/
|
|
71
|
+
Toolbar.addElementGetter('button_save_all', 'al-button.save-all');
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Make sure the toolbar is visible
|
|
75
|
+
*
|
|
76
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
77
|
+
* @since 0.2.0
|
|
78
|
+
* @version 0.2.0
|
|
79
|
+
*/
|
|
80
|
+
Toolbar.setStatic(function show() {
|
|
81
|
+
|
|
82
|
+
if (!alchemy.hasPermission('alchemy.widgets.toolbar')) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let toolbar = document.querySelector('al-widget-toolbar');
|
|
87
|
+
|
|
88
|
+
if (toolbar) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
toolbar = hawkejs.createElement('al-widget-toolbar');
|
|
93
|
+
|
|
94
|
+
hawkejs.scene.bottom_element.append(toolbar);
|
|
11
95
|
});
|
|
12
96
|
|
|
13
97
|
/**
|
|
14
|
-
*
|
|
98
|
+
* Get all the root widgets
|
|
15
99
|
*
|
|
16
100
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
17
|
-
* @since 0.
|
|
18
|
-
* @version 0.
|
|
101
|
+
* @since 0.2.0
|
|
102
|
+
* @version 0.2.0
|
|
103
|
+
*/
|
|
104
|
+
Toolbar.setMethod(function getAllRootWidgets() {
|
|
105
|
+
|
|
106
|
+
let elements = document.body.queryAllNotNested('al-widgets'),
|
|
107
|
+
result = [],
|
|
108
|
+
i;
|
|
109
|
+
|
|
110
|
+
for (i = 0; i < elements.length; i++) {
|
|
111
|
+
result.push(elements[i]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
elements = document.body.queryAllNotNested('al-widget');
|
|
115
|
+
|
|
116
|
+
for (i = 0; i < elements.length; i++) {
|
|
117
|
+
|
|
118
|
+
if (elements[i].is_root_widget) {
|
|
119
|
+
result.push(elements[i]);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return result;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Start editing all the widgets
|
|
19
128
|
*
|
|
20
|
-
* @
|
|
129
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
130
|
+
* @since 0.2.0
|
|
131
|
+
* @version 0.2.0
|
|
21
132
|
*/
|
|
22
|
-
Toolbar.setMethod(function
|
|
133
|
+
Toolbar.setMethod(function startEditing() {
|
|
23
134
|
|
|
24
|
-
|
|
135
|
+
let i;
|
|
136
|
+
|
|
137
|
+
Blast.editing = true;
|
|
138
|
+
document.body.classList.add('editing-blocks');
|
|
139
|
+
|
|
140
|
+
let elements = this.getAllRootWidgets();
|
|
141
|
+
|
|
142
|
+
for (i = 0; i < elements.length; i++) {
|
|
143
|
+
elements[i].startEditor();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
this.setState('editing');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Stop editing all the widgets
|
|
151
|
+
*
|
|
152
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
153
|
+
* @since 0.2.0
|
|
154
|
+
* @version 0.2.0
|
|
155
|
+
*/
|
|
156
|
+
Toolbar.setMethod(function stopEditing() {
|
|
157
|
+
|
|
158
|
+
if (!Blast.editing) {
|
|
25
159
|
return;
|
|
26
160
|
}
|
|
27
161
|
|
|
28
|
-
|
|
162
|
+
let i;
|
|
29
163
|
|
|
30
|
-
|
|
164
|
+
Blast.editing = false;
|
|
165
|
+
document.body.classList.remove('editing-blocks');
|
|
31
166
|
|
|
32
|
-
|
|
33
|
-
Hawkejs.removeChildren(this);
|
|
167
|
+
let elements = this.getAllRootWidgets();
|
|
34
168
|
|
|
35
|
-
for (
|
|
169
|
+
for (i = 0; i < elements.length; i++) {
|
|
170
|
+
elements[i].stopEditor();
|
|
171
|
+
}
|
|
36
172
|
|
|
37
|
-
|
|
38
|
-
|
|
173
|
+
this.setState('ready');
|
|
174
|
+
});
|
|
39
175
|
|
|
40
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Save all the widgets
|
|
178
|
+
*
|
|
179
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
180
|
+
* @since 0.2.0
|
|
181
|
+
* @version 0.2.0
|
|
182
|
+
*/
|
|
183
|
+
Toolbar.setMethod(async function saveAll() {
|
|
41
184
|
|
|
42
|
-
|
|
43
|
-
|
|
185
|
+
if (this._saving) {
|
|
186
|
+
try {
|
|
187
|
+
await this._saving;
|
|
188
|
+
} catch (err) {
|
|
189
|
+
// Ignore;
|
|
44
190
|
}
|
|
191
|
+
}
|
|
45
192
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
193
|
+
this._saving = null;
|
|
194
|
+
|
|
195
|
+
let elements = this.getAllRootWidgets();
|
|
196
|
+
let widget_data = [];
|
|
197
|
+
let pledge;
|
|
198
|
+
|
|
199
|
+
for (let element of elements) {
|
|
200
|
+
let entry = element.gatherSaveData();
|
|
201
|
+
|
|
202
|
+
if (entry) {
|
|
203
|
+
widget_data.push(entry);
|
|
56
204
|
}
|
|
205
|
+
}
|
|
57
206
|
|
|
58
|
-
|
|
207
|
+
if (widget_data.length) {
|
|
208
|
+
let config = {
|
|
209
|
+
href : alchemy.routeUrl('AlchemyWidgets#save'),
|
|
210
|
+
post : {
|
|
211
|
+
widgets: widget_data
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
pledge = alchemy.fetch(config);
|
|
216
|
+
this._saving = pledge;
|
|
217
|
+
}
|
|
59
218
|
|
|
60
|
-
|
|
219
|
+
return pledge;
|
|
220
|
+
});
|
|
61
221
|
|
|
62
|
-
|
|
63
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Save all and update the states
|
|
224
|
+
*
|
|
225
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
226
|
+
* @since 0.2.0
|
|
227
|
+
* @version 0.2.0
|
|
228
|
+
*
|
|
229
|
+
* @param {Boolean} before_stop
|
|
230
|
+
*/
|
|
231
|
+
Toolbar.setMethod(async function saveAllAndUpdateButtonStates(before_stop) {
|
|
232
|
+
|
|
233
|
+
let state = 'saving',
|
|
234
|
+
button;
|
|
235
|
+
|
|
236
|
+
if (before_stop) {
|
|
237
|
+
button = this.button_stop_and_save;
|
|
238
|
+
state += '-before-stop';
|
|
239
|
+
} else {
|
|
240
|
+
button = this.button_save_all;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
this.setState(state);
|
|
244
|
+
button.setState(state);
|
|
245
|
+
|
|
246
|
+
let save_error = null;
|
|
247
|
+
|
|
248
|
+
let restore_toolbar_state = this.wrapForCurrentState(() => {
|
|
249
|
+
if (save_error) {
|
|
250
|
+
this.setState('error');
|
|
251
|
+
} else {
|
|
252
|
+
this.setState('editing')
|
|
64
253
|
}
|
|
254
|
+
});
|
|
65
255
|
|
|
66
|
-
|
|
256
|
+
let restore_button_state = button.wrapForCurrentState(() => {
|
|
67
257
|
|
|
68
|
-
|
|
258
|
+
if (save_error) {
|
|
259
|
+
button.setState('error');
|
|
260
|
+
} else {
|
|
261
|
+
button.setState('saved', 2500, 'ready');
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
try {
|
|
266
|
+
await this.saveAll();
|
|
267
|
+
} catch (err) {
|
|
268
|
+
save_error = err;
|
|
269
|
+
}
|
|
69
270
|
|
|
70
|
-
|
|
71
|
-
|
|
271
|
+
restore_toolbar_state();
|
|
272
|
+
restore_button_state();
|
|
72
273
|
|
|
73
|
-
|
|
274
|
+
if (save_error) {
|
|
275
|
+
return false;
|
|
74
276
|
}
|
|
277
|
+
|
|
278
|
+
return true;
|
|
75
279
|
});
|
|
76
280
|
|
|
77
281
|
/**
|
|
78
|
-
*
|
|
282
|
+
* This element has been added to the DOM for the first time
|
|
79
283
|
*
|
|
80
284
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
81
|
-
* @since 0.
|
|
82
|
-
* @version 0.
|
|
285
|
+
* @since 0.2.0
|
|
286
|
+
* @version 0.2.0
|
|
83
287
|
*/
|
|
84
|
-
Toolbar.setMethod(function
|
|
85
|
-
this.hidden = true;
|
|
288
|
+
Toolbar.setMethod(function introduced() {
|
|
86
289
|
|
|
87
|
-
|
|
88
|
-
this.
|
|
89
|
-
}
|
|
290
|
+
this.button_start.addEventListener('activate', async e => {
|
|
291
|
+
this.startEditing();
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
this.button_stop.addEventListener('activate', async e => {
|
|
295
|
+
this.stopEditing();
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
this.button_save_all.addEventListener('activate', e => {
|
|
299
|
+
this.saveAllAndUpdateButtonStates(false);
|
|
300
|
+
});
|
|
90
301
|
|
|
91
|
-
this.
|
|
302
|
+
this.button_stop_and_save.addEventListener('activate', async e => {
|
|
303
|
+
let saved = await this.saveAllAndUpdateButtonStates(true);
|
|
304
|
+
|
|
305
|
+
if (saved) {
|
|
306
|
+
this.stopEditing();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
hawkejs.scene.on('opening_url', e => {
|
|
311
|
+
this.stopEditing();
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* The element has been added to the dom
|
|
317
|
+
*
|
|
318
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
319
|
+
* @since 0.2.0
|
|
320
|
+
* @version 0.2.0
|
|
321
|
+
*/
|
|
322
|
+
Toolbar.setMethod(function connected() {
|
|
323
|
+
let html = document.querySelector('html');
|
|
324
|
+
html.classList.add('with-al-widget-toolbar');
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* The element has been removed from the dom
|
|
329
|
+
*
|
|
330
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
331
|
+
* @since 0.2.0
|
|
332
|
+
* @version 0.2.0
|
|
333
|
+
*/
|
|
334
|
+
Toolbar.setMethod(function disconnected() {
|
|
335
|
+
let html = document.querySelector('html');
|
|
336
|
+
html.classList.remove('with-al-widget-toolbar');
|
|
92
337
|
});
|
package/helper/widget_action.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
7
7
|
* @since 0.1.0
|
|
8
|
-
* @version 0.
|
|
8
|
+
* @version 0.2.0
|
|
9
9
|
*
|
|
10
10
|
* @param {String} name
|
|
11
11
|
*/
|
|
@@ -29,8 +29,8 @@ const Action = Function.inherits('Alchemy.Base', 'Alchemy.Widget', function Acti
|
|
|
29
29
|
// The icon to use for this action
|
|
30
30
|
this.icon = null;
|
|
31
31
|
|
|
32
|
-
// Close the
|
|
33
|
-
this.
|
|
32
|
+
// Close the actionbar after clicking?
|
|
33
|
+
this.close_actionbar = false;
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -90,11 +90,11 @@ Action.setMethod(function setIcon(icon) {
|
|
|
90
90
|
*
|
|
91
91
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
92
92
|
* @since 0.1.0
|
|
93
|
-
* @version 0.
|
|
93
|
+
* @version 0.2.0
|
|
94
94
|
*
|
|
95
95
|
* @param {HTMLElement} widget
|
|
96
96
|
*/
|
|
97
|
-
Action.setMethod(function applyOnWidget(widget,
|
|
97
|
+
Action.setMethod(function applyOnWidget(widget, actionbar) {
|
|
98
98
|
|
|
99
99
|
if (!this.handler) {
|
|
100
100
|
throw new Error('Failed to apply action "' + this.name + '" on widget, no handler found');
|
|
@@ -103,10 +103,10 @@ Action.setMethod(function applyOnWidget(widget, toolbar) {
|
|
|
103
103
|
let instance = widget.instance,
|
|
104
104
|
handle = instance.getHandle();
|
|
105
105
|
|
|
106
|
-
this.handler(widget, handle,
|
|
106
|
+
this.handler(widget, handle, actionbar);
|
|
107
107
|
|
|
108
|
-
if (this.
|
|
109
|
-
|
|
108
|
+
if (this.close_actionbar) {
|
|
109
|
+
actionbar.close();
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
|
|
@@ -119,7 +119,7 @@ Action.setMethod(function applyOnWidget(widget, toolbar) {
|
|
|
119
119
|
*
|
|
120
120
|
* @param {HTMLElement} widget
|
|
121
121
|
*
|
|
122
|
-
* @return {Boolean}
|
|
122
|
+
* @return {Boolean|Promise}
|
|
123
123
|
*/
|
|
124
124
|
Action.setMethod(function test(widget) {
|
|
125
125
|
|
|
@@ -154,7 +154,7 @@ Action.setMethod(function getButtonContent() {
|
|
|
154
154
|
let icon = this.icon;
|
|
155
155
|
|
|
156
156
|
if (typeof icon == 'string') {
|
|
157
|
-
result = Blast.Classes.Hawkejs.Hawkejs.createElement('al-
|
|
157
|
+
result = Blast.Classes.Hawkejs.Hawkejs.createElement('al-icon');
|
|
158
158
|
result.setIcon(icon);
|
|
159
159
|
} else if (icon.html) {
|
|
160
160
|
result = Blast.Classes.Hawkejs.parseHTML(icon.html);
|
|
@@ -101,7 +101,7 @@ Widget.enforceProperty(function hawkejs_renderer(new_value) {
|
|
|
101
101
|
*
|
|
102
102
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
103
103
|
* @since 0.1.0
|
|
104
|
-
* @version 0.
|
|
104
|
+
* @version 0.2.0
|
|
105
105
|
*/
|
|
106
106
|
Widget.constitute(function prepareSchema() {
|
|
107
107
|
|
|
@@ -114,7 +114,7 @@ Widget.constitute(function prepareSchema() {
|
|
|
114
114
|
// Extra classnames for the wrapper
|
|
115
115
|
this.schema.addField('wrapper_class_names', 'String', {
|
|
116
116
|
title : 'Wrapper CSS classes',
|
|
117
|
-
description : 'Configure extra CSS classes to the wrapper `
|
|
117
|
+
description : 'Configure extra CSS classes to the wrapper `al-widget` element',
|
|
118
118
|
array: true,
|
|
119
119
|
widget_config_editable: true,
|
|
120
120
|
});
|
|
@@ -126,6 +126,34 @@ Widget.constitute(function prepareSchema() {
|
|
|
126
126
|
array: true,
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
+
// Add the "copy to clipboard" action
|
|
130
|
+
let copy = this.createAction('copy', 'Copy to clipboard');
|
|
131
|
+
|
|
132
|
+
copy.setHandler(function copyAction(widget_el, handle) {
|
|
133
|
+
return widget_el.copyConfigToClipboard();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
copy.setTester(function copyAction(widget_el, handle) {
|
|
137
|
+
return true;
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
copy.setIcon('clipboard');
|
|
141
|
+
copy.close_actionbar = true;
|
|
142
|
+
|
|
143
|
+
// Add the "paste from clipboard" action
|
|
144
|
+
let paste = this.createAction('paste', 'Replace from clipboard');
|
|
145
|
+
|
|
146
|
+
paste.setHandler(function pasteAction(widget_el, handle) {
|
|
147
|
+
return widget_el.pasteConfigFromClipboard();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
paste.setTester(function pasteAction(widget_el, handle) {
|
|
151
|
+
return widget_el.getConfigFromClipboard();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
paste.setIcon('paste');
|
|
155
|
+
paste.close_actionbar = true;
|
|
156
|
+
|
|
129
157
|
// Add the "save" action
|
|
130
158
|
let save = this.createAction('save', 'Save');
|
|
131
159
|
|
|
@@ -142,7 +170,7 @@ Widget.constitute(function prepareSchema() {
|
|
|
142
170
|
// Add the remove action
|
|
143
171
|
let remove = this.createAction('remove', 'Remove');
|
|
144
172
|
|
|
145
|
-
remove.
|
|
173
|
+
remove.close_actionbar = true;
|
|
146
174
|
|
|
147
175
|
remove.setHandler(function removeAction(widget_el, handle) {
|
|
148
176
|
handle.remove();
|
|
@@ -157,7 +185,7 @@ Widget.constitute(function prepareSchema() {
|
|
|
157
185
|
// Add the config action
|
|
158
186
|
let config = this.createAction('config', 'Config');
|
|
159
187
|
|
|
160
|
-
config.
|
|
188
|
+
config.close_actionbar = true;
|
|
161
189
|
config.setIcon('gears');
|
|
162
190
|
|
|
163
191
|
config.setHandler(function configAction(widget_el, handle) {
|
|
@@ -167,7 +195,7 @@ Widget.constitute(function prepareSchema() {
|
|
|
167
195
|
// The move-left action
|
|
168
196
|
let move_left = this.createAction('move-left', 'Move left');
|
|
169
197
|
|
|
170
|
-
move_left.
|
|
198
|
+
move_left.close_actionbar = true;
|
|
171
199
|
|
|
172
200
|
move_left.setHandler(function moveLeftAction(widget_el, handle) {
|
|
173
201
|
// Hawkejs custom element method!
|
|
@@ -187,7 +215,7 @@ Widget.constitute(function prepareSchema() {
|
|
|
187
215
|
|
|
188
216
|
let move_right = this.createAction('move-right', 'Move right');
|
|
189
217
|
|
|
190
|
-
move_right.
|
|
218
|
+
move_right.close_actionbar = true;
|
|
191
219
|
|
|
192
220
|
move_right.setHandler(function moveRightAction(widget_el, handle) {
|
|
193
221
|
// Hawkejs custom element method!
|
|
@@ -202,7 +230,7 @@ Widget.constitute(function prepareSchema() {
|
|
|
202
230
|
|
|
203
231
|
let next = handle.nextElementSibling;
|
|
204
232
|
|
|
205
|
-
if (!next || next.tagName == '
|
|
233
|
+
if (!next || next.tagName == 'AL-WIDGET-ADD-AREA') {
|
|
206
234
|
return false;
|
|
207
235
|
}
|
|
208
236
|
|
|
@@ -214,7 +242,7 @@ Widget.constitute(function prepareSchema() {
|
|
|
214
242
|
// The move-in-left action
|
|
215
243
|
let move_in_left = this.createAction('move-in-left', 'Move in left');
|
|
216
244
|
|
|
217
|
-
move_in_left.
|
|
245
|
+
move_in_left.close_actionbar = true;
|
|
218
246
|
|
|
219
247
|
move_in_left.setHandler(function moveLeftAction(widget_el, handle) {
|
|
220
248
|
// Hawkejs custom element method!
|
|
@@ -239,7 +267,7 @@ Widget.constitute(function prepareSchema() {
|
|
|
239
267
|
// The move-in-right action
|
|
240
268
|
let move_in_right = this.createAction('move-in-right', 'Move in right');
|
|
241
269
|
|
|
242
|
-
move_in_right.
|
|
270
|
+
move_in_right.close_actionbar = true;
|
|
243
271
|
|
|
244
272
|
move_in_right.setHandler(function moveRightAction(widget_el, handle) {
|
|
245
273
|
// Hawkejs custom element method!
|
|
@@ -421,22 +449,29 @@ Widget.setMethod(function toDry() {
|
|
|
421
449
|
});
|
|
422
450
|
|
|
423
451
|
/**
|
|
424
|
-
* Get an array of
|
|
452
|
+
* Get an array of actionbar actions
|
|
425
453
|
*
|
|
426
454
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
427
455
|
* @since 0.1.0
|
|
428
|
-
* @version 0.
|
|
456
|
+
* @version 0.2.0
|
|
429
457
|
*
|
|
430
458
|
* @return {Array}
|
|
431
459
|
*/
|
|
432
|
-
Widget.setMethod(function
|
|
460
|
+
Widget.setMethod(async function getActionbarActions() {
|
|
433
461
|
|
|
434
462
|
let sorted = this.constructor.actions.getSorted(),
|
|
435
463
|
result = [],
|
|
436
464
|
action;
|
|
437
465
|
|
|
438
466
|
for (action of sorted) {
|
|
439
|
-
|
|
467
|
+
|
|
468
|
+
let tester = action.test(this.widget);
|
|
469
|
+
|
|
470
|
+
if (Pledge.isThenable(tester)) {
|
|
471
|
+
tester = await tester;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
if (tester) {
|
|
440
475
|
result.push(action);
|
|
441
476
|
}
|
|
442
477
|
}
|
|
@@ -476,17 +511,17 @@ Widget.setMethod(function createElement(tag_name) {
|
|
|
476
511
|
|
|
477
512
|
/**
|
|
478
513
|
* Create an instance of the HTML element representing this widget
|
|
479
|
-
* This will probably be just <
|
|
514
|
+
* This will probably be just <al-widget>
|
|
480
515
|
*
|
|
481
516
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
482
517
|
* @since 0.1.0
|
|
483
|
-
* @version 0.
|
|
518
|
+
* @version 0.2.0
|
|
484
519
|
*
|
|
485
520
|
* @return {HTMLElement}
|
|
486
521
|
*/
|
|
487
522
|
Widget.setMethod(function _createWidgetElement() {
|
|
488
523
|
|
|
489
|
-
let element = this.createElement('
|
|
524
|
+
let element = this.createElement('al-widget');
|
|
490
525
|
|
|
491
526
|
// Set the type of the widget to our type
|
|
492
527
|
element.type = this.constructor.type_name;
|
|
@@ -642,7 +677,7 @@ Widget.setMethod(function syncConfig() {
|
|
|
642
677
|
*
|
|
643
678
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
644
679
|
* @since 0.1.0
|
|
645
|
-
* @version 0.
|
|
680
|
+
* @version 0.2.0
|
|
646
681
|
*/
|
|
647
682
|
Widget.setMethod(async function showConfig(fields) {
|
|
648
683
|
|
|
@@ -675,6 +710,7 @@ Widget.setMethod(async function showConfig(fields) {
|
|
|
675
710
|
let widget_settings = Object.assign({}, this.syncConfig());
|
|
676
711
|
|
|
677
712
|
let variables = {
|
|
713
|
+
title : this.constructor.title,
|
|
678
714
|
schema : this.schema,
|
|
679
715
|
widget_settings,
|
|
680
716
|
fields : fields
|
|
@@ -697,7 +733,7 @@ Widget.setMethod(async function showConfig(fields) {
|
|
|
697
733
|
button.addEventListener('click', e => {
|
|
698
734
|
e.preventDefault();
|
|
699
735
|
|
|
700
|
-
let form = dialog.querySelector('
|
|
736
|
+
let form = dialog.querySelector('al-form');
|
|
701
737
|
|
|
702
738
|
Object.assign(this.config, form.value);
|
|
703
739
|
|
|
@@ -51,13 +51,13 @@ Container.setMethod(function initContainer() {
|
|
|
51
51
|
*
|
|
52
52
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
53
53
|
* @since 0.1.0
|
|
54
|
-
* @version 0.
|
|
54
|
+
* @version 0.2.0
|
|
55
55
|
*
|
|
56
56
|
* @return {HTMLElement}
|
|
57
57
|
*/
|
|
58
58
|
Container.setMethod(function _createWidgetElement() {
|
|
59
59
|
|
|
60
|
-
let tag_name = '
|
|
60
|
+
let tag_name = 'al-widgets-' + this.constructor.type_name;
|
|
61
61
|
|
|
62
62
|
let element = this.createElement(tag_name);
|
|
63
63
|
|
|
@@ -72,14 +72,14 @@ Container.setMethod(function _createWidgetElement() {
|
|
|
72
72
|
*
|
|
73
73
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
74
74
|
* @since 0.1.0
|
|
75
|
-
* @version 0.
|
|
75
|
+
* @version 0.2.0
|
|
76
76
|
*/
|
|
77
77
|
Container.setMethod(function _startEditor() {
|
|
78
78
|
|
|
79
|
-
let add_area = this.widget.querySelector(':scope >
|
|
79
|
+
let add_area = this.widget.querySelector(':scope > al-widget-add-area');
|
|
80
80
|
|
|
81
81
|
if (!add_area) {
|
|
82
|
-
add_area = this.createElement('
|
|
82
|
+
add_area = this.createElement('al-widget-add-area');
|
|
83
83
|
this.widget.append(add_area);
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -100,11 +100,11 @@ Container.setMethod(function _startEditor() {
|
|
|
100
100
|
*
|
|
101
101
|
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
102
102
|
* @since 0.1.0
|
|
103
|
-
* @version 0.
|
|
103
|
+
* @version 0.2.0
|
|
104
104
|
*/
|
|
105
105
|
Container.setMethod(function _stopEditor() {
|
|
106
106
|
|
|
107
|
-
let add_area = this.widget.querySelector(':scope >
|
|
107
|
+
let add_area = this.widget.querySelector(':scope > al-widget-add-area');
|
|
108
108
|
|
|
109
109
|
if (add_area) {
|
|
110
110
|
add_area.remove();
|
|
@@ -22,7 +22,7 @@ List.setMethod(function initContainer() {
|
|
|
22
22
|
|
|
23
23
|
let ul = this.createElement('ul');
|
|
24
24
|
|
|
25
|
-
Classes.Alchemy.Element.Widget.
|
|
25
|
+
Classes.Alchemy.Element.Widget.AlWidgets.prototype._appendWidgetElement.call(this.widget, ul);
|
|
26
26
|
|
|
27
27
|
this.widget.list_element = ul;
|
|
28
28
|
|