2
if (!this.support.loading) {
3
alert("You need the Flash Player 9.028 or above to use SWFUpload.");
7
function loadFailed() {
8
alert("Something went wrong while loading SWFUpload. If this were a real application we'd clean up and then give you an alternative");
11
function fileQueueError(file, errorCode, message) {
13
var imageName = "error.gif";
15
if (errorCode === SWFUpload.errorCode_QUEUE_LIMIT_EXCEEDED) {
16
errorName = "You have attempted to queue too many files.";
19
if (errorName !== "") {
25
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
26
imageName = "zerobyte.gif";
28
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
29
imageName = "toobig.gif";
31
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
32
case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
38
addImage("themes/core/javascript/swfupload/" + imageName);
46
function fileDialogComplete(numFilesSelected, numFilesQueued) {
48
if (numFilesQueued > 0) {
49
this.startResizedUpload(this.getFile(0).ID, this.customSettings.picture_width, this.customSettings.picture_height, SWFUpload.RESIZE_ENCODING.JPEG, this.customSettings.picture_quality, false);
57
function uploadProgress(file, bytesLoaded) {
60
var percent = Math.ceil((bytesLoaded / file.size) * 100);
62
var progress = new FileProgress(file, this.customSettings.upload_target);
63
progress.setProgress(percent);
64
progress.setStatus("Uploading...");
65
progress.toggleCancel(true, this);
71
function uploadSuccess(file, serverData) {
74
document.getElementById("image_small").value = file.name;
75
var progress = new FileProgress(file, this.customSettings.upload_target);
77
if( file.name != '' ) {
78
addImg( this.customSettings.uploadpath + "/temps/" + file.name );
80
addImg(this.customSettings.uploadpath + "/logo_none.jpg");
83
if (serverData.substring(0, 7) === "FILEID:") {
84
//addImage("uploads/thumbnail.php?id=" + serverData.substring(7));
85
progress.setStatus("Upload Complete.");
86
progress.toggleCancel(false);
89
//addImage("themes/core/javascript/swfupload/error.gif");
90
progress.setStatus("Error.");
91
progress.toggleCancel(false);
100
function uploadComplete(file) {
102
/* I want the next upload to continue automatically so I'll call startUpload here */
103
if (this.getStats().files_queued > 0) {
104
this.startResizedUpload(this.getFile(0).ID, this.customSettings.picture_width, this.customSettings.picture_height, SWFUpload.RESIZE_ENCODING.JPEG, this.customSettings.picture_quality, false);
105
//this.startUpload();
107
var progress = new FileProgress(file, this.customSettings.upload_target);
108
progress.setComplete();
109
progress.setStatus("All images received.");
110
progress.toggleCancel(false);
117
function uploadError(file, errorCode, message) {
118
var imageName = "error.gif";
122
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
124
progress = new FileProgress(file, this.customSettings.upload_target);
125
progress.setCancelled();
126
progress.setStatus("Cancelled");
127
progress.toggleCancel(false);
133
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
135
progress = new FileProgress(file, this.customSettings.upload_target);
136
progress.setCancelled();
137
progress.setStatus("Stopped");
138
progress.toggleCancel(true);
143
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
144
imageName = "uploadlimit.gif";
151
addImage("themes/core/javascript/swfupload/" + imageName);
159
function addImg(src) {
160
var newImg = document.getElementById("previewlogo");
164
function addImage(src) {
165
var newImg = document.createElement("img");
166
newImg.style.margin = "0";
167
newImg.style.verticalAlign = "middle";
169
var divThumbs = document.getElementById("thumbnails");
170
divThumbs.insertBefore(newImg, divThumbs.firstChild);
171
//document.getElementById("thumbnails").appendChild(newImg);
172
if (newImg.filters) {
174
newImg.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 0;
176
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
177
newImg.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + 0 + ')';
180
newImg.style.opacity = 0;
183
newImg.onload = function () {
189
function fadeIn(element, opacity) {
190
var reduceOpacityBy = 5;
191
var rate = 30; // 15 fps
195
opacity += reduceOpacityBy;
200
if (element.filters) {
202
element.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
204
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
205
element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')';
208
element.style.opacity = opacity / 100;
213
setTimeout(function () {
214
fadeIn(element, opacity);
221
/* ******************************************
222
* FileProgress Object
223
* Control object for displaying file info
224
* ****************************************** */
226
function FileProgress(file, targetID) {
227
this.fileProgressID = "divFileProgress";
229
this.fileProgressWrapper = document.getElementById(this.fileProgressID);
230
if (!this.fileProgressWrapper) {
231
this.fileProgressWrapper = document.createElement("div");
232
this.fileProgressWrapper.className = "progressWrapper";
233
this.fileProgressWrapper.id = this.fileProgressID;
235
this.fileProgressElement = document.createElement("div");
236
this.fileProgressElement.className = "progressContainer";
238
var progressCancel = document.createElement("a");
239
progressCancel.className = "progressCancel";
240
progressCancel.href = "#";
241
progressCancel.style.visibility = "hidden";
242
progressCancel.appendChild(document.createTextNode(" "));
244
var progressText = document.createElement("div");
245
progressText.className = "progressName";
246
progressText.appendChild(document.createTextNode(file.name));
248
var progressBar = document.createElement("div");
249
progressBar.className = "progressBarInProgress";
251
var progressStatus = document.createElement("div");
252
progressStatus.className = "progressBarStatus";
253
progressStatus.innerHTML = " ";
255
this.fileProgressElement.appendChild(progressCancel);
256
this.fileProgressElement.appendChild(progressText);
257
this.fileProgressElement.appendChild(progressStatus);
258
this.fileProgressElement.appendChild(progressBar);
260
this.fileProgressWrapper.appendChild(this.fileProgressElement);
262
document.getElementById(targetID).appendChild(this.fileProgressWrapper);
263
fadeIn(this.fileProgressWrapper, 0);
266
this.fileProgressElement = this.fileProgressWrapper.firstChild;
267
this.fileProgressElement.childNodes[1].firstChild.nodeValue = file.name;
270
this.height = this.fileProgressWrapper.offsetHeight;
273
FileProgress.prototype.setProgress = function (percentage) {
274
this.fileProgressElement.className = "progressContainer green";
275
this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
276
this.fileProgressElement.childNodes[3].style.width = percentage + "%";
278
FileProgress.prototype.setComplete = function () {
279
this.fileProgressElement.className = "progressContainer blue";
280
this.fileProgressElement.childNodes[3].className = "progressBarComplete";
281
this.fileProgressElement.childNodes[3].style.width = "";
284
FileProgress.prototype.setError = function () {
285
this.fileProgressElement.className = "progressContainer red";
286
this.fileProgressElement.childNodes[3].className = "progressBarError";
287
this.fileProgressElement.childNodes[3].style.width = "";
290
FileProgress.prototype.setCancelled = function () {
291
this.fileProgressElement.className = "progressContainer";
292
this.fileProgressElement.childNodes[3].className = "progressBarError";
293
this.fileProgressElement.childNodes[3].style.width = "";
296
FileProgress.prototype.setStatus = function (status) {
297
this.fileProgressElement.childNodes[2].innerHTML = status;
300
FileProgress.prototype.toggleCancel = function (show, swfuploadInstance) {
301
this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
302
if (swfuploadInstance) {
303
var fileID = this.fileProgressID;
304
this.fileProgressElement.childNodes[0].onclick = function () {
305
swfuploadInstance.cancelUpload(fileID);