Class: Geoblacklight::Configuration::LeafletConfig

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model
Defined in:
lib/geoblacklight/configuration/leaflet_config.rb

Constant Summary collapse

DEFAULT_SLEEP_CONFIG =
{
  sleep: true, # set to false to disable
  margin_distance: 100, # set to zero / false if you want to disable this check
  sleeptime: 750,
  waketime: 750,
  hovertowake: false,
  background: "rgba(214, 214, 214, .7)"
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLeafletConfig

Returns a new instance of LeafletConfig.



46
47
48
49
50
# File 'lib/geoblacklight/configuration/leaflet_config.rb', line 46

def initialize
  super
  @sleep = LeafletSleepConfig.new(DEFAULT_SLEEP_CONFIG)
  @layers = LeafletLayersConfig.new(self.class.default_layers_config)
end

Instance Attribute Details

#bounds_overlayObject

Returns the value of attribute bounds_overlay.



9
10
11
# File 'lib/geoblacklight/configuration/leaflet_config.rb', line 9

def bounds_overlay
  @bounds_overlay
end

#controlsObject

Returns the value of attribute controls.



9
10
11
# File 'lib/geoblacklight/configuration/leaflet_config.rb', line 9

def controls
  @controls
end

#layersObject

Returns the value of attribute layers.



11
12
13
# File 'lib/geoblacklight/configuration/leaflet_config.rb', line 11

def layers
  @layers
end

#sleepObject

Returns the value of attribute sleep.



11
12
13
# File 'lib/geoblacklight/configuration/leaflet_config.rb', line 11

def sleep
  @sleep
end

Class Method Details

.default_layers_configObject

Built lazily (rather than as a frozen constant) so the sr_color_name values pick up the current I18n locale each time a config is built.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/geoblacklight/configuration/leaflet_config.rb', line 27

def self.default_layers_config
  {
    index: {
      DEFAULT: LayerConfig.new(
        color: "#7FCDBB",
        sr_color_name: I18n.t("geoblacklight.map.legend.colors.default")
      ),
      UNAVAILABLE: LayerConfig.new(
        color: "#EDF8B1",
        sr_color_name: I18n.t("geoblacklight.map.legend.colors.unavailable")
      ),
      SELECTED: LayerConfig.new(
        color: "#2C7FB8",
        sr_color_name: I18n.t("geoblacklight.map.legend.colors.selected")
      )
    }
  }
end

Instance Method Details

#to_hObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/geoblacklight/configuration/leaflet_config.rb', line 60

def to_h
  {
    bounds_overlay: bounds_overlay,
    selected_color: selected_color,
    sleep: sleep.to_h,
    sidebar: sidebar,
    layers: layers.to_h,
    controls: controls
  }.compact
end