infrastructureModule.directive('roleManage', ['$log', function ($log) { 'use strict'; $log.debug('roleManage.ctor()...'); return { restrict: 'E', templateUrl: '/app/admin/infrastructure/roleManage/views/role-manage.html' + '?_=' + Math.random(), replace: true, scope: {}, controller: 'RoleManageController', link: function (scope, element) { $(document).on({ mouseenter: function (e) { $(this).css('font-weight', 'bold'); }, mouseleave: function (e) { $(this).css('font-weight', 'normal'); } }, '.icon-role-category-modify,.icon-role-category-delete,.ng-inline-edit__button'); $(document).on('click', '.ng-inline-edit__button--edit', function () { }); Split(['#left-container', '#right-container'], { //An array of initial sizes of the elements, specified as percentage values. Example: Setting the initial sizes to 25% and 75%. sizes: [22, 78], //An array of minimum sizes of the elements, specified as pixel values. Example: Setting the minimum sizes to 100px and 300px, respectively. minSize: [250, 750], onDragEnd: function () { //$timeout(function () { // $rootScope.$broadcast(enums.vatEvent.layoutChanged, {}); //}, 700); } }) } }; } ]); infrastructureModule.directive('roleNameUnique', ['$q', 'roleService', function ($q, roleService) { return { require: 'ngModel', link: function (scope, elm, attrs, ctrl) { if (!ctrl) return; ctrl.$asyncValidators.roleNameUnique = function (modelValue, viewValue) { if (ctrl.$isEmpty(modelValue)) { $q.resolve(); } var def = $q.defer(); var newRoleName = $('#EditRoleName').val(); //scope.roleUpdatedModel.editRoleName; var oldRoleName = scope.selectedRole.name; roleService.validateRoleNameUnique(newRoleName, oldRoleName) .success(function (data, status, headers, config) { if (data) { def.resolve(); } else { def.reject(); } }) .error(function (data, status, headers, config) { def.reject(); }); return def.promise; }; } } }]); infrastructureModule.directive("editableDiv", function () { return { restrict: "A", require: "ngModel", link: function (scope, element, attrs, ngModel) { function read() { // view -> model var html = element.html(); html = html.replace(/ /g, "\u00a0"); ngModel.$setViewValue(html); } // model -> view ngModel.$render = function () { element.html(ngModel.$viewValue || ""); }; element.bind("blur", function () { scope.$apply(read); }); element.bind("keydown keypress", function (event) { if (event.which === 13) { this.blur(); event.preventDefault(); } }); } }; });