{"id":13802824,"url":"https://github.com/ezraroi/ngJsTree","last_synced_at":"2025-05-13T13:32:59.240Z","repository":{"id":20488545,"uuid":"23766708","full_name":"ezraroi/ngJsTree","owner":"ezraroi","description":"Angular Directive for the famous JS Tree ","archived":false,"fork":false,"pushed_at":"2023-05-29T07:55:54.000Z","size":2027,"stargazers_count":269,"open_issues_count":28,"forks_count":101,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-04-23T23:01:08.559Z","etag":null,"topics":["angular","jstree"],"latest_commit_sha":null,"homepage":"http://ezraroi.github.io/ngJsTree/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ezraroi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2014-09-07T18:01:31.000Z","updated_at":"2024-01-16T09:43:33.000Z","dependencies_parsed_at":"2022-09-09T11:40:38.846Z","dependency_job_id":"f781d1aa-0d31-4342-acd4-67297224b9af","html_url":"https://github.com/ezraroi/ngJsTree","commit_stats":{"total_commits":92,"total_committers":14,"mean_commits":6.571428571428571,"dds":0.1630434782608695,"last_synced_commit":"1dcb95f6d149ca6c56071a5baafa8c2c42a28c9b"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezraroi%2FngJsTree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezraroi%2FngJsTree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezraroi%2FngJsTree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezraroi%2FngJsTree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ezraroi","download_url":"https://codeload.github.com/ezraroi/ngJsTree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225229912,"owners_count":17441343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","jstree"],"created_at":"2024-08-04T00:01:58.969Z","updated_at":"2024-11-18T18:30:42.392Z","avatar_url":"https://github.com/ezraroi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Bower version](https://badge.fury.io/bo/ng-js-tree.svg)](http://badge.fury.io/bo/ng-js-tree)\n[![Build Status](https://travis-ci.org/ezraroi/ngJsTree.svg?branch=master)](https://travis-ci.org/ezraroi/ngJsTree)\n[![Dependency Status](https://gemnasium.com/ezraroi/ngJsTree.svg)](https://gemnasium.com/ezraroi/ngJsTree)\n[![Coverage Status](https://img.shields.io/coveralls/ezraroi/ngJsTree.svg)](https://coveralls.io/r/ezraroi/ngJsTree?branch=master)\n[![Code Climate](https://codeclimate.com/github/ezraroi/ngJsTree/badges/gpa.svg)](https://codeclimate.com/github/ezraroi/ngJsTree)\n[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)\n[![NPM](https://nodei.co/npm/ng-js-tree.png?mini=true)](https://npmjs.org/package/ng-js-tree)\n\nngJsTree\n========\n\nAngular Directive for the famous [JS Tree] library.\n\n\n## Dependencies\n\n\nThe ngJsTree depends on the following libraries:\n* Angular\n* JsTree\n\n\n## Install\n\n\nYou can install the ngJsTree with bower:\n\n```bat\nbower install ng-js-tree --save\n```\n\nor with npm:\n```bat\nnpm install ng-js-tree --save\n```\n\n\nor you can add the ngJsTree.min.js file to your HTML page:\n```html\n\u003cscript src=\"jquery.js\"/\u003e\n\u003cscript src=\"angular.js\"/\u003e\n\u003cscript src=\"jstree.min.js\"/\u003e\n\u003cscript src=\"ngJsTree.min.js\"/\u003e\n```\n\nAdd the `ngJsTree` to your module dependencies\n\n\n# Documentation\n\n\nYou can find the JSTree documentation at [this link]\n\n## Usage\n\n```html\n\u003cdiv js-tree=\"treeConfig\" ng-model=\"treeData\" should-apply=\"ignoreModelChanges()\" tree=\"treeInstance\" tree-events=\"ready:readyCB;create_node:createNodeCB\"\u003e\u003c/div\u003e\n```\n\n* `treeConfig` - This is the configuration object of the JsTree, if you will not supply one, an empty one will be created (not mandatory).\n* `treeData` - The array with the elements of the tree, will be used for data binding (adding / removing / updating this data will be reflected in the tree).\n* `ignoreModelChanges()` - A method that returns true or false. when returning false, model changes will not be reflected in the tree (not mandatory).\n* `treeInstance` - The Js Tree instance will be assigned to this variable in your controller scope (not mandatory).\n* `ready:readyCB;create_node:createNodeCB` - List of Js Tree events and callbacks in your controller scope that will be called for each event (not mandatory).\n\n\n### Registering for events\nYou can register a callback for any Js Tree event in one of the following ways:\n\n* add the `tree-events` attribute and specify the name of the events to register for and a callback for each event.\n\nExample:\n```html\n\u003cdiv ng-controller='myCtrl'\u003e\n    \u003cdiv js-tree=\"treeConfig\" ng-model=\"treeData\" should-apply=\"ignoreModelChanges()\" tree=\"treeInstance\" tree-events=\"ready:readyCB;create_node:createNodeCB\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n```\n\n```javascript\nangular.module('myApp').controller('myCtrl', function($scope,$log) {\n    $scope.readyCB = function() {\n        $log.info('ready called');\n    };\n\n    $scope.createNodeCB = function(e,item) {\n        $log.info('create_node called');\n    };\n);\n```\n\n* add the `tree-events-obj` attribute passing an object containing the list of events with the callback objects.\n\nExample:\n```html\n\u003cdiv ng-controller='myCtrl'\u003e\n    \u003cdiv js-tree=\"treeConfig\" ng-model=\"treeData\" should-apply=\"ignoreModelChanges()\" tree=\"treeInstance\" tree-events-obj=\"treeEventsObj\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n```\n\n```javascript\nangular.module('myApp').controller('myCtrl', function($scope,$log) {\n\n    $scope.treeEventsObj = {\n      'ready': readyCB,\n      'create_node': createNodeCB,\n      'select_node': selectNodeCB   // on node selected callback\n    }\n\n    function readyCB() {\n        $log.info('ready called');\n    };\n\n    function createNodeCB(e,item) {\n        $log.info('create_node called');\n    };\n    \n    function selectNodeCB(node, selected, event) {\n        $log.info(\"some_node_selected\");\n    };\n);\n```\n*NOTE:* Only one of the methods can be used to pass event callbacks, `tree-events` will take precedence.\n\n### Using the Js Tree API from your controller\nAdd the tree attribute to the jstree directive and assign it with a name of a variable in your controller that will hold the jstree instance.\n```html\n\u003cdiv ng-controller='myCtrl'\u003e\n    \u003cdiv js-tree=\"treeConfig\" ng-model=\"treeData\" tree=\"treeInstance\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n```\n\n```javascript\nfunction yourCtrl($scope)  {\n    var selected_nodes = $scope.treeInstance.jstree(true).get_selected();\n}\n```\n\n### Recreating the Tree\nIf from some reason you would like to recreate the tree, the right way to do it is update the tree configuration object. Once the directive will detect a change to the tree configuration it will destory the tree and recreate it.\n```javascript\nthis.treeConfig = {\n    core : {\n        multiple : false,\n        animation: true,\n        error : function(error) {\n            $log.error('treeCtrl: error from js tree - ' + angular.toJson(error));\n        },\n        check_callback : true,\n        worker : true\n    },\n    version : 1\n};\nthis.reCreateTree = function() {\n    this.treeConfig.version++;\n}\n```\n* The reason I am using the version property is because it is not a JsTree config property, so it will not effect the tree.\n\n## Development\n#### Prepare your environment\n\n* Install [Node.js](http://nodejs.org/) and NPM (should come with)\n* Install global dev dependencies: `npm install -g grunt-cli karma`\n* Install local dev dependencies: `npm install` while current directory is ngJsTree\n* Install javascript dependencies: `bower install` while current directory is ngJsTree\n\n#### Build\n* Build the whole project: `grunt` - this will run `jshint` and `test` and will build the project\n\n\n#### TDD\n* Run test: `grunt watch`\n\nLicense\n----\n\nMIT\n\n[JS Tree]:http://www.jstree.com/\n[this link]:http://www.jstree.com/api/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezraroi%2FngJsTree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fezraroi%2FngJsTree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezraroi%2FngJsTree/lists"}