diff --git a/PhotoGrid.sketchplugin/Contents/Sketch/manifest.json b/PhotoGrid.sketchplugin/Contents/Sketch/manifest.json index 3918304..643b33c 100644 --- a/PhotoGrid.sketchplugin/Contents/Sketch/manifest.json +++ b/PhotoGrid.sketchplugin/Contents/Sketch/manifest.json @@ -34,8 +34,9 @@ "version": "3.1.1", "description": "Size layers to common photo dimensions and scale them to fit in rows or columns", "name": "Photo Grid", + "identifier": "Photo Grid", "disableCocoaScriptPreprocessor": true, - "appcast": "https://api.sketchpacks.com/v1/plugins/com.gilesperry.photo-grid/appcast", + "appcast": "https://raw.githubusercontent.com/perrysmotors/photo-grid/master/.appcast.xml", "author": "Giles Perry", "authorEmail": "giles@gilesperry.info" } \ No newline at end of file diff --git a/PhotoGrid.sketchplugin/Contents/Sketch/photo-grid.js b/PhotoGrid.sketchplugin/Contents/Sketch/photo-grid.js index c11a676..edd9be6 100644 --- a/PhotoGrid.sketchplugin/Contents/Sketch/photo-grid.js +++ b/PhotoGrid.sketchplugin/Contents/Sketch/photo-grid.js @@ -41,19 +41,34 @@ var exports = /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { -/******/ configurable: false, -/******/ enumerable: true, -/******/ get: getter -/******/ }); +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? diff --git a/PhotoGrid.sketchplugin/Contents/Sketch/photo-grid.js.map b/PhotoGrid.sketchplugin/Contents/Sketch/photo-grid.js.map index 0ffbe48..b1d84e6 100644 --- a/PhotoGrid.sketchplugin/Contents/Sketch/photo-grid.js.map +++ b/PhotoGrid.sketchplugin/Contents/Sketch/photo-grid.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://exports/webpack/bootstrap","webpack://exports/./src/photo-grid.js","webpack://exports/external \"sketch/dom\"","webpack://exports/external \"sketch/settings\"","webpack://exports/external \"sketch/ui\""],"names":["UI","require","DOM","Settings","aspectRatios","options","initOptions","form","defaults","isRowLayout","padding","hasWidthLimit","maxWidth","option","value","eval","settingForKey","undefined","setSettingForKey","onRandomizeAspectRatios","context","document","getSelectedDocument","selection","selectedLayers","length","message","bounds","getBoundingBox","layers","groups","findGroups","forEach","randomizeAspectRatios","group","onFit","width","y","fitLayersInRows","sketchObject","absoluteRect","frame","height","x","fitLayersInColumns","onSettings","alert","createDialog","response","runModal","spacingTextFieldInput","spacingTextField","stringValue","spacingValue","parseInt","isNaN","rowsRadioButton","state","NSOnState","hasWidthLimitCheckbox","maxWidthTextFieldInput","maxWidthTextField","maxWidthValue","orderedLayers","sort","a","b","layer","setConstrainProportions","ratio","randomAspectRatio","delta","getDelta","Math","round","floor","random","min","max","lastLayer","median","map","widths","totalWidth","reduce","total","current","totalPadding","scale","heights","totalHeight","deltaX","deltaY","remainingLayers","Set","range","largestGroup","findLayersInGroup","delete","push","size","groupA","groupB","referenceLayer","found","rowCentre","getLayerCentre","lower","upper","centre","values","half","lefts","rights","tops","bottoms","viewWidth","viewHeight","dialog","NSAlert","alloc","init","setMessageText","addButtonWithTitle","view","NSView","initWithFrame","NSMakeRect","setAccessoryView","infoLabel","createTextField","spacingLabel","layoutLabel","maxWidthLabel","NSTextField","createRadioButton","columnsRadioButton","createCheckbox","setStringValue","String","setState","setEnabled","setCOSJSTargetFunction","sender","radioTargetFunction","addSubview","textField","setSelectable","setEditable","setBezeled","setDrawsBackground","title","checkbox","NSButton","setButtonType","NSSwitchButton","setBezelStyle","setTitle","radioButton","NSRadioButton"],"mappings":";;;;;;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;;;;;ACnEA;AAAA,IAAMA,KAAK,mBAAAC,CAAQ,4BAAR,CAAX;AAAA,IACMC,MAAM,mBAAAD,CAAQ,8BAAR,CADZ;AAAA,IAEME,WAAW,mBAAAF,CAAQ,wCAAR,CAFjB;;AAIA,IAAMG,eAAe,CAAC,CAAD,EAAI,KAAG,CAAP,EAAU,IAAE,CAAZ,EAAe,IAAE,CAAjB,EAAoB,IAAE,CAAtB,EAAyB,KAAG,CAA5B,EAA+B,IAAE,CAAjC,EAAoC,IAAE,CAAtC,EAAyC,IAAE,CAA3C,EAA8C,IAAE,EAAhD,CAArB;AAEA,IAAIC,UAAUC,aAAd;AACA,IAAIC,OAAO,EAAX;;AAEA,SAASD,WAA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AAEA,SAAOO,WAAP;AACD,C;;;;;;;;;;;ACheD,uC;;;;;;;;;;;ACAA,4C;;;;;;;;;;;ACAA,sC","file":"photo-grid.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/photo-grid.js\");\n","const UI = require('sketch/ui'),\n DOM = require('sketch/dom'),\n Settings = require('sketch/settings');\n\nconst aspectRatios = [1, 10/8, 4/3, 7/5, 3/2, 16/9, 2/3, 5/7, 3/4, 8/10];\n\nvar options = initOptions();\nvar form = {};\n\nfunction initOptions() {\n const defaults = {\n isRowLayout: true,\n padding: 16,\n hasWidthLimit: false,\n maxWidth: 1200\n };\n for (let option in defaults) {\n let value = eval(Settings.settingForKey(option));\n if (value === undefined) {\n Settings.setSettingForKey(option, defaults[option]);\n } else {\n defaults[option] = value;\n }\n }\n return defaults\n}\n\nexport function onRandomizeAspectRatios(context) {\n var document = DOM.getSelectedDocument(),\n selection = document.selectedLayers;\n\n if (selection.length === 0) {\n UI.message('Select one or more layers');\n } else {\n let bounds = getBoundingBox(selection.layers);\n let groups = findGroups(selection.layers);\n\n groups.forEach(group => {\n randomizeAspectRatios(group, bounds);\n });\n }\n}\n\nexport function onFit(context) {\n var document = DOM.getSelectedDocument(),\n selection = document.selectedLayers;\n\n if (selection.length === 0) {\n UI.message('Select one or more layers');\n } else {\n let bounds = getBoundingBox(selection.layers);\n let groups = findGroups(selection.layers);\n\n if (options.isRowLayout) {\n if (options.hasWidthLimit) {\n bounds.width = options.maxWidth;\n }\n\n let y = bounds.y;\n groups.forEach(group => {\n fitLayersInRows(group, bounds, y);\n y = group[0].sketchObject.absoluteRect().y() + group[0].frame.height + options.padding;\n });\n\n } else {\n\n let x = bounds.x;\n groups.forEach(group => {\n fitLayersInColumns(group, bounds, x);\n x = group[0].sketchObject.absoluteRect().x() + group[0].frame.width + options.padding;\n });\n\n }\n }\n}\n\nexport function onSettings(context) {\n\n var alert = createDialog();\n\n var response = alert.runModal();\n\n if (response == \"1000\") {\n // This code only runs when the user clicks 'OK';\n\n // Get Spacing\n let spacingTextFieldInput = form.spacingTextField.stringValue();\n let spacingValue = parseInt(spacingTextFieldInput);\n\n if (isNaN(spacingValue) || spacingTextFieldInput === '') {\n UI.message('⚠️ The spacing was not changed. Try entering a number.');\n } else if (spacingValue < 0 || spacingValue > 1000) {\n UI.message('⚠️ Enter a spacing value between 0 and 1000');\n } else {\n options.padding = spacingValue;\n Settings.setSettingForKey('padding', spacingValue);\n }\n\n // Get Layout\n options.isRowLayout = (form.rowsRadioButton.state() === NSOnState);\n Settings.setSettingForKey('isRowLayout', options.isRowLayout);\n\n // Get max width setting\n options.hasWidthLimit = (form.hasWidthLimitCheckbox.state() === NSOnState);\n Settings.setSettingForKey('hasWidthLimit', options.hasWidthLimit);\n\n // Get width value\n let maxWidthTextFieldInput = form.maxWidthTextField.stringValue();\n let maxWidthValue = parseInt(maxWidthTextFieldInput);\n\n if (isNaN(maxWidthValue) || maxWidthTextFieldInput === '') {\n UI.message('⚠️ The maximum width was not changed. Try entering a number.');\n } else if (maxWidthValue < 10 || maxWidthValue > 10000) {\n UI.message('⚠️ Enter a maximum width between 10 and 10,000');\n } else {\n options.maxWidth = maxWidthValue;\n Settings.setSettingForKey('maxWidth', maxWidthValue);\n }\n\n }\n\n}\n\nfunction randomizeAspectRatios(layers, bounds) {\n let orderedLayers;\n\n let x = bounds.x,\n y = bounds.y;\n\n if (options.isRowLayout) {\n orderedLayers = layers.sort((a, b) => a.sketchObject.absoluteRect().x() - b.sketchObject.absoluteRect().x());\n y = orderedLayers[0].sketchObject.absoluteRect().y();\n } else {\n orderedLayers = layers.sort((a, b) => a.sketchObject.absoluteRect().y() - b.sketchObject.absoluteRect().y());\n x = orderedLayers[0].sketchObject.absoluteRect().x();\n }\n\n orderedLayers.forEach(layer => {\n\n layer.sketchObject.setConstrainProportions(0);\n\n let ratio = randomAspectRatio();\n let delta = getDelta(layer, x, y);\n let frame = layer.frame;\n\n frame.x += delta.x;\n frame.y += delta.y;\n\n if (options.isRowLayout) {\n frame.width = Math.round(frame.height * ratio);\n x += frame.width + options.padding;\n } else {\n frame.height = Math.round(frame.width / ratio);\n y += frame.height + options.padding;\n }\n\n layer.frame = frame;\n\n });\n\n}\n\nfunction randomAspectRatio() {\n return aspectRatios[Math.floor(Math.random() * aspectRatios.length)]\n}\n\nfunction fitLayersInRows(layers, bounds, y) {\n let min = bounds.x;\n let max = bounds.x + bounds.width;\n\n let orderedLayers = layers.sort((a, b) => a.sketchObject.absoluteRect().x() - b.sketchObject.absoluteRect().x());\n let lastLayer = orderedLayers[orderedLayers.length - 1];\n\n let height = Math.round(median(layers.map(layer => layer.frame.height)));\n let widths = layers.map(layer => layer.frame.width * height / layer.frame.height);\n let totalWidth = widths.reduce((total, current) => total + current);\n\n let totalPadding = (layers.length - 1) * options.padding;\n let scale = (max - min) / (totalWidth + totalPadding);\n\n let x = min;\n\n orderedLayers.forEach(layer => {\n\n layer.sketchObject.setConstrainProportions(0);\n\n let delta = getDelta(layer, x, y);\n let frame = layer.frame;\n\n frame.x += delta.x;\n frame.y += delta.y;\n\n frame.width = Math.round(frame.width * height / frame.height * scale);\n frame.height = Math.round(height * scale);\n x += frame.width + options.padding;\n\n layer.frame = frame;\n\n });\n\n let frame = lastLayer.frame;\n frame.width = max - lastLayer.sketchObject.absoluteRect().x();\n lastLayer.frame = frame;\n\n}\n\nfunction fitLayersInColumns(layers, bounds, x) {\n let min = bounds.y;\n let max = bounds.y + bounds.height;\n\n let orderedLayers = layers.sort((a, b) => a.sketchObject.absoluteRect().y() - b.sketchObject.absoluteRect().y());\n let lastLayer = orderedLayers[orderedLayers.length - 1];\n\n let width = Math.round(median(layers.map(layer => layer.frame.width)));\n let heights = layers.map(layer => layer.frame.height * width / layer.frame.width);\n let totalHeight = heights.reduce((total, current) => total + current);\n\n let totalPadding = (layers.length - 1) * options.padding;\n let scale = (max - min) / (totalHeight + totalPadding);\n\n let y = min;\n\n orderedLayers.forEach(layer => {\n\n layer.sketchObject.setConstrainProportions(0);\n\n let delta = getDelta(layer, x, y);\n let frame = layer.frame;\n\n frame.x += delta.x;\n frame.y += delta.y;\n\n frame.height = Math.round(frame.height * width / frame.width * scale);\n frame.width = Math.round(width * scale);\n y += frame.height + options.padding;\n\n layer.frame = frame;\n\n });\n\n let frame = lastLayer.frame;\n frame.height = max - lastLayer.sketchObject.absoluteRect().y();\n lastLayer.frame = frame;\n\n}\n\nfunction getDelta(layer, x, y) {\n let absoluteRect = layer.sketchObject.absoluteRect();\n let deltaX = x - absoluteRect.x();\n let deltaY = y - absoluteRect.y();\n return {x: deltaX, y: deltaY};\n}\n\nfunction findGroups(layers) {\n let groups = [];\n let remainingLayers = new Set(layers);\n\n let range;\n if (options.isRowLayout) {\n range = Math.round(median(layers.map(layer => layer.frame.height)));\n } else {\n range = Math.round(median(layers.map(layer => layer.frame.width)));\n }\n\n while (remainingLayers.size > 0) {\n let largestGroup = [];\n remainingLayers.forEach(layer => {\n let group = findLayersInGroup(remainingLayers, layer, range);\n if (group.length > largestGroup.length) {\n largestGroup = group;\n }\n });\n\n largestGroup.forEach(layer => {\n remainingLayers.delete(layer);\n });\n\n groups.push(largestGroup);\n }\n\n if (options.isRowLayout) {\n return groups.sort((groupA, groupB) => groupA[0].sketchObject.absoluteRect().y() - groupB[0].sketchObject.absoluteRect().y());\n } else {\n return groups.sort((groupA, groupB) => groupA[0].sketchObject.absoluteRect().x() - groupB[0].sketchObject.absoluteRect().x());\n }\n\n}\n\nfunction findLayersInGroup(layers, referenceLayer, range) {\n\n let found = [];\n let rowCentre = getLayerCentre(referenceLayer);\n\n if (options.isRowLayout) {\n\n let lower = rowCentre.y - range / 2;\n let upper = rowCentre.y + range / 2;\n\n layers.forEach(layer => {\n let centre = getLayerCentre(layer);\n if (centre.y > lower && centre.y < upper) {\n found.push(layer);\n }\n });\n\n } else {\n\n let lower = rowCentre.x - range / 2;\n let upper = rowCentre.x + range / 2;\n\n layers.forEach(layer => {\n let centre = getLayerCentre(layer);\n if (centre.x > lower && centre.x < upper) {\n found.push(layer);\n }\n });\n\n }\n\n return found;\n}\n\nfunction median(values) {\n values.sort((a, b) => a - b);\n let half = Math.floor(values.length/2);\n\n if (values.length % 2) {\n return values[half];\n } else {\n return (values[half-1] + values[half]) / 2.0;\n }\n}\n\nfunction getBoundingBox(layers) {\n let lefts = layers.map(layer => layer.sketchObject.absoluteRect().x()).sort((a, b) => a - b);\n let rights = layers.map(layer => layer.sketchObject.absoluteRect().x() + layer.frame.width).sort((a, b) => a - b);\n let tops = layers.map(layer => layer.sketchObject.absoluteRect().y()).sort((a, b) => a - b);\n let bottoms = layers.map(layer => layer.sketchObject.absoluteRect().y() + layer.frame.height).sort((a, b) => a - b);\n return {\n x: lefts[0],\n y: tops[0],\n width: rights[layers.length - 1] - lefts[0],\n height: bottoms[layers.length - 1] - tops[0]\n }\n}\n\nfunction getLayerCentre(layer) {\n return {\n x: layer.sketchObject.absoluteRect().x() + layer.frame.width / 2,\n y: layer.sketchObject.absoluteRect().y() + layer.frame.height / 2\n };\n}\n\n// function numberLayers(layers, prefix) {\n// let i = 1;\n// layers.forEach(layer => {\n// layer.name += `${prefix}-${i++}`\n// });\n// }\n\nfunction createDialog() {\n\n var viewWidth = 360;\n var viewHeight = 250;\n\n // Setup the window\n var dialog = NSAlert.alloc().init();\n dialog.setMessageText('Photo Grid Settings')\n dialog.addButtonWithTitle('Ok');\n dialog.addButtonWithTitle('Cancel');\n\n // Create the main view\n var view = NSView.alloc().initWithFrame(NSMakeRect(0, 0, viewWidth, viewHeight));\n dialog.setAccessoryView(view);\n\n // --------------------------------------------------------------------------\n\n // Create labels\n var infoLabel = createTextField('Choose row or column layout and set the layer spacing. Photo Grid will try to keep layers in existing rows or columns.' , NSMakeRect(0, viewHeight - 40, viewWidth - 10, 40));\n var spacingLabel = createTextField('Spacing:', NSMakeRect(0, viewHeight - 70, 200, 20));\n var layoutLabel = createTextField('Layout:', NSMakeRect(0, viewHeight - 135, 200, 20));\n var maxWidthLabel = createTextField('Scale and Fit Rows to Fixed Width:', NSMakeRect(0, viewHeight - 200, viewWidth -10, 20));\n\n // Create textfields\n form.spacingTextField = NSTextField.alloc().initWithFrame(NSMakeRect(0, viewHeight - 95, 70, 20));\n form.maxWidthTextField = NSTextField.alloc().initWithFrame(NSMakeRect(90, viewHeight - 225, 70, 20));\n\n // Create radiobuttons\n form.rowsRadioButton = createRadioButton('Rows →', NSMakeRect(0, viewHeight - 160, 90, 20));\n form.columnsRadioButton = createRadioButton('Columns ↓', NSMakeRect(80, viewHeight - 160, 90, 20));\n\n // Create checkbox\n form.hasWidthLimitCheckbox = createCheckbox('On', NSMakeRect(0, viewHeight - 225, 90, 20));\n\n // --------------------------------------------------------------------------\n\n // Set initial input values and enabled states\n form.spacingTextField.setStringValue(String(options.padding));\n form.maxWidthTextField.setStringValue(String(options.maxWidth));\n\n if (options.hasWidthLimit) {\n form.hasWidthLimitCheckbox.setState(NSOnState);\n } else {\n form.maxWidthTextField.setEnabled(false);\n }\n\n if (options.isRowLayout) {\n form.rowsRadioButton.setState(NSOnState);\n } else {\n form.columnsRadioButton.setState(NSOnState);\n form.hasWidthLimitCheckbox.setEnabled(false);\n form.maxWidthTextField.setEnabled(false);\n }\n\n // --------------------------------------------------------------------------\n\n // Handle Enable / Disable Events\n form.hasWidthLimitCheckbox.setCOSJSTargetFunction((sender) => {\n form.maxWidthTextField.setEnabled(sender.state() === NSOnState);\n });\n\n let radioTargetFunction = (sender) => {\n let isRowLayout = (sender === form.rowsRadioButton);\n let hasWidthLimit = (form.hasWidthLimitCheckbox.state() === NSOnState);\n if (isRowLayout) {\n form.hasWidthLimitCheckbox.setEnabled(true);\n form.maxWidthTextField.setEnabled(hasWidthLimit);\n } else {\n form.hasWidthLimitCheckbox.setEnabled(false);\n form.maxWidthTextField.setEnabled(false);\n }\n };\n\n form.rowsRadioButton.setCOSJSTargetFunction(sender => radioTargetFunction(sender));\n form.columnsRadioButton.setCOSJSTargetFunction(sender => radioTargetFunction(sender));\n\n // --------------------------------------------------------------------------\n\n // Add inputs to view\n view.addSubview(infoLabel);\n view.addSubview(spacingLabel);\n view.addSubview(layoutLabel);\n view.addSubview(maxWidthLabel);\n view.addSubview(form.spacingTextField);\n view.addSubview(form.maxWidthTextField);\n view.addSubview(form.rowsRadioButton);\n view.addSubview(form.columnsRadioButton);\n view.addSubview(form.hasWidthLimitCheckbox);\n\n // --------------------------------------------------------------------------\n\n // Show the dialog window\n return dialog;\n}\n\nfunction createTextField(stringValue, frame) {\n let textField = NSTextField.alloc().initWithFrame(frame);\n textField.setStringValue(stringValue);\n textField.setSelectable(false);\n textField.setEditable(false);\n textField.setBezeled(false);\n textField.setDrawsBackground(false);\n return textField;\n}\n\nfunction createCheckbox(title, frame) {\n let checkbox = NSButton.alloc().initWithFrame(frame);\n checkbox.setButtonType(NSSwitchButton);\n checkbox.setBezelStyle(0);\n checkbox.setTitle(title);\n\n return checkbox;\n}\n\nfunction createRadioButton(title, frame) {\n let radioButton = NSButton.alloc().initWithFrame(frame);\n radioButton.setButtonType(NSRadioButton);\n radioButton.setTitle(title);\n\n return radioButton;\n}\n","module.exports = require(\"sketch/dom\");","module.exports = require(\"sketch/settings\");","module.exports = require(\"sketch/ui\");"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://exports/webpack/bootstrap","webpack://exports/./src/photo-grid.js","webpack://exports/external \"sketch/dom\"","webpack://exports/external \"sketch/settings\"","webpack://exports/external \"sketch/ui\""],"names":["UI","require","DOM","Settings","aspectRatios","options","initOptions","form","defaults","isRowLayout","padding","hasWidthLimit","maxWidth","option","value","eval","settingForKey","undefined","setSettingForKey","onRandomizeAspectRatios","context","document","getSelectedDocument","selection","selectedLayers","length","message","bounds","getBoundingBox","layers","groups","findGroups","forEach","group","randomizeAspectRatios","onFit","width","y","fitLayersInRows","sketchObject","absoluteRect","frame","height","x","fitLayersInColumns","onSettings","alert","createDialog","response","runModal","spacingTextFieldInput","spacingTextField","stringValue","spacingValue","parseInt","isNaN","rowsRadioButton","state","NSOnState","hasWidthLimitCheckbox","maxWidthTextFieldInput","maxWidthTextField","maxWidthValue","orderedLayers","sort","a","b","layer","setConstrainProportions","ratio","randomAspectRatio","delta","getDelta","Math","round","floor","random","min","max","lastLayer","median","map","widths","totalWidth","reduce","total","current","totalPadding","scale","heights","totalHeight","deltaX","deltaY","remainingLayers","Set","range","largestGroup","findLayersInGroup","delete","push","size","groupA","groupB","referenceLayer","found","rowCentre","getLayerCentre","lower","upper","centre","values","half","lefts","rights","tops","bottoms","viewWidth","viewHeight","dialog","NSAlert","alloc","init","setMessageText","addButtonWithTitle","view","NSView","initWithFrame","NSMakeRect","setAccessoryView","infoLabel","createTextField","spacingLabel","layoutLabel","maxWidthLabel","NSTextField","createRadioButton","columnsRadioButton","createCheckbox","setStringValue","String","setState","setEnabled","setCOSJSTargetFunction","sender","radioTargetFunction","addSubview","textField","setSelectable","setEditable","setBezeled","setDrawsBackground","title","checkbox","NSButton","setButtonType","NSSwitchButton","setBezelStyle","setTitle","radioButton","NSRadioButton"],"mappings":";;;;;;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;;AClFA;AAAA;AAAA;AAAA;AAAA,IAAMA,EAAE,GAAGC,mBAAO,CAAC,4BAAD,CAAlB;AAAA,IACMC,GAAG,GAAGD,mBAAO,CAAC,8BAAD,CADnB;AAAA,IAEME,QAAQ,GAAGF,mBAAO,CAAC,wCAAD,CAFxB;;AAIA,I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P;AACD;;AAED,SAASY,eAAT,CAAyB9E,WAAzB,EAAsCX,KAAtC,EAA6C;AAC3C,MAAIyG,SAAS,GAAGZ,WAAW,CAACd,KAAZ,GAAoBM,aAApB,CAAkCrF,KAAlC,CAAhB;AACAyG,WAAS,CAACR,cAAV,CAAyBtF,WAAzB;AACA8F,WAAS,CAACC,aAAV,CAAwB,KAAxB;AACAD,WAAS,CAACE,WAAV,CAAsB,KAAtB;AACAF,WAAS,CAACG,UAAV,CAAqB,KAArB;AACAH,WAAS,CAACI,kBAAV,CAA6B,KAA7B;AACA,SAAOJ,SAAP;AACD;;AAED,SAAST,cAAT,CAAwBc,KAAxB,EAA+B9G,KAA/B,EAAsC;AACpC,MAAI+G,QAAQ,GAAGC,QAAQ,CAACjC,KAAT,GAAiBM,aAAjB,CAA+BrF,KAA/B,CAAf;AACA+G,UAAQ,CAACE,aAAT,CAAuBC,cAAvB;AACAH,UAAQ,CAACI,aAAT,CAAuB,CAAvB;AACAJ,UAAQ,CAACK,QAAT,CAAkBN,KAAlB;AAEA,SAAOC,QAAP;AACD;;AAED,SAASjB,iBAAT,CAA2BgB,KAA3B,EAAkC9G,KAAlC,EAAyC;AACvC,MAAIqH,WAAW,GAAGL,QAAQ,CAACjC,KAAT,GAAiBM,aAAjB,CAA+BrF,KAA/B,CAAlB;AACAqH,aAAW,CAACJ,aAAZ,CAA0BK,aAA1B;AACAD,aAAW,CAACD,QAAZ,CAAqBN,KAArB;AAEA,SAAOO,WAAP;AACD,C;;;;;;;;;;;ACheD,uC;;;;;;;;;;;ACAA,4C;;;;;;;;;;;ACAA,sC","file":"photo-grid.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/photo-grid.js\");\n","const UI = require('sketch/ui'),\n DOM = require('sketch/dom'),\n Settings = require('sketch/settings');\n\nconst aspectRatios = [1, 10/8, 4/3, 7/5, 3/2, 16/9, 2/3, 5/7, 3/4, 8/10];\n\nvar options = initOptions();\nvar form = {};\n\nfunction initOptions() {\n const defaults = {\n isRowLayout: true,\n padding: 16,\n hasWidthLimit: false,\n maxWidth: 1200\n };\n for (let option in defaults) {\n let value = eval(Settings.settingForKey(option));\n if (value === undefined) {\n Settings.setSettingForKey(option, defaults[option]);\n } else {\n defaults[option] = value;\n }\n }\n return defaults\n}\n\nexport function onRandomizeAspectRatios(context) {\n var document = DOM.getSelectedDocument(),\n selection = document.selectedLayers;\n\n if (selection.length === 0) {\n UI.message('Select one or more layers');\n } else {\n let bounds = getBoundingBox(selection.layers);\n let groups = findGroups(selection.layers);\n\n groups.forEach(group => {\n randomizeAspectRatios(group, bounds);\n });\n }\n}\n\nexport function onFit(context) {\n var document = DOM.getSelectedDocument(),\n selection = document.selectedLayers;\n\n if (selection.length === 0) {\n UI.message('Select one or more layers');\n } else {\n let bounds = getBoundingBox(selection.layers);\n let groups = findGroups(selection.layers);\n\n if (options.isRowLayout) {\n if (options.hasWidthLimit) {\n bounds.width = options.maxWidth;\n }\n\n let y = bounds.y;\n groups.forEach(group => {\n fitLayersInRows(group, bounds, y);\n y = group[0].sketchObject.absoluteRect().y() + group[0].frame.height + options.padding;\n });\n\n } else {\n\n let x = bounds.x;\n groups.forEach(group => {\n fitLayersInColumns(group, bounds, x);\n x = group[0].sketchObject.absoluteRect().x() + group[0].frame.width + options.padding;\n });\n\n }\n }\n}\n\nexport function onSettings(context) {\n\n var alert = createDialog();\n\n var response = alert.runModal();\n\n if (response == \"1000\") {\n // This code only runs when the user clicks 'OK';\n\n // Get Spacing\n let spacingTextFieldInput = form.spacingTextField.stringValue();\n let spacingValue = parseInt(spacingTextFieldInput);\n\n if (isNaN(spacingValue) || spacingTextFieldInput === '') {\n UI.message('⚠️ The spacing was not changed. Try entering a number.');\n } else if (spacingValue < 0 || spacingValue > 1000) {\n UI.message('⚠️ Enter a spacing value between 0 and 1000');\n } else {\n options.padding = spacingValue;\n Settings.setSettingForKey('padding', spacingValue);\n }\n\n // Get Layout\n options.isRowLayout = (form.rowsRadioButton.state() === NSOnState);\n Settings.setSettingForKey('isRowLayout', options.isRowLayout);\n\n // Get max width setting\n options.hasWidthLimit = (form.hasWidthLimitCheckbox.state() === NSOnState);\n Settings.setSettingForKey('hasWidthLimit', options.hasWidthLimit);\n\n // Get width value\n let maxWidthTextFieldInput = form.maxWidthTextField.stringValue();\n let maxWidthValue = parseInt(maxWidthTextFieldInput);\n\n if (isNaN(maxWidthValue) || maxWidthTextFieldInput === '') {\n UI.message('⚠️ The maximum width was not changed. Try entering a number.');\n } else if (maxWidthValue < 10 || maxWidthValue > 10000) {\n UI.message('⚠️ Enter a maximum width between 10 and 10,000');\n } else {\n options.maxWidth = maxWidthValue;\n Settings.setSettingForKey('maxWidth', maxWidthValue);\n }\n\n }\n\n}\n\nfunction randomizeAspectRatios(layers, bounds) {\n let orderedLayers;\n\n let x = bounds.x,\n y = bounds.y;\n\n if (options.isRowLayout) {\n orderedLayers = layers.sort((a, b) => a.sketchObject.absoluteRect().x() - b.sketchObject.absoluteRect().x());\n y = orderedLayers[0].sketchObject.absoluteRect().y();\n } else {\n orderedLayers = layers.sort((a, b) => a.sketchObject.absoluteRect().y() - b.sketchObject.absoluteRect().y());\n x = orderedLayers[0].sketchObject.absoluteRect().x();\n }\n\n orderedLayers.forEach(layer => {\n\n layer.sketchObject.setConstrainProportions(0);\n\n let ratio = randomAspectRatio();\n let delta = getDelta(layer, x, y);\n let frame = layer.frame;\n\n frame.x += delta.x;\n frame.y += delta.y;\n\n if (options.isRowLayout) {\n frame.width = Math.round(frame.height * ratio);\n x += frame.width + options.padding;\n } else {\n frame.height = Math.round(frame.width / ratio);\n y += frame.height + options.padding;\n }\n\n layer.frame = frame;\n\n });\n\n}\n\nfunction randomAspectRatio() {\n return aspectRatios[Math.floor(Math.random() * aspectRatios.length)]\n}\n\nfunction fitLayersInRows(layers, bounds, y) {\n let min = bounds.x;\n let max = bounds.x + bounds.width;\n\n let orderedLayers = layers.sort((a, b) => a.sketchObject.absoluteRect().x() - b.sketchObject.absoluteRect().x());\n let lastLayer = orderedLayers[orderedLayers.length - 1];\n\n let height = Math.round(median(layers.map(layer => layer.frame.height)));\n let widths = layers.map(layer => layer.frame.width * height / layer.frame.height);\n let totalWidth = widths.reduce((total, current) => total + current);\n\n let totalPadding = (layers.length - 1) * options.padding;\n let scale = (max - min) / (totalWidth + totalPadding);\n\n let x = min;\n\n orderedLayers.forEach(layer => {\n\n layer.sketchObject.setConstrainProportions(0);\n\n let delta = getDelta(layer, x, y);\n let frame = layer.frame;\n\n frame.x += delta.x;\n frame.y += delta.y;\n\n frame.width = Math.round(frame.width * height / frame.height * scale);\n frame.height = Math.round(height * scale);\n x += frame.width + options.padding;\n\n layer.frame = frame;\n\n });\n\n let frame = lastLayer.frame;\n frame.width = max - lastLayer.sketchObject.absoluteRect().x();\n lastLayer.frame = frame;\n\n}\n\nfunction fitLayersInColumns(layers, bounds, x) {\n let min = bounds.y;\n let max = bounds.y + bounds.height;\n\n let orderedLayers = layers.sort((a, b) => a.sketchObject.absoluteRect().y() - b.sketchObject.absoluteRect().y());\n let lastLayer = orderedLayers[orderedLayers.length - 1];\n\n let width = Math.round(median(layers.map(layer => layer.frame.width)));\n let heights = layers.map(layer => layer.frame.height * width / layer.frame.width);\n let totalHeight = heights.reduce((total, current) => total + current);\n\n let totalPadding = (layers.length - 1) * options.padding;\n let scale = (max - min) / (totalHeight + totalPadding);\n\n let y = min;\n\n orderedLayers.forEach(layer => {\n\n layer.sketchObject.setConstrainProportions(0);\n\n let delta = getDelta(layer, x, y);\n let frame = layer.frame;\n\n frame.x += delta.x;\n frame.y += delta.y;\n\n frame.height = Math.round(frame.height * width / frame.width * scale);\n frame.width = Math.round(width * scale);\n y += frame.height + options.padding;\n\n layer.frame = frame;\n\n });\n\n let frame = lastLayer.frame;\n frame.height = max - lastLayer.sketchObject.absoluteRect().y();\n lastLayer.frame = frame;\n\n}\n\nfunction getDelta(layer, x, y) {\n let absoluteRect = layer.sketchObject.absoluteRect();\n let deltaX = x - absoluteRect.x();\n let deltaY = y - absoluteRect.y();\n return {x: deltaX, y: deltaY};\n}\n\nfunction findGroups(layers) {\n let groups = [];\n let remainingLayers = new Set(layers);\n\n let range;\n if (options.isRowLayout) {\n range = Math.round(median(layers.map(layer => layer.frame.height)));\n } else {\n range = Math.round(median(layers.map(layer => layer.frame.width)));\n }\n\n while (remainingLayers.size > 0) {\n let largestGroup = [];\n remainingLayers.forEach(layer => {\n let group = findLayersInGroup(remainingLayers, layer, range);\n if (group.length > largestGroup.length) {\n largestGroup = group;\n }\n });\n\n largestGroup.forEach(layer => {\n remainingLayers.delete(layer);\n });\n\n groups.push(largestGroup);\n }\n\n if (options.isRowLayout) {\n return groups.sort((groupA, groupB) => groupA[0].sketchObject.absoluteRect().y() - groupB[0].sketchObject.absoluteRect().y());\n } else {\n return groups.sort((groupA, groupB) => groupA[0].sketchObject.absoluteRect().x() - groupB[0].sketchObject.absoluteRect().x());\n }\n\n}\n\nfunction findLayersInGroup(layers, referenceLayer, range) {\n\n let found = [];\n let rowCentre = getLayerCentre(referenceLayer);\n\n if (options.isRowLayout) {\n\n let lower = rowCentre.y - range / 2;\n let upper = rowCentre.y + range / 2;\n\n layers.forEach(layer => {\n let centre = getLayerCentre(layer);\n if (centre.y > lower && centre.y < upper) {\n found.push(layer);\n }\n });\n\n } else {\n\n let lower = rowCentre.x - range / 2;\n let upper = rowCentre.x + range / 2;\n\n layers.forEach(layer => {\n let centre = getLayerCentre(layer);\n if (centre.x > lower && centre.x < upper) {\n found.push(layer);\n }\n });\n\n }\n\n return found;\n}\n\nfunction median(values) {\n values.sort((a, b) => a - b);\n let half = Math.floor(values.length/2);\n\n if (values.length % 2) {\n return values[half];\n } else {\n return (values[half-1] + values[half]) / 2.0;\n }\n}\n\nfunction getBoundingBox(layers) {\n let lefts = layers.map(layer => layer.sketchObject.absoluteRect().x()).sort((a, b) => a - b);\n let rights = layers.map(layer => layer.sketchObject.absoluteRect().x() + layer.frame.width).sort((a, b) => a - b);\n let tops = layers.map(layer => layer.sketchObject.absoluteRect().y()).sort((a, b) => a - b);\n let bottoms = layers.map(layer => layer.sketchObject.absoluteRect().y() + layer.frame.height).sort((a, b) => a - b);\n return {\n x: lefts[0],\n y: tops[0],\n width: rights[layers.length - 1] - lefts[0],\n height: bottoms[layers.length - 1] - tops[0]\n }\n}\n\nfunction getLayerCentre(layer) {\n return {\n x: layer.sketchObject.absoluteRect().x() + layer.frame.width / 2,\n y: layer.sketchObject.absoluteRect().y() + layer.frame.height / 2\n };\n}\n\n// function numberLayers(layers, prefix) {\n// let i = 1;\n// layers.forEach(layer => {\n// layer.name += `${prefix}-${i++}`\n// });\n// }\n\nfunction createDialog() {\n\n var viewWidth = 360;\n var viewHeight = 250;\n\n // Setup the window\n var dialog = NSAlert.alloc().init();\n dialog.setMessageText('Photo Grid Settings')\n dialog.addButtonWithTitle('Ok');\n dialog.addButtonWithTitle('Cancel');\n\n // Create the main view\n var view = NSView.alloc().initWithFrame(NSMakeRect(0, 0, viewWidth, viewHeight));\n dialog.setAccessoryView(view);\n\n // --------------------------------------------------------------------------\n\n // Create labels\n var infoLabel = createTextField('Choose row or column layout and set the layer spacing. Photo Grid will try to keep layers in existing rows or columns.' , NSMakeRect(0, viewHeight - 40, viewWidth - 10, 40));\n var spacingLabel = createTextField('Spacing:', NSMakeRect(0, viewHeight - 70, 200, 20));\n var layoutLabel = createTextField('Layout:', NSMakeRect(0, viewHeight - 135, 200, 20));\n var maxWidthLabel = createTextField('Scale and Fit Rows to Fixed Width:', NSMakeRect(0, viewHeight - 200, viewWidth -10, 20));\n\n // Create textfields\n form.spacingTextField = NSTextField.alloc().initWithFrame(NSMakeRect(0, viewHeight - 95, 70, 20));\n form.maxWidthTextField = NSTextField.alloc().initWithFrame(NSMakeRect(90, viewHeight - 225, 70, 20));\n\n // Create radiobuttons\n form.rowsRadioButton = createRadioButton('Rows →', NSMakeRect(0, viewHeight - 160, 90, 20));\n form.columnsRadioButton = createRadioButton('Columns ↓', NSMakeRect(80, viewHeight - 160, 90, 20));\n\n // Create checkbox\n form.hasWidthLimitCheckbox = createCheckbox('On', NSMakeRect(0, viewHeight - 225, 90, 20));\n\n // --------------------------------------------------------------------------\n\n // Set initial input values and enabled states\n form.spacingTextField.setStringValue(String(options.padding));\n form.maxWidthTextField.setStringValue(String(options.maxWidth));\n\n if (options.hasWidthLimit) {\n form.hasWidthLimitCheckbox.setState(NSOnState);\n } else {\n form.maxWidthTextField.setEnabled(false);\n }\n\n if (options.isRowLayout) {\n form.rowsRadioButton.setState(NSOnState);\n } else {\n form.columnsRadioButton.setState(NSOnState);\n form.hasWidthLimitCheckbox.setEnabled(false);\n form.maxWidthTextField.setEnabled(false);\n }\n\n // --------------------------------------------------------------------------\n\n // Handle Enable / Disable Events\n form.hasWidthLimitCheckbox.setCOSJSTargetFunction((sender) => {\n form.maxWidthTextField.setEnabled(sender.state() === NSOnState);\n });\n\n let radioTargetFunction = (sender) => {\n let isRowLayout = (sender === form.rowsRadioButton);\n let hasWidthLimit = (form.hasWidthLimitCheckbox.state() === NSOnState);\n if (isRowLayout) {\n form.hasWidthLimitCheckbox.setEnabled(true);\n form.maxWidthTextField.setEnabled(hasWidthLimit);\n } else {\n form.hasWidthLimitCheckbox.setEnabled(false);\n form.maxWidthTextField.setEnabled(false);\n }\n };\n\n form.rowsRadioButton.setCOSJSTargetFunction(sender => radioTargetFunction(sender));\n form.columnsRadioButton.setCOSJSTargetFunction(sender => radioTargetFunction(sender));\n\n // --------------------------------------------------------------------------\n\n // Add inputs to view\n view.addSubview(infoLabel);\n view.addSubview(spacingLabel);\n view.addSubview(layoutLabel);\n view.addSubview(maxWidthLabel);\n view.addSubview(form.spacingTextField);\n view.addSubview(form.maxWidthTextField);\n view.addSubview(form.rowsRadioButton);\n view.addSubview(form.columnsRadioButton);\n view.addSubview(form.hasWidthLimitCheckbox);\n\n // --------------------------------------------------------------------------\n\n // Show the dialog window\n return dialog;\n}\n\nfunction createTextField(stringValue, frame) {\n let textField = NSTextField.alloc().initWithFrame(frame);\n textField.setStringValue(stringValue);\n textField.setSelectable(false);\n textField.setEditable(false);\n textField.setBezeled(false);\n textField.setDrawsBackground(false);\n return textField;\n}\n\nfunction createCheckbox(title, frame) {\n let checkbox = NSButton.alloc().initWithFrame(frame);\n checkbox.setButtonType(NSSwitchButton);\n checkbox.setBezelStyle(0);\n checkbox.setTitle(title);\n\n return checkbox;\n}\n\nfunction createRadioButton(title, frame) {\n let radioButton = NSButton.alloc().initWithFrame(frame);\n radioButton.setButtonType(NSRadioButton);\n radioButton.setTitle(title);\n\n return radioButton;\n}\n","module.exports = require(\"sketch/dom\");","module.exports = require(\"sketch/settings\");","module.exports = require(\"sketch/ui\");"],"sourceRoot":""} \ No newline at end of file