238 lines
No EOL
6.4 KiB
JavaScript
238 lines
No EOL
6.4 KiB
JavaScript
angular.module("core-ui", [])
|
|
.directive('corLogBox', function() {
|
|
var directiveDefinitionObject = {
|
|
priority: 1,
|
|
templateUrl: '/static/directives/cor-log-box.html',
|
|
replace: true,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {
|
|
'logs': '=logs'
|
|
},
|
|
controller: function($rootScope, $scope, $element, $timeout) {
|
|
$scope.hasNewLogs = false;
|
|
|
|
var scrollHandlerBound = false;
|
|
var isAnimatedScrolling = false;
|
|
var isScrollBottom = true;
|
|
|
|
var scrollHandler = function() {
|
|
if (isAnimatedScrolling) { return; }
|
|
var element = $element.find("#co-log-viewer")[0];
|
|
isScrollBottom = element.scrollHeight - element.scrollTop === element.clientHeight;
|
|
if (isScrollBottom) {
|
|
$scope.hasNewLogs = false;
|
|
}
|
|
};
|
|
|
|
var animateComplete = function() {
|
|
isAnimatedScrolling = false;
|
|
};
|
|
|
|
$scope.moveToBottom = function() {
|
|
$scope.hasNewLogs = false;
|
|
isAnimatedScrolling = true;
|
|
isScrollBottom = true;
|
|
|
|
$element.find("#co-log-viewer").animate(
|
|
{ scrollTop: $element.find("#co-log-content").height() }, "slow", null, animateComplete);
|
|
};
|
|
|
|
$scope.$watch('logs', function(value, oldValue) {
|
|
if (!value) { return; }
|
|
|
|
$timeout(function() {
|
|
if (!scrollHandlerBound) {
|
|
$element.find("#co-log-viewer").on('scroll', scrollHandler);
|
|
scrollHandlerBound = true;
|
|
}
|
|
|
|
if (!isScrollBottom) {
|
|
$scope.hasNewLogs = true;
|
|
return;
|
|
}
|
|
|
|
$scope.moveToBottom();
|
|
}, 500);
|
|
});
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
})
|
|
|
|
.directive('corOptionsMenu', function() {
|
|
var directiveDefinitionObject = {
|
|
priority: 1,
|
|
templateUrl: '/static/directives/cor-options-menu.html',
|
|
replace: true,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {},
|
|
controller: function($rootScope, $scope, $element) {
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
})
|
|
|
|
.directive('corOption', function() {
|
|
var directiveDefinitionObject = {
|
|
priority: 1,
|
|
templateUrl: '/static/directives/cor-option.html',
|
|
replace: true,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {
|
|
'optionClick': '&optionClick'
|
|
},
|
|
controller: function($rootScope, $scope, $element) {
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
})
|
|
|
|
|
|
.directive('corTitle', function() {
|
|
var directiveDefinitionObject = {
|
|
priority: 1,
|
|
templateUrl: '/static/directives/cor-title.html',
|
|
replace: true,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {},
|
|
controller: function($rootScope, $scope, $element) {
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
})
|
|
|
|
.directive('corTitleContent', function() {
|
|
var directiveDefinitionObject = {
|
|
priority: 1,
|
|
templateUrl: '/static/directives/cor-title-content.html',
|
|
replace: true,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {},
|
|
controller: function($rootScope, $scope, $element) {
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
})
|
|
|
|
.directive('corTitleLink', function() {
|
|
var directiveDefinitionObject = {
|
|
priority: 1,
|
|
templateUrl: '/static/directives/cor-title-link.html',
|
|
replace: true,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {},
|
|
controller: function($rootScope, $scope, $element) {
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
})
|
|
|
|
.directive('corTabPanel', function() {
|
|
var directiveDefinitionObject = {
|
|
priority: 1,
|
|
templateUrl: '/static/directives/cor-tab-panel.html',
|
|
replace: true,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {},
|
|
controller: function($rootScope, $scope, $element) {
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
})
|
|
|
|
.directive('corTabContent', function() {
|
|
var directiveDefinitionObject = {
|
|
priority: 2,
|
|
templateUrl: '/static/directives/cor-tab-content.html',
|
|
replace: true,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {},
|
|
controller: function($rootScope, $scope, $element) {
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
})
|
|
|
|
.directive('corTabs', function() {
|
|
var directiveDefinitionObject = {
|
|
priority: 3,
|
|
templateUrl: '/static/directives/cor-tabs.html',
|
|
replace: true,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {},
|
|
controller: function($rootScope, $scope, $element) {
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
})
|
|
|
|
.directive('corFloatingBottomBar', function() {
|
|
var directiveDefinitionObject = {
|
|
priority: 3,
|
|
templateUrl: '/static/directives/cor-floating-bottom-bar.html',
|
|
replace: true,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {},
|
|
controller: function($rootScope, $scope, $element, $timeout, $interval) {
|
|
var handler = function() {
|
|
$element.removeClass('floating');
|
|
$element.css('width', $element[0].parentNode.clientWidth + 'px');
|
|
|
|
var windowHeight = $(window).height();
|
|
var rect = $element[0].getBoundingClientRect();
|
|
if (rect.bottom > windowHeight) {
|
|
$element.addClass('floating');
|
|
}
|
|
};
|
|
|
|
$(window).on("scroll", handler);
|
|
$(window).on("resize", handler);
|
|
|
|
var previousHeight = $element[0].parentNode.clientHeight;
|
|
var stop = $interval(function() {
|
|
var currentHeight = $element[0].parentNode.clientWidth;
|
|
if (previousHeight != currentHeight) {
|
|
currentHeight = previousHeight;
|
|
handler();
|
|
}
|
|
}, 100);
|
|
|
|
$scope.$on('$destroy', function() {
|
|
$(window).off("resize", handler);
|
|
$(window).off("scroll", handler);
|
|
$internval.stop(stop);
|
|
});
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
|
|
})
|
|
|
|
.directive('corTab', function() {
|
|
var directiveDefinitionObject = {
|
|
priority: 4,
|
|
templateUrl: '/static/directives/cor-tab.html',
|
|
replace: true,
|
|
transclude: true,
|
|
restrict: 'C',
|
|
scope: {
|
|
'tabActive': '@tabActive',
|
|
'tabTitle': '@tabTitle',
|
|
'tabTarget': '@tabTarget',
|
|
'tabInit': '&tabInit'
|
|
},
|
|
controller: function($rootScope, $scope, $element) {
|
|
}
|
|
};
|
|
return directiveDefinitionObject;
|
|
}); |