From f80ca0ef62785cf72176598b695a1a291dd38e91 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 29 Sep 2014 16:47:34 -0400 Subject: fix error in color picker --- public/assets/javascripts/ui/editor/LightControl.js | 6 +++--- public/assets/javascripts/ui/site/LayoutsModal.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/ui/editor/LightControl.js b/public/assets/javascripts/ui/editor/LightControl.js index d975180..96f6942 100644 --- a/public/assets/javascripts/ui/editor/LightControl.js +++ b/public/assets/javascripts/ui/editor/LightControl.js @@ -247,11 +247,11 @@ var LabColorPicker = function (parent, w, h) { var var_G = ( RGB[1] / 255 ) // G from 0 to 255 var var_B = ( RGB[2] / 255 ) // B from 0 to 255 - if ( var_R > 0.04045 ) var_R = ( ( var_R + 0.055 ) / 1.055 ) ^ 2.4 + if ( var_R > 0.04045 ) var_R = Math.pow( ( var_R + 0.055 ) / 1.055, 2.4) else var_R = var_R / 12.92 - if ( var_G > 0.04045 ) var_G = ( ( var_G + 0.055 ) / 1.055 ) ^ 2.4 + if ( var_G > 0.04045 ) var_G = Math.pow( ( var_G + 0.055 ) / 1.055, 2.4) else var_G = var_G / 12.92 - if ( var_B > 0.04045 ) var_B = ( ( var_B + 0.055 ) / 1.055 ) ^ 2.4 + if ( var_B > 0.04045 ) var_B = Math.pow( ( var_B + 0.055 ) / 1.055, 2.4) else var_B = var_B / 12.92 var_R = var_R * 100 diff --git a/public/assets/javascripts/ui/site/LayoutsModal.js b/public/assets/javascripts/ui/site/LayoutsModal.js index f109ec3..bfc3dec 100644 --- a/public/assets/javascripts/ui/site/LayoutsModal.js +++ b/public/assets/javascripts/ui/site/LayoutsModal.js @@ -57,7 +57,7 @@ var ProjectsModal = ModalView.extend(LayoutsIndex.prototype).extend({ this.$(".templates .active").removeClass("active") var $layout = $(e.currentTarget) $layout.addClass("active") - + // actually do window.location.pathname = "/project/" + $layout.data("slug") + "/edit" }, -- cgit v1.2.3-70-g09d2 From f378a60b4ce813216eaba03bd266559c56c4a54d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 29 Sep 2014 16:54:49 -0400 Subject: Close room settings modal when image is clicked Activate Close button in menu when settings modal is open --- public/assets/javascripts/ui/editor/EditorSettings.js | 8 ++++++-- public/assets/javascripts/ui/editor/EditorView.js | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index 2a3929a..0a3364b 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -96,8 +96,12 @@ var EditorSettings = FormView.extend({ }.bind(this)) }, - toggle: function(){ - this.$el.toggleClass("active") + toggle: function(state){ + var state = typeof state == 'boolean' ? state : ! this.$el.hasClass("active") + this.$el.toggleClass("active", state) + + $(".inuse").removeClass("inuse") + $("[data-role='toggle-project-settings']").toggleClass("inuse", state) }, enterSubmit: function (e) { diff --git a/public/assets/javascripts/ui/editor/EditorView.js b/public/assets/javascripts/ui/editor/EditorView.js index e11f189..22e32ca 100644 --- a/public/assets/javascripts/ui/editor/EditorView.js +++ b/public/assets/javascripts/ui/editor/EditorView.js @@ -46,6 +46,7 @@ var EditorView = View.extend({ hideExtras: function(){ this.mediaEditor.hide() + this.settings.toggle(false) } }) -- cgit v1.2.3-70-g09d2 From 69e52fdf43ac9314d23b3c2016f42a944156e6f0 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 29 Sep 2014 17:12:44 -0400 Subject: hide scissors --- public/assets/javascripts/ui/editor/EditorSettings.js | 10 ++++++++++ public/assets/javascripts/ui/editor/WallpaperPicker.js | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index 0a3364b..de47be4 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -41,6 +41,16 @@ var EditorSettings = FormView.extend({ else { this.parent.lightControl.loadDefaults() } + + if (data.walls) { + data.walls.some(function(wall){ + if (wall.background !== "none") { + this.parent.wallpaperPicker.$remove.show() + return true + } + return false + }.bind(this)) + } if (data.isNew) { this.$name.val( "Room " + moment().format("DD/MM/YYYY ha") ) diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js index bcae3c5..8048288 100644 --- a/public/assets/javascripts/ui/editor/WallpaperPicker.js +++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js @@ -13,6 +13,8 @@ var WallpaperPicker = UploadView.extend({ initialize: function(){ this.__super__.initialize.call(this) this.$swatches = this.$(".swatches") + this.$remove = this.$(".wallpaperRemove") + this.$remove.hide() }, loaded: false, @@ -36,7 +38,9 @@ var WallpaperPicker = UploadView.extend({ populate: function(data){ console.log(data) this.loaded = true - data && data.forEach(this.add.bind(this)) + if (data && data.length) { + data.forEach(this.add.bind(this)) + } this.toggle(true) }, @@ -46,6 +50,7 @@ var WallpaperPicker = UploadView.extend({ swatch.className = "swatch" swatch.style.backgroundImage = "url(" + media.url + ")" this.$swatches.append(swatch) + this.$swatches.show() }, toggle: function (state) { @@ -69,6 +74,7 @@ var WallpaperPicker = UploadView.extend({ pick: function(e){ var $swatch = $(e.currentTarget) this.follow( e, $swatch.css('background-image') ) + this.$remove.show() }, remove: function(e){ -- cgit v1.2.3-70-g09d2 From c8bfd290434ab06cd6b8b1536b9c317eba7e6630 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 29 Sep 2014 17:33:18 -0400 Subject: if no media, dont show “delete media” button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/javascripts/ui/editor/EditorSettings.js | 7 ++-- public/assets/javascripts/ui/editor/MediaViewer.js | 37 +++++++++++++++++----- .../javascripts/ui/editor/WallpaperPicker.js | 1 - views/controls/editor/media-drawer.ejs | 2 +- 4 files changed, 34 insertions(+), 13 deletions(-) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index de47be4..f74b535 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -17,8 +17,8 @@ var EditorSettings = FormView.extend({ }, initialize: function(opt){ - this.parent = opt.parent - this.__super__.initialize.call(this) + this.parent = opt.parent + this.__super__.initialize.call(this) this.$id = this.$("[name=_id]") this.$csrf = this.$("[name=_csrf]") @@ -110,7 +110,6 @@ var EditorSettings = FormView.extend({ var state = typeof state == 'boolean' ? state : ! this.$el.hasClass("active") this.$el.toggleClass("active", state) - $(".inuse").removeClass("inuse") $("[data-role='toggle-project-settings']").toggleClass("inuse", state) }, @@ -183,6 +182,8 @@ var EditorSettings = FormView.extend({ window.history.pushState(null, document.title, "/project/" + data.slug + "/edit") this.parent.data = data + + this.toggle(false) }, }) diff --git a/public/assets/javascripts/ui/editor/MediaViewer.js b/public/assets/javascripts/ui/editor/MediaViewer.js index 7cfa863..436c0cb 100644 --- a/public/assets/javascripts/ui/editor/MediaViewer.js +++ b/public/assets/javascripts/ui/editor/MediaViewer.js @@ -6,23 +6,33 @@ var MediaViewer = ModalView.extend({ events: { 'click .foundToggle': "foundToggle", - 'click .yourMedia': "userToggle", + 'click .userToggle': "userToggle", 'click #deleteMedia': "deleteArmed", 'click .mediaContainer': "pick", }, + initialize: function(opt){ + this.__super__.initialize.call(this) + this.parent = opt.parent + this.$foundMedia = this.$(".foundMedia") + this.$myMedia = this.$(".myMedia") + this.$foundToggle = this.$(".foundToggle") + this.$userToggle = this.$(".userToggle") + this.$deleteMedia = this.$("#deleteMedia") + }, + foundToggle: function(){ - this.$(".foundMedia").addClass("active"); - this.$(".myMedia").addClass("inactive"); + this.foundMedia.addClass("active"); + this.myMedia.addClass("inactive"); this.$("a").removeClass("active"); - this.$(".foundToggle").addClass("active"); + this.foundToggle.addClass("active"); }, userToggle: function(){ - this.$(".foundMedia").removeClass("active"); - this.$(".myMedia").removeClass("inactive"); + this.foundMedia.removeClass("active"); + this.myMedia.removeClass("inactive"); this.$("a").removeClass("active"); - this.$(".yourMedia").addClass("active"); + this.userToggle.addClass("active"); }, show: function(){ @@ -46,7 +56,12 @@ var MediaViewer = ModalView.extend({ populate: function(data){ this.loaded = true - data && data.forEach(this.add.bind(this)) + if (data && data.length) { + data.forEach(this.add.bind(this)) + } + else { + this.$deleteMedia.hide() + } this.__super__.show.call(this) }, @@ -78,6 +93,7 @@ var MediaViewer = ModalView.extend({ $span.append(image) this.$(".myMedia").prepend($span) + this.$deleteMedia.show() }, deleteIsArmed: false, @@ -112,6 +128,11 @@ var MediaViewer = ModalView.extend({ if (this.deleteIsArmed) { this.destroy(media._id) $target.remove() + + if ($(".myMedia .mediaContainer").length == 0) { + this.$deleteMedia.hide() + this.deleteArmed(false) + } return } diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js index 8048288..0dd2921 100644 --- a/public/assets/javascripts/ui/editor/WallpaperPicker.js +++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js @@ -36,7 +36,6 @@ var WallpaperPicker = UploadView.extend({ }, populate: function(data){ - console.log(data) this.loaded = true if (data && data.length) { data.forEach(this.add.bind(this)) diff --git a/views/controls/editor/media-drawer.ejs b/views/controls/editor/media-drawer.ejs index 241164f..d73a3ef 100644 --- a/views/controls/editor/media-drawer.ejs +++ b/views/controls/editor/media-drawer.ejs @@ -16,7 +16,7 @@
X -

Your MediaFound Media


+

Your MediaFound Media


delete media?

-- cgit v1.2.3-70-g09d2 From e8bdd7f9f64ad07aed8097c2072863fcdbcb1c3e Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 29 Sep 2014 17:43:49 -0400 Subject: write titles under layout names, in the layout picker as well as the project picker --- public/assets/javascripts/ui/site/LayoutsModal.js | 1 + public/assets/stylesheets/app.css | 12 ++++++++++++ 2 files changed, 13 insertions(+) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/ui/site/LayoutsModal.js b/public/assets/javascripts/ui/site/LayoutsModal.js index bfc3dec..1bfc6cb 100644 --- a/public/assets/javascripts/ui/site/LayoutsModal.js +++ b/public/assets/javascripts/ui/site/LayoutsModal.js @@ -25,6 +25,7 @@ var LayoutsIndex = View.extend({ // $span.html(JSON.stringify(room)) $span.data("slug", room.slug) $span.css("background-image", "url(" + room.photo + ")") + $span.attr("data-name", room.name) this.$templates.append($span) }.bind(this)) diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index a7a3517..cadd11d 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -497,6 +497,18 @@ iframe.embed { display: inline-block; margin: 4vw; border:1px solid white; + position: relative; +} + +.templates span:after { + content: attr(data-name); + position: absolute; + top: 100%; + width: 100%; + left: 0; + background: #fff; + padding: 5px; + border-top: 1px solid black; } .templates span:hover { -- cgit v1.2.3-70-g09d2 From cc5393678f3acd8ff16af6863a903b1064502895 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 29 Sep 2014 17:55:27 -0400 Subject: fix spinning --- public/assets/javascripts/ui/site/ProjectList.js | 4 ++-- views/projects/list-projects.ejs | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/ui/site/ProjectList.js b/public/assets/javascripts/ui/site/ProjectList.js index ee1b89f..993d805 100644 --- a/public/assets/javascripts/ui/site/ProjectList.js +++ b/public/assets/javascripts/ui/site/ProjectList.js @@ -4,8 +4,8 @@ var ProjectList = View.extend({ el: ".projectList", events: { - "mouseenter td.border": 'spinOn', - "mouseleave td.border": 'spinOff', + "mouseenter .room": 'spinOn', + "mouseleave .room": 'spinOff', }, initialize: function(){ diff --git a/views/projects/list-projects.ejs b/views/projects/list-projects.ejs index 3801e30..537d409 100644 --- a/views/projects/list-projects.ejs +++ b/views/projects/list-projects.ejs @@ -4,15 +4,7 @@ [[ projects.forEach(function(project, i) { ]] - [[ if (i % 4 == 1) { ]] - - [[ } ]] - - [[ if (i == 0) { ]] - - [[ } else { ]] - [[ } ]] [[ if (String(user._id) == String(project.user_id)) { ]]
edit
-- cgit v1.2.3-70-g09d2 From c4344861a58fa67a28d02dd05f68eef8981282aa Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 29 Sep 2014 18:37:36 -0400 Subject: fix media stuff saving --- public/assets/javascripts/ui/editor/MediaEditor.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index 750cf41..2d32d4f 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -142,9 +142,15 @@ var MediaEditor = FormView.extend({ }, unbind: function(){ - if (this.scenery && this.scenery.mx) { - this.scenery.mx.bound = false - this.scenery.mx.el.classList.remove("picked") + if (this.scenery) { + this.scenery.media.title = this.$name.val() + this.scenery.media.description = this.$description.val() + Minotaur.watch( app.router.editorView.settings ) + + if (this.scenery.mx) { + this.scenery.mx.bound = false + this.scenery.mx.el.classList.remove("picked") + } } this.scenery = null }, -- cgit v1.2.3-70-g09d2 From de93d0404ccb9ea7c9598293c7543620c8a85bb8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 29 Sep 2014 18:49:20 -0400 Subject: cursor on color picker --- .../assets/javascripts/ui/editor/LightControl.js | 32 ++++++++++++---------- public/assets/stylesheets/app.css | 15 ++++++++-- views/controls/editor/light-control.ejs | 3 ++ 3 files changed, 33 insertions(+), 17 deletions(-) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/ui/editor/LightControl.js b/public/assets/javascripts/ui/editor/LightControl.js index 96f6942..9c3cdd3 100644 --- a/public/assets/javascripts/ui/editor/LightControl.js +++ b/public/assets/javascripts/ui/editor/LightControl.js @@ -4,8 +4,7 @@ var LightControl = View.extend({ events: { "mousedown": "stopPropagation", - "click .swatch": "clickSwatch", - "click label": "clickLabel", + "click .color-swatches span": "select", "input #shadow-control": "updateShadow", "mousedown #brightness-control": "beginBrightness", "input #brightness-control": "updateBrightness", @@ -14,8 +13,10 @@ var LightControl = View.extend({ }, initialize: function(){ + this.colorPicker = new LabColorPicker(this, 180, 180) - this.$el.prepend( this.colorPicker.canvas ) + this.$("#color-picker").append( this.colorPicker.canvas ) + this.$("#color-picker").append( this.colorPicker.cursor ) this.$swatches = this.$(".swatch") this.$labels = this.$(".swatch + label") @@ -100,21 +101,16 @@ var LightControl = View.extend({ setMode: function (mode) { var color, brightness this.mode = mode - this.$swatches.removeClass("selected") - this.$labels.removeClass("selected") - this.$swatch[ mode ].addClass("selected") + this.$(".active").removeClass("active") + this.$swatch[ mode ].parent().addClass("active") color = Walls.colors[ mode ] - this.$(".swatch.selected").next("label").addClass("selected") this.labColor = this.colorPicker.load(color) this.$brightnessControl.val( this.labColor[0] ) }, - clickLabel: function(e){ - $(e.currentTarget).prev(".swatch").trigger("click") - }, - clickSwatch: function(e){ - var mode = $(e.currentTarget).data('mode') + select: function(e){ + var mode = $('.swatch', e.currentTarget).data('mode') this.setMode(mode) }, @@ -138,8 +134,8 @@ var LabColorPicker = function (parent, w, h) { var imageData = ctx.createImageData(w,h) var data = imageData.data -// var cursor = this.cursor = document.createElement("div") -// cursor.className = "colorPickerCursor" + var cursor = this.cursor = document.createElement("div") + cursor.className = "colorPickerCursor" canvas.width = w canvas.height = h @@ -182,6 +178,7 @@ var LabColorPicker = function (parent, w, h) { var x = mix( i/ww, a_range[0], a_range[1] ) var y = mix( j/hh, b_range[0], b_range[1] ) var rgb = xyz2rgb(hunterlab2xyz(val, x, y)).map(Math.round) + this.moveCursor(x,y) parent.pick( rgb, [val,x,y] ) } this.load = function(rgba){ @@ -189,10 +186,15 @@ var LabColorPicker = function (parent, w, h) { var val = clamp( Lab[0], L_range[0], L_range[1] ) var x = mix( norm(Lab[1], a_range[0], a_range[1]), 0, ww ) var y = mix( norm(Lab[2], b_range[0], b_range[1]), 0, hh ) - // move the cursor + + this.moveCursor(x,y) this.setLab(Lab) return Lab } + this.moveCursor = function(x,y){ + cursor.style.left = x + "px" + cursor.style.top = y + "px" + } this.paint = function() { val = clamp(val, L_range[0], L_range[1]) var x, y, t diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index fe50b92..8f22db5 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1262,9 +1262,20 @@ input[type="range"]::-webkit-slider-thumb { border-radius:10px; cursor:pointer; } +#color-picker { + position: relative; +} .colorPicker { cursor: crosshair; } +.colorPickerCursor { + position: absolute; + width: 8px; + height: 8px; + border: 2px solid black; + border-radius: 50%; + margin-left: -4px; +} .swatch { width: 20px; @@ -1274,10 +1285,10 @@ input[type="range"]::-webkit-slider-thumb { cursor: pointer; float:left; } -.swatch:hover { +span:hover .swatch { border: 1px solid red; } -.swatch.selected { +.active .swatch { border: 1px solid #000; } .color-swatches { diff --git a/views/controls/editor/light-control.ejs b/views/controls/editor/light-control.ejs index 65a602f..8b133a5 100644 --- a/views/controls/editor/light-control.ejs +++ b/views/controls/editor/light-control.ejs @@ -1,4 +1,7 @@
+
+
+

Brightness Control

-- cgit v1.2.3-70-g09d2 From dea374c2a0721a394ae5f041e8e324df4b5eb375 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 29 Sep 2014 18:56:17 -0400 Subject: fix color picker cursor lol --- public/assets/javascripts/ui/editor/LightControl.js | 4 +++- public/assets/stylesheets/app.css | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/ui/editor/LightControl.js b/public/assets/javascripts/ui/editor/LightControl.js index 9c3cdd3..3eb2861 100644 --- a/public/assets/javascripts/ui/editor/LightControl.js +++ b/public/assets/javascripts/ui/editor/LightControl.js @@ -175,10 +175,12 @@ var LabColorPicker = function (parent, w, h) { return rgb } this.pick = function(i, j){ + i = clamp(i, 0, w) + j = clamp(j, 0, h) var x = mix( i/ww, a_range[0], a_range[1] ) var y = mix( j/hh, b_range[0], b_range[1] ) var rgb = xyz2rgb(hunterlab2xyz(val, x, y)).map(Math.round) - this.moveCursor(x,y) + this.moveCursor(i, j) parent.pick( rgb, [val,x,y] ) } this.load = function(rgba){ diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index e136e03..39f9f1a 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1274,6 +1274,7 @@ input[type="range"]::-webkit-slider-thumb { border: 2px solid black; border-radius: 50%; margin-left: -4px; + margin-top: -4px; } .swatch { -- cgit v1.2.3-70-g09d2 From 98c48d7a0f541d1d807b3303565274c1b3ff9b48 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 29 Sep 2014 19:07:24 -0400 Subject: annoying editor modal state stuff --- public/assets/javascripts/ui/editor/EditorSettings.js | 9 ++++++--- public/assets/javascripts/ui/editor/EditorToolbar.js | 9 +++++++++ public/assets/javascripts/ui/editor/EditorView.js | 1 - public/assets/javascripts/ui/editor/MediaEditor.js | 3 +++ 4 files changed, 18 insertions(+), 4 deletions(-) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index f74b535..92eff2b 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -10,7 +10,7 @@ var EditorSettings = FormView.extend({ "keydown": 'stopPropagation', "keydown [name=name]": 'enterSubmit', "click [data-role='show-collaborators']": 'showCollaborators', - "click [data-role='save-project']": 'save', + "click [data-role='save-project']": 'clickSave', "click [data-role='clone-project']": 'clone', "click [data-role='clear-project']": 'clear', "click [data-role='destroy-project']": 'destroy', @@ -171,6 +171,11 @@ var EditorSettings = FormView.extend({ return false }, + clickSave: function(){ + this.toggle(false) + this.save() + }, + success: function(data){ this.$id.val(data._id) this.$name.val(data.name) @@ -182,8 +187,6 @@ var EditorSettings = FormView.extend({ window.history.pushState(null, document.title, "/project/" + data.slug + "/edit") this.parent.data = data - - this.toggle(false) }, }) diff --git a/public/assets/javascripts/ui/editor/EditorToolbar.js b/public/assets/javascripts/ui/editor/EditorToolbar.js index c631317..e91da0f 100644 --- a/public/assets/javascripts/ui/editor/EditorToolbar.js +++ b/public/assets/javascripts/ui/editor/EditorToolbar.js @@ -23,6 +23,11 @@ var EditorToolbar = View.extend({ }, toggleSettings: function(){ + this.resetMode() + $(".inuse").removeClass("inuse") + this.parent.lightControl.hide() + this.parent.wallpaperPicker.hide() + this.parent.mediaEditor.hide() this.parent.settings.toggle() }, @@ -84,7 +89,9 @@ var EditorToolbar = View.extend({ var state = ! $("[data-role='toggle-wallpaper-panel']").hasClass("inuse") this.resetMode() $("[data-role='toggle-wallpaper-panel']").toggleClass("inuse", state) + this.parent.mediaEditor.hide() this.parent.lightControl.hide() + this.parent.settings.hide() this.parent.wallpaperPicker.toggle(state) }, @@ -92,7 +99,9 @@ var EditorToolbar = View.extend({ var state = ! $("[data-role='toggle-light-control']").hasClass("inuse") this.resetMode() $("[data-role='toggle-light-control']").toggleClass("inuse", state) + this.parent.mediaEditor.hide() this.parent.wallpaperPicker.hide() + this.parent.settings.hide() this.parent.lightControl.toggle(state) }, diff --git a/public/assets/javascripts/ui/editor/EditorView.js b/public/assets/javascripts/ui/editor/EditorView.js index 22e32ca..e11f189 100644 --- a/public/assets/javascripts/ui/editor/EditorView.js +++ b/public/assets/javascripts/ui/editor/EditorView.js @@ -46,7 +46,6 @@ var EditorView = View.extend({ hideExtras: function(){ this.mediaEditor.hide() - this.settings.toggle(false) } }) diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index 2d32d4f..9b20a43 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -39,6 +39,9 @@ var MediaEditor = FormView.extend({ }, toggle: function(state) { + if (state) { + this.parent.settings.toggle() + } this.$el.toggleClass("active", state); }, -- cgit v1.2.3-70-g09d2 From 4a0717d5f8aa0ff3378ff589b106cd35c0586367 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 29 Sep 2014 19:31:25 -0400 Subject: outline walls on builder --- .../assets/javascripts/rectangles/engine/map/ui_editor.js | 1 - .../assets/javascripts/rectangles/engine/rooms/_walls.js | 14 ++++++++++++++ .../assets/javascripts/rectangles/engine/rooms/builder.js | 3 ++- public/assets/javascripts/ui/builder/BuilderInfo.js | 1 + public/assets/javascripts/ui/builder/BuilderSettings.js | 7 ++++++- public/assets/javascripts/ui/builder/BuilderView.js | 5 +++++ public/assets/javascripts/ui/site/LayoutsModal.js | 1 + public/assets/stylesheets/app.css | 1 + server/lib/api/projects.js | 8 ++++---- 9 files changed, 34 insertions(+), 7 deletions(-) (limited to 'public/assets/javascripts/ui') diff --git a/public/assets/javascripts/rectangles/engine/map/ui_editor.js b/public/assets/javascripts/rectangles/engine/map/ui_editor.js index 9a557b9..f9334e6 100644 --- a/public/assets/javascripts/rectangles/engine/map/ui_editor.js +++ b/public/assets/javascripts/rectangles/engine/map/ui_editor.js @@ -38,7 +38,6 @@ Map.UI.Editor = function(map){ cursor.quantize(1/map.zoom) map.center.a = cursor.x.a map.center.b = -cursor.y.a - console.log(map.center+"") cursor.x.b = cursor.x.a cursor.y.b = cursor.y.a base.mouse.down = false diff --git a/public/assets/javascripts/rectangles/engine/rooms/_walls.js b/public/assets/javascripts/rectangles/engine/rooms/_walls.js index f9eb9b7..82ccb87 100644 --- a/public/assets/javascripts/rectangles/engine/rooms/_walls.js +++ b/public/assets/javascripts/rectangles/engine/rooms/_walls.js @@ -88,6 +88,20 @@ }) }, + base.paint = function(){ + var wallColor = rgba_string(Walls.colors.wall, app.defaults.wallOpacity) + var outlineColor = rgb_string(Walls.colors.outline) + var floorColor = rgb_string(Walls.colors.floor) + var ceilingColor = rgb_string(Walls.colors.ceiling) + Walls.forEach(function(wall){ + wall.outline(wallColor, outlineColor) + }) + Rooms.forEach(function(room){ + room.setFloorColor(floorColor) + room.setCeilingColor(ceilingColor) + }) + } + base.setColor = { wall: function(rgb){ diff --git a/public/assets/javascripts/rectangles/engine/rooms/builder.js b/public/assets/javascripts/rectangles/engine/rooms/builder.js index f0935d4..6a89158 100644 --- a/public/assets/javascripts/rectangles/engine/rooms/builder.js +++ b/public/assets/javascripts/rectangles/engine/rooms/builder.js @@ -44,9 +44,10 @@ base.clear() base.build() Rooms.grouper.build() + app.tube("rooms-built") } } - + base.build = function (){ Rooms.regions.forEach(function(region){ this.build_walls(region).forEach(function(el){ diff --git a/public/assets/javascripts/ui/builder/BuilderInfo.js b/public/assets/javascripts/ui/builder/BuilderInfo.js index 2fffdba..e6b7e97 100644 --- a/public/assets/javascripts/ui/builder/BuilderInfo.js +++ b/public/assets/javascripts/ui/builder/BuilderInfo.js @@ -55,6 +55,7 @@ var BuilderInfo = View.extend({ this.$height.unitVal( room.height ) this.$x.unitVal( room.rect.x.a ) this.$y.unitVal( room.rect.y.a ) + this.show() }, destroy: function(room){ diff --git a/public/assets/javascripts/ui/builder/BuilderSettings.js b/public/assets/javascripts/ui/builder/BuilderSettings.js index 796c398..94eed29 100644 --- a/public/assets/javascripts/ui/builder/BuilderSettings.js +++ b/public/assets/javascripts/ui/builder/BuilderSettings.js @@ -9,7 +9,7 @@ var BuilderSettings = FormView.extend({ events: { "keydown": 'stopPropagation', "keydown [name=name]": 'enterSubmit', - "click [data-role='save-layout']": 'save', + "click [data-role='save-layout']": 'clickSave', "click [data-role='clone-layout']": 'clone', "click [data-role='clear-layout']": 'clear', "click [data-role='destroy-layout']": 'destroy', @@ -118,6 +118,11 @@ var BuilderSettings = FormView.extend({ fd.append( "thumbnail", dataUriToBlob(map.canvas.toDataURL()) ) return fd }, + + clickSave: function(){ + this.toggle(false) + this.save() + }, success: function(data){ this.$id.val(data._id) diff --git a/public/assets/javascripts/ui/builder/BuilderView.js b/public/assets/javascripts/ui/builder/BuilderView.js index a89111f..81dce52 100644 --- a/public/assets/javascripts/ui/builder/BuilderView.js +++ b/public/assets/javascripts/ui/builder/BuilderView.js @@ -12,6 +12,11 @@ var BuilderView = View.extend({ this.toolbar = new BuilderToolbar ({ parent: this }) this.settings = new BuilderSettings ({ parent: this }) this.lightControl = new LightControl ({ parent: this }) + + app.on("rooms-built", function(){ + Walls.paint() + }) + }, load: function(name){ diff --git a/public/assets/javascripts/ui/site/LayoutsModal.js b/public/assets/javascripts/ui/site/LayoutsModal.js index 1bfc6cb..2449465 100644 --- a/public/assets/javascripts/ui/site/LayoutsModal.js +++ b/public/assets/javascripts/ui/site/LayoutsModal.js @@ -29,6 +29,7 @@ var LayoutsIndex = View.extend({ this.$templates.append($span) }.bind(this)) + console.log(this.$templates.html()) this.show() } diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 39f9f1a..ebc21a8 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -482,6 +482,7 @@ iframe.embed { .templates { overflow: auto; max-height: 80%; + width: 100%; } .no-templates { display: none; diff --git a/server/lib/api/projects.js b/server/lib/api/projects.js index da41b48..61a6e10 100644 --- a/server/lib/api/projects.js +++ b/server/lib/api/projects.js @@ -21,10 +21,10 @@ var projects = { } else { var name = util.sanitize(req.params.slug) - if (name == "new") { - name = "" - } - res.json({ _id: "new", name: name, isNew: true }) + Project.count({}, function(err, count){ + name = "Project #" + (count || 0) + res.json({ _id: "new", name: name, isNew: true }) + }) } }) }, -- cgit v1.2.3-70-g09d2