mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-02 22:11:48 +01:00
This drag-drop javascript has got the best of me for the time being. I'm removing all drag-drop functionality to eliminate the javascript performance issues from the trunk. If anyone if interested in digging into this further, I'll be attaching a patch containing the code removed here to ticket #220.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@280 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
0b188b6e24
commit
ef42421f64
3 changed files with 2 additions and 127 deletions
|
|
@ -2,7 +2,6 @@ if @saved
|
|||
item_container_id = "item-#{@item.id}-container"
|
||||
if @item.context_id == @original_item_context_id
|
||||
page.replace_html item_container_id, :partial => 'todo/item'
|
||||
page.call "todoItems.prepareForLazyLoadingDraggable", item_container_id
|
||||
page.visual_effect :highlight, item_container_id, :duration => 3
|
||||
else
|
||||
page[item_container_id].remove
|
||||
|
|
@ -11,7 +10,6 @@ if @saved
|
|||
page.delay(0.5) do
|
||||
page.call "todoItems.ensureContainerHeight", "c#{@original_item_context_id}items"
|
||||
page.call "todoItems.ensureContainerHeight", "c#{@item.context_id}items"
|
||||
page.call "todoItems.prepareForLazyLoadingDraggable", item_container_id
|
||||
page.visual_effect :highlight, item_container_id, :duration => 3
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -154,13 +154,6 @@ ToDoItems.prototype = {
|
|||
return null;
|
||||
},
|
||||
|
||||
findItemElem: function(elem)
|
||||
{
|
||||
if (elem.hasClassName("item-container"))
|
||||
return elem;
|
||||
else
|
||||
return this.findNearestParentByClassName(elem, "item-container");
|
||||
},
|
||||
findItemsElem : function(elem)
|
||||
{
|
||||
var containerElem = this.findNearestParentByClassName(elem, "container");
|
||||
|
|
@ -168,123 +161,8 @@ ToDoItems.prototype = {
|
|||
return document.getElementsByClassName('toggle_target',containerElem)[0];
|
||||
else
|
||||
return null;
|
||||
},
|
||||
addItemDragDrop: function()
|
||||
{
|
||||
this.itemContainers = $$('.item-container');
|
||||
for(i=0; i < this.itemContainers.length; i++)
|
||||
{
|
||||
itemContainer = this.itemContainers[i];
|
||||
this.prepareForLazyLoadingDraggable(itemContainer.id);
|
||||
}
|
||||
contextElems = $$('.context');
|
||||
for(i=0; i < contextElems.length; i++)
|
||||
{
|
||||
this.makeContextDroppable(contextElems[i]);
|
||||
}
|
||||
/*
|
||||
sidebarProjectElems = $$('.sidebar-project');
|
||||
for(i=0; i < sidebarProjectElems.length; i++)
|
||||
{
|
||||
this.makeProjectDroppable(sidebarProjectElems[i]);
|
||||
}
|
||||
sidebarContextElems = $$('.sidebar-context');
|
||||
for(i=0; i < sidebarContextElems.length; i++)
|
||||
{
|
||||
this.makeContextDroppable(sidebarContextElems[i]);
|
||||
}
|
||||
*/
|
||||
},
|
||||
prepareForLazyLoadingDraggable : function(itemContainerElemId)
|
||||
{
|
||||
Event.observe($(itemContainerElemId), "mouseover", this.createDraggableListener.bindAsEventListener(this));
|
||||
},
|
||||
createDraggableListener : function(event)
|
||||
{
|
||||
itemToMakeDraggable = this.findItemElem(Event.element(event));
|
||||
this.makeItemDraggable(itemToMakeDraggable);
|
||||
//remove this listener once the draggable has been created (no longer needed)
|
||||
Event.stopObserving(itemToMakeDraggable, "mouseover", itemToMakeDraggable.createDraggableListener);
|
||||
itemToMakeDraggable.createDraggableListener = null;
|
||||
},
|
||||
makeItemDraggable: function(itemContainerElem)
|
||||
{
|
||||
new Draggable(itemContainerElem.id,
|
||||
{
|
||||
handle:'description',
|
||||
starteffect:this.startDraggingItem.bindAsEventListener(this),
|
||||
endeffect:this.stopDraggingItem.bindAsEventListener(this),
|
||||
revert:true
|
||||
});
|
||||
},
|
||||
|
||||
makeContextDroppable: function(contextElem)
|
||||
{
|
||||
Droppables.add($(contextElem).id,
|
||||
{
|
||||
accept:'item-container',
|
||||
hoverclass:'item-container-drop-target',
|
||||
onDrop: this.itemContextDrop
|
||||
});
|
||||
},
|
||||
makeProjectDroppable: function(projectElem)
|
||||
{
|
||||
Droppables.add($(projectElem).id,
|
||||
{
|
||||
accept:'item-container',
|
||||
hoverclass:'item-container-drop-target',
|
||||
onDrop: this.itemProjectDrop
|
||||
});
|
||||
},
|
||||
startDraggingItem:function(draggable)
|
||||
{
|
||||
parentContainer = this.findNearestParentByClassName(draggable, 'container');
|
||||
draggable.parentContainer = parentContainer;
|
||||
toggleElem = document.getElementsByClassName('container_toggle',parentContainer)[0];
|
||||
this.collapseAllNextActionListing(toggleElem);
|
||||
},
|
||||
stopDraggingItem:function(draggable)
|
||||
{
|
||||
this.setNextActionListingTogglesToCookiedState();
|
||||
},
|
||||
|
||||
itemContextDrop:function(draggableElement, droppableElement) {
|
||||
if (draggableElement.parentContainer == droppableElement) {
|
||||
return; //same destination as original, nothing to be done
|
||||
}
|
||||
itemElementId = draggableElement.id
|
||||
todoId = draggableElement.id.match(/\d+/)[0];
|
||||
contextId = droppableElement.id.match(/\d+/)[0];
|
||||
Draggables.drags.each(function(drag) {
|
||||
if (drag.element == draggableElement) {
|
||||
drag.destroy();
|
||||
}
|
||||
})
|
||||
new Ajax.Request('/todo/update_context', {
|
||||
asynchronous:true,
|
||||
evalScripts:true,
|
||||
parameters:"id=" + todoId + "&context_id=" + contextId
|
||||
})
|
||||
},
|
||||
itemProjectDrop:function(draggableElement, droppableElement) {
|
||||
if (draggableElement.parentContainer == droppableElement) {
|
||||
return; //same destination as original, nothing to be done
|
||||
}
|
||||
itemElementId = draggableElement.id
|
||||
todoId = draggableElement.id.match(/\d+/)[0];
|
||||
projectId = droppableElement.id.match(/\d+/)[0];
|
||||
Draggables.drags.each(function(drag) {
|
||||
if (drag.element == draggableElement) {
|
||||
drag.destroy();
|
||||
}
|
||||
})
|
||||
new Ajax.Request('/todo/update_project', {
|
||||
asynchronous:true,
|
||||
evalScripts:true,
|
||||
parameters:"id=" + todoId + "&project_id=" + projectId
|
||||
})
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
todoItems = new ToDoItems();
|
||||
Event.observe(window, "load", todoItems.addNextActionListingToggles.bindAsEventListener(todoItems));
|
||||
Event.observe(window, "load", todoItems.addItemDragDrop.bindAsEventListener(todoItems));
|
||||
|
|
|
|||
|
|
@ -219,7 +219,6 @@ input.item-checkbox {
|
|||
}
|
||||
|
||||
.description {
|
||||
cursor:move;
|
||||
margin-left: 70px;
|
||||
margin-right: 10px;
|
||||
_margin-left: 0px;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue