summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/editor/EditorView.js
blob: 3773366f75f27d8276bf01525eea78274584f1b5 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var EditorView = View.extend({
	el: "#editorView",
	
	projectAction: "/api/project/",
	layoutAction: "/api/layout/",

	events: {
	},
	
	initialize: function(){
	  this.cursor = new HelpCursor ({ parent: this })
		this.toolbar = new EditorToolbar ({ parent: this })
		this.settings = new EditorSettings ({ parent: this })
		this.info = new BuilderInfo ({ parent: this })
		this.mediaViewer = new MediaViewer ({ parent: this })
		this.mediaUpload = new MediaUpload ({ parent: this })
		this.mediaEditor = new MediaEditor ({ parent: this })
		this.wallpaperPicker = new WallpaperPicker ({ parent: this })
		this.colorControl = new ColorControl ({ parent: this })
		this.textEditor = new TextEditor ({ parent: this })
		this.collaborators = new Collaborators ({ parent: this })
		this.presets = new Presets ({ parent: this })
		this.share = new ShareView ({ parent: this })
	},

	load: function(name){
		name = sanitize(name)
		$.get(this.projectAction + name, this.ready.bind(this))
	},
	
	loadLayout: function(layout){
	  if (layout == "empty") {
	    this.readyLayout({})
	    this.toolbar.toggleMap()
      return
	  }
		layout = sanitize(layout)
		$.get(this.layoutAction + layout, this.readyLayout.bind(this))
	},
	
	ready: function(data){
		$("#map").hide()

    this.data = data

		this.settings.load(data)
		this.info.load(data)
	},
	
	readyLayout: function(data){
		data.isNew = true
		$('#help-button').trigger("click")
		this.ready(data)
	},
	
	pick: function(scenery){
	  if (scenery.type == "text") {
      this.mediaEditor.hide()
      this.textEditor.pick(scenery)
	  }
	  else {
      this.textEditor.hide()
      this.mediaEditor.pick(scenery)
	  }
	},
	
	pickWall: function(wall, pos){
		this.hideExtras()
		this.wallpaperPicker.pickWall(wall)
	},
	
	hideExtras: function(){
		this.mediaEditor.hide()
		this.textEditor.hide()
		this.share.hide()
    Scenery.resize.hide()
		Scenery.hovering = false
  }

})