Cleaned up the interaction around naming a group.

+ Animation on changing the default name
+ Appropriate color changes
+ Only show the input box on hover
This commit is contained in:
Aza Raskin 2010-04-21 14:12:41 -04:00
parent 87d1a2df16
commit 22cf8d5cfb
4 changed files with 49 additions and 15 deletions

View File

@ -94,29 +94,36 @@ window.Group = function(listOfEls, options) {
var titleUnfocus = function() { var titleUnfocus = function() {
if(!self.getTitle()) { if(!self.getTitle()) {
self.$title self.$title
.css({ .addClass("defaultName")
fontStyle: 'italic', .val(self.defaultName);
backgroundImage: 'url(img/edit.png)', } else {
paddingLeft: 15 self.$title.css({"background":"none"})
}) .animate({"paddingLeft":1, "easing":"linear"}, 340);
.val('group name');
} }
}; };
var handleKeyPress = function(e){
if( e.which == 13 ) { // return
self.$title.blur()
.addClass("transparentBorder")
.one("mouseout", function(){
self.$title.removeClass("transparentBorder");
});
}
}
this.$title = $('.name', this.$titlebar) this.$title = $('.name', this.$titlebar)
.css({backgroundRepeat: 'no-repeat'}) .css({backgroundRepeat: 'no-repeat'})
.blur(titleUnfocus) .blur(titleUnfocus)
.focus(function() { .focus(function() {
self.$title.select();
if(!self.getTitle()) { if(!self.getTitle()) {
self.$title self.$title
.css({ .removeClass("defaultName")
fontStyle: 'normal',
backgroundImage: '',
paddingLeft: 0
})
.val(''); .val('');
} }
}); })
.keydown(handleKeyPress);
titleUnfocus(); titleUnfocus();
@ -160,11 +167,14 @@ window.Group = function(listOfEls, options) {
}; };
// ---------- // ----------
window.Group.prototype = $.extend(new Item(), new Subscribable(), { window.Group.prototype = $.extend(new Item(), new Subscribable(), {
// ----------
defaultName: "name this group...",
// ---------- // ----------
getTitle: function() { getTitle: function() {
var value = (this.$title ? this.$title.val() : ''); var value = (this.$title ? this.$title.val() : '');
return (value == 'group name' ? '' : value); return (value == this.defaultName ? '' : value);
}, },
// ---------- // ----------

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 B

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -161,10 +161,34 @@ body {
input.name{ input.name{
background: transparent; background: transparent;
border: 1px solid #ddd; border: 1px solid transparent;
color: #999; color: #999;
margin: 3px 0px 0px 3px; margin: 3px 0px 0px 3px;
padding: 1px; padding: 1px;
background-image: url(../img/edit-light.png);
padding-left: 20px;
}
input.name:hover{
border: 1px solid #ddd;
}
input.name:focus{
color: #555;
}
input.defaultName{
font-style: italic !important;
background-image-opacity: .1;
color: transparent;
}
input.defaultName:hover{
color: #CCC;
}
.transparentBorder{
border: 1px solid transparent !important;
} }
/* Resizable /* Resizable