11var app , deps ;
22
3- deps = [ 'ntt.TreeDnD' , 'ngRoute' ] ;
3+ deps = [ 'ntt.TreeDnD' , 'ngRoute' , 'toaster' , 'ngAnimate' , 'ui.bootstrap' ] ;
44
55app = angular . module ( 'TreeDnDTest' , deps )
6- . config (
7- [
8- '$routeProvider' ,
9- function ( $routeProvider ) {
10- $routeProvider
11- . when (
12- '/basic' , {
13- templateUrl : 'basic/basic-frame.html' ,
14- controller : 'BasicController'
15- }
16- )
17- . when (
18- '/filter' , {
19- templateUrl : 'filter/filter-frame.html' ,
20- controller : 'FilterController'
21- }
22- )
23- . when (
24- '/list' , {
25- templateUrl : 'list/list-frame.html' ,
26- controller : 'ListController'
27- }
28- )
29- . when (
30- '/multi' , {
31- templateUrl : 'multi/multi-frame.html' ,
32- controller : 'MultiController'
33- }
34- )
35- . when (
36- '/custom-options' , {
37- templateUrl : 'custom/custom-frame.html' ,
38- controller : 'CustomController'
39- }
40- )
41- . otherwise ( { redirectTo : '/basic' } ) ;
42- } ]
43- ) .
44- directive (
45- 'navigation' , function ( $rootScope , $location ) {
6+ . config ( [ '$routeProvider' , function ( $routeProvider ) {
7+ $routeProvider
8+ . when ( '/table' , {
9+ templateUrl : 'routers/filter/filter-frame.html' ,
10+ controller : 'FilterController'
11+ } )
12+ . when ( '/list' , {
13+ templateUrl : 'routers/list/list-frame.html' ,
14+ controller : 'ListController'
15+ } )
16+ . when ( '/multi' , {
17+ templateUrl : 'routers/multi/multi-frame.html' ,
18+ controller : 'MultiController'
19+ } )
20+ . when ( '/event' , {
21+ templateUrl : 'routers/basic/basic-frame.html' ,
22+ controller : 'BasicController'
23+ } )
24+ . when ( '/custom' , {
25+ templateUrl : 'routers/custom/custom-frame.html' ,
26+ controller : 'CustomController'
27+ } )
28+ . otherwise ( { redirectTo : '/table' } ) ;
29+ } ] )
30+ . directive ( 'navigation' , function ( $rootScope , $location ) {
4631 return {
4732 template : '<li ng-repeat="option in options" ng-class="{active: isActive(option)}">' +
4833 ' <a ng-href="{{option.href}}">{{option.label}}</a>' +
4934 '</li>' ,
5035 link : function ( scope , element , attr ) {
5136 scope . options = [
5237 {
53- label : 'Basic' ,
54- href : '#/basic'
55- } ,
56- {
57- label : 'Filter' ,
58- href : '#/filter'
38+ label : 'Table & Filter' ,
39+ href : '#/table'
5940 } ,
6041 {
6142 label : 'List Tree' ,
6243 href : '#/list'
6344 } ,
6445 {
65- label : 'Multi ' ,
46+ label : 'Advanced ' ,
6647 href : '#/multi'
6748 } ,
49+ {
50+ label : 'Events' ,
51+ href : '#/event'
52+ } ,
6853 {
6954
70- label : 'Custom Options ' ,
71- href : '#/custom-options '
55+ label : 'Custom' ,
56+ href : '#/custom'
7257 } ,
7358 {
7459 label : 'Github' ,
@@ -87,14 +72,13 @@ app = angular.module('TreeDnDTest', deps)
8772 ) ;
8873 }
8974 } ;
90- }
91- ) . directive (
92- 'panel' , function ( ) {
75+ } )
76+ . directive ( 'panel' , function ( ) {
9377 return {
94- restrict : 'E' ,
95- scope : true ,
96- replace : true ,
97- template : '<div class="panel" ng-class="\'panel-\' + type">' +
78+ restrict : 'E' ,
79+ scope : true ,
80+ replace : true ,
81+ template : '<div class="panel" ng-class="\'panel-\' + type">' +
9882 ' <div ng-if="title && title.length > 0" class="panel-heading">' +
9983 ' <h3 class="panel-title">{{ title }}</h3>' +
10084 ' </div>' +
@@ -103,44 +87,52 @@ app = angular.module('TreeDnDTest', deps)
10387 transclude : true ,
10488 link : function fnPost ( scope , element , attrs ) {
10589 scope . title = attrs . title || '' ;
106- scope . type = attrs . type || 'info' ;
90+ scope . type = attrs . type || 'info' ;
10791 }
10892 } ;
109- }
110- ) . directive (
111- 'showCode' , [
112- '$compile' , '$timeout' , function ( $compile , $timeout ) {
113- return {
114- restrict : 'E' ,
115- replace : true ,
116- link : function ( scope , element , attr ) {
117- var _temp =
118- [
119- '<pre class="line-numbers">' ,
120- '<code class="language-' + ( attr . type || 'markup' ) + '">' ,
121- '{{ data }}' ,
122- '</code>' ,
123- '</pre>' ] . join ( '' )
124- ;
125- scope . data = '' ;
93+ } )
94+ . directive ( 'showCode' , [ '$compile' , '$timeout' , function ( $compile , $timeout ) {
95+ return {
96+ restrict : 'E' ,
97+ replace : true ,
98+ link : function ( scope , element , attr ) {
99+ var _temp =
100+ [
101+ '<pre class="line-numbers">' ,
102+ '<code class="language-' + ( attr . type || 'markup' ) + '">' ,
103+ '{{ data }}' ,
104+ '</code>' ,
105+ '</pre>' ] . join ( '' )
106+ ;
107+ scope . data = '' ;
126108
127- scope . $watch (
128- attr . source , function ( val ) {
129- if ( val ) {
130- scope . data = val ;
131- element . html ( '' ) ;
132- element . append ( $compile ( _temp ) ( scope ) ) ;
133- $timeout ( Prism . highlightAll , 0 ) ;
134- }
135- } , true
136- ) ;
137- }
138- } ;
139- } ]
140- ) . factory (
141- 'DataDemo' , function ( ) {
109+ scope . $watch (
110+ attr . source , function ( val ) {
111+ if ( val ) {
112+ scope . data = val ;
113+ element . html ( '' ) ;
114+ element . append ( $compile ( _temp ) ( scope ) ) ;
115+ $timeout ( Prism . highlightAll , 0 ) ;
116+ }
117+ } , true
118+ ) ;
119+ }
120+ } ;
121+ } ] )
122+ . directive ( 'staticInclude' , function ( $http , $templateCache , $compile ) {
123+ return function ( scope , element , attrs ) {
124+ var templatePath = attrs . staticInclude ;
125+ $http . get ( templatePath , { cache : $templateCache } ) . success ( function ( response ) {
126+ var contents = element . html ( response ) . contents ( ) ;
127+ // console.log(contents);
128+ element . replaceWith ( contents ) ;
129+ $compile ( contents ) ( scope ) ;
130+ } ) ;
131+ } ;
132+ } )
133+ . factory ( 'DataDemo' , function ( ) {
142134 return {
143- getDatas : function ( ) {
135+ getDatas : function ( ) {
144136 return [
145137 {
146138 'DemographicId' : 1 ,
@@ -302,29 +294,29 @@ app = angular.module('TreeDnDTest', deps)
302294 }
303295
304296 console . time ( 'Generate_BigData' ) ;
305- var data = [ ] , opt = {
297+ var data = [ ] , opt = {
306298 amount : 0 ,
307299 deptMax : deptMax ,
308300 limit : number
309301 } , patern ,
310- fnGenerate = fn || function ( parent , cloned , _opt ) {
311- 'use strict' ;
312- var keyO = Object . keys ( cloned ) ,
313- lenO = keyO . length ;
314- if ( keyParent ) {
315- cloned [ keyParent ] = parent && parent [ keyId ] || null ;
316- }
302+ fnGenerate = fn || function ( parent , cloned , _opt ) {
303+ 'use strict' ;
304+ var keyO = Object . keys ( cloned ) ,
305+ lenO = keyO . length ;
306+ if ( keyParent ) {
307+ cloned [ keyParent ] = parent && parent [ keyId ] || null ;
308+ }
317309
318- cloned [ keyId ] = _opt . amount ;
310+ cloned [ keyId ] = _opt . amount ;
319311
320- for ( var i = 0 ; i < lenO ; i ++ ) {
321- if ( keyO [ i ] !== keyParent && keyO [ i ] !== keyId ) {
322- cloned [ keyO [ i ] ] += '#' + _opt . amount ;
323- }
312+ for ( var i = 0 ; i < lenO ; i ++ ) {
313+ if ( keyO [ i ] !== keyParent && keyO [ i ] !== keyId ) {
314+ cloned [ keyO [ i ] ] += '#' + _opt . amount ;
324315 }
316+ }
325317
326- return cloned ;
327- } ;
318+ return cloned ;
319+ } ;
328320
329321
330322 while ( opt . amount < number ) {
@@ -337,5 +329,4 @@ app = angular.module('TreeDnDTest', deps)
337329 return data ;
338330 }
339331 }
340- }
341- ) ;
332+ } ) ;
0 commit comments