diff options
Diffstat (limited to 'public/assets/javascripts/ui')
| -rw-r--r-- | public/assets/javascripts/ui/editor/EditorToolbar.js | 42 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/editor/EditorView.js | 1 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/editor/LightControl.js | 34 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/editor/Presets.js | 59 |
4 files changed, 78 insertions, 58 deletions
diff --git a/public/assets/javascripts/ui/editor/EditorToolbar.js b/public/assets/javascripts/ui/editor/EditorToolbar.js index 49decc2..4f12a7b 100644 --- a/public/assets/javascripts/ui/editor/EditorToolbar.js +++ b/public/assets/javascripts/ui/editor/EditorToolbar.js @@ -7,8 +7,8 @@ var EditorToolbar = View.extend({ "click [data-role='toggle-map-view']": 'toggleMap', "click [data-role='toggle-project-settings']": 'toggleSettings', "click [data-role='open-media-viewer']": 'openMediaViewer', -// "click [data-role='resize-media']": 'resizeMedia', - "click [data-role='destroy-media']": 'destroyMedia', + "click [data-role='toggle-presets']": 'togglePresets', +// "click [data-role='destroy-media']": 'destroyMedia', "click [data-role='toggle-wallpaper-panel']": 'toggleWallpaper', "click [data-role='toggle-light-control']": 'toggleLightControl', "click [data-role='toggle-text-editor']": 'toggleTextEditor', @@ -26,6 +26,7 @@ var EditorToolbar = View.extend({ toggleSettings: function(){ // this.resetMode() this.parent.textEditor.hide() + this.parent.presets.hide() this.parent.lightControl.hide() this.parent.wallpaperPicker.hide() this.parent.mediaEditor.hide() @@ -52,6 +53,7 @@ var EditorToolbar = View.extend({ $(".inuse").removeClass("inuse") this.parent.textEditor.hide() this.parent.wallpaperPicker.hide() + this.parent.presets.hide() this.parent.lightControl.hide() this.parent.settings.hide() }, @@ -62,28 +64,6 @@ var EditorToolbar = View.extend({ editor.permissions.add("resize") editor.permissions.remove("destroy") }, - -// resizeMedia: function(e, state){ -// this.resetControls() -// if (! state && typeof e == "boolean") { -// state = e -// editor.permissions.assign("resize", state) -// } -// else { -// state = editor.permissions.toggle("resize") -// } -// ! state && editor.permissions.assign("move", true) -// $(".inuse").removeClass("inuse") -// $("[data-role='resize-media']").toggleClass("inuse", state) -// if (state) { -// if (this.parent.mediaEditor.scenery) { -// Scenery.resize.show( this.parent.mediaEditor.scenery ) -// } -// } -// else { -// Scenery.resize.hide() -// } -// }, destroyMedia: function(e, state){ this.resetControls() @@ -113,6 +93,7 @@ var EditorToolbar = View.extend({ this.parent.lightControl.hide() this.parent.textEditor.hide() this.parent.settings.hide() + this.parent.presets.hide() this.parent.wallpaperPicker.toggle(state) }, @@ -124,6 +105,7 @@ var EditorToolbar = View.extend({ this.parent.wallpaperPicker.hide() this.parent.textEditor.hide() this.parent.settings.hide() + this.parent.presets.hide() this.parent.lightControl.toggle(state) }, @@ -135,9 +117,21 @@ var EditorToolbar = View.extend({ this.parent.wallpaperPicker.hide() this.parent.lightControl.hide() this.parent.settings.hide() + this.parent.presets.hide() this.parent.textEditor.toggle(state) }, + togglePresets: function(){ + var state = ! $("[data-role='toggle-presets']").hasClass("inuse") + this.resetMode() + $("[data-role='toggle-presets']").toggleClass("inuse", state) + this.parent.mediaEditor.hide() + this.parent.wallpaperPicker.hide() + this.parent.textEditor.hide() + this.parent.settings.hide() + this.parent.lightControl.hide() + this.parent.presets.toggle(state) + }, }) var editor = new function(){ diff --git a/public/assets/javascripts/ui/editor/EditorView.js b/public/assets/javascripts/ui/editor/EditorView.js index f60b149..b35c872 100644 --- a/public/assets/javascripts/ui/editor/EditorView.js +++ b/public/assets/javascripts/ui/editor/EditorView.js @@ -18,6 +18,7 @@ var EditorView = View.extend({ this.lightControl = new LightControl ({ parent: this }) this.textEditor = new TextEditor ({ parent: this }) this.collaborators = new Collaborators ({ parent: this }) + this.presets = new Presets ({ parent: this }) }, load: function(name){ diff --git a/public/assets/javascripts/ui/editor/LightControl.js b/public/assets/javascripts/ui/editor/LightControl.js index 6100762..3eb2861 100644 --- a/public/assets/javascripts/ui/editor/LightControl.js +++ b/public/assets/javascripts/ui/editor/LightControl.js @@ -10,7 +10,6 @@ var LightControl = View.extend({ "input #brightness-control": "updateBrightness", "input #outline-hue": "updateShadow", "input #wall-hue": "updateShadow", - "click .presets span": "selectPreset", }, initialize: function(){ @@ -115,39 +114,6 @@ var LightControl = View.extend({ this.setMode(mode) }, - presets: { - wireframe: { - wall: [255,255,255], - outline: [0,0,0], - floor: [246,246,246], - ceiling: [255,255,255], - }, - shaded: { - wall: [205,205,204], - outline: [0,0,0], - floor: [109,116,106], - ceiling: [159,163,157], - }, - pfunk: { - wall: [255,63,78], - outline: [255,246,0], - floor: [255,255,0], - ceiling: [225,118,252], - }, - inverse: { - wall: [0,0,0], - outline: [255,255,255], - floor: [0,0,0], - ceiling: [0,0,0], - }, - }, - selectPreset: function(e){ - var preset = $(e.currentTarget).data('preset') - if (! this.presets[preset]) return - this.load(this.presets[preset]) - $(e.currentTarget).addClass('active') - }, - beginBrightness: function(){ this.begin() $(window).one("mouseup", this.finalize.bind(this)) diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js new file mode 100644 index 0000000..a7e92b6 --- /dev/null +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -0,0 +1,59 @@ +var Presets = View.extend({ + el: "#presets", + + events: { + "click .presets span": "selectPreset", + }, + + presets: { + wireframe: { + wall: [255,255,255], + outline: [0,0,0], + floor: [246,246,246], + ceiling: [255,255,255], + }, + shaded: { + wall: [205,205,204], + outline: [0,0,0], + floor: [109,116,106], + ceiling: [159,163,157], + }, + pfunk: { + wall: [255,63,78], + outline: [255,246,0], + floor: [255,255,0], + ceiling: [225,118,252], + }, + inverse: { + wall: [0,0,0], + outline: [255,255,255], + floor: [0,0,0], + ceiling: [0,0,0], + }, + }, + + initialize: function(opt){ + this.parent = opt.parent + }, + + toggle: function(state){ + this.$el.toggleClass("active", state); + }, + + show: function(){ + this.toggle(true) + }, + + hide: function(){ + this.toggle(false) + }, + + selectPreset: function(e){ + var preset = $(e.currentTarget).data('preset') + if (! this.presets[preset]) return + this.parent.lightControl.load(this.presets[preset]) + this.$(".active").removeClass('active') + $(e.currentTarget).addClass('active') + }, + +})
\ No newline at end of file |
