Skip to content

Commit 4a4db7b

Browse files
author
Lukas Oppermann
committed
update readme & dists
1 parent fc071bc commit 4a4db7b

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ HTML5 Sortable jQuery Plugin
88
* Built using native HTML5 drag and drop API.
99
* Supports both list and grid style layouts.
1010
* Works in IE 5.5+, Firefox 3.5+, Chrome 3+, Safari 3+ and, Opera 12+.
11+
* Supports exports as AMD, CommonJS or global
1112
* Comes with an AngularJS directive [help wanted](#angularjs-usage)
1213

1314
# Installation

dist/html.sortable.js

+22-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
(function(root, factory) {
2+
if (typeof define === 'function' && define.amd) {
3+
define(['jquery'], factory);
4+
} else if (typeof exports === 'object') {
5+
module.exports = factory(require('jquery'));
6+
} else {
7+
root.sortable = factory(root.$);
8+
}
9+
}(this, function(jquery) {
110
/*
211
* HTML5 Sortable jQuery Plugin
312
* https://github.com/voidberg/html5sortable
@@ -9,19 +18,19 @@
918
*
1019
* Released under the MIT license.
1120
*/
12-
(function($) {
13-
'use strict';
14-
1521
var dragging;
1622
var draggingHeight;
1723
var placeholders = $();
18-
$.fn.sortable = function(options) {
24+
var sortable = function(options) {
25+
'use strict';
1926
var method = String(options);
2027

2128
options = $.extend({
2229
connectWith: false,
2330
placeholder: null,
24-
dragImage: null
31+
dragImage: null,
32+
placeholderClass: 'sortable-placeholder',
33+
draggingClass: 'sortable-dragging'
2534
}, options);
2635

2736
return this.each(function() {
@@ -60,7 +69,7 @@
6069

6170
var startParent;
6271
var newParent;
63-
var placeholder = (options.placeholder === null) ? $('<' + (/^ul|ol$/i.test(this.tagName) ? 'li' : 'div') + ' class="sortable-placeholder"/>') : $(options.placeholder).addClass('sortable-placeholder');
72+
var placeholder = (options.placeholder === null) ? $('<' + (/^ul|ol$/i.test(this.tagName) ? 'li' : 'div') + ' class="'+options.placeholderClass+'"/>') : $(options.placeholder).addClass(options.placeholderClass);
6473

6574
$(this).data('items', options.items);
6675
placeholders = placeholders.add(placeholder);
@@ -90,7 +99,7 @@
9099
dt.setDragImage(options.dragImage, 0, 0);
91100
}
92101

93-
index = (dragging = $(this)).addClass('sortable-dragging').attr('aria-grabbed', 'true').index();
102+
index = (dragging = $(this)).addClass(options.draggingClass).attr('aria-grabbed', 'true').index();
94103
draggingHeight = dragging.height();
95104
startParent = $(this).parent();
96105
dragging.parent().triggerHandler('sortstart', {
@@ -101,7 +110,7 @@
101110
if (!dragging) {
102111
return;
103112
}
104-
dragging.removeClass('sortable-dragging').attr('aria-grabbed', 'false').show();
113+
dragging.removeClass(options.draggingClass).attr('aria-grabbed', 'false').show();
105114
placeholders.detach();
106115
newParent = $(this).parent();
107116
if (index !== dragging.index() || startParent.get(0) !== newParent.get(0)) {
@@ -156,4 +165,8 @@
156165
});
157166
});
158167
};
159-
})(jQuery);
168+
169+
$.fn.sortable = sortable;
170+
171+
return sortable;
172+
}));

dist/html.sortable.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)