src/sidebar/Layers.js
// Adds sortable and selectable options to layers.
Adds sortable and selectable options to layers.
Adds sortable and selectable options to layers .
function addLayerProperties() {
  var layer_list = document.getElementById("sortable_layers");
  var layer = layer_list.getElementsByClassName("layer");
  for (var i = 0; i < layer.length; i++) {
      layer[i].addEventListener("click", function() {
          var current = document.getElementsByClassName("active");
          if (current[0]){
          current[0].className = current[0].className.replace(" active", "");
          }
          this.className += " active";
          updateSelected()
      });
  }
  reorderLayers(getLayers())
  Sortable.create(layer_list,{
      onEnd: function (e){
          reorderLayers(getLayers())
      }
  })
function getLayers(){
  var i;
  var list_order = [];
  var a = document.getElementsByClassName("layer")
  for (i=0; i < a.length; i++){
      var class_name = ((a[i].className).split(" "))
      list_order.push(class_name[1])
  }
  return list_order;
}
}
function addLayerProperties ( ) { var layer_list = document . getElementById ( "sortable_layers" ) ; var layer = layer_list . getElementsByClassName ( "layer" ) ; for ( var i = 0 ; i < layer . length ; i ++ ) { layer [ i ] . addEventListener ( "click" , function ( ) { var current = document . getElementsByClassName ( "active" ) ; if ( current [ 0 ] ) { current [ 0 ] . className = current [ 0 ] . className . replace ( " active" , "" ) ; } this . className += " active" ; updateSelected ( ) } ) ; } reorderLayers ( getLayers ( ) ) Sortable . create ( layer_list , { onEnd : function ( e ) { reorderLayers ( getLayers ( ) ) } } ) function getLayers ( ) { var i ; var list_order = [ ] ; var a = document . getElementsByClassName ( "layer" ) for ( i = 0 ; i < a . length ; i ++ ) { var class_name = ( ( a [ i ] . className ) . split ( " " ) ) list_order . push ( class_name [ 1 ] ) } return list_order ; } }
Adds sortable and selectable options to layers.
Adds sortable and selectable options to layers .
// Gets the class name for the layer list. // Makes the sidebar layer list selectable. // Makes the sidebar layer list sortable // Reorders the layers based on ID name ordering. // Function that returns all layers (and their order.)