-
Notifications
You must be signed in to change notification settings - Fork 576
/
Copy pathck_browse.html
100 lines (95 loc) · 2.52 KB
/
ck_browse.html
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
{{include "jquery.html"}}
{{from gluon import current,URL}}
<style type="text/css">
div.item {
display: inline-block;
min-width: 104px;
height: 126px;
border: 1px solid gray;
-moz-border-radius: 3px;
border-radius: 3px;
padding: 2px;
margin: 3px;
text-align: center;
cursor: pointer;
overflow: hidden;
}
div.item:hover {
background: #eeeed5;
}
div.item span.delete {
background: white;
float: right;
padding: 2px;
border: 1px solid gray;
-moz-border-radius: 3px;
border-radius: 3px;
margin: -3px;
margin-bottom: 2px;
font-weight: bold;
}
div.item span.delete:hover {
background: #FF7374;
color: white;
}
img {
max-width: 100px;
max-height: 100px;
border: 1px solid gray;
}
</style>
{{
def icon_url(category):
url = URL("static", "img")
if category == "video":
return url + "/file/video.png"
elif category == "audio":
return url + "/file/audio.png"
elif category == "pdf":
return url + "/file/pdf.png"
elif category == "word":
return url + "/file/doc.png"
elif category == "archive":
return url + "/file/zip.png"
elif category == "excel":
return url + "/file/xls.png"
elif category == "powerpoint":
return url + "/file/ppt.png"
else:
return url + "/file/paperclip.png"
pass
}}
<h3>Uploads</h3>
{{for row in rows:}}
<div class="item" data-url="{{=row.upload}}">
<span class="delete"> x </span>
{{category = current.s3db.doc_filetype(row.filename)}}
{{url = URL("default", "download", args=[row.upload])}}
{{if category != "image":}}
{{url = icon_url(category)}}
{{pass}}
<img src="{{=url}}" />
<div>{{=row.title}}</div>
</div>
{{pass}}
{{if len(rows) == 0:}}
<span>There is nothing here. Please upload something first.</span>
{{pass}}
<script type="text/javascript">
jQuery(function() {
jQuery('.delete').click(function() {
if (confirm('Are you sure you want to delete this item? This cannot be undone and will cause any references to this item to fail.')) {
var url = '{{=URL("doc", "ck_delete")}}/' + jQuery(jQuery(this).parent()).data('url');
jQuery.post(url, function() {
window.location.reload(true);
});
}
return false;
});
jQuery('.item').click(function() {
var url = '{{=URL("default", "download")}}/' + jQuery(this).data('url');
window.opener.CKEDITOR.tools.callFunction({{=ckfuncnum}}, url);
window.close();
});
});
</script>