summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/mx/primitives/mx.text.js
blob: b4089f34e18a2dad417a796f1f7a1a89d9c02b30 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
MX.Text = MX.Object3D.extend({

  init: function (ops) {

		this.type = "Text"

  	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.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){
    if (ops.color) this.el.style.color = ops.color;
    if (ops.fontFamily) this.el.style.fontFamily = "'" + ops.fontFamily + "',sans-serif";
    if (ops.fontSize) this.el.style.fontSize = ops.fontSize + "px";

    this.inner.innerHTML = marked( ops.media.description || "" )
  },
  
  setText: function(text){
    this.inner.innerHTML = marked( text || "" )
  },

})