Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
*
* @module package/quiqqer/menu/bin/Controls/NavTabsVerticalSettings
*
* @require qui/controls/elements/FormList
* @require css!package/quiqqer/menu/bin/Controls/NavTabsVerticalSettings.css
*/
define('package/quiqqer/menu/bin/Controls/NavTabsVerticalSettings', [
'qui/controls/elements/FormList',
'utils/Controls',
'Locale',
'Mustache',
'text!package/quiqqer/menu/bin/Controls/NavTabsVerticalSettings.html',
'css!package/quiqqer/menu/bin/Controls/NavTabsVerticalSettings.css'
], function (QUIFormList, QUIControls, QUILocale, Mustache, template) {
"use strict";
var lg = 'quiqqer/menu';
return new Class({
Extends: QUIFormList,
Type : 'package/quiqqer/menu/bin/Controls/NavTabsVerticalSettings',
Binds: [
'$onParsed'
],
initialize: function (options) {
this.parent(options);
this.$Project = null;
this.addEvents({
onParsed: this.$onParsed
});
this.getElm().addClass('qui-controls-formlist-navTabsVerticalSettings');
this.setAttributes({
buttonText: QUILocale.get(lg, 'control.navTabsVertical.entries.addButton'),
entry : Mustache.render(template, {
'title' : QUILocale.get(lg, 'control.navTabsVertical.entries.entryTitle'),
'titleIcon' : QUILocale.get(lg, 'control.navTabsVertical.entries.entryTitleIcon'),
'titleIconColor': QUILocale.get(lg, 'control.navTabsVertical.entries.entryTitleIconColor'),
'image' : QUILocale.get(lg, 'control.navTabsVertical.entries.entryImage'),
'content' : QUILocale.get(lg, 'control.navTabsVertical.entries.entryContent')
})
});
},
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* @event on import
*
* https://dev.quiqqer.com/quiqqer/package-bricks/issues/97
*/
$onImport: function () {
// look if some value exist
var value = this.getElm().value;
if (value === '') {
this.parent();
return;
}
value = JSON.decode(value);
if (typeOf(value) !== 'array') {
this.parent();
return;
}
for (var i = 0, len = value.length; i < len; i++) {
if (typeof value[i].content !== 'undefined') {
value[i]['entryContent'] = value[i].content;
}
if (typeof value[i].title !== 'undefined') {
value[i]['entryTitle'] = value[i].title;
}
if (typeof value[i].image !== 'undefined') {
value[i]['entryImage'] = value[i].title;
}
}
this.getElm().value = JSON.encode(value);
this.parent();
},
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/**
* set the project to the control
*
* @param Project
*/
setProject: function (Project) {
this.$Project = Project;
this.$onParsed(false, this.getElm());
},
/**
* Parses QUI controls when a new entry is created
*
* Fired after (inherited) FormList has parsed the content
*
* @param event
* @param Node - The element that was previously parsed by (inherited) FormList
*/
$onParsed: function (event, Node) {
if (!this.$Project) {
return;
}
this.$executeParsing(Node);
},
/**
* Parse the editor
*
* @param Node
* @returns {Promise}
*/
$executeParsing: function (Node) {
var self = this;
return QUIControls.parse(Node).then(function () {
// Element is fully parsed so we can finally show it
Node.getElements('.quiqqer-menu-navTabsVerticalSettings-entry').show();
self.getElm().addClass('qui-controls-formlist-navTabsVerticalSettings');
var inputEditors = Node.getElements('[data-qui="controls/editors/Input"]').map(function (InnerNode) {
return QUI.Controls.getById(InnerNode.get('data-quiid'));
});
for (var i = 0, len = inputEditors.length; i < len; i++) {
if (inputEditors[i]) {
inputEditors[i].setProject(self.$Project);
}
}
});
}
});
});