UNPKG

angular-gantt

Version:

Gantt chart component for AngularJS

154 lines (128 loc) 6.31 kB
/* Project: angular-gantt v1.2.9 - Gantt chart component for AngularJS Authors: Marco Schweighauser, Rémi Alvergnat License: MIT Homepage: https://www.angular-gantt.com Github: https://github.com/angular-gantt/angular-gantt.git */ (function(){ 'use strict'; angular.module('gantt.labels', ['gantt', 'gantt.labels.templates']).directive('ganttLabels', ['ganttUtils', '$compile', '$document', '$log', function(utils, $compile, $document, $log) { // Provides the row sort functionality to any Gantt row // Uses the sortableState to share the current row return { restrict: 'E', require: '^gantt', scope: { enabled: '=?', header: '=?' }, link: function(scope, element, attrs, ganttCtrl) { var api = ganttCtrl.gantt.api; $log.warn('Angular Gantt Labels plugin is deprecated. Please use Table plugin instead.'); // Load options from global options attribute. if (scope.options && typeof(scope.options.sortable) === 'object') { for (var option in scope.options.sortable) { scope[option] = scope.options[option]; } } if (scope.enabled === undefined) { scope.enabled = true; } if (scope.header === undefined) { scope.header = 'Name'; } api.directives.on.new(scope, function(directiveName, sideContentScope, sideContentElement) { if (directiveName === 'ganttSideContent') { var labelsScope = sideContentScope.$new(); labelsScope.pluginScope = scope; var ifElement = $document[0].createElement('div'); angular.element(ifElement).attr('data-ng-if', 'pluginScope.enabled'); angular.element(ifElement).addClass('side-element'); var labelsElement = $document[0].createElement('gantt-side-content-labels'); angular.element(ifElement).append(labelsElement); sideContentElement.append($compile(ifElement)(labelsScope)); } }); function fitSideWidthToLabels() { var labels = ganttCtrl.gantt.side.$element[0].getElementsByClassName('gantt-row-label'); var newSideWidth = 0; angular.forEach(labels, function (label) { var width = label.children[0].offsetWidth; newSideWidth = Math.max(newSideWidth, width); }); if (newSideWidth >= 0) { api.side.setWidth(newSideWidth); } } api.registerMethod('labels', 'fitSideWidth', fitSideWidthToLabels, this); } }; }]); }()); (function(){ 'use strict'; angular.module('gantt.labels').directive('ganttLabelsBody', ['GanttDirectiveBuilder', 'ganttLayout', function(Builder, layout) { var builder = new Builder('ganttLabelsBody', 'plugins/labels/labelsBody.tmpl.html'); builder.controller = function($scope) { var hScrollBarHeight = layout.getScrollBarHeight(); $scope.getLabelsCss = function() { var css = {}; if ($scope.maxHeight) { var bodyScrollBarHeight = $scope.gantt.scroll.isHScrollbarVisible() ? hScrollBarHeight : 0; css['max-height'] = $scope.maxHeight - bodyScrollBarHeight - $scope.gantt.header.getHeight() + 'px'; } return css; }; }; return builder.build(); }]); }()); (function(){ 'use strict'; angular.module('gantt.labels').directive('ganttLabelsHeader', ['GanttDirectiveBuilder', function(Builder) { var builder = new Builder('ganttLabelsHeader', 'plugins/labels/labelsHeader.tmpl.html'); return builder.build(); }]); }()); (function(){ 'use strict'; angular.module('gantt.labels').directive('ganttSideContentLabels', ['GanttDirectiveBuilder', function(Builder) { var builder = new Builder('ganttSideContentLabels', 'plugins/labels/sideContentLabels.tmpl.html'); return builder.build(); }]); }()); angular.module('gantt.labels.templates', []).run(['$templateCache', function($templateCache) { $templateCache.put('plugins/labels/labelsBody.tmpl.html', '<div class="gantt-labels-body" ng-style="getLabelsCss()">\n' + ' <div gantt-vertical-scroll-receiver>\n' + ' <div ng-repeat="row in gantt.rowsManager.visibleRows track by row.model.id">\n' + ' <div gantt-row-label\n' + ' class="gantt-row-label gantt-row-height"\n' + ' ng-class="row.model.classes"\n' + ' ng-style="{\'height\': row.model.height}">\n' + ' <span class="gantt-label-text">{{row.model.name}}</span>\n' + ' </div>\n' + ' </div>\n' + ' </div>\n' + '</div>\n' + ''); $templateCache.put('plugins/labels/labelsHeader.tmpl.html', '<div class="gantt-labels-header">\n' + ' <div ng-show="gantt.columnsManager.columns.length > 0 && gantt.columnsManager.headers.length > 0">\n' + ' <div ng-repeat="header in gantt.columnsManager.headers">\n' + ' <div class="gantt-row-height" ng-class="{\'gantt-labels-header-row\': $last, \'gantt-labels-header-row-last\': $last}"><span>{{$last ? pluginScope.header : ""}}</span></div>\n' + ' </div>\n' + ' </div>\n' + '</div>\n' + ''); $templateCache.put('plugins/labels/sideContentLabels.tmpl.html', '<div class="gantt-side-content-labels">\n' + ' <gantt-labels-header>\n' + ' </gantt-labels-header>\n' + ' <gantt-labels-body>\n' + ' </gantt-labels-body>\n' + '</div>\n' + ''); }]); //# sourceMappingURL=angular-gantt-labels-plugin.js.map