1 | import sourceAutocomplete from './sourceAutocomplete' |
||
2 | import sourceOption from './sourceOption' |
||
3 | import {abeExtend, User, cmsData} from '../../../' |
||
4 | |||
5 | export function getAttributes(params) { |
||
6 | var attributes = '' |
||
7 | if (params.key != null) |
||
8 | attributes += `id="${params.key}" data-id="${params.key}"` |
||
0 ignored issues
–
show
|
|||
9 | if (params.value != null) attributes += ` value="${params.value}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
10 | if (params['max-length'] != null) |
||
11 | attributes += ` data-maxlength="${params['max-length']}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
12 | if (params.reload != null) attributes += ` reload="${params.reload}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
13 | if (params.order != null) attributes += ` tabIndex="${params.order}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
14 | if (params.required != null) |
||
15 | attributes += ` data-required="${params.required}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
16 | if (params.display != null) attributes += ` data-display="${params.display}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
17 | if (params.visible != null) attributes += ` data-visible="${params.visible}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
18 | if (params.autocomplete != null) |
||
19 | attributes += ` data-autocomplete="${params.autocomplete}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
20 | if (params.placeholder != null) |
||
21 | attributes += ` placeholder="${params.placeholder}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
22 | if (params.thumbs != null) attributes += ` data-size="${params.thumbs}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
23 | if (params.toolbar != null) attributes += ` data-toolbar="${params.toolbar}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
24 | if (params.multiple != null) |
||
25 | attributes += ` data-multiple="${params.multiple}"` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
26 | if (params.disabled != null) attributes += ` ${params.disabled}` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
27 | return attributes |
||
28 | } |
||
29 | |||
30 | export function getLabel(params) { |
||
31 | var desc = params.desc + (params.required ? ' *' : '') |
||
32 | return `<label class="control-label" for="${params.key}" > |
||
33 | ${desc} |
||
34 | </label>` |
||
35 | } |
||
36 | |||
37 | export function hint(params) { |
||
38 | if (params.hint) { |
||
39 | return `<p class="abe-hint help-block"> |
||
40 | <span class="glyphicon glyphicon-info-sign"></span> <em>${params.hint}</em> |
||
41 | </p>` |
||
42 | } |
||
43 | |||
44 | return '' |
||
45 | } |
||
46 | |||
47 | export function createInputSource(attributes, inputClass, params) { |
||
48 | var inputSource = `<div class="parent-${params.type} parent-${params.key}" data-parent="${params.key}">` |
||
49 | var lastValues |
||
50 | |||
51 | if ( |
||
52 | (params.autocomplete != null && params.autocomplete === 'true') || |
||
53 | (params.multiple != null && params.multiple === 'multiple') |
||
54 | ) { |
||
55 | if(cmsData.sql.getSourceType(params.sourceString) === "url") lastValues = params.source |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
56 | else lastValues = JSON.stringify(params.source).replace(/\'/g, '"e;') |
||
57 | inputSource += '<div class="autocomplete-result-wrapper">' |
||
58 | if ( |
||
59 | params.autocomplete != null && |
||
60 | params.autocomplete === 'true' && |
||
61 | params.prefill === 'true' |
||
62 | ) { |
||
63 | inputSource += `<div class="autocomplete-refresh" value='' |
||
64 | data-autocomplete-refresh="true" |
||
65 | data-autocomplete-refresh-sourcestring="${params.sourceString}" |
||
66 | data-autocomplete-refresh-prefill-quantity="${params[ |
||
67 | 'prefill-quantity' |
||
68 | ]}" |
||
69 | data-autocomplete-refresh-key="${params.key}" |
||
70 | data-autocomplete-data-display="${params.display}" > |
||
71 | <span class="glyphicon glyphicon-refresh"></span> |
||
72 | </div>` |
||
73 | } |
||
74 | Array.prototype.forEach.call(params.value, val => { |
||
75 | inputSource += sourceAutocomplete(val, params) |
||
76 | }) |
||
77 | inputSource += '</div>' |
||
78 | } |
||
79 | |||
80 | if (params.autocomplete != null && params.autocomplete === 'true') { |
||
81 | inputSource += `<input value="" type="text" autocomplete="off" data-value='${lastValues}' ${attributes} class="${inputClass}" />` |
||
0 ignored issues
–
show
|
|||
82 | } else { |
||
83 | // lastValues = JSON.stringify(params.value).replace(/\'/g, '"e;') |
||
84 | inputSource += `<select ${attributes} class="${inputClass}">` |
||
85 | |||
86 | // if (!params.required) inputSource += '<option value=\'\'></option>' |
||
87 | var options = '' |
||
88 | if ( |
||
89 | typeof params.source === 'object' && |
||
90 | Object.prototype.toString.call(params.source) === '[object Array]' |
||
91 | ) { |
||
92 | Array.prototype.forEach.call(params.source, val => { |
||
93 | options += sourceOption(val, params) |
||
94 | }) |
||
95 | } else { |
||
96 | options += sourceOption(params.source, params) |
||
97 | } |
||
98 | |||
99 | var defaultValueSelected = 'selected=selected' |
||
100 | if (options.indexOf('selected') > -1) { |
||
101 | defaultValueSelected = '' |
||
102 | } |
||
103 | if (params.required) |
||
104 | inputSource += `<option value="" disabled ${defaultValueSelected}>Select ${params.desc.toLowerCase()}...</option>` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
105 | if (!params.required) |
||
106 | inputSource += `<option value="" ${defaultValueSelected}></option>` |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
107 | inputSource += options |
||
108 | |||
109 | inputSource += '</select>' |
||
110 | } |
||
111 | inputSource += `${hint(params)}</div>` |
||
112 | |||
113 | return inputSource |
||
114 | } |
||
115 | |||
116 | export function createInputRich(attributes, inputClass, params) { |
||
117 | var buttons = [ |
||
118 | { |
||
119 | icon: 'bold', |
||
120 | title: 'Bold (Ctrl+B)', |
||
121 | action: 'bold', |
||
122 | param: '', |
||
123 | hotkey: 'b', |
||
124 | key: 'b' |
||
125 | }, |
||
126 | { |
||
127 | icon: 'ti-Italic', |
||
128 | title: 'Italic (Ctrl+I)', |
||
129 | action: 'italic', |
||
130 | param: '', |
||
131 | hotkey: 'i' |
||
132 | }, |
||
133 | { |
||
134 | icon: 'ti-underline', |
||
135 | title: 'Underline (Ctrl+U)', |
||
136 | action: 'underline', |
||
137 | param: '', |
||
138 | hotkey: 'u' |
||
139 | }, |
||
140 | { |
||
141 | icon: 'strikethrough', |
||
142 | title: 'Strikethrough', |
||
143 | action: 'strikethrough', |
||
144 | param: '', |
||
145 | key: 's' |
||
146 | }, |
||
147 | { |
||
148 | icon: 'ti-paint-bucket', |
||
149 | title: 'Text color', |
||
150 | action: 'forecolor', |
||
151 | param: '', |
||
152 | popup: 'color' |
||
153 | }, |
||
154 | { |
||
155 | icon: 'ti-paint-bucket bg', |
||
156 | title: 'Background color', |
||
157 | action: 'highlight', |
||
158 | param: '', |
||
159 | popup: 'color' |
||
160 | }, |
||
161 | {icon: 'ti-align-left', title: 'Left', action: 'align', param: 'left'}, |
||
162 | { |
||
163 | icon: 'ti-align-center', |
||
164 | title: 'Center', |
||
165 | action: 'align', |
||
166 | param: 'center' |
||
167 | }, |
||
168 | {icon: 'ti-align-right', title: 'Right', action: 'align', param: 'right'}, |
||
169 | { |
||
170 | icon: 'ti-align-justify', |
||
171 | title: 'Justify', |
||
172 | action: 'align', |
||
173 | param: 'justify' |
||
174 | }, |
||
175 | { |
||
176 | icon: 'ti-text ti-text-sub', |
||
177 | title: 'Subscript', |
||
178 | action: 'subscript', |
||
179 | param: '' |
||
180 | }, |
||
181 | { |
||
182 | icon: 'ti-text ti-text-sup', |
||
183 | title: 'Superscript', |
||
184 | action: 'superscript', |
||
185 | param: '' |
||
186 | }, |
||
187 | {icon: 'ti-shift-right-alt', title: 'Indent', action: 'indent', param: ''}, |
||
188 | { |
||
189 | icon: 'ti-shift-left-alt', |
||
190 | title: 'Outdent', |
||
191 | action: 'indent', |
||
192 | param: 'outdent' |
||
193 | }, |
||
194 | {icon: 'ti-list', title: 'Unordered list', action: 'list', param: ''}, |
||
195 | { |
||
196 | icon: 'ti-list-ol', |
||
197 | title: 'Ordered list', |
||
198 | action: 'list', |
||
199 | param: 'ordered' |
||
200 | }, |
||
201 | { |
||
202 | icon: 'ti-eraser', |
||
203 | title: 'Remove format', |
||
204 | action: 'removeFormat', |
||
205 | param: '' |
||
206 | }, |
||
207 | { |
||
208 | icon: 'ti-link', |
||
209 | title: 'Add link', |
||
210 | action: 'insertLink', |
||
211 | param: '', |
||
212 | popup: 'link' |
||
213 | }, |
||
214 | { |
||
215 | icon: 'console', |
||
216 | title: 'Code style', |
||
217 | action: 'code', |
||
218 | param: '', |
||
219 | key: '{code}' |
||
220 | }, |
||
221 | { |
||
222 | icon: 'ti-image', |
||
223 | title: 'media', |
||
224 | action: 'media', |
||
225 | param: '', |
||
226 | popup: 'image' |
||
227 | }, |
||
228 | { |
||
229 | icon: 'ti-face-smile', |
||
230 | title: 'smiley', |
||
231 | action: 'smiley', |
||
232 | param: '', |
||
233 | popup: 'smiley' |
||
234 | } |
||
235 | ] |
||
236 | |||
237 | var selects = [ |
||
238 | { |
||
239 | name: 'Formating', |
||
240 | id: 'format', |
||
241 | options: [ |
||
242 | {name: 'Heading 1', regexp: '<h1>$1</h1>'}, |
||
243 | {name: 'Heading 2', regexp: '<h2>$1</h2>'}, |
||
244 | {name: 'Heading 3', regexp: '<h3>$1</h3>'}, |
||
245 | {name: 'Heading 4', regexp: '<h4>$1</h4>'}, |
||
246 | {name: 'Heading 5', regexp: '<h5>$1</h5>'}, |
||
247 | {name: 'Heading 6', regexp: '<h6>$1</h6>'}, |
||
248 | {name: 'Paragraph', regexp: '<p>$1</p>'} |
||
249 | ] |
||
250 | }, |
||
251 | { |
||
252 | name: 'Font', |
||
253 | id: 'font', |
||
254 | options: [ |
||
255 | { |
||
256 | name: 'Georgia', |
||
257 | regexp: '<span style="font-family:Georgia;">$1</span>' |
||
258 | }, |
||
259 | {name: 'serif', regexp: '<span style="font-family:serif;">$1</span>'}, |
||
260 | { |
||
261 | name: 'Helvetica', |
||
262 | regexp: '<span style="font-family:Helvetica;">$1</span>' |
||
263 | }, |
||
264 | {name: 'Times', regexp: '<span style="font-family:Times;">$1</span>'}, |
||
265 | { |
||
266 | name: 'Times New Roman', |
||
267 | regexp: '<span style="font-family:Times New Roman;">$1</span>' |
||
268 | }, |
||
269 | {name: 'Arial', regexp: '<span style="font-family:Arial;">$1</span>'}, |
||
270 | { |
||
271 | name: 'Arial Black', |
||
272 | regexp: '<span style="font-family:Arial Black;">$1</span>' |
||
273 | }, |
||
274 | { |
||
275 | name: 'Verdana', |
||
276 | regexp: '<span style="font-family:Verdana;">$1</span>' |
||
277 | }, |
||
278 | { |
||
279 | name: 'monospace', |
||
280 | regexp: '<span style="font-family:monospace;">$1</span>' |
||
281 | }, |
||
282 | { |
||
283 | name: 'fantasy', |
||
284 | regexp: '<span style="font-family:fantasy;">$1</span>' |
||
285 | } |
||
286 | ] |
||
287 | }, |
||
288 | { |
||
289 | name: 'Font size', |
||
290 | id: 'fontsize', |
||
291 | options: [ |
||
292 | {name: '5', regexp: '<span style="font-size:5px;">$1</span>'}, |
||
293 | {name: '6', regexp: '<span style="font-size:6px;">$1</span>'}, |
||
294 | {name: '7', regexp: '<span style="font-size:7px;">$1</span>'}, |
||
295 | {name: '8', regexp: '<span style="font-size:8px;">$1</span>'}, |
||
296 | {name: '9', regexp: '<span style="font-size:9px;">$1</span>'}, |
||
297 | {name: '10', regexp: '<span style="font-size:10px;">$1</span>'}, |
||
298 | {name: '11', regexp: '<span style="font-size:11px;">$1</span>'}, |
||
299 | {name: '12', regexp: '<span style="font-size:12px;">$1</span>'}, |
||
300 | {name: '14', regexp: '<span style="font-size:14px;">$1</span>'}, |
||
301 | {name: '16', regexp: '<span style="font-size:16px;">$1</span>'}, |
||
302 | {name: '18', regexp: '<span style="font-size:18px;">$1</span>'}, |
||
303 | {name: '20', regexp: '<span style="font-size:20px;">$1</span>'}, |
||
304 | {name: '22', regexp: '<span style="font-size:22px;">$1</span>'}, |
||
305 | {name: '24', regexp: '<span style="font-size:24px;">$1</span>'}, |
||
306 | {name: '26', regexp: '<span style="font-size:26px;">$1</span>'}, |
||
307 | {name: '28', regexp: '<span style="font-size:28px;">$1</span>'}, |
||
308 | {name: '36', regexp: '<span style="font-size:36px;">$1</span>'}, |
||
309 | {name: '48', regexp: '<span style="font-size:48px;">$1</span>'}, |
||
310 | {name: '72', regexp: '<span style="font-size:72px;">$1</span>'} |
||
311 | ] |
||
312 | } |
||
313 | ] |
||
314 | |||
315 | if (params.toolbar !== '*') params.toolbar = params.toolbar.split(',') |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
316 | var inputRich = `<div class="parent-${params.type} parent-${params.key}" data-parent="${params.key}"> |
||
317 | <div class="wysiwyg-container rich"> |
||
318 | <div class="wysiwyg-toolbar wysiwyg-toolbar-top">` |
||
319 | |||
320 | selects.forEach(function(select) { |
||
321 | if (params.toolbar === '*' || params.toolbar.indexOf(select.id) > -1) { |
||
322 | inputRich += `<div class="dropdown"> |
||
323 | <button id="${select.id}" class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
||
324 | ${select.name} |
||
325 | <span class="caret"></span> |
||
326 | </button> |
||
327 | <ul class="dropdown-menu" aria-labelledby="${select.id}">` |
||
328 | select.options.forEach(function(option) { |
||
329 | inputRich += `<li> |
||
330 | <a href='#' class='wysiwyg-dropdown-option' data-regexp='${option.regexp}'> |
||
331 | ${option.name} |
||
332 | </a> |
||
333 | </li>` |
||
334 | }) |
||
335 | inputRich += `</ul> |
||
336 | </div>` |
||
337 | } |
||
338 | }) |
||
339 | |||
340 | buttons.forEach(function(button) { |
||
341 | if (params.toolbar === '*' || params.toolbar.indexOf(button.action) > -1) { |
||
342 | var hotkey = button.hotkey != null ? `hotkey="${button.hotkey}"` : '' |
||
343 | var popup = button.popup != null ? `data-popup="${button.popup}"` : '' |
||
344 | if (button.popup === 'image') button.action = 'insertImage' |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
345 | if (button.action === 'list') button.action = 'insertList' |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
346 | inputRich += `<a class="wysiwyg-toolbar-icon parent-${button.icon}" |
||
347 | data-action="${button.action}" |
||
348 | data-param="${button.param}" |
||
349 | title="${button.title}" |
||
350 | ${hotkey} |
||
351 | ${popup} |
||
352 | href="#"> |
||
353 | <span class="glyphicon theme-icon ${button.icon}">${button.key |
||
354 | ? button.key |
||
355 | : ''}</span> |
||
356 | </a>` |
||
357 | } |
||
358 | }) |
||
359 | |||
360 | inputRich += `</div> |
||
361 | <textarea class="${inputClass} form-rich" ${attributes} rows="4">${params.value}</textarea> |
||
362 | </div> |
||
363 | ${hint(params)} |
||
364 | </div>` |
||
365 | return inputRich |
||
366 | } |
||
367 | |||
368 | export function createInputFile(attributes, inputClass, params) { |
||
369 | return `<div class="parent-${params.type} parent-${params.key}" data-parent="${params.key}"> |
||
370 | <div class="input-group file-upload"> |
||
371 | <div class="input-group-addon image"> |
||
372 | <span class="glyphicon glyphicon-file" aria-hidden="true"></span> |
||
373 | </div> |
||
374 | <input type="text" ${attributes} class="${inputClass} file-input" /> |
||
375 | |||
376 | <div class="input-group-btn"> |
||
377 | <span class="border"> |
||
378 | <div class="upload-wrapper"> |
||
379 | <input class="form-control" ${attributes} name="${params.key}" type="file" title="upload file"/> |
||
380 | <span class="percent"> |
||
381 | <span class="glyphicon glyphicon-upload" aria-hidden="true"></span> |
||
382 | </span> |
||
383 | </div> |
||
384 | </span> |
||
385 | <span class="image-icon"></span> |
||
386 | </div> |
||
387 | |||
388 | </div> |
||
389 | <div class="input-error"></div> |
||
390 | ${hint(params)} |
||
391 | </div>` |
||
392 | } |
||
393 | |||
394 | export function createInputTextarea(attributes, inputClass, params) { |
||
395 | return `<div class="parent-${params.type} parent-${params.key}" data-parent="${params.key}"> |
||
396 | <textarea class="${inputClass}" ${attributes} rows="4">${params.value}</textarea> |
||
397 | ${hint(params)} |
||
398 | </div>` |
||
399 | } |
||
400 | |||
401 | export function createInputLink(attributes, inputClass, params) { |
||
402 | return `<div class="parent-${params.type} parent-${params.key}" data-parent="${params.key}"> |
||
403 | <div class="input-group"> |
||
404 | <div class="input-group-addon link"> |
||
405 | <span class="glyphicon glyphicon-link" aria-hidden="true"></span> |
||
406 | </div> |
||
407 | <input type="text" ${attributes} class="${inputClass}" /> |
||
408 | </div> |
||
409 | ${hint(params)} |
||
410 | </div>` |
||
411 | } |
||
412 | |||
413 | export function createInputImage(attributes, inputClass, params) { |
||
414 | return `<div class="parent-${params.type} parent-${params.key}" data-parent="${params.key}"> |
||
415 | <div class="input-group img-upload"> |
||
416 | <div class="input-group-addon image"> |
||
417 | <span class="glyphicon glyphicon-picture" aria-hidden="true"></span> |
||
418 | </div> |
||
419 | <input type="text" ${attributes} class="${inputClass} file-input" /> |
||
420 | <div class="input-group-btn"> |
||
421 | <span class="border"> |
||
422 | <div class="upload-wrapper"> |
||
423 | <input class="form-control" ${attributes} name="${params.key}" type="file" title="upload an image"/> |
||
424 | <span class="percent"> |
||
425 | <span class="glyphicon glyphicon-upload" aria-hidden="true"></span> |
||
426 | </span> |
||
427 | </div> |
||
428 | </span> |
||
429 | <span class="image-icon"></span> |
||
430 | </div> |
||
431 | </div> |
||
432 | <div class="input-error"> |
||
433 | </div> |
||
434 | ${hint(params)} |
||
435 | </div>` |
||
436 | } |
||
437 | |||
438 | export function createInputText(attributes, inputClass, params) { |
||
439 | if (params.editable) |
||
440 | return `<div class="parent-${params.type} parent-${params.key}" data-parent="${params.key}"> |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
441 | <div class="input-group"> |
||
442 | <div class="input-group-addon"> |
||
443 | <span class="glyphicon glyphicon-font" aria-hidden="true"></span> |
||
444 | </div> |
||
445 | <input type="text" ${attributes} class="${inputClass}" /> |
||
446 | </div> |
||
447 | ${hint(params)} |
||
448 | </div>` |
||
449 | else |
||
450 | return `<div class="parent-${params.type} parent-${params.key}" data-parent="${params.key}"> |
||
451 | <div> |
||
452 | <input type="hidden" ${attributes} class="${inputClass}" /> |
||
453 | </div> |
||
454 | </div>` |
||
455 | } |
||
456 | |||
457 | /** |
||
458 | * Print form input based on input data type {Textarea | text | meta | link | image | ...} |
||
459 | * && add appropriate attributs / data-attributs |
||
460 | * @return {String|html} input / input group ... |
||
461 | */ |
||
462 | export function printInput(params, root) { |
||
463 | params = abeExtend.hooks.instance.trigger('beforeEditorInput', params) |
||
464 | let userWorkflow = root.user != null ? root.user.role.workflow : '' |
||
465 | let inputClass = 'form-control form-abe' |
||
466 | let res |
||
467 | if (params.editable) { |
||
468 | res = `<div class="form-group" data-precontrib-templates="${params.precontribTemplate}">` |
||
469 | res += getLabel(params) |
||
470 | } else { |
||
471 | res = `<div data-precontrib-templates="${params.precontribTemplate}">` |
||
472 | } |
||
473 | |||
474 | if (params.value === null && params.defaultValue != null) |
||
475 | params.value = params.defaultValue |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
476 | params.placeholder = params.placeholder || '' |
||
477 | params.value = params.value || '' |
||
478 | |||
479 | if (typeof params.value === 'string') |
||
480 | params.value = params.value.replace(/\"/g, '"') |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
481 | if (!(params.toolbar != null)) params.toolbar = '*' |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
482 | |||
483 | params.disabled = '' |
||
484 | if ( |
||
485 | params.tab !== 'slug' && |
||
486 | !User.utils.isUserAllowedOnRoute( |
||
487 | userWorkflow, |
||
488 | `/abe/operations/edit/${params.status}` |
||
489 | ) |
||
490 | ) { |
||
491 | params.disabled = 'disabled="disabled"' |
||
492 | } |
||
493 | let attributes = getAttributes(params) |
||
494 | |||
495 | if (params.source != null) { |
||
496 | params.multiple = |
||
497 | (params['max-length'] == null || params['max-length'] > 1) && |
||
498 | params.source.length > 0 |
||
499 | ? 'multiple' |
||
500 | : '' |
||
501 | params.disabled = params.source.length <= 0 ? 'disabled' : '' |
||
502 | res += createInputSource(getAttributes(params), inputClass, params) |
||
503 | } else if (params.type.indexOf('rich') >= 0) |
||
504 | res += createInputRich(attributes, inputClass, params) |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
505 | else if (params.type.indexOf('file') >= 0) |
||
506 | res += createInputFile(attributes, inputClass, params) |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
507 | else if (params.type.indexOf('textarea') >= 0) |
||
508 | res += createInputTextarea(attributes, inputClass, params) |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
509 | else if (params.type.indexOf('link') >= 0) |
||
510 | res += createInputLink(attributes, inputClass, params) |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
511 | else if (params.type.indexOf('image') >= 0) |
||
512 | res += createInputImage(attributes, inputClass, params) |
||
0 ignored issues
–
show
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later. Consider: if (a > 0)
b = 42;
If you or someone else later decides to put another statement in, only the first statement will be executed. if (a > 0)
console.log("a > 0");
b = 42;
In this case the statement if (a > 0) {
console.log("a > 0");
b = 42;
}
ensures that the proper code will be executed conditionally no matter how many statements are added or removed.
Loading history...
|
|||
513 | else res += createInputText(attributes, inputClass, params) |
||
514 | |||
515 | res += '</div>' |
||
516 | res = abeExtend.hooks.instance.trigger('afterEditorInput', res, params) |
||
517 | |||
518 | return res |
||
519 | } |
||
520 |
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.
Consider:
If you or someone else later decides to put another statement in, only the first statement will be executed.
In this case the statement
b = 42
will always be executed, while the logging statement will be executed conditionally.ensures that the proper code will be executed conditionally no matter how many statements are added or removed.