* upgraded plupload to 1.5.2

git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@278 5e329b0b-a2ee-ea63-e329-299493fc886d
This commit is contained in:
vit.jonas@gmail.com 2012-01-10 14:16:39 +00:00
parent f4f6976983
commit 1ce5faf426
15 changed files with 326 additions and 561 deletions

View File

@ -1,25 +1,24 @@
// German
plupload.addI18n({
'Select files' : 'Wählen Sie die Dateien:',
'Add files to the upload queue and click the start button.' : 'Dateien hinzufügen und danach auf \'Starten des Uploads\' klicken und die Datei hochzuladen.',
'Select files' : 'Dateien hochladen',
'Add files to the upload queue and click the start button.' : 'Dateien hinzufügen und auf \'Hochladen\' klicken.',
'Filename' : 'Dateiname',
'Status' : 'Status',
'Size' : 'Größe',
'Add files' : 'Hinzufügen von Dateien',
'Stop current upload' : 'Stop aktuellen Upload',
'Start uploading queue' : 'Starte Upload',
'Uploaded %d/%d files': '%d/%d Dateien sind Hochgeladen',
'Add files' : 'Dateien', // hinzufügen',
'Stop current upload' : 'Aktuelles Hochladen stoppen',
'Start uploading queue' : 'Hochladen starten',
'Uploaded %d/%d files': '%d/%d Dateien sind hochgeladen',
'N/A' : 'Nicht verfügbar',
'Drag files here.' : 'Ziehen Sie die Dateien hier hin',
'File extension error.': 'Dateiendungs Fehler.',
'File size error.': 'Dateigrößen Fehler.',
'Init error.': 'Initialisierungs Fehler.',
'HTTP Error.': 'HTTP Fehler.',
'Security error.': 'Sicherheits Fehler.',
'Generic error.': 'Generic Fehler.',
'IO error.': 'Ein/Ausgabe Fehler.',
'Stop Upload': 'Stoppen des Uploads.',
'Add Files': 'Dateien hinzufügen',
'Start Upload': 'Starten des Uploads.',
'%d files queued': '%d Dateien in der Warteschlange.'
'File extension error.': 'Fehler bei Dateiendung',
'File size error.': 'Fehler bei Dateigröße',
'Init error.': 'Initialisierungsfehler',
'HTTP Error.': 'HTTP-Fehler',
'Security error.': 'Sicherheitsfehler',
'Generic error.': 'Typischer Fehler',
'IO error.': 'Ein/Ausgabe-Fehler',
'Stop Upload': 'Hochladen stoppen',
'Start upload': 'Hochladen',
'%d files queued': '%d Dateien in der Warteschlange'
});

View File

