1 (function ($, rf) {
  2 
  3     rf.ui = rf.ui || {};
  4 
  5     rf.ui.ListMulti = function(id, options) {
  6         this.namespace = this.namespace || "." + rf.Event.createNamespace(this.name, id);
  7         var mergedOptions = $.extend({}, defaultOptions, options);
  8         $super.constructor.call(this, id, mergedOptions);
  9         this.disabled = mergedOptions.disabled;
 10     };
 11 
 12     rf.ui.List.extend(rf.ui.ListMulti);
 13     var $super = rf.ui.ListMulti.$super;
 14 
 15     var defaultOptions = {
 16         clickRequiredToSelect: true
 17     };
 18 
 19     $.extend(rf.ui.ListMulti.prototype, ( function () {
 20 
 21         return{
 22 
 23             name : "listMulti",
 24 
 25             getSelectedItems: function() {
 26                 return this.list.find("." + this.selectItemCssMarker);
 27             },
 28 
 29             removeSelectedItems: function() {
 30                 var items = this.getSelectedItems();
 31                 this.removeItems(items);
 32                 return items;
 33             },
 34 
 35             __selectByIndex: function(index, clickModified) {
 36                 if (! this.__isSelectByIndexValid(index)) {
 37                     return;
 38                 }
 39 
 40                 this.index = this.__sanitizeSelectedIndex(index);
 41 
 42                 var item = this.items.eq(this.index);
 43                 if (! clickModified) {
 44                     var that = this;
 45                     this.getSelectedItems().each( function() {
 46                         that.unselectItem($(this))
 47                     });
 48                     this.selectItem(item);
 49                 } else {
 50                     if (this.isSelected(item)) {
 51                         this.unselectItem(item);
 52                     } else {
 53                         this.selectItem(item);
 54                     }
 55                 }
 56             }
 57         }
 58     })());
 59 
 60 })(RichFaces.jQuery, window.RichFaces);