Skip to content

Commit

Permalink
Inline the required enableSelection/disableSelection functionality in…
Browse files Browse the repository at this point in the history
…stead of adding 37kb of jQuery UI JavaScript
  • Loading branch information
matthiask committed Feb 1, 2016
1 parent ce47845 commit a718d99
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
17 changes: 17 additions & 0 deletions mptt/static/mptt/draggable-admin.js
Expand Up @@ -13,6 +13,23 @@ if (!Array.prototype.indexOf) {
};
}

// https://github.com/jquery/jquery-ui/blob/master/ui/disable-selection.js
django.jQuery.fn.extend({
disableSelection: (function() {
var eventType = 'onselectstart' in document.createElement('div') ? 'selectstart' : 'mousedown';

return function() {
return this.on(eventType + '.ui-disableSelection', function(event) {
event.preventDefault();
});
};
})(),

enableSelection: function() {
return this.off('.ui-disableSelection');
}
});


django.jQuery(function($){

Expand Down

0 comments on commit a718d99

Please sign in to comment.