@ -1,4 +1,4 @@
// .po file like language pack
// French
plupload.addI18n({
'Select files' : 'Sélectionnez les fichiers',
'Add files to the upload queue and click the start button.' : 'Ajoutez des fichiers à la file et appuyez sur le bouton démarrer.',

View File

@ -0,0 +1,25 @@
// Croatian
plupload.addI18n({
'Select files': 'Izaberite datoteke:',
'Add files to the upload queue and click the start button.': 'Dodajte datoteke u listu i kliknite Upload.',
'Filename': 'Ime datoteke',
'Status': 'Status',
'Size': 'Veličina',
'Add files': 'Dodajte datoteke',
'Stop current upload': 'Zaustavi trenutan upload',
'Start uploading queue': 'Pokreni Upload',
'Uploaded %d/%d files': 'Uploadano %d/%d datoteka',
'N/A': 'N/A',
'Drag files here.': 'Dovucite datoteke ovdje',
'File extension error.': 'Greška ekstenzije datoteke.',
'File size error.': 'Greška veličine datoteke.',
'Init error.': 'Greška inicijalizacije.',
'HTTP Error.': 'HTTP greška.',
'Security error.': 'Sigurnosna greška.',
'Generic error.': 'Generička greška.',
'IO error.': 'I/O greška.',
'Stop Upload': 'Zaustavi upload.',
'Add Files': 'Dodaj datoteke',
'Start Upload': 'Pokreni upload.',
'%d files queued': '%d datoteka na čekanju.'
});

View File

@ -0,0 +1,33 @@
// Hungarian
plupload.addI18n({
'Select files' : 'Fájlok kiválasztása',
'Add files to the upload queue and click the start button.' : 'Válaszd ki a fájlokat, majd kattints az Indítás gombra.',
'Filename' : 'Fájlnév',
'Status' : 'Állapot',
'Size' : 'Méret',
'Add files' : 'Hozzáadás',
'Stop current upload' : 'Jelenlegi feltöltés megszakítása',
'Start uploading queue' : 'Várakozási sor feltöltésének indítása',
'Uploaded %d/%d files': 'Feltöltött fájlok: %d/%d',
'N/A': 'Nem elérhető',
'Drag files here.' : 'Húzd ide a fájlokat.',
'Stop upload': 'Feltöltés megszakítása',
'Start upload': 'Indítás',
'%d files queued': '%d fájl sorbaállítva',
'File: %s': 'Fájl: %s',
'Close': 'Bezárás',
'Using runtime: ': 'Használt runtime: ',
'File: %f, size: %s, max file size: %m': 'Fájl: %f, méret: %s, maximális fájlméret: %m',
'Upload element accepts only %d file(s) at a time. Extra files were stripped.': 'A feltöltés egyszerre csak %d fájlt fogad el, a többi fájl nem lesz feltöltve.',
'Upload URL might be wrong or doesn\'t exist': 'A megadott URL hibás vagy nem létezik',
'Error: File too large: ': 'Hiba: A fájl túl nagy: ',
'Error: Invalid file extension: ': 'Hiba: Érvénytelen fájlkiterjesztés: ',
'File extension error.': 'Hibás fájlkiterjesztés.',
'File size error.': 'Hibás fájlméret.',
'File count error.': 'A fájlok számával kapcsolatos hiba.',
'Init error.': 'Init hiba.',
'HTTP Error.': 'HTTP hiba.',
'Security error.': 'Biztonsági hiba.',
'Generic error.': 'Általános hiba.',
'IO error.': 'I/O hiba.'
});

View File

@ -1,11 +1,11 @@
// .po file like language pack
// Italian
plupload.addI18n({
'Select files' : 'Seleziona i files',
'Add files to the upload queue and click the start button.' : 'Aggiungi i file alla coda di caricamento e clicca il pulsante di avvio.',
'Filename' : 'Nome file',
'Status' : 'Stato',
'Size' : 'Dimensione',
'Add files' : 'Aggiungi file',
'Add Files' : 'Aggiungi file',
'Stop current upload' : 'Interrompi il caricamento',
'Start uploading queue' : 'Avvia il caricamento',
'Uploaded %d/%d files': 'Caricati %d/%d file',
@ -17,5 +17,8 @@ plupload.addI18n({
'HTTP Error.': 'Errore HTTP.',
'Security error.': 'Errore sicurezza.',
'Generic error.': 'Errore generico.',
'IO error.': 'Errore IO.'
'IO error.': 'Errore IO.',
'Stop Upload': 'Ferma Upload',
'Start Upload': 'Inizia Upload',
'%d files queued': '%d file in lista'
});

View File

@ -0,0 +1,24 @@
// Romanian
plupload.addI18n({
'Select files' : 'Selectare fişiere',
'Add files to the upload queue and click the start button.' : 'Adaugă fişiere în lista apoi apasă butonul \'Începe încărcare\'.',
'Filename' : 'Nume fişier',
'Status' : 'Stare',
'Size' : 'Mărime',
'Add files' : 'Adăugare fişiere',
'Stop current upload' : 'Întrerupe încărcarea curentă',
'Start uploading queue' : 'Începe incărcarea',
'Uploaded %d/%d files': 'Fişiere încărcate %d/%d',
'N/A' : 'N/A',
'Drag files here.' : 'Trage aici fişierele',
'File extension error.': 'Extensie fişier eronată',
'File size error.': 'Eroare dimensiune fişier',
'Init error.': 'Eroare iniţializare',
'HTTP Error.': 'Eroare HTTP',
'Security error.': 'Eroare securitate',
'Generic error.': 'Eroare generică',
'IO error.': 'Eroare Intrare/Ieşire',
'Stop Upload': 'Oprire încărcare',
'Start upload': 'Începe încărcare',
'%d files queued': '%d fişiere listate'
});

View File

@ -0,0 +1,14 @@
// Serbian
plupload.addI18n({
'Select files' : 'Izaberite fajlove',
'Add files to the upload queue and click the start button.' : 'Dodajte fajlove u listu i kliknite na dugme Start.',
'Filename' : 'Naziv fajla',
'Status' : 'Status',
'Size' : 'Veličina',
'Add Files' : 'Dodaj fajlove',
'Stop current upload' : 'Zaustavi upload',
'Start uploading queue' : 'Počni upload',
'Drag files here.' : 'Prevucite fajlove ovde.',
'Start Upload': 'Počni upload',
'Uploaded %d/%d files': 'Snimljeno %d/%d fajlova'
});

View File

@ -159,20 +159,6 @@ $.widget("ui.plupload", {
});
}
// all buttons are optional, so they can be disabled and hidden
if (!this.options.buttons.browse) {
this.browse_button.button('disable').hide();
$('#' + id + self.runtime + '_container').hide();
}
if (!this.options.buttons.start) {
this.start_button.button('disable').hide();
}
if (!this.options.buttons.stop) {
this.stop_button.button('disable').hide();
}
// progressbar
this.progressbar = $('.plupload_progress_container', this.container);
@ -193,8 +179,28 @@ $.widget("ui.plupload", {
browse_button: id + '_browse'
}, this.options));
// do not show UI if no runtime can be initialized
uploader.bind('Error', function(up, err) {
if (err.code === plupload.INIT_ERROR) {
self.destroy();
}
});
uploader.bind('Init', function(up, res) {
// all buttons are optional, so they can be disabled and hidden
if (!self.options.buttons.browse) {
self.browse_button.button('disable').hide();
up.disableBrowse(true);
}
if (!self.options.buttons.start) {
self.start_button.button('disable').hide();
}
if (!self.options.buttons.stop) {
self.stop_button.button('disable').hide();
}
if (!self.options.unique_names && self.options.rename) {
self._enableRenaming();
}
@ -213,7 +219,7 @@ $.widget("ui.plupload", {
});
self.stop_button.click(function(e) {
uploader.stop();
self.stop();
e.preventDefault();
});
});
@ -244,7 +250,10 @@ $.widget("ui.plupload", {
self._trigger('selected', null, { up: up, files: files } );
if (self.options.autostart) {
// set a little delay to make sure that QueueChanged triggered by the core has time to complete
setTimeout(function() {
self.start();
}, 10);
}
});
@ -272,7 +281,12 @@ $.widget("ui.plupload", {
uploader.bind('UploadProgress', function(up, file) {
// Set file specific progress
$('#' + file.id + ' .plupload_file_status', self.element).html(file.percent + '%');
$('#' + file.id)
.find('.plupload_file_status')
.html(file.percent + '%')
.end()
.find('.plupload_file_size')
.html(plupload.formatSize(file.size));
self._handleFileStatus(file);
self._updateTotalProgress();
@ -354,10 +368,10 @@ $.widget("ui.plupload", {
if (!value.browse) {
self.browse_button.button('disable').hide();
$('#' + self.id + self.runtime + '_container').hide();
up.disableBrowse(true);
} else {
self.browse_button.button('enable').show();
$('#' + self.id + self.runtime + '_container').show();
up.disableBrowse(false);
}
if (!value.start) {
@ -419,9 +433,9 @@ $.widget("ui.plupload", {
_handleState: function() {
var self = this, uploader = this.uploader;
var self = this, up = this.uploader;
if (uploader.state === plupload.STARTED) {
if (up.state === plupload.STARTED) {
$(self.start_button).button('disable');
@ -431,7 +445,7 @@ $.widget("ui.plupload", {
.removeClass('plupload_hidden');
$('.plupload_upload_status', self.element).text(
_('Uploaded %d/%d files').replace('%d/%d', uploader.total.uploaded+'/'+uploader.files.length)
_('Uploaded %d/%d files').replace('%d/%d', up.total.uploaded+'/'+up.files.length)
);
$('.plupload_header_content', self.element).addClass('plupload_header_content_bw');
@ -457,6 +471,11 @@ $.widget("ui.plupload", {
_handleFileStatus: function(file) {
var actionClass, iconClass;
// since this method might be called asynchronously, file row might not yet be rendered
if (!$('#' + file.id).length) {
return;
}
switch (file.status) {
case plupload.DONE:
actionClass = 'plupload_done';
@ -498,20 +517,24 @@ $.widget("ui.plupload", {
_updateTotalProgress: function() {
var uploader = this.uploader;
var up = this.uploader;
this.progressbar.progressbar('value', uploader.total.percent);
this.progressbar.progressbar('value', up.total.percent);
$('.plupload_total_status', this.element).html(uploader.total.percent + '%');
$('.plupload_upload_status', this.element).text(
_('Uploaded %d/%d files').replace('%d/%d', uploader.total.uploaded+'/'+uploader.files.length)
);
this.element
.find('.plupload_total_status')
.html(up.total.percent + '%')
.end()
.find('.plupload_total_file_size')
.html(plupload.formatSize(up.total.size))
.end()
.find('.plupload_upload_status')
.text(_('Uploaded %d/%d files').replace('%d/%d', up.total.uploaded+'/'+up.files.length));
},
_updateFileList: function() {
var self = this, uploader = this.uploader, filelist = this.filelist,
var self = this, up = this.uploader, filelist = this.filelist,
count = 0,
id, prefix = this.id + '_',
fields;
@ -523,7 +546,7 @@ $.widget("ui.plupload", {
filelist.empty();
$.each(uploader.files, function(i, file) {
$.each(up.files, function(i, file) {
fields = '';
id = prefix + count;
@ -552,7 +575,7 @@ $.widget("ui.plupload", {
$('#' + file.id + '.plupload_delete .ui-icon, #' + file.id + '.plupload_done .ui-icon')
.click(function(e) {
$('#' + file.id).remove();
uploader.removeFile(file);
up.removeFile(file);
e.preventDefault();
});
@ -560,17 +583,14 @@ $.widget("ui.plupload", {
self._trigger('updatelist', null, filelist);
});
$('.plupload_total_file_size', self.element).html(plupload.formatSize(uploader.total.size));
if (uploader.total.queued === 0) {
if (up.total.queued === 0) {
$('.ui-button-text', self.browse_button).text(_('Add Files'));
} else {
$('.ui-button-text', self.browse_button).text(_('%d files queued').replace('%d', uploader.total.queued));
$('.ui-button-text', self.browse_button).text(_('%d files queued').replace('%d', up.total.queued));
}
if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
if (up.files.length === (up.total.uploaded + up.total.failed)) {
self.start_button.button('disable');
} else {
self.start_button.button('enable');
@ -582,7 +602,7 @@ $.widget("ui.plupload", {
self._updateTotalProgress();
if (!uploader.files.length && uploader.features.dragdrop && uploader.settings.dragdrop) {
if (!up.files.length && up.features.dragdrop && up.settings.dragdrop) {
// Re-add drag message if there are no files
$('#' + id + '_filelist').append('<tr><td class="plupload_droptext">' + _("Drag files here.") + '</td></tr>');
} else {
@ -597,7 +617,7 @@ $.widget("ui.plupload", {
_enableRenaming: function() {
var self = this;
$('.plupload_file_name span', this.filelist).live('click', function(e) {
$('.plupload_delete .plupload_file_name span', this.filelist).live('click', function(e) {
var targetSpan = $(e.target), file, parts, name, ext = "";
// Get file name and split out name and extension

View File

@ -133,7 +133,7 @@
html = '<object id="' + uploader.id + '_flash" type="application/x-shockwave-flash" data="' + uploader.settings.flash_swf_url + '" ';
if (plupload.ua.ie) {
html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
}
html += 'width="100%" height="100%" style="outline:0">' +
@ -206,6 +206,10 @@
});
});
uploader.bind("CancelUpload", function() {
getFlashObj().cancelUpload();
});
uploader.bind("Flash:UploadProcess", function(up, flash_file) {
var file = up.getFile(lookup[flash_file.id]);
@ -230,7 +234,7 @@
up.trigger('ChunkUploaded', file, chunkArgs);
// Stop upload if file is maked as failed
if (file.status != plupload.FAILED) {
if (file.status !== plupload.FAILED && up.state !== plupload.STOPPED) {
getFlashObj().uploadNextChunk();
}
@ -396,6 +400,11 @@
}
});
uploader.bind("DisableBrowse", function(up, disabled) {
getFlashObj().disableBrowse(disabled);
});
uploader.bind("Destroy", function(up) {
var flashContainer;

View File

@ -68,7 +68,7 @@
type = plupload.mimeTypes[ext[y]];
if (type) {
if (type && plupload.inArray(type, mimes) === -1) {
mimes.push(type);
}
}
@ -106,7 +106,9 @@
// Route click event to input element programmatically, if possible
if (up.features.triggerDialog && browseButton) {
plupload.addEvent(getById(up.settings.browse_button), 'click', function(e) {
if (!input.disabled) {
input.click();
}
e.preventDefault();
}, up.id);
}
@ -116,7 +118,7 @@
width : '100%',
height : '100%',
opacity : 0,
fontSize: '999px' // force input element to be bigger then needed to occupy whole space
fontSize: '99px' // force input element to be bigger then needed to occupy whole space
});
plupload.extend(form.style, {
@ -374,6 +376,13 @@
}
});
uploader.bind("DisableBrowse", function(up, disabled) {
var input = document.getElementById('input_' + currentFileId);
if (input) {
input.disabled = disabled;
}
});
// Completely destroy the runtime
uploader.bind("Destroy", function(up) {

View File

@ -210,7 +210,7 @@
* @param {function} callback Callback to execute when the runtime initializes or fails to initialize. If it succeeds an object with a parameter name success will be set to true.
*/
init : function(uploader, callback) {
var features;
var features, xhr;
function addSelectedFiles(native_files) {
var file, i, files = [], id, fileNames = {};
@ -289,7 +289,7 @@
type = plupload.mimeTypes[ext[y]];
if (type) {
if (type && plupload.inArray(type, mimes) === -1) {
mimes.push(type);
}
}
@ -357,7 +357,10 @@
// Route click event to the input[type=file] element for supporting browsers
if (up.features.triggerDialog) {
plupload.addEvent(browseButton, 'click', function(e) {
document.getElementById(up.id + '_html5').click();
var input = document.getElementById(up.id + '_html5');
if (input && !input.disabled) { // for some reason FF (up to 8.0.1 so far) lets to click disabled input[type=file]
input.click();
}
e.preventDefault();
}, up.id);
}
@ -478,6 +481,19 @@
}
});
uploader.bind("DisableBrowse", function(up, disabled) {
var input = document.getElementById(up.id + '_html5');
if (input) {
input.disabled = disabled;
}
});
uploader.bind("CancelUpload", function() {
if (xhr.abort) {
xhr.abort();
}
});
uploader.bind("UploadFile", function(up, file) {
var settings = up.settings, nativeFile, resize;
@ -511,13 +527,13 @@
function prepareAndSend(bin) {
var multipartDeltaSize = 0,
xhr = new XMLHttpRequest,
upload = xhr.upload,
boundary = '----pluploadboundary' + plupload.guid(), formData, dashdash = '--', crlf = '\r\n', multipartBlob = ''
boundary = '----pluploadboundary' + plupload.guid(), formData, dashdash = '--', crlf = '\r\n', multipartBlob = '';
xhr = new XMLHttpRequest;
// Do we have upload progress support
if (upload) {
upload.onprogress = function(e) {
if (xhr.upload) {
xhr.upload.onprogress = function(e) {
file.loaded = Math.min(file.size, loaded + e.loaded - multipartDeltaSize); // Loaded can be larger than file size due to multipart encoding
up.trigger('UploadProgress', file);
};
@ -526,7 +542,7 @@
xhr.onreadystatechange = function() {
var httpStatus, chunkArgs;
if (xhr.readyState == 4) {
if (xhr.readyState == 4 && up.state !== plupload.STOPPED) {
// Getting the HTTP status might fail on some Gecko versions
try {
httpStatus = xhr.status;
@ -583,9 +599,6 @@
uploadNextChunk();
}
}
xhr = null;
}
};
@ -708,7 +721,7 @@
}
// workaround Gecko 2,5,6 FormData+Blob bug: https://bugzilla.mozilla.org/show_bug.cgi?id=649150
if (typeof(chunkBlob) !== 'string' && fr && features.cantSendBlobInFormData && features.chunks && up.settings.chunk_size) {// Gecko 2,5,6
if (up.settings.multipart && features.multipart && typeof(chunkBlob) !== 'string' && fr && features.cantSendBlobInFormData && features.chunks && up.settings.chunk_size) { // Gecko 2,5,6
fr.onload = function() {
prepareAndSend(fr.result);
}
@ -733,8 +746,10 @@
if (res.success) {
file.size = res.data.length;
sendBinaryBlob(res.data);
} else {
} else if (features.chunks) {
sendBinaryBlob(nativeFile);
} else {
readFileAsBinary(nativeFile, sendBinaryBlob); // for browsers not supporting File.slice (e.g. FF3.6)
}
});
// if there's no way to slice file without preloading it in memory, preload it
@ -1360,13 +1375,11 @@
Exif = extractTags(offsets.exifIFD, tags.exif);
// Fix formatting of some tags
if (Exif.ExifVersion) {
Exif.ExifVersion = String.fromCharCode(
Exif.ExifVersion[0],
Exif.ExifVersion[1],
Exif.ExifVersion[2],
Exif.ExifVersion[3]
);
if (Exif.ExifVersion && plupload.typeOf(Exif.ExifVersion) === 'array') {
for (var i = 0, exifVersion = ''; i < Exif.ExifVersion.length; i++) {
exifVersion += String.fromCharCode(Exif.ExifVersion[i]);
}
Exif.ExifVersion = exifVersion;
}
return Exif;

View File

@ -51,7 +51,14 @@
"application/vnd.ms-powerpoint,ppt pps pot," +
"application/zip,zip," +
"application/x-shockwave-flash,swf swfl," +
"application/vnd.openxmlformats,docx pptx xlsx," +
"application/vnd.openxmlformats-officedocument.wordprocessingml.document,docx," +
"application/vnd.openxmlformats-officedocument.wordprocessingml.template,dotx," +
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,xlsx," +
"application/vnd.openxmlformats-officedocument.presentationml.presentation,pptx," +
"application/vnd.openxmlformats-officedocument.presentationml.template,potx," +
"application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," +
"application/x-javascript,js," +
"application/json,json," +
"audio/mpeg,mpga mpega mp2 mp3," +
"audio/x-wav,wav," +
"audio/mp4,m4a," +
@ -62,7 +69,10 @@
"image/png,png," +
"image/svg+xml,svg svgz," +
"image/tiff,tiff tif," +
"text/plain,asc txt text diff log," +
"text/html,htm html xhtml," +
"text/css,css," +
"text/csv,csv," +
"text/rtf,rtf," +
"video/mpeg,mpeg mpg mpe," +
"video/quicktime,qt mov," +
@ -73,8 +83,7 @@
"video/avi,avi," +
"video/webm,webm," +
"video/vnd.rn-realvideo,rv," +
"text/csv,csv," +
"text/plain,asc txt text diff log," +
"application/vnd.oasis.opendocument.formula-template,otf," +
"application/octet-stream,exe"
);
@ -257,6 +266,17 @@
};
}()),
/**
* Gets the true type of the built-in object (better version of typeof).
* @credits Angus Croll (http://javascriptweblog.wordpress.com/)
*
* @param {Object} o Object to check.
* @return {String} Object [[Class]]
*/
typeOf: function(o) {
return ({}).toString.call(o).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
},
/**
* Extends the specified object with another object.
*
@ -566,6 +586,29 @@
return arr;
},
/**
* Find an element in array and return it's index if present, otherwise return -1.
*
* @method inArray
* @param {mixed} needle Element to find
* @param {Array} array
* @return {Int} Index of the element, or -1 if not found
*/
inArray : function(needle, array) {
if (array) {
if (Array.prototype.indexOf) {
return Array.prototype.indexOf.call(array, needle);
}
for (var i = 0, length = array.length; i < length; i++) {
if (array[i] === needle) {
return i;
}
}
}
return -1;
},
/**
* Extends the language pack object with new items.
*
@ -848,7 +891,7 @@
* @param {Object} settings Initialization settings, to be used by the uploader instance and runtimes.
*/
plupload.Uploader = function(settings) {
var events = {}, total, files = [], startTime;
var events = {}, total, files = [], startTime, disabled = false;
// Inital total state
total = new plupload.QueueProgress();
@ -1241,10 +1284,22 @@
stop : function() {
if (this.state != plupload.STOPPED) {
this.state = plupload.STOPPED;
this.trigger("CancelUpload");
this.trigger("StateChanged");
}
},
/**
* Disables/enables browse button on request.
*
* @method disableBrowse
* @param {Boolean} disable Whether to disable or enable (default: true)
*/
disableBrowse : function() {
disabled = arguments[0] !== undef ? arguments[0] : true;
this.trigger("DisableBrowse", disabled);
},
/**
* Returns the specified file object by id.
*
@ -1405,6 +1460,7 @@
* @method destroy
*/
destroy : function() {
this.stop();
this.trigger('Destroy');
// Clean-up after uploader itself

View File

@ -1,440 +0,0 @@
/**
* plupload.silverlight.js
*
* Copyright 2009, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
// JSLint defined globals
/*global window:false, document:false, plupload:false, ActiveXObject:false */
(function(window, document, plupload, undef) {
var uploadInstances = {}, initialized = {};
function jsonSerialize(obj) {
var value, type = typeof obj, isArray, i, key;
// Treat undefined as null
if (obj === undef || obj === null) {
return 'null';
}
// Encode strings
if (type === 'string') {
value = '\bb\tt\nn\ff\rr\""\'\'\\\\';
return '"' + obj.replace(/([\u0080-\uFFFF\x00-\x1f\"])/g, function(a, b) {
var idx = value.indexOf(b);
if (idx + 1) {
return '\\' + value.charAt(idx + 1);
}
a = b.charCodeAt().toString(16);
return '\\u' + '0000'.substring(a.length) + a;
}) + '"';
}
// Loop objects/arrays
if (type == 'object') {
isArray = obj.length !== undef;
value = '';
if (isArray) {
for (i = 0; i < obj.length; i++) {
if (value) {
value += ',';
}
value += jsonSerialize(obj[i]);
}
value = '[' + value + ']';
} else {
for (key in obj) {
if (obj.hasOwnProperty(key)) {
if (value) {
value += ',';
}
value += jsonSerialize(key) + ':' + jsonSerialize(obj[key]);
}
}
value = '{' + value + '}';
}
return value;
}
// Convert all other types to string
return '' + obj;
}
function isInstalled(version) {
var isVersionSupported = false, container = null, control = null, actualVer,
actualVerArray, reqVerArray, requiredVersionPart, actualVersionPart, index = 0;
try {
try {
control = new ActiveXObject('AgControl.AgControl');
if (control.IsVersionSupported(version)) {
isVersionSupported = true;
}
control = null;
} catch (e) {
var plugin = navigator.plugins["Silverlight Plug-In"];
if (plugin) {
actualVer = plugin.description;
if (actualVer === "1.0.30226.2") {
actualVer = "2.0.30226.2";
}
actualVerArray = actualVer.split(".");
while (actualVerArray.length > 3) {
actualVerArray.pop();
}
while ( actualVerArray.length < 4) {
actualVerArray.push(0);
}
reqVerArray = version.split(".");
while (reqVerArray.length > 4) {
reqVerArray.pop();
}
do {
requiredVersionPart = parseInt(reqVerArray[index], 10);
actualVersionPart = parseInt(actualVerArray[index], 10);
index++;
} while (index < reqVerArray.length && requiredVersionPart === actualVersionPart);
if (requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart)) {
isVersionSupported = true;
}
}
}
} catch (e2) {
isVersionSupported = false;
}
return isVersionSupported;
}
plupload.silverlight = {
trigger : function(id, name) {
var uploader = uploadInstances[id], i, args;
if (uploader) {
args = plupload.toArray(arguments).slice(1);
args[0] = 'Silverlight:' + name;
// Detach the call so that error handling in the browser is presented correctly
setTimeout(function() {
uploader.trigger.apply(uploader, args);
}, 0);
}
}
};
/**
* Silverlight implementation. This runtime supports these features: jpgresize, pngresize, chunks.
*
* @static
* @class plupload.runtimes.Silverlight
* @extends plupload.Runtime
*/
plupload.runtimes.Silverlight = plupload.addRuntime("silverlight", {
/**
* Returns a list of supported features for the runtime.
*
* @return {Object} Name/value object with supported features.
*/
getFeatures : function() {
return {
jpgresize: true,
pngresize: true,
chunks: true,
progress: true,
multipart: true,
multi_selection: true
};
},
/**
* Initializes the upload runtime. This runtime supports these features: jpgresize, pngresize, chunks.
*
* @method init
* @param {plupload.Uploader} uploader Uploader instance that needs to be initialized.
* @param {function} callback Callback to execute when the runtime initializes or fails to initialize. If it succeeds an object with a parameter name success will be set to true.
*/
init : function(uploader, callback) {
var silverlightContainer, filter = '', filters = uploader.settings.filters, i, container = document.body;
// Check if Silverlight is installed, Silverlight windowless parameter doesn't work correctly on Opera so we disable it for now
if (!isInstalled('2.0.31005.0') || (window.opera && window.opera.buildNumber)) {
callback({success : false});
return;
}
initialized[uploader.id] = false;
uploadInstances[uploader.id] = uploader;
// Create silverlight container and insert it at an absolute position within the browse button
silverlightContainer = document.createElement('div');
silverlightContainer.id = uploader.id + '_silverlight_container';
plupload.extend(silverlightContainer.style, {
position : 'absolute',
top : '0px',
background : uploader.settings.shim_bgcolor || 'transparent',
zIndex : 99999,
width : '100px',
height : '100px',
overflow : 'hidden',
opacity : uploader.settings.shim_bgcolor || document.documentMode > 8 ? '' : 0.01 // Force transparent if bgcolor is undefined
});
silverlightContainer.className = 'plupload silverlight';
if (uploader.settings.container) {
container = document.getElementById(uploader.settings.container);
if (plupload.getStyle(container, 'position') === 'static') {
container.style.position = 'relative';
}
}
container.appendChild(silverlightContainer);
for (i = 0; i < filters.length; i++) {
filter += (filter != '' ? '|' : '') + filters[i].title + " | *." + filters[i].extensions.replace(/,/g, ';*.');
}
// Insert the Silverlight object inide the Silverlight container
silverlightContainer.innerHTML = '<object id="' + uploader.id + '_silverlight" data="data:application/x-silverlight," type="application/x-silverlight-2" style="outline:none;" width="1024" height="1024">' +
'<param name="source" value="' + uploader.settings.silverlight_xap_url + '"/>' +
'<param name="background" value="Transparent"/>' +
'<param name="windowless" value="true"/>' +
'<param name="enablehtmlaccess" value="true"/>' +
'<param name="initParams" value="id=' + uploader.id + ',filter=' + filter + ',multiselect=' + uploader.settings.multi_selection + '"/>' +
'</object>';
function getSilverlightObj() {
return document.getElementById(uploader.id + '_silverlight').content.Upload;
}
uploader.bind("Silverlight:Init", function() {
var selectedFiles, lookup = {};
// Prevent eventual reinitialization of the instance
if (initialized[uploader.id]) {
return;
}
initialized[uploader.id] = true;
uploader.bind("Silverlight:StartSelectFiles", function(up) {
selectedFiles = [];
});
uploader.bind("Silverlight:SelectFile", function(up, sl_id, name, size) {
var id;
// Store away silverlight ids
id = plupload.guid();
lookup[id] = sl_id;
lookup[sl_id] = id;
// Expose id, name and size
selectedFiles.push(new plupload.File(id, name, size));
});
uploader.bind("Silverlight:SelectSuccessful", function() {
// Trigger FilesAdded event if we added any
if (selectedFiles.length) {
uploader.trigger("FilesAdded", selectedFiles);
}
});
uploader.bind("Silverlight:UploadChunkError", function(up, file_id, chunk, chunks, message) {
uploader.trigger("Error", {
code : plupload.IO_ERROR,
message : 'IO Error.',
details : message,
file : up.getFile(lookup[file_id])
});
});
uploader.bind("Silverlight:UploadFileProgress", function(up, sl_id, loaded, total) {
var file = up.getFile(lookup[sl_id]);
if (file.status != plupload.FAILED) {
file.size = total;
file.loaded = loaded;
up.trigger('UploadProgress', file);
}
});
uploader.bind("Refresh", function(up) {
var browseButton, browsePos, browseSize;
browseButton = document.getElementById(up.settings.browse_button);
if (browseButton) {
browsePos = plupload.getPos(browseButton, document.getElementById(up.settings.container));
browseSize = plupload.getSize(browseButton);
plupload.extend(document.getElementById(up.id + '_silverlight_container').style, {
top : browsePos.y + 'px',
left : browsePos.x + 'px',
width : browseSize.w + 'px',
height : browseSize.h + 'px'
});
}
});
uploader.bind("Silverlight:UploadChunkSuccessful", function(up, sl_id, chunk, chunks, text) {
var chunkArgs, file = up.getFile(lookup[sl_id]);
chunkArgs = {
chunk : chunk,
chunks : chunks,
response : text
};
up.trigger('ChunkUploaded', file, chunkArgs);
// Stop upload if file is maked as failed
if (file.status != plupload.FAILED) {
getSilverlightObj().UploadNextChunk();
}
// Last chunk then dispatch FileUploaded event
if (chunk == chunks - 1) {
file.status = plupload.DONE;
up.trigger('FileUploaded', file, {
response : text
});
}
});
uploader.bind("Silverlight:UploadSuccessful", function(up, sl_id, response) {
var file = up.getFile(lookup[sl_id]);
file.status = plupload.DONE;
up.trigger('FileUploaded', file, {
response : response
});
});
uploader.bind("FilesRemoved", function(up, files) {
var i;
for (i = 0; i < files.length; i++) {
getSilverlightObj().RemoveFile(lookup[files[i].id]);
}
});
uploader.bind("UploadFile", function(up, file) {
var settings = up.settings, resize = settings.resize || {};
getSilverlightObj().UploadFile(
lookup[file.id],
up.settings.url,
jsonSerialize({
name : file.target_name || file.name,
mime : plupload.mimeTypes[file.name.replace(/^.+\.([^.]+)/, '$1').toLowerCase()] || 'application/octet-stream',
chunk_size : settings.chunk_size,
image_width : resize.width,
image_height : resize.height,
image_quality : resize.quality || 90,
multipart : !!settings.multipart,
multipart_params : settings.multipart_params || {},
file_data_name : settings.file_data_name,
headers : settings.headers
})
);
});
uploader.bind('Silverlight:MouseEnter', function(up) {
var browseButton, hoverClass;
browseButton = document.getElementById(uploader.settings.browse_button);
hoverClass = up.settings.browse_button_hover;
if (browseButton && hoverClass) {
plupload.addClass(browseButton, hoverClass);
}
});
uploader.bind('Silverlight:MouseLeave', function(up) {
var browseButton, hoverClass;
browseButton = document.getElementById(uploader.settings.browse_button);
hoverClass = up.settings.browse_button_hover;
if (browseButton && hoverClass) {
plupload.removeClass(browseButton, hoverClass);
}
});
uploader.bind('Silverlight:MouseLeftButtonDown', function(up) {
var browseButton, activeClass;
browseButton = document.getElementById(uploader.settings.browse_button);
activeClass = up.settings.browse_button_active;
if (browseButton && activeClass) {
plupload.addClass(browseButton, activeClass);
// Make sure that browse_button has active state removed from it
plupload.addEvent(document.body, 'mouseup', function() {
plupload.removeClass(browseButton, activeClass);
});
}
});
uploader.bind('Sliverlight:StartSelectFiles', function(up) {
var browseButton, activeClass;
browseButton = document.getElementById(uploader.settings.browse_button);
activeClass = up.settings.browse_button_active;
if (browseButton && activeClass) {
plupload.removeClass(browseButton, activeClass);
}
});
uploader.bind("Destroy", function(up) {
var silverlightContainer;
plupload.removeAllEvents(document.body, up.id);
delete initialized[up.id];
delete uploadInstances[up.id];
silverlightContainer = document.getElementById(up.id + '_silverlight_container');
if (silverlightContainer) {
container.removeChild(silverlightContainer);
}
});
callback({success : true});
});
}
});
})(window, document, plupload);