   ]
   @
 
-
+# This section is wrapped in an immediately invoked function so that it can exit
+# early when discovering a lack of browser support to prevent unnecessary work.
 do ->
-  # Loop through the CSS hash and replace each value with the result of `testProp()`.
+  # Loop through the CSS map and replace each value with the result of `testProp()`.
   for key, value of css
     css[key] = testProp value
     # If the returned value is false, warn the user that the browser doesn't support
-    # OriDomi, set `isSupported` to false and break out of the loop.
-    unless css[key]
-      supportWarning value
-      return
-
+    # OriDomi, set `isSupported` to false, and break out of the loop.
+    return supportWarning value unless css[key]
+
+  # Test for `preserve-3d` as a transform style. This is particularly important
+  # since it's necessary for nested 3D transforms and recent versions of IE that
+  # support 3D transforms lack it.
   p3d = 'preserve-3d'
-  if isSupported and css.transformStyle
-    testEl.style[css.transformStyle] = p3d
-    unless testEl.style[css.transformStyle] is p3d
-      isSupported = false
-      supportWarning p3d
-      return
-
-  # CSS3 gradients are used for shading.
+  testEl.style[css.transformStyle] = p3d
+  # Failure is indicated when querying the style lacks the correct string.
+  unless testEl.style[css.transformStyle] is p3d
+    return supportWarning p3d
+
+  # CSS3 linear gradients are used for shading.
   # Testing for them is different because they are prefixed values, not properties.
-  # This invokes an anonymous function to loop through vendor-prefixed linear-gradients.
+  # This invokes an anonymous function to loop through vendor-prefixed linear gradients.
   css.gradientProp = do ->
     for prefix in prefixList
       hyphenated = "-#{ prefix.toLowerCase() }-linear-gradient"


# Set a reference to jQuery (or another `$`-aliased DOM library).
# If it doesn't exist, set to null so OriDomi knows we are working without jQuery.
# OriDomi doesn't require it to work, but offers a useful plugin bridge.
$ = if (window.jQuery or window.$)?.data then window.$ else null

# This variable is set to true and negated later if the browser does
# not support OriDomi.
isSupported = true

anchorList  = ['left', 'right', 'top', 'bottom']
anchorListV = anchorList[..1]
anchorListH = anchorList[2..]

# Create a div for testing CSS3 properties.
testEl = document.createElement 'div'

# The style buffer is later populated with CSS rules and appended to the document.
styleBuffer = ''

# List of browser prefixes for testing CSS3 properties.
prefixList = ['Webkit', 'Moz', 'ms']
baseName   = 'oridomi'
# CSS classes used by style rules.
elClasses  =
  active:       'active'
  clone:        'clone'
  holder:       'holder'
