Skip to content

Commit 99fcc82

Browse files
committed
Added test project and source from the 1.1.3 App store package
1 parent 4f89c4a commit 99fcc82

File tree

13 files changed

+210
-0
lines changed

13 files changed

+210
-0
lines changed
134 Bytes
Loading
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
dojo.provide("FileDocumentViewer.widget.FileDocumentViewer");
2+
3+
mendix.dom.insertCss(mx.moduleUrl("FileDocumentViewer", "widget/styles/FileDocumentViewer.css"));
4+
5+
mendix.widget.declare("FileDocumentViewer.widget.FileDocumentViewer", {
6+
addons: [
7+
dijit._Templated,
8+
dijit._Contained,
9+
mendix.addon._Contextable
10+
],
11+
12+
inputargs: {
13+
title : "",
14+
width : 0,
15+
height : 0,
16+
txtenlarge : "",
17+
txtpopout : "",
18+
showheader : true
19+
},
20+
templatePath : mx.moduleUrl("FileDocumentViewer.widget", "templates/FileDocumentViewer.html"),
21+
22+
domNode : null,
23+
iframe : null,
24+
titleNode : null,
25+
eventEnlarge : null,
26+
eventPopout : null,
27+
filedoc : null,
28+
windowObj : null,
29+
30+
postCreate : function() {
31+
logger.debug(this.id + ".postCreate");
32+
33+
if (!this.showheader)
34+
dojo.style(this.toolbarNode, 'display', 'none');
35+
36+
this.windowObj = this.iframe.contentWindow;
37+
38+
dojo.html.set(this.titleNode, this.title);
39+
dojo.html.set(this.enlargeNode, this.txtenlarge);
40+
dojo.html.set(this.popoutNode, this.txtpopout);
41+
this.connect(this.enlargeNode, "onclick", dojo.hitch(this, this.eventEnlarge));
42+
this.connect(this.popoutNode, "onclick", dojo.hitch(this, this.eventPopout));
43+
44+
dojo.style(this.domNode, {
45+
'width': this.width == 0 ? 'auto' : this.width + 'px'
46+
});
47+
dojo.style(this.iframe, {
48+
'height': this.height == 0 ? 'auto' : this.height + 'px',
49+
'width' : '100%',
50+
'overflow': 'auto'
51+
});
52+
53+
this.actRendered();
54+
},
55+
56+
//received the context
57+
applyContext : function(context, callback){
58+
logger.debug(this.id + ".applyContext");
59+
if (context)
60+
mx.processor.getObject(context.getActiveGUID(), dojo.hitch(this, this.setContextObject));
61+
else {
62+
logger.warn(this.id + ".applyContext received empty context");
63+
this.windowObj.location.replace(mx.moduleUrl("FileDocumentViewer.widget", "styles/blank.html"));
64+
}
65+
callback && callback();
66+
},
67+
68+
setContextObject : function(filedoc) {
69+
this.filedoc = filedoc;
70+
this.loadIFrame();
71+
},
72+
73+
74+
getFileUrl : function() {
75+
if (this.filedoc == null || this.filedoc.getAttribute("FileID") == null)
76+
return mx.moduleUrl("FileDocumentViewer.widget", "styles/error.html");
77+
else
78+
return "file?target=window&fileID=" + this.filedoc.getAttribute('FileID');
79+
},
80+
81+
loadIFrame : function() {
82+
this.iframe.contentWindow.location.replace(this.getFileUrl());
83+
},
84+
85+
eventEnlarge : function() {
86+
dojo.style(this.iframe, {
87+
height: dojo.style(this.iframe, 'height') * 1.5
88+
});
89+
},
90+
91+
eventPopout : function() {
92+
window.open(this.getFileUrl());
93+
},
94+
95+
uninitialize : function() {
96+
running = false;
97+
}
98+
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<widget id="FileDocumentViewer.widget.FileDocumentViewer" needsEntityContext="true" xmlns="http://www.mendix.com/widget/1.0/">
3+
<name>File Document Viewer</name>
4+
<description>A File Document Viewer. Should be used in a FileDocument based dataview</description>
5+
<icon>R0lGODlhEgASAKIHAHd3d8zMzO7u7qqqqoiIiLu7u////////yH5BAEAAAcALAAAAAASABIAAANL
6+
eLrcHSXK4VgxOBdaz83YxTkf+I0WiA1EiyqlihGknAl0E8t5ahu4mk2wEcpOOlus57ENQMyYAGh4
7+
GgDJqRaII7AYrJZ4jP12OqwEADs=</icon>
8+
9+
<properties>
10+
<property key="title" type="translatableString" required="true">
11+
<caption>Title</caption>
12+
<category>Appearance</category>
13+
<description>The caption of the viewer.</description>
14+
</property>
15+
<property key="width" type="integer" defaultValue="0">
16+
<caption>Width</caption>
17+
<category>Appearance</category>
18+
<description>Width of the viewer in pixels. Use '0' for auto. The height will depend on the contents. </description>
19+
</property>
20+
<property key="height" type="integer" defaultValue="400">
21+
<caption>Height</caption>
22+
<category>Appearance</category>
23+
<description>Height of the viewer in pixels. Use '0' to determine the width automatically. This will use any remaining space.</description>
24+
</property>
25+
<property key="showheader" type="boolean" defaultValue="true">
26+
<caption>Show header</caption>
27+
<category>Appearance</category>
28+
<description>If true, a header including a 'pop out' and 'enlarge' button will be shown</description>
29+
</property>
30+
<property key="txtenlarge" type="translatableString" required="true">
31+
<caption>Enlarge caption</caption>
32+
<category>Appearance</category>
33+
<description>The tooltip of the enlarge button.</description>
34+
</property>
35+
<property key="txtpopout" type="translatableString" required="true">
36+
<caption>Popout caption</caption>
37+
<category>Appearance</category>
38+
<description>The tooltip of the popout (open in new window) button</description>
39+
</property>
40+
</properties>
41+
</widget>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.FileDocumentViewer {
2+
border: 1px solid #adadad;
3+
}
4+
5+
.FileDocumentViewer .toolbar {
6+
color: #2e2e2e;
7+
padding: 8px 8px;
8+
border-bottom: 1px solid #adadad;
9+
background-image: url(bg_title.gif);
10+
text-align : right;
11+
}
12+
13+
.FileDocumentViewer a {
14+
padding-left: 12px;
15+
padding-right: 8px;
16+
background-position: 0px 3px;
17+
background-repeat : no-repeat;
18+
text-decoration: none;
19+
}
20+
21+
.FileDocumentViewer .enlarge {
22+
background-image: url(enlarge.png);
23+
}
24+
25+
.FileDocumentViewer .popout {
26+
background-image: url(popout.png);
27+
}
28+
29+
.FileDocumentViewer h1 {
30+
font-size: 16px;
31+
font-weight: bold;
32+
float : left;
33+
margin-top : -2px;
34+
}
35+
36+
.FileDocumentViewer iframe {
37+
border : 0px solid black;
38+
background-color: transparent;
39+
}
261 Bytes
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<html>
2+
<head/>
3+
<body style="font-family:arial,helvetica,clean,sans-serif; font-size: 10px; margin-top: 30px; text-align: center;">
4+
<img src="../../../../ui/theme-default/images/loader.gif"/> Loading..
5+
</body>
6+
</html>
140 Bytes
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<html>
2+
<head>
3+
</head>
4+
<body style="font-family:arial,helvetica,clean,sans-serif; font-size: 10px; margin-top: 30px; text-align: center;">
5+
-- The requested document was not found --
6+
</body>
156 Bytes
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="FileDocumentViewer" dojoAttachPoint="domNode">
2+
<div class="toolbar" dojoAttachPoint="toolbarNode">
3+
<h1 dojoAttachPoint="titleNode"></h1>
4+
<a href="javascript:void 0" class="enlarge" dojoAttachPoint="enlargeNode">Enlarge</a>
5+
<a href="javascript:void 0" class="popout" dojoAttachPoint="popoutNode">Popout</a>
6+
</div>
7+
<iframe dojoAttachPoint="iframe" class="documentiframe" style="height: 0px">
8+
</iframe>
9+
</div>

0 commit comments

Comments
 (0)