diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-08-05 18:20:51 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-08-05 18:20:51 -0400 |
| commit | 8cf6d964f91354f85a2b831e2b6e313b04a72173 (patch) | |
| tree | ba543a28e5f8d29fc2ed07de520bf146fe06abf0 | |
| parent | abd50f1cfca26bb8e83275cfb443a2d678625aef (diff) | |
toolbar toggles
4 files changed, 33 insertions, 8 deletions
diff --git a/public/assets/javascripts/ui/editor/EditorToolbar.js b/public/assets/javascripts/ui/editor/EditorToolbar.js index a3abc5a..5e0da7e 100644 --- a/public/assets/javascripts/ui/editor/EditorToolbar.js +++ b/public/assets/javascripts/ui/editor/EditorToolbar.js @@ -30,6 +30,7 @@ var EditorToolbar = View.extend({ this.parent.mediaViewer.show() this.parent.mediaUpload.show() this.resetMode() + this.resetControls() }, resetMode: function(){ @@ -43,6 +44,7 @@ var EditorToolbar = View.extend({ }, resizeMedia: function(e, state){ + this.resetControls() if (! state && typeof e == "boolean") { state = e editor.permissions.assign("resize", state) @@ -59,6 +61,7 @@ var EditorToolbar = View.extend({ }, destroyMedia: function(e, state){ + this.resetControls() if (! state && typeof e == "boolean") { state = e editor.permissions.assign("destroy", state) @@ -73,11 +76,19 @@ var EditorToolbar = View.extend({ }, toggleWallpaper: function(){ - this.parent.wallpaperPicker.toggle() + var state = ! $("[data-role='toggle-wallpaper-panel']").hasClass("inuse") + this.resetMode() + $("[data-role='toggle-wallpaper-panel']").toggleClass("inuse", state) + this.parent.lightControl.hide() + this.parent.wallpaperPicker.toggle(state) }, toggleLightControl: function(){ - this.parent.lightControl.toggle() + var state = ! $("[data-role='toggle-light-control']").hasClass("inuse") + this.resetMode() + $("[data-role='toggle-light-control']").toggleClass("inuse", state) + this.parent.wallpaperPicker.hide() + this.parent.lightControl.toggle(state) }, editWallText: function(){ diff --git a/public/assets/javascripts/ui/editor/LightControl.js b/public/assets/javascripts/ui/editor/LightControl.js index 93d97ed..c3e80c2 100644 --- a/public/assets/javascripts/ui/editor/LightControl.js +++ b/public/assets/javascripts/ui/editor/LightControl.js @@ -6,12 +6,18 @@ var LightControl = View.extend({ "mousedown": "stopPropagation", }, - toggle: function(){ - this.$el.toggleClass("active"); + toggle: function(state){ + this.$el.toggleClass("active", state); // toggle the class that makes the cursor a paintbucket // $("body").removeClass("pastePaper"); }, + show: function(){ + this.toggle(true) + }, + hide: function(){ + this.toggle(false) + }, /* $("#shadow-control").on({ diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js index cb1e361..9ee441b 100644 --- a/public/assets/javascripts/ui/editor/WallpaperPicker.js +++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js @@ -23,11 +23,17 @@ var WallpaperPicker = View.extend({ wm.init() }, - toggle: function(){ - this.$el.toggleClass("active"); + toggle: function(state){ + this.$el.toggleClass("active", state); // toggle the class that makes the cursor a paintbucket // $("body").removeClass("pastePaper"); }, + show: function(){ + this.toggle(true) + }, + hide: function(){ + this.toggle(false) + }, pick: function(e){ var $swatch = $(e.currentTarget) diff --git a/public/assets/javascripts/ui/site/LayoutsModal.js b/public/assets/javascripts/ui/site/LayoutsModal.js index 4948b0e..1035474 100644 --- a/public/assets/javascripts/ui/site/LayoutsModal.js +++ b/public/assets/javascripts/ui/site/LayoutsModal.js @@ -19,6 +19,7 @@ var LayoutsIndex = View.extend({ this.$form.hide() this.$noTemplates.show() } + this.$templates.empty() data.forEach(function(room){ var $span = $("<span>") // $span.html(JSON.stringify(room)) @@ -103,7 +104,7 @@ var NewProjectModal = ModalView.extend(LayoutsIndex.prototype).extend({ action: "/api/layout", events: { - "click .templates span": 'toggleActive', + "click .templates span": 'choose', "submit form": 'choose', }, @@ -115,7 +116,8 @@ var NewProjectModal = ModalView.extend(LayoutsIndex.prototype).extend({ choose: function(e){ e && e.preventDefault() - var layout = this.$(".templates .active").data("slug") +// var layout = this.$(".templates .active").data("slug") + var layout = $(e.currentTarget).data("slug") if (! layout || ! layout.length) return window.location.pathname = "/project/new/" + layout } |
