UNPKG

acha-framework

Version:

is a modular framework on both client (angular.js) and server (node.js) side, it provides security, orm, ioc, obfuscation and ...

82 lines 2.71 kB
(function ($, angular, underscore, window, document, undefined) { 'use strict'; angular.module('frontend.directives').directive('treeContainer', [ '$rootScope', 'cultureService', 'recursion-helper', function ($rootScope, cultureService, recursionHelper) { return { restrict: 'E', replace: true, scope: { uuid: '=', isRoot: '=', parent: '=', items: '=?' }, templateUrl: '/templates/framework/directives/tree/tree-container.html', compile: function ($$element) { return recursionHelper.compile($$element, function (scope, element, attr) { scope.vm = {}; scope.vm.init = function () { if (angular.isUndefined(scope.disabled)) { scope.disabled = false; } if (angular.isUndefined(scope.visible)) { scope.visible = true; } if (angular.isUndefined(scope.cssClass)) { scope.cssClass = ''; } if (angular.isUndefined(scope.items)) { scope.items = []; } scope.vm.bind(); }; scope.vm.getNodeClass = function (node) { if (node.icon) return node.icon; if (node.items && node.items.length || node.expandable) return 'af-icon-folder'; return 'af-icon-file'; }; scope.vm.getNodeIcon = function (node) { var cls; if (node.expanded) cls = 'af-icon-chevron_down'; else { if (cultureService.rtl) cls = 'af-icon-chevron_left'; else cls = 'af-icon-chevron_right'; if (node.selected) { cls += '_hover'; } } return cls; }; scope.vm.onPick = function (node, $event) { $event.stopPropagation(); $event.preventDefault(); $rootScope.$broadcast(scope.uuid, { type: 'node-select', value: node }); }; scope.vm.onExpand = function (node, $event) { $event.stopPropagation(); $event.preventDefault(); $rootScope.$broadcast(scope.uuid, { type: 'node-expand', value: node }); }; scope.vm.bind = function () { }; scope.vm.init(); }); } }; } ]); }(jQuery, angular, _, window, document));