-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.js
More file actions
61 lines (43 loc) · 1.13 KB
/
editor.js
File metadata and controls
61 lines (43 loc) · 1.13 KB
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
jQuery(function($) {
var refs = $('[data-ks-editable]');
function addButton($editable, href, label) {
$editable.css({ position: 'relative' });
var visible = false;
var $btn = $('<a class="ks-editable-btn" href="' + href + '" target="_blank">' + label + '</a>')
.css({
opacity: 0,
top: 0,
right: 0
})
.appendTo($editable);
$editable.on('mouseenter mousemove', function(e) {// eslint-disable-line no-unused-vars
if (visible) return;
visible = true;
$btn.css({ opacity: 1 });
}).on('mouseleave', function(e) {// eslint-disable-line no-unused-vars
visible = false;
$btn.css({ opacity: 0 });
});
}
refs.each(function(i, editable) {
var $editable = $(editable),
data = $editable.data('ks-editable');
switch (data.type) {
case 'list':
var href = '/keystone/' + data.path,
label = 'Manage ' + data.plural;
if (data.id) {
href += '/' + data.id;
label = 'Edit ' + data.singular;
}
addButton($editable, href, label);
break;
case 'content':
// TODO
break;
case 'error':
// TODO
break;
}
});
});