Skip to content

Commit

Permalink
deleting works
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingmachine committed Nov 19, 2011
1 parent 9a06f4d commit fb24e69
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
25 changes: 23 additions & 2 deletions app/assets/javascripts/lists.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class App.backbone.ItemView extends Backbone.View
handleDrag: ->
App.mainList.updateItems()
@select()
e.stopImmediatePropagation()
return false;

changeStatus: ->
App.mainList.updateItems()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: ->
Expand Down Expand Up @@ -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')

Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/lists.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-moz-border-radius:10px;
border-radius:10px;
border:1px solid #fff;
background:white;

&:hover {
border-color:#96e9fc;
Expand All @@ -24,6 +25,10 @@
}
}

.dragging {
opacity:0.7;
}

.drag-drop-placeholder {
background:#84def3;
@include border-radius(8px)
Expand Down

0 comments on commit fb24e69

Please sign in to comment.