Skip to content

Instantly share code, notes, and snippets.

@ivey
Created October 15, 2013 01:31
Show Gist options
  • Save ivey/6985209 to your computer and use it in GitHub Desktop.
Save ivey/6985209 to your computer and use it in GitHub Desktop.
flexiglass-style bindings for slate (https://github.com/jigish/slate)
// other window
slate.bind('p:ctrl,cmd,alt', function(win) {
var current = slate.screen().id();
var count = slate.screenCount() - 1;
var target = current + 1;
if (target > count) {
target = 0;
}
win.doOperation(slate.operation("throw", {
"screen": target,
"x" : "screenOriginX + (screenSizeX*0.1)",
"y" : "screenOriginY + (screenSizeY*0.1)",
"width" : "screenSizeX*0.8",
"height" : "screenSizeY*0.8"
}))
});
// fullscreen and center
slate.bindAll({
'f:ctrl,alt,cmd': slate.operation("move", {
"x" : "screenOriginX",
"y" : "screenOriginY",
"width" : "screenSizeX",
"height" : "screenSizeY"
}),
'c:ctrl,alt,cmd': slate.operation("move", {
"x" : "screenOriginX + (screenSizeX*0.1)",
"y" : "screenOriginY + (screenSizeY*0.1)",
"width" : "screenSizeX*0.8",
"height" : "screenSizeY*0.8"
})
})
// 4 corners
var cornerTopLeft = slate.operation("corner", {
"direction" : "top-left",
"width" : "screenSizeX/2",
"height" : "screenSizeY/2"
});
var cornerTopRight = cornerTopLeft.dup({ "direction" : "top-right" });
var cornerBotLeft = cornerTopLeft.dup({ "direction" : "bottom-left" });
var cornerBotRight = cornerTopLeft.dup({ "direction" : "bottom-right" });
slate.bind("i:ctrl,alt,cmd", cornerTopLeft);
slate.bind("o:ctrl,alt,cmd", cornerTopRight);
slate.bind("k:ctrl,alt,cmd", cornerBotLeft);
slate.bind("l:ctrl,alt,cmd", cornerBotRight);
// top left right bottom
var pushUp = slate.operation("push", {
"direction" : "up",
"style" : "bar-resize:screenSizeY/2"
});
var pushDown = pushUp.dup({"direction" : "down"});
var pushRight = pushUp.dup({"direction" : "right", "style" : "bar-resize:screenSizeX/2"});
var pushLeft = pushRight.dup({"direction" : "left"});
slate.bind("up:ctrl,alt,cmd", pushUp);
slate.bind("down:ctrl,alt,cmd", pushDown);
slate.bind("right:ctrl,alt,cmd", pushRight);
slate.bind("left:ctrl,alt,cmd", pushLeft);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment