app/helpers/blacklight/openseadragon_helper.rb in blacklight-gallery-3.5.0 vs app/helpers/blacklight/openseadragon_helper.rb in blacklight-gallery-4.0.0
- old
+ new
@@ -1,7 +1,24 @@
module Blacklight
module OpenseadragonHelper
+ # Somewhat arbitrary number; the only important thing is that
+ # it is bigger than the number of embedded viewers on a page
+ ID_COUNTER_MAX = (2**20) - 1
+
+ # Mint a (sufficiently) unique identifier, so we can associate
+ # the expand/collapse control with labels
+ def self.mint_id
+ @id_counter = ((@id_counter || 0) + 1) % ID_COUNTER_MAX
+
+ # We convert the ID to hex for markup compactness
+ @id_counter.to_s(16)
+ end
+
def osd_container_class
"col-md-6"
end
+
+ def osd_html_id_prefix
+ "osd-#{Blacklight::OpenseadragonHelper.mint_id}".to_param
+ end
end
-end
\ No newline at end of file
+end