return recipeStore;
}
+ function setRecipeStore(store) {
+ recipeStore = store;
+ }
+
function _addRecipe(recipe) {
var $recipe;
if (recipe.type === 'recipe') {
$('#tic-recipe-list').append($recipe);
}
- // TODO: set/get sortable recipe
function _updateRecipe() {
var $recipe = $('#tic-recipe-list');
$recipe.empty();
}
function updatePackage() {
- // FIXME:
var postBody = {
- //repos : _.map(_.orderBy(recipeStore, ['priority']), 'url'),
recipes : recipeStore
};
return Util.POST(CONFIG.EVENT.PACKAGE.ANALYSIS, postBody)
.then(function (result) {
if (result.result === 'true') {
- recipeStore = result.data.recipes;
+ setRecipeStore(result.data.recipes);
_updateRecipe();
return result.data;
} else {
function _importHandler() {
Import.showImportDialog(recipeStore)
.then(function(recipes) {
- recipeStore = recipes;
+ setRecipeStore(recipes);
_updateRecipe();
});
}
pullPlaceholder: false,
// set $item relative to cursor position
- onDragStart: function ($item, container, _super) {
+ onDragStart: function($item, container, _super) {
var offset = $item.offset()
var pointer = container.rootGroup.pointer;
adjustment = {
};
_super($item, container);
},
- onDrag: function ($item, position) {
+ onDrag: function($item, position) {
$item.css({
left: position.left - adjustment.left,
top: position.top - adjustment.top
});
+ },
+ onDrop: function($item, container, _super) {
+ // reorder for recipe
+ var recipeItems = $('#tic-recipe-list li');
+ var store = [];
+ _.forEach(recipeItems, function(recipeItem) {
+ store.push(_.find(getRecipeStore(), { url: recipeItem.id }));
+ });
+ setRecipeStore(store);
+
+ // animation on drop
+ var $clonedItem = $('<li/>').css({height: 0});
+ $item.before($clonedItem);
+ $clonedItem.animate({'height': $item.height()});
+
+ $item.animate($clonedItem.position(), function() {
+ $clonedItem.detach();
+ _super($item, container);
+ });
}
});