Split directives into separate files

This commit is contained in:
Kevin Gisi
2015-06-08 04:13:55 -04:00
parent e0794b1f08
commit 7ef98ff7e2
12 changed files with 319 additions and 198 deletions

View File

@@ -0,0 +1,32 @@
'use strict';
angular
.module('habitrpg')
.directive('hrpgSortTasks', hrpgSortTasks);
hrpgSortTasks.$inject = [
'User'
];
function hrpgSortTasks(User) {
return function($scope, element, attrs, ngModel) {
$(element).sortable({
axis: "y",
distance: 5,
start: function (event, ui) {
ui.item.data('startIndex', ui.item.index());
},
stop: function (event, ui) {
var task = angular.element(ui.item[0]).scope().task;
var startIndex = ui.item.data('startIndex');
User.user.ops.sortTask({
params: { id: task.id },
query: {
from: startIndex,
to: ui.item.index()
}
});
}
});
}
}