forked from utom/sketch-measure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1. Sizes.sketchplugin
56 lines (45 loc) · 1.75 KB
/
1. Sizes.sketchplugin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// (ctrl cmd 1)
#import 'library/common.js'
#import 'library/sizes.js'
#import 'library/overlayer.js'
var layers = selection;
if([layers count] > 0){
var alert = createAlertBase(),
widthTypes = ['none', 'top', 'middle', 'bottom'],
widthIndex = getIndex(widthTypes, configs.remenberSizeWidth),
heightTypes = ['none', 'left', 'center', 'right'],
heightIndex = getIndex(heightTypes, configs.remenberSizeHeight);
[alert setMessageText: 'Measure Sizes']
[alert setInformativeText: 'Customize the Size Guide that will be created.']
[alert addTextLabelWithValue: 'Width:']
[alert addAccessoryView: createSelect(widthTypes, widthIndex)]
[alert addTextLabelWithValue: 'Height:']
[alert addAccessoryView: createSelect(heightTypes, heightIndex)]
[alert addAccessoryView: creatCheckbox({name: 'Add Overlayer', value: 'overlayer'}, configs.remenberSizeOverlayer)]
var responseCode = [alert runModal];
handleAlertResponse(alert, responseCode);
}
else {
alert("Make sure you've selected a symbol, or a layer that.");
}
function handleAlertResponse(alert, responseCode) {
if (responseCode == "1000") {
var values = {
width: valueAtIndex(alert, 1),
height: valueAtIndex(alert, 3)
}
setConfig('remenber-size-overlayer', false);
if( checkedAtIndex(alert, 4) ) {
Overlayer();
setConfig('remenber-size-overlayer', true);
}
if( /none|top|middle|bottom/.exec(values.width) ) {
if(values.width != 'none') SelectionSizes('width', values.width);
setConfig('remenber-size-width', values.width);
}
if( /none|left|center|right/.exec(values.height) ) {
if(values.height != 'none') SelectionSizes('height', values.height);
setConfig('remenber-size-height', values.height);
}
}
}