Browse Source

imported fixed upload version (by Arthur) from rop

svn changeset:182/svn branch:toolkit
tags/6.7.0.beta1
Matti Tahvonen 17 years ago
parent
commit
57b7729163
2 changed files with 34 additions and 23 deletions
  1. 9
    2
      WebContent/themes/default/theme.css
  2. 25
    21
      WebContent/themes/default/theme.js

+ 9
- 2
WebContent/themes/default/theme.css View File

} }
.table .actions .over { .table .actions .over {
background-color: Highlight; background-color: Highlight;
}
}
.upload-iframe {
width: 450px;
height: 30px;
border: none;
margin: 0px;
padding: 0px;
background: transparent;
}

+ 25
- 21
WebContent/themes/default/theme.js View File

// Unique name for iframes // Unique name for iframes
var frameName = "upload_"+varNode.getAttribute("id")+"_iframe"; var frameName = "upload_"+varNode.getAttribute("id")+"_iframe";
var iframe = theme.createElementTo(div, "iframe");
iframe.style.width = '300px';
iframe.style.height = '30px';
var iframe = theme.createElementTo(div, "iframe","upload-iframe");
iframe.id = frameName; iframe.id = frameName;
iframe.name = frameName; iframe.name = frameName;
iframe.src = 'about:blank'; iframe.src = 'about:blank';
iframe.style.border = 'none';
iframe.style.margin = '0px';
iframe.style.padding = '0px';
iframe.style.background = 'none';
// Get the window object of the iframe // Get the window object of the iframe
var ifr = window.frames[frameName]; var ifr = window.frames[frameName];
if (ifr != null) { if (ifr != null) {
// TODO: Put some initial content to IFRAME.
// Put some initial content to IFRAME.
// Nasty, but without this the browsers fail // Nasty, but without this the browsers fail
// to create any elements into window. // to create any elements into window.
var code="<HTML>"+"<BODY STYLE=\" overflow: hidden; border: none; margin: 0px; padding: 0px;\"><\/BODY><\/HTML>";
// TODO import CSS file to get right background-color for IE
var code="<HTML><BODY STYLE=\" overflow: hidden; border: none; margin: 0px; padding: 0px;background-color: transparent;\"><\/BODY><\/HTML>";
ifr.document.open(); ifr.document.open();
ifr.document.write(code); ifr.document.write(code);
ifr.document.close(); ifr.document.close();
upload.name = varNode.getAttribute("id"); upload.name = varNode.getAttribute("id");
var submit = theme.createInputElementTo(form, "submit"); var submit = theme.createInputElementTo(form, "submit");
submit.value = "Send"; submit.value = "Send";
// submit.value = caption
submit.disabled = true;
submit.onclick = function() {
iframe.style.visibility='hidden';
}
upload.onchange = function() {
if(upload.value) {
submit.disabled = false;
} else {
submit.disabled = true;
}
}
ifr.document.body.appendChild(form); ifr.document.body.appendChild(form);
// Attach event listeners for processing the chencges after upload. // Attach event listeners for processing the chencges after upload.
if (document.all) { if (document.all) {
iframe.onreadystatechange = function() { iframe.onreadystatechange = function() {
if (iframe.readyState == "complete") { if (iframe.readyState == "complete") {
//TODO: Is there a better way? Cannot figure out a
// way to take the changes out of iframes document in IE.
// FF seems to be working, but IE just renders the
// XML as highlight HTML and looses the original XML.
//div.ownerDocument.location.reload();
div.ownerDocument.location.href = div.ownerDocument.location.href;
iframe.onreadystatechange = null;
client.processVariableChanges(true);
// FIXME next line is workaround to 'iframe is not instantly updated after upload is done' bug.
// location.reload();
} }
}; };
} else { } else {
iframe.onload = function() { iframe.onload = function() {
if (ifr.document != null && (ifr.document.contentType == "application/xml")) { if (ifr.document != null && (ifr.document.contentType == "application/xml")) {
// TODO: Damn. This would be nice but seems to be unreliable:
//client.processUpdates(ifr.document);
//div.ownerDocument.location.reload();
div.ownerDocument.location.href = div.ownerDocument.location.href;
iframe.onload = null;
client.processVariableChanges(true);
// FIXME next line is workaround to 'iframe is not instantly updated after upload is done' bug.
// location.reload();
} }
}; };
} }

Loading…
Cancel
Save