Browse Source

* upd

gh-pages
RubaXa 10 years ago
parent
commit
969e313007
  1. 2
      CONTRIBUTING.md
  2. 14
      README.md
  3. 8
      Sortable.js
  4. 7
      bower.json
  5. 2
      index.html
  6. 37
      ng-sortable.js
  7. 4
      package.json

2
CONTRIBUTING.md

@ -5,7 +5,7 @@
1. Try [dev](https://github.com/RubaXa/Sortable/tree/dev/)-branch, perhaps the problem has been solved; 1. Try [dev](https://github.com/RubaXa/Sortable/tree/dev/)-branch, perhaps the problem has been solved;
2. [Use the search](https://github.com/RubaXa/Sortable/search?q=problem), maybe already have an answer; 2. [Use the search](https://github.com/RubaXa/Sortable/search?q=problem), maybe already have an answer;
3. If not found, create example on [jsbin.com](http://jsbin.com/zunibaxada/1/edit?html,js,output) and describe the problem. 3. If not found, create example on [jsbin.com (draft)](http://jsbin.com/zunibaxada/1/edit?html,js,output) and describe the problem.
--- ---

14
README.md

@ -55,6 +55,7 @@ You can use any element for the list and its elements, not just `ul`/`li`. Here
var sortable = new Sortable(el, { var sortable = new Sortable(el, {
group: "name", // or { name: "...", pull: [true, false, clone], put: [true, false, array] } group: "name", // or { name: "...", pull: [true, false, clone], put: [true, false, array] }
sort: true, // sorting inside list sort: true, // sorting inside list
delay: 0, // time in milliseconds to define when the sorting should start
disabled: false, // Disables the sortable if set to true. disabled: false, // Disables the sortable if set to true.
store: null, // @see Store store: null, // @see Store
animation: 150, // ms, animation speed moving items when sorting, `0` — without animation animation: 150, // ms, animation speed moving items when sorting, `0` — without animation
@ -140,7 +141,7 @@ You can also define whether lists can give away, give and keep a copy (`clone`),
#### `sort` option #### `sort` option
Sorting inside list Sorting inside list.
Demo: http://jsbin.com/xizeh/2/edit?html,js,output Demo: http://jsbin.com/xizeh/2/edit?html,js,output
@ -148,6 +149,15 @@ Demo: http://jsbin.com/xizeh/2/edit?html,js,output
--- ---
#### `delay` option
Time in milliseconds to define when the sorting should start.
Demo: http://jsbin.com/xizeh/4/edit?html,js,output
---
#### `disabled` options #### `disabled` options
Disables the sortable if set to `true`. Disables the sortable if set to `true`.
@ -205,7 +215,7 @@ Sortable.create(el, {
Sortable.create(list, { Sortable.create(list, {
filter: ".js-remove, .js-edit", filter: ".js-remove, .js-edit",
onFilter: function (evt) { onFilter: function (evt) {
var item = el.item, var item = evt.item,
ctrl = evt.target; ctrl = evt.target;
if (Sortable.utils.is(ctrl, ".js-remove")) { // Click on remove button if (Sortable.utils.is(ctrl, ".js-remove")) { // Click on remove button

8
Sortable.js

@ -991,11 +991,11 @@
evt.oldIndex = startIndex; evt.oldIndex = startIndex;
evt.newIndex = newIndex; evt.newIndex = newIndex;
rootEl.dispatchEvent(evt);
if (options[onName]) { if (options[onName]) {
options[onName].call(sortable, evt); options[onName].call(sortable, evt);
} }
rootEl.dispatchEvent(evt);
} }
@ -1035,7 +1035,9 @@
/** @returns {HTMLElement|false} */ /** @returns {HTMLElement|false} */
function _ghostInBottom(el, evt) { function _ghostInBottom(el, evt) {
var lastEl = el.lastElementChild, rect = lastEl.getBoundingClientRect(); var lastEl = el.lastElementChild,
rect = lastEl.getBoundingClientRect();
return (evt.clientY - (rect.top + rect.height) > 5) && lastEl; // min delta return (evt.clientY - (rect.top + rect.height) > 5) && lastEl; // min delta
} }

7
bower.json

@ -1,6 +1,11 @@
{ {
"name": "Sortable", "name": "Sortable",
"main": "Sortable.js", "main": [
"Sortable.js",
"ng-sortable.js",
"knockout-sortable.js",
"react-sortable-mixin.js"
],
"version": "1.2.0", "version": "1.2.0",
"homepage": "http://rubaxa.github.io/Sortable/", "homepage": "http://rubaxa.github.io/Sortable/",
"authors": [ "authors": [

2
index.html

@ -173,7 +173,7 @@
<a name="ng"></a> <a name="ng"></a>
<div id="todos" ng-app="todoApp" class="container" style="margin-top: 100px"> <div id="todos" ng-app="todoApp" class="container" style="margin-top: 100px">
<div style="margin-left: 30px"> <div style="margin-left: 30px">
<div><div data-force="5" class="layer title title_xl">AngluarJS / ng-sortable</div></div> <div><div data-force="5" class="layer title title_xl">AngularJS / ng-sortable</div></div>
<div style="width: 30%; margin-top: -8px; margin-left: 10px; float: left;" class="block__list block__list_words"> <div style="width: 30%; margin-top: -8px; margin-left: 10px; float: left;" class="block__list block__list_words">
<div ng-controller="TodoController"> <div ng-controller="TodoController">

37
ng-sortable.js

@ -64,11 +64,12 @@
// Export // Export
return { return {
restrict: 'AC', restrict: 'AC',
scope: { ngSortable: "=?" },
link: function (scope, $el, attrs) { link: function (scope, $el, attrs) {
var el = $el[0], var el = $el[0],
ngSortable = attrs.ngSortable, options = scope.ngSortable || {},
options = scope.$eval(ngSortable) || {},
source = getSource(el), source = getSource(el),
watchers = [],
sortable sortable
; ;
@ -154,27 +155,29 @@
})); }));
$el.on('$destroy', function () { $el.on('$destroy', function () {
angular.forEach(watchers, function (/** Function */unwatch) {
unwatch();
});
sortable.destroy(); sortable.destroy();
watchers = null;
sortable = null; sortable = null;
nextSibling = null; nextSibling = null;
}); });
if (ngSortable && !/{|}/.test(ngSortable)) { // todo: ugly angular.forEach([
angular.forEach([ 'sort', 'disabled', 'draggable', 'handle', 'animation',
'sort', 'disabled', 'draggable', 'handle', 'animation', 'onStart', 'onEnd', 'onAdd', 'onUpdate', 'onRemove', 'onSort'
'onStart', 'onEnd', 'onAdd', 'onUpdate', 'onRemove', 'onSort' ], function (name) {
], function (name) { watchers.push(scope.$watch('ngSortable.' + name, function (value) {
scope.$watch(ngSortable + '.' + name, function (value) { if (value !== void 0) {
if (value !== void 0) { options[name] = value;
options[name] = value;
if (!/^on[A-Z]/.test(name)) {
if (!/^on[A-Z]/.test(name)) { sortable.option(name, value);
sortable.option(name, value);
}
} }
}); }
}); }));
} });
} }
}; };
}]); }]);

4
package.json

@ -1,7 +1,7 @@
{ {
"name": "sortablejs", "name": "sortablejs",
"exportName": "Sortable", "exportName": "Sortable",
"version": "1.2.0", "version": "1.2.1",
"devDependencies": { "devDependencies": {
"grunt": "*", "grunt": "*",
"grunt-version": "*", "grunt-version": "*",
@ -25,7 +25,7 @@
"drag", "drag",
"meteor", "meteor",
"angular", "angular",
"ng-srotable", "ng-sortable",
"react", "react",
"mixin" "mixin"
], ],

Loading…
Cancel
Save