summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/builder/BuilderInfo.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/ui/builder/BuilderInfo.js')
-rw-r--r--public/assets/javascripts/ui/builder/BuilderInfo.js27
1 files changed, 24 insertions, 3 deletions
diff --git a/public/assets/javascripts/ui/builder/BuilderInfo.js b/public/assets/javascripts/ui/builder/BuilderInfo.js
index 0bf2338..196eca6 100644
--- a/public/assets/javascripts/ui/builder/BuilderInfo.js
+++ b/public/assets/javascripts/ui/builder/BuilderInfo.js
@@ -13,6 +13,7 @@ var BuilderInfo = View.extend({
"change [name=units]": 'changeUnits',
"change [name=resolution]": 'changeResolution',
"change [name=viewHeight]": 'changeViewHeight',
+ "click [data-role=destroy-room]": 'destroy',
},
initialize: function(opt){
@@ -25,8 +26,11 @@ var BuilderInfo = View.extend({
this.$units = this.$("[name=units]")
this.$viewHeight = this.$("[name=viewHeight]")
this.$unitName = this.$(".unitName")
+ this.$noSelection = this.$(".no-selection")
+ this.$settings = this.$(".setting")
app.on("builder-pick-room", this.pick.bind(this))
- app.on("builder-destroy-room", this.destroy.bind(this))
+ app.on("builder-destroy-room", this.hide.bind(this))
+ app.on("builder-pick-nothing", this.deselect.bind(this))
},
load: function(data){
@@ -36,6 +40,8 @@ var BuilderInfo = View.extend({
},
toggle: function(state){
+ this.$settings.toggle( !! this.room )
+ this.$noSelection.toggle( ! this.room )
this.$el.toggleClass("active", state)
},
@@ -43,7 +49,8 @@ var BuilderInfo = View.extend({
this.toggle(true)
},
- hide: function(){
+ hide: function(){
+ this.room = null
this.toggle(false)
},
@@ -58,8 +65,22 @@ var BuilderInfo = View.extend({
this.$y.unitVal( room.rect.y.a )
this.show()
},
+
+ deselect: function(){
+ this.room = null
+ this.toggle(true)
+ },
+
+ destroy: function(){
+ UndoStack.push({
+ type: "destroy-room",
+ undo: this.room.copy(),
+ redo: { id: this.room.id },
+ })
+
+ Rooms.remove(this.room)
+ app.tube("builder-destroy-room", this.room)
- destroy: function(room){
this.room = null
this.hide()
},