Commit 6e572656 authored by Timo Tegtmeier's avatar Timo Tegtmeier

Refactored delete handling

parent c21fc5ac
......@@ -102,6 +102,11 @@ enyo.kind({
onCancel: "itemDeleteCanceled"
},
events: {
onSelected: "",
onDeleted: ""
},
//
// List handling
//
......@@ -125,22 +130,34 @@ enyo.kind({
},
itemDeleted: function() {
var index = this.swipedIndex;
var delSelected = this.selectedIndex === index;
if(delSelected) {
this.selectedIndex = -1;
}
this.$.list.finishSwiping(this.swipedIndex);
this.deletedItem = this.items[index];
this.items.splice(index, 1);
this.$.list.setCount(this.items.length);
this.$.list.refresh(); // Provide quick visual response.
return delSelected;
this.handleItemDeletion(this.swipedIndex, true);
return true;
},
handleItemDeletion: function(index, wasSwipe) {
var delSelected = this.selectedIndex === index;
if(delSelected) {
this.selectedIndex = -1;
}
if(wasSwipe)
this.$.list.finishSwiping(this.swipedIndex);
this.deletedItem = this.items[index];
this.items.splice(index, 1);
this.$.list.setCount(this.items.length);
this.$.list.refresh(); // Provide quick visual response.
if(delSelected) {
this.doSelected({
item: null,
isFirst: true,
isLast: true
});
}
this.doDeleted(this.deletedItem);
},
itemDeleteCanceled: function() {
if(this.swipedIndex >= 0) {
this.$.list.finishSwiping(this.swipedIndex);
......
......@@ -34,8 +34,6 @@ enyo.kind({
events: {
onOpenAppMenu: "",
onFeedSelected: "",
onFeedDeleted: "",
onAddFeed: "",
onEditFeed: ""
},
......@@ -348,23 +346,11 @@ enyo.kind({
return true;
},
itemDeleted: function(sender, index) {
if(this.swipedIndex === undefined)
throw "Missed dragstart event!";
if(this.inherited(arguments)) {
this.doFeedSelected({
item: null,
isFirst: true,
isLast: true
});
}
this.doFeedDeleted(this.deletedItem);
enyo.application.feeds.deleteFeed(this.deletedItem);
this.deletedItem = null;
return true;
},
handleItemDeletion: function(index, wasSwipe) {
this.inherited(arguments);
enyo.application.feeds.deleteFeed(this.deletedItem);
this.deletedItem = null;
},
setFeedSpinner: function(index, state) {
if(!this.waitingForData) {
......@@ -410,7 +396,7 @@ enyo.kind({
},
menuDeleteFeed: function(sender, event) {
this.itemDeleted(sender, this.menuIndex);
this.handleItemDeletion(this.menuIndex, false);
return true;
},
......
......@@ -42,13 +42,13 @@ enyo.kind({
name: "feedList",
kind: FeedList,
onOpenAppMenu: "openAppMenu",
onFeedSelected: "feedSelected",
onSelected: "feedSelected",
onAddFeed: "addFeed",
onEditFeed: "editFeed"
}, {
name: "storyList",
kind: StoryList,
onStorySelected: "storySelected",
onSelected: "storySelected",
onBackClick: "backToFeedList",
onNextFeed: "selectNextFeed",
onPrevFeed: "selectPrevFeed"
......
......@@ -32,8 +32,6 @@ enyo.kind({
},
events: {
onStorySelected: "",
onStoryDeleted: "",
onBackClick: "",
onNextFeed: "",
onPrevFeed: ""
......@@ -314,20 +312,11 @@ enyo.kind({
this.updateOnly = false;
},
itemDeleted: function(sender, index) {
if(this.inherited(arguments)) {
this.doStorySelected({
item: null,
isFirst: true,
isLast: true
});
}
this.doStoryDeleted(this.deletedItem);
enyo.application.feeds.deleteStory(this.deletedItem);
this.deletedItem = null;
return true;
},
handleItemDeletion: function(index, wasSwipe) {
this.inherited(arguments);
enyo.application.feeds.deleteStory(this.deletedItem);
this.deletedItem = null;
},
itemClicked: function(sender, event) {
if(!this.inherited(arguments))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment