<NME> action-settings.cocoascript
<BEF> var configureRetinaEnabled = nil
var configureRetinaValue = nil
var configureRetinaString = nil
var configureMobile = nil
var configureMinimalExport = nil
var configureAutoplay = nil

var measureSettingsHeight = 470
var measureSettingsWidth = 300
var measureSettingBlock = 16



var runSettings = function() {
	StatisticsInventory.sendRequest(StatisticsInventory.returnRequestURL(settingsOpenedRequest))

	var exportWindow = [[NSWindow alloc] init]
	exportWindow.setStyleMask(NSTitledWindowMask + NSFullSizeContentViewWindowMask);
	exportWindow.setBackgroundColor(ViewInventory.colorWindow());
	exportWindow.setTitleVisibility(NSWindowTitleHidden);
	exportWindow.setTitlebarAppearsTransparent(true);
	exportWindow.setFrame_display(NSMakeRect(0, 0, ViewInventory.sizeModalSettings(), measureSettingsHeight-50), false);
	exportWindow.setMovableByWindowBackground(true);
	exportWindow.setHasShadow(true);
	exportWindow.setLevel(NSFloatingWindowLevel);

	var topBreaker = ViewInventory.addImage(NSMakeRect(0, 440-50, ViewInventory.sizeModalSettings(), 1), "settings/breaker")
	[[exportWindow contentView] addSubview:topBreaker]

	var bottomBreaker = ViewInventory.addImage(NSMakeRect(0, 53, ViewInventory.sizeModalSettings(), 1), "settings/breaker")
	[[exportWindow contentView] addSubview:bottomBreaker]




	var topImage = ViewInventory.addImage(NSMakeRect(68, 340-50, 164, 83), "settings/top")
	[[exportWindow contentView] addSubview:topImage]

	// var groupsImage = ViewInventory.addImage(NSMakeRect(41, 134, 15, 39), "settings/groups")
	// [[exportWindow contentView] addSubview:groupsImage]

	var menuImage = ViewInventory.addImage(NSMakeRect(0, 274-50-2, 300, 32), "settings/menu")
	[[exportWindow contentView] addSubview:menuImage]




	var headerViews = createHeader()
	for (var i = 0; i < headerViews.length; i++) { [[exportWindow contentView] addSubview:headerViews[i]] }

	var licenseButton = ViewInventory.addButton( NSMakeRect(126+5+4, 274-50, 112, 28), "settings/donate",
			function(sender){
					var registeredState = DemoInventory.isRegistered()

					if (DemoInventory.isRegistered()) { showRemoveLicense() }
					else { showEnterLicense() }

					if (registeredState != DemoInventory.isRegistered()) {
						[exportWindow orderOut:nil]
						[NSApp stopModal]
					}

	})
	[[exportWindow contentView] addSubview:licenseButton]



	// var firstLineViews = createFirstLine()
	// for (var i = 0; i < firstLineViews.length; i++) { [[exportWindow contentView] addSubview:firstLineViews[i]] }
	// var retinaInput = firstLineViews[0]




	var checkViews = createCheckViews()
	for (var i = 0; i < checkViews.length; i++) { [[exportWindow contentView] addSubview:checkViews[i]] }

	[[exportWindow contentView] addSubview:createVersionView()]
	[[exportWindow contentView] addSubview:createHelpButton()]




	var saveButton = ViewInventory.addButton(NSMakeRect(16, 16, 58, 20), "settings/done",
			function(sender){
				[exportWindow orderOut:nil]
				[NSApp stopModal]
				ToolbarInventory.updateAccessoryControls()

				// var newRetinaValue = retinaInput.stringValue() + ""
				var trimmedRetinaValue = newRetinaValue.trim()
				if (trimmedRetinaValue == "") { [currentDocument showMessage:"Scale variable can't be empty. Back to \"" + userDefaults.myRetinaString + "\""] }
				else if (/^[a-zA-Z]+$/.test(trimmedRetinaValue)) {
					userDefaults.myRetinaString = trimmedRetinaValue
					saveDefaults(Status.userDomain(), userDefaults)
					[currentDocument showMessage:"💾"]
				}
				else { [currentDocument showMessage:"Scale variable should contain only letters. Back to \"" + userDefaults.myRetinaString + "\""] }
	})

	[saveButton setKeyEquivalent:"\033"]
	[[exportWindow contentView] addSubview:saveButton];




	var learnButton = ViewInventory.addButton( NSMakeRect(86, 17, 78, 22), "settings/learn",
			function(sender){
				var url = [NSURL URLWithString:StatisticsInventory.getLearnLink()];
				[[NSWorkspace sharedWorkspace] openURL:url]
	})

	[[exportWindow contentView] addSubview:learnButton];
	// [[exportWindow contentView] addSubview:createRadioGroupRelative()];
	[[exportWindow contentView] addSubview:createRadioGroupStyle()];
	[[exportWindow contentView] addSubview:createRadioGroupStyleCases()];




	var registeredStatusText = [[NSTextField alloc] initWithFrame:NSMakeRect(6, 446-50, ViewInventory.sizeModalSettings() - 12, 17)];
	[registeredStatusText setEditable:false];
	[registeredStatusText setBordered:false];
	[registeredStatusText setFont:ViewInventory.fontInputControls()];
	[registeredStatusText setTextColor:ViewInventory.colorVersion()];
	[registeredStatusText setDrawsBackground:false];
	[[exportWindow contentView] addSubview:registeredStatusText];

	if (DemoInventory.isRegistered()) {
		[registeredStatusText setStringValue:ViewInventory.registeredStatusDone()]
		[registeredStatusText setAlignment:NSCenterTextAlignment];
	}
	else {
		[registeredStatusText setStringValue:ViewInventory.registeredStatusLeft()]

		var getProButton = ViewInventory.addButton(NSMakeRect(235, 444, 58, 18), "settings/get pro",
				function(sender){
					showExpiredModal()

					if (DemoInventory.isRegistered()) {
						[exportWindow orderOut:nil]
						[NSApp stopModal]
					}
				});
		[[exportWindow contentView] addSubview:getProButton];
	}


	var textTitles = []

	var styleText = [[NSTextField alloc] initWithFrame:NSMakeRect(19, 183+4, 64, 12)];
	[styleText setStringValue:"Configure generated code style"];
	textTitles.push(styleText)

	for (var i = 0; i < textTitles.length; i++) {
		var currentTextView = textTitles[i]
		[currentTextView setEditable:false];
	  [currentTextView setBordered:false];
		[currentTextView setFont:ViewInventory.fontInputControls()];
	  [currentTextView setTextColor:ViewInventory.colorTitle()];
	  [currentTextView setDrawsBackground:false];
	  [currentTextView sizeToFit];
		[[exportWindow contentView] addSubview:currentTextView];
	}

	[NSApp runModalForWindow:exportWindow];
}




var createHeader = function() {

	var supportButton = ViewInventory.addButton( NSMakeRect(10+5, 274-50, 112, 28), "settings/support",
			function(sender){
				var url = [NSURL URLWithString:StatisticsInventory.getSupportLink()];
				[[NSWorkspace sharedWorkspace] openURL:url]

	})

	return [supportButton]
}



var createRadioGroupRelative = function() {

	var prototype = [[NSButtonCell alloc] init];
	[prototype setTitle:"Artboard Type"];
	[prototype setButtonType:NSRadioButton];
	[prototype setFont:ViewInventory.fontRadioButton()];

	var matrixRect = NSMakeRect(16, 130, 120, 48);
	var myMatrix = [[NSMatrix alloc] initWithFrame:matrixRect
																										mode:NSRadioModeMatrix
																							 prototype:prototype
																						numberOfRows:2
																				 numberOfColumns:1];

	var cellArray = [myMatrix cells];
	var cellTitle1 = "       Artboard"
	var cellTitle2 = "       Group"
	[[cellArray objectAtIndex:0] setTitle:cellTitle1];
	[[cellArray objectAtIndex:1] setTitle:cellTitle2];
	[myMatrix setCellSize:NSMakeSize(120, 24)]
	if (userDefaults.myRelativeGroup == 1) { [myMatrix selectCellAtRow:1 column:0] }
	else { [myMatrix selectCellAtRow:0 column:0] }

	[myMatrix setCOSJSTargetFunction:function(sender) {
		var currentCellTitle = [[myMatrix selectedCell] title]
		if ([currentCellTitle isEqualToString:cellTitle2]) { userDefaults.myRelativeGroup = 1 }
		else { userDefaults.myRelativeGroup = 0 }
		saveDefaults(Status.userDomain(), userDefaults)
	}];

	return myMatrix
}



var createRadioGroupStyleCases = function() {

		var prototype = [[NSButtonCell alloc] init];
	[helpButton setBezelStyle:NSHelpButtonBezelStyle];
	[helpButton setTitle:nil];
	[helpButton setCOSJSTargetFunction:function(sender) {
		var url = [NSURL URLWithString:@"http://medium.com"];
		[[NSWorkspace sharedWorkspace] openURL:url]
	}];
	[helpButton setAction:"callAction:"]
																								 prototype:prototype
																							numberOfRows:2
																					 numberOfColumns:1];

		var cellArray = [myMatrix cells];
		var cellTitle1 = " camelCase"
		var cellTitle2 = " under_scores"
		[[cellArray objectAtIndex:0] setTitle:cellTitle1];
		[[cellArray objectAtIndex:1] setTitle:cellTitle2];
		[myMatrix setCellSize:NSMakeSize(120, 24)]
		if (userDefaults.myCodeStyle == 0) { [myMatrix selectCellAtRow:1 column:0] }
		else { [myMatrix selectCellAtRow:0 column:0] }

		[myMatrix setCOSJSTargetFunction:function(sender) {
			var currentCellTitle = [[myMatrix selectedCell] title]
			if ([currentCellTitle isEqualToString:cellTitle2]) { userDefaults.myCodeStyle = 0 }
			else { userDefaults.myCodeStyle = 1 }
			saveDefaults(Status.userDomain(), userDefaults)
		}];

		return myMatrix
	}

var createRadioGroupStyle = function() {

		var prototype = [[NSButtonCell alloc] init];
		[prototype setTitle:"Style Type"];
		[prototype setButtonType:NSRadioButton];
		[prototype setFont:ViewInventory.fontRadioButton()];

		var matrixRect = NSMakeRect(174, 130, 120, 48);
		var myMatrix = [[NSMatrix alloc] initWithFrame:matrixRect
																											mode:NSRadioModeMatrix
																								 prototype:prototype
																							numberOfRows:2
																					 numberOfColumns:1];

		var cellArray = [myMatrix cells];
		var cellTitle1 = " Tabs"
		var cellTitle2 = " Commas"
		[[cellArray objectAtIndex:0] setTitle:cellTitle1];
		[[cellArray objectAtIndex:1] setTitle:cellTitle2];
		[myMatrix setCellSize:NSMakeSize(120, 24)]
		if (userDefaults.myDetailedNotation == 0) { [myMatrix selectCellAtRow:1 column:0] }
		else { [myMatrix selectCellAtRow:0 column:0] }

		[myMatrix setCOSJSTargetFunction:function(sender) {
			var currentCellTitle = [[myMatrix selectedCell] title]
			if ([currentCellTitle isEqualToString:cellTitle2]) { userDefaults.myDetailedNotation = 0 }
			else { userDefaults.myDetailedNotation = 1 }
			saveDefaults(Status.userDomain(), userDefaults)
		}];

		return myMatrix
	}


var createFirstLine = function() {

	var retinaInput = [[NSTextField alloc] initWithFrame:NSMakeRect(88, 224-4, 78, 20)];
  [[retinaInput cell] setPlaceholderString:"Ex: \"retina\""];
	[retinaInput setFocusRingType:NSFocusRingTypeNone];
	[retinaInput becomeFirstResponder];
  [retinaInput setBordered:false];
  [retinaInput setBackgroundColor:[NSColor colorWithSRGBRed:0.97 green:0.97 blue:0.97 alpha:1]];
  [retinaInput setStringValue:userDefaults.myRetinaString];
	[retinaInput setFont:ViewInventory.fontInputControls()];


	var densityAccessory = NSPopUpButton.alloc().initWithFrame(NSMakeRect(measureSettingBlock, 220-4, 64, 28))
	[[densityAccessory cell] setBezelStyle:NSTexturedRoundedBezelStyle];
	var densityValues = ["Pixels", "Points"];
	densityAccessory.addItemsWithTitles(densityValues)
	// densityAccessory.selectItemAtIndex(userDefaults.myRetinaEnabled)
	densityAccessory.selectItemAtIndex(0)
	[densityAccessory setFont:ViewInventory.fontAccessory()];

	densityAccessory.setCOSJSTargetFunction(function(sender){
			userDefaults.myRetinaEnabled = densityAccessory.indexOfSelectedItem()
			saveDefaults(Status.userDomain(), userDefaults)
	})


	var deviceAccessory = NSPopUpButton.alloc().initWithFrame(NSMakeRect(174, 220-4, 110, 28))
	[[deviceAccessory cell] setBezelStyle:NSTexturedRoundedBezelStyle];
	var devices = ScaleInventory.returnDevices()
	for (var i = 0; i < devices.length; i++) {
			deviceAccessory.addItemsWithTitles(devices[i])
			if (i != devices.length - 1) { [[deviceAccessory menu] addItem:[NSMenuItem separatorItem]] }
	}
	deviceAccessory.selectItemAtIndex(ScaleInventory.deviceToSelect(userDefaults.myDevice))
	[deviceAccessory setFont:ViewInventory.fontAccessory()];

	deviceAccessory.setCOSJSTargetFunction(function(sender) {
			userDefaults.myDevice = ScaleInventory.selectedDeviceIndex(deviceAccessory.indexOfSelectedItem())
			saveDefaults(Status.userDomain(), userDefaults)
			ToolbarInventory.updateAccessoryControls()
	})


	return [retinaInput, densityAccessory, deviceAccessory]
}



