Giter Site home page Giter Site logo

looper-575 / ng-nestable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kamilkp/ng-nestable

0.0 2.0 0.0 584 KB

Angular module for jQuery nestable plugin

Home Page: http://kamilkp.github.io/ng-nestable

License: MIT License

CSS 15.18% JavaScript 84.82%

ng-nestable's Introduction

angular-nestable 0.0.1 Bower version

###DEMO: check out the demo here

###DESCRIPTION: angular-nestable is a module for AngularJS that uses the jQuery nestable plugin to create multi-sortable lists with the ability to nest items within each other.

###INSTALLATION

Either run bower install ng-nestable or download angular-nestable.js form the repository directly.

Include the module in your app dependency:

angular.module('yourAppModule', ['ng-nestable']);

Note that this module requires jQuery and jQuery nestable plugin.

###USAGE:

<div ng-nestable ng-model="items">
	<div>
		<!-- this element is the template for each menu item -->
		<!-- the $item is available on scope and is the reference to the menu item object -->
		{{$item}}
	</div>
</div>

Example items object structure:

[
	{
		item: {}, // this object will be referenced as the $item on scope
		children: []
	},
	{
		item: {},
		children: [
			{
				item: {},
				children: []
			}
		]
	},
	{
		item: {},
		children: []
	}
]

Each nestable element in the DOM gets it's own non-isolated scope just like with ng-repeat.

Also the options object can be passed to the directive as the ng-nestable attribute. Those options will be passed to the jQuery nestable function when creating a nestable.

===

The module also exposes a $nestableProvider that can be injected into a config block. It provides two methods:

  • $nestableProvider.modelName(str) - can be used to set the model name variable inside each nestable element. The default value of model name is $item.

  • $nestableProvider.defaultOptions(obj) - can be used to set some default options for the nestable jquery plugin. Those options include the following: (extract from the jQuery nestable readme)

     maxDepth        : number of levels an item can be nested (default 5)
     group           : group ID to allow dragging between lists (default 0)
    
     listNodeName    : The HTML element to create for lists (default 'ol')
     itemNodeName    : The HTML element to create for list items (default 'li')
     rootClass       : The class of the root element .nestable() was used on (default 'dd')
     listClass       : The class of all list elements (default 'dd-list')
     itemClass       : The class of all list item elements (default 'dd-item')
     dragClass       : The class applied to the list element that is being dragged (default 'dd-dragel')
     handleClass     : The class of the content element inside each list item (default 'dd-handle')
     collapsedClass  : The class applied to lists that have been collapsed (default 'dd-collapsed')
     placeClass      : The class of the placeholder element (default 'dd-placeholder')
     emptyClass      : The class used for empty list placeholder elements (default 'dd-empty')
     expandBtnHTML   : The HTML text used to generate a list item expand button (default '<button data-action="expand">Expand></button>')
     collapseBtnHTML : The HTML text used to generate a list item collapse button (default '<button data-action="collapse">Collapse</button>')
    

===

Also note that the ng-sortable directive uses ngModelController to read and write to the provided model object and is fully compliant with $formatters and $parsers.

ng-nestable's People

Contributors

kamilkp avatar alexanderpa avatar tiran133 avatar

Watchers

James Cloos avatar Danish Sheraz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.