forked from SolidOS/solid-panes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimagePane.js
More file actions
58 lines (48 loc) · 1.73 KB
/
imagePane.js
File metadata and controls
58 lines (48 loc) · 1.73 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
/* Image Pane
**
** This outline pane contains the document contents for an Image document
*/
var UI = require('solid-ui')
module.exports ={
icon: UI.icons.originalIconBase + 'tango/22-image-x-generic.png',
name: 'image',
label: function(subject) {
var kb = UI.store;
var ns = UI.ns;
if (!kb.anyStatementMatching(
subject, UI.ns.rdf( 'type'),
kb.sym('http://purl.org/dc/terms/Image'))) // NB: Not dc: namespace!
return null;
// See aslo the source pane, which has lower precedence.
var contentTypeMatch = function(kb, x, contentTypes) {
var cts = kb.fetcher.getHeader(x, 'content-type');
if (cts) {
for (var j=0; j<cts.length; j++) {
for (var k=0; k < contentTypes.length; k++) {
if (cts[j].indexOf(contentTypes[k]) >= 0) {
return true;
}
}
}
}
return false;
};
var suppressed = [ 'application/pdf'];
if (contentTypeMatch(kb, subject, suppressed)) return null;
return "view";
},
render: function(subject, myDocument) {
var div = myDocument.createElement("div")
div.setAttribute('class', 'imageView')
var img = myDocument.createElement("IMG")
img.setAttribute('src', subject.uri) // w640 h480
img.setAttribute('style','max-width: 100%; max-height: 100%;')
// div.style['max-width'] = '640';
// div.style['max-height'] = '480';
var tr = myDocument.createElement('TR') // why need tr?
tr.appendChild(img)
div.appendChild(tr)
return div
}
}
//ends