kms 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/kms/application/controllers/pages_controller.coffee.erb +1 -2
- data/app/assets/javascripts/templates/assets/index.html.slim +4 -12
- data/app/assets/javascripts/templates/help/scopes.html.slim +74 -0
- data/app/assets/javascripts/templates/pages/index.html.slim +4 -3
- data/app/assets/javascripts/templates/snippets/index.html.slim +4 -3
- data/app/assets/javascripts/templates/templates/index.html.slim +4 -3
- data/app/assets/javascripts/templates/users/index.html.slim +3 -2
- data/app/assets/stylesheets/kms/custom.css.scss +3 -0
- data/app/controllers/kms/pages_controller.rb +2 -2
- data/app/models/ability.rb +0 -1
- data/app/models/concerns/kms/positioned.rb +18 -0
- data/app/models/kms/page.rb +2 -12
- data/app/services/kms/functions_registry.rb +11 -0
- data/app/uploaders/kms/asset_uploader.rb +1 -1
- data/config/initializers/help.rb +1 -1
- data/config/initializers/liquor.rb +0 -47
- data/config/locales/en.yml +22 -0
- data/config/locales/ru.yml +22 -0
- data/lib/generators/kms/install/install_generator.rb +2 -0
- data/lib/generators/kms/install/templates/carrierwave.rb +14 -0
- data/lib/kms/dependencies.rb +2 -0
- data/lib/kms/engine.rb +1 -1
- data/lib/kms/version.rb +1 -1
- data/spec/controllers/kms/snippets_controller_spec.rb +6 -6
- data/spec/internal/log/test.log +2439 -0
- data/spec/services/kms/functions_registry_spec.rb +14 -0
- data/spec/spec_helper.rb +1 -1
- data/vendor/assets/bower.json +1 -1
- data/vendor/assets/bower_components/angular-ui-tree/CHANGELOG.md +164 -0
- data/vendor/assets/bower_components/angular-ui-tree/CONTRIBUTING.md +39 -0
- data/vendor/assets/bower_components/angular-ui-tree/README.md +145 -37
- data/vendor/assets/bower_components/angular-ui-tree/bower.json +28 -18
- data/vendor/assets/bower_components/angular-ui-tree/{source → dist}/angular-ui-tree.css +18 -16
- data/vendor/assets/bower_components/angular-ui-tree/dist/angular-ui-tree.js +1408 -822
- data/vendor/assets/bower_components/angular-ui-tree/dist/angular-ui-tree.min.css +1 -2
- data/vendor/assets/bower_components/angular-ui-tree/dist/angular-ui-tree.min.js +3 -3
- data/vendor/assets/bower_components/angular-ui-tree/e2e/basic-example/basic-example.js +81 -0
- data/vendor/assets/bower_components/angular-ui-tree/e2e/basic-example/page.js +42 -0
- data/vendor/assets/bower_components/angular-ui-tree/e2e/table-example/page.js +31 -0
- data/vendor/assets/bower_components/angular-ui-tree/e2e/table-example/table-example.js +34 -0
- data/vendor/assets/bower_components/angular-ui-tree/index.js +2 -0
- data/vendor/assets/bower_components/angular-ui-tree/protractor.conf.js +19 -0
- data/vendor/assets/bower_components/angular/angular.js +4880 -2111
- data/vendor/assets/bower_components/angular/angular.min.js +320 -297
- data/vendor/assets/bower_components/angular/angular.min.js.gzip +0 -0
- data/vendor/assets/bower_components/angular/angular.min.js.map +3 -3
- data/vendor/assets/bower_components/angular/bower.json +1 -1
- data/vendor/assets/bower_components/angular/package.json +1 -1
- metadata +32 -40
- data/vendor/assets/bower_components/angular-ui-tree/Gruntfile.js +0 -229
- data/vendor/assets/bower_components/angular-ui-tree/build/compiler.jar +0 -0
- data/vendor/assets/bower_components/angular-ui-tree/demo/css/demo-horizontal.css +0 -47
- data/vendor/assets/bower_components/angular-ui-tree/demo/css/demo.css +0 -31
- data/vendor/assets/bower_components/angular-ui-tree/demo/css/tree.css +0 -25
- data/vendor/assets/bower_components/angular-ui-tree/demo/dist/angular-ui-tree.js +0 -1243
- data/vendor/assets/bower_components/angular-ui-tree/demo/dist/angular-ui-tree.min.css +0 -2
- data/vendor/assets/bower_components/angular-ui-tree/demo/dist/angular-ui-tree.min.js +0 -6
- data/vendor/assets/bower_components/angular-ui-tree/demo/filter.html +0 -64
- data/vendor/assets/bower_components/angular-ui-tree/demo/groups.html +0 -100
- data/vendor/assets/bower_components/angular-ui-tree/demo/index.html +0 -101
- data/vendor/assets/bower_components/angular-ui-tree/demo/js/demo.js +0 -63
- data/vendor/assets/bower_components/angular-ui-tree/demo/js/filter.js +0 -91
- data/vendor/assets/bower_components/angular-ui-tree/demo/js/groups.js +0 -143
- data/vendor/assets/bower_components/angular-ui-tree/demo/js/tree.js +0 -102
- data/vendor/assets/bower_components/angular-ui-tree/demo/js/trees.js +0 -60
- data/vendor/assets/bower_components/angular-ui-tree/demo/test.html +0 -60
- data/vendor/assets/bower_components/angular-ui-tree/demo/tree-horizontal.html +0 -66
- data/vendor/assets/bower_components/angular-ui-tree/demo/tree.html +0 -66
- data/vendor/assets/bower_components/angular-ui-tree/demo/trees.html +0 -92
- data/vendor/assets/bower_components/angular-ui-tree/guide/00_usage.ngdoc +0 -78
- data/vendor/assets/bower_components/angular-ui-tree/guide/01_development_setup.ngdoc +0 -58
- data/vendor/assets/bower_components/angular-ui-tree/guide/index.ngdoc +0 -33
- data/vendor/assets/bower_components/angular-ui-tree/karma.conf.js +0 -49
- data/vendor/assets/bower_components/angular-ui-tree/package.json +0 -40
- data/vendor/assets/bower_components/angular-ui-tree/source/angular-ui-tree.scss +0 -63
- data/vendor/assets/bower_components/angular-ui-tree/source/controllers/handleCtrl.js +0 -16
- data/vendor/assets/bower_components/angular-ui-tree/source/controllers/nodeCtrl.js +0 -141
- data/vendor/assets/bower_components/angular-ui-tree/source/controllers/nodesCtrl.js +0 -100
- data/vendor/assets/bower_components/angular-ui-tree/source/controllers/treeCtrl.js +0 -63
- data/vendor/assets/bower_components/angular-ui-tree/source/directives/uiTree.js +0 -115
- data/vendor/assets/bower_components/angular-ui-tree/source/directives/uiTreeHandle.js +0 -27
- data/vendor/assets/bower_components/angular-ui-tree/source/directives/uiTreeNode.js +0 -427
- data/vendor/assets/bower_components/angular-ui-tree/source/directives/uiTreeNodes.js +0 -59
- data/vendor/assets/bower_components/angular-ui-tree/source/main.js +0 -23
- data/vendor/assets/bower_components/angular-ui-tree/source/services/helper.js +0 -265
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
@ngdoc overview
|
|
2
|
-
@name Usage
|
|
3
|
-
@description
|
|
4
|
-
|
|
5
|
-
# Usage
|
|
6
|
-
|
|
7
|
-
In this section we will give step-by-step instructions on how you get
|
|
8
|
-
up and running with Angular-NestedSortable in just a few steps.
|
|
9
|
-
|
|
10
|
-
## 1. Download Angular-NestedSortable
|
|
11
|
-
|
|
12
|
-
You can install the `Angular-NestedSortable` package very easily using Bower. After
|
|
13
|
-
installing Bower on your machine, simply run:
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
$ bower install Angular-NestedSortable
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## 2. Include the sources
|
|
20
|
-
|
|
21
|
-
Load the file `angular-nested-sortable.js` in your application.
|
|
22
|
-
|
|
23
|
-
````
|
|
24
|
-
<script type="text/javascript" src="bower_components/angular-nested-sortable/angular-nested-sortable.js"></script>
|
|
25
|
-
````
|
|
26
|
-
|
|
27
|
-
## 3. Add dependency to your AngularJS application
|
|
28
|
-
|
|
29
|
-
Add the sortable module as a dependency to your application module.
|
|
30
|
-
|
|
31
|
-
````
|
|
32
|
-
var app = angular.module('MyApp', ['ui.nestedSortable'])
|
|
33
|
-
````
|
|
34
|
-
|
|
35
|
-
## 4. Setup the NestedSortable template
|
|
36
|
-
|
|
37
|
-
You have all the freedom when creating the HTML for your NestedSortable tree component.
|
|
38
|
-
It's up to you to choose the elements you want to use, you only need to include the Angular-NestedSortable controllers.
|
|
39
|
-
|
|
40
|
-
### Example 1
|
|
41
|
-
|
|
42
|
-
Tree with one level nesting supports.
|
|
43
|
-
|
|
44
|
-
````
|
|
45
|
-
<ol ui-nested-sortable="" ng-model="list">
|
|
46
|
-
<li ng-repeat="item in list" ui-nested-sortable-item="">
|
|
47
|
-
<div ui-nested-sortable-handle>
|
|
48
|
-
{{item.title}}
|
|
49
|
-
</div>
|
|
50
|
-
<ol ui-nested-sortable="" ng-model="item.items">
|
|
51
|
-
<li ng-repeat="subItem in item.items" ui-nested-sortable-item="">
|
|
52
|
-
<div ui-nested-sortable-handle>
|
|
53
|
-
{{subItem.title}}
|
|
54
|
-
</div>
|
|
55
|
-
</li>
|
|
56
|
-
</ol>
|
|
57
|
-
</li>
|
|
58
|
-
</ol>
|
|
59
|
-
````
|
|
60
|
-
|
|
61
|
-
### Example 2
|
|
62
|
-
|
|
63
|
-
Support unlimited nesting using a template for the menu items.
|
|
64
|
-
|
|
65
|
-
````
|
|
66
|
-
<script type="text/ng-template" id="items_renderer.html">
|
|
67
|
-
<div ui-nested-sortable-handle>
|
|
68
|
-
{{item.title}}
|
|
69
|
-
</div>
|
|
70
|
-
<ol ui-nested-sortable="options" ng-model="item.items">
|
|
71
|
-
<li ng-repeat="item in item.items" ui-nested-sortable-item="" ng-include="'items_renderer.html'"></li>
|
|
72
|
-
</ol>
|
|
73
|
-
</script>
|
|
74
|
-
|
|
75
|
-
<ol ui-nested-sortable="options" ng-model="list" id="nested-sortable-root">
|
|
76
|
-
<li ng-repeat="item in list" ui-nested-sortable-item="" ng-include="'items_renderer.html'"></li>
|
|
77
|
-
</ol>
|
|
78
|
-
````
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
@ngdoc overview
|
|
2
|
-
@name Development setup
|
|
3
|
-
@description
|
|
4
|
-
|
|
5
|
-
# Development environment setup
|
|
6
|
-
|
|
7
|
-
## Prerequisites
|
|
8
|
-
|
|
9
|
-
* [Node Package Manager](https://npmjs.org/) (NPM)
|
|
10
|
-
* [Git](http://git-scm.com/)
|
|
11
|
-
|
|
12
|
-
## Dependencies
|
|
13
|
-
|
|
14
|
-
* [Grunt](http://gruntjs.com/) (task automation)
|
|
15
|
-
* [Bower](http://bower.io/) (package management)
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
Run the commands below in the project root directory.
|
|
20
|
-
|
|
21
|
-
###1. Install Grunt and Bower
|
|
22
|
-
|
|
23
|
-
$ sudo npm install -g grunt-cli bower
|
|
24
|
-
|
|
25
|
-
###2. Install project dependencies
|
|
26
|
-
|
|
27
|
-
$ npm install
|
|
28
|
-
$ bower install
|
|
29
|
-
|
|
30
|
-
## Useful commands
|
|
31
|
-
|
|
32
|
-
### Running a local webserver
|
|
33
|
-
To debug code and run end-to-end tests, it is often useful to have a local HTTP server. For this purpose, we have made available a local web server based on Node.js.
|
|
34
|
-
|
|
35
|
-
To start the web server, run:
|
|
36
|
-
|
|
37
|
-
$ grunt webserver
|
|
38
|
-
|
|
39
|
-
To access the local server, enter the following URL into your web browser:
|
|
40
|
-
|
|
41
|
-
http://localhost:8080/demo/
|
|
42
|
-
|
|
43
|
-
By default, it serves the contents of the demo project.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
### Build source
|
|
47
|
-
|
|
48
|
-
To build Angular-NestedSortable, use the following command.
|
|
49
|
-
|
|
50
|
-
$ grunt build
|
|
51
|
-
|
|
52
|
-
This will generate a concatenated- and minified JavaScript file in the `dist` directory.
|
|
53
|
-
|
|
54
|
-
### Run tests
|
|
55
|
-
You can run the tests once or choose to run them continuously.
|
|
56
|
-
|
|
57
|
-
$ grunt test
|
|
58
|
-
$ grunt test:continuous
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
@ngdoc overview
|
|
2
|
-
@name Guide
|
|
3
|
-
@description
|
|
4
|
-
|
|
5
|
-
# Angular NestedSortable
|
|
6
|
-
|
|
7
|
-
<br>
|
|
8
|
-
Angular NestedSortable is an AngularJS UI component that can sort nested lists,
|
|
9
|
-
provides drag & drop support and doesn't depend on jQuery.
|
|
10
|
-
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
- Uses the native AngularJS scope for data binding
|
|
14
|
-
- Sorted and move items through the entire tree
|
|
15
|
-
- Prevent elements from accepting child nodes
|
|
16
|
-
|
|
17
|
-
If you like the module and use it in your projects, make it public on
|
|
18
|
-
[ngmodules](http://ngmodules.org/modules/Angular-NestedSortable) and click the "_I use it_" button!
|
|
19
|
-
|
|
20
|
-
## Browser support
|
|
21
|
-
|
|
22
|
-
The Angular NestedSortable is tested with the following browsers:
|
|
23
|
-
|
|
24
|
-
- Chrome (stable)
|
|
25
|
-
- Firefox
|
|
26
|
-
- IE 8, 9 and 10
|
|
27
|
-
|
|
28
|
-
For IE8 support, make sure you do the following:
|
|
29
|
-
|
|
30
|
-
- include an [ES5 shim](https://github.com/es-shims/es5-shim)
|
|
31
|
-
- make your [AngularJS application compatible with Internet Explorer](http://docs.angularjs.org/guide/ie)
|
|
32
|
-
- use [jQuery 1.x](http://jquery.com/browser-support/)
|
|
33
|
-
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
module.exports = function(config) {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var cfg = {
|
|
5
|
-
bowerComponents: 'demo/bower_components'
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
config.set({
|
|
9
|
-
basePath: '',
|
|
10
|
-
frameworks: ['jasmine'],
|
|
11
|
-
|
|
12
|
-
// files to load in the browser
|
|
13
|
-
files: [
|
|
14
|
-
// components
|
|
15
|
-
cfg.bowerComponents + '/jquery/dist/jquery.js',
|
|
16
|
-
cfg.bowerComponents + '/jasmine-jquery/lib/jasmine-jquery.js',
|
|
17
|
-
cfg.bowerComponents + '/angular/angular.js',
|
|
18
|
-
cfg.bowerComponents + '/angular-mocks/angular-mocks.js',
|
|
19
|
-
|
|
20
|
-
// source files
|
|
21
|
-
'source/main.js',
|
|
22
|
-
'source/**/*.js',
|
|
23
|
-
|
|
24
|
-
// tests
|
|
25
|
-
'tests/**/*.spec.js'
|
|
26
|
-
],
|
|
27
|
-
|
|
28
|
-
// generate js files from html templates to expose them during testing
|
|
29
|
-
preprocessors: {
|
|
30
|
-
'**/*.html': 'ng-html2js'
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
// https://github.com/karma-runner/karma-ng-html2js-preprocessor#configuration
|
|
34
|
-
ngHtml2JsPreprocessor: {
|
|
35
|
-
// setting this option will create only a single module that contains templates
|
|
36
|
-
// from all the files, so you can load them all with module('foo')
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
// files to exclude
|
|
40
|
-
exclude: [],
|
|
41
|
-
|
|
42
|
-
// level of logging
|
|
43
|
-
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
|
|
44
|
-
logLevel: config.LOG_INFO,
|
|
45
|
-
|
|
46
|
-
port: 9876,
|
|
47
|
-
reporters: 'dots'
|
|
48
|
-
});
|
|
49
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "Angular-NestedSortable",
|
|
3
|
-
"version": "2.1.5",
|
|
4
|
-
"dependencies": {
|
|
5
|
-
"grunt": "~0.4.2",
|
|
6
|
-
"grunt-contrib-jshint": "~0.8.0",
|
|
7
|
-
"load-grunt-tasks": "~0.2.1"
|
|
8
|
-
},
|
|
9
|
-
"devDependencies": {
|
|
10
|
-
"bower": "~1.2.6",
|
|
11
|
-
"jshint-stylish": "~0.1.5",
|
|
12
|
-
"grunt-contrib-clean": "~0.5.0",
|
|
13
|
-
"grunt-contrib-copy": "~0.4.1",
|
|
14
|
-
"grunt-contrib-watch": "~0.5.3",
|
|
15
|
-
"grunt-contrib-uglify": "~0.3.2",
|
|
16
|
-
"grunt-closure-compiler": "~0.0.21",
|
|
17
|
-
"grunt-contrib-concat": "~0.3.0",
|
|
18
|
-
"grunt-open": "~0.2.3",
|
|
19
|
-
"grunt-contrib-connect": "~0.6.0",
|
|
20
|
-
"karma-script-launcher": "~0.1.0",
|
|
21
|
-
"karma-chrome-launcher": "~0.1.2",
|
|
22
|
-
"karma-firefox-launcher": "~0.1.3",
|
|
23
|
-
"karma-ng-html2js-preprocessor": "~0.1.0",
|
|
24
|
-
"grunt-html2js": "~0.2.4",
|
|
25
|
-
"grunt-karma": "~0.6.2",
|
|
26
|
-
"karma-phantomjs-launcher": "~0.1.2",
|
|
27
|
-
"karma-html2js-preprocessor": "~0.1.0",
|
|
28
|
-
"karma-jasmine": "~0.1.5",
|
|
29
|
-
"karma-coffee-preprocessor": "~0.1.2",
|
|
30
|
-
"requirejs": "~2.1.10",
|
|
31
|
-
"karma-requirejs": "~0.2.1",
|
|
32
|
-
"karma": "~0.10.9",
|
|
33
|
-
"grunt-tasks-list": "~0.1.1",
|
|
34
|
-
"grunt-ngdocs": "~0.2.1",
|
|
35
|
-
"grunt-contrib-cssmin": "~0.9.0"
|
|
36
|
-
},
|
|
37
|
-
"engines": {
|
|
38
|
-
"node": ">=0.8.0"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
.angular-ui-tree {
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.angular-ui-tree-empty {
|
|
6
|
-
border: 1px dashed #bbb;
|
|
7
|
-
min-height: 100px;
|
|
8
|
-
background-color: #e5e5e5;
|
|
9
|
-
background-image: -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
|
|
10
|
-
background-image: -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
|
|
11
|
-
background-image: linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
|
|
12
|
-
background-size: 60px 60px;
|
|
13
|
-
background-position: 0 0, 30px 30px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.angular-ui-tree-nodes {
|
|
17
|
-
display: block;
|
|
18
|
-
position: relative;
|
|
19
|
-
margin: 0px;
|
|
20
|
-
padding: 0px;
|
|
21
|
-
list-style: none;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.angular-ui-tree-nodes .angular-ui-tree-nodes {
|
|
25
|
-
padding-left: 20px;
|
|
26
|
-
}
|
|
27
|
-
.angular-ui-tree-node, .angular-ui-tree-placeholder {
|
|
28
|
-
display: block;
|
|
29
|
-
position: relative;
|
|
30
|
-
margin: 0px;
|
|
31
|
-
padding: 0px;
|
|
32
|
-
min-height: 20px;
|
|
33
|
-
line-height: 20px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.angular-ui-tree-hidden {
|
|
37
|
-
display: none;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.angular-ui-tree-placeholder {
|
|
41
|
-
margin: 5px 0;
|
|
42
|
-
padding: 0;
|
|
43
|
-
min-height: 30px;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.angular-ui-tree-handle {
|
|
47
|
-
cursor: move;
|
|
48
|
-
text-decoration: none;
|
|
49
|
-
font-weight: bold;
|
|
50
|
-
-webkit-box-sizing: border-box;
|
|
51
|
-
-moz-box-sizing: border-box;
|
|
52
|
-
box-sizing: border-box;
|
|
53
|
-
min-height: 20px;
|
|
54
|
-
line-height: 20px;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
.angular-ui-tree-drag {
|
|
59
|
-
position: absolute;
|
|
60
|
-
pointer-events: none;
|
|
61
|
-
z-index: 999;
|
|
62
|
-
opacity: .8;
|
|
63
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
(function () {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
angular.module('ui.tree')
|
|
5
|
-
|
|
6
|
-
.controller('TreeHandleController', ['$scope', '$element', '$attrs', 'treeConfig',
|
|
7
|
-
function ($scope, $element, $attrs, treeConfig) {
|
|
8
|
-
this.scope = $scope;
|
|
9
|
-
|
|
10
|
-
$scope.$element = $element;
|
|
11
|
-
$scope.$nodeScope = null;
|
|
12
|
-
$scope.$type = 'uiTreeHandle';
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
]);
|
|
16
|
-
})();
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
(function () {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
angular.module('ui.tree')
|
|
5
|
-
|
|
6
|
-
.controller('TreeNodeController', ['$scope', '$element', '$attrs', 'treeConfig',
|
|
7
|
-
function ($scope, $element, $attrs, treeConfig) {
|
|
8
|
-
this.scope = $scope;
|
|
9
|
-
|
|
10
|
-
$scope.$element = $element;
|
|
11
|
-
$scope.$modelValue = null; // Model value for node;
|
|
12
|
-
$scope.$parentNodeScope = null; // uiTreeNode Scope of parent node;
|
|
13
|
-
$scope.$childNodesScope = null; // uiTreeNodes Scope of child nodes.
|
|
14
|
-
$scope.$parentNodesScope = null; // uiTreeNodes Scope of parent nodes.
|
|
15
|
-
$scope.$treeScope = null; // uiTree scope
|
|
16
|
-
$scope.$handleScope = null; // it's handle scope
|
|
17
|
-
$scope.$type = 'uiTreeNode';
|
|
18
|
-
$scope.$$apply = false; //
|
|
19
|
-
|
|
20
|
-
$scope.collapsed = false;
|
|
21
|
-
|
|
22
|
-
$scope.init = function(controllersArr) {
|
|
23
|
-
var treeNodesCtrl = controllersArr[0];
|
|
24
|
-
$scope.$treeScope = controllersArr[1] ? controllersArr[1].scope : null;
|
|
25
|
-
|
|
26
|
-
// find the scope of it's parent node
|
|
27
|
-
$scope.$parentNodeScope = treeNodesCtrl.scope.$nodeScope;
|
|
28
|
-
// modelValue for current node
|
|
29
|
-
$scope.$modelValue = treeNodesCtrl.scope.$modelValue[$scope.$index];
|
|
30
|
-
$scope.$parentNodesScope = treeNodesCtrl.scope;
|
|
31
|
-
treeNodesCtrl.scope.initSubNode($scope); // init sub nodes
|
|
32
|
-
|
|
33
|
-
$element.on('$destroy', function() {
|
|
34
|
-
treeNodesCtrl.scope.destroySubNode($scope); // destroy sub nodes
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
$scope.index = function() {
|
|
39
|
-
return $scope.$parentNodesScope.$modelValue.indexOf($scope.$modelValue);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
$scope.dragEnabled = function() {
|
|
43
|
-
return !($scope.$treeScope && !$scope.$treeScope.dragEnabled);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
$scope.isSibling = function(targetNode) {
|
|
47
|
-
return $scope.$parentNodesScope == targetNode.$parentNodesScope;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
$scope.isChild = function(targetNode) {
|
|
51
|
-
var nodes = $scope.childNodes();
|
|
52
|
-
return nodes && nodes.indexOf(targetNode) > -1;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
$scope.prev = function() {
|
|
56
|
-
var index = $scope.index();
|
|
57
|
-
if (index > 0) {
|
|
58
|
-
return $scope.siblings()[index - 1];
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
$scope.siblings = function() {
|
|
64
|
-
return $scope.$parentNodesScope.childNodes();
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
$scope.childNodesCount = function() {
|
|
68
|
-
return $scope.childNodes() ? $scope.childNodes().length : 0;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
$scope.hasChild = function() {
|
|
72
|
-
return $scope.childNodesCount() > 0;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
$scope.childNodes = function() {
|
|
76
|
-
return $scope.$childNodesScope && $scope.$childNodesScope.$modelValue ?
|
|
77
|
-
$scope.$childNodesScope.childNodes() :
|
|
78
|
-
null;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
$scope.accept = function(sourceNode, destIndex) {
|
|
82
|
-
return $scope.$childNodesScope &&
|
|
83
|
-
$scope.$childNodesScope.$modelValue &&
|
|
84
|
-
$scope.$childNodesScope.accept(sourceNode, destIndex);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
$scope.removeNode = function(){
|
|
88
|
-
var node = $scope.remove();
|
|
89
|
-
$scope.$callbacks.removed(node);
|
|
90
|
-
return node;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
$scope.remove = function() {
|
|
94
|
-
return $scope.$parentNodesScope.removeNode($scope);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
$scope.toggle = function() {
|
|
98
|
-
$scope.collapsed = !$scope.collapsed;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
$scope.collapse = function() {
|
|
102
|
-
$scope.collapsed = true;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
$scope.expand = function() {
|
|
106
|
-
$scope.collapsed = false;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
$scope.depth = function() {
|
|
110
|
-
var parentNode = $scope.$parentNodeScope;
|
|
111
|
-
if (parentNode) {
|
|
112
|
-
return parentNode.depth() + 1;
|
|
113
|
-
}
|
|
114
|
-
return 1;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
var subDepth = 0;
|
|
118
|
-
var countSubDepth = function(scope) {
|
|
119
|
-
var count = 0;
|
|
120
|
-
var nodes = scope.childNodes();
|
|
121
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
122
|
-
var childNodes = nodes[i].$childNodesScope;
|
|
123
|
-
if (childNodes) {
|
|
124
|
-
count = 1;
|
|
125
|
-
countSubDepth(childNodes);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
subDepth += count;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
$scope.maxSubDepth = function() {
|
|
132
|
-
subDepth = 0;
|
|
133
|
-
if ($scope.$childNodesScope) {
|
|
134
|
-
countSubDepth($scope.$childNodesScope);
|
|
135
|
-
}
|
|
136
|
-
return subDepth;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
]);
|
|
141
|
-
})();
|