multiselect icon indicating copy to clipboard operation
multiselect copied to clipboard

added support to sortable callbacks, removed trailing witespaces, removed unused css class 'actions'

Open volpino opened this issue 14 years ago • 2 comments

hi! I added some changes to your code because i needed a callback for the sortable list. I use your multiselect as a layer selector for OpenLayers (unfortunately i don't have an online public demo). When i sort the list i want the layers on the map to sort too.

So i use this code to create the multiselect:

    $(".multiselect").multiselect({                                            
      sortable: 'left',                                                        
      sortableUpdate:                                                          
        function(event, ui, sortable) {                                        
          var layer_list = sortable.sortable("toArray");                       
          var layer_id = ui.item.attr("id");                                   
          var layer = map.getLayersBy("id", layer_id)[0];                      
          if (!(layer.isBaseLayer || layer_id.search("OSM") != -1)) {          
            var layer_pos = layer_list.length - 1 - layer_list.indexOf(layer_id);
            if (layer_pos != 0) {                                              
              console.log("moving " + layer_id + " to " + layer_pos);          
              map.setLayerIndex(layer, layer_pos);                             
              return;                                                          
            }                                                                  
          }                                                                    
          sortable.sortable('cancel');                                         
        },                                                                     
      selected:                                                                
        function(event, ui) {                                                  
          map.getLayersByName($(ui.option).val())[0].setVisibility(true);   
        },                                                                     
      deselected:                                                              
        function(event, ui) {                                                  
          map.getLayersByName($(ui.option).val())[0].setVisibility(false);  
        }                                                                      
    });

I removed some trailing whitespaces, and an unused css class that was messing everything up because it is defined in the twitter bootstrap css (which i'm using for the whole webpage style).

volpino avatar Dec 21 '11 21:12 volpino

The 'actions' class added in js messes things up with Twitter Bootstrap. Looks like it should be 'action' according to the css.

Prasanna79 avatar Mar 09 '12 06:03 Prasanna79

Yes, it's what my patch is about. You can use my fork in the meanwhile

volpino avatar Mar 09 '12 08:03 volpino