correcting Drag and Drop for FileTree

This commit is contained in:
Sean McArthur 2011-12-15 17:48:16 -08:00
Родитель 2bd90f8c35
Коммит d88b10a907
5 изменённых файлов: 22 добавлений и 34 удалений

Просмотреть файл

@ -326,7 +326,6 @@ module.exports = new Class({
this.editor.registerItem(att.get('uid'), att);
}
var controller = this;
att.addEvent('destroy', function() {
delete controller.attachments[this.get('uid')];
});
@ -581,7 +580,7 @@ module.exports = new Class({
}
var controller = this;
this.sidebar.addEvent('select', function(file) {
this.sidebar.addListener('select', function(file) {
controller.onSidebarSelect(file);
});
},
@ -592,7 +591,7 @@ module.exports = new Class({
}
var controller = this;
this.tabs.addEvent('select', function(tab) {
this.tabs.addListener('select', function(tab) {
controller.onTabSelect(tab);
});
},

Просмотреть файл

@ -77,18 +77,6 @@ var FileTree = module.exports = new Class({
},
mousedown: function(element, event) {
//tree.js prevents event immediately, when really we only want
//the event prevents when it drags. This is because if the element
//has contentEditable active, we want the default mousedown action,
//which is to move the cursor around the text node. If it's not,
//then preventDefault will be called twice, and the dragging will still
//work. :)
var oldDefault = event.preventDefault;
event.preventDefault = function(){
event.preventDefault = oldDefault;
};
this.parent(element, event);
if (this._clone) {
this._clone.setStyle('display', 'none');

Просмотреть файл

@ -378,7 +378,7 @@ var Sidebar = module.exports = new Class({
selectBranch: function(li) {
var file = li.retrieve('file');
this.fireEvent('select', file);
this.emit('select', file);
this.setSelectedFile(li);
},
@ -394,7 +394,7 @@ var Sidebar = module.exports = new Class({
var emptydir = node.retrieve('file');
if (emptydir instanceof Folder) {
emptydir.removeEvent('destroy', emptydir._removeFromTree);
node.eliminate('file');
node.unstore('file');
emptydir.destroy();
}
}

Просмотреть файл

@ -9,13 +9,13 @@ var Class = require('shipyard/class/Class'),
var uid = '$tree:' + string.uniqueID();
var bind = function() {
var bound = {},
key;
for (var i = 0, len = arguments.length; i < len; i++) {
key = arguments[i];
bound[key] = this[key].bind(this);
}
return bound;
var bound = {},
key;
for (var i = 0, len = arguments.length; i < len; i++) {
key = arguments[i];
bound[key] = this[key].bind(this);
}
return bound;
};
module.exports = new Class({
@ -48,7 +48,7 @@ module.exports = new Class({
tree.mousedown(this, e);
};
this.bound = bind.call(this, 'hideIndicator', 'onDrag', 'onDrop')
this.bound = bind.call(this, 'hideIndicator', 'onDrag', 'onDrop');
this.attach();
},
@ -57,9 +57,9 @@ module.exports = new Class({
this.downHandler = this.element.delegate('li', 'mousedown', function(e) {
tree.mousedown(this, e);
});
this.upHandler = dom.document.body.addListener('mouseup', funciton(e) {
tree.mouseup(this, e);
});
this.upHandler = dom.document.body.addListener('mouseup', function(e) {
tree.mouseup(this, e);
});
return this;
},
@ -70,8 +70,6 @@ module.exports = new Class({
},
mousedown: function(element, event) {
event.preventDefault();
this.padding = (this.element.getElement('li ul li') || this.element.getElement('li')).getLeft() - this.element.getLeft() + this.options.indicatorOffset;
if(!this.options.checkDrag.call(this, element)) {
@ -93,6 +91,7 @@ module.exports = new Class({
onLeave: this.bound.hideIndicator,
onDrag: this.bound.onDrag,
onDrop: this.bound.onDrop,
preventDefault: true,
container: this.options.container ? (dom.$(this.options.container) || this.element) : null
});
dragger.start(event);
@ -100,7 +99,7 @@ module.exports = new Class({
mouseup: function() {
if (this._clone) {
this._clone.destroy();
this._clone = this._clone.destroy();
}
},
@ -118,7 +117,9 @@ module.exports = new Class({
return;
}
var droppable = (event.target.get('tag') === 'li') ? event.target : event.target.getParent('li');
var target = dom.$(event.target);
var droppable = (target.get('tag') === 'li') ? target : target.getParent('li');
if (!droppable || this.element === droppable || !this.element.contains(droppable)) {
return;
}
@ -128,7 +129,7 @@ module.exports = new Class({
}
var coords = droppable.getCoordinates(),
marginTop = droppable.getStyle('marginTop').toInt(),
marginTop = parseInt(droppable.getStyle('marginTop'), 10),
center = coords.top + marginTop + (coords.height / 2),
isSubnode = (event.page.x > coords.left + this.padding),
position = {

@ -1 +1 @@
Subproject commit b3d3d8eedf2041d9f3127e85632dca2bd80dd818
Subproject commit 3ee1a3a929d3f8fc02d0d52e89da53558602168f