@@ -53,55 +53,53 @@ Elm.Native.Text.make = function(elm) {
54 function toText(str) { return Utils.txt(properEscape(JS.fromString(str))); }
54 function toText(str) { return Utils.txt(properEscape(JS.fromString(str))); }
56− function addTag(tag) {
56+ function height(px, text) {
57− return function(text) {
57+ return { style: 'font-size:' + px + 'px;', text:text }
58− return Utils.txt('<' + tag + '>' + text + '</' + tag + '>');
62− function addStyle(style, value, text) {
63− return Utils.txt("<span style='" + style + ":" + value + "'>" + text + "</span>");
66 function typeface(name, text) {
59 function typeface(name, text) {
67− return addStyle('font-family', JS.fromString(name), text);
60+ return { style: 'font-family:' + name + ';', text:text }
69 function monospace(text) {
62 function monospace(text) {
70− return addStyle('font-family', 'monospace', text);
63+ return { style: 'font-family:monospace;', text:text }
72− function size(px, text) { return addStyle('font-size', px + 'px', text) }
65+ function italic(text) {
73− var header = addTag('h1');
66+ return { style: 'font-style:italic;', text:text }
74− function height(h, text) { return addStyle('font-size', h+'px', text) }
75− function italic(text) { return addStyle('font-style', 'italic', text) }
76− var bold = addTag('b');
78− function extract(c) {
79− if (c._3 === 1) { return 'rgb(' + c._0 + ', ' + c._1 + ', ' + c._2 + ')'; }
80− return 'rgba(' + c._0 + ', ' + c._1 + ', ' + c._2 + ', ' + c._3 + ')';
82− function color(c, text) {
68+ function bold(text) {
83− return addStyle('color', extract(c), text);
69+ return { style: 'font-weight:bold;', text:text }
71+ function link(href, text) {
72+ return { href: toText(href), text:text };
74+ function underline(text) {
75+ return { line: ' underline', text:text };
77+ function overline(text) {
78+ return { line: ' overline', text:text };
85− function underline(text) { return addStyle('text-decoration', 'underline', text) }
86− function overline(text) { return addStyle('text-decoration', 'overline', text) }
87 function strikeThrough(text) {
80 function strikeThrough(text) {
88− return addStyle('text-decoration', 'line-through', text);
81+ return { line: ' line-through', text:text };
90− function link(href, text) {
84+ function color(c, text) {
91− return Utils.txt("<a href='" + toText(href) + "'>" + text + "</a>");
85+ var color = (c._3 === 1)
86+ ? ('rgb(' + c._0 + ', ' + c._1 + ', ' + c._2 + ')')
87+ : ('rgba(' + c._0 + ', ' + c._1 + ', ' + c._2 + ', ' + c._3 + ')');
88+ return { style: 'color:' + color + ';', text:text };
94 function position(align) {
91 function position(align) {
95− return function(text) {
92+ function create(text) {
96 var raw = {
93 var raw = {
97 ctor:'RawHtml',
94 ctor:'RawHtml',
98− html: '<span style="text-align:' + align + ';">' + text + '</span>',
95+ html: Utils.makeText('text-align:' + align + ';', text),
99 guid: null,
96 guid: null,
100 args: [],
97 args: [],
102 var pos = A2(Utils.htmlHeight, 0, raw);
99 var pos = A2(Utils.htmlHeight, 0, raw);
103 return A3(Element.newElement, pos._0, pos._1, raw);
100 return A3(Element.newElement, pos._0, pos._1, raw);
107 function markdown(text, guid) {
105 function markdown(text, guid) {
@@ -123,18 +121,18 @@ Elm.Native.Text.make = function(elm) {
123 return A3(Element.newElement, pos._0, pos._1, raw);
121 return A3(Element.newElement, pos._0, pos._1, raw);
124+ var text = position('left');
126 function asText(v) {
125 function asText(v) {
127− return position('left')(monospace(toText(show(v))));
126+ return text(monospace(toText(show(v))));
130 function plainText(v) {
129 function plainText(v) {
131− return position('left')(toText(v));
130+ return text(toText(v));
134 return elm.Native.Text.values = {
133 return elm.Native.Text.values = {
135 toText: toText,
134 toText: toText,
138 height : F2(height),
136 height : F2(height),
139 italic : italic,
137 italic : italic,
140 bold : bold,
138 bold : bold,
@@ -149,7 +147,7 @@ Elm.Native.Text.make = function(elm) {
149 justified : position('justify'),
147 justified : position('justify'),
150 centered : position('center'),
148 centered : position('center'),
151 righted : position('right'),
149 righted : position('right'),
152− text : position('left'),
150+ text : text,
153 plainText : plainText,
151 plainText : plainText,
154 markdown : markdown,
152 markdown : markdown,