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,622 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The client side base ChimeraField class
|
|
3
|
-
*
|
|
4
|
-
* @constructor
|
|
5
|
-
*
|
|
6
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
7
|
-
* @since 0.2.0
|
|
8
|
-
* @version 0.6.0
|
|
9
|
-
*
|
|
10
|
-
* @param {Object} options
|
|
11
|
-
* @param {ChimeraFieldWrapper} options.parent
|
|
12
|
-
* @param {DOMElement} options.container
|
|
13
|
-
* @param {Object} options.variables
|
|
14
|
-
* @param {Mixed} options.value
|
|
15
|
-
* @param {String} options.prefix
|
|
16
|
-
* @param {Number} options.original_index
|
|
17
|
-
*/
|
|
18
|
-
var ChimeraField = Function.inherits('Informer', function ChimeraField(options) {
|
|
19
|
-
|
|
20
|
-
var that = this,
|
|
21
|
-
action;
|
|
22
|
-
|
|
23
|
-
if (!options) {
|
|
24
|
-
throw new Error('ChimeraField can\'t be created without options');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// The parent wrapper
|
|
28
|
-
this.parent = options.parent;
|
|
29
|
-
|
|
30
|
-
// Make the instance self-register in the parent
|
|
31
|
-
this.parent.fields.push(this);
|
|
32
|
-
|
|
33
|
-
// The container element, with the 'chimeraField-container' CSS class
|
|
34
|
-
this.container = options.container || this.parent.container;
|
|
35
|
-
|
|
36
|
-
// The variables passed to the rendering element
|
|
37
|
-
this.variables = options.variables || this.parent.variables;
|
|
38
|
-
|
|
39
|
-
// Field value
|
|
40
|
-
this.value = options.value;
|
|
41
|
-
|
|
42
|
-
// The original value
|
|
43
|
-
this.originalValue = this.value;
|
|
44
|
-
|
|
45
|
-
// The original value index
|
|
46
|
-
this.original_index = options.original_index;
|
|
47
|
-
|
|
48
|
-
// Identify local-added fields (by clicking + button)
|
|
49
|
-
this.is_local_add = options.local_add || this.original_index == null;
|
|
50
|
-
|
|
51
|
-
// Field data
|
|
52
|
-
this.field = this.parent.field;
|
|
53
|
-
|
|
54
|
-
// The prefix of the field
|
|
55
|
-
this.prefix = options.prefix;
|
|
56
|
-
|
|
57
|
-
this.readOnly = this.parent.readOnly;
|
|
58
|
-
this.isArray = this.parent.isArray;
|
|
59
|
-
this.isTranslatable = this.parent.isTranslatable;
|
|
60
|
-
|
|
61
|
-
action = Blast.Bound.String.classify(String(this.parent.action));
|
|
62
|
-
|
|
63
|
-
this.actionType = action;
|
|
64
|
-
|
|
65
|
-
__Protoblast.setImmediate(function() {
|
|
66
|
-
|
|
67
|
-
// @TODO: render only needs to happen when new values are added
|
|
68
|
-
if (that.is_local_add || that.require_render) {
|
|
69
|
-
that.render(function done(err) {
|
|
70
|
-
if (err) {
|
|
71
|
-
throw err;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
that.doInit();
|
|
75
|
-
});
|
|
76
|
-
} else {
|
|
77
|
-
that.doInit();
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Each ChimeraField handles a single value by default
|
|
84
|
-
*
|
|
85
|
-
* @type {Boolean}
|
|
86
|
-
*/
|
|
87
|
-
ChimeraField.setStaticProperty('multipleValues', false);
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The index of this value inside the array.
|
|
91
|
-
* Is always false if it isn't an arrayable field
|
|
92
|
-
*/
|
|
93
|
-
ChimeraField.setProperty(function index() {
|
|
94
|
-
|
|
95
|
-
if (!this.parent.isArray) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return this.parent.fields.indexOf(this);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Get the input element
|
|
104
|
-
*
|
|
105
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
106
|
-
* @since 0.3.0
|
|
107
|
-
* @version 0.3.0
|
|
108
|
-
*
|
|
109
|
-
*/
|
|
110
|
-
ChimeraField.setProperty(function input() {
|
|
111
|
-
|
|
112
|
-
if (!this._input && this.entry) {
|
|
113
|
-
this._input = this.entry.querySelector('.chimeraField-prime');
|
|
114
|
-
|
|
115
|
-
if (!this._input) {
|
|
116
|
-
this._input = this.entry.querySelector('.chimeraEditor-input');
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return this._input;
|
|
121
|
-
}, function setInput(element) {
|
|
122
|
-
this._input = element;
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Get the entry element
|
|
127
|
-
*
|
|
128
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
129
|
-
* @since 0.3.0
|
|
130
|
-
* @version 0.6.0
|
|
131
|
-
*
|
|
132
|
-
*/
|
|
133
|
-
ChimeraField.setProperty(function entry() {
|
|
134
|
-
|
|
135
|
-
var element,
|
|
136
|
-
index = this.original_index || 0,
|
|
137
|
-
i;
|
|
138
|
-
|
|
139
|
-
if (this._entry != null) {
|
|
140
|
-
return this._entry;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (this.is_local_add) {
|
|
144
|
-
this._entry = false;
|
|
145
|
-
} else if (!this.parent.isTranslatable) {
|
|
146
|
-
this._entry = this.parent.entries[index];
|
|
147
|
-
} else {
|
|
148
|
-
for (i = 0; i < this.parent.entries.length; i++) {
|
|
149
|
-
element = this.parent.entries[i];
|
|
150
|
-
|
|
151
|
-
if (element.parentElement.dataset.prefix != this.prefix) {
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (element.dataset.oid == index) {
|
|
156
|
-
this._entry = element;
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return this._entry;
|
|
163
|
-
}, function set_entry(val) {
|
|
164
|
-
this._entry = val;
|
|
165
|
-
return val;
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* The path of this value
|
|
170
|
-
*/
|
|
171
|
-
ChimeraField.setProperty(function path() {
|
|
172
|
-
|
|
173
|
-
var result = this.field.path;
|
|
174
|
-
|
|
175
|
-
if (this.index !== false) {
|
|
176
|
-
result += '.' + this.index;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (this.prefix) {
|
|
180
|
-
result += '.' + this.prefix;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return result;
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Return the nested path
|
|
188
|
-
*
|
|
189
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
190
|
-
* @since 0.2.0
|
|
191
|
-
* @version 0.2.0
|
|
192
|
-
*/
|
|
193
|
-
ChimeraField.setProperty(function nested_path() {
|
|
194
|
-
return this.getNestedPath();
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Get the path of the value it's nested in
|
|
199
|
-
*
|
|
200
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
201
|
-
* @since 0.2.0
|
|
202
|
-
* @version 0.2.0
|
|
203
|
-
*/
|
|
204
|
-
ChimeraField.setMethod(function getNestedPath() {
|
|
205
|
-
return this.parent.getNestedPath();
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Get the full path of this value
|
|
210
|
-
*
|
|
211
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
212
|
-
* @since 0.4.0
|
|
213
|
-
* @version 0.4.0
|
|
214
|
-
*/
|
|
215
|
-
ChimeraField.setMethod(function getFullPath() {
|
|
216
|
-
|
|
217
|
-
var nested = this.getNestedPath();
|
|
218
|
-
|
|
219
|
-
if (nested) {
|
|
220
|
-
return nested + '.' + this.path;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return this.path;
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Get a text representation
|
|
228
|
-
*
|
|
229
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
230
|
-
* @since 0.2.1
|
|
231
|
-
* @version 0.2.1
|
|
232
|
-
*/
|
|
233
|
-
ChimeraField.setMethod(function getText(mixed) {
|
|
234
|
-
|
|
235
|
-
var result;
|
|
236
|
-
|
|
237
|
-
// See if mixed is not an object (and not null)
|
|
238
|
-
if (typeof mixed != 'object') {
|
|
239
|
-
result = mixed;
|
|
240
|
-
} else if (mixed) {
|
|
241
|
-
// Mixed is an object, but not null
|
|
242
|
-
// @TODO: show translations?
|
|
243
|
-
result = Object.first(mixed);
|
|
244
|
-
} else {
|
|
245
|
-
result = mixed;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return String(result);
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Get the value to store in the database
|
|
253
|
-
*
|
|
254
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
255
|
-
* @since 0.2.0
|
|
256
|
-
* @version 0.2.0
|
|
257
|
-
*/
|
|
258
|
-
ChimeraField.setMethod(function getData() {
|
|
259
|
-
return this.value;
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Add element to the wrapper
|
|
264
|
-
*
|
|
265
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
266
|
-
* @since 0.2.0
|
|
267
|
-
* @version 0.2.0
|
|
268
|
-
*
|
|
269
|
-
* @param {Element} element
|
|
270
|
-
*/
|
|
271
|
-
ChimeraField.setMethod(function addElement(element) {
|
|
272
|
-
|
|
273
|
-
var arr,
|
|
274
|
-
i;
|
|
275
|
-
|
|
276
|
-
if (typeof element == 'string') {
|
|
277
|
-
element = Blast.parseHTML(element);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
arr = Array.cast(element);
|
|
281
|
-
|
|
282
|
-
for (i = 0; i < arr.length; i++) {
|
|
283
|
-
this.entry.appendChild(arr[i]);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
return arr[0];
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Set the main element
|
|
291
|
-
*
|
|
292
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
293
|
-
* @since 0.2.0
|
|
294
|
-
* @version 0.2.0
|
|
295
|
-
*
|
|
296
|
-
* @param {Element} element
|
|
297
|
-
*/
|
|
298
|
-
ChimeraField.setMethod(function setMainElement(element) {
|
|
299
|
-
|
|
300
|
-
var elements;
|
|
301
|
-
|
|
302
|
-
if (typeof element == 'string') {
|
|
303
|
-
element = Blast.parseHTML(element);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// If there already is a main element, remove it now!
|
|
307
|
-
if (this.input) {
|
|
308
|
-
this.input.remove();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
elements = Array.cast(element);
|
|
312
|
-
element = elements[0];
|
|
313
|
-
|
|
314
|
-
// Store the main element under the input property
|
|
315
|
-
this.input = element;
|
|
316
|
-
this.$input = $(element);
|
|
317
|
-
|
|
318
|
-
this.input.classList.add('chimeraField-prime');
|
|
319
|
-
|
|
320
|
-
// And add it to the wrapper
|
|
321
|
-
this.addElement(element);
|
|
322
|
-
|
|
323
|
-
if (elements[1]) {
|
|
324
|
-
this.addElement(elements[1]);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return element;
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Render the element
|
|
332
|
-
*
|
|
333
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
334
|
-
* @since 0.2.0
|
|
335
|
-
* @version 0.3.0
|
|
336
|
-
*/
|
|
337
|
-
ChimeraField.setMethod(function render(callback) {
|
|
338
|
-
|
|
339
|
-
var that = this,
|
|
340
|
-
render_function,
|
|
341
|
-
placeholder;
|
|
342
|
-
|
|
343
|
-
// Construct the expected render function name
|
|
344
|
-
render_function = 'render' + this.actionType;
|
|
345
|
-
|
|
346
|
-
// If there is a custom render function, execute that
|
|
347
|
-
// For exaple: renderEdit, renderList, renderPeek, renderView, ...
|
|
348
|
-
if (typeof this[render_function] == 'function') {
|
|
349
|
-
return this[render_function](callback);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// Print the field, get the placeholder
|
|
353
|
-
placeholder = hawkejs.scene.helpers.Chimera.printField({field: this.field, value: this.value}, {print_wrapper: false});
|
|
354
|
-
|
|
355
|
-
// Resolve the placeholder
|
|
356
|
-
placeholder.getContent(function gotContent(err, html) {
|
|
357
|
-
|
|
358
|
-
var entries;
|
|
359
|
-
|
|
360
|
-
if (err) {
|
|
361
|
-
return callback(err);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// Still not done: we only want the entries block
|
|
365
|
-
entries = placeholder.parent.blocks.entries;
|
|
366
|
-
|
|
367
|
-
// Get the html
|
|
368
|
-
entries.joinBuffer(function gotResult(err, html) {
|
|
369
|
-
|
|
370
|
-
var entry_element;
|
|
371
|
-
|
|
372
|
-
if (err) {
|
|
373
|
-
return callback(err);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// Get the new entry element
|
|
377
|
-
entry_element = Array.cast(Blast.parseHTML(html))[0];
|
|
378
|
-
|
|
379
|
-
// Set it
|
|
380
|
-
that.entry = entry_element;
|
|
381
|
-
|
|
382
|
-
that.parent.addEntry(that);
|
|
383
|
-
|
|
384
|
-
callback(null);
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Add extra buttons
|
|
391
|
-
*
|
|
392
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
393
|
-
* @since 0.2.0
|
|
394
|
-
* @version 0.3.0
|
|
395
|
-
*/
|
|
396
|
-
ChimeraField.setMethod(function addButtons() {
|
|
397
|
-
|
|
398
|
-
var that = this,
|
|
399
|
-
elements,
|
|
400
|
-
el;
|
|
401
|
-
|
|
402
|
-
if (this.isArray) {
|
|
403
|
-
|
|
404
|
-
// Get the remove button
|
|
405
|
-
elements = this.entry.querySelectorAll('.chimeraField-remove-entry');
|
|
406
|
-
|
|
407
|
-
// Get the LAST ONE,
|
|
408
|
-
// all the others could bu sub-array-field remove buttons
|
|
409
|
-
el = elements[elements.length - 1];
|
|
410
|
-
|
|
411
|
-
if (el) {
|
|
412
|
-
el.addEventListener('click', function onClickRemoveEntry(e) {
|
|
413
|
-
that.remove();
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Create the edit input element
|
|
421
|
-
*
|
|
422
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
423
|
-
* @since 0.2.0
|
|
424
|
-
* @version 0.2.0
|
|
425
|
-
*
|
|
426
|
-
* @param {Function} callback
|
|
427
|
-
*/
|
|
428
|
-
ChimeraField.setMethod(function _renderEdit(callback) {
|
|
429
|
-
var html = '<input class="chimeraField-string" type="text">';
|
|
430
|
-
|
|
431
|
-
this.setMainElement(html);
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Create the view input element
|
|
436
|
-
*
|
|
437
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
438
|
-
* @since 0.2.0
|
|
439
|
-
* @version 0.2.0
|
|
440
|
-
*
|
|
441
|
-
* @param {Function} callback
|
|
442
|
-
*/
|
|
443
|
-
ChimeraField.setMethod(function _renderView() {
|
|
444
|
-
return this.renderEdit();
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* Create the list input element
|
|
449
|
-
*
|
|
450
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
451
|
-
* @since 0.2.0
|
|
452
|
-
* @version 0.2.0
|
|
453
|
-
*
|
|
454
|
-
* @param {Function} callback
|
|
455
|
-
*/
|
|
456
|
-
ChimeraField.setMethod(function _renderList() {
|
|
457
|
-
var html = '<div>' + this.value + '</div>';
|
|
458
|
-
this.setMainElement(html);
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Render the element
|
|
463
|
-
*
|
|
464
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
465
|
-
* @since 0.2.0
|
|
466
|
-
* @version 0.2.0
|
|
467
|
-
*
|
|
468
|
-
* @param {Function} callback
|
|
469
|
-
*/
|
|
470
|
-
ChimeraField.setMethod(function _render(callback) {
|
|
471
|
-
|
|
472
|
-
var that = this,
|
|
473
|
-
fieldElement,
|
|
474
|
-
|
|
475
|
-
fieldElement = [
|
|
476
|
-
// The expected element to use
|
|
477
|
-
'chimera/fields/' + this.parent.viewname + '_' + this.parent.action,
|
|
478
|
-
// The fallback element
|
|
479
|
-
'chimera/fields/default_' + this.parent.action
|
|
480
|
-
];
|
|
481
|
-
|
|
482
|
-
hawkejs.render(fieldElement, {value: this.value}, callback);
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Remove this value (from an array field)
|
|
487
|
-
*
|
|
488
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
489
|
-
* @since 0.2.0
|
|
490
|
-
* @version 0.2.0
|
|
491
|
-
*
|
|
492
|
-
* @param {Boolean} force Delete, even if it's not an array
|
|
493
|
-
*/
|
|
494
|
-
ChimeraField.setMethod(function remove(force) {
|
|
495
|
-
|
|
496
|
-
if (!this.isArray && !force) {
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
// Remove the element
|
|
501
|
-
this.entry.remove();
|
|
502
|
-
|
|
503
|
-
// Remove the instance from the parent
|
|
504
|
-
this.parent.removeFromArray(this, force);
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* Set the new value for this field.
|
|
509
|
-
* Only new values will be sent to the server on save.
|
|
510
|
-
*
|
|
511
|
-
* @author Jelle De Loecker <jelle@kipdola.be>
|
|
512
|
-
* @since 0.2.0
|
|
513
|
-
* @version 0.4.0
|
|
514
|
-
*
|
|
515
|
-
* @param {Mixed} value
|
|
516
|
-
*/
|
|
517
|
-
ChimeraField.setMethod(function setValue(value, emit_change) {
|
|
518
|
-
this.value = value;
|
|
519
|
-
|
|
520
|
-
if (emit_change == null || emit_change) {
|
|
521
|
-
this.emit('change', value);
|
|
522
|
-
this.parent.emit('change');
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* Start the appropriate initialization
|
|
528
|
-
*
|
|
529
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
530
|
-
* @since 0.3.0
|
|
531
|
-
* @version 0.3.0
|
|
532
|
-
*/
|
|
533
|
-
ChimeraField.setMethod(function doInit() {
|
|
534
|
-
|
|
535
|
-
var init_action;
|
|
536
|
-
|
|
537
|
-
// Add optional buttons (language prefixes)
|
|
538
|
-
this.addButtons();
|
|
539
|
-
|
|
540
|
-
// Construct the expected init name
|
|
541
|
-
init_action = 'init' + this.actionType;
|
|
542
|
-
|
|
543
|
-
if (typeof this[init_action] == 'function') {
|
|
544
|
-
this[init_action]();
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
if (this.readOnly) {
|
|
548
|
-
this.setReadOnly(true);
|
|
549
|
-
}
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Initialize the field in the edit action
|
|
554
|
-
*
|
|
555
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
556
|
-
* @since 0.2.0
|
|
557
|
-
* @version 0.5.0
|
|
558
|
-
*
|
|
559
|
-
* @param {Mixed} value Optional value to override
|
|
560
|
-
*/
|
|
561
|
-
ChimeraField.setMethod(function initEdit(value) {
|
|
562
|
-
|
|
563
|
-
var that = this;
|
|
564
|
-
|
|
565
|
-
// Override the value if given
|
|
566
|
-
if (typeof value !== 'undefined') {
|
|
567
|
-
this.input.value = value;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
//console.log('Listening to change on', this);
|
|
571
|
-
|
|
572
|
-
// Add change listener
|
|
573
|
-
if (this.input) {
|
|
574
|
-
this.input.addEventListener('change', function onChange() {
|
|
575
|
-
that.setValue(that.input.value);
|
|
576
|
-
});
|
|
577
|
-
} else if (!(this.field && this.field.fieldType && this.field.fieldType.name == '_id')) {
|
|
578
|
-
console.warn('Field', this, 'has no input! Changes will not be saved');
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Initialize the field in the add action
|
|
584
|
-
*
|
|
585
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
586
|
-
* @since 0.2.0
|
|
587
|
-
* @version 0.3.0
|
|
588
|
-
*
|
|
589
|
-
* @param {Mixed} value
|
|
590
|
-
*/
|
|
591
|
-
ChimeraField.setMethod(function initAdd(value) {
|
|
592
|
-
return this.initEdit(value);
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* Initialize the field in the list action
|
|
597
|
-
*
|
|
598
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
599
|
-
* @since 0.2.0
|
|
600
|
-
* @version 0.2.0
|
|
601
|
-
*/
|
|
602
|
-
ChimeraField.setMethod(function initList() {
|
|
603
|
-
return;
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
/**
|
|
607
|
-
* Set the new value for this field.
|
|
608
|
-
* Only new values will be sent to the server on save.
|
|
609
|
-
*
|
|
610
|
-
* @param {Mixed} value
|
|
611
|
-
*/
|
|
612
|
-
ChimeraField.setMethod(function setReadOnly(value) {
|
|
613
|
-
|
|
614
|
-
var $prime = this.$input;
|
|
615
|
-
$prime.attr('disabled', value);
|
|
616
|
-
|
|
617
|
-
if (value) {
|
|
618
|
-
$prime.addClass('chimera-read-only');
|
|
619
|
-
} else {
|
|
620
|
-
$prime.removeClass('chimera-read-only');
|
|
621
|
-
}
|
|
622
|
-
});
|