Skip to content

Commit

Permalink
Accepting children element.
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo committed Jan 16, 2017
1 parent 26143ea commit 90b862a
Show file tree
Hide file tree
Showing 19 changed files with 10,467 additions and 18 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.DS_Store
node_modules
dist
styles.min.css
styles.min.css.map
coverage
Expand Down
74 changes: 74 additions & 0 deletions dist/commonjs/Manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _find = require('lodash/find');

var _find2 = _interopRequireDefault(_find);

var _sortBy = require('lodash/sortBy');

var _sortBy2 = _interopRequireDefault(_sortBy);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Manager = function () {
function Manager() {
_classCallCheck(this, Manager);

this.refs = {};
}

_createClass(Manager, [{
key: 'add',
value: function add(collection, ref) {
if (!this.refs[collection]) this.refs[collection] = [];

this.refs[collection].push(ref);
}
}, {
key: 'remove',
value: function remove(collection, ref) {
var index = this.getIndex(collection, ref);

if (index !== -1) {
this.refs[collection].splice(index, 1);
}
}
}, {
key: 'getActive',
value: function getActive() {
var _this = this;

return (0, _find2.default)(this.refs[this.active.collection], function (_ref) {
var node = _ref.node;
return node.sortableInfo.index == _this.active.index;
});
}
}, {
key: 'getIndex',
value: function getIndex(collection, ref) {
return this.refs[collection].indexOf(ref);
}
}, {
key: 'getOrderedRefs',
value: function getOrderedRefs() {
var collection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.active.collection;

return (0, _sortBy2.default)(this.refs[collection], function (_ref2) {
var node = _ref2.node;
return node.sortableInfo.index;
});
}
}]);

return Manager;
}();

exports.default = Manager;
Loading

0 comments on commit 90b862a

Please sign in to comment.