diff options
| author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-03-14 18:48:00 +0100 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-03-14 18:48:00 +0100 |
| commit | 054fdbdf7a1e5106725b8b5a36db99242cfa65c1 (patch) | |
| tree | 1633b26e884feb1f29afedbb80cef7a6ecbdba2d /chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js | |
| parent | 8a5ba2650678ec22107a1a0a10650b6e0cc14683 (diff) | |
| parent | d02ec4246813eb0787bf3ab54af1af9ce32bd376 (diff) | |
| download | Chimère-054fdbdf7a1e5106725b8b5a36db99242cfa65c1.tar.bz2 Chimère-054fdbdf7a1e5106725b8b5a36db99242cfa65c1.zip | |
Merge branch 'master' into saclay
Conflicts:
chimere/locale/fr/LC_MESSAGES/django.po
chimere/static/chimere/css/styles.css
chimere/static/chimere/js/jquery.chimere.js
chimere/templates/chimere/detail.html
chimere/templatetags/chimere_tags.py
chimere/utils.py
chimere/views.py
example_project/settings.py
Diffstat (limited to 'chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js')
| -rw-r--r-- | chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js b/chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js new file mode 100644 index 0000000..3e4b9f8 --- /dev/null +++ b/chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js @@ -0,0 +1,49 @@ +/* + * Better Select Multiple Sortable Plugin + * + * Copyright (c) 2010 by Victor Berchet - http://www.github.com/vicb + * + * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. + * + * version: v1.1.1 - 2010-11-17 + */ +(function($) { + $.bsmSelect.plugins.sortable = function(sortConfig, options) + { + if (!(this instanceof arguments.callee)) { + return new arguments.callee(sortConfig, options); + } + this.sortConfig = sortConfig; + this.options = $.extend({}, this.defaultOpt, options || {}); + } + + $.extend($.bsmSelect.plugins.sortable.prototype, { + defaultOpt: { + listSortableClass: 'bsmListSortable' + }, + + init: function(bsm) { + var o = $.extend({}, this.options, bsm.options), + config = $.extend({}, this.sortConfig, { items: '.' + o.listItemClass }), + self = this; + bsm.$list.addClass(o.listSortableClass).sortable(config); + bsm.$original.bind('change', function(e, info) { self.onChange.call(self, bsm, e, info); } ); + bsm.$list.bind('sortupdate', function(e, ui) { self.onSort.call(self, bsm, e, ui); } ); + }, + + onChange: function(bsm, e, info) { + if (info && info.type == 'add' && !bsm.buildingSelect) { + info.option.detach()[bsm.options.addItemTarget == 'top' ? 'prependTo' : 'appendTo'](bsm.$original); + bsm.$list.sortable('refresh'); + } + }, + + onSort: function(bsm, e, ui) { + $('.' + bsm.options.listItemClass, bsm.$list).each(function() { + $(this).data('bsm-option').data('orig-option').detach().appendTo(bsm.$original); + }); + bsm.triggerOriginalChange($(ui.item).data('bsm-option').data('orig-option'), 'sort'); + } + }); +})(jQuery); + |