var createCheckViews = function() {

	var titleMinimalExport = [[NSTextField alloc] initWithFrame:NSMakeRect(measureSettingBlock*2+2, 88, measureSettingsWidth - measureSettingBlock*3, measureSettingBlock)];
  [titleMinimalExport setEditable:false];
  [titleMinimalExport setBordered:false];
	[titleMinimalExport setFont:ViewInventory.fontCheckControls()];
  [titleMinimalExport setTextColor:ViewInventory.colorBlack()];
  [titleMinimalExport setDrawsBackground:false];
  [titleMinimalExport setStringValue:" Use minimazed states in Prototypes"];
  [titleMinimalExport sizeToFit];

	var checkboxMinimalExport = [[NSButton alloc] initWithFrame:NSMakeRect(measureSettingBlock, 88-1, measureSettingBlock*12, measureSettingBlock)];
	[checkboxMinimalExport setButtonType:NSSwitchButton];
	[checkboxMinimalExport setTitle:""];
	[checkboxMinimalExport setState:userDefaults.myMinimalExport];
	checkboxMinimalExport.setCOSJSTargetFunction(function(sender){
		userDefaults.myMinimalExport = userDefaults.myMinimalExport == 0 ? 1 : 0
		saveDefaults(Status.userDomain(), userDefaults)
	})

	return [titleMinimalExport, checkboxMinimalExport]
}




var createVersionView = function() {
	var titleVersion = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 319-50+4, measureSettingsWidth, measureSettingBlock)];
	[titleVersion setEditable:false];
	[titleVersion setBordered:false];
	[titleVersion setFont:ViewInventory.fontCheckControls()];
	[titleVersion setTextColor:ViewInventory.colorVersion()];
	[titleVersion setDrawsBackground:false];
	[titleVersion setStringValue:"v" + pluginVersion];
	[titleVersion setAlignment:NSCenterTextAlignment];

	return titleVersion
}


var createHelpButton = function() {
  var helpButton = [[NSButton alloc] initWithFrame:NSMakeRect(measureSettingsWidth-32-20+2, 12, 32, 32)];
	[helpButton setBezelStyle:NSHelpButtonBezelStyle];
	[helpButton setTitle:nil];
	[helpButton setCOSJSTargetFunction:function(sender) {
			var url = NSURL.URLWithString(StatisticsInventory.getHelpLink());
			[[NSWorkspace sharedWorkspace] openURL:url]
	}];
	[helpButton setAction:"callAction:"]

	return helpButton
}

<MSG> 2.0.1

- Updated article link in Settings

<DFF> @@ -224,7 +224,7 @@ var createHelpButton = function(exportWindow) {
 	[helpButton setBezelStyle:NSHelpButtonBezelStyle];
 	[helpButton setTitle:nil];
 	[helpButton setCOSJSTargetFunction:function(sender) {
-		var url = [NSURL URLWithString:@"http://medium.com"];
+		var url = [NSURL URLWithString:@"http://bit.ly/deep-framer-inventory"];
 		[[NSWorkspace sharedWorkspace] openURL:url]
 	}];
 	[helpButton setAction:"callAction:"]

2.0.1