Skip to content

Commit

Permalink
Fix for issue #31, modiifed the directive name to prefix 'as' on dire…
Browse files Browse the repository at this point in the history
…ctives.
  • Loading branch information
a5hik committed Oct 12, 2014
1 parent e7b71cc commit 7331082
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 73 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Latest release verision 1.1.1
Demo Includes:

- Drag between adjacent Lists.
- Controll Drag on Specific Destinations.
- Control Drag on Specific Destinations.

#### Features:

Expand All @@ -40,20 +40,20 @@ Demo Includes:

The directives are structured like below.

sortable --> Items list
sortable-item --> Item to sort/drag
sortable-item-handle --> Drag Handle
as-sortable --> Items list
as-sortable-item --> Item to sort/drag
as-sortable-item-handle --> Drag Handle

#### Design details:

- ng-model is used to bind the sortable list items with the sortable element.
- sortable can be added to the root element.
- sortable-item can be added in item element, and follows ng-repeat.
- sortable-item-handle can be added to the drag handle in item element.
- All sortable, ng-model, sortable-item and sortable-item-handle are required.
- the no-drag attribute can be added to avoid dragging an element inside item-handle.
- as-sortable can be added to the root element.
- as-sortable-item can be added in item element, and follows ng-repeat.
- as-sortable-item-handle can be added to the drag handle in item element.
- All as-sortable, ng-model, as-sortable-item and as-sortable-item-handle are required.
- the no-drag attribute can be added to avoid dragging an element inside as-sortable-item-handle.
- Added a Jquery like 'containment' option to the sortable to prevent the drag outside specified bounds.
- isEnabled attribute on Sortable to determine Drag at runTime.
- isEnabled attribute on as-sortable to determine Drag at runTime.

#### Callbacks:

Expand Down Expand Up @@ -121,9 +121,9 @@ angular.module('xyzApp', ['ui.sortable', '....']);

Invoke the Directives using below html structure.

<ul data-sortable="board.dragControlListeners" data-ng-model="items">
<li data-ng-repeat="item in items" data-sortable-item>
<div data-sortable-item-handle></div>
<ul data-as-sortable="board.dragControlListeners" data-ng-model="items">
<li data-ng-repeat="item in items" data-as-sortable-item>
<div data-as-sortable-item-handle></div>
</li>
</ul>

Expand Down Expand Up @@ -183,13 +183,13 @@ The move failure Impl here just reverts the moved item to its original location.

###### Horizontal Sorting:

Horizontal Drag and Drop can be achieved using the same Library. The Column dispaly can be tweaked to have horizonatal items and the same can be achieved via some CSS tweaks (like making the column display style to "inline-block"). Added a sample in the demo source (refer plunker.css/js/html).
Horizontal Drag and Drop can be achieved using the same Library. The Column display can be tweaked to have horizonatal items and the same can be achieved via some CSS tweaks (like making the column display style to "inline-block"). Added a sample in the demo source (refer plunker.css/js/html).

###### Enable/Disable Drag at Runtime:

The Drag can be controlled at runtime and you can enable/disable it by setting the "isEnabled" property to true or false.

<sortable isEnabled="true">..</div>
<div as-sortable isEnabled="true">..</div>

##### Testing:

Expand Down
24 changes: 12 additions & 12 deletions demo/dist/ng-sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
'use strict';
angular.module('ui.sortable', [])
.constant('sortableConfig', {
itemClass: 'sortable-item',
handleClass: 'sortable-handle',
placeHolderClass: 'sortable-placeholder',
dragClass: 'sortable-drag',
hiddenClass: 'sortable-hidden'
itemClass: 'as-sortable-item',
handleClass: 'as-sortable-item-handle',
placeHolderClass: 'as-sortable-placeholder',
dragClass: 'as-sortable-drag',
hiddenClass: 'as-sortable-hidden'
});
}());

Expand Down Expand Up @@ -385,7 +385,7 @@
* Parent directive for draggable and sortable items.
* Sets modelValue, callbacks, element in scope.
*/
mainModule.directive('sortable',
mainModule.directive('asSortable',
function () {
return {
require: 'ngModel', // get a hold of NgModelController
Expand Down Expand Up @@ -468,7 +468,7 @@
};

//Set the sortOptions callbacks else set it to default.
scope.$watch(attrs.sortable, function (newVal, oldVal) {
scope.$watch(attrs.asSortable, function (newVal, oldVal) {
angular.forEach(newVal, function (value, key) {
if (callbacks[key]) {
if (typeof value === 'function') {
Expand Down Expand Up @@ -515,10 +515,10 @@
/**
* Directive for sortable item handle.
*/
mainModule.directive('sortableItemHandle', ['sortableConfig', '$helper', '$window', '$document',
mainModule.directive('asSortableItemHandle', ['sortableConfig', '$helper', '$window', '$document',
function (sortableConfig, $helper, $window, $document) {
return {
require: '^sortableItem',
require: '^asSortableItem',
scope: true,
restrict: 'A',
controller: 'ui.sortable.sortableItemHandleController',
Expand Down Expand Up @@ -552,7 +552,7 @@
}

scope.itemScope = itemController.scope;

scope.$watch('sortableScope.isEnabled', function(newVal) {
if (isEnabled !== newVal) {
isEnabled = newVal;
Expand Down Expand Up @@ -959,10 +959,10 @@
/**
* sortableItem directive.
*/
mainModule.directive('sortableItem', ['sortableConfig',
mainModule.directive('asSortableItem', ['sortableConfig',
function (sortableConfig) {
return {
require: '^sortable',
require: '^asSortable',
restrict: 'A',
controller: 'ui.sortable.sortableItemController',
link: function (scope, element, attrs, sortableController) {
Expand Down
2 changes: 1 addition & 1 deletion demo/dist/ng-sortable.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7331082

Please sign in to comment.