summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/blueprint/BlueprintView.js
blob: cf627d96c0673c3a68fa4481478de9bbe04c3a87 (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
var BlueprintView = View.extend({
	el: "#blueprintView",

	action: "/api/layout/",

	events: {
	},
	
	initialize: function(){
// 		this.info = new BuilderInfo ({ parent: this })
// 		this.settings = new BuilderSettings ({ parent: this })
// 		this.colorControl = new ColorControl ({ parent: this })
// 		this.cursor = new HelpCursor({ parent: this })
    this.map = this.buildMap()
		this.editor = new BlueprintEditor ({ parent: this })
		this.toolbar = new BlueprintToolbar ({ parent: this })
    this.uploader = new BlueprintUploader ({ parent: this })
    this.scaler = new BlueprintScaler ({ parent: this })
	},

	load: function(name){
		if (! name || name == "new") {
// 			this.ready({ isNew: true, _id: "new", name: "" })
      this.uploader.load()
			return
		}
		
		name = sanitize(name)
		
		$.get(this.action + name, this.ready.bind(this))
	},
	
	buildMap: function(){
	  // i forget if this has to be global
    map = new Map ({
      type: "ortho",
      el: document.querySelector("#orthographic"),
      width: window.innerWidth/2,
      height: window.innerHeight,
      zoom: -2,
      zoom_min: -6.2,
      zoom_max: 1,
    })
    map.ui.add_tool("arrow", new ArrowTool)
    map.ui.add_tool("polyline", new PolylineTool)
    map.ui.add_tool("ortho-polyline", new OrthoPolylineTool)
    map.ui.add_tool("eraser", new EraserTool)
    map.ui.add_tool("position", new PositionTool)
    map.ui.placing = false
    return map
	},
	
	ready: function(data){
// 		this.settings.load(data)
// 		this.info.load(data)
	},
	
	hideExtras: function(){
	},
	
	useFloorplan: function(media){
	  this.editor.loadFloorplan(media)
	},

	pickWall: function(wall, pos){
	},

})