angular-ui-sortable-multiselection
Advanced tools
Comparing version 0.3.1 to 0.4.0
{ | ||
"name": "angular-ui-sortable-multiselection", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "This directive allows multiple element sorting in UI-Sortable.", | ||
@@ -5,0 +5,0 @@ "author": "https://github.com/thgreasi/ui-sortable-multiselection/graphs/contributors", |
@@ -1,2 +0,6 @@ | ||
var myapp = angular.module('sortableApp', ['ui.sortable', 'ui.sortable.multiselection']); | ||
var myapp = angular.module('sortableApp', ['ui.sortable', 'ui.sortable.multiselection'], function ($compileProvider) { | ||
if (typeof $compileProvider.debugInfoEnabled === 'function') { | ||
$compileProvider.debugInfoEnabled(false); | ||
} | ||
}); | ||
@@ -3,0 +7,0 @@ |
@@ -1,4 +0,7 @@ | ||
var myapp = angular.module('sortableApp', ['ui.sortable', 'ui.sortable.multiselection']); | ||
var myapp = angular.module('sortableApp', ['ui.sortable', 'ui.sortable.multiselection'], function ($compileProvider) { | ||
if (typeof $compileProvider.debugInfoEnabled === 'function') { | ||
$compileProvider.debugInfoEnabled(false); | ||
} | ||
}); | ||
myapp.controller('sortableController', function ($scope, uiSortableMultiSelectionMethods) { | ||
@@ -5,0 +8,0 @@ var tmpList = []; |
{ | ||
"name": "angular-ui-sortable-multiselection", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "This directive allows multiple element sorting in UI-Sortable.", | ||
@@ -5,0 +5,0 @@ "author": "https://github.com/thgreasi/ui-sortable-multiselection/graphs/contributors", |
ui-sortable-multiselection | ||
========================== | ||
[](https://www.npmjs.com/package/angular-ui-sortable-multiselection) | ||
[](https://www.npmjs.com/package/angular-ui-sortable-multiselection) | ||
[](https://docs.angularjs.org/guide/production#disabling-debug-data) | ||
@@ -11,2 +12,4 @@ Provide multiple element sorting in [UI-Sortable](https://github.com/angular-ui/ui-sortable) | ||
[Handle Demo pen](http://codepen.io/feus4177/pen/zvWvpY) | ||
## ui.item.sortableMultiSelect API documentation | ||
@@ -13,0 +16,0 @@ |
@@ -13,2 +13,3 @@ angular.module('ui.sortable.multiselection', []) | ||
var jquerySortableCancelOption = $parent.sortable('option', 'cancel'); | ||
var jquerySortableHandleOption = $parent.sortable('option', 'handle'); | ||
@@ -20,6 +21,20 @@ // Respect jQuery UI Sortable's cancel property by testing if element matches selector | ||
var parentScope = $parent.scope(); | ||
parentScope.sortableMultiSelect = parentScope.sortableMultiSelect || {}; | ||
// Mimic jQuery UI Sortable's handle property when determining if an item is selected | ||
if (jquerySortableHandleOption) { | ||
var validHandle = false; | ||
$parent.find(jquerySortableHandleOption).find('*').addBack().each(function () { | ||
if (this === e.target) { | ||
validHandle = true; | ||
} | ||
}); | ||
var lastIndex = parentScope.sortableMultiSelect.lastIndex; | ||
if (!validHandle) { | ||
return; | ||
} | ||
} | ||
var sortableMultiSelectState = $parent.data('uiSortableMultiSelectionState') || {}; | ||
var lastIndex = sortableMultiSelectState.lastIndex; | ||
var index = $this.index(); | ||
@@ -39,4 +54,12 @@ | ||
} | ||
parentScope.sortableMultiSelect.lastIndex = index; | ||
sortableMultiSelectState.lastIndex = index; | ||
$parent.data('uiSortableMultiSelectionState', sortableMultiSelectState); | ||
$parent.trigger('ui-sortable-selectionschanged'); | ||
}); | ||
element.parent().on('$destroy', function() { | ||
console.log('destroy'); | ||
element.parent().removeData('uiSortableMultiSelectionState'); | ||
}); | ||
} | ||
@@ -181,20 +204,16 @@ }; | ||
if (!ui.item.sortable.isCanceled()) { | ||
var scope = ui.item.sortable.droptarget.scope(); | ||
var ngModel = ui.item.sortable.droptargetModel, | ||
newPosition = ui.item.sortable.dropindex, | ||
models = ui.item.sortableMultiSelect.moved; | ||
scope.$apply(function () { | ||
var ngModel = ui.item.sortable.droptargetModel, | ||
newPosition = ui.item.sortable.dropindex, | ||
models = ui.item.sortableMultiSelect.moved; | ||
// add the models to the target list | ||
Array.prototype.splice.apply( | ||
ngModel, | ||
[newPosition+ 1, 0] | ||
.concat(models.below)); | ||
// add the models to the target list | ||
Array.prototype.splice.apply( | ||
ngModel, | ||
[newPosition+ 1, 0] | ||
.concat(models.below)); | ||
Array.prototype.splice.apply( | ||
ngModel, | ||
[newPosition, 0] | ||
.concat(models.above)); | ||
}); | ||
Array.prototype.splice.apply( | ||
ngModel, | ||
[newPosition, 0] | ||
.concat(models.above)); | ||
} else { | ||
@@ -207,15 +226,11 @@ ui.item.sortableMultiSelect.sourceElement.find('> .' + selectedItemClass).show(); | ||
if (!ui.item.sortable.isCanceled()) { | ||
var scope = ui.item.sortableMultiSelect.sourceElement.scope(); | ||
var ngModel = ui.item.sortable.sourceModel, | ||
oldPosition = ui.item.sortable.index; | ||
scope.$apply(function () { | ||
var ngModel = ui.item.sortable.sourceModel, | ||
oldPosition = ui.item.sortable.index; | ||
var indexes = groupIndexes(ui.item.sortableMultiSelect.indexes, oldPosition); | ||
var indexes = groupIndexes(ui.item.sortableMultiSelect.indexes, oldPosition); | ||
// get the models and remove them from the original list | ||
// the code should run in reverse order, | ||
// so that the indexes will not break | ||
ui.item.sortableMultiSelect.moved = extractGroupedModelsFromIndexes(ngModel, indexes.above, indexes.below); | ||
}); | ||
// get the models and remove them from the original list | ||
// the code should run in reverse order, | ||
// so that the indexes will not break | ||
ui.item.sortableMultiSelect.moved = extractGroupedModelsFromIndexes(ngModel, indexes.above, indexes.below); | ||
} else { | ||
@@ -222,0 +237,0 @@ ui.item.sortableMultiSelect.sourceElement.find('> .' + selectedItemClass).show(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
26604
14
456
44