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.
Files changed (128) hide show
  1. package/CHANGELOG.md +39 -4
  2. package/assets/scripts/chimera/chimera.js +13 -288
  3. package/assets/stylesheets/chimera/chimera.scss +451 -0
  4. package/bootstrap.js +6 -302
  5. package/config/routes.js +53 -5
  6. package/controller/00-chimera_controller.js +16 -0
  7. package/controller/chimera_editor_controller.js +159 -614
  8. package/controller/chimera_static_controller.js +102 -9
  9. package/lib/chimera_config.js +138 -163
  10. package/model/model.js +1 -1
  11. package/package.json +8 -12
  12. package/view/chimera/dashboard.hwk +8 -0
  13. package/view/chimera/editor/index.hwk +20 -0
  14. package/view/chimera/sidebar.hwk +4 -0
  15. package/view/chimera/widgets.hwk +8 -0
  16. package/view/layouts/chimera_base.hwk +15 -0
  17. package/view/layouts/chimera_basics.hwk +15 -0
  18. package/view/layouts/chimera_body.hwk +24 -0
  19. package/assets/scripts/chimera/assoc_field.js +0 -311
  20. package/assets/scripts/chimera/boolean_field.js +0 -53
  21. package/assets/scripts/chimera/chimera_field.js +0 -622
  22. package/assets/scripts/chimera/chimera_field_wrapper.js +0 -558
  23. package/assets/scripts/chimera/date_field.js +0 -170
  24. package/assets/scripts/chimera/geopoint_field.js +0 -147
  25. package/assets/scripts/chimera/medium-button.js +0 -6
  26. package/assets/scripts/chimera/object_field.js +0 -51
  27. package/assets/scripts/chimera/page-editor.js +0 -3
  28. package/assets/scripts/chimera/password_field.js +0 -73
  29. package/assets/scripts/chimera/schema_field.js +0 -300
  30. package/assets/scripts/chimera/text_field.js +0 -119
  31. package/assets/scripts/rome/rome.js +0 -4978
  32. package/assets/scripts/vex/vex.dialog.js +0 -151
  33. package/assets/scripts/vex/vex.js +0 -193
  34. package/assets/stylesheets/chimera/chimera.less +0 -1075
  35. package/assets/stylesheets/chimera_old/chimera.less +0 -351
  36. package/assets/stylesheets/chimera_old/core.less +0 -315
  37. package/assets/stylesheets/chimera_old/font.less +0 -38
  38. package/assets/stylesheets/chimera_old/mixins.less +0 -35
  39. package/assets/stylesheets/chimera_old/page-editor.less +0 -23
  40. package/assets/stylesheets/rome/rome.less +0 -130
  41. package/assets/stylesheets/vex/vex-theme-bottom-right-corner.less +0 -613
  42. package/assets/stylesheets/vex/vex.default.less +0 -501
  43. package/assets/stylesheets/vex/vex.flat.less +0 -443
  44. package/assets/stylesheets/vex/vex.less +0 -320
  45. package/controller/chimera_page_controller.js +0 -14
  46. package/controller/chimera_settings_controller.js +0 -129
  47. package/controller/tasks_chimera_controller.js +0 -106
  48. package/helper/chimera_helper.js +0 -202
  49. package/lib/chimera_action_fields.js +0 -292
  50. package/lib/chimera_field/belongsto_chimera_field.js +0 -160
  51. package/lib/chimera_field/boolean_chimera_field.js +0 -19
  52. package/lib/chimera_field/date_chimera_field.js +0 -20
  53. package/lib/chimera_field/datetime_chimera_field.js +0 -20
  54. package/lib/chimera_field/enum_chimera_field.js +0 -131
  55. package/lib/chimera_field/geopoint_chimera_field.js +0 -20
  56. package/lib/chimera_field/habtm_chimera_field.js +0 -55
  57. package/lib/chimera_field/hasoneparent_chimera_field.js +0 -18
  58. package/lib/chimera_field/html_chimera_field.js +0 -20
  59. package/lib/chimera_field/object_chimera_field.js +0 -18
  60. package/lib/chimera_field/password_chimera_field.js +0 -18
  61. package/lib/chimera_field/schema_chimera_field.js +0 -149
  62. package/lib/chimera_field/text_chimera_field.js +0 -20
  63. package/lib/chimera_field/time_chimera_field.js +0 -18
  64. package/lib/chimera_field.js +0 -208
  65. package/model/setting_model.js +0 -51
  66. package/public/chimera/codedor.svg +0 -28
  67. package/view/chimera/dashboard.ejs +0 -5
  68. package/view/chimera/editor/add.ejs +0 -32
  69. package/view/chimera/editor/edit.ejs +0 -33
  70. package/view/chimera/editor/index.ejs +0 -87
  71. package/view/chimera/editor/remove.ejs +0 -23
  72. package/view/chimera/editor/view.ejs +0 -54
  73. package/view/chimera/elements/editor_actions.ejs +0 -4
  74. package/view/chimera/elements/empty +0 -0
  75. package/view/chimera/field_wrappers/_entries.ejs +0 -91
  76. package/view/chimera/field_wrappers/_wrapper.ejs +0 -82
  77. package/view/chimera/field_wrappers/date_edit.ejs +0 -23
  78. package/view/chimera/field_wrappers/date_list.ejs +0 -3
  79. package/view/chimera/field_wrappers/date_view.ejs +0 -16
  80. package/view/chimera/field_wrappers/default_edit.ejs +0 -22
  81. package/view/chimera/field_wrappers/default_list.ejs +0 -3
  82. package/view/chimera/field_wrappers/default_peek.ejs +0 -3
  83. package/view/chimera/field_wrappers/default_view.ejs +0 -14
  84. package/view/chimera/field_wrappers/geopoint_edit.ejs +0 -25
  85. package/view/chimera/field_wrappers/geopoint_list.ejs +0 -5
  86. package/view/chimera/field_wrappers/geopoint_view.ejs +0 -18
  87. package/view/chimera/field_wrappers/schema_edit.ejs +0 -19
  88. package/view/chimera/field_wrappers/text_edit.ejs +0 -22
  89. package/view/chimera/field_wrappers/text_list.ejs +0 -1
  90. package/view/chimera/fields/belongsto_edit.ejs +0 -4
  91. package/view/chimera/fields/belongsto_list.ejs +0 -1
  92. package/view/chimera/fields/belongsto_peek.ejs +0 -1
  93. package/view/chimera/fields/boolean_edit.ejs +0 -17
  94. package/view/chimera/fields/boolean_list.ejs +0 -3
  95. package/view/chimera/fields/boolean_view.ejs +0 -3
  96. package/view/chimera/fields/date_edit.ejs +0 -14
  97. package/view/chimera/fields/date_list.ejs +0 -9
  98. package/view/chimera/fields/date_peek.ejs +0 -9
  99. package/view/chimera/fields/date_view.ejs +0 -9
  100. package/view/chimera/fields/datetime_edit.ejs +0 -24
  101. package/view/chimera/fields/datetime_list.ejs +0 -9
  102. package/view/chimera/fields/datetime_view.ejs +0 -10
  103. package/view/chimera/fields/default_edit.ejs +0 -10
  104. package/view/chimera/fields/default_list.ejs +0 -15
  105. package/view/chimera/fields/default_view.ejs +0 -1
  106. package/view/chimera/fields/enum_edit.ejs +0 -10
  107. package/view/chimera/fields/geopoint_edit.ejs +0 -10
  108. package/view/chimera/fields/geopoint_list.ejs +0 -9
  109. package/view/chimera/fields/geopoint_view.ejs +0 -9
  110. package/view/chimera/fields/habtm_edit.ejs +0 -5
  111. package/view/chimera/fields/hasoneparent_edit.ejs +0 -6
  112. package/view/chimera/fields/hasoneparent_list.ejs +0 -1
  113. package/view/chimera/fields/object_edit.ejs +0 -8
  114. package/view/chimera/fields/password_edit.ejs +0 -12
  115. package/view/chimera/fields/schema_edit.ejs +0 -14
  116. package/view/chimera/fields/text_edit.ejs +0 -5
  117. package/view/chimera/fields/text_list.ejs +0 -9
  118. package/view/chimera/fields/text_view.ejs +0 -3
  119. package/view/chimera/fields/time_edit.ejs +0 -15
  120. package/view/chimera/fields/time_list.ejs +0 -9
  121. package/view/chimera/fields/time_view.ejs +0 -9
  122. package/view/chimera/page/edit.ejs +0 -18
  123. package/view/chimera/page_editor.ejs +0 -5
  124. package/view/chimera/sidebar.ejs +0 -40
  125. package/view/chimera/tasks/index.ejs +0 -114
  126. package/view/layouts/chimera.ejs +0 -12
  127. package/view/layouts/chimera_base.ejs +0 -11
  128. package/view/layouts/chimera_body.ejs +0 -43
