-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds bookmarklet code and simple readme
- Loading branch information
1 parent
5a4156e
commit 87ad0da
Showing
2 changed files
with
62 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
javascript:(function($) { | ||
|
||
var jqui = $.getScript('//code.jquery.com/ui/1.10.3/jquery-ui.js', function() { | ||
var ms = $('<div></div>'); | ||
ms.css({ | ||
backgroundColor: 'orange', | ||
height: '10px', | ||
left: '20px', | ||
position: 'absolute', | ||
top: '20px', | ||
width: '10px', | ||
zIndex: '999999' | ||
}).appendTo('body').draggable({ grid: [ 20, 20 ] }); | ||
|
||
$(document).keydown(function(e) { | ||
var step = e.shiftKey ? 10 : 1; | ||
|
||
switch (e.keyCode) { | ||
case 37: /* left */ | ||
if (e.altKey) { | ||
ms.width(ms.width() - step); | ||
} else { | ||
ms.css('left', (parseInt(ms.offset().left, 10) - step) + 'px'); | ||
} | ||
break; | ||
case 38: /* up */ | ||
if (e.altKey) { | ||
ms.height(ms.height() - step); | ||
} else { | ||
ms.css('top', (parseInt(ms.offset().top, 10) - step) + 'px'); | ||
} | ||
break; | ||
case 39: /* right */ | ||
if (e.altKey) { | ||
ms.width(ms.width() + step); | ||
} else { | ||
ms.css('left', (parseInt(ms.offset().left, 10) + step) + 'px'); | ||
} | ||
break; | ||
case 40: /* down */ | ||
if (e.altKey) { | ||
ms.height(ms.height() + step); | ||
} else { | ||
ms.css('top', (parseInt(ms.offset().top, 10) + step) + 'px'); | ||
} | ||
break; | ||
default: | ||
return true; | ||
} | ||
|
||
return false; | ||
}); | ||
}); | ||
|
||
}(jQuery)) |