Skip to content

Commit

Permalink
Merge pull request #4 from chibatching/adapt_new_sketch_version
Browse files Browse the repository at this point in the history
Adapt new sketch version
  • Loading branch information
chibatching authored Aug 9, 2016
2 parents 1f9f62e + 655b012 commit f98ac06
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
17 changes: 9 additions & 8 deletions Contents/Sketch/manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"author" : "chibatching",
"identifier" : "com.chibatching.select_all_slices",
"version" : "2.1",
"description" : "Select all slices and exportables in current page.",
"authorEmail" : "[email protected]",
"name" : "Select all slices",
"homepage" : "https://github.com/chibatching/select_all_slices",
"commands" : [
{
"script" : "select_all_slices.cocoascript",
"script" : "select_all_slices.js",
"handler" : "onRun",
"shortcut" : "shift control s",
"name" : "Select all slices",
"identifier" : "slices"
},
{
"script" : "select_all_exportables.cocoascript",
"script" : "select_all_exportables.js",
"handler" : "onRun",
"shortcut" : "shift control e",
"name" : "Select all exportables",
Expand All @@ -22,10 +28,5 @@
"exportables"
],
"title" : "Select all slices"
},
"identifier" : "com.chibatching.select_all_slices",
"version" : "2.0",
"description" : "Select all slices and exportables in current page.",
"authorEmail" : "[email protected]",
"name" : "Select all slices"
}
}
12 changes: 0 additions & 12 deletions Contents/Sketch/select_all_exportables.cocoascript

This file was deleted.

14 changes: 14 additions & 0 deletions Contents/Sketch/select_all_exportables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var onRun = function(context) {
log('Select all exportable in current page.');

var doc = context.document
// Unselect everything
doc.currentPage().deselectAllLayers()

var exportables = doc.currentPage().exportableLayers()
for (var i = 0; i < exportables.length; i++) {
var exportable = exportables.objectAtIndex(i)
log(" " + exportable.name())
exportable.select_byExpandingSelection(true, true)
}
};
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
var onRun = function(context) {
log('Select all slice in page.');

var doc = context.document
// Unselect everything
[[doc currentPage] deselectAllLayers]
doc.currentPage().deselectAllLayers()

// Recursive execute through all layers:
selectSliceRecursive([doc currentPage])
selectSliceRecursive(doc.currentPage())
};

function selectSliceRecursive(layer) {
if (layer instanceof MSSliceLayer) {
[layer select:true byExpandingSelection:true]
log(" " + [layer name])
layer.select_byExpandingSelection(true, true)
log(" " + layer.name())
return
}
try {
var children = layer.layers()
for (var i = 0; i < [children length]; i++) {
for (var i = 0; i < children.length; i++) {
selectSliceRecursive(children.objectAtIndex(i))
}
} catch(e) {
Expand Down

0 comments on commit f98ac06

Please sign in to comment.