forked from alice0775/userChrome.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontextMenuImageRotate.uc.js
81 lines (72 loc) · 3 KB
/
contextMenuImageRotate.uc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// ==UserScript==
// @name contextMenuImageRotate.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description imageを回転
// @include main
// @compatibility Firefox 9+
// @author Alice0775
// @version 2013/02/04 moji
// @version 2012/12/08
// @Note Required Sub-Script/Overlay Loader v3.0.38mod( https://github.com/alice0775/userChrome.js/blob/master/userChrome.js )
// ==/UserScript==
var contextMenuImageRotate = {
init: function() {
var overlay = ' \
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" \
xmlns:html="http://www.w3.org/1999/xhtml"> \
<menupopup id="contentAreaContextMenu"> \
<menu id="contextMenuImageRotateMenu" \
insertbefore="context-sep-copyimage" \
label="Rotate Image" \
onclick="if(event.button != 0) {contextMenuImageRotate.doRotate(gContextMenu.target, \'\');this.parentNode.hidePopup();}"> \
<menupopup id="contextMenuImageRotatePopup" \
oncommand="contextMenuImageRotate.onCommand(event);" \
onclick="if(event.button != 0) {contextMenuImageRotate.doRotate(gContextMenu.target, \'\');this.parentNode.hidePopup();}"> \
<menuitem label=" 0deg" value="rotate(0deg)" /> \
<menuitem label=" 90deg" value="rotate(90deg)" /> \
<menuitem label="180deg" value="rotate(180deg)" /> \
<menuitem label="270deg" value="rotate(270deg)" /> \
<menuitem label="Reset" value="" /> \
</menupopup> \
</menu> \
</menupopup> \
</overlay>';
overlay = "data:application/vnd.mozilla.xul+xml;charset=utf-8," + encodeURI(overlay);
window.userChrome_js.loadOverlay(overlay, contextMenuImageRotate);
},
observe: function(){
document.getElementById("contentAreaContextMenu").addEventListener("popupshowing", this, false);
window.addEventListener("unload", this, false);
},
uninit: function() {
document.getElementById("contentAreaContextMenu").removeEventListener("popupshowing", this, false);
window.removeEventListener("unload", this, false);
},
onCommand: function(event) {
this.doRotate(gContextMenu.target, event.target.value);
},
doRotate: function(target, value) {
if (value !="") {
target.style.setProperty("-moz-transform", value, "important");
target.style.setProperty("transform", value, "important");
} else {
target.style.removeProperty("-moz-transform");
target.style.removeProperty("transform");
}
},
onPopupshowing: function(event) {
var menu = document.getElementById("contextMenuImageRotateMenu");
menu.hidden = !gContextMenu.onImage;
},
handleEvent: function(event) {
switch(event.type) {
case 'popupshowing':
this.onPopupshowing(event);
break;
case 'unload':
this.uninit();
break;
}
}
};
contextMenuImageRotate.init();