/* * jQuery UI Multiselect * * Authors: * Michael Aufreiter (quasipartikel.at) * Yanick Rochon (yanick.rochon[at]gmail[dot]com) * * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * http://www.quasipartikel.at/multiselect/ * * * Depends: * ui.core.js * ui.sortable.js * * Optional: * localization (http://plugins.jquery.com/project/localisation) * scrollTo (http://plugins.jquery.com/project/ScrollTo) * * Todo: * Make batch actions faster * Implement dynamic insertion through remote calls */ (function($) { $.widget("ui.multiselect", { options: { sortable: true, searchable: true, doubleClickable: true, animated: 'fast', show: 'slideDown', hide: 'slideUp', dividerLocation: 0.6, availableFirst: false, nodeComparator: function(node1,node2) { var text1 = node1.text(), text2 = node2.text(); return text1 == text2 ? 0 : (text1 < text2 ? -1 : 1); } }, _create: function() { this.element.hide(); this.id = this.element.attr("id"); this.container = $('
').insertAfter(this.element); this.count = 0; // number of currently selected options this.selectedContainer = $('
').appendTo(this.container); this.availableContainer = $('
')[this.options.availableFirst?'prependTo': 'appendTo'](this.container); this.selectedActions = $('
0 '+$.ui.multiselect.locale.itemsCount+''+$.ui.multiselect.locale.removeAll+'
').appendTo(this.selectedContainer); this.availableActions = $('
'+$.ui.multiselect.locale.addAll+'
').appendTo(this.availableContainer); this.selectedList = $('').bind('selectstart', function(){return false;}).appendTo(this.selectedContainer); this.availableList = $('').bind('selectstart', function(){return false;}).appendTo(this.availableContainer); var that = this; // set dimensions this.container.width(this.element.width()+1); this.selectedContainer.width(Math.floor(this.element.width()*this.options.dividerLocation)); this.availableContainer.width(Math.floor(this.element.width()*(1-this.options.dividerLocation))); // fix list height to match