Skip to content
Permalink
Browse files

release 2.0

  • Loading branch information...
PavelLaptev committed Sep 14, 2016
1 parent 98d678c commit 5d4f5f55dd1ba3d0c14fb08f8a74dfdf8ca78411
@@ -7,6 +7,16 @@ var onRun = function(context) {

var flag = ( flag === false ) ? NSOffState : NSOnState;

var checkboxArtboards = NSButton.alloc().initWithFrame( NSMakeRect( 0, 0, 300, 18 ) );
checkboxArtboards.setButtonType( NSSwitchButton );
checkboxArtboards.setTitle( 'Artboards' );
checkboxArtboards.setState( true );

var checkboxShapes = NSButton.alloc().initWithFrame( NSMakeRect( 0, 0, 300, 18 ) );
checkboxShapes.setButtonType( NSSwitchButton );
checkboxShapes.setTitle( 'Artboards' );
checkboxShapes.setState( true );

var checkboxShapes = NSButton.alloc().initWithFrame( NSMakeRect( 0, 0, 300, 18 ) );
checkboxShapes.setButtonType( NSSwitchButton );
checkboxShapes.setTitle( 'Shapes' );
@@ -38,6 +48,7 @@ var onRun = function(context) {
checkboxSuffix.setState( false );

var userInput = COSAlertWindow.new();
userInput.addAccessoryView(checkboxArtboards);
userInput.addAccessoryView(checkboxGroups);
userInput.addAccessoryView(checkboxShapes);
userInput.addAccessoryView(checkboxSymbols);
@@ -73,6 +84,9 @@ var onRun = function(context) {

doc.currentPage().deselectAllLayers();

if ( checkboxArtboards.state() == true ) {
selectLayersOfType_inContainer("MSArtboardGroup");
}
if ( checkboxGroups.state() == true ) {
selectLayersOfType_inContainer("MSLayerGroup");
}
@@ -1,22 +1,30 @@
{
"name" : "Lazy exportable 🙈",
"version" : "1.0",
"description" : "For lazy designers who don't care.",
"authorEmail" : "graphics.dario@gmail.com",
"author" : "Laptev Pavel",
"commands" : [
{
"script" : "lazy-exportable.js",
"handler" : "onRun",
"shortcut" : "cmd ctrl e",
"name" : "Lazy exportable 🙈",
"identifier" : "Lazy-exportable"
}
],
"menu": {
"isRoot": true,
"items": [
"Lazy-exportable"
]
}
"name" : "Lazy exportable 🙈",
"version" : "1.0",
"description" : "For lazy designers who don't care.",
"authorEmail" : "graphics.dario@gmail.com",
"author" : "Laptev Pavel",
"commands" : [
{
"script" : "makeExportable.js",
"handler" : "onRun",
"shortcut" : "cmd ctrl e",
"name" : "make Exportable",
"identifier" : "makeExportable"
},
{
"script" : "removeExportable.js",
"handler" : "onRun",
"shortcut" : "cmd alt ctrl e",
"name" : "remove Exportable",
"identifier" : "removeExportable"
}
],
"menu" : {
"items" : [
"makeExportable",
"removeExportable"
],
"title" : "Lazy Exportable 🙈"
}
}
@@ -0,0 +1,137 @@
var onRun = function(context) {
var doc = context.document,
artboard = doc.currentPage().currentArtboard(),
page = doc.currentPage(),
artboards = page.artboards(),
selection = context.selection;

var flag = ( flag === false ) ? NSOffState : NSOnState;

var checkboxArtboards = NSButton.alloc().initWithFrame( NSMakeRect( 0, 0, 300, 18 ) );
checkboxArtboards.setButtonType( NSSwitchButton );
checkboxArtboards.setTitle( 'Artboards' );
checkboxArtboards.setState( true );

var checkboxShapes = NSButton.alloc().initWithFrame( NSMakeRect( 0, 0, 300, 18 ) );
checkboxShapes.setButtonType( NSSwitchButton );
checkboxShapes.setTitle( 'Artboards' );
checkboxShapes.setState( true );

var checkboxShapes = NSButton.alloc().initWithFrame( NSMakeRect( 0, 0, 300, 18 ) );
checkboxShapes.setButtonType( NSSwitchButton );
checkboxShapes.setTitle( 'Shapes' );
checkboxShapes.setState( true );

var checkboxGroups = NSButton.alloc().initWithFrame( NSMakeRect( 0, 0, 300, 18 ) );
checkboxGroups.setButtonType( NSSwitchButton );
checkboxGroups.setTitle( 'Groups' );
checkboxGroups.setState( true );

var checkboxSymbols = NSButton.alloc().initWithFrame( NSMakeRect( 0, 0, 300, 18 ) );
checkboxSymbols.setButtonType( NSSwitchButton );
checkboxSymbols.setTitle( 'Symbols' );
checkboxSymbols.setState( true );

var checkboxText = NSButton.alloc().initWithFrame( NSMakeRect( 0, 0, 300, 18 ) );
checkboxText.setButtonType( NSSwitchButton );
checkboxText.setTitle( 'Text' );
checkboxText.setState( false );

var checkboxBitmaps = NSButton.alloc().initWithFrame( NSMakeRect( 0, 0, 300, 18 ) );
checkboxBitmaps.setButtonType( NSSwitchButton );
checkboxBitmaps.setTitle( 'Bitmaps' );
checkboxBitmaps.setState( false );

var checkboxSuffix = NSButton.alloc().initWithFrame( NSMakeRect( 0, 0, 300, 18 ) );
checkboxSuffix.setButtonType( NSSwitchButton );
checkboxSuffix.setTitle( 'Suffix ^' );
checkboxSuffix.setState( false );

var userInput = COSAlertWindow.new();
userInput.addAccessoryView(checkboxArtboards);
userInput.addAccessoryView(checkboxGroups);
userInput.addAccessoryView(checkboxShapes);
userInput.addAccessoryView(checkboxSymbols);
userInput.addAccessoryView(checkboxText);
userInput.addAccessoryView(checkboxBitmaps);
userInput.addAccessoryView(checkboxSuffix);
userInput.setMessageText('Remove Exportable');
userInput.addTextLabelWithValue("Exportable by name:");
userInput.addTextFieldWithValue("");

userInput.addButtonWithTitle('Destroy!')
userInput.addButtonWithTitle('Not today')
var responseCode = userInput.runModal();


var selectLayersOfType_inContainer = function(layerType) {

var children = page.children(),
predicate = NSPredicate.predicateWithFormat("(className == %@)", layerType),
layers = children.filteredArrayUsingPredicate(predicate);

var loop = layers.objectEnumerator(), layer;
while (layer = loop.nextObject()) {
layer.select_byExpandingSelection(true, true);
layer.exportOptions().removeAllExportFormats();
}

log(layers.count() + " " + layerType + "s selected ")
}


if (responseCode == 1000){

doc.currentPage().deselectAllLayers();

if ( checkboxArtboards.state() == true ) {
selectLayersOfType_inContainer("MSArtboardGroup");
}
if ( checkboxGroups.state() == true ) {
selectLayersOfType_inContainer("MSLayerGroup");
}
if ( checkboxShapes.state() == true ) {
selectLayersOfType_inContainer("MSShapeGroup");
}
if ( checkboxSymbols.state() == true ) {
selectLayersOfType_inContainer("MSSymbolInstance");
}
if ( checkboxText.state() == true ) {
selectLayersOfType_inContainer("MSTextLayer");
}
if ( checkboxBitmaps.state() == true ) {
selectLayersOfType_inContainer("MSBitmapLayer");
} if ( checkboxSuffix.state() == true ) {

var layers = page.children();
var matchTimes = 0;

for ( var i = 0; i < layers.count(); i++ ) {
if ( layers[i].name().match( /\^+$/gi ) ) {
matchTimes++;
layers[i].select_byExpandingSelection(true, true);
layers[i].exportOptions().addExportFormat();
}
};
log(matchTimes);

} if (userInput.viewAtIndex(7).stringValue() != "") {
var layers = page.children();
var find = new RegExp( userInput.viewAtIndex(7).stringValue() );
var matchTimes = 0;

for ( var i = 0; i < layers.count(); i++ ) {
if ( layers[i].name().match( find ) ) {
matchTimes++;
layers[i].select_byExpandingSelection(true, true);
layers[i].exportOptions().addExportFormat();
}
};
log(matchTimes + " " + userInput.viewAtIndex(7).stringValue());
}
}

if (responseCode == 1001){
doc.showMessage('Right choise) Make it manualy)')
}
}
@@ -1,11 +1,11 @@
[![GitHub release](https://img.shields.io/badge/release-1.0-green.svg?maxAge=2592000)](https://github.com/PavelLaptev/Lazy-Exportable---sketch-plugin/releases)
[![GitHub release](https://img.shields.io/badge/release-2.0-orange.svg)](https://github.com/PavelLaptev/Lazy-Exportable---sketch-plugin/releases)

![Cover](https://dl.dropboxusercontent.com/s/saot0qre0x9rtys/cover.png?dl=0)
# Lazy exportable — Sketch plugin

**If you are lazy or you have no time to manually make the layers exportable for developers - this plugin is for you.**

![Dialog preview](https://dl.dropboxusercontent.com/s/ke3ixotufrm1b04/dialog.jpg?dl=0)
![Dialog preview](https://dl.dropboxusercontent.com/s/o2d4iv3bgmsitq1/windows.jpg?dl=0)

# How it works
### Lazy way

0 comments on commit 5d4f5f5

Please sign in to comment.
You can’t perform that action at this time.