From 95de299e6e1f64331e4d8be9b0255bb2e93fb85f Mon Sep 17 00:00:00 2001 From: MrZYX Date: Wed, 6 Apr 2011 14:18:33 +0200 Subject: [PATCH] fixed #953 --- app/controllers/aspects_controller.rb | 2 -- public/javascripts/aspect-edit.js | 35 +++++++++++++++++---------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 6f4223977..8452d3e58 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -137,8 +137,6 @@ class AspectsController < ApplicationController else flash[:error] = I18n.t 'aspects.update.failure', :name => @aspect.name end - - respond_with @aspect end def toggle_contact_visibility diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index e526ed3e0..716039f4a 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -20,6 +20,7 @@ var AspectEdit = { $("#manage_aspect_zones").find(".delete").live("click", AspectEdit.deletePerson); $(".aspect h3").live('focus', AspectEdit.changeName); + }, startDrag: function() { @@ -116,27 +117,35 @@ var AspectEdit = { id = $this.closest(".aspect").attr("data-guid"), link = "/aspects/" + id; + //cleanup + $this.text($.trim($this.text())); - $this.keyup(function() { + $this.keypress(function(e) { if (e.which == 13) { e.preventDefault(); $this.blur(); - - //save changes - $.ajax({ - type: "PUT", - url: link, - data: { - "aspect": { - "name" : $this.text() - } - } - }); } - + + //length limit + if ($this.text().length >= 20) { + e.preventDefault(); + } //update all other aspect links $("#aspect_nav li[data-guid='" + id + "'] a").text($this.text()); }); + + $this.blur(function() { + //save changes + $.ajax({ + type: "PUT", + url: link, + data: { + "aspect": { + "name" : $this.text() + } + } + }); + }); }, deletePerson: function() {