summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/ui')
-rw-r--r--public/assets/javascripts/ui/editor/EditorSettings.js15
-rw-r--r--public/assets/javascripts/ui/editor/WallpaperPicker.js29
2 files changed, 39 insertions, 5 deletions
diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js
index 026607a..b319404 100644
--- a/public/assets/javascripts/ui/editor/EditorSettings.js
+++ b/public/assets/javascripts/ui/editor/EditorSettings.js
@@ -18,6 +18,7 @@ var EditorSettings = FormView.extend({
"click [data-role='clear-project']": 'clear',
"click [data-role='destroy-project']": 'destroy',
"click [data-role='toggle-map']": 'toggleMap',
+ "click [data-role='view-project']": 'viewProject',
"click #startText": "setStartPosition",
"click #moveText": "confirmStartPosition",
"click #confirmText": "setStartPosition",
@@ -217,11 +218,25 @@ var EditorSettings = FormView.extend({
this.isVisible = true
},
+ viewAfterSave: false,
+ viewProject: function(e){
+ e.preventDefault()
+ Minotaur.unwatch(this)
+ Minotaur.hide()
+ this.viewAfterSave = true
+ this.save()
+ },
+
success: function(data){
this.$id.val(data._id)
this.$name.val(data.name)
this.action = this.updateAction
+ if (this.viewAfterSave) {
+ window.location.pathname = "/project/" + data.slug
+ return
+ }
+
Minotaur.unwatch(this)
Minotaur.hide()
diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js
index e2aaeb7..3640d6d 100644
--- a/public/assets/javascripts/ui/editor/WallpaperPicker.js
+++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js
@@ -5,6 +5,7 @@ var WallpaperPicker = UploadView.extend({
mediaTag: "wallpaper",
createAction: "/api/media/new",
uploadAction: "/api/media/upload",
+ destroyAction: "/api/media/destroy",
events: {
"contextmenu": 'contextmenu',
@@ -51,8 +52,6 @@ var WallpaperPicker = UploadView.extend({
this.load()
}
}
- // toggle the class that makes the cursor a paintbucket
- // $("body").removeClass("pastePaper")
},
load: function(){
@@ -78,6 +77,7 @@ var WallpaperPicker = UploadView.extend({
var swatch = document.createElement("div")
swatch.className = "swatch"
swatch.style.backgroundImage = "url(" + media.url + ")"
+ swatch.setAttribute("data-id", media._id)
this.$swatches.append(swatch)
this.$swatches.show()
this.$(".txt").hide()
@@ -104,23 +104,41 @@ var WallpaperPicker = UploadView.extend({
},
pick: function(e){
- app.tube('cancel-wallpaper')
var $swatch = $(e.currentTarget)
- this.follow( e, $swatch.css('background-image') )
- this.parent.presets.modified = true
+ if (Scenery.nextWallpaper == "none") {
+ var _id = $swatch[0].getAttribute("data-id")
+ $swatch.remove()
+ this.destroy(_id, function(){})
+ }
+ else {
+ app.tube('cancel-wallpaper')
+ this.follow( e, $swatch.css('background-image') )
+ this.parent.presets.modified = true
+ }
},
remove: function(e){
if (Scenery.nextWallpaper) {
+ // remove red class to the wallpaper
Scenery.nextWallpaper = null
app.tube('cancel-wallpaper')
}
else {
+ // add red class to the wallpaper
this.follow( e, "none" )
$(".floatingSwatch").addClass("scissors")
+ this.$el.addClass("deleteArmed")
}
},
+ destroy: function(_id, cb){
+ $.ajax({
+ type: "delete",
+ url: this.destroyAction,
+ data: { _id: _id, _csrf: $("[name=_csrf]").val() }
+ }).complete(cb || function(){})
+ },
+
contextmenu: function(e){
if (Scenery.nextWallpaper) {
e.preventDefault()
@@ -159,6 +177,7 @@ var WallpaperPicker = UploadView.extend({
app.off('cancel-wallpaper', _hideCursor)
$floatingSwatch.removeClass("scissors").hide()
$(".floodMessage").hide()
+ base.$el.removeClass("deleteArmed")
}
function _floodRoom (e) {
if (e.keyCode == 13) {