@@ -1,147 +0,0 @@
1
- /**
2
- * The Geopoint ChimeraField class
3
- *
4
- * @constructor
5
- *
6
- * @author Jelle De Loecker <jelle@kipdola.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
- GeopointChimeraField = ChimeraField.extend(function GeopointChimeraField(parent, value, container, variables, prefix) {
17
- GeopointChimeraField.super.call(this, parent, value, container, variables, prefix);
18
- });
19
-
20
- /**
21
- * Create the edit input element
22
- *
23
- * @author Jelle De Loecker <jelle@kipdola.be>
24
- * @since 0.2.0
25
- * @version 0.2.0
26
- */
27
- GeopointChimeraField.setMethod(function renderEdit() {
28
-
29
- var html = '<div class="geopoint-div geopoint-edit"></div>';
30
-
31
- this.setMainElement(html);
32
- });
33
-
34
- /**
35
- * Initialize the field
36
- *
37
- * @param {Mixed} value
38
- */
39
- GeopointChimeraField.setMethod(function initEdit() {
40
-
41
- var that = this,
42
- $input = this.$input,
43
- coordinates,
44
- value;
45
-
46
- options = {
47
- minZoom: 1,
48
- maxZoom: 16,
49
- dragging: true,
50
- editable: true
51
- };
52
-
53
- value = this.value || {};
54
-
55
- coordinates = value.coordinates || [];
56
-
57
- result = applyGeopoint($input, coordinates[0], coordinates[1], options);
58
-
59
- if (!result) {
60
- throw new Error('Map wrapper could not be created');
61
- }
62
-
63
- map = result[0];
64
- marker = result[1];
65
-
66
- marker.on('dragend', function afterDrag() {
67
- var coordinates = marker.getLatLng();
68
- that.setValue([coordinates.lat, coordinates.lng]);
69
- //$el.data('new-value', [coordinates.lat, coordinates.lng]);
70
- });
71
- });
72
-
73
- /**
74
- * Initialize the list field
75
- *
76
- * @param {Mixed} value
77
- */
78
- GeopointChimeraField.setMethod(function initList() {
79
-
80
- var that = this,
81
- $input = $('.geopoint-list', this.intake),
82
- options,
83
- coordinates,
84
- value;
85
-
86
- options = {
87
- dragging: false
88
- };
89
-
90
- value = this.value || {};
91
-
92
- coordinates = value.coordinates || [];
93
-
94
- result = applyGeopoint($input, coordinates[0], coordinates[1], options);
95
- });
96
-
97
- function applyGeopoint($el, lat, lng, _options) {
98
-
99
- var markOptions,
100
- options,
101
- marker,
102
- lat,
103
- lng,
104
- map;
105
-
106
- if ($el == null) {
107
- throw new Error('Wrapper element not found, can\'t create map');
108
- }
109
-
110
- // Skip this map if the coordinates are not numbers
111
- if (!isFinite(lat) || !isFinite(lng)) {
112
- lat = 51.044821;
113
- lng = 3.738785;
114
- }
115
-
116
- options = {
117
- dragging: false,
118
- touchZoom: false,
119
- center: [lat+0.0012, lng],
120
- zoomControl: false,
121
- attributionControl: false,
122
- scrollWheelZoom: 'center',
123
- minZoom: 13,
124
- maxZoom: 15,
125
- zoom: 14
126
- };
127
-
128
- Object.assign(options, _options);
129
-
130
- // Add the point to the map
131
- map = L.map($el[0], options);
132
-
133
- L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}', {
134
- attribution: '',
135
- maxZoom: 16
136
- }).addTo(map);
137
-
138
- markOptions = {};
139
-
140
- if (options.editable === true) {
141
- markOptions.draggable = true;
142
- }
143
-
144
- marker = L.marker([lat, lng], markOptions).addTo(map);
145
-
146
- return [map, marker];
147
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * MediumButton 1.1 (08.08.2014)
3
- * By Patrick Stillhart
4
- * https://stillhart.biz/
5
- */
6
- function MediumButton(t){return void 0!==t.label&&/\S{1}/.test(t.label)&&void 0!==t.start&&/\S{1}/.test(t.start)&&void 0!==t.end&&/\S{1}/.test(t.end)||void 0!==t.label&&/\S{1}/.test(t.label)&&void 0!==t.action&&/\S{1}/.test(t.action)?(t.start=void 0===t.start?"":t.start,t.end=void 0===t.end?"":t.end,this.options=t,this.button=document.createElement("button"),this.button.className="medium-editor-action",this.button.innerHTML=t.label,void(this.button.onclick=function(){var e=getCurrentSelection(),n=window.getSelection();void 0===t.start||-1==e.indexOf(t.start)&&-1==e.indexOf(t.end)?(void 0!=t.action&&(e=t.action(e,!0)),e=t.start+e+t.end):(void 0!=t.action&&(e=t.action(e,!1)),e=String(e).split(t.start).join(""),e=String(e).split(t.end).join(""));var o;if(n.getRangeAt&&n.rangeCount){if(o=window.getSelection().getRangeAt(0),o.deleteContents(),o.createContextualFragment)fragment=o.createContextualFragment(e);else{var i=document.createElement("div");for(i.innerHTML=e,fragment=document.createDocumentFragment();child=i.firstChild;)fragment.appendChild(child)}var a=fragment.firstChild,r=fragment.lastChild;o.insertNode(fragment),a&&(o.setStartBefore(a),o.setEndAfter(r)),n.removeAllRanges(),n.addRange(o)}})):void console.error('[Custom-Button] You need to specify "label", "start" and "end" OR "label" and "action"')}function getCurrentSelection(){var t,e="";if("undefined"!=typeof window.getSelection){if(t=window.getSelection(),t.rangeCount){for(var n=document.createElement("div"),o=0,i=t.rangeCount;i>o;++o)n.appendChild(t.getRangeAt(o).cloneContents());e=n.innerHTML}}else"undefined"!=typeof document.selection&&"Text"==document.selection.type&&(e=document.selection.createRange().htmlText);return e}MediumButton.prototype.getButton=function(){return this.button},MediumButton.prototype.checkState=function(){var t=getCurrentSelection();""!=this.options.start&&t.indexOf(this.options.start)>-1&&t.indexOf(this.options.end)>-1&&this.button.classList.add("medium-editor-button-active")};
@@ -1,51 +0,0 @@
1
- /**
2
- * The Object ChimeraField class
3
- *
4
- * @constructor
5
- *
6
- * @author Jelle De Loecker <jelle@develry.be>
7
- * @since 0.3.0
8
- * @version 0.3.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 ObjectChimeraField = Function.inherits('ChimeraField', function ObjectChimeraField(options) {
17
- ObjectChimeraField.super.call(this, options);
18
- });
19
-
20
- /**
21
- * Initialize the field in the edit action
22
- *
23
- * @author Jelle De Loecker <jelle@develry.be>
24
- * @since 0.3.0
25
- * @version 0.3.0
26
- *
27
- * @param {Mixed} value Optional value to override
28
- */
29
- ObjectChimeraField.setMethod(function initEdit(value) {
30
-
31
- var that = this;
32
-
33
- // Override the value if given
34
- if (typeof value !== 'undefined') {
35
- this.input.value = JSON.dry(value, null, 4);
36
- }
37
-
38
- // Add change listener
39
- this.input.addEventListener('change', function onChange() {
40
-
41
- var value;
42
-
43
- try {
44
- value = JSON.undry(that.input.value);
45
- } catch (err) {
46
- return console.error('Failed to parse JSON: ', value);
47
- }
48
-
49
- that.setValue(value);
50
- });
51
- });
@@ -1,3 +0,0 @@
1
- var PageEditBlock = Function.inherits(function PageEditBlock(container, variables) {
2
-
3
- });
@@ -1,73 +0,0 @@
1
- /**
2
- * The Password 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 PasswordChimeraField = ChimeraField.extend(function PasswordChimeraField(parent, value, container, variables, prefix) {
17
- PasswordChimeraField.super.call(this, parent, value, container, variables, prefix);
18
- });
19
-
20
- /**
21
- * Initialize the field
22
- *
23
- * @param {Mixed} value
24
- */
25
- PasswordChimeraField.setMethod(function initEdit() {
26
-
27
- "use strict";
28
-
29
- var that = this,
30
- $first = $('.chimeraPassword-first', this.container),
31
- $second = $('.chimeraPassword-second', this.container),
32
- $validation = $('.validation', this.container);
33
-
34
- $first.add($second).change(function onFirstChange() {
35
-
36
- checkMatch();
37
-
38
- if ($first.val() == $second.val()) {
39
- that.setValue($first.val());
40
- } else {
41
- //that.setValue(null);
42
- }
43
- });
44
-
45
- $first.add($second).on('keyup', function() {
46
- checkMatch();
47
- });
48
-
49
- function checkMatch() {
50
-
51
- var first = $first.val(),
52
- second = $second.val();
53
-
54
- if (first == second) {
55
- $validation.text('');
56
- that.container.classList.remove('has-error');
57
-
58
- if (first) {
59
- that.container.classList.add('has-success');
60
- }
61
- } else {
62
- let error_html = String(alchemy.__('chimera', 'passwords.dont.match'));
63
- let html = '<br><div class="alert alert-danger" role="alert">'
64
- + '<i class="alert-ico fa fa-fw fa-ban"></i>'
65
- + error_html
66
- + '</div>';
67
-
68
- $validation.html(html);
69
- that.container.classList.add('has-error');
70
- that.container.classList.remove('has-success');
71
- }
72
- }
73
- });
@@ -1,300 +0,0 @@
1
- /**
2
- * The Schema ChimeraField 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 {ChimeraFieldWrapper} parent
11
- * @param {Mixed} value
12
- * @param {DOMElement} container
13
- * @param {Object} variables
14
- * @param {String} prefix
15
- */
16
- var SchemaChimeraField = Function.inherits('ChimeraField', function SchemaChimeraField(options) {
17
-
18
- var that = this,
19
- value = options.value,
20
- base;
21
-
22
- // @todo: this is probably breaking array support for schema's
23
- if (Array.isArray(value)) {
24
- value = value[0];
25
- }
26
-
27
- // Make sure the fields exist inside the value object
28
- if (!value) {
29
-
30
- // Prepare the new value object
31
- value = {fields: []};
32
-
33
- // Get the original value of the parent wrapper
34
- base = Object.first(options.parent.original_value);
35
-
36
- if (base && base.fields) {
37
- // Copy over the fields, but not the value
38
- base.fields.forEach(function eachField(entry) {
39
- value.fields.push({field: entry.field});
40
- });
41
- }
42
- }
43
-
44
- options.value = value;
45
-
46
- SchemaChimeraField.super.call(this, options);
47
-
48
- // Newly created ChimeraField instances of the subschema
49
- // will be stored in this array
50
- this.fields = [];
51
- });
52
-
53
- /**
54
- * The linked field, if any
55
- *
56
- * @author Jelle De Loecker <jelle@kipdola.be>
57
- * @since 0.4.0
58
- * @version 0.4.0
59
- */
60
- SchemaChimeraField.setProperty(function linked_field() {
61
-
62
- var siblings,
63
- pieces,
64
- field,
65
- path,
66
- i;
67
-
68
- path = this.field.fieldType.options.schema;
69
-
70
- if (typeof path != 'string') {
71
- return null;
72
- }
73
-
74
- pieces = path.split('.');
75
-
76
- // Get the siblings
77
- siblings = this.container.parentElement.children;
78
-
79
- for (i = 0; i < siblings.length; i++) {
80
-
81
- // Ignore ourselves
82
- if (siblings[i] == this.container) {
83
- continue;
84
- }
85
-
86
- field = siblings[i].CFWrapper;
87
-
88
- if (field.name == pieces[0]) {
89
- return field;
90
- }
91
-
92
- // The regular `field.name` can contain the root model name,
93
- // so look deeper for just the name of the field
94
- if (field.field && field.field.fieldType && field.field.fieldType.name == pieces[0]) {
95
- return field;
96
- }
97
- }
98
- });
99
-
100
- /**
101
- * Get the path of the value it's nested in
102
- *
103
- * @author Jelle De Loecker <jelle@develry.be>
104
- * @since 0.4.0
105
- * @version 0.4.0
106
- */
107
- SchemaChimeraField.setMethod(function getNestedPath() {
108
-
109
- if (this.variables && this.variables.data && this.variables.data.nested_path) {
110
- return this.variables.data.nested_path;
111
- }
112
-
113
- return this.parent.getNestedPath();
114
- });
115
-
116
- /**
117
- * Initialize the field
118
- *
119
- * @author Jelle De Loecker <jelle@kipdola.be>
120
- * @since 0.2.0
121
- * @version 0.4.0
122
- *
123
- * @param {Mixed} value
124
- */
125
- SchemaChimeraField.setMethod(function initEdit() {
126
-
127
- var that = this,
128
- containers,
129
- class_name,
130
- urlparams,
131
- selector,
132
- recordId,
133
- Router,
134
- linked,
135
- temp,
136
- url,
137
- i;
138
-
139
- // Get all the field containers that are direct descendents of this schema,
140
- // but not further (not a schema in a schema)
141
- if (this.is_local_add) {
142
- selector = '.chimeraField-container';
143
-
144
- // Get the very first container
145
- temp = this.entry.querySelector(selector);
146
-
147
- if (temp) {
148
- for (i = 0; i < temp.classList.length; i++) {
149
- if (temp.classList[i].startsWith('nid-')) {
150
- class_name = temp.classList[i].after('nid-');
151
- break;
152
- }
153
- }
154
-
155
- if (class_name) {
156
- selector += '.nid-' + class_name;
157
- }
158
- }
159
-
160
- } else {
161
- selector = '.chimeraField-container.nid-' + this.parent.entries_id;
162
- }
163
-
164
- // Get all the containers
165
- containers = Array.cast(this.entry.querySelectorAll(selector));
166
-
167
- // Filter out any non-container elements
168
- containers = containers.filter(function eachElement(element) {
169
- return element.matches('.chimeraField-container');
170
- });
171
-
172
- containers.forEach(function eachContainer(element, index) {
173
-
174
- var model_name,
175
- instance,
176
- options,
177
- config,
178
- entry;
179
-
180
- entry = that.value.fields[index];
181
- config = entry.field;
182
-
183
- // Construct the wrapper options
184
- options = {
185
- nested_in: that,
186
- variables: that.variables,
187
- container: element,
188
- viewname: config.viewname,
189
- value: entry.value,
190
- field: entry.field
191
- };
192
-
193
- // Create a new wrapper instance
194
- instance = new ChimeraFieldWrapper(options);
195
-
196
- that.fields.push(instance);
197
- });
198
-
199
- // Get the optional linked field
200
- linked = this.linked_field;
201
-
202
- if (!linked) {
203
- return;
204
- }
205
-
206
- Router = new hawkejs.constructor.helpers.Router();
207
-
208
- urlparams = this.variables.__urlparams || {};
209
-
210
- if (urlparams.id) {
211
- recordId = urlparams.id;
212
- } else {
213
- recordId = Object.path(this.variables, 'item.value.id');
214
- }
215
-
216
- if (!recordId) {
217
- recordId = Object.path(this.variables, 'data.root_id');
218
-
219
- if (!recordId) {
220
- recordId = this.variables.__recordId || "000000000000000000000000";
221
- }
222
- }
223
-
224
- // Get the name of the model this field is in
225
- model_name = this.field.model_name || this.modelName || this.variables.modelName;
226
-
227
- // If it's still not found, look in the data variable
228
- if (!model_name) {
229
- if (this.variables.data && this.variables.data.root_model) {
230
- model_name = this.variables.data.root_model;
231
- }
232
- }
233
-
234
- url = Blast.Collection.URL.parse(Router.routeUrl('RecordAction', {
235
- controller: 'editor',
236
- subject: model_name,
237
- action: 'related_data',
238
- id: recordId
239
- }));
240
-
241
- if (this.nested_path) {
242
- url.addQuery('nested_in', this.nested_path);
243
- }
244
-
245
- url.addQuery('fieldpath', this.field.path);
246
-
247
- linked.on('change', function onChange() {
248
-
249
- var target_url,
250
- value,
251
- data;
252
-
253
- data = linked.getData();
254
-
255
- if (!data) {
256
- return;
257
- }
258
-
259
- value = Object.path(data, linked.name);
260
-
261
- target_url = url.clone();
262
- target_url.addQuery('path_of_new_value', linked.getFullPath());
263
- target_url.addQuery('new_value', value);
264
-
265
- hawkejs.scene.fetch(target_url, {}, function gotResult(err, data) {
266
-
267
- if (err) {
268
- throw err;
269
- }
270
-
271
- // Remove the original field, this has to happen before adding the
272
- // new field, because otherwise multiple indexes exist and it screws up
273
- that.remove(true);
274
-
275
- that.parent.setPrefixValue(data, that.index, that.prefix);
276
-
277
- // Unlisten to change event
278
- linked.removeListener('change', onChange);
279
- });
280
- });
281
- });
282
-
283
- /**
284
- * Get the data from the subschema
285
- *
286
- * @author Jelle De Loecker <jelle@kipdola.be>
287
- * @since 0.2.0
288
- * @version 0.2.0
289
- */
290
- SchemaChimeraField.setMethod(function getData() {
291
-
292
- var that = this,
293
- result = {};
294
-
295
- this.fields.forEach(function eachField(field) {
296
- Object.merge(result, field.getData());
297
- });
298
-
299
- return result;
300
- });
@@ -1,119 +0,0 @@
1
- /**
2
- * The Text 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 TextChimeraField = ChimeraField.extend(function TextChimeraField(parent, value, container, variables, prefix) {
17
- TextChimeraField.super.call(this, parent, value, container, variables, prefix);
18
- });
19
-
20
- /**
21
- * Initialize the field
22
- *
23
- * @param {Mixed} value
24
- */
25
- TextChimeraField.setMethod(function initEdit() {
26
-
27
- var that = this,
28
- field_options = this.parent.field && this.parent.field.options,
29
- ck_options,
30
- editor,
31
- name,
32
- id,
33
- i;
34
-
35
- if (!field_options) {
36
- field_options = {};
37
- }
38
-
39
- ck_options = {
40
- extraPlugins : 'sourcedialog',
41
- filebrowserBrowseUrl : '/boeckeditor',
42
- allowedContent : true,
43
- toolbarGroups : [
44
- {"name":"styles", "groups":["styles"]},
45
- {"name":"basicstyles", "groups":["basicstyles"]},
46
- {"name":"links", "groups":["links"]},
47
- {"name":"paragraph", "groups":["list","blocks"]},
48
- {"name":"document", "groups":["mode"]},
49
- {"name":"insert", "groups":["insert"]},
50
- ],
51
- removeButtons: 'Underline,Strike,Subscript,Superscript,Anchor,Styles,Specialchar,NewPage,Flash,HorizontalRule,CreateDiv,Smiley,SpecialChar,PageBreak,Iframe'
52
- };
53
-
54
- ck_options.extraAllowedContent = 'p(*)[*]{*};div(*)[*]{*};li(*)[*]{*};ul(*)[*]{*}';
55
- CKEDITOR.dtd.$removeEmpty.i = 0;
56
-
57
- if (field_options.use_br) {
58
- ck_options.enterMode = CKEDITOR.ENTER_BR;
59
- }
60
-
61
- if (field_options.contents_css) {
62
- ck_options.contentsCss = Array.cast(field_options.contents_css);
63
- }
64
-
65
- if (field_options.height) {
66
- ck_options.height = field_options.height;
67
- }
68
-
69
- if (field_options.inline === false) {
70
-
71
- if (!field_options.contents_css) {
72
- ck_options.contentsCss = ['/stylesheets/website.css'];
73
- }
74
-
75
- for (i = 0; i < ck_options.contentsCss.length; i++) {
76
- ck_options.contentsCss[i] = String(new Blast.Classes.RURL(ck_options.contentsCss[i], window.location));
77
- }
78
-
79
- if (!ck_options.height) {
80
- if (that.input.clientHeight > 100) {
81
- if (that.input.clientHeight > 450) {
82
- ck_options.height = 450;
83
- } else {
84
- ck_options.height = that.input.clientHeight;
85
- }
86
- } else {
87
- ck_options.height = 200;
88
- }
89
-
90
- if (ck_options.height < 200) {
91
- ck_options.height = 200;
92
- }
93
- }
94
-
95
- editor = CKEDITOR.replace(that.input, ck_options);
96
- } else {
97
- editor = CKEDITOR.inline(that.input, ck_options);
98
- }
99
-
100
- editor.on('focus', function () {
101
- editor.setReadOnly(!!that.readOnly);
102
- });
103
-
104
- this.ckeditor = editor;
105
-
106
- editor.on('change', function onCkChange() {
107
- that.setValue(editor.getData());
108
- });
109
- });
110
-
111
- /**
112
- * Make the CKEditor instance read-only
113
- *
114
- * @param {Boolean} value
115
- */
116
- TextChimeraField.setMethod(function setReadOnly(value) {
117
- var that = this;
118
- this.readOnly = value;
119
- });