-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmodule.js
115 lines (105 loc) · 3.56 KB
/
module.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* JavaScript library for the hotpot module.
*
* @package mod-hotpot
* @copyright 2010 Gordon Bateson <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
M.mod_hotpot = M.mod_hotpot || {};
M.mod_hotpot.fix_targets = {
/**
* prevent
*/
prevent: function() {
alert('fix targets');
}
}
M.mod_hotpot.secure_window = {
/**
* init
*
* @param xxx Y
*/
init: function(Y) {
if (window.location.href.substring(0,4) == 'file') {
window.location = 'about:blank';
}
Y.delegate('contextmenu', M.mod_hotpot.secure_window.prevent, document.body, '*');
Y.delegate('mousedown', M.mod_hotpot.secure_window.prevent_mouse, document.body, '*');
Y.delegate('mouseup', M.mod_hotpot.secure_window.prevent_mouse, document.body, '*');
Y.delegate('dragstart', M.mod_hotpot.secure_window.prevent, document.body, '*');
Y.delegate('selectstart', M.mod_hotpot.secure_window.prevent, document.body, '*');
M.mod_hotpot.secure_window.clear_status;
Y.on('beforeprint', function() {
Y.one(document.body).setStyle('display', 'none');
}, window);
Y.on('afterprint', function() {
Y.one(document.body).setStyle('display', 'block');
}, window);
Y.on('key', M.mod_hotpot.secure_window.prevent, '*', 'press:67,86,88+ctrl');
Y.on('key', M.mod_hotpot.secure_window.prevent, '*', 'up:67,86,88+ctrl');
Y.on('key', M.mod_hotpot.secure_window.prevent, '*', 'down:67,86,88+ctrl');
Y.on('key', M.mod_hotpot.secure_window.prevent, '*', 'press:67,86,88+meta');
Y.on('key', M.mod_hotpot.secure_window.prevent, '*', 'up:67,86,88+meta');
Y.on('key', M.mod_hotpot.secure_window.prevent, '*', 'down:67,86,88+meta');
},
/**
* clear_status
*/
clear_status: function() {
window.status = '';
setTimeout(M.mod_hotpot.secure_window.clear_status, 10);
},
/**
* prevent
*
* @param xxx e
*/
prevent: function(e) {
alert(M.str.hotpot.functiondisabledbysecuremode);
e.halt();
},
/**
* prevent_mouse
*
* @param xxx e
*/
prevent_mouse: function(e) {
if (e.button == 1 && /^(INPUT|TEXTAREA|BUTTON|SELECT|LABEL|A)$/i.test(e.target.get('tagName'))) {
// Left click on a button or similar. No worries.
return;
}
alert(M.str.hotpot.functiondisabledbysecuremode);
e.halt();
},
/**
* close
*
* @param xxx url
* @param xxx delay
*/
close: function(url, delay) {
setTimeout(function() {
if (window.opener) {
window.opener.document.location.reload();
window.close();
} else {
window.location.href = url;
}
}, delay*1000);
}
};