<NME> describe.cocoascript
<BEF> ADDFILE
<MSG> Refactored descriptions

- changed location of descriptions from generate.cocoascript to
describe.cocoascript

<DFF> @@ -0,0 +1,151 @@
+
+// function DescribeInventory () {}
+
+
+
+// states related
+
+function generateStateSection(layerName, generatedStates) {
+	if (generatedStates == nil || generatedStates.length == 0) { return "" }
+	
+	var stateSectionName = normalizeName(layerName) + ".states.add {" + ln()
+	var stateBottomSection = "}" + ln()
+	
+	var states = ""
+	for (var i = 0; i < generatedStates.length; i++) {
+		var correctBeginString = generatedStates[i].replace("{,", "{")
+		states += tln() + correctBeginString + ln()
+	}
+	
+	return stateSectionName + states + stateBottomSection
+}
+
+function generateState(stateName, stateContent) {
+	if (stateContent == "" || stateContent == nil || stateContent == '') { return "" }
+	return clearName(stateName) + ": {" + stateContent + "}"
+}
+
+
+function generateStateSwitchInstant(layerName, stateName) {
+	return "" + normalizeName(layerName) + ".states.switchInstant \"" + normalizeName(stateName) + "\"" + dln()
+}
+
+function generateRetinaVariable() {
+	var chosenRetina = FramerInventory.getRetinaValue()
+	return userDefaults.myRetina + " = " + chosenRetina + ln()
+}
+
+function generatePhoneModel() {
+	var model = FramerInventory.getPhoneValue()
+	var modelDescription = ""
+	
+	if (model == 1 || model == 2 || model == 3) {
+		modelDescription += "# mobile" + ln()
+	} 
+	
+	if (model == 1) {
+		modelDescription += "Framer.Device.deviceType = \"iphone-5s-spacegray\"" + ln()
+	}
+	else if (model == 2) {
+		modelDescription += "Framer.Device.deviceType = \"iphone-6-spacegray\"" + ln()
+		modelDescription += "if Screen.width == 640" + ln()
+		modelDescription += tln() + "Framer.Device.contentScale = 0.853" + ln()
+	}
+	else if (model == 3) {
+		modelDescription += "Framer.Device.deviceType = \"iphone-6plus-spacegray\"" + ln()
+		modelDescription += "if Screen.width == 640" + ln()
+		modelDescription += tln() + "Framer.Device.contentScale = 0.515" + ln()
+		modelDescription += "if Screen.width == 750" + ln()
+		modelDescription += tln() + "Framer.Device.contentScale = 0.604" + ln()
+	}
+	return modelDescription
+}
+
+
+
+function getButtonName() {
+	return "cycleButton"
+}
+
+function generateCycleButton() {
+	return getButtonName() + " = new Layer width: Screen.width, height: Screen.height, backgroundColor: \"transparent\"" + dln()
+}
+
+
+
+function getCycleArrayName() {
+	return "statesFromArtboards"
+}
+
+function generateCycleStates(states) {
+	var cycleStatesDescription = getCycleArrayName() + " = ["
+	for (var i = 0; i < states.length; i++) {
+		cycleStatesDescription += "\"" + normalizeName(states[i]) + "\""
+		if (i != states.length - 1) { cycleStatesDescription += ", "}
+	}
+	cycleStatesDescription += "]" + ln()
+	return cycleStatesDescription
+}
+
+
+
+function getLayersArrayName() {
+	return "items"
+}
+
+function generateLayers(layers) {
+	var layersDescription = getLayersArrayName() + " = ["
+	for (var i = 0; i < layers.count(); i++) {
+		var layerName = [[layers objectAtIndex: i] name]
+		layersDescription += normalizeName(layerName)
+		if (i != layers.count() - 1) { layersDescription += ", "}
+	}
+	layersDescription += "]" + ln()
+	return layersDescription
+	
+}
+
+
+
+function getCyclerName() {
+	return "cycler"
+}
+
+function generateCycler() {
+	var cyclerDescription = getCyclerName() + " = Utils.cycle(" + getCycleArrayName() + ")" + ln()
+	cyclerDescription += "nextState = " + getCyclerName() + "()" + dln()
+	return cyclerDescription
+}
+
+function getFunctionName() {
+	return "runSimulation"
+}
+
+
+
+function generateHandler() {
+	var handlerDescription = ""
+	
+	if (userDefaults.myAutoplay == 0) {
+		handlerDescription = getButtonName() + ".on Events.Click, ->" + ln()
+		handlerDescription += tln() + "nextState = " + getCyclerName() + "()" + ln()
+		handlerDescription += tln() + "for item in " + getLayersArrayName() + ln()
+		handlerDescription += tln() + tln() + "try" + ln()
+		handlerDescription += tln() + tln() + tln() + "item.states.switch(nextState)" + ln()
+		handlerDescription += tln() + tln() + "catch error" + dln()
+	}
+	else {
+		handlerDescription = getFunctionName() + " = () ->" + ln()
+		handlerDescription += tln() + "nextState = " + getCyclerName() + "()" + ln()
+		handlerDescription += tln() + "for item in " + getLayersArrayName() + ln()
+		handlerDescription += tln() + tln() + "try" + ln()
+		handlerDescription += tln() + tln() + tln() + "item.states.switch(nextState)" + ln()
+		handlerDescription += tln() + tln() + "catch error" + ln()
+		handlerDescription += tln() + "Utils.delay 2, ->" + ln()
+		handlerDescription += tln() + tln() + getFunctionName() + "()" + dln()
+		
+		handlerDescription += getFunctionName() + "()"
+	}
+	return handlerDescription
+}
+

Refactored descriptions