Permalink
Browse files

deleting works

  • Loading branch information...
1 parent 9a06f4d commit fb24e69fc50fab3487b430c1a7c5ba1197584524 @flyingmachine committed Nov 19, 2011
Showing with 28 additions and 2 deletions.
  1. +23 −2 app/assets/javascripts/lists.js.coffee
  2. +5 −0 app/assets/stylesheets/lists.css.scss
@@ -85,7 +85,7 @@ class App.backbone.ItemView extends Backbone.View
handleDrag: ->
App.mainList.updateItems()
@select()
- e.stopImmediatePropagation()
+ return false;
changeStatus: ->
App.mainList.updateItems()
@@ -131,13 +131,22 @@ class App.backbone.ItemView extends Backbone.View
if index < all.length - 1
index++
all[index].view
+
+ nextSibling: ->
+ $(@el).next()[0]?.view
previous: ->
all = $("#app li").toArray()
index = all.indexOf(@el)
if index > 0
index--
all[index].view
+
+ previousSibling: ->
+ $(@el).prev()[0]?.view
+
+ parent: ->
+ $(@el).parents("li")[0]?.view
indent: ->
if $(@el).prev("li").length
@@ -313,7 +322,17 @@ class App.backbone.ListView extends Backbone.View
App.selection().switchToForm()
deleteItem: ->
- App.selection().remove()
+ toDelete = App.selection()
+ if toDelete != toDelete.nextSibling() && toDelete.nextSibling()
+ toSelect = toDelete.nextSibling()
+ else if toDelete != toDelete.previousSibling() && toDelete.previousSibling()
+ toSelect = toDelete.previousSibling()
+ else
+ toSelect = toDelete.parent()
+ console.log toSelect
+ toSelect?.select()
+ toDelete.remove()
+ App.mainList.updateItems()
false
render: ->
@@ -379,6 +398,8 @@ new App.Slice
items: 'li'
tolerance: 'pointer'
toleranceElement: '> div'
+ start: (event, ui) ->
+ $(ui.helper).addClass("dragging")
stop: (event, ui) ->
$(ui.item['0']).trigger('drag')
@@ -5,6 +5,7 @@
-moz-border-radius:10px;
border-radius:10px;
border:1px solid #fff;
+ background:white;
&:hover {
border-color:#96e9fc;
@@ -24,6 +25,10 @@
}
}
+.dragging {
+ opacity:0.7;
+}
+
.drag-drop-placeholder {
background:#84def3;
@include border-radius(8px)

0 comments on commit fb24e69

Please sign in to comment.