123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- starter.directive('task', [function () {
- return {
- restrict: "E",
- scope: {
- data: "=source"
- },
- templateUrl: 'templates/template-task.html',
- controller: function ($scope) {
- if ($scope.data.end_dd != null) {
- $scope.data.end_dd = new Date($scope.data.end_dd);
- $scope.date = new Date();
- var startTime = new Date(Date.parse($scope.data.end_dd)).getTime();
- var endTime = new Date(Date.parse($scope.date)).getTime();
- var dates = Math.floor((endTime - startTime) / (1000 * 60 * 60 * 24));
- if (($scope.data.end_dd < $scope.date && dates != 0) && $scope.data.is_completed == 0) {
- $scope.node = '过期' + dates + '天';
- $scope.flag = true;
- } else {
- $scope.node = '截止';
- $scope.flag = false;
- }
- }
- $scope.showcardinfo = function (id) {
- console.log(id);
- }
- }
- }
- }])
- .directive('scrollpin', function ($window) {
- return {
- link: function (scope, element, attrs) {
- angular.element($window).on('scroll', onScroll);
- function onScroll() {
- var offset = $window.pageYOffset;
- var offsetTop = element[0].offsetTop;
- var before = element[0].previousElementSibling;
- if (offsetTop < offset) {
- var move = parseInt(attrs.scrollpin || 0) + offsetTop - offset;
- before.style.position = 'fixed';
- if (move < 0 && -move < parseInt(attrs.scrollpin)) {
- before.style.top = move + 'px';
- } else {
- before.style.top = '0';
- }
- } else {
- before.style.position = 'absolute';
- before.style.top = '';
- }
- }
- }
- };
- });
|