Commit 9df61460 authored by Michael Danielczok's avatar Michael Danielczok

feat: data-qui-options-* attributs in bricks.xml will no longer be ignored.

refactor: Some code preformance improvements in BrickEdit.js.
#104
parent d03bb128
......@@ -26,7 +26,8 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
'css!package/quiqqer/bricks/bin/BrickEdit.css'
], function (QUI, QUIPanel, QUIConfirm, BrickAreas, QUIAjax, QUILocale,
Projects, QUIFormUtils, ControlUtils, Template, Bricks) {
Projects, QUIFormUtils, ControlUtils, Template, Bricks
) {
"use strict";
var lg = 'quiqqer/bricks';
......@@ -64,14 +65,14 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
initialize: function (options) {
this.parent(options);
this.$availableBricks = [];
this.$availableBricks = [];
this.$availableSettings = [];
this.$customfields = [];
this.$loaded = false;
this.$customfields = [];
this.$loaded = false;
this.$Container = null;
this.$Editor = false;
this.$Areas = false;
this.$Editor = false;
this.$Areas = false;
this.addEvents({
onInject : this.$onInject,
......@@ -185,7 +186,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
*/
this.$availableBricks = bricks;
this.$availableSettings = brick.availableSettings;
this.$customfields = brick.customfields;
this.$customfields = brick.customfields;
this.setAttribute('data', brick);
......@@ -432,9 +433,9 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
if (attributes.areas) {
areas = attributes.areas
.replace(/^,*/, '')
.replace(/,*$/, '')
.split(',');
.replace(/^,*/, '')
.replace(/,*$/, '')
.split(',');
}
// areas
......@@ -459,11 +460,11 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
new Element('tr', {
'class': i % 2 ? 'odd' : 'even',
html : '<td>' +
'<label>' +
'<input type="checkbox" name="flexible-' + data.name + '" />' +
'<span>' + QUILocale.get(data.text[0], data.text[1]) + '</span>' +
'</label>' +
'</td>'
'<label>' +
'<input type="checkbox" name="flexible-' + data.name + '" />' +
'<span>' + QUILocale.get(data.text[0], data.text[1]) + '</span>' +
'</label>' +
'</td>'
}).inject(TBody);
}
......@@ -678,7 +679,8 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
TableExtra.setStyle('display', null);
var i, len, Row, text, Value, setting, extraFieldId;
var i, c, len, cLen, attr, Row, text, Value, setting,
extraFieldId, dataAttributes;
var self = this,
id = this.getId(),
......@@ -686,8 +688,9 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
// extra settings
for (i = 0, len = this.$availableSettings.length; i < len; i++) {
setting = this.$availableSettings[i];
setting = this.$availableSettings[i];
extraFieldId = 'extraField_' + id + '_' + i;
dataAttributes = setting['data-attributes'];
text = setting.text;
......@@ -699,11 +702,11 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
Row = new Element('tr', {
'class': i % 2 ? 'odd' : 'even',
html : '<td>' +
' <label class="quiqqer-bricks-areas" for="' + extraFieldId + '">' +
text +
' </label>' +
'</td>' +
'<td></td>'
' <label class="quiqqer-bricks-areas" for="' + extraFieldId + '">' +
text +
' </label>' +
'</td>' +
'<td></td>'
}).inject(TableBody);
if (setting.type !== 'select') {
......@@ -718,6 +721,14 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
Value.set('data-qui', setting['data-qui']);
}
if (typeof dataAttributes === 'object') {
for (attr in dataAttributes) {
if (dataAttributes.hasOwnProperty(attr)) {
Value.set(attr, dataAttributes[attr]);
}
}
}
continue;
}
......@@ -728,7 +739,7 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
}).inject(Row.getElement('td:last-child'));
for (var c = 0, clen = setting.options.length; c < clen; c++) {
for (c = 0, cLen = setting.options.length; c < cLen; c++) {
text = setting.options[c].text;
if (typeOf(setting.options[c].text) === 'array') {
......@@ -743,6 +754,14 @@ define('package/quiqqer/bricks/bin/BrickEdit', [
value: setting.options[c].value
}).inject(Value);
}
if (typeof dataAttributes === 'object') {
for (attr in dataAttributes) {
if (dataAttributes.hasOwnProperty(attr)) {
Value.set(attr, dataAttributes[attr]);
}
}
}
}
TableExtra.setStyle('display', null);
......
......@@ -623,13 +623,26 @@ class Manager
}
}
$dataAttributes = [];
foreach ($Setting->attributes as $attribute) {
if ($attribute->nodeName === 'data-qui') {
continue;
}
if (strpos($attribute->nodeName, 'data-') !== false) {
$dataAttributes[$attribute->nodeName] = trim($attribute->nodeValue);
}
}
return [
'name' => $Setting->getAttribute('name'),
'text' => QUI\Utils\DOM::getTextFromNode($Setting, false),
'type' => $Setting->getAttribute('type'),
'class' => $Setting->getAttribute('class'),
'data-qui' => $Setting->getAttribute('data-qui'),
'options' => $options
'name' => $Setting->getAttribute('name'),
'text' => QUI\Utils\DOM::getTextFromNode($Setting, false),
'type' => $Setting->getAttribute('type'),
'class' => $Setting->getAttribute('class'),
'data-qui' => $Setting->getAttribute('data-qui'),
'options' => $options,
'data-attributes' => $dataAttributes
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment