Rank: Member
Groups: Member
Joined: 3/20/2007(UTC) Posts: 21
|
Hello Alex, here is main code for component. PETER Code:
<%@ page language="java" pageEncoding="UTF-8"%>
<jsp:directive.page import="cz.anect.mis.ApplicationConfig;" />
<%@ include file="/includes.jsp" %>
<fmt:setLocale value="cs"/>
<script type="text/javascript">
var prevUploadFileCount = 0;
/*
Callback function which is called when upload finished successfully.
*/
function ImageUploaderID_AfterUpload(html) {
var pos = html.lastIndexOf("##");
if (pos == -1) {
alert(html); //show result information
}
else {
//get doc ids
var docIds = html.substring(2, pos); //2 is length of '##'
alert(html.substr(pos + 2));
//open new window for displaying added documents
openNewWindowWithParams("<%=ApplicationConfig.getCentralPartUrl()%>displayAddedDocuments.htm",
"ids", docIds);
}
if (elm('exactCreationDate').value == '') {
elm('exactCreationDate').value = 'DD.MM.RRRR';
}
}
/*
Callback function which is called during uploading.
*/
function ImageUploader_Progress(Status, Progress, ValueMax, Value, StatusText) {
//4 - Some server-side error occurred
//11 - The server returned HTTP code 3xx (e.g. 302 or 304) during redirection.
if (Status == "ERROR" && (Value == 11 || Value == 4)) {
//error from server side
if (StatusText == "") {
alert('<fmt:message key="errorOccured.js"/>');
}
else {
var pos = StatusText.indexOf('http');
if (pos != 0) {
alert('<fmt:message key="followingErrorOccured"/>:\n' + StatusText);
}
else {
//redirect to other page
window.location = StatusText;
}
}
if (elm('exactCreationDate').value == '') {
elm('exactCreationDate').value = 'DD.MM.RRRR';
}
}
}
/*
Method is invoked when an image is selected.
Selected image is displayed in thumbnail pane.
*/
function ImageUploader_SelectionChange() {
var imageUploader = getImageUploader("ImageUploaderID");
var thumbnail = getImageUploader("ImageThumbnailID");
if (imageUploader) {
var selectedFileIndex = null;
//Iterate all upload list items
for (var i = 1; i <= imageUploader.getUploadFileCount(); i++){
if (imageUploader.getUploadFileSelected(i)) {
//only one image can be thumbnail
if (selectedFileIndex == null){
selectedFileIndex = i;
}
else {
selectedFileIndex = "multiple"
}
}
}
}
if (selectedFileIndex){
//Display selected image preview using <img> tag when only one item is selected.
// For multiple items blank area is displayed.
if (typeof(selectedFileIndex) == "number") {
thumbnail.setGuid(imageUploader.getUploadFileGuid(selectedFileIndex));
}
else {
thumbnail.setGuid("");
}
}
else {
thumbnail.setGuid("");
}
}
/*
* Method is invoked when count of selected files is changed.
*/
function ImageUploader_UploadFileCountChange() {
var imageUploader = getImageUploader("ImageUploaderID");
var thumbnail = getImageUploader("ImageThumbnailID");
if (imageUploader){
var uploadFileCount = imageUploader.getUploadFileCount();
//Files are being added.
if (prevUploadFileCount <= uploadFileCount) {
//nothing to do at this moment
}
//Files are being removed.
else {
if (uploadFileCount == 0) {
//clear thumbnail pane
thumbnail.setGuid("");
}
else {
//select last selected document
thumbnail.setGuid(imageUploader.getUploadFileGuid(uploadFileCount));
}
}
prevUploadFileCount = uploadFileCount;
}
}
//
// component configuration
//
var iu = new ImageUploaderWriter("ImageUploaderID", 900, 390);
// If you do not want to use ActiveX or Java version, set the appropriate
// property to false.
iu.activeXControlEnabled = true;
iu.javaAppletEnabled = true;
iu.activeXControlVersion = "4,5,35,0";
iu.javaAppletVersion = "2.5.35.0";
iu.javaAppletCached = true;
iu.activeXControlCodeBase = "includes/ImageUploader4.cab";
iu.javaAppletCodeBase="includes/";
//component configuration
iu.addParam("Action", "addDocument.htm"); //must be
iu.addParam("AutoRecoverTimeOut", "3000");
iu.addParam("AllowAutoRotate", "false");
iu.addParam("AllowRotate", "true");
iu.addParam("ShowDescriptions", "false");
iu.addParam("MaxFileCount", "20");
iu.addParam("MaxFileSize", "51200000"); //=50MB
iu.addParam("MaxTotalFileSize", "102400000"); //=100MB
iu.addParam("ExtractExif", "ExifDateTime");
iu.addParam("FolderPaneSortMode", "Name");
iu.addParam("LicenseKey", "...");
//component apperiance
iu.addParam("BackgroundColor", "#e8d5c4");
iu.addParam("TreePaneWidth", "210");
iu.addParam("FolderPaneHeight", "200");
iu.addParam("PreviewThumbnailSize", "70"); //96 default
iu.addParam("AutoRecoverMaxTriesCount", "1");
//thumbnail info
iu.addParam("UploadThumbnail1FitMode", "Fit");
iu.addParam("UploadThumbnail1Width", "800");
iu.addParam("UploadThumbnail1Height", "600");
iu.addParam("UploadThumbnail1JpegQuality", "70");
iu.addParam("UploadThumbnail1ResizeQuality", "Medium");
//include data from form
iu.addParam("AdditionalFormName", "addDocument");
//Configure file mask to upload supported files only.
iu.addParam("FileMask", "*.doc;*.pdf;*.htm;*.html;*.jpg;*.jpeg;*.png;*.txt;*.rtf;*.tif;*.tiff");
//Czech localization
cs_resources.addParams(iu);
//formular checking
iu.addEventListener("SelectionChange", "ImageUploader_SelectionChange");
iu.addEventListener("BeforeUpload", "beforeUploadHandler");
iu.addEventListener("AfterUpload", "ImageUploaderID_AfterUpload");
iu.addEventListener("UploadFileCountChange", "ImageUploader_UploadFileCountChange");
iu.addEventListener("Progress", "ImageUploader_Progress");
iu.writeHtml();
</script>
<div style="border: 1px solid #E5CEBB; width: 900px; margin-bottom: 10px;">
<script type="text/javascript">
//===================== thumbnail pain
var t = new ThumbnailWriter("ImageThumbnailID", 900, 270);
t.activeXControlEnabled = iu.activeXControlEnabled;
t.javaAppletEnabled = iu.javaAppletEnabled;
t.activeXControlVersion = iu.activeXControlVersion;
t.javaAppletVersion = iu.javaAppletVersion;
t.javaAppletCached = iu.javaAppletCached;
t.activeXControlCodeBase = iu.activeXControlCodeBase;
t.javaAppletCodeBase = iu.javaAppletCodeBase;
t.addParam("ParentControlName", "ImageUploaderID");
t.addParam("BackgroundColor", "#f7f0ea");
t.writeHtml();
</script>
</div>
Edited by user Sunday, February 24, 2008 6:08:55 PM(UTC)
| Reason: Not specified
|