vendor/assets/javascripts/uikit/components/sortable.js in uikit2-rails-0.1.7 vs vendor/assets/javascripts/uikit/components/sortable.js in uikit2-rails-0.1.8
- old
+ new
@@ -1,6 +1,6 @@
-/*! UIkit 2.26.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
+/*! UIkit 2.26.2 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
/*
* Based on nativesortable - Copyright (c) Brian Grinstead - https://github.com/bgrins/nativesortable
*/
(function(addon) {
@@ -164,10 +164,15 @@
if ($target.is(':input')) {
return;
}
+ if ($this.options.handleClass) {
+ var handle = $target.hasClass($this.options.handleClass) ? $target : $target.closest('.'+$this.options.handleClass, $this.element);
+ if (!handle.length) return;
+ }
+
e.preventDefault();
if (!supportsTouch && $link.length) {
$link.one('click', function(e){
@@ -299,20 +304,10 @@
if (!supportsTouch && e.button==2) {
return;
}
- if ($this.options.handleClass) {
-
- var handle = target.hasClass($this.options.handleClass) ? target : target.closest('.'+$this.options.handleClass, $this.element);
-
- if (!handle.length) {
- //e.preventDefault();
- return;
- }
- }
-
if (target.is('.'+$this.options.noDragClass) || target.closest('.'+$this.options.noDragClass).length) {
return;
}
// prevent dragging if taget is a form field
@@ -330,11 +325,11 @@
var $current = UI.$(currentlyDraggingElement), offset = $current.offset();
delayIdle = {
pos : { x:e.pageX, y:e.pageY },
- threshold : $this.options.threshold,
+ threshold : $this.options.handleClass ? 0 : $this.options.threshold,
apply : function(evt) {
draggingPlaceholder = UI.$('<div class="'+([$this.options.draggingClass, $this.options.dragCustomClass].join(' '))+'"></div>').css({
display : 'none',
top : offset.top,
@@ -600,13 +595,15 @@
var data = [], item, attribute;
this.element.children().each(function(j, child) {
item = {};
- for (var i = 0; i < child.attributes.length; i++) {
+ for (var i = 0, attr, val; i < child.attributes.length; i++) {
attribute = child.attributes[i];
if (attribute.name.indexOf('data-') === 0) {
- item[attribute.name.substr(5)] = UI.Utils.str2json(attribute.value);
+ attr = attribute.name.substr(5);
+ val = UI.Utils.str2json(attribute.value);
+ item[attr] = (val || attribute.value=='false' || attribute.value=='0') ? val:attribute.value;
}
}
data.push(item);
});