mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-02 12:32:55 +00:00
+ You can now drag a group by its title. If you click on the title instead, it selects the whole title (which, it turns out, it was doing anyway) and allows you to edit it.
+ Reenabled the ability to exit title editing by clicking in empty space
This commit is contained in:
parent
a3c5f6f2b8
commit
c2da60b151
@ -72,6 +72,7 @@ window.Group = function(listOfEls, options) {
|
|||||||
|
|
||||||
$container
|
$container
|
||||||
.css({zIndex: -100})
|
.css({zIndex: -100})
|
||||||
|
.data('isDragging', false)
|
||||||
.appendTo("body")
|
.appendTo("body")
|
||||||
.dequeue();
|
.dequeue();
|
||||||
|
|
||||||
@ -92,9 +93,14 @@ window.Group = function(listOfEls, options) {
|
|||||||
.hide();
|
.hide();
|
||||||
|
|
||||||
// ___ Titlebar
|
// ___ Titlebar
|
||||||
var html = "<div class='titlebar'><input class='name' value='"
|
var html =
|
||||||
+ (options.title || "")
|
"<div class='titlebar'>" +
|
||||||
+ "'/><div class='close'></div></div>";
|
"<div class='title-container'>" +
|
||||||
|
"<input class='name' value='" + (options.title || "") + "'/>" +
|
||||||
|
"<div class='title-shield' />" +
|
||||||
|
"</div>" +
|
||||||
|
"<div class='close' />" +
|
||||||
|
"</div>";
|
||||||
|
|
||||||
this.$titlebar = $(html)
|
this.$titlebar = $(html)
|
||||||
.appendTo($container);
|
.appendTo($container);
|
||||||
@ -108,7 +114,12 @@ window.Group = function(listOfEls, options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ___ Title
|
// ___ Title
|
||||||
|
this.$titleContainer = $('.title-container', this.$titlebar);
|
||||||
|
this.$title = $('.name', this.$titlebar);
|
||||||
|
this.$titleShield = $('.title-shield', this.$titlebar);
|
||||||
|
|
||||||
var titleUnfocus = function() {
|
var titleUnfocus = function() {
|
||||||
|
self.$titleShield.show();
|
||||||
if(!self.getTitle()) {
|
if(!self.getTitle()) {
|
||||||
self.$title
|
self.$title
|
||||||
.addClass("defaultName")
|
.addClass("defaultName")
|
||||||
@ -130,7 +141,7 @@ window.Group = function(listOfEls, options) {
|
|||||||
self.adjustTitleSize();
|
self.adjustTitleSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$title = $('.name', this.$titlebar)
|
this.$title
|
||||||
.css({backgroundRepeat: 'no-repeat'})
|
.css({backgroundRepeat: 'no-repeat'})
|
||||||
.blur(titleUnfocus)
|
.blur(titleUnfocus)
|
||||||
.focus(function() {
|
.focus(function() {
|
||||||
@ -151,7 +162,24 @@ window.Group = function(listOfEls, options) {
|
|||||||
|
|
||||||
if(this.locked.title)
|
if(this.locked.title)
|
||||||
this.$title.addClass('name-locked');
|
this.$title.addClass('name-locked');
|
||||||
|
else {
|
||||||
|
this.$titleShield
|
||||||
|
.mousedown(function(e) {
|
||||||
|
self.lastMouseDownTarget = (Utils.isRightClick(e) ? null : e.target);
|
||||||
|
})
|
||||||
|
.mouseup(function(e) {
|
||||||
|
var same = (e.target == self.lastMouseDownTarget);
|
||||||
|
self.lastMouseDownTarget = null;
|
||||||
|
if(!same)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!$container.data('isDragging')) {
|
||||||
|
self.$titleShield.hide();
|
||||||
|
self.$title.get(0).focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// ___ Content
|
// ___ Content
|
||||||
this.$content = $('<div class="group-content"/>')
|
this.$content = $('<div class="group-content"/>')
|
||||||
.css({
|
.css({
|
||||||
@ -227,9 +255,9 @@ window.Group.prototype = $.extend(new Item(), new Subscribable(), {
|
|||||||
adjustTitleSize: function() {
|
adjustTitleSize: function() {
|
||||||
Utils.assert('bounds needs to have been set', this.bounds);
|
Utils.assert('bounds needs to have been set', this.bounds);
|
||||||
var w = Math.min(this.bounds.width - 35, Math.max(150, this.getTitle().length * 6));
|
var w = Math.min(this.bounds.width - 35, Math.max(150, this.getTitle().length * 6));
|
||||||
this.$title.css({
|
var css = {width: w};
|
||||||
width: w
|
this.$title.css(css);
|
||||||
});
|
this.$titleShield.css(css);
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
@ -755,12 +783,6 @@ window.Group.prototype = $.extend(new Item(), new Subscribable(), {
|
|||||||
drag.info = null;
|
drag.info = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
this.$title.mousedown(function() {
|
|
||||||
Utils.log('wtf');
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(container).droppable({
|
$(container).droppable({
|
||||||
|
@ -225,7 +225,7 @@ window.Page = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
createGroupOnDrag: function(e){
|
createGroupOnDrag: function(e){
|
||||||
e.preventDefault();
|
/* e.preventDefault(); */
|
||||||
const minSize = 60;
|
const minSize = 60;
|
||||||
|
|
||||||
var startPos = {x:e.clientX, y:e.clientY}
|
var startPos = {x:e.clientX, y:e.clientY}
|
||||||
|
@ -252,6 +252,20 @@ input.defaultName:hover{
|
|||||||
color: #CCC;
|
color: #CCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.title-container {
|
||||||
|
}
|
||||||
|
|
||||||
|
.title-shield {
|
||||||
|
position:absolute;
|
||||||
|
margin: 3px 0px 0px 3px;
|
||||||
|
padding: 1px;
|
||||||
|
left:0;
|
||||||
|
top:0;
|
||||||
|
width:100%;
|
||||||
|
height:100%;
|
||||||
|
z-index:10;
|
||||||
|
}
|
||||||
|
|
||||||
.transparentBorder{
|
.transparentBorder{
|
||||||
border: 1px solid transparent !important;
|
border: 1px solid transparent !important;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user