diff options
Diffstat (limited to 'public/assets/javascripts/ui/editor')
5 files changed, 62 insertions, 17 deletions
diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index 13a6f60..d6a79fb 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -130,7 +130,7 @@ var EditorSettings = FormView.extend({ this.$name.val(data.name) this.action = this.updateAction - window.history.pushState(null, document.title, "/project/" + data.slug) + window.history.pushState(null, document.title, "/project/" + data.slug + "/edit") }, }) 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/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index cd8fb63..e3a8f2e 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -11,6 +11,9 @@ var MediaEditor = FormView.extend({ "change [name=autoplay]": "setAutoplay", "change [name=loop]": "setLoop", "change [name=mute]": "setMute", + "change [name=width]": 'changeWidth', + "change [name=height]": 'changeHeight', + "change [name=units]": 'changeUnits', "click [data-role=destroy-media]": "destroy", }, @@ -22,8 +25,8 @@ var MediaEditor = FormView.extend({ this.$description = this.$("[name=description]") // image fields - this.$widthDimension = this.$("[name=width]") - this.$heightDimension = this.$("[name=height]") + this.$width = this.$("[name=width]") + this.$height = this.$("[name=height]") this.$units = this.$("[name=units]") // video fields @@ -55,16 +58,14 @@ var MediaEditor = FormView.extend({ this.$name.val(media.title) this.$description.val(media.description) + this.setDimensions() + this.$units.val( "ft" ) switch (media.type) { case "image": this.$(".image").show() this.$(".video").hide() - - this.$widthDimension.val( Number(media.widthDimension) || "" ) - this.$heightDimension.val( Number(media.heightDimension) || "" ) - this.$units.val( media.units || "cm" ) - + break case "youtube": @@ -113,18 +114,39 @@ var MediaEditor = FormView.extend({ this.scenery.mute(checked) }, + setDimensions: function(){ + this.$width.unitVal( Number(this.scenery.dimensions.a * this.scenery.scale) || "" ) + this.$height.unitVal( Number(this.scenery.dimensions.b * this.scenery.scale) || "" ) + }, + changeWidth: function(e){ + e.stopPropagation() + this.scenery.set_scale( this.$width.unitVal() / this.scenery.dimensions.a ) + this.setDimensions() + }, + changeHeight: function(e){ + e.stopPropagation() + this.scenery.set_scale( this.$height.unitVal() / this.scenery.dimensions.b ) + this.setDimensions() + }, + changeUnits: function(){ + app.units = this.$units.val() + this.$('.units').resetUnitVal() + }, + bind: function(scenery){ this.scenery = scenery this.scenery.mx.bound = true }, unbind: function(){ - this.scenery.mx.bound = false - this.scenery = null + if (this.scenery && this.scenery.mx) { + this.scenery.mx.bound = false + } + this.scenery = null }, destroy: function(){ - ConfirmModal.confirm("Are you sure you want to this media?", function(){ + ConfirmModal.confirm("Are you sure you want delete to this media?", function(){ var scenery = this.scenery this.hide() Scenery.remove(scenery.id) 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) |
