summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/mx/primitives/mx.text.js
blob: 9c7af5c88f1c0316b9c97cd1670742611bbb1cb4 (plain)
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
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.children.forEach(function (c, i) {
      if (ops.classname) {
        c.el.classList.add(ops.classname)
      }
      else {
      }
      c.el.style.backgroundRepeat = 'no-repeat'
    })

    this.dirty = true
    this.updateChildren = true
    this.update()
  }

})