-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from weixin/order
Order
- Loading branch information
Showing
33 changed files
with
160 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,5 +217,9 @@ | |
}, | ||
"fontCharacters":{ | ||
"m1":"请先选择要添加字符的文字" | ||
}, | ||
"orderLayers":{ | ||
"m1":"排序成功", | ||
"m2":"请选中要排序的元素" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-744 Bytes
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/Order-enUS.png
Binary file not shown.
Binary file removed
BIN
-1.5 KB
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/[email protected]
Binary file not shown.
Binary file modified
BIN
-44 Bytes
(96%)
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/cut-zhCN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-109 Bytes
(96%)
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-32 Bytes
(97%)
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/fontCharacters-enUS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-45 Bytes
(98%)
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-11 Bytes
(99%)
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/fontCharacters-zhCN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+172 Bytes
(110%)
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-11 Bytes
(99%)
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/fontCharacters-zhtw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+172 Bytes
(110%)
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-984 Bytes
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/order-zhCN.png
Binary file not shown.
Binary file removed
BIN
-2.07 KB
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/[email protected]
Binary file not shown.
Binary file removed
BIN
-997 Bytes
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/order-zhtw.png
Binary file not shown.
Binary file removed
BIN
-2.06 KB
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/[email protected]
Binary file not shown.
Binary file added
BIN
+886 Bytes
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/sorting-enUS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+981 Bytes
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/sorting-zhCN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.22 KB
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+988 Bytes
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/sorting-zhTW.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.23 KB
WeSketch.sketchplugin/Contents/Sketch/library/toolbar/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
@import "common.js" | ||
|
||
function sortingLayers(context){ | ||
var i18 = _(context).orderLayers; | ||
|
||
var by = function(name,minor){ | ||
return function(o,p){ | ||
var a,b; | ||
if(o && p && typeof o === 'object' && typeof p ==='object'){ | ||
a = o[name]; | ||
b = p[name]; | ||
if(a === b){ | ||
return typeof minor === 'function' ? minor(o,p):0; | ||
} | ||
if(typeof a === typeof b){ | ||
return a < b ? -1:1; | ||
} | ||
return typeof a < typeof b ? -1 : 1; | ||
}else{ | ||
thro("error"); | ||
} | ||
} | ||
} | ||
|
||
var selection = context.selection; | ||
if(selection.length == 0){ | ||
return NSApp.displayDialog(i18.m2); | ||
} | ||
var artboard = selection[0].parentArtboard(); | ||
var length = selection.length; | ||
var order = {}; | ||
|
||
for(var i = 0;i<length;i++){ | ||
var x = selection[i].absoluteRect().x(); | ||
var y = selection[i].absoluteRect().y(); | ||
var width = selection[i].rect().size.width; | ||
var height = selection[i].rect().size.height; | ||
var name = selection[i].name(); | ||
|
||
var obj = order[width + '_' + height]; | ||
if(!obj){ | ||
order[width + '_' + height] = []; | ||
obj = order[width + '_' + height]; | ||
} | ||
|
||
var object = {}; | ||
object.x = x; | ||
object.y = y; | ||
object.width = width; | ||
object.height = height; | ||
object.name = selection[i].name(); | ||
object.selection = selection[i]; | ||
obj.push(object); | ||
} | ||
for(var i in order){ | ||
order[i].sort(by('y',by('x'))); | ||
var layer = order[i][order[i].length-1].selection.copy(); | ||
for(var k = 0;k < order[i].length;k++){ | ||
if(k == 0){ | ||
artboard.addLayers([layer]); | ||
layer.moveToLayer_beforeLayer(artboard,order[i][k].selection); | ||
order[i][k].selection.moveToLayer_beforeLayer(artboard,layer); | ||
}else{ | ||
order[i][k].selection.moveToLayer_beforeLayer(artboard,order[i][k-1].selection); | ||
} | ||
order[i][k].selection.setName(order[i][0].name + (k+1)); | ||
if(k == order[i].length - 1){ | ||
layer.removeFromParent(); | ||
} | ||
} | ||
} | ||
context.document.showMessage(i18.m1); | ||
} | ||
|
||
var onRun = function(context) { | ||
sortingLayers(context); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters