     @$settings.show()
 
 
-Xray.init()+# Utility methods.
+util =
+  # Computes the bounding box of a jQuery set, which may be many sibling
+  # elements with no parent in the set.
+  computeBoundingBox: ($contents) ->
+    # Edge case: the container may not physically wrap its children, for
+    # example if they are floated and no clearfix is present.
+    if $contents.length == 1 and $contents.height() <= 0
+      return util._computeBoundingBox($contents.children())
+
+    boxFrame =
+      top    : Number.POSITIVE_INFINITY
+      left   : Number.POSITIVE_INFINITY
+      right  : Number.NEGATIVE_INFINITY
+      bottom : Number.NEGATIVE_INFINITY
+
+    for el in $contents
+      $el = $(el)
+      continue unless $el.is(':visible')
+      frame = $el.offset()
+      frame.right  = frame.left + $el.outerWidth()
+      frame.bottom = frame.top + $el.outerHeight()
+      boxFrame.top    = frame.top if frame.top < boxFrame.top
+      boxFrame.left   = frame.left if frame.left < boxFrame.left
+      boxFrame.right  = frame.right if frame.right > boxFrame.right
+      boxFrame.bottom = frame.bottom if frame.bottom > boxFrame.bottom
+
+    return {
+      left   : boxFrame.left
+      top    : boxFrame.top
+      width  : boxFrame.right - boxFrame.left
+      height : boxFrame.bottom - boxFrame.top
+    }
+
+  # Benchmark a piece of code
+  bm: (name, fn) ->
+    time = new Date
+    result = fn()
+    # console.log "#{name} : #{new Date() - time}ms"
+    result

window.Xray = {}
return unless $ = window.jQuery

# Benchmark a piece of code
bm = (name, fn) ->
  time = new Date
  result = fn()
  # console.log "#{name} : #{new Date() - time}ms"
  result

# Max CSS z-index. The overlay and xray bar use this.
MAX_ZINDEX = 2147483647

# Initialize Xray
Xray.init = ->
  return if Xray.initialized
  Xray.initialized = true


# Wraps a DOM element that Xray is tracking. This is subclassed by
# Xray.TemplateSpecimen and Xray.ViewSpecimen.
class Xray.Specimen
  @add: (el, info = {}) ->
    @all.push new this(el, info)

  @remove: (el) ->
    @find(el)?.remove()
