diff --git a/assets/javascripts/plupload/i18n/de.js b/assets/javascripts/plupload/i18n/de.js index 96429d31..4c4de07a 100644 --- a/assets/javascripts/plupload/i18n/de.js +++ b/assets/javascripts/plupload/i18n/de.js @@ -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.', - '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', - '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.' + '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' : '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.': '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' }); \ No newline at end of file diff --git a/assets/javascripts/plupload/i18n/fr.js b/assets/javascripts/plupload/i18n/fr.js index c534ec4e..53dbe289 100644 --- a/assets/javascripts/plupload/i18n/fr.js +++ b/assets/javascripts/plupload/i18n/fr.js @@ -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.', diff --git a/assets/javascripts/plupload/i18n/hr.js b/assets/javascripts/plupload/i18n/hr.js new file mode 100644 index 00000000..084be51c --- /dev/null +++ b/assets/javascripts/plupload/i18n/hr.js @@ -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.' +}); \ No newline at end of file diff --git a/assets/javascripts/plupload/i18n/hu.js b/assets/javascripts/plupload/i18n/hu.js new file mode 100644 index 00000000..87070bae --- /dev/null +++ b/assets/javascripts/plupload/i18n/hu.js @@ -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.' +}); diff --git a/assets/javascripts/plupload/i18n/it.js b/assets/javascripts/plupload/i18n/it.js index 7946578a..891e4fb0 100644 --- a/assets/javascripts/plupload/i18n/it.js +++ b/assets/javascripts/plupload/i18n/it.js @@ -1,21 +1,24 @@ -// .po file like language pack -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', - 'Stop current upload' : 'Interrompi il caricamento', - 'Start uploading queue' : 'Avvia il caricamento', - 'Uploaded %d/%d files': 'Caricati %d/%d file', - 'N/A' : 'N/D', - 'Drag files here.' : 'Trascina i file qui.', - 'File extension error.': 'Errore estensione file.', - 'File size error.': 'Errore dimensione file.', - 'Init error.': 'Errore inizializzazione.', - 'HTTP Error.': 'Errore HTTP.', - 'Security error.': 'Errore sicurezza.', - 'Generic error.': 'Errore generico.', - 'IO error.': 'Errore IO.' +// 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', + 'Stop current upload' : 'Interrompi il caricamento', + 'Start uploading queue' : 'Avvia il caricamento', + 'Uploaded %d/%d files': 'Caricati %d/%d file', + 'N/A' : 'N/D', + 'Drag files here.' : 'Trascina i file qui.', + 'File extension error.': 'Errore estensione file.', + 'File size error.': 'Errore dimensione file.', + 'Init error.': 'Errore inizializzazione.', + 'HTTP Error.': 'Errore HTTP.', + 'Security error.': 'Errore sicurezza.', + 'Generic error.': 'Errore generico.', + 'IO error.': 'Errore IO.', + 'Stop Upload': 'Ferma Upload', + 'Start Upload': 'Inizia Upload', + '%d files queued': '%d file in lista' }); \ No newline at end of file diff --git a/assets/javascripts/plupload/i18n/ro.js b/assets/javascripts/plupload/i18n/ro.js new file mode 100644 index 00000000..fd198f0a --- /dev/null +++ b/assets/javascripts/plupload/i18n/ro.js @@ -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' +}); \ No newline at end of file diff --git a/assets/javascripts/plupload/i18n/sr.js b/assets/javascripts/plupload/i18n/sr.js new file mode 100644 index 00000000..59dc0a97 --- /dev/null +++ b/assets/javascripts/plupload/i18n/sr.js @@ -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' +}); \ No newline at end of file diff --git a/assets/javascripts/plupload/jquery.ui.plupload/jquery.ui.plupload.js b/assets/javascripts/plupload/jquery.ui.plupload/jquery.ui.plupload.js index 680ffec8..5ed1a499 100644 --- a/assets/javascripts/plupload/jquery.ui.plupload/jquery.ui.plupload.js +++ b/assets/javascripts/plupload/jquery.ui.plupload/jquery.ui.plupload.js @@ -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); @@ -186,15 +172,35 @@ $.widget("ui.plupload", { id: id + '_count', name: id + '_count' }); - + // initialize uploader instance uploader = this.uploader = uploaders[id] = new plupload.Uploader($.extend({ container: id , 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) { + 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) { - self.start(); + // 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'); @@ -456,6 +470,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: @@ -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,25 +575,22 @@ $.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(); }); 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('' + _("Drag files here.") + ''); } 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 diff --git a/assets/javascripts/plupload/plupload.flash.js b/assets/javascripts/plupload/plupload.flash.js index a5d08b10..9af96127 100644 --- a/assets/javascripts/plupload/plupload.flash.js +++ b/assets/javascripts/plupload/plupload.flash.js @@ -133,7 +133,7 @@ html = '= 0; i--) { if (up.files[i].status == plupload.UPLOADING) { @@ -1240,10 +1283,22 @@ */ stop : function() { if (this.state != plupload.STOPPED) { - 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. @@ -1404,7 +1459,8 @@ * * @method destroy */ - destroy : function() { + destroy : function() { + this.stop(); this.trigger('Destroy'); // Clean-up after uploader itself diff --git a/assets/javascripts/plupload/plupload.silverlight.js b/assets/javascripts/plupload/plupload.silverlight.js deleted file mode 100644 index 6d285f7b..00000000 --- a/assets/javascripts/plupload/plupload.silverlight.js +++ /dev/null @@ -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 = '' + - '' + - '' + - '' + - '' + - '' + - ''; - - 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); diff --git a/assets/javascripts/plupload/plupload.silverlight.xap b/assets/javascripts/plupload/plupload.silverlight.xap deleted file mode 100644 index 1a5cbb56..00000000 Binary files a/assets/javascripts/plupload/plupload.silverlight.xap and /dev/null differ