directive.js
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"use strict";
var DirectiveModule = angular.module('DirectiveModule',[
'homeDirective'
]);
DirectiveModule.directive('keditorEdit',[
'$rootScope',
'$location',
'BaseService',
function ($rootScope, $location, BaseService) {
return {
restrict:'EA',
link:function(scope, el, attr) {
// KindEditor.ready(function(K) {
window.editor = KindEditor.create('#prodcut-keditor-edit',{
uploadJson : '../fileupload/kindUpload',
fileManagerJson : '../fileupload/kindUpload',
allowFileManager : true
});
// });
scope.$watch('details',function(value){
window.editor.html(value)
})
}
}
}
]);
DirectiveModule.directive('tree', [
'$rootScope',
'SysResourceService',
function($rootScope, SysResourceService) {
return {
require: '?ngModel',
restrict: 'A',
link: function (scope, element, attrs, ngModel) {
//var opts = angular.extend({}, $scope.$eval(attrs.nlUploadify));
var setting = {
check: {
enable: true
},
data: {
key : {
checked : 'checked'
},
simpleData: {
enable: true,
idKey: "id",
pIdKey: "parentId",
rootPId: 0
}
},
callback: {
onCheck: function (event, treeId, treeNode, clickFlag) {
console.log(treeNode);
},
onClick:function(event, treeId, treeNode, clickFlag) {
scope.resource={
id:treeNode.id,
name:treeNode.name,
type:treeNode.type,
parentId:treeNode.parentId,
resourceUrl:treeNode.resourceUrl,
target:treeNode.target,
iconImg:treeNode.iconImg,
sort:treeNode.sort,
isShow:1
};
$rootScope.$apply();
}
}
};
scope.ztrees = [];
SysResourceService.getTreeSysResource(function (res) {
if(res.code == 0) {
scope.ztrees = res.data;
$.fn.zTree.init(element, setting, scope.ztrees);
}
});
}
};
}
]);
DirectiveModule.directive('onClickMenu', function ($timeout) {
return {
restrict: 'A',
link: function(scope, element, attr) {
if (scope.$last === true) {
$timeout(function() {
scope.$emit('ngRepeatFinished');
});
}
}
};
});