Skip to content

Commit

Permalink
update examples and changelog
Browse files Browse the repository at this point in the history
closes #173
  • Loading branch information
Jonas von Andrian authored and Jonas von Andrian committed Jun 27, 2015
1 parent 74a7100 commit 0f9f239
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 97 deletions.
47 changes: 28 additions & 19 deletions CHANGELOG
@@ -1,28 +1,37 @@
[0.9.13] fix hovering over empty container (Jonny Gerig Meyer)
allow custom drag classes (Jonny Gerig Meyer)
support text areas inside sortables (Isaac Kearse)
fix drag with placeholder issue (Michael McLaughlin)
user outer dimensions for dragged item (Jared Mellentine)
support npm and bower (Patrick Gunderson, Shaun Dern)
fix issue with legacy jQuery 1.10
fix for mobile chrome

[0.9.12] expose mouse events in callbacks
add refresh method
add destroy method
add delay option
falsy return value in onMousedown prevents dragging
fix exclusion of items
fix ignore for select element (abixalmon)
fix touch events (prateekjadhwani)
fix itemPath issues (appending and dragInit)
improve documentation
add refresh method
add destroy method
add delay option
falsy return value in onMousedown prevents dragging
fix exclusion of items
fix ignore for select element (abixalmon)
fix touch events (prateekjadhwani)
fix itemPath issues (appending and dragInit)
improve documentation
[0.9.11] option tolerance accepts negative values
rewrote enable/disable logic
added (item|container)Path
rewrote enable/disable logic
added (item|container)Path

[0.9.10]Fix Array.indexOf() error in IE < 9 (Dev-Speranza)
serialize() assumes one subcontainer per item
remove call to stopPropagation()
Added onMousedown()
[0.9.10] Fix Array.indexOf() error in IE < 9 (Dev-Speranza)
serialize() assumes one subcontainer per item
remove call to stopPropagation()
Added onMousedown()

[0.9.9] Added options tolerance and distance
Do not modify Array.prototype (by Joakin)
serialize respects exclude option
Do not modify Array.prototype (by Joakin)
serialize respects exclude option

[0.9.8] Added Serialization
Added onCancel
Added onCancel

[0.9.7] Support iFrame and Touch events
Better behavior if the CSS position changes
Better behavior if the CSS position changes
2 changes: 1 addition & 1 deletion config.rb
Expand Up @@ -47,7 +47,7 @@ def escape_file(name)
end
def example(name)
content = escape_file("js/examples/"+ name + ".js")
content.match(/\A\$\(function\s*\(\)\s*\{\s*(.*)\s*\}\s*\)\s*\z/mi)[1].gsub(/^ /, "")
content.match(/\A\$\(function\s*\(\)\s*\{\s*(.*)\s*\}\s*\);\s*\z/mi)[1].gsub(/^ /, "")
end
def show_code_button
content_tag( :div,
Expand Down
2 changes: 2 additions & 0 deletions source/_table.html.haml
Expand Up @@ -36,8 +36,10 @@
%tr
%th A Column
%th B Column
%th C Column
%tbody
= iterate(6) do |i, name|
%tr
%td A #{name}
%td B #{name}
%td C #{name}
10 changes: 5 additions & 5 deletions source/js/application.js
Expand Up @@ -9,9 +9,9 @@

$(function () {
if(!/test/.test(window.location.pathname))
$('body').scrollspy()
$('body').scrollspy();
$('.show-code').on('click', function () {
$(this).closest('.row').children('.example').slideToggle()
})
$('ol.default').sortable()
})
$(this).closest('.row').children('.example').slideToggle();
});
$('ol.default').sortable();
});
4 changes: 2 additions & 2 deletions source/js/debug.js
Expand Up @@ -7,6 +7,6 @@ $(function () {
itemSelector: '.part, .layout',
containerSelector: '.region',
nested: true,
placeholder: '<div class="placeholder">Drop here</div>',
placeholder: '<div class="placeholder">Drop here</div>'
});
})
});
4 changes: 2 additions & 2 deletions source/js/examples/basic.js
@@ -1,3 +1,3 @@
$(function () {
$("ol.example").sortable()
})
$("ol.example").sortable();
});
18 changes: 9 additions & 9 deletions source/js/examples/limited_drop_targets.js
Expand Up @@ -3,19 +3,19 @@ $(function () {
group: 'limited_drop_targets',
isValidTarget: function ($item, container) {
if($item.is(".highlight"))
return true
else {
return $item.parent("ol")[0] == container.el[0]
}
return true;
else
return $item.parent("ol")[0] == container.el[0];
},
onDrop: function ($item, container, _super) {
$('#serialize_output').text(group.sortable("serialize").get().join("\n"))
_super($item, container)
$('#serialize_output').text(
group.sortable("serialize").get().join("\n"));
_super($item, container);
},
serialize: function (parent, children, isContainer) {
return isContainer ? children.join() : parent.text()
return isContainer ? children.join() : parent.text();
},
tolerance: 6,
distance: 10
})
})
});
});
15 changes: 8 additions & 7 deletions source/js/examples/nested_bootstrap.js
Expand Up @@ -5,15 +5,16 @@ $(function () {
vertical: false,
exclude: '.divider-vertical',
onDragStart: function($item, container, _super) {
$item.find('ol.dropdown-menu').sortable('disable')
_super($item, container)
$item.find('ol.dropdown-menu').sortable('disable');
_super($item, container);
},
onDrop: function($item, container, _super) {
$item.find('ol.dropdown-menu').sortable('enable')
_super($item, container)
$item.find('ol.dropdown-menu').sortable('enable');
_super($item, container);
}
})
});

$("ol.dropdown-menu").sortable({
group: 'nav'
})
})
});
});
22 changes: 11 additions & 11 deletions source/js/examples/nested_with_switch.js
@@ -1,24 +1,24 @@
$(function () {
var oldContainer
var oldContainer;
$("ol.nested_with_switch").sortable({
group: 'nested',
afterMove: function (placeholder, container) {
if(oldContainer != container){
if(oldContainer)
oldContainer.el.removeClass("active")
container.el.addClass("active")
oldContainer.el.removeClass("active");
container.el.addClass("active");

oldContainer = container
oldContainer = container;
}
},
onDrop: function ($item, container, _super) {
container.el.removeClass("active")
_super($item, container)
container.el.removeClass("active");
_super($item, container);
}
})
});

$(".switch-container").on("click", ".switch", function (e) {
var method = $(this).hasClass("active") ? "enable" : "disable"
$(e.delegateTarget).next().sortable(method)
})
})
var method = $(this).hasClass("active") ? "enable" : "disable";
$(e.delegateTarget).next().sortable(method);
});
});
6 changes: 3 additions & 3 deletions source/js/examples/serialization.js
Expand Up @@ -8,7 +8,7 @@ $(function () {
var jsonString = JSON.stringify(data, null, ' ');

$('#serialize_output2').text(jsonString);
_super($item, container)
_super($item, container);
}
})
})
});
});
26 changes: 13 additions & 13 deletions source/js/examples/simple_with_animation.js
@@ -1,38 +1,38 @@
$(function () {
var adjustment
var adjustment;

$("ol.simple_with_animation").sortable({
group: 'simple_with_animation',
pullPlaceholder: false,
// animation on drop
onDrop: function ($item, container, _super) {
var $clonedItem = $('<li/>').css({height: 0})
$item.before($clonedItem)
$clonedItem.animate({'height': $item.height()})
var $clonedItem = $('<li/>').css({height: 0});
$item.before($clonedItem);
$clonedItem.animate({'height': $item.height()});

$item.animate($clonedItem.position(), function () {
$clonedItem.detach()
_super($item, container)
})
$clonedItem.detach();
_super($item, container);
});
},

// set $item relative to cursor position
onDragStart: function ($item, container, _super) {
var offset = $item.offset(),
pointer = container.rootGroup.pointer
pointer = container.rootGroup.pointer;

adjustment = {
left: pointer.left - offset.left,
top: pointer.top - offset.top
}
};

_super($item, container)
_super($item, container);
},
onDrag: function ($item, position) {
$item.css({
left: position.left - adjustment.left,
top: position.top - adjustment.top
})
});
}
})
})
});
});
12 changes: 6 additions & 6 deletions source/js/examples/simple_with_no_drop.js
Expand Up @@ -5,16 +5,16 @@ $(function() {
onDragStart: function ($item, container, _super) {
// Duplicate items of the no drop area
if(!container.options.drop)
$item.clone().insertAfter($item)
_super($item, container)
$item.clone().insertAfter($item);
_super($item, container);
}
})
});
$("ol.simple_with_no_drop").sortable({
group: 'no-drop',
drop: false
})
});
$("ol.simple_with_no_drag").sortable({
group: 'no-drop',
drag: false
})
})
});
});
35 changes: 18 additions & 17 deletions source/js/examples/table.js
Expand Up @@ -5,35 +5,36 @@ $(function () {
itemPath: '> tbody',
itemSelector: 'tr',
placeholder: '<tr class="placeholder"/>'
})
});

// Sortable column heads
var oldIndex
var oldIndex;
$('.sorted_head tr').sortable({
containerSelector: 'tr',
itemSelector: 'th',
placeholder: '<th class="placeholder"/>',
vertical: false,
onDragStart: function ($item, container, _super) {
oldIndex = $item.index()
$item.appendTo($item.parent())
_super($item, container)
oldIndex = $item.index();
$item.appendTo($item.parent());
_super($item, container);
},
onDrop: function ($item, container, _super) {
var field,
newIndex = $item.index()
newIndex = $item.index();

if(newIndex != oldIndex)
if(newIndex != oldIndex) {
$item.closest('table').find('tbody tr').each(function (i, row) {
row = $(row)
field = row.children().eq(oldIndex)
if(newIndex)
field.before(row.children()[newIndex])
else
row.prepend(field)
})
row = $(row);
if(newIndex < oldIndex) {
row.children().eq(newIndex).before(row.children()[oldIndex]);
} else if (newIndex > oldIndex) {
row.children().eq(newIndex).after(row.children()[oldIndex]);
}
});
}

_super($item, container)
_super($item, container);
}
})
})
});
});
3 changes: 1 addition & 2 deletions source/js/jquery-sortable.js
Expand Up @@ -28,8 +28,7 @@
* ========================================================== */

!function ( $, window, pluginName, undefined){
var eventNames,
containerDefaults = {
var containerDefaults = {
// If true, items can be dragged from this container
drag: true,
// If true, items can be droped onto this container
Expand Down

0 comments on commit 0f9f239

Please sign in to comment.