alchemy-chimera 0.5.4 → 1.0.2
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 +39 -4
- package/assets/scripts/chimera/chimera.js +13 -288
- package/assets/stylesheets/chimera/chimera.scss +451 -0
- package/bootstrap.js +6 -302
- package/config/routes.js +53 -5
- package/controller/00-chimera_controller.js +16 -0
- package/controller/chimera_editor_controller.js +159 -614
- package/controller/chimera_static_controller.js +102 -9
- package/lib/chimera_config.js +138 -163
- package/model/model.js +1 -1
- package/package.json +8 -12
- package/view/chimera/dashboard.hwk +8 -0
- package/view/chimera/editor/index.hwk +20 -0
- package/view/chimera/sidebar.hwk +4 -0
- package/view/chimera/widgets.hwk +8 -0
- package/view/layouts/chimera_base.hwk +15 -0
- package/view/layouts/chimera_basics.hwk +15 -0
- package/view/layouts/chimera_body.hwk +24 -0
- package/assets/scripts/chimera/assoc_field.js +0 -311
- package/assets/scripts/chimera/boolean_field.js +0 -53
- package/assets/scripts/chimera/chimera_field.js +0 -622
- package/assets/scripts/chimera/chimera_field_wrapper.js +0 -558
- package/assets/scripts/chimera/date_field.js +0 -170
- package/assets/scripts/chimera/geopoint_field.js +0 -147
- package/assets/scripts/chimera/medium-button.js +0 -6
- package/assets/scripts/chimera/object_field.js +0 -51
- package/assets/scripts/chimera/page-editor.js +0 -3
- package/assets/scripts/chimera/password_field.js +0 -73
- package/assets/scripts/chimera/schema_field.js +0 -300
- package/assets/scripts/chimera/text_field.js +0 -119
- package/assets/scripts/rome/rome.js +0 -4978
- package/assets/scripts/vex/vex.dialog.js +0 -151
- package/assets/scripts/vex/vex.js +0 -193
- package/assets/stylesheets/chimera/chimera.less +0 -1075
- package/assets/stylesheets/chimera_old/chimera.less +0 -351
- package/assets/stylesheets/chimera_old/core.less +0 -315
- package/assets/stylesheets/chimera_old/font.less +0 -38
- package/assets/stylesheets/chimera_old/mixins.less +0 -35
- package/assets/stylesheets/chimera_old/page-editor.less +0 -23
- package/assets/stylesheets/rome/rome.less +0 -130
- package/assets/stylesheets/vex/vex-theme-bottom-right-corner.less +0 -613
- package/assets/stylesheets/vex/vex.default.less +0 -501
- package/assets/stylesheets/vex/vex.flat.less +0 -443
- package/assets/stylesheets/vex/vex.less +0 -320
- package/controller/chimera_page_controller.js +0 -14
- package/controller/chimera_settings_controller.js +0 -129
- package/controller/tasks_chimera_controller.js +0 -106
- package/helper/chimera_helper.js +0 -202
- package/lib/chimera_action_fields.js +0 -292
- package/lib/chimera_field/belongsto_chimera_field.js +0 -160
- package/lib/chimera_field/boolean_chimera_field.js +0 -19
- package/lib/chimera_field/date_chimera_field.js +0 -20
- package/lib/chimera_field/datetime_chimera_field.js +0 -20
- package/lib/chimera_field/enum_chimera_field.js +0 -131
- package/lib/chimera_field/geopoint_chimera_field.js +0 -20
- package/lib/chimera_field/habtm_chimera_field.js +0 -55
- package/lib/chimera_field/hasoneparent_chimera_field.js +0 -18
- package/lib/chimera_field/html_chimera_field.js +0 -20
- package/lib/chimera_field/object_chimera_field.js +0 -18
- package/lib/chimera_field/password_chimera_field.js +0 -18
- package/lib/chimera_field/schema_chimera_field.js +0 -149
- package/lib/chimera_field/text_chimera_field.js +0 -20
- package/lib/chimera_field/time_chimera_field.js +0 -18
- package/lib/chimera_field.js +0 -208
- package/model/setting_model.js +0 -51
- package/public/chimera/codedor.svg +0 -28
- package/view/chimera/dashboard.ejs +0 -5
- package/view/chimera/editor/add.ejs +0 -32
- package/view/chimera/editor/edit.ejs +0 -33
- package/view/chimera/editor/index.ejs +0 -87
- package/view/chimera/editor/remove.ejs +0 -23
- package/view/chimera/editor/view.ejs +0 -54
- package/view/chimera/elements/editor_actions.ejs +0 -4
- package/view/chimera/elements/empty +0 -0
- package/view/chimera/field_wrappers/_entries.ejs +0 -91
- package/view/chimera/field_wrappers/_wrapper.ejs +0 -82
- package/view/chimera/field_wrappers/date_edit.ejs +0 -23
- package/view/chimera/field_wrappers/date_list.ejs +0 -3
- package/view/chimera/field_wrappers/date_view.ejs +0 -16
- package/view/chimera/field_wrappers/default_edit.ejs +0 -22
- package/view/chimera/field_wrappers/default_list.ejs +0 -3
- package/view/chimera/field_wrappers/default_peek.ejs +0 -3
- package/view/chimera/field_wrappers/default_view.ejs +0 -14
- package/view/chimera/field_wrappers/geopoint_edit.ejs +0 -25
- package/view/chimera/field_wrappers/geopoint_list.ejs +0 -5
- package/view/chimera/field_wrappers/geopoint_view.ejs +0 -18
- package/view/chimera/field_wrappers/schema_edit.ejs +0 -19
- package/view/chimera/field_wrappers/text_edit.ejs +0 -22
- package/view/chimera/field_wrappers/text_list.ejs +0 -1
- package/view/chimera/fields/belongsto_edit.ejs +0 -4
- package/view/chimera/fields/belongsto_list.ejs +0 -1
- package/view/chimera/fields/belongsto_peek.ejs +0 -1
- package/view/chimera/fields/boolean_edit.ejs +0 -17
- package/view/chimera/fields/boolean_list.ejs +0 -3
- package/view/chimera/fields/boolean_view.ejs +0 -3
- package/view/chimera/fields/date_edit.ejs +0 -14
- package/view/chimera/fields/date_list.ejs +0 -9
- package/view/chimera/fields/date_peek.ejs +0 -9
- package/view/chimera/fields/date_view.ejs +0 -9
- package/view/chimera/fields/datetime_edit.ejs +0 -24
- package/view/chimera/fields/datetime_list.ejs +0 -9
- package/view/chimera/fields/datetime_view.ejs +0 -10
- package/view/chimera/fields/default_edit.ejs +0 -10
- package/view/chimera/fields/default_list.ejs +0 -15
- package/view/chimera/fields/default_view.ejs +0 -1
- package/view/chimera/fields/enum_edit.ejs +0 -10
- package/view/chimera/fields/geopoint_edit.ejs +0 -10
- package/view/chimera/fields/geopoint_list.ejs +0 -9
- package/view/chimera/fields/geopoint_view.ejs +0 -9
- package/view/chimera/fields/habtm_edit.ejs +0 -5
- package/view/chimera/fields/hasoneparent_edit.ejs +0 -6
- package/view/chimera/fields/hasoneparent_list.ejs +0 -1
- package/view/chimera/fields/object_edit.ejs +0 -8
- package/view/chimera/fields/password_edit.ejs +0 -12
- package/view/chimera/fields/schema_edit.ejs +0 -14
- package/view/chimera/fields/text_edit.ejs +0 -5
- package/view/chimera/fields/text_list.ejs +0 -9
- package/view/chimera/fields/text_view.ejs +0 -3
- package/view/chimera/fields/time_edit.ejs +0 -15
- package/view/chimera/fields/time_list.ejs +0 -9
- package/view/chimera/fields/time_view.ejs +0 -9
- package/view/chimera/page/edit.ejs +0 -18
- package/view/chimera/page_editor.ejs +0 -5
- package/view/chimera/sidebar.ejs +0 -40
- package/view/chimera/tasks/index.ejs +0 -114
- package/view/layouts/chimera.ejs +0 -12
- package/view/layouts/chimera_base.ejs +0 -11
- package/view/layouts/chimera_body.ejs +0 -43
|
@@ -1,558 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The client side ChimeraFieldWrapper class
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.3.0
|
|
9
|
-
*
|
|
10
|
-
* @param {Object} options
|
|
11
|
-
*/
|
|
12
|
-
var ChimeraFieldWrapper = Function.inherits('Informer', function ChimeraFieldWrapper(options) {
|
|
13
|
-
|
|
14
|
-
if (!options) {
|
|
15
|
-
throw new Error('No options given for Chimera field wrapper');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Field data
|
|
19
|
-
this.field = options.field || options.variables.data.field;
|
|
20
|
-
|
|
21
|
-
// The name of the field, for debugging purposes mainly
|
|
22
|
-
this.name = this.field.path;
|
|
23
|
-
|
|
24
|
-
// The viewname to render
|
|
25
|
-
this.viewname = options.viewname;
|
|
26
|
-
|
|
27
|
-
// The value of this field
|
|
28
|
-
if ('value' in options) {
|
|
29
|
-
this.value = options.value;
|
|
30
|
-
} else {
|
|
31
|
-
this.value = options.variables.data.value;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// The variables passed to the rendering element
|
|
35
|
-
this.variables = options.variables;
|
|
36
|
-
|
|
37
|
-
// The container element, with the 'chimeraField-container' CSS class
|
|
38
|
-
this.container = options.container;
|
|
39
|
-
|
|
40
|
-
// The entries wrapper
|
|
41
|
-
this.entries_wrapper = options.entries_wrapper || options.container.querySelector('[data-name="entries"]');
|
|
42
|
-
|
|
43
|
-
// Store this instance on the entries wrapper element and the container
|
|
44
|
-
this.container.CFWrapper = this;
|
|
45
|
-
this.entries_wrapper.CFWrapper = this;
|
|
46
|
-
|
|
47
|
-
// Get the entries id
|
|
48
|
-
this.entries_id = this.entries_wrapper.getAttribute('data-entries-id');
|
|
49
|
-
|
|
50
|
-
// Get the actual entries (live list)
|
|
51
|
-
this.entries = this.entries_wrapper.getElementsByClassName('cfe-' + this.entries_id);
|
|
52
|
-
|
|
53
|
-
// See if this field is nested inside another field
|
|
54
|
-
this.nested_in = options.nested_in;
|
|
55
|
-
|
|
56
|
-
// Store the initial value
|
|
57
|
-
this.original_value = this.value;
|
|
58
|
-
|
|
59
|
-
// Available prefixes array
|
|
60
|
-
this.prefixes = options.prefixes || this.variables.prefixes;
|
|
61
|
-
|
|
62
|
-
// Prefix containers
|
|
63
|
-
this.prefixContainers = null;
|
|
64
|
-
|
|
65
|
-
// The currently showing prefix
|
|
66
|
-
this.activePrefix = null;
|
|
67
|
-
|
|
68
|
-
// The action name
|
|
69
|
-
this.action = this.field.viewaction;
|
|
70
|
-
|
|
71
|
-
// Is this an arrayable field?
|
|
72
|
-
this.isArray = this.field.fieldType.isArray;
|
|
73
|
-
|
|
74
|
-
// Is this a translatable field?
|
|
75
|
-
this.isTranslatable = this.field.fieldType.isTranslatable;
|
|
76
|
-
|
|
77
|
-
// Is this a field translatable field?
|
|
78
|
-
this.fieldTranslatable = this.field.fieldType.fieldTranslatable;
|
|
79
|
-
this.valueTranslatable = this.field.fieldType.valueTranslatable;
|
|
80
|
-
|
|
81
|
-
// Field instances
|
|
82
|
-
this.fields = [];
|
|
83
|
-
|
|
84
|
-
// Is this a read-only field?
|
|
85
|
-
if ('read_only' in options) {
|
|
86
|
-
this.readOnly = options.read_only;
|
|
87
|
-
} else {
|
|
88
|
-
this.readOnly = this.variables.__chimeraReadOnly === true;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
this.initFields();
|
|
92
|
-
this.addButtons();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Static create method
|
|
97
|
-
*
|
|
98
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
99
|
-
* @since 0.2.0
|
|
100
|
-
* @version 0.2.0
|
|
101
|
-
*/
|
|
102
|
-
ChimeraFieldWrapper.setStatic(function create(options) {
|
|
103
|
-
return new this(options);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* The fieldClass property (Class Constructor)
|
|
108
|
-
*
|
|
109
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
110
|
-
* @since 0.2.0
|
|
111
|
-
* @version 0.2.0
|
|
112
|
-
*/
|
|
113
|
-
ChimeraFieldWrapper.prepareProperty(function fieldClass() {
|
|
114
|
-
|
|
115
|
-
var className,
|
|
116
|
-
Classes,
|
|
117
|
-
fnc;
|
|
118
|
-
|
|
119
|
-
Classes = __Protoblast.Classes;
|
|
120
|
-
className = Blast.Bound.String.classify(this.viewname) + 'ChimeraField';
|
|
121
|
-
|
|
122
|
-
if (Classes[className]) {
|
|
123
|
-
fnc = Classes[className];
|
|
124
|
-
} else {
|
|
125
|
-
fnc = ChimeraField;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return fnc;
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Get the path to this field value
|
|
133
|
-
*
|
|
134
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
135
|
-
* @since 0.2.0
|
|
136
|
-
* @version 0.2.0
|
|
137
|
-
*/
|
|
138
|
-
ChimeraFieldWrapper.setMethod(function getNestedPath() {
|
|
139
|
-
|
|
140
|
-
var nested,
|
|
141
|
-
result = '';
|
|
142
|
-
|
|
143
|
-
// Originally we only returned the field name:
|
|
144
|
-
// this.parent.nested_in.field.fieldType.name
|
|
145
|
-
|
|
146
|
-
// Get the field this is nested in
|
|
147
|
-
nested = this.nested_in;
|
|
148
|
-
|
|
149
|
-
// As long as a field is nested, do this
|
|
150
|
-
while (nested) {
|
|
151
|
-
if (result) {
|
|
152
|
-
result = nested.path + '.' + result;
|
|
153
|
-
} else {
|
|
154
|
-
result = nested.path
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (nested.parent) {
|
|
158
|
-
nested = nested.parent.nested_in;
|
|
159
|
-
} else {
|
|
160
|
-
nested = false;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return result;
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Get the full path of this value
|
|
169
|
-
*
|
|
170
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
171
|
-
* @since 0.4.0
|
|
172
|
-
* @version 0.4.0
|
|
173
|
-
*/
|
|
174
|
-
ChimeraFieldWrapper.setMethod(function getFullPath() {
|
|
175
|
-
|
|
176
|
-
var nested = this.getNestedPath();
|
|
177
|
-
|
|
178
|
-
if (nested) {
|
|
179
|
-
return nested + '.' + this.name;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return this.name;
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Create ChimeraField instances
|
|
187
|
-
*
|
|
188
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
189
|
-
* @since 0.2.0
|
|
190
|
-
* @version 0.3.0
|
|
191
|
-
*/
|
|
192
|
-
ChimeraFieldWrapper.setMethod(function initFields() {
|
|
193
|
-
|
|
194
|
-
var instance,
|
|
195
|
-
elements,
|
|
196
|
-
element,
|
|
197
|
-
values,
|
|
198
|
-
prefix,
|
|
199
|
-
value,
|
|
200
|
-
html,
|
|
201
|
-
key,
|
|
202
|
-
el,
|
|
203
|
-
i;
|
|
204
|
-
|
|
205
|
-
if (this.isTranslatable) {
|
|
206
|
-
this.prefixContainers = {};
|
|
207
|
-
|
|
208
|
-
// Get the prefix elements
|
|
209
|
-
elements = this.entries_wrapper.querySelectorAll('.chimeraField-prefix-intake');
|
|
210
|
-
|
|
211
|
-
for (i = 0; i < elements.length; i++) {
|
|
212
|
-
element = elements[i];
|
|
213
|
-
prefix = element.getAttribute('data-prefix');
|
|
214
|
-
|
|
215
|
-
if (i == 0) {
|
|
216
|
-
this.activePrefix = prefix;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
this.prefixContainers[prefix] = element;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (this.isArray) {
|
|
224
|
-
values = Array.cast(this.value);
|
|
225
|
-
} else {
|
|
226
|
-
values = [];
|
|
227
|
-
|
|
228
|
-
if (this.value != null) {
|
|
229
|
-
values[0] = this.value;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
i = 0;
|
|
234
|
-
|
|
235
|
-
do {
|
|
236
|
-
this.addValue(values[i], i);
|
|
237
|
-
i++;
|
|
238
|
-
} while (i < values.length);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Add translate buttons
|
|
243
|
-
*
|
|
244
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
245
|
-
* @since 0.2.0
|
|
246
|
-
* @version 0.5.1
|
|
247
|
-
*/
|
|
248
|
-
ChimeraFieldWrapper.setMethod(function addButtons() {
|
|
249
|
-
|
|
250
|
-
var that = this,
|
|
251
|
-
$prefixButtons,
|
|
252
|
-
$intake = $(this.intake),
|
|
253
|
-
$left = $('.chimeraField-left', that.container).first(),
|
|
254
|
-
el,
|
|
255
|
-
i;
|
|
256
|
-
|
|
257
|
-
if (!$left.length) {
|
|
258
|
-
$left = $(that.container);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Look for add-entry buttons
|
|
262
|
-
if (this.isArray) {
|
|
263
|
-
// Get the first add-entry button (so skip buttons in sub schemas)
|
|
264
|
-
el = this.container.querySelector('.chimeraField-add-entry');
|
|
265
|
-
|
|
266
|
-
if (el) {
|
|
267
|
-
el.addEventListener('click', function onClick() {
|
|
268
|
-
that.addValue();
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if (this.isTranslatable && this.prefixes && this.prefixes.length > 1) {
|
|
274
|
-
this.prefixes.forEach(function eachPrefix(prefix) {
|
|
275
|
-
|
|
276
|
-
var $prefix_button,
|
|
277
|
-
prefix_button,
|
|
278
|
-
is_first;
|
|
279
|
-
|
|
280
|
-
if (!$prefixButtons) {
|
|
281
|
-
$prefixButtons = $('.chimeraField-prefix-buttons', $left);
|
|
282
|
-
is_first = true;
|
|
283
|
-
|
|
284
|
-
if (!$prefixButtons.length) {
|
|
285
|
-
$prefixButtons = $('<div class="chimeraField-prefix-buttons"></div>');
|
|
286
|
-
$left.append($prefixButtons);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
prefix_button = Blast.parseHTML('<button class="chimeraField-prefix-selector btn btn-default">' + alchemy.__('chimera-prefix', prefix) + '</button>');
|
|
291
|
-
$prefixButtons.append(prefix_button);
|
|
292
|
-
$prefix_button = $(prefix_button);
|
|
293
|
-
|
|
294
|
-
if (is_first) {
|
|
295
|
-
prefix_button.classList.add('active');
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
$prefix_button.on('click', function onClickPrefix(e) {
|
|
299
|
-
that.showPrefix(prefix);
|
|
300
|
-
|
|
301
|
-
$prefix_button.siblings().removeClass('active');
|
|
302
|
-
$prefix_button.addClass('active');
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Get all the fields of a single prefix
|
|
311
|
-
*
|
|
312
|
-
* @param {String} prefix
|
|
313
|
-
*/
|
|
314
|
-
ChimeraFieldWrapper.setMethod(function getPrefixFields(prefix) {
|
|
315
|
-
|
|
316
|
-
var result = [],
|
|
317
|
-
field,
|
|
318
|
-
i;
|
|
319
|
-
|
|
320
|
-
for (i = 0; i < this.fields.length; i++) {
|
|
321
|
-
field = this.fields[i];
|
|
322
|
-
|
|
323
|
-
if (field.prefix == prefix) {
|
|
324
|
-
result.push(field);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
return result;
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Get the data
|
|
333
|
-
*
|
|
334
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
335
|
-
* @since 0.2.0
|
|
336
|
-
* @version 0.2.0
|
|
337
|
-
*
|
|
338
|
-
* @param {Boolean} changesOnly
|
|
339
|
-
*/
|
|
340
|
-
ChimeraFieldWrapper.setMethod(function getData(changesOnly) {
|
|
341
|
-
|
|
342
|
-
var that = this,
|
|
343
|
-
result = {};
|
|
344
|
-
|
|
345
|
-
this.fields.forEach(function eachField(field) {
|
|
346
|
-
|
|
347
|
-
var value = field.getData();
|
|
348
|
-
|
|
349
|
-
if (changesOnly && Object.alike(value, field.originalValue)) {
|
|
350
|
-
// If the field is an array, we will have to return everything
|
|
351
|
-
// otherwise things can get screwed up
|
|
352
|
-
if (!that.isArray) {
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
Object.setPath(result, field.path, value);
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
return result;
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Enable the given prefix
|
|
365
|
-
*
|
|
366
|
-
* @param {String} prefix
|
|
367
|
-
*/
|
|
368
|
-
ChimeraFieldWrapper.setMethod(function showPrefix(prefix) {
|
|
369
|
-
|
|
370
|
-
var key,
|
|
371
|
-
el;
|
|
372
|
-
|
|
373
|
-
if (this.activePrefix == prefix) {
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
for (key in this.prefixContainers) {
|
|
378
|
-
el = this.prefixContainers[key];
|
|
379
|
-
|
|
380
|
-
if (key == prefix) {
|
|
381
|
-
el.style.display = '';
|
|
382
|
-
} else {
|
|
383
|
-
el.style.display = 'none';
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
this.activePrefix = prefix;
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Add a value
|
|
392
|
-
*
|
|
393
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
394
|
-
* @since 0.2.0
|
|
395
|
-
* @version 0.3.0
|
|
396
|
-
*
|
|
397
|
-
* @param {Object} value
|
|
398
|
-
* @param {Number} index
|
|
399
|
-
*/
|
|
400
|
-
ChimeraFieldWrapper.setMethod(function addValue(value, index) {
|
|
401
|
-
|
|
402
|
-
var that = this,
|
|
403
|
-
prefixes,
|
|
404
|
-
prefix;
|
|
405
|
-
|
|
406
|
-
if (this.isTranslatable) {
|
|
407
|
-
|
|
408
|
-
// Get the basic prefixes
|
|
409
|
-
prefixes = this.prefixes.slice(0);
|
|
410
|
-
|
|
411
|
-
// Add prefixes from within the value
|
|
412
|
-
if (Object.isObject(value)) {
|
|
413
|
-
for (prefix in value) {
|
|
414
|
-
if (prefix.length < 128 && prefixes.indexOf(prefix) == -1) {
|
|
415
|
-
prefixes.push(prefix);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
prefixes.forEach(function eachPrefix(prefix) {
|
|
421
|
-
|
|
422
|
-
var val;
|
|
423
|
-
|
|
424
|
-
if (value) {
|
|
425
|
-
val = value[prefix];
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
that.addPrefixValue(val, index, prefix);
|
|
429
|
-
});
|
|
430
|
-
} else {
|
|
431
|
-
this.addPrefixValue(value, index);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Add a prefix value
|
|
437
|
-
*
|
|
438
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
439
|
-
* @since 0.2.0
|
|
440
|
-
* @version 0.2.0
|
|
441
|
-
*
|
|
442
|
-
* @param {Object} value
|
|
443
|
-
* @param {Number} index
|
|
444
|
-
* @param {String} prefix
|
|
445
|
-
*/
|
|
446
|
-
ChimeraFieldWrapper.setMethod(function addPrefixValue(value, index, prefix) {
|
|
447
|
-
|
|
448
|
-
var instance,
|
|
449
|
-
options,
|
|
450
|
-
fields;
|
|
451
|
-
|
|
452
|
-
fields = this.getPrefixFields(prefix);
|
|
453
|
-
|
|
454
|
-
// If the field itself supports multiple values, let it handle it
|
|
455
|
-
if (this.fieldClass.multipleValues && this.fields.length) {
|
|
456
|
-
return fields[0].addValue(value);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
try {
|
|
460
|
-
options = {
|
|
461
|
-
parent: this,
|
|
462
|
-
value: value,
|
|
463
|
-
prefix: prefix,
|
|
464
|
-
original_index: index
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
instance = new this.fieldClass(options);
|
|
468
|
-
} catch (err) {
|
|
469
|
-
console.error('Failed to create field:', err)
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* Set a prefix value
|
|
475
|
-
*
|
|
476
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
477
|
-
* @since 0.4.0
|
|
478
|
-
* @version 0.4.0
|
|
479
|
-
*
|
|
480
|
-
* @param {Object} value
|
|
481
|
-
* @param {Number} index
|
|
482
|
-
* @param {String} prefix
|
|
483
|
-
*/
|
|
484
|
-
ChimeraFieldWrapper.setMethod(function setPrefixValue(value, index, prefix) {
|
|
485
|
-
|
|
486
|
-
var instance,
|
|
487
|
-
options,
|
|
488
|
-
fields;
|
|
489
|
-
|
|
490
|
-
fields = this.getPrefixFields(prefix);
|
|
491
|
-
|
|
492
|
-
if (this.fieldClass.multipleValues && this.fields.length) {
|
|
493
|
-
return fields[0].addValue(value);
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
try {
|
|
497
|
-
options = {
|
|
498
|
-
parent: this,
|
|
499
|
-
value: value,
|
|
500
|
-
prefix: prefix,
|
|
501
|
-
original_index: index,
|
|
502
|
-
local_add: true
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
instance = new this.fieldClass(options);
|
|
506
|
-
} catch (err) {
|
|
507
|
-
console.error('Failed to create field:', err)
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Remove the given child from the array
|
|
513
|
-
*
|
|
514
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
515
|
-
* @since 0.2.0
|
|
516
|
-
* @version 0.4.0
|
|
517
|
-
*
|
|
518
|
-
* @param {ChimeraField} child
|
|
519
|
-
* @param {Boolean} force
|
|
520
|
-
*/
|
|
521
|
-
ChimeraFieldWrapper.setMethod(function removeFromArray(child, force) {
|
|
522
|
-
|
|
523
|
-
var index;
|
|
524
|
-
|
|
525
|
-
if (!this.isArray && !force) {
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
index = this.fields.indexOf(child);
|
|
530
|
-
|
|
531
|
-
if (index < 0) {
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
this.fields.splice(index, 1);
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Add the child to the correct intake element
|
|
540
|
-
*
|
|
541
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
542
|
-
* @since 0.2.0
|
|
543
|
-
* @version 0.3.0
|
|
544
|
-
*
|
|
545
|
-
* @param {ChimeraField} child
|
|
546
|
-
*/
|
|
547
|
-
ChimeraFieldWrapper.setMethod(function addEntry(child) {
|
|
548
|
-
|
|
549
|
-
var wrapper;
|
|
550
|
-
|
|
551
|
-
if (child.prefix) {
|
|
552
|
-
wrapper = this.prefixContainers[child.prefix];
|
|
553
|
-
} else {
|
|
554
|
-
wrapper = this.entries_wrapper;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
wrapper.appendChild(child.entry);
|
|
558
|
-
});
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Datetime ChimeraField class
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Kjell Keisse <kjell@codedor.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.2.0
|
|
9
|
-
*
|
|
10
|
-
* @param {ChimeraFieldWrapper} parent
|
|
11
|
-
* @param {Mixed} value
|
|
12
|
-
* @param {DOMElement} container
|
|
13
|
-
* @param {Object} variables
|
|
14
|
-
* @param {String} prefix
|
|
15
|
-
*/
|
|
16
|
-
var DatetimeChimeraField = Function.inherits('ChimeraField', function DatetimeChimeraField(parent, value, container, variables, prefix) {
|
|
17
|
-
DatetimeChimeraField.super.call(this, parent, value, container, variables, prefix);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Don't use rome for list views
|
|
22
|
-
*
|
|
23
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
24
|
-
* @since 0.2.1
|
|
25
|
-
* @version 0.2.1
|
|
26
|
-
*/
|
|
27
|
-
DatetimeChimeraField.setMethod(function renderList() {
|
|
28
|
-
|
|
29
|
-
var format,
|
|
30
|
-
html,
|
|
31
|
-
val = this.value;
|
|
32
|
-
|
|
33
|
-
if (this.parent.field.options.list_format) {
|
|
34
|
-
format = this.parent.field.options.list_format;
|
|
35
|
-
} else {
|
|
36
|
-
format = 'Y-m-d H:i';
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (val && Date.isDate(val)) {
|
|
40
|
-
val = val.format(format);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
html = '<div>' + val + '</div>';
|
|
44
|
-
this.setMainElement(html);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Initialize the field in the edit action
|
|
49
|
-
*
|
|
50
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
51
|
-
* @since 0.4.0
|
|
52
|
-
* @version 0.4.0
|
|
53
|
-
*
|
|
54
|
-
* @param {Mixed} value Optional value to override
|
|
55
|
-
*/
|
|
56
|
-
DatetimeChimeraField.setMethod(function initEdit(value) {
|
|
57
|
-
|
|
58
|
-
var that = this;
|
|
59
|
-
|
|
60
|
-
// Override the value if given
|
|
61
|
-
if (typeof value !== 'undefined') {
|
|
62
|
-
this.input.value = value;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Add change listener
|
|
66
|
-
if (this.input) {
|
|
67
|
-
this.input.addEventListener('change', function onChange() {
|
|
68
|
-
|
|
69
|
-
var date;
|
|
70
|
-
|
|
71
|
-
date = Date.create(that.input.value);
|
|
72
|
-
|
|
73
|
-
that.setValue(date);
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
console.warn('Field', this, 'has no input! Changes will not be saved');
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* The Date ChimeraField class
|
|
82
|
-
*
|
|
83
|
-
* @constructor
|
|
84
|
-
*
|
|
85
|
-
* @author Kjell Keisse <kjell@codedor.be>
|
|
86
|
-
* @since 0.2.0
|
|
87
|
-
* @version 0.4.0
|
|
88
|
-
*
|
|
89
|
-
* @param {ChimeraFieldWrapper} parent
|
|
90
|
-
* @param {Mixed} value
|
|
91
|
-
* @param {DOMElement} container
|
|
92
|
-
* @param {Object} variables
|
|
93
|
-
* @param {String} prefix
|
|
94
|
-
*/
|
|
95
|
-
var DateChimeraField = Function.inherits('ChimeraField', function DateChimeraField(parent, value, container, variables, prefix) {
|
|
96
|
-
DateChimeraField.super.call(this, parent, value, container, variables, prefix);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Don't use rome for list views
|
|
101
|
-
*
|
|
102
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
103
|
-
* @since 0.2.1
|
|
104
|
-
* @version 0.2.1
|
|
105
|
-
*/
|
|
106
|
-
DateChimeraField.setMethod(function renderList() {
|
|
107
|
-
|
|
108
|
-
var format,
|
|
109
|
-
html,
|
|
110
|
-
val = this.value;
|
|
111
|
-
|
|
112
|
-
if (this.parent.field.options.list_format) {
|
|
113
|
-
format = this.parent.field.options.list_format;
|
|
114
|
-
} else {
|
|
115
|
-
format = 'Y-m-d';
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (val && Date.isDate(val)) {
|
|
119
|
-
val = val.format(format);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
html = '<div>' + val + '</div>';
|
|
123
|
-
this.setMainElement(html);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* The Time ChimeraField class
|
|
128
|
-
*
|
|
129
|
-
* @constructor
|
|
130
|
-
*
|
|
131
|
-
* @author Kjell Keisse <kjell@codedor.be>
|
|
132
|
-
* @since 0.2.0
|
|
133
|
-
* @version 0.4.0
|
|
134
|
-
*
|
|
135
|
-
* @param {ChimeraFieldWrapper} parent
|
|
136
|
-
* @param {Mixed} value
|
|
137
|
-
* @param {DOMElement} container
|
|
138
|
-
* @param {Object} variables
|
|
139
|
-
* @param {String} prefix
|
|
140
|
-
*/
|
|
141
|
-
TimeChimeraField = ChimeraField.extend(function TimeChimeraField(parent, value, container, variables, prefix) {
|
|
142
|
-
TimeChimeraField.super.call(this, parent, value, container, variables, prefix);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Don't use rome for list views
|
|
147
|
-
*
|
|
148
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
149
|
-
* @since 0.2.1
|
|
150
|
-
* @version 0.2.1
|
|
151
|
-
*/
|
|
152
|
-
TimeChimeraField.setMethod(function renderList() {
|
|
153
|
-
|
|
154
|
-
var format,
|
|
155
|
-
html,
|
|
156
|
-
val = this.value;
|
|
157
|
-
|
|
158
|
-
if (this.parent.field.options.list_format) {
|
|
159
|
-
format = this.parent.field.options.list_format;
|
|
160
|
-
} else {
|
|
161
|
-
format = 'H:i:s';
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (val && Date.isDate(val)) {
|
|
165
|
-
val = val.format(format);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
html = '<div>' + val + '</div>';
|
|
169
|
-
this.setMainElement(html);
|
|
170
|
-
});
|