From b7b307e82baca5a9c5e00e16c2b36e2b00afdade Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Wed, 2 Apr 2014 15:35:05 +0100 Subject: [PATCH] trim project and entiry names/renames --- services/web/public/coffee/file-tree/FileTreeManager.coffee | 3 ++- services/web/public/coffee/list.coffee | 2 +- services/web/public/coffee/settings/SettingsManager.coffee | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/services/web/public/coffee/file-tree/FileTreeManager.coffee b/services/web/public/coffee/file-tree/FileTreeManager.coffee index 13bd45403e..942d8b60b2 100644 --- a/services/web/public/coffee/file-tree/FileTreeManager.coffee +++ b/services/web/public/coffee/file-tree/FileTreeManager.coffee @@ -159,6 +159,7 @@ define [ renameEntity: (entity, name) -> + name = name?.trim() @ide.socket.emit 'renameEntity', entity.id, entity.get("type"), name entity.set("name", name) @@ -197,7 +198,7 @@ define [ el = $($("#newEntityModalTemplate").html()) input = el.find("input") create = _.once () => - name = input.val() + name = input.val()?.trim() if name != "" callback(name) modal = new Modal diff --git a/services/web/public/coffee/list.coffee b/services/web/public/coffee/list.coffee index c800353733..b56e7c52bf 100644 --- a/services/web/public/coffee/list.coffee +++ b/services/web/public/coffee/list.coffee @@ -144,7 +144,7 @@ require [ $confirm.click (e) => $confirm.attr("disabled", true) $confirm.text("Creating...") - projectName = $modal.find('input').val() + projectName = $modal.find('input').val()?.trim() $.ajax url: '/project/new' type:'POST' diff --git a/services/web/public/coffee/settings/SettingsManager.coffee b/services/web/public/coffee/settings/SettingsManager.coffee index 5474263a38..9f9e20347c 100644 --- a/services/web/public/coffee/settings/SettingsManager.coffee +++ b/services/web/public/coffee/settings/SettingsManager.coffee @@ -126,7 +126,10 @@ define [ # http://stackoverflow.com/questions/6692031/check-if-event-is-triggered-by-a-human if e.originalEvent? if @ide.isAllowedToDoIt "readAndWrite" - @project.set("name", e.target.value) + newName = e.target.value?.trim() + $("input.projectName").val(newName) + @project.set("name", newName) + bindToCompiler: -> $('select#compilers').val(@project.get("compiler"))