Browse Source

* bump

gh-pages
RubaXa 9 years ago
parent
commit
ebd0e1c65a
  1. 15
      Sortable.js
  2. 4
      Sortable.min.js
  3. 7
      jquery.binding.js
  4. 6
      knockout-sortable.js
  5. 15
      ng-sortable.js
  6. 13
      react-sortable-mixin.js

15
Sortable.js

@ -172,6 +172,10 @@
* @param {Object} [options] * @param {Object} [options]
*/ */
function Sortable(el, options) { function Sortable(el, options) {
if (!(el && el.nodeType && el.nodeType === 1)) {
throw 'Sortable: `el` must be HTMLElement, and not ' + {}.toString.call(el);
}
this.el = el; // root element this.el = el; // root element
this.options = options = _extend({}, options); this.options = options = _extend({}, options);
@ -489,12 +493,13 @@
if (!ghostEl) { if (!ghostEl) {
var rect = dragEl.getBoundingClientRect(), var rect = dragEl.getBoundingClientRect(),
css = _css(dragEl), css = _css(dragEl),
options = this.options,
ghostRect; ghostRect;
ghostEl = dragEl.cloneNode(true); ghostEl = dragEl.cloneNode(true);
_toggleClass(ghostEl, this.options.ghostClass, false); _toggleClass(ghostEl, options.ghostClass, false);
_toggleClass(ghostEl, this.options.fallbackClass, true); _toggleClass(ghostEl, options.fallbackClass, true);
_css(ghostEl, 'top', rect.top - parseInt(css.marginTop, 10)); _css(ghostEl, 'top', rect.top - parseInt(css.marginTop, 10));
_css(ghostEl, 'left', rect.left - parseInt(css.marginLeft, 10)); _css(ghostEl, 'left', rect.left - parseInt(css.marginLeft, 10));
@ -505,7 +510,7 @@
_css(ghostEl, 'zIndex', '100000'); _css(ghostEl, 'zIndex', '100000');
_css(ghostEl, 'pointerEvents', 'none'); _css(ghostEl, 'pointerEvents', 'none');
this.options.fallbackOnBody && document.body.appendChild(ghostEl) || rootEl.appendChild(ghostEl); options.fallbackOnBody && document.body.appendChild(ghostEl) || rootEl.appendChild(ghostEl);
// Fixing dimensions. // Fixing dimensions.
ghostRect = ghostEl.getBoundingClientRect(); ghostRect = ghostEl.getBoundingClientRect();
@ -792,7 +797,7 @@
} }
if (Sortable.active) { if (Sortable.active) {
if (newIndex == null || newIndex === -1) { if (newIndex === null || newIndex === -1) {
newIndex = oldIndex; newIndex = oldIndex;
} }
@ -1239,6 +1244,6 @@
// Export // Export
Sortable.version = '1.3.0-rc1'; Sortable.version = '1.4.2';
return Sortable; return Sortable;
}); });

4
Sortable.min.js vendored

File diff suppressed because one or more lines are too long

7
jquery.binding.js

@ -27,7 +27,8 @@
* @returns {jQuery|*} * @returns {jQuery|*}
*/ */
$.fn.sortable = function (options) { $.fn.sortable = function (options) {
var retVal; var retVal,
args = arguments;
this.each(function () { this.each(function () {
var $el = $(this), var $el = $(this),
@ -47,10 +48,10 @@
$el.removeData('sortable'); $el.removeData('sortable');
} }
else if (typeof sortable[options] === 'function') { else if (typeof sortable[options] === 'function') {
retVal = sortable[options].apply(sortable, [].slice.call(arguments, 1)); retVal = sortable[options].apply(sortable, [].slice.call(args, 1));
} }
else if (options in sortable.options) { else if (options in sortable.options) {
retVal = sortable.option.apply(sortable, arguments); retVal = sortable.option.apply(sortable, args);
} }
} }
}); });

6
knockout-sortable.js

@ -36,11 +36,11 @@
}.bind(undefined, e, viewModel, allBindings, options[e]); }.bind(undefined, e, viewModel, allBindings, options[e]);
}); });
viewModel._sortable = Sortable.create(element, options); var sortableElement = Sortable.create(element, options);
//Destroy the sortable if knockout disposes the element it's connected to //Destroy the sortable if knockout disposes the element it's connected to
ko.utils.domNodeDisposal.addDisposeCallback(element, function () { ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
viewModel._sortable.destroy(); sortableElement.destroy();
}); });
return ko.bindingHandlers.template.init(element, valueAccessor); return ko.bindingHandlers.template.init(element, valueAccessor);
}, },
@ -84,9 +84,11 @@
newIndex = e.newIndex; newIndex = e.newIndex;
if (e.item.previousElementSibling) if (e.item.previousElementSibling)
{
newIndex = fromArray.indexOf(ko.dataFor(e.item.previousElementSibling)); newIndex = fromArray.indexOf(ko.dataFor(e.item.previousElementSibling));
if (originalIndex > newIndex) if (originalIndex > newIndex)
newIndex = newIndex + 1; newIndex = newIndex + 1;
}
//Remove sortables "unbound" element //Remove sortables "unbound" element
e.item.parentNode.removeChild(e.item); e.item.parentNode.removeChild(e.item);

15
ng-sortable.js

@ -5,12 +5,17 @@
(function (factory) { (function (factory) {
'use strict'; 'use strict';
if (window.angular && window.Sortable) { if (typeof define === 'function' && define.amd) {
factory(angular, Sortable);
}
else if (typeof define === 'function' && define.amd) {
define(['angular', './Sortable'], factory); define(['angular', './Sortable'], factory);
} }
else if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
require('angular');
factory(angular, require('./Sortable'));
module.exports = 'ng-sortable';
}
else if (window.angular && window.Sortable) {
factory(angular, Sortable);
}
})(function (angular, Sortable) { })(function (angular, Sortable) {
'use strict'; 'use strict';
@ -41,7 +46,9 @@
if (!ngRepeat) { if (!ngRepeat) {
// Without ng-repeat // Without ng-repeat
return function () {
return null; return null;
};
} }
// tests: http://jsbin.com/kosubutilo/1/edit?js,output // tests: http://jsbin.com/kosubutilo/1/edit?js,output

13
react-sortable-mixin.js vendored

@ -70,7 +70,7 @@
* @mixin * @mixin
*/ */
var SortableMixin = { var SortableMixin = {
sortableMixinVersion: '0.1.0', sortableMixinVersion: '0.1.1',
/** /**
@ -81,7 +81,7 @@
componentDidMount: function () { componentDidMount: function () {
var options = _extend(_extend({}, _defaultOptions), this.sortableOptions || {}), var DOMNode, options = _extend(_extend({}, _defaultOptions), this.sortableOptions || {}),
copyOptions = _extend({}, options), copyOptions = _extend({}, options),
emitEvent = function (/** string */type, /** Event */evt) { emitEvent = function (/** string */type, /** Event */evt) {
@ -120,7 +120,13 @@
} }
newState[_getModelName(this)] = items; newState[_getModelName(this)] = items;
if (copyOptions.stateHandler) {
this[copyOptions.stateHandler](newState);
} else {
this.setState(newState); this.setState(newState);
}
(this !== _activeComponent) && _activeComponent.setState(remoteState); (this !== _activeComponent) && _activeComponent.setState(remoteState);
} }
@ -130,9 +136,10 @@
}.bind(this); }.bind(this);
}, this); }, this);
DOMNode = this.getDOMNode() ? (this.refs[options.ref] || this).getDOMNode() : this.refs[options.ref] || this;
/** @namespace this.refs — http://facebook.github.io/react/docs/more-about-refs.html */ /** @namespace this.refs — http://facebook.github.io/react/docs/more-about-refs.html */
this._sortableInstance = Sortable.create((this.refs[options.ref] || this).getDOMNode(), copyOptions); this._sortableInstance = Sortable.create(DOMNode, copyOptions);
}, },
componentWillReceiveProps: function (nextProps) { componentWillReceiveProps: function (nextProps) {

Loading…
Cancel
Save