From b73d639f09cfacf261418d2561a2353b8b295086 Mon Sep 17 00:00:00 2001 From: Olivier LE LAY Date: Tue, 27 Sep 2016 14:16:40 +0200 Subject: [PATCH 1/6] add disable capability with sv-disabled --- src/angular-sortable-view.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/angular-sortable-view.js b/src/angular-sortable-view.js index 05694f0..25aa2e0 100644 --- a/src/angular-sortable-view.js +++ b/src/angular-sortable-view.js @@ -51,6 +51,14 @@ var onStart = $parse($attrs.svOnStart); var onStop = $parse($attrs.svOnStop); + var disabled; + $scope.$watch($attrs.svDisabled, function() { + disabled = $scope.$eval($attrs.svDisabled) || false; + }); + + this.isDisabled = function() { + return disabled; + }; this.sortingInProgress = function(){ return sortingInProgress; @@ -390,6 +398,7 @@ function onMousedown(e){ touchFix(e); + if($controllers[1].isDisabled()) return; if($controllers[1].sortingInProgress()) return; if(e.button != 0 && e.type === 'mousedown') return; From fb9b0c953c2a98146e87b49b6049de594e4789ea Mon Sep 17 00:00:00 2001 From: Olivier LE LAY Date: Tue, 27 Sep 2016 14:22:40 +0200 Subject: [PATCH 2/6] v0.0.16 --- CHANGELOG.md | 5 +++++ README.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd2909..41bc932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +Version 0.0.16 - 2016/10/27 +================ + + * add disabled capability + Version 0.0.15 - 2016/01/18 ================ diff --git a/README.md b/README.md index 8e1b683..00d4d9b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ This library requires ***no dependencies whatsoever*** (except angular.js of cou The API is declarative. There are four directives (hooked on attributes) that need to be nested properly: - * `sv-root` - this is where all the logic is happening. If multiple lists should be connected with each other so that elements can be moved between them and they have a common ancestor, put this attribute on that element. If not and you still want the multi-sortable behaviour a value for that attribue must be provided. That value will be used as an identifier to connect those roots together. + * `sv-root` - this is where all the logic is happening. If multiple lists should be connected with each other so that elements can be moved between them and they have a common ancestor, put this attribute on that element. If not and you still want the multi-sortable behaviour a value for that attribue must be provided. That value will be used as an identifier to connect those roots together. Optionnally you can add `sv-disabled=boolean` to deactive dragging. **Optional attributes:** * `sv-on-sort` - The expression passed as a value of that attribute will be evaluated when elements order has changed after sorting. Several parameters can be injected there like: `sv-on-sort="foo($item, $partFrom, $partTo, $indexFrom, $indexTo)"` where: * `sv-part` - this attribute should be placed on an element that is a container for the `ngRepeat`'ed elements. Its value should be the same as the right hand side expression in `ng-repeat` attribute. - * `sv-element` - this attribute should be placed on the same element as `ng-repeat` attribute. Its (optional) value should be an expression that evaluates to the options object. + * `sv-element` - this attribute should be placed on the same element as `ng-repeat` attribute. Its (optional) value should be an expression that evaluates to the options object. Optionnally you can add `sv-disabled=boolean` to deactive dragging on this element. * `sv-handle` - this attribute is optional. If needed it can be placed on an element within the sortable element. This element will be the handle for sorting operations. * `sv-helper` - the element with this attribute will serve as a custom helper for sorting operations * `sv-placeholder` - the element with this attribute will serve as a custom placeholder for sorting operations diff --git a/bower.json b/bower.json index 9edb073..668a983 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-sortable-view", - "version": "0.0.16", + "version": "0.0.17", "homepage": "http://kamilkp.github.io/angular-sortable-view/", "authors": [ "Kamil Pękala " diff --git a/package.json b/package.json index c6552d4..ec294fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-sortable-view", - "version": "0.0.16", + "version": "0.0.17", "description": "Fully declarative (multi)sortable for AngularJS", "main": "./src/angular-sortable-view.js", "homepage": "http://kamilkp.github.io/angular-sortable-view",