Skip to content
Browse files

Add beta Utils.globalLayers

  • Loading branch information
koenbok committed Dec 12, 2014
1 parent 47f8be6 commit d400c9c94da2515432ecd7b4e3224a23462b6687
Showing with 21 additions and 0 deletions.
  1. +21 −0 framer/
@@ -565,3 +565,24 @@ Utils.convertPoint = (input, layerA, layerB) ->

_.extend exports, Utils

Utils.globalLayers = (importedLayers) ->

# Beta. Not sure if we should push this but it's nice to have.
# Use this to make all layers in an imported set available on
# on the top level, so without the "importedLayers" prefix.

for layerName, layer of importedLayers

# Replace all whitespace in layer names
layerName = layerName.replace(/\s/g,"")

# Check if there are global variables with the same name
if window.hasOwnProperty(layerName) and not window.Framer._globalWarningGiven
print "Warning: Cannot make layer '#{layerName}' a global, an variable with that name already exists"
window[layerName] = layer

window.Framer._globalWarningGiven = true

0 comments on commit d400c9c

Please sign in to comment.