Commit 8fb30b9a authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

listbox_field: add a <pre> tag if parameter value is multilines to save the formatting

Also fix linter
parent aac8b6c1
/*globals console, window, document, rJS, RSVP, loopEventListener, i18n, Handlebars $*/
/*globals console, window, document, rJS, loopEventListener, i18n */
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, document, rJS, RSVP, Handlebars) {
(function (window, document, rJS) {
"use strict";
var gadget_klass = rJS(window);
......@@ -15,21 +15,26 @@
return {};
})
.declareMethod("render", function (options) {
var gadget = this, a, value;
var gadget = this, a, pre, value;
return gadget.getElement()
.push(function (element) {
value = options.value;
if (options.value &&
(options.value.startsWith("http://") ||
options.value.startsWith("https://"))) {
a = document.createElement('a');
a.setAttribute("href", options.value);
a.setAttribute("target", "_blank");
a.innerText = options.value;
value = a.outerHTML;
if (options.value) {
if (options.value.startsWith("http://") ||
options.value.startsWith("https://")) {
a = document.createElement('a');
a.setAttribute("href", options.value);
a.setAttribute("target", "_blank");
a.innerText = options.value;
value = a.outerHTML;
} else if (options.value.indexOf("\n") !== -1) {
pre = document.createElement('pre');
pre.innerText = options.value;
value = pre.outerHTML;
}
}
element.innerHTML = value;
return element;
});
});
}(window, document, rJS, RSVP, Handlebars));
\ No newline at end of file
}(window, document, rJS));
\ No newline at end of file
......@@ -99,7 +99,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget SlapOS Site invoice State</string> </value>
<value> <string>Gadget SlapOS Label Listbox Field</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -216,7 +216,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value>
<value> <string>superthomas</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.40941.62497.477</string> </value>
<value> <string>972.17178.36781.34560</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1519141899.05</float>
<float>1544636507.97</float>
<string>UTC</string>
</tuple>
</state>
......
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