Skip to content

Commit e986714

Browse files
committed
add jstree
1 parent a9ac3c0 commit e986714

File tree

10 files changed

+8168
-1
lines changed

10 files changed

+8168
-1
lines changed

_tasks/download/tasks/download.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ module.exports = function(grunt) {
4444
var data = this.data;
4545

4646
grunt.log.writeln('downloading ' + data.url);
47-
request.get(data.url, function(err, res, body) {
47+
request.get({
48+
url: data.url,
49+
encoding: /\.(jpg|gif|png)$/.test(data.url) ? null : undefined
50+
}, function(err, res, body) {
4851
if (err) {
4952
grunt.log.error(err);
5053
} else if (res.statusCode !== 200) {
@@ -58,6 +61,7 @@ module.exports = function(grunt) {
5861
grunt.log.writeln('Add header and footer');
5962
code = [options.header || '', code, options.footer || ''].join('\n');
6063
}
64+
console.log(code);
6165
grunt.file.write(path.join(options.dest, data.name), code);
6266
grunt.log.ok();
6367
}

jstree/Gruntfile.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = function(grunt) {
2+
var pkg = grunt.file.readJSON('package.json');
3+
4+
grunt.initConfig({
5+
pkg: pkg,
6+
7+
download: {
8+
options: {
9+
dest: 'src'
10+
},
11+
src: {
12+
options: {
13+
transform: function(code) {
14+
code = 'define(function(require, exports, module) {\n' + code;
15+
code += '});';
16+
code = code.replace("require('jquery')", "require(\"$\")");
17+
return code;
18+
}
19+
},
20+
url: 'https://raw.githubusercontent.com/vakata/jstree/<%= pkg.version %>/dist/jstree.js',
21+
name: 'jstree.js'
22+
},
23+
css: {
24+
url: 'https://raw.githubusercontent.com/vakata/jstree/3.0.2/dist/themes/default/style.css',
25+
name: 'defalut.css'
26+
},
27+
png: {
28+
url: 'https://raw.githubusercontent.com/vakata/jstree/3.0.2/dist/themes/default/32px.png',
29+
name: '32px.png'
30+
},
31+
png2: {
32+
url: 'https://raw.githubusercontent.com/vakata/jstree/3.0.2/dist/themes/default/40px.png',
33+
name: '40px.png'
34+
}
35+
}
36+
});
37+
38+
grunt.loadGlobalTasks('spm-build');
39+
grunt.util._.merge(grunt.config.data, require('spm-build').config);
40+
41+
grunt.loadTasks('../_tasks/download/tasks');
42+
grunt.registerTask('build', ['download', 'spm-build']);
43+
};
44+

jstree/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# jstree
2+
3+
[jsTree][jstree] is a tree view for jQuery (depends on 1.9.1 or later).
4+
It is absolutely free (MIT licence) and supports all modern browsers and IE from version 8 up.
5+
jsTree can display trees by parsing HTML or JSON and supports AJAX, it is themeable and easy to configure and customize. Events are fired when the user interacts with the tree. Other notable features are inline editing, drag'n'drop support, fuzzy searching (with optional server side calls), tri-state checkbox support, configurable node types, AMD compatibility, easily extendable via plugins.
6+
[jstree]: http://www.jstree.com/
7+
8+
## Getting Started
9+
10+
Download or checkout the latest copy and include the scripts and styles in your web page. Then create an instance (in this case using the inline HTML).
11+
12+
```html
13+
<link rel="stylesheet" href="dist/themes/default/style.min.css" />
14+
<script src="dist/libs/jquery.js"></script>
15+
<script src="dist/jstree.min.js"></script>
16+
<script>
17+
$(function() {
18+
$('#container').jstree(/* optional config object here */);
19+
});
20+
</script>
21+
<div id="container">
22+
<ul>
23+
<li>Root node
24+
<ul>
25+
<li id="child_node">Child node</li>
26+
</ul>
27+
</li>
28+
</ul>
29+
</div>
30+
```
31+
32+
Listen for changes on the tree using events:
33+
34+
```html
35+
<script>
36+
$(function () {
37+
$('#container').on('changed.jstree', function (e, data) {
38+
console.log(data.selected);
39+
});
40+
});
41+
</script>
42+
```
43+
44+
And interact with the tree:
45+
46+
```html
47+
<script>
48+
$(function () {
49+
$('#container').jstree(true).select_node('child_node');
50+
});
51+
</script>
52+
```
53+
54+
For a complete list of configuration options, events and available functions refer to the [documentation][docs] and [demos][demo].
55+
[docs]: http://jstree.com/docs
56+
[demo]: http://jstree.com/demo
57+
58+
## Contributing
59+
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/gruntjs/grunt).
60+
61+
_Please do NOT edit files in the "dist" subdirectory as they are generated via grunt. You'll find source code in the "src" subdirectory!_
62+
63+
If you want to you can always [donate a small amount][paypal] to help the development of jstree.
64+
[paypal]: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@vakata.com&currency_code=USD&amount=&return=http://jstree.com/donation&item_name=Buy+me+a+coffee+for+jsTree
65+
66+
## License
67+
Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
68+
69+
Licensed under the [MIT license][mit].
70+
[mit]: http://www.opensource.org/licenses/mit-license.php

jstree/dist/32px.png

3.05 KB
Loading

jstree/dist/40px.png

1.84 KB
Loading

0 commit comments

Comments
 (0)