diff options
Diffstat (limited to 'public/assets/javascripts/ui/editor')
8 files changed, 126 insertions, 28 deletions
diff --git a/public/assets/javascripts/ui/editor/ColorControl.js b/public/assets/javascripts/ui/editor/ColorControl.js index 9ab2623..54a6a2e 100644 --- a/public/assets/javascripts/ui/editor/ColorControl.js +++ b/public/assets/javascripts/ui/editor/ColorControl.js @@ -47,7 +47,12 @@ var ColorControl = View.extend({ $swatch.css("background-color","rgb(" + color + ")") $swatch.data('color', color) this.$colors.append($swatch) - }.bind(this)) + }.bind(this)) + + if ($.browser.mozilla) { + $("#floor-color").parent().hide() + $("#ceiling-color").parent().hide() + } }, modes: [ "wall", "outline", "floor", "ceiling" ], 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/EditorToolbar.js b/public/assets/javascripts/ui/editor/EditorToolbar.js index 277718a..a5ad2dd 100644 --- a/public/assets/javascripts/ui/editor/EditorToolbar.js +++ b/public/assets/javascripts/ui/editor/EditorToolbar.js @@ -59,7 +59,6 @@ var EditorToolbar = View.extend({ this.resetControls() this.toggleMap(false) this.parent.mediaViewer.show() - this.parent.mediaUpload.show() }, resetMode: function(){ diff --git a/public/assets/javascripts/ui/editor/EditorView.js b/public/assets/javascripts/ui/editor/EditorView.js index 4a2f712..50d3650 100644 --- a/public/assets/javascripts/ui/editor/EditorView.js +++ b/public/assets/javascripts/ui/editor/EditorView.js @@ -15,6 +15,7 @@ var EditorView = View.extend({ this.info = new BuilderInfo ({ parent: this }) this.mediaViewer = new MediaViewer ({ parent: this }) this.mediaUpload = new MediaUpload ({ parent: this }) + this.mediaTumblr = new MediaTumblr ({ parent: this }) this.mediaEditor = new MediaEditor ({ parent: this }) this.wallpaperPicker = new WallpaperPicker ({ parent: this }) this.colorControl = new ColorControl ({ parent: this }) diff --git a/public/assets/javascripts/ui/editor/MediaTumblr.js b/public/assets/javascripts/ui/editor/MediaTumblr.js new file mode 100644 index 0000000..47419ae --- /dev/null +++ b/public/assets/javascripts/ui/editor/MediaTumblr.js @@ -0,0 +1,53 @@ + +var MediaTumblr = ModalView.extend({ + el: "#tumblrUpload", + + events: { + 'mousedown': "stopPropagation", + "keydown .url": "enterSubmit", + "click .exampleTumblr": "loadExample", + }, + + initialize: function(opt){ + this.__super__.initialize.call(this) + this.parent = opt.parent + this.$url = this.$(".url") + }, + + show: function(){ + this.$el.addClass("active") + this.$url.val("") + }, + + hide: function(){ + this.$el.removeClass("active") + }, + + enterSubmit: function(e){ + e.stopPropagation() + if (e.keyCode == 13) { + e.preventDefault() + var url = this.$tumblrUrl.val() + this.loadTumblr(url) + } + }, + + loadTumblr: function(url){ + Parser.tumblr(url, function(media_list){ + console.log(media_list) + this.parent.mediaViewer.$foundMediaContainer.empty() + media_list.reverse().forEach(function(media){ + this.parent.mediaViewer.add(media, this.parent.mediaViewer.$foundMediaContainer) + }.bind(this)) + }.bind(this)) + }, + + loadExample: function(e){ + e.preventDefault() + var name = $(e.currentTarget).html() + var url = "http://" + name + ".tumblr.com/" + this.$url.val(url) + this.loadTumblr(url) + }, + +})
\ No newline at end of file diff --git a/public/assets/javascripts/ui/editor/MediaUpload.js b/public/assets/javascripts/ui/editor/MediaUpload.js index 9ae90e3..d09e38c 100644 --- a/public/assets/javascripts/ui/editor/MediaUpload.js +++ b/public/assets/javascripts/ui/editor/MediaUpload.js @@ -1,6 +1,6 @@ var MediaUpload = UploadView.extend({ - el: ".fileUpload", + el: "#fileUpload", createAction: "/api/media/new", uploadAction: "/api/media/upload", diff --git a/public/assets/javascripts/ui/editor/MediaViewer.js b/public/assets/javascripts/ui/editor/MediaViewer.js index 029252d..2ae5104 100644 --- a/public/assets/javascripts/ui/editor/MediaViewer.js +++ b/public/assets/javascripts/ui/editor/MediaViewer.js @@ -38,11 +38,11 @@ var MediaViewer = ModalView.extend({ this.$deleteMedia = this.$("#deleteMedia") this.$viewMore = this.$(".viewMore") this.$noMedia = this.$(".noMedia") - - this.$tumblrUrl = this.$("#tumblr-url") }, + mode: "user", wallpaperToggle: function(){ + this.mode = "wallpaper" this.$wallpaperMedia.addClass("active") this.$foundMedia.addClass("inactive") this.$myMedia.addClass("inactive").removeClass('active') @@ -51,29 +51,34 @@ var MediaViewer = ModalView.extend({ }, foundToggle: function(){ + this.mode = "found" this.$wallpaperMedia.removeClass("active") this.$foundMedia.addClass("active") this.$myMedia.addClass("inactive").removeClass('active') this.$("a").removeClass("active") this.$foundToggle.addClass("active") + this.parent.mediaUpload.hide() + this.parent.mediaTumblr.show() }, userToggle: function(){ + this.mode = "user" this.$wallpaperMedia.removeClass("active") this.$foundMedia.removeClass("active") this.$myMedia.removeClass("inactive").addClass('active') this.$("a").removeClass("active") this.$userToggle.addClass("active") + this.parent.mediaUpload.show() + this.parent.mediaTumblr.hide() }, show: function(){ if (! this.loaded) { this.load() - this.loadTrending() + // this.loadTrending() } else { - this.parent.cursor.message("media") - this.__super__.show.call(this) + this.reallyShow() } }, @@ -81,13 +86,26 @@ var MediaViewer = ModalView.extend({ this.__super__.hide.call(this) this.deleteArmed(false) this.parent.mediaUpload.hide() + this.parent.mediaTumblr.hide() this.parent.cursor.message('start') }, + + reallyShow: function(){ + this.__super__.show.call(this) + if (this.mode == "user") { + this.userToggle() + } + else { + this.foundToggle() + } + this.parent.cursor.message("media") + }, load: function(){ $.get("/api/media/user", { offset: this.offset, limit: this.perPage }, this.populate.bind(this)) }, - + +/* loadTrending: function(){ var trending_imagery = [ 'https://d1ycxz9plii3tb.cloudfront.net/post_images/52ec0e20c9dc24f1d8000067/large.jpg', @@ -121,6 +139,7 @@ var MediaViewer = ModalView.extend({ if (img.complete && ! loaded) { img.onload() } }.bind(this)) }, +*/ randomize: function(){ var $divs = this.$(".active .container").find(".mediaContainer").toArray() @@ -157,8 +176,7 @@ var MediaViewer = ModalView.extend({ } else { this.loaded = true - this.parent.cursor.message("media") - this.__super__.show.call(this) + this.reallyShow() } }, @@ -294,16 +312,4 @@ var MediaViewer = ModalView.extend({ _followCursor(e) }, - enterTumblrUrl: function(e){ - e.stopPropagation() - if (e.keyCode !== 13) { return } - var url = this.$tumblrUrl.val() - Parser.tumblr(url, function(media_list){ - console.log(media_list) - this.$foundMediaContainer.empty() - media_list.reverse().forEach(function(media){ - this.add(media, this.$foundMediaContainer) - }.bind(this)) - }.bind(this)) - }, }) 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) { |
