diff options
| author | ryderr <r@okfoc.us> | 2014-10-07 16:12:46 -0400 |
|---|---|---|
| committer | ryderr <r@okfoc.us> | 2014-10-07 16:12:46 -0400 |
| commit | 038a4ed165df6f3ad64ce7c9375934384a9b5d43 (patch) | |
| tree | 813fbcebb018c088bf525ba44aa4419f6606abc5 /public/assets/javascripts/mx/primitives/mx.text.js | |
| parent | 06e38245987304ef6bddb1f9c3e6cad16a215209 (diff) | |
| parent | f5ab61241bf9519325a36b86ee74ab2df13a4331 (diff) | |
merge
Diffstat (limited to 'public/assets/javascripts/mx/primitives/mx.text.js')
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.text.js | 73 |
1 files changed, 47 insertions, 26 deletions
diff --git a/public/assets/javascripts/mx/primitives/mx.text.js b/public/assets/javascripts/mx/primitives/mx.text.js index 9c7af5c..1d975ec 100644 --- a/public/assets/javascripts/mx/primitives/mx.text.js +++ b/public/assets/javascripts/mx/primitives/mx.text.js @@ -3,34 +3,55 @@ MX.Text = MX.Object3D.extend({ init: function (ops) { this.type = "Text" - - var layer = new MX.Object3D('text') - layer.width = ops.width || 100 - layer.height = ops.height || 50 - layer.x = ops.x || 0 - layer.y = ops.y || 0 - layer.z = ops.z || 0 - layer.scale = ops.scale || 1 - layer.el.innerHTML = ops.value || "" - if (ops.id) layer.el.id = ops.id; - if (ops.background) layer.el.style.background = ops.background; - if (ops.color) layer.el.style.color = ops.color; - if (ops.fontSize) layer.el.style.fontSize = ops.fontSize + "px"; - this.add(layer) + this.type = "Image" + this.media = ops.media + this.width = 0 + this.height = 0 + this.x = ops.x || 0 + this.y = ops.y || 0 + this.z = ops.z || 0 + this.scale = ops.scale || 1 + this.backface = ops.backface || false - this.children.forEach(function (c, i) { - if (ops.classname) { - c.el.classList.add(ops.classname) - } - else { - } - c.el.style.backgroundRepeat = 'no-repeat' - }) + this.scale = ops.scale || 1 + this.width = ops.media.width + this.height = ops.media.height + this.x = ops.x || 0 + this.y = ops.y || 0 + this.z = ops.z || 0 + this.rotationX = ops.rotationX || 0 + this.rotationY = ops.rotationY || 0 + this.rotationZ = ops.rotationZ || 0 + + ops.className && this.el.classList.add(ops.className) + this.backface && this.el.classList.add("backface-visible") + this.el.classList.add("mx-text") + this.el.classList.add("mx-scenery") + + this.inner = document.createElement("div") + this.inner.classList.add("inner") + this.el.appendChild(this.inner) + + this.load(ops) + }, + + load: function(ops){ + var media = ops.media + if (media.color) this.el.style.color = media.color; + if (media.font) this.setFont(media.font) - this.dirty = true - this.updateChildren = true - this.update() - } + this.setText( media.description ) + }, + + setFont: function(font){ + this.inner.style.fontFamily = "'" + font.family + "',sans-serif" + this.el.style.fontSize = (2 * font.size) + "pt" + this.el.style.textAlign = font.align + }, + + setText: function(text){ + this.inner.innerHTML = marked( text || "" ) + }, }) |
