Plupload library upgraded to v1.5.8
@ -29,7 +29,7 @@ plupload.addI18n({
|
||||
'Close': 'بستن',
|
||||
'%d files queued': '%d فایل در صف',
|
||||
'Using runtime: ': 'استفاده میکنید از : ',
|
||||
'File: %f, size: %s, max file size: %m':' فایل: %f, سایز: %s, بزرگترین سایز فایل: %m',
|
||||
'File: %f, size: %s, max file size: %m': فایل: %f, سایز: %s, بزرگترین سایز فایل: %m',
|
||||
'Upload element accepts only %d file(s) at a time. Extra files were stripped.': 'عنصر بارگذار فقط %d فایل رو در یک زمان می پذیرد. سایر فایل ها مجرد از این موضوع هستند.',
|
||||
'Upload URL might be wrong or doesn\'t exist': 'آدرس آپلود اشتباه می باشد یا وجود ندارد',
|
||||
'Error: File too large: ': 'خطا: فایل حجیم است :: ',
|
||||
|
||||
@ -3,33 +3,23 @@ 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.',
|
||||
'Filename' : 'Nom de fichier',
|
||||
'Status' : 'Statut',
|
||||
'Status' : 'Status',
|
||||
'Size' : 'Taille',
|
||||
'Add files' : 'Ajouter Fichiers',
|
||||
'Stop current upload' : 'Arrêter l\'envoi en cours',
|
||||
'Start uploading queue' : 'Démarrer l\'envoi',
|
||||
'Uploaded %d/%d files': '%d/%d fichiers envoyés',
|
||||
'N/A' : 'Non applicable',
|
||||
'Drag files here.' : 'Déposer les fichiers ici',
|
||||
'Drag files here.' : 'Déposer les fichiers ici.',
|
||||
'File extension error.': 'Erreur extension fichier',
|
||||
'File size error.': 'Erreur taille fichier',
|
||||
'Init error.': 'Erreur d\'initialisation',
|
||||
'HTTP Error.': 'Erreur HTTP',
|
||||
'Security error.': 'Erreur de sécurité',
|
||||
'Generic error.': 'Erreur générique',
|
||||
'IO error.': 'Erreur E/S',
|
||||
'Stop Upload': 'Arrêter les envois',
|
||||
'File size error.': 'Erreur taille fichier.',
|
||||
'Init error.': 'Erreur d\'initialisation.',
|
||||
'HTTP Error.': 'Erreur HTTP.',
|
||||
'Security error.': 'Erreur de sécurité.',
|
||||
'Generic error.': 'Erreur générique.',
|
||||
'IO error.': 'Erreur E/S.',
|
||||
'Stop Upload': 'Arrêter les envois.',
|
||||
'Add Files': 'Ajouter des fichiers',
|
||||
'Start Upload': 'Démarrer les envois',
|
||||
'%d files queued': '%d fichiers en attente',
|
||||
'File: %s':'Fichier: %s',
|
||||
'Close':'Fermer',
|
||||
'Using runtime:':'Moteur logiciel :',
|
||||
'File: %f, size: %s, max file size: %m':'Fichier: %f, poids: %s, poids maximal : %m',
|
||||
'Upload element accepts only %d file(s) at a time. Extra files were stripped.':'La file accepte %d fichier(s) à la fois. Les fichiers en trop sont ignorés.',
|
||||
'Upload URL might be wrong or doesn\'t exist':'L\'URL d\'envoi est erronée ou inexistante.',
|
||||
'Error: File to large: ':'Fichier trop volumineux : ',
|
||||
'Error: Invalid file extension: ':'Extension de fichier invalide : ',
|
||||
'File size error.':'Erreur de taille de fichier',
|
||||
'File count error.':'Erreur de comptage des fichiers'
|
||||
});
|
||||
'Start Upload': 'Démarrer les envois.',
|
||||
'%d files queued': '%d fichiers en attente.'
|
||||
});
|
||||
@ -8,7 +8,7 @@ plupload.addI18n({
|
||||
'Add files' : 'Добавить файлы',
|
||||
'Stop current upload' : 'Остановить загрузку',
|
||||
'Start uploading queue' : 'Загрузить файлы',
|
||||
'Uploaded %d/%d files': 'Загружено %d из %d файлов',
|
||||
'Uploaded %d/%d files': 'Загружено %d/%d файлов',
|
||||
'N/A' : 'N/D',
|
||||
'Drag files here.' : 'Перетащите файлы сюда.',
|
||||
'File extension error.': 'Неправильное расширение файла.',
|
||||
|
||||
25
assets/javascripts/plupload/i18n/sk.js
Normal file
@ -0,0 +1,25 @@
|
||||
// .po file like language pack
|
||||
plupload.addI18n({
|
||||
'Select files' : 'Vyberte súbory',
|
||||
'Add files to the upload queue and click the start button.' : 'Pridajte súbory do zoznamu a potom spustite nahrávanie.',
|
||||
'Filename' : 'Názov súboru',
|
||||
'Status' : 'Stav',
|
||||
'Size' : 'Veľkosť',
|
||||
'Add files' : 'Pridať súbory',
|
||||
'Stop current upload' : 'Zastaviť nahrávanie',
|
||||
'Start uploading queue' : 'Spustiť nahrávanie zoznamu',
|
||||
'Drag files here.' : 'Sem pretiahnite súbory.',
|
||||
'Start upload': 'Spustiť nahrávanie',
|
||||
'Uploaded %d/%d files': 'Nahraných %d/%d súborov',
|
||||
'Using runtime: ': 'K odoslaniu súborov sa použije rozhranie: ',
|
||||
'N/A' : 'N/A',
|
||||
'File extension error.': 'Chybný typ súboru.',
|
||||
'File size error.': 'Súbor je príliš veľký.',
|
||||
'Init error.': 'Chyba inicializácie.',
|
||||
'HTTP Error.': 'HTTP Chyba.',
|
||||
'Security error.': 'Bezpečnostná Chyba.',
|
||||
'Generic error.': 'Chyba.',
|
||||
'IO error.': 'IO Chyba',
|
||||
'Stop Upload': 'Zastaviť nahrávanie',
|
||||
'%d files queued': '%d súborov pridaných do zoznamu'
|
||||
});
|
||||
@ -1,4 +1,4 @@
|
||||
// Serbian
|
||||
// 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.',
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// .po file like language pack
|
||||
// .po file like language pack
|
||||
plupload.addI18n({
|
||||
'Select files' : 'Välj filer',
|
||||
'Add files to the upload queue and click the start button.' : 'Lägg till filer till kön och tryck på start.',
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
// Traditional Chinese, translated by aecho1028@gmail.com.
|
||||
plupload.addI18n({
|
||||
'Select files' : '選取檔案',
|
||||
'Add files to the upload queue and click the start button.' : '新增檔案到上傳佇列,然後請點擊開始按鈕。',
|
||||
'Filename' : '檔案名稱',
|
||||
'Status' : '狀態',
|
||||
'Size' : '檔案大小',
|
||||
'Add Files' : '新增檔案',
|
||||
'Stop Upload' : '停止上傳',
|
||||
'Start Upload' : '開始上傳',
|
||||
'Add files' : '新增檔案',
|
||||
'Add files.' : '新增檔案',
|
||||
'Stop current upload' : '停止現在的上傳',
|
||||
'Start uploading queue' : '開始上傳',
|
||||
'Stop upload' : '停止上傳',
|
||||
'Start upload' : '開始上傳',
|
||||
'Uploaded %d/%d files': '己上傳 %d/%d 檔案',
|
||||
'N/A' : 'N/A',
|
||||
'Drag files here.' : '將檔案拖拉到這邊',
|
||||
'File extension error.': '副檔名錯誤',
|
||||
'File size error.': '檔案大小錯誤',
|
||||
'File count error.': '檔案筆數錯誤',
|
||||
'Init error.': '初始化錯誤',
|
||||
'HTTP Error.': 'HTTP錯誤',
|
||||
'Security error.': '安全性錯誤',
|
||||
'Generic error.': '錯誤',
|
||||
'IO error.': 'IO錯誤',
|
||||
'File: %s': '檔案: %s',
|
||||
'Close': '關閉',
|
||||
'%d files queued': '%d 檔案佇列中',
|
||||
'Using runtime: ': 'Using runtime: ',
|
||||
'File: %f, size: %s, max file size: %m': '檔案: %f, 大小: %s, 最大檔案大小: %m',
|
||||
'Upload element accepts only %d file(s) at a time. Extra files were stripped.': '一次只能上傳 %d 個檔案。多餘的檔案將會被捨棄。',
|
||||
'Upload URL might be wrong or doesn\'t exist': '上傳的URL可能不正確,或是不存在。',
|
||||
'Error: File too large: ': '錯誤: 檔案太大了: ',
|
||||
'Error: Invalid file extension: ': '錯誤: 副檔名不正確: '
|
||||
});
|
||||
@ -0,0 +1,177 @@
|
||||
/*
|
||||
Plupload
|
||||
------------------------------------------------------------------- */
|
||||
|
||||
.plupload_button {
|
||||
display: -moz-inline-box; /* FF < 3*/
|
||||
display: inline-block;
|
||||
font: normal 12px sans-serif;
|
||||
text-decoration: none;
|
||||
color: #42454a;
|
||||
border: 1px solid #bababa;
|
||||
padding: 2px 8px 3px 20px;
|
||||
margin-right: 4px;
|
||||
background: #f3f3f3 url('../img/buttons.png') no-repeat 0 center;
|
||||
outline: 0;
|
||||
|
||||
/* Optional rounded corners for browsers that support it */
|
||||
-moz-border-radius: 3px;
|
||||
-khtml-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.plupload_button:hover {
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.plupload_disabled, a.plupload_disabled:hover {
|
||||
color: #737373;
|
||||
border-color: #c5c5c5;
|
||||
background: #ededed url('../img/buttons-disabled.png') no-repeat 0 center;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.plupload_add {
|
||||
background-position: -181px center;
|
||||
}
|
||||
|
||||
.plupload_wrapper {
|
||||
font: normal 11px Verdana,sans-serif;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.plupload_container {
|
||||
padding: 8px;
|
||||
background: url('../img/transp50.png');
|
||||
/*-moz-border-radius: 5px;*/
|
||||
}
|
||||
|
||||
.plupload_container input {
|
||||
border: 1px solid #DDD;
|
||||
font: normal 11px Verdana,sans-serif;
|
||||
width: 98%;
|
||||
}
|
||||
|
||||
.plupload_header {background: #2A2C2E url('../img/backgrounds.gif') repeat-x;}
|
||||
.plupload_header_content {
|
||||
background: url('../img/backgrounds.gif') no-repeat 0 -317px;
|
||||
min-height: 56px;
|
||||
padding-left: 60px;
|
||||
color: #FFF;
|
||||
}
|
||||
.plupload_header_title {
|
||||
font: normal 18px sans-serif;
|
||||
padding: 6px 0 3px;
|
||||
}
|
||||
.plupload_header_text {
|
||||
font: normal 12px sans-serif;
|
||||
}
|
||||
|
||||
.plupload_filelist {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.plupload_scroll .plupload_filelist {
|
||||
height: 185px;
|
||||
background: #F5F5F5;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.plupload_filelist li {
|
||||
padding: 10px 8px;
|
||||
background: #F5F5F5 url('../img/backgrounds.gif') repeat-x 0 -156px;
|
||||
border-bottom: 1px solid #DDD;
|
||||
}
|
||||
|
||||
.plupload_filelist_header, .plupload_filelist_footer {
|
||||
background: #DFDFDF;
|
||||
padding: 8px 8px;
|
||||
color: #42454A;
|
||||
}
|
||||
.plupload_filelist_header {
|
||||
border-top: 1px solid #EEE;
|
||||
border-bottom: 1px solid #CDCDCD;
|
||||
}
|
||||
|
||||
.plupload_filelist_footer {border-top: 1px solid #FFF; height: 22px; line-height: 20px; vertical-align: middle;}
|
||||
.plupload_file_name {float: left; overflow: hidden}
|
||||
.plupload_file_status {color: #777;}
|
||||
.plupload_file_status span {color: #42454A;}
|
||||
.plupload_file_size, .plupload_file_status, .plupload_progress {
|
||||
float: right;
|
||||
width: 80px;
|
||||
}
|
||||
.plupload_file_size, .plupload_file_status, .plupload_file_action {text-align: right;}
|
||||
|
||||
.plupload_filelist .plupload_file_name {width: 205px}
|
||||
|
||||
.plupload_file_action {
|
||||
float: right;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.plupload_file_action * {
|
||||
display: none;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
li.plupload_uploading {background: #ECF3DC url('../img/backgrounds.gif') repeat-x 0 -238px;}
|
||||
li.plupload_done {color:#AAA}
|
||||
|
||||
li.plupload_delete a {
|
||||
background: url('../img/delete.gif');
|
||||
}
|
||||
|
||||
li.plupload_failed a {
|
||||
background: url('../img/error.gif');
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
li.plupload_done a {
|
||||
background: url('../img/done.gif');
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.plupload_progress, .plupload_upload_status {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.plupload_progress_container {
|
||||
margin-top: 3px;
|
||||
border: 1px solid #CCC;
|
||||
background: #FFF;
|
||||
padding: 1px;
|
||||
}
|
||||
.plupload_progress_bar {
|
||||
width: 0px;
|
||||
height: 7px;
|
||||
background: #CDEB8B;
|
||||
}
|
||||
|
||||
.plupload_scroll .plupload_filelist_header .plupload_file_action, .plupload_scroll .plupload_filelist_footer .plupload_file_action {
|
||||
margin-right: 17px;
|
||||
}
|
||||
|
||||
/* Floats */
|
||||
|
||||
.plupload_clear,.plupload_clearer {clear: both;}
|
||||
.plupload_clearer, .plupload_progress_bar {
|
||||
display: block;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
li.plupload_droptext {
|
||||
background: transparent;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
border: 0;
|
||||
line-height: 165px;
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/javascripts/plupload/jquery.plupload.queue/img/delete.gif
Normal file
|
After Width: | Height: | Size: 180 B |
BIN
assets/javascripts/plupload/jquery.plupload.queue/img/done.gif
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
assets/javascripts/plupload/jquery.plupload.queue/img/error.gif
Normal file
|
After Width: | Height: | Size: 994 B |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 399 B |
@ -0,0 +1,336 @@
|
||||
/**
|
||||
* jquery.plupload.queue.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 plupload:false, jQuery:false, alert:false */
|
||||
|
||||
(function($) {
|
||||
var uploaders = {};
|
||||
|
||||
function _(str) {
|
||||
return plupload.translate(str) || str;
|
||||
}
|
||||
|
||||
function renderUI(id, target) {
|
||||
// Remove all existing non plupload items
|
||||
target.contents().each(function(i, node) {
|
||||
node = $(node);
|
||||
|
||||
if (!node.is('.plupload')) {
|
||||
node.remove();
|
||||
}
|
||||
});
|
||||
|
||||
target.prepend(
|
||||
'<div class="plupload_wrapper plupload_scroll">' +
|
||||
'<div id="' + id + '_container" class="plupload_container">' +
|
||||
'<div class="plupload">' +
|
||||
'<div class="plupload_header">' +
|
||||
'<div class="plupload_header_content">' +
|
||||
'<div class="plupload_header_title">' + _('Select files') + '</div>' +
|
||||
'<div class="plupload_header_text">' + _('Add files to the upload queue and click the start button.') + '</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
|
||||
'<div class="plupload_content">' +
|
||||
'<div class="plupload_filelist_header">' +
|
||||
'<div class="plupload_file_name">' + _('Filename') + '</div>' +
|
||||
'<div class="plupload_file_action"> </div>' +
|
||||
'<div class="plupload_file_status"><span>' + _('Status') + '</span></div>' +
|
||||
'<div class="plupload_file_size">' + _('Size') + '</div>' +
|
||||
'<div class="plupload_clearer"> </div>' +
|
||||
'</div>' +
|
||||
|
||||
'<ul id="' + id + '_filelist" class="plupload_filelist"></ul>' +
|
||||
|
||||
'<div class="plupload_filelist_footer">' +
|
||||
'<div class="plupload_file_name">' +
|
||||
'<div class="plupload_buttons">' +
|
||||
'<a href="#" class="plupload_button plupload_add">' + _('Add files') + '</a>' +
|
||||
'<a href="#" class="plupload_button plupload_start">' + _('Start upload') + '</a>' +
|
||||
'</div>' +
|
||||
'<span class="plupload_upload_status"></span>' +
|
||||
'</div>' +
|
||||
'<div class="plupload_file_action"></div>' +
|
||||
'<div class="plupload_file_status"><span class="plupload_total_status">0%</span></div>' +
|
||||
'<div class="plupload_file_size"><span class="plupload_total_file_size">0 b</span></div>' +
|
||||
'<div class="plupload_progress">' +
|
||||
'<div class="plupload_progress_container">' +
|
||||
'<div class="plupload_progress_bar"></div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="plupload_clearer"> </div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<input type="hidden" id="' + id + '_count" name="' + id + '_count" value="0" />' +
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
|
||||
$.fn.pluploadQueue = function(settings) {
|
||||
if (settings) {
|
||||
this.each(function() {
|
||||
var uploader, target, id;
|
||||
|
||||
target = $(this);
|
||||
id = target.attr('id');
|
||||
|
||||
if (!id) {
|
||||
id = plupload.guid();
|
||||
target.attr('id', id);
|
||||
}
|
||||
|
||||
uploader = new plupload.Uploader($.extend({
|
||||
dragdrop : true,
|
||||
container : id
|
||||
}, settings));
|
||||
|
||||
uploaders[id] = uploader;
|
||||
|
||||
function handleStatus(file) {
|
||||
var actionClass;
|
||||
|
||||
if (file.status == plupload.DONE) {
|
||||
actionClass = 'plupload_done';
|
||||
}
|
||||
|
||||
if (file.status == plupload.FAILED) {
|
||||
actionClass = 'plupload_failed';
|
||||
}
|
||||
|
||||
if (file.status == plupload.QUEUED) {
|
||||
actionClass = 'plupload_delete';
|
||||
}
|
||||
|
||||
if (file.status == plupload.UPLOADING) {
|
||||
actionClass = 'plupload_uploading';
|
||||
}
|
||||
|
||||
var icon = $('#' + file.id).attr('class', actionClass).find('a').css('display', 'block');
|
||||
if (file.hint) {
|
||||
icon.attr('title', file.hint);
|
||||
}
|
||||
}
|
||||
|
||||
function updateTotalProgress() {
|
||||
$('span.plupload_total_status', target).html(uploader.total.percent + '%');
|
||||
$('div.plupload_progress_bar', target).css('width', uploader.total.percent + '%');
|
||||
$('span.plupload_upload_status', target).html(
|
||||
_('Uploaded %d/%d files').replace(/%d\/%d/, uploader.total.uploaded+'/'+uploader.files.length)
|
||||
);
|
||||
}
|
||||
|
||||
function updateList() {
|
||||
var fileList = $('ul.plupload_filelist', target).html(''), inputCount = 0, inputHTML;
|
||||
|
||||
$.each(uploader.files, function(i, file) {
|
||||
inputHTML = '';
|
||||
|
||||
if (file.status == plupload.DONE) {
|
||||
if (file.target_name) {
|
||||
inputHTML += '<input type="hidden" name="' + id + '_' + inputCount + '_tmpname" value="' + plupload.xmlEncode(file.target_name) + '" />';
|
||||
}
|
||||
|
||||
inputHTML += '<input type="hidden" name="' + id + '_' + inputCount + '_name" value="' + plupload.xmlEncode(file.name) + '" />';
|
||||
inputHTML += '<input type="hidden" name="' + id + '_' + inputCount + '_status" value="' + (file.status == plupload.DONE ? 'done' : 'failed') + '" />';
|
||||
|
||||
inputCount++;
|
||||
|
||||
$('#' + id + '_count').val(inputCount);
|
||||
}
|
||||
|
||||
fileList.append(
|
||||
'<li id="' + file.id + '">' +
|
||||
'<div class="plupload_file_name"><span>' + file.name + '</span></div>' +
|
||||
'<div class="plupload_file_action"><a href="#"></a></div>' +
|
||||
'<div class="plupload_file_status">' + file.percent + '%</div>' +
|
||||
'<div class="plupload_file_size">' + plupload.formatSize(file.size) + '</div>' +
|
||||
'<div class="plupload_clearer"> </div>' +
|
||||
inputHTML +
|
||||
'</li>'
|
||||
);
|
||||
|
||||
handleStatus(file);
|
||||
|
||||
$('#' + file.id + '.plupload_delete a').click(function(e) {
|
||||
$('#' + file.id).remove();
|
||||
uploader.removeFile(file);
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
$('span.plupload_total_file_size', target).html(plupload.formatSize(uploader.total.size));
|
||||
|
||||
if (uploader.total.queued === 0) {
|
||||
$('span.plupload_add_text', target).html(_('Add files.'));
|
||||
} else {
|
||||
$('span.plupload_add_text', target).html(uploader.total.queued + ' files queued.');
|
||||
}
|
||||
|
||||
$('a.plupload_start', target).toggleClass('plupload_disabled', uploader.files.length == (uploader.total.uploaded + uploader.total.failed));
|
||||
|
||||
// Scroll to end of file list
|
||||
fileList[0].scrollTop = fileList[0].scrollHeight;
|
||||
|
||||
updateTotalProgress();
|
||||
|
||||
// Re-add drag message if there is no files
|
||||
if (!uploader.files.length && uploader.features.dragdrop && uploader.settings.dragdrop) {
|
||||
$('#' + id + '_filelist').append('<li class="plupload_droptext">' + _("Drag files here.") + '</li>');
|
||||
}
|
||||
}
|
||||
|
||||
uploader.bind("UploadFile", function(up, file) {
|
||||
$('#' + file.id).addClass('plupload_current_file');
|
||||
});
|
||||
|
||||
uploader.bind('Init', function(up, res) {
|
||||
renderUI(id, target);
|
||||
|
||||
// Enable rename support
|
||||
if (!settings.unique_names && settings.rename) {
|
||||
target.on('click', '#' + id + '_filelist div.plupload_file_name span', function(e) {
|
||||
var targetSpan = $(e.target), file, parts, name, ext = "";
|
||||
|
||||
// Get file name and split out name and extension
|
||||
file = up.getFile(targetSpan.parents('li')[0].id);
|
||||
name = file.name;
|
||||
parts = /^(.+)(\.[^.]+)$/.exec(name);
|
||||
if (parts) {
|
||||
name = parts[1];
|
||||
ext = parts[2];
|
||||
}
|
||||
|
||||
// Display input element
|
||||
targetSpan.hide().after('<input type="text" />');
|
||||
targetSpan.next().val(name).focus().blur(function() {
|
||||
targetSpan.show().next().remove();
|
||||
}).keydown(function(e) {
|
||||
var targetInput = $(this);
|
||||
|
||||
if ($.inArray(e.keyCode, [13, 27]) !== -1) {
|
||||
e.preventDefault();
|
||||
|
||||
// Rename file and glue extension back on
|
||||
if (e.keyCode === 13) {
|
||||
file.name = targetInput.val() + ext;
|
||||
targetSpan.html(file.name);
|
||||
}
|
||||
targetInput.blur();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$('a.plupload_add', target).attr('id', id + '_browse');
|
||||
|
||||
up.settings.browse_button = id + '_browse';
|
||||
|
||||
// Enable drag/drop
|
||||
if (up.features.dragdrop && up.settings.dragdrop) {
|
||||
up.settings.drop_element = id + '_filelist';
|
||||
$('#' + id + '_filelist').append('<li class="plupload_droptext">' + _("Drag files here.") + '</li>');
|
||||
}
|
||||
|
||||
$('#' + id + '_container').attr('title', 'Using runtime: ' + res.runtime);
|
||||
|
||||
$('a.plupload_start', target).click(function(e) {
|
||||
if (!$(this).hasClass('plupload_disabled')) {
|
||||
uploader.start();
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$('a.plupload_stop', target).click(function(e) {
|
||||
e.preventDefault();
|
||||
uploader.stop();
|
||||
});
|
||||
|
||||
$('a.plupload_start', target).addClass('plupload_disabled');
|
||||
});
|
||||
|
||||
uploader.init();
|
||||
|
||||
uploader.bind("Error", function(up, err) {
|
||||
var file = err.file, message;
|
||||
|
||||
if (file) {
|
||||
message = err.message;
|
||||
|
||||
if (err.details) {
|
||||
message += " (" + err.details + ")";
|
||||
}
|
||||
|
||||
if (err.code == plupload.FILE_SIZE_ERROR) {
|
||||
alert(_("Error: File too large: ") + file.name);
|
||||
}
|
||||
|
||||
if (err.code == plupload.FILE_EXTENSION_ERROR) {
|
||||
alert(_("Error: Invalid file extension: ") + file.name);
|
||||
}
|
||||
|
||||
file.hint = message;
|
||||
$('#' + file.id).attr('class', 'plupload_failed').find('a').css('display', 'block').attr('title', message);
|
||||
}
|
||||
});
|
||||
|
||||
uploader.bind('StateChanged', function() {
|
||||
if (uploader.state === plupload.STARTED) {
|
||||
$('li.plupload_delete a,div.plupload_buttons', target).hide();
|
||||
$('span.plupload_upload_status,div.plupload_progress,a.plupload_stop', target).css('display', 'block');
|
||||
$('span.plupload_upload_status', target).html('Uploaded ' + uploader.total.uploaded + '/' + uploader.files.length + ' files');
|
||||
|
||||
if (settings.multiple_queues) {
|
||||
$('span.plupload_total_status,span.plupload_total_file_size', target).show();
|
||||
}
|
||||
} else {
|
||||
updateList();
|
||||
$('a.plupload_stop,div.plupload_progress', target).hide();
|
||||
$('a.plupload_delete', target).css('display', 'block');
|
||||
}
|
||||
});
|
||||
|
||||
uploader.bind('QueueChanged', updateList);
|
||||
|
||||
uploader.bind('FileUploaded', function(up, file) {
|
||||
handleStatus(file);
|
||||
});
|
||||
|
||||
uploader.bind("UploadProgress", function(up, file) {
|
||||
// Set file specific progress
|
||||
$('#' + file.id + ' div.plupload_file_status', target).html(file.percent + '%');
|
||||
|
||||
handleStatus(file);
|
||||
updateTotalProgress();
|
||||
|
||||
if (settings.multiple_queues && uploader.total.uploaded + uploader.total.failed == uploader.files.length) {
|
||||
$(".plupload_buttons,.plupload_upload_status", target).css("display", "inline");
|
||||
$(".plupload_start", target).addClass("plupload_disabled");
|
||||
$('span.plupload_total_status,span.plupload_total_file_size', target).hide();
|
||||
}
|
||||
});
|
||||
|
||||
// Call setup function
|
||||
if (settings.setup) {
|
||||
settings.setup(uploader);
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
} else {
|
||||
// Get uploader instance for specified element
|
||||
return uploaders[$(this[0]).attr('id')];
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
147
assets/javascripts/plupload/jquery.ui.plupload/css/jquery.ui.plupload.css
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
Plupload
|
||||
------------------------------------------------------------------- */
|
||||
|
||||
.plupload_button {cursor: pointer;}
|
||||
|
||||
.plupload_wrapper {
|
||||
font: normal 11px Verdana,sans-serif;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.plupload .plupload_container input {width: 98%;}
|
||||
.plupload .plupload_filelist_footer {border-width: 1px 0 0 0}
|
||||
.plupload .plupload_filelist_header {border-width: 0 0 1px 0}
|
||||
div.plupload .plupload_file {border-width: 0 0 1px 0}
|
||||
div.plupload div.plupload_header {border-width: 0 0 1px 0; position: relative;}
|
||||
|
||||
.plupload_file .ui-icon {
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.plupload_header_content {
|
||||
background-image: url('../img/plupload.png');
|
||||
background-repeat: no-repeat;
|
||||
background-position: 8px center;
|
||||
min-height: 56px;
|
||||
padding-left: 60px;
|
||||
position:relative;
|
||||
}
|
||||
.plupload_header_content_bw {background-image: url('../img/plupload-bw.png');}
|
||||
.plupload_header_title {
|
||||
font: normal 18px sans-serif;
|
||||
padding: 6px 0 3px;
|
||||
}
|
||||
.plupload_header_text {font: normal 12px sans-serif;}
|
||||
|
||||
.plupload_filelist,
|
||||
.plupload_filelist_content {
|
||||
border-collapse: collapse;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
-moz-user-select:none;
|
||||
-webkit-user-select:none;
|
||||
user-select:none;
|
||||
}
|
||||
|
||||
.plupload_cell {padding: 8px 6px;}
|
||||
|
||||
.plupload_file {
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.plupload .ui-sortable-helper,
|
||||
.plupload .ui-sortable .plupload_file {
|
||||
cursor:move;
|
||||
}
|
||||
|
||||
.plupload_scroll {
|
||||
max-height: 180px;
|
||||
min-height: 168px;
|
||||
_height: 168px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.plupload_file_size, .plupload_file_status {text-align: right;}
|
||||
.plupload_file_size, .plupload_file_status {width: 52px;}
|
||||
.plupload_file_action {width: 16px;}
|
||||
.plupload_file_name {
|
||||
overflow: hidden;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.plupload_file_rename {
|
||||
width:95%;
|
||||
}
|
||||
|
||||
.plupload_progress {width: 60px;}
|
||||
.plupload_progress_container {padding: 1px;}
|
||||
|
||||
|
||||
/* Floats */
|
||||
|
||||
.plupload_right {float: right;}
|
||||
.plupload_left {float: left;}
|
||||
.plupload_clear,.plupload_clearer {clear: both;}
|
||||
.plupload_clearer, .plupload_progress_bar {
|
||||
display: block;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
}
|
||||
.plupload_clearer {height: 0;}
|
||||
|
||||
/* Misc */
|
||||
.plupload_hidden {display: none;}
|
||||
.plupload_droptext {
|
||||
background: transparent;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
border: 0;
|
||||
line-height: 165px;
|
||||
}
|
||||
|
||||
.plupload_buttons, .plupload_upload_status {float: left}
|
||||
|
||||
.plupload_message {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.plupload_message p {
|
||||
padding:0.7em;
|
||||
margin:0;
|
||||
}
|
||||
|
||||
.plupload_message strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
plupload_message i {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.plupload_message p span.ui-icon {
|
||||
float: left;
|
||||
margin-right: 0.3em;
|
||||
}
|
||||
|
||||
.plupload_header_content .ui-state-error,
|
||||
.plupload_header_content .ui-state-highlight {
|
||||
border:none;
|
||||
}
|
||||
|
||||
.plupload_message_close {
|
||||
position:absolute;
|
||||
top:5px;
|
||||
right:5px;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.plupload .ui-sortable-placeholder {
|
||||
height:35px;
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/javascripts/plupload/jquery.ui.plupload/img/plupload.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
@ -1 +1,361 @@
|
||||
(function(a){a.runtimes.BrowserPlus=a.addRuntime("browserplus",{getFeatures:function(){return{dragdrop:true,jpgresize:true,pngresize:true,chunks:true,progress:true,multipart:true,multi_selection:true}},init:function(g,i){var e=window.BrowserPlus,h={},d=g.settings,c=d.resize;function f(n){var m,l,j=[],k,o;for(l=0;l<n.length;l++){k=n[l];o=a.guid();h[o]=k;j.push(new a.File(o,k.name,k.size))}if(l){g.trigger("FilesAdded",j)}}function b(){var j=false;g.bind("PostInit",function(){var n,l=d.drop_element,p=g.id+"_droptarget",k=document.getElementById(l),m;function q(s,r){e.DragAndDrop.AddDropTarget({id:s},function(t){e.DragAndDrop.AttachCallbacks({id:s,hover:function(u){if(!u&&r){r()}},drop:function(u){if(r){r()}f(u)}},function(){})})}function o(){document.getElementById(p).style.top="-1000px"}if(k){if(document.attachEvent&&(/MSIE/gi).test(navigator.userAgent)){n=document.createElement("div");n.setAttribute("id",p);a.extend(n.style,{position:"absolute",top:"-1000px",background:"red",filter:"alpha(opacity=0)",opacity:0});document.body.appendChild(n);a.addEvent(k,"dragenter",function(s){var r,t;r=document.getElementById(l);t=a.getPos(r);a.extend(document.getElementById(p).style,{top:t.y+"px",left:t.x+"px",width:r.offsetWidth+"px",height:r.offsetHeight+"px"})});q(p,o)}else{q(l)}}a.addEvent(document.getElementById(d.browse_button),"click",function(x){var r=[],t,s,w=d.filters,v,u;x.preventDefault();if(j){return}no_type_restriction:for(t=0;t<w.length;t++){v=w[t].extensions.split(",");for(s=0;s<v.length;s++){if(v[s]==="*"){r=[];break no_type_restriction}u=a.mimeTypes[v[s]];if(u&&a.inArray(u,r)===-1){r.push(a.mimeTypes[v[s]])}}}e.FileBrowse.OpenBrowseDialog({mimeTypes:r},function(y){if(y.success){f(y.value)}})});k=n=null});g.bind("CancelUpload",function(){e.Uploader.cancel({},function(){})});g.bind("DisableBrowse",function(k,l){j=l});g.bind("UploadFile",function(n,k){var m=h[k.id],s={},l=n.settings.chunk_size,o,p=[];function r(t,v){var u;if(k.status==a.FAILED){return}s.name=k.target_name||k.name;if(l){s.chunk=""+t;s.chunks=""+v}u=p.shift();e.Uploader.upload({url:n.settings.url,files:{file:u},cookies:document.cookies,postvars:a.extend(s,n.settings.multipart_params),progressCallback:function(y){var x,w=0;o[t]=parseInt(y.filePercent*u.size/100,10);for(x=0;x<o.length;x++){w+=o[x]}k.loaded=w;n.trigger("UploadProgress",k)}},function(x){var w,y;if(x.success){w=x.value.statusCode;if(l){n.trigger("ChunkUploaded",k,{chunk:t,chunks:v,response:x.value.body,status:w})}if(p.length>0){r(++t,v)}else{k.status=a.DONE;n.trigger("FileUploaded",k,{response:x.value.body,status:w});if(w>=400){n.trigger("Error",{code:a.HTTP_ERROR,message:a.translate("HTTP Error."),file:k,status:w})}}}else{n.trigger("Error",{code:a.GENERIC_ERROR,message:a.translate("Generic Error."),file:k,details:x.error})}})}function q(t){k.size=t.size;if(l){e.FileAccess.chunk({file:t,chunkSize:l},function(w){if(w.success){var x=w.value,u=x.length;o=Array(u);for(var v=0;v<u;v++){o[v]=0;p.push(x[v])}r(0,u)}})}else{o=Array(1);p.push(t);r(0,1)}}if(c&&/\.(png|jpg|jpeg)$/i.test(k.name)){BrowserPlus.ImageAlter.transform({file:m,quality:c.quality||90,actions:[{scale:{maxwidth:c.width,maxheight:c.height}}]},function(t){if(t.success){q(t.value.file)}})}else{q(m)}});i({success:true})}if(e){e.init(function(k){var j=[{service:"Uploader",version:"3"},{service:"DragAndDrop",version:"1"},{service:"FileBrowse",version:"1"},{service:"FileAccess",version:"2"}];if(c){j.push({service:"ImageAlter",version:"4"})}if(k.success){e.require({services:j},function(l){if(l.success){b()}else{i()}})}else{i()}})}else{i()}}})})(plupload);
|
||||
/**
|
||||
* plupload.browserplus.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 plupload:false, BrowserPlus:false, window:false */
|
||||
|
||||
(function(plupload) {
|
||||
/**
|
||||
* Yahoo BrowserPlus implementation. This runtime supports these features: dragdrop, jpgresize, pngresize.
|
||||
*
|
||||
* @static
|
||||
* @class plupload.runtimes.BrowserPlus
|
||||
* @extends plupload.Runtime
|
||||
*/
|
||||
plupload.runtimes.BrowserPlus = plupload.addRuntime("browserplus", {
|
||||
/**
|
||||
* Returns a list of supported features for the runtime.
|
||||
*
|
||||
* @return {Object} Name/value object with supported features.
|
||||
*/
|
||||
getFeatures : function() {
|
||||
return {
|
||||
dragdrop : true,
|
||||
jpgresize : true,
|
||||
pngresize : true,
|
||||
chunks : true,
|
||||
progress: true,
|
||||
multipart: true,
|
||||
multi_selection: true
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the browserplus runtime.
|
||||
*
|
||||
* @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 browserPlus = window.BrowserPlus, browserPlusFiles = {}, settings = uploader.settings, resize = settings.resize;
|
||||
|
||||
function addSelectedFiles(native_files) {
|
||||
var files, i, selectedFiles = [], file, id;
|
||||
|
||||
// Add the native files and setup plupload files
|
||||
for (i = 0; i < native_files.length; i++) {
|
||||
file = native_files[i];
|
||||
id = plupload.guid();
|
||||
browserPlusFiles[id] = file;
|
||||
|
||||
selectedFiles.push(new plupload.File(id, file.name, file.size));
|
||||
}
|
||||
|
||||
// Any files selected fire event
|
||||
if (i) {
|
||||
uploader.trigger("FilesAdded", selectedFiles);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup event listeners if browserplus was initialized
|
||||
function setup() {
|
||||
var disabled = false;
|
||||
|
||||
// Add drop handler
|
||||
uploader.bind("PostInit", function() {
|
||||
var dropTargetElm, dropElmId = settings.drop_element,
|
||||
dropTargetId = uploader.id + '_droptarget',
|
||||
dropElm = document.getElementById(dropElmId),
|
||||
lastState;
|
||||
|
||||
// Enable/disable drop support for the drop target
|
||||
// this is needed to resolve IE bubbeling issues and make it possible to drag/drop
|
||||
// files into gears runtimes on the same page
|
||||
function addDropHandler(id, end_callback) {
|
||||
// Add drop target and listener
|
||||
browserPlus.DragAndDrop.AddDropTarget({id : id}, function(res) {
|
||||
browserPlus.DragAndDrop.AttachCallbacks({
|
||||
id : id,
|
||||
hover : function(res) {
|
||||
if (!res && end_callback) {
|
||||
end_callback();
|
||||
}
|
||||
},
|
||||
drop : function(res) {
|
||||
if (end_callback) {
|
||||
end_callback();
|
||||
}
|
||||
|
||||
addSelectedFiles(res);
|
||||
}
|
||||
}, function() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function hide() {
|
||||
document.getElementById(dropTargetId).style.top = '-1000px';
|
||||
}
|
||||
|
||||
if (dropElm) {
|
||||
// Since IE has issues with bubbeling when it comes to the drop of files
|
||||
// we need to do this hack where we show a drop target div element while dropping
|
||||
if (document.attachEvent && (/MSIE/gi).test(navigator.userAgent)) {
|
||||
// Create drop target
|
||||
dropTargetElm = document.createElement('div');
|
||||
dropTargetElm.setAttribute('id', dropTargetId);
|
||||
plupload.extend(dropTargetElm.style, {
|
||||
position : 'absolute',
|
||||
top : '-1000px',
|
||||
background : 'red',
|
||||
filter : 'alpha(opacity=0)',
|
||||
opacity : 0
|
||||
});
|
||||
|
||||
document.body.appendChild(dropTargetElm);
|
||||
|
||||
plupload.addEvent(dropElm, 'dragenter', function(e) {
|
||||
var dropElm, dropElmPos;
|
||||
|
||||
dropElm = document.getElementById(dropElmId);
|
||||
dropElmPos = plupload.getPos(dropElm);
|
||||
|
||||
plupload.extend(document.getElementById(dropTargetId).style, {
|
||||
top : dropElmPos.y + 'px',
|
||||
left : dropElmPos.x + 'px',
|
||||
width : dropElm.offsetWidth + 'px',
|
||||
height : dropElm.offsetHeight + 'px'
|
||||
});
|
||||
});
|
||||
|
||||
addDropHandler(dropTargetId, hide);
|
||||
} else {
|
||||
addDropHandler(dropElmId);
|
||||
}
|
||||
}
|
||||
|
||||
plupload.addEvent(document.getElementById(settings.browse_button), 'click', function(e) {
|
||||
var mimes = [], i, a, filters = settings.filters, ext, type;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert extensions to mimetypes
|
||||
no_type_restriction:
|
||||
for (i = 0; i < filters.length; i++) {
|
||||
ext = filters[i].extensions.split(',');
|
||||
|
||||
for (a = 0; a < ext.length; a++) {
|
||||
if (ext[a] === '*') {
|
||||
mimes = [];
|
||||
break no_type_restriction;
|
||||
}
|
||||
type = plupload.mimeTypes[ext[a]];
|
||||
|
||||
if (type && plupload.inArray(type, mimes) === -1) {
|
||||
mimes.push(plupload.mimeTypes[ext[a]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
browserPlus.FileBrowse.OpenBrowseDialog({
|
||||
mimeTypes : mimes
|
||||
}, function(res) {
|
||||
if (res.success) {
|
||||
addSelectedFiles(res.value);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Prevent IE leaks
|
||||
dropElm = dropTargetElm = null;
|
||||
});
|
||||
|
||||
uploader.bind("CancelUpload", function() {
|
||||
browserPlus.Uploader.cancel({}, function(){});
|
||||
});
|
||||
|
||||
uploader.bind("DisableBrowse", function(up, state) {
|
||||
disabled = state;
|
||||
});
|
||||
|
||||
uploader.bind("UploadFile", function(up, file) {
|
||||
var nativeFile = browserPlusFiles[file.id], reqParams = {},
|
||||
chunkSize = up.settings.chunk_size, loadProgress, chunkStack = [];
|
||||
|
||||
function uploadFile(chunk, chunks) {
|
||||
var chunkFile;
|
||||
|
||||
// Stop upload if file is maked as failed
|
||||
if (file.status == plupload.FAILED) {
|
||||
return;
|
||||
}
|
||||
|
||||
reqParams.name = file.target_name || file.name;
|
||||
|
||||
// Only send chunk parameters if chunk size is defined
|
||||
if (chunkSize) {
|
||||
reqParams.chunk = "" + chunk;
|
||||
reqParams.chunks = "" + chunks;
|
||||
}
|
||||
|
||||
chunkFile = chunkStack.shift();
|
||||
|
||||
browserPlus.Uploader.upload({
|
||||
url : up.settings.url,
|
||||
files : {file : chunkFile},
|
||||
cookies : document.cookies,
|
||||
postvars : plupload.extend(reqParams, up.settings.multipart_params),
|
||||
progressCallback : function(res) {
|
||||
var i, loaded = 0;
|
||||
|
||||
// since more than 1 chunk can be sent at a time, keep track of how many bytes
|
||||
// of each chunk was sent
|
||||
loadProgress[chunk] = parseInt(res.filePercent * chunkFile.size / 100, 10);
|
||||
for (i = 0; i < loadProgress.length; i++) {
|
||||
loaded += loadProgress[i];
|
||||
}
|
||||
|
||||
file.loaded = loaded;
|
||||
up.trigger('UploadProgress', file);
|
||||
}
|
||||
}, function(res) {
|
||||
var httpStatus, chunkArgs;
|
||||
|
||||
if (res.success) {
|
||||
httpStatus = res.value.statusCode;
|
||||
|
||||
if (chunkSize) {
|
||||
up.trigger('ChunkUploaded', file, {
|
||||
chunk : chunk,
|
||||
chunks : chunks,
|
||||
response : res.value.body,
|
||||
status : httpStatus
|
||||
});
|
||||
}
|
||||
|
||||
if (chunkStack.length > 0) {
|
||||
// More chunks to be uploaded
|
||||
uploadFile(++chunk, chunks);
|
||||
} else {
|
||||
file.status = plupload.DONE;
|
||||
|
||||
up.trigger('FileUploaded', file, {
|
||||
response : res.value.body,
|
||||
status : httpStatus
|
||||
});
|
||||
|
||||
// Is error status
|
||||
if (httpStatus >= 400) {
|
||||
up.trigger('Error', {
|
||||
code : plupload.HTTP_ERROR,
|
||||
message : plupload.translate('HTTP Error.'),
|
||||
file : file,
|
||||
status : httpStatus
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
up.trigger('Error', {
|
||||
code : plupload.GENERIC_ERROR,
|
||||
message : plupload.translate('Generic Error.'),
|
||||
file : file,
|
||||
details : res.error
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function chunkAndUploadFile(native_file) {
|
||||
file.size = native_file.size;
|
||||
if (chunkSize) {
|
||||
browserPlus.FileAccess.chunk({file : native_file, chunkSize : chunkSize}, function(cr) {
|
||||
if (cr.success) {
|
||||
var chunks = cr.value, len = chunks.length;
|
||||
|
||||
loadProgress = Array(len);
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
loadProgress[i] = 0;
|
||||
chunkStack.push(chunks[i]);
|
||||
}
|
||||
|
||||
uploadFile(0, len);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
loadProgress = Array(1);
|
||||
chunkStack.push(native_file);
|
||||
uploadFile(0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Resize image if it's a supported format and resize is enabled
|
||||
if (resize && /\.(png|jpg|jpeg)$/i.test(file.name)) {
|
||||
BrowserPlus.ImageAlter.transform({
|
||||
file : nativeFile,
|
||||
quality : resize.quality || 90,
|
||||
actions : [{
|
||||
scale : {
|
||||
maxwidth : resize.width,
|
||||
maxheight : resize.height
|
||||
}
|
||||
}]
|
||||
}, function(res) {
|
||||
if (res.success) {
|
||||
chunkAndUploadFile(res.value.file);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chunkAndUploadFile(nativeFile);
|
||||
}
|
||||
});
|
||||
|
||||
callback({success : true});
|
||||
}
|
||||
|
||||
// Check for browserplus object
|
||||
if (browserPlus) {
|
||||
browserPlus.init(function(res) {
|
||||
var services = [
|
||||
{service: "Uploader", version: "3"},
|
||||
{service: "DragAndDrop", version: "1"},
|
||||
{service: "FileBrowse", version: "1"},
|
||||
{service: "FileAccess", version: "2"}
|
||||
];
|
||||
|
||||
if (resize) {
|
||||
services.push({service : 'ImageAlter', version : "4"});
|
||||
}
|
||||
|
||||
if (res.success) {
|
||||
browserPlus.require({
|
||||
services : services
|
||||
}, function(sres) {
|
||||
if (sres.success) {
|
||||
setup();
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
})(plupload);
|
||||
|
||||
@ -1 +1,446 @@
|
||||
(function(){if(window.google&&google.gears){return}var a=null;if(typeof GearsFactory!="undefined"){a=new GearsFactory()}else{try{a=new ActiveXObject("Gears.Factory");if(a.getBuildInfo().indexOf("ie_mobile")!=-1){a.privateSetGlobalObject(this)}}catch(b){if((typeof navigator.mimeTypes!="undefined")&&navigator.mimeTypes["application/x-googlegears"]){a=document.createElement("object");a.style.display="none";a.width=0;a.height=0;a.type="application/x-googlegears";document.documentElement.appendChild(a)}}}if(!a){return}if(!window.google){window.google={}}if(!google.gears){google.gears={factory:a}}})();(function(e,b,c,d){var f={};function a(h,j,l){var g,i,k,n;i=google.gears.factory.create("beta.canvas");try{i.decode(h);if(!j.width){j.width=i.width}if(!j.height){j.height=i.height}n=Math.min(width/i.width,height/i.height);if(n<1||(n===1&&l==="image/jpeg")){i.resize(Math.round(i.width*n),Math.round(i.height*n));if(j.quality){return i.encode(l,{quality:j.quality/100})}return i.encode(l)}}catch(m){}return h}c.runtimes.Gears=c.addRuntime("gears",{getFeatures:function(){return{dragdrop:true,jpgresize:true,pngresize:true,chunks:true,progress:true,multipart:true,multi_selection:true}},init:function(k,m){var l,h,g=false;if(!e.google||!google.gears){return m({success:false})}try{l=google.gears.factory.create("beta.desktop")}catch(j){return m({success:false})}function i(p){var o,n,q=[],r;for(n=0;n<p.length;n++){o=p[n];r=c.guid();f[r]=o.blob;q.push(new c.File(r,o.name,o.blob.length))}k.trigger("FilesAdded",q)}k.bind("PostInit",function(){var o=k.settings,n=b.getElementById(o.drop_element);if(n){c.addEvent(n,"dragover",function(p){l.setDropEffect(p,"copy");p.preventDefault()},k.id);c.addEvent(n,"drop",function(q){var p=l.getDragData(q,"application/x-gears-files");if(p){i(p.files)}q.preventDefault()},k.id);n=0}c.addEvent(b.getElementById(o.browse_button),"click",function(t){var s=[],q,p,r;t.preventDefault();if(g){return}no_type_restriction:for(q=0;q<o.filters.length;q++){r=o.filters[q].extensions.split(",");for(p=0;p<r.length;p++){if(r[p]==="*"){s=[];break no_type_restriction}s.push("."+r[p])}}l.openFiles(i,{singleFile:!o.multi_selection,filter:s})},k.id)});k.bind("CancelUpload",function(){if(h.abort){h.abort()}});k.bind("UploadFile",function(t,q){var v=0,u,r,s=0,p=t.settings.resize,n;if(p&&/\.(png|jpg|jpeg)$/i.test(q.name)){f[q.id]=a(f[q.id],p,/\.png$/i.test(q.name)?"image/png":"image/jpeg")}q.size=f[q.id].length;r=t.settings.chunk_size;n=r>0;u=Math.ceil(q.size/r);if(!n){r=q.size;u=1}function o(){var B,x=t.settings.multipart,w=0,A={name:q.target_name||q.name},y=t.settings.url;function z(D){var C,I="----pluploadboundary"+c.guid(),F="--",H="\r\n",E,G;if(x){h.setRequestHeader("Content-Type","multipart/form-data; boundary="+I);C=google.gears.factory.create("beta.blobbuilder");c.each(c.extend(A,t.settings.multipart_params),function(K,J){C.append(F+I+H+'Content-Disposition: form-data; name="'+J+'"'+H+H);C.append(K+H)});G=c.mimeTypes[q.name.replace(/^.+\.([^.]+)/,"$1").toLowerCase()]||"application/octet-stream";C.append(F+I+H+'Content-Disposition: form-data; name="'+t.settings.file_data_name+'"; filename="'+q.name+'"'+H+"Content-Type: "+G+H+H);C.append(D);C.append(H+F+I+F+H);E=C.getAsBlob();w=E.length-D.length;D=E}h.send(D)}if(q.status==c.DONE||q.status==c.FAILED||t.state==c.STOPPED){return}if(n){A.chunk=v;A.chunks=u}B=Math.min(r,q.size-(v*r));if(!x){y=c.buildUrl(t.settings.url,A)}h=google.gears.factory.create("beta.httprequest");h.open("POST",y);if(!x){h.setRequestHeader("Content-Disposition",'attachment; filename="'+q.name+'"');h.setRequestHeader("Content-Type","application/octet-stream")}c.each(t.settings.headers,function(D,C){h.setRequestHeader(C,D)});h.upload.onprogress=function(C){q.loaded=s+C.loaded-w;t.trigger("UploadProgress",q)};h.onreadystatechange=function(){var C;if(h.readyState==4&&t.state!==c.STOPPED){if(h.status==200){C={chunk:v,chunks:u,response:h.responseText,status:h.status};t.trigger("ChunkUploaded",q,C);if(C.cancelled){q.status=c.FAILED;return}s+=B;if(++v>=u){q.status=c.DONE;t.trigger("FileUploaded",q,{response:h.responseText,status:h.status})}else{o()}}else{t.trigger("Error",{code:c.HTTP_ERROR,message:c.translate("HTTP Error."),file:q,chunk:v,chunks:u,status:h.status})}}};if(v<u){z(f[q.id].slice(v*r,B))}}o()});k.bind("DisableBrowse",function(n,o){g=o});k.bind("Destroy",function(n){var o,p,q={browseButton:n.settings.browse_button,dropElm:n.settings.drop_element};for(o in q){p=b.getElementById(q[o]);if(p){c.removeAllEvents(p,n.id)}}});m({success:true})}})})(window,document,plupload);
|
||||
/**
|
||||
* plupload.gears.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, google:false, GearsFactory:false, ActiveXObject:false */
|
||||
|
||||
// Copyright 2007, Google Inc.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// 3. Neither the name of Google Inc. nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Sets up google.gears.*, which is *the only* supported way to access Gears.
|
||||
//
|
||||
// Circumvent this file at your own risk!
|
||||
//
|
||||
// In the future, Gears may automatically define google.gears.* without this
|
||||
// file. Gears may use these objects to transparently fix bugs and compatibility
|
||||
// issues. Applications that use the code below will continue to work seamlessly
|
||||
// when that happens.
|
||||
|
||||
(function() {
|
||||
// We are already defined. Hooray!
|
||||
if (window.google && google.gears) {
|
||||
return;
|
||||
}
|
||||
|
||||
var factory = null;
|
||||
|
||||
// Firefox
|
||||
if (typeof GearsFactory != 'undefined') {
|
||||
factory = new GearsFactory();
|
||||
} else {
|
||||
// IE
|
||||
try {
|
||||
factory = new ActiveXObject('Gears.Factory');
|
||||
// privateSetGlobalObject is only required and supported on WinCE.
|
||||
if (factory.getBuildInfo().indexOf('ie_mobile') != -1) {
|
||||
factory.privateSetGlobalObject(this);
|
||||
}
|
||||
} catch (e) {
|
||||
// Safari
|
||||
if ((typeof navigator.mimeTypes != 'undefined') && navigator.mimeTypes["application/x-googlegears"]) {
|
||||
factory = document.createElement("object");
|
||||
factory.style.display = "none";
|
||||
factory.width = 0;
|
||||
factory.height = 0;
|
||||
factory.type = "application/x-googlegears";
|
||||
document.documentElement.appendChild(factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// *Do not* define any objects if Gears is not installed. This mimics the
|
||||
// behavior of Gears defining the objects in the future.
|
||||
if (!factory) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Now set up the objects, being careful not to overwrite anything.
|
||||
//
|
||||
// Note: In Internet Explorer for Windows Mobile, you can't add properties to
|
||||
// the window object. However, global objects are automatically added as
|
||||
// properties of the window object in all browsers.
|
||||
if (!window.google) {
|
||||
window.google = {};
|
||||
}
|
||||
|
||||
if (!google.gears) {
|
||||
google.gears = {factory: factory};
|
||||
}
|
||||
})();
|
||||
|
||||
(function(window, document, plupload, undef) {
|
||||
var blobs = {};
|
||||
|
||||
function scaleImage(image_blob, resize, mime) {
|
||||
var percentage, canvas, context, scale;
|
||||
|
||||
// Setup canvas and scale
|
||||
canvas = google.gears.factory.create('beta.canvas');
|
||||
try {
|
||||
canvas.decode(image_blob);
|
||||
|
||||
if (!resize.width) {
|
||||
resize.width = canvas.width;
|
||||
}
|
||||
|
||||
if (!resize.height) {
|
||||
resize.height = canvas.height;
|
||||
}
|
||||
|
||||
scale = Math.min(resize.width / canvas.width, resize.height / canvas.height);
|
||||
|
||||
if (scale < 1) {
|
||||
canvas.resize(Math.round(canvas.width * scale), Math.round(canvas.height * scale));
|
||||
} else if (!resize.quality || mime !== 'image/jpeg') {
|
||||
return image_blob;
|
||||
}
|
||||
|
||||
if (resize.quality) {
|
||||
return canvas.encode(mime, {quality : resize.quality / 100});
|
||||
}
|
||||
|
||||
return canvas.encode(mime);
|
||||
} catch (e) {
|
||||
// Ignore for example when a user uploads a file that can't be decoded
|
||||
}
|
||||
|
||||
return image_blob;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gears implementation. This runtime supports these features: dragdrop, jpgresize, pngresize, chunks.
|
||||
*
|
||||
* @static
|
||||
* @class plupload.runtimes.Gears
|
||||
* @extends plupload.Runtime
|
||||
*/
|
||||
plupload.runtimes.Gears = plupload.addRuntime("gears", {
|
||||
/**
|
||||
* Returns a list of supported features for the runtime.
|
||||
*
|
||||
* @return {Object} Name/value object with supported features.
|
||||
*/
|
||||
getFeatures : function() {
|
||||
return {
|
||||
dragdrop: true,
|
||||
jpgresize: true,
|
||||
pngresize: true,
|
||||
chunks: true,
|
||||
progress: true,
|
||||
multipart: true,
|
||||
multi_selection: true
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the upload runtime.
|
||||
*
|
||||
* @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 desktop, req, disabled = false;
|
||||
|
||||
// Check for gears support
|
||||
if (!window.google || !google.gears) {
|
||||
return callback({success : false});
|
||||
}
|
||||
|
||||
try {
|
||||
desktop = google.gears.factory.create('beta.desktop');
|
||||
} catch (e) {
|
||||
// Might fail on the latest Gecko build for some odd reason
|
||||
return callback({success : false});
|
||||
}
|
||||
|
||||
function addSelectedFiles(selected_files) {
|
||||
var file, i, files = [], id;
|
||||
|
||||
// Add the selected files to the file queue
|
||||
for (i = 0; i < selected_files.length; i++) {
|
||||
file = selected_files[i];
|
||||
|
||||
// Store away gears blob internally
|
||||
id = plupload.guid();
|
||||
blobs[id] = file.blob;
|
||||
|
||||
files.push(new plupload.File(id, file.name, file.blob.length));
|
||||
}
|
||||
|
||||
// Fire FilesAdded event
|
||||
uploader.trigger("FilesAdded", files);
|
||||
}
|
||||
|
||||
// Add drop handler
|
||||
uploader.bind("PostInit", function() {
|
||||
var settings = uploader.settings, dropElm = document.getElementById(settings.drop_element);
|
||||
|
||||
if (dropElm) {
|
||||
// Block browser default drag over
|
||||
plupload.addEvent(dropElm, 'dragover', function(e) {
|
||||
desktop.setDropEffect(e, 'copy');
|
||||
e.preventDefault();
|
||||
}, uploader.id);
|
||||
|
||||
// Attach drop handler and grab files from Gears
|
||||
plupload.addEvent(dropElm, 'drop', function(e) {
|
||||
var dragData = desktop.getDragData(e, 'application/x-gears-files');
|
||||
|
||||
if (dragData) {
|
||||
addSelectedFiles(dragData.files);
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
}, uploader.id);
|
||||
|
||||
// Prevent IE leak
|
||||
dropElm = 0;
|
||||
}
|
||||
|
||||
// Add browse button
|
||||
plupload.addEvent(document.getElementById(settings.browse_button), 'click', function(e) {
|
||||
var filters = [], i, a, ext;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
no_type_restriction:
|
||||
for (i = 0; i < settings.filters.length; i++) {
|
||||
ext = settings.filters[i].extensions.split(',');
|
||||
|
||||
for (a = 0; a < ext.length; a++) {
|
||||
if (ext[a] === '*') {
|
||||
filters = [];
|
||||
break no_type_restriction;
|
||||
}
|
||||
|
||||
filters.push('.' + ext[a]);
|
||||
}
|
||||
}
|
||||
|
||||
desktop.openFiles(addSelectedFiles, {singleFile : !settings.multi_selection, filter : filters});
|
||||
}, uploader.id);
|
||||
});
|
||||
|
||||
|
||||
uploader.bind("CancelUpload", function() {
|
||||
if (req.abort) {
|
||||
req.abort();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
uploader.bind("UploadFile", function(up, file) {
|
||||
var chunk = 0, chunks, chunkSize, loaded = 0, resize = up.settings.resize, chunking;
|
||||
|
||||
// If file is png or jpeg and resize is configured then resize it
|
||||
if (resize && /\.(png|jpg|jpeg)$/i.test(file.name)) {
|
||||
blobs[file.id] = scaleImage(blobs[file.id], resize, /\.png$/i.test(file.name) ? 'image/png' : 'image/jpeg');
|
||||
}
|
||||
|
||||
file.size = blobs[file.id].length;
|
||||
|
||||
chunkSize = up.settings.chunk_size;
|
||||
chunking = chunkSize > 0;
|
||||
chunks = Math.ceil(file.size / chunkSize);
|
||||
|
||||
// If chunking is disabled then upload the whole file in one huge chunk
|
||||
if (!chunking) {
|
||||
chunkSize = file.size;
|
||||
chunks = 1;
|
||||
}
|
||||
|
||||
function uploadNextChunk() {
|
||||
var curChunkSize, multipart = up.settings.multipart, multipartLength = 0, reqArgs = {name : file.target_name || file.name}, url = up.settings.url;
|
||||
|
||||
// Sends the binary blob multipart encoded or raw depending on config
|
||||
function sendBinaryBlob(blob) {
|
||||
var builder, boundary = '----pluploadboundary' + plupload.guid(), dashdash = '--', crlf = '\r\n', multipartBlob, mimeType;
|
||||
|
||||
// Build multipart request
|
||||
if (multipart) {
|
||||
req.setRequestHeader('Content-Type', 'multipart/form-data; boundary=' + boundary);
|
||||
builder = google.gears.factory.create('beta.blobbuilder');
|
||||
|
||||
// Append mutlipart parameters
|
||||
plupload.each(plupload.extend(reqArgs, up.settings.multipart_params), function(value, name) {
|
||||
builder.append(
|
||||
dashdash + boundary + crlf +
|
||||
'Content-Disposition: form-data; name="' + name + '"' + crlf + crlf
|
||||
);
|
||||
|
||||
builder.append(value + crlf);
|
||||
});
|
||||
|
||||
mimeType = plupload.mimeTypes[file.name.replace(/^.+\.([^.]+)/, '$1').toLowerCase()] || 'application/octet-stream';
|
||||
|
||||
// Add file header
|
||||
builder.append(
|
||||
dashdash + boundary + crlf +
|
||||
'Content-Disposition: form-data; name="' + up.settings.file_data_name + '"; filename="' + file.name + '"' + crlf +
|
||||
'Content-Type: ' + mimeType + crlf + crlf
|
||||
);
|
||||
|
||||
// Add file data
|
||||
builder.append(blob);
|
||||
|
||||
// Add footer
|
||||
builder.append(crlf + dashdash + boundary + dashdash + crlf);
|
||||
multipartBlob = builder.getAsBlob();
|
||||
multipartLength = multipartBlob.length - blob.length;
|
||||
blob = multipartBlob;
|
||||
}
|
||||
|
||||
// Send blob or multipart blob depending on config
|
||||
req.send(blob);
|
||||
}
|
||||
|
||||
// File upload finished
|
||||
if (file.status == plupload.DONE || file.status == plupload.FAILED || up.state == plupload.STOPPED) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only add chunking args if needed
|
||||
if (chunking) {
|
||||
reqArgs.chunk = chunk;
|
||||
reqArgs.chunks = chunks;
|
||||
}
|
||||
|
||||
// Setup current chunk size
|
||||
curChunkSize = Math.min(chunkSize, file.size - (chunk * chunkSize));
|
||||
|
||||
if (!multipart) {
|
||||
url = plupload.buildUrl(up.settings.url, reqArgs);
|
||||
}
|
||||
|
||||
req = google.gears.factory.create('beta.httprequest');
|
||||
req.open('POST', url);
|
||||
|
||||
// Add disposition and type if multipart is disabled
|
||||
if (!multipart) {
|
||||
req.setRequestHeader('Content-Disposition', 'attachment; filename="' + file.name + '"');
|
||||
req.setRequestHeader('Content-Type', 'application/octet-stream');
|
||||
}
|
||||
|
||||
// Set custom headers
|
||||
plupload.each(up.settings.headers, function(value, name) {
|
||||
req.setRequestHeader(name, value);
|
||||
});
|
||||
|
||||
req.upload.onprogress = function(progress) {
|
||||
file.loaded = loaded + progress.loaded - multipartLength;
|
||||
up.trigger('UploadProgress', file);
|
||||
};
|
||||
|
||||
req.onreadystatechange = function() {
|
||||
var chunkArgs;
|
||||
|
||||
if (req.readyState == 4 && up.state !== plupload.STOPPED) {
|
||||
if (req.status == 200) {
|
||||
chunkArgs = {
|
||||
chunk : chunk,
|
||||
chunks : chunks,
|
||||
response : req.responseText,
|
||||
status : req.status
|
||||
};
|
||||
|
||||
up.trigger('ChunkUploaded', file, chunkArgs);
|
||||
|
||||
// Stop upload
|
||||
if (chunkArgs.cancelled) {
|
||||
file.status = plupload.FAILED;
|
||||
return;
|
||||
}
|
||||
|
||||
loaded += curChunkSize;
|
||||
|
||||
if (++chunk >= chunks) {
|
||||
file.status = plupload.DONE;
|
||||
up.trigger('FileUploaded', file, {
|
||||
response : req.responseText,
|
||||
status : req.status
|
||||
});
|
||||
} else {
|
||||
uploadNextChunk();
|
||||
}
|
||||
} else {
|
||||
up.trigger('Error', {
|
||||
code : plupload.HTTP_ERROR,
|
||||
message : plupload.translate('HTTP Error.'),
|
||||
file : file,
|
||||
chunk : chunk,
|
||||
chunks : chunks,
|
||||
status : req.status
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (chunk < chunks) {
|
||||
sendBinaryBlob(blobs[file.id].slice(chunk * chunkSize, curChunkSize));
|
||||
}
|
||||
}
|
||||
|
||||
// Start uploading chunks
|
||||
uploadNextChunk();
|
||||
});
|
||||
|
||||
uploader.bind("DisableBrowse", function(up, state) {
|
||||
disabled = state;
|
||||
});
|
||||
|
||||
|
||||
uploader.bind("Destroy", function(up) {
|
||||
var name, element,
|
||||
elements = {
|
||||
browseButton: up.settings.browse_button,
|
||||
dropElm: up.settings.drop_element
|
||||
};
|
||||
|
||||
// Unbind event handlers
|
||||
for (name in elements) {
|
||||
element = document.getElementById(elements[name]);
|
||||
if (element) {
|
||||
plupload.removeAllEvents(element, up.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
callback({success : true});
|
||||
}
|
||||
});
|
||||
})(window, document, plupload);
|
||||
|
||||
@ -1 +1,430 @@
|
||||
(function(d,a,b,c){function e(f){return a.getElementById(f)}b.runtimes.Html4=b.addRuntime("html4",{getFeatures:function(){return{multipart:true,triggerDialog:(b.ua.gecko&&d.FormData||b.ua.webkit)}},init:function(f,g){f.bind("Init",function(p){var j=a.body,n,h="javascript",k,x,q,z=[],r=/MSIE/.test(navigator.userAgent),t=[],m=p.settings.filters,o,l,s,w;no_type_restriction:for(o=0;o<m.length;o++){l=m[o].extensions.split(/,/);for(w=0;w<l.length;w++){if(l[w]==="*"){t=[];break no_type_restriction}s=b.mimeTypes[l[w]];if(s&&b.inArray(s,t)===-1){t.push(s)}}}t=t.join(",");function v(){var B,y,i,A;q=b.guid();z.push(q);B=a.createElement("form");B.setAttribute("id","form_"+q);B.setAttribute("method","post");B.setAttribute("enctype","multipart/form-data");B.setAttribute("encoding","multipart/form-data");B.setAttribute("target",p.id+"_iframe");B.style.position="absolute";y=a.createElement("input");y.setAttribute("id","input_"+q);y.setAttribute("type","file");y.setAttribute("accept",t);y.setAttribute("size",1);A=e(p.settings.browse_button);if(p.features.triggerDialog&&A){b.addEvent(e(p.settings.browse_button),"click",function(C){if(!y.disabled){y.click()}C.preventDefault()},p.id)}b.extend(y.style,{width:"100%",height:"100%",opacity:0,fontSize:"99px",cursor:"pointer"});b.extend(B.style,{overflow:"hidden"});i=p.settings.shim_bgcolor;if(i){B.style.background=i}if(r){b.extend(y.style,{filter:"alpha(opacity=0)"})}b.addEvent(y,"change",function(F){var D=F.target,C,E=[],G;if(D.value){e("form_"+q).style.top=-1048575+"px";C=D.value.replace(/\\/g,"/");C=C.substring(C.length,C.lastIndexOf("/")+1);E.push(new b.File(q,C));if(!p.features.triggerDialog){b.removeAllEvents(B,p.id)}else{b.removeEvent(A,"click",p.id)}b.removeEvent(y,"change",p.id);v();if(E.length){f.trigger("FilesAdded",E)}}},p.id);B.appendChild(y);j.appendChild(B);p.refresh()}function u(){var i=a.createElement("div");i.innerHTML='<iframe id="'+p.id+'_iframe" name="'+p.id+'_iframe" src="'+h+':""" style="display:none"></iframe>';n=i.firstChild;j.appendChild(n);b.addEvent(n,"load",function(C){var D=C.target,B,y;if(!k){return}try{B=D.contentWindow.document||D.contentDocument||d.frames[D.id].document}catch(A){p.trigger("Error",{code:b.SECURITY_ERROR,message:b.translate("Security error."),file:k});return}y=B.body.innerHTML;if(y){k.status=b.DONE;k.loaded=1025;k.percent=100;p.trigger("UploadProgress",k);p.trigger("FileUploaded",k,{response:y})}},p.id)}if(p.settings.container){j=e(p.settings.container);if(b.getStyle(j,"position")==="static"){j.style.position="relative"}}p.bind("UploadFile",function(i,A){var B,y;if(A.status==b.DONE||A.status==b.FAILED||i.state==b.STOPPED){return}B=e("form_"+A.id);y=e("input_"+A.id);y.setAttribute("name",i.settings.file_data_name);B.setAttribute("action",i.settings.url);b.each(b.extend({name:A.target_name||A.name},i.settings.multipart_params),function(E,C){var D=a.createElement("input");b.extend(D,{type:"hidden",name:C,value:E});B.insertBefore(D,B.firstChild)});k=A;e("form_"+q).style.top=-1048575+"px";B.submit()});p.bind("FileUploaded",function(i){i.refresh()});p.bind("StateChanged",function(i){if(i.state==b.STARTED){u()}else{if(i.state==b.STOPPED){d.setTimeout(function(){b.removeEvent(n,"load",i.id);if(n.parentNode){n.parentNode.removeChild(n)}},0)}}b.each(i.files,function(A,y){if(A.status===b.DONE||A.status===b.FAILED){var B=e("form_"+A.id);if(B){B.parentNode.removeChild(B)}}})});p.bind("Refresh",function(y){var F,A,B,C,i,G,H,E,D;F=e(y.settings.browse_button);if(F){i=b.getPos(F,e(y.settings.container));G=b.getSize(F);H=e("form_"+q);E=e("input_"+q);b.extend(H.style,{top:i.y+"px",left:i.x+"px",width:G.w+"px",height:G.h+"px"});if(y.features.triggerDialog){if(b.getStyle(F,"position")==="static"){b.extend(F.style,{position:"relative"})}D=parseInt(F.style.zIndex,10);if(isNaN(D)){D=0}b.extend(F.style,{zIndex:D});b.extend(H.style,{zIndex:D-1})}B=y.settings.browse_button_hover;C=y.settings.browse_button_active;A=y.features.triggerDialog?F:H;if(B){b.addEvent(A,"mouseover",function(){b.addClass(F,B)},y.id);b.addEvent(A,"mouseout",function(){b.removeClass(F,B)},y.id)}if(C){b.addEvent(A,"mousedown",function(){b.addClass(F,C)},y.id);b.addEvent(a.body,"mouseup",function(){b.removeClass(F,C)},y.id)}}});f.bind("FilesRemoved",function(y,B){var A,C;for(A=0;A<B.length;A++){C=e("form_"+B[A].id);if(C){C.parentNode.removeChild(C)}}});f.bind("DisableBrowse",function(i,A){var y=a.getElementById("input_"+q);if(y){y.disabled=A}});f.bind("Destroy",function(i){var y,A,B,C={inputContainer:"form_"+q,inputFile:"input_"+q,browseButton:i.settings.browse_button};for(y in C){A=e(C[y]);if(A){b.removeAllEvents(A,i.id)}}b.removeAllEvents(a.body,i.id);b.each(z,function(E,D){B=e("form_"+E);if(B){j.removeChild(B)}})});v()});g({success:true})}})})(window,document,plupload);
|
||||
/**
|
||||
* plupload.html4.js
|
||||
*
|
||||
* Copyright 2010, Ryan Demmer
|
||||
* 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 plupload:false, window:false */
|
||||
|
||||
(function(window, document, plupload, undef) {
|
||||
function getById(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML4 implementation. This runtime has no special features it uses an form that posts files into an hidden iframe.
|
||||
*
|
||||
* @static
|
||||
* @class plupload.runtimes.Html4
|
||||
* @extends plupload.Runtime
|
||||
*/
|
||||
plupload.runtimes.Html4 = plupload.addRuntime("html4", {
|
||||
/**
|
||||
* Returns a list of supported features for the runtime.
|
||||
*
|
||||
* @return {Object} Name/value object with supported features.
|
||||
*/
|
||||
getFeatures : function() {
|
||||
// Only multipart feature
|
||||
return {
|
||||
multipart: true,
|
||||
|
||||
// WebKit and Gecko 2+ can trigger file dialog progrmmatically
|
||||
triggerDialog: (plupload.ua.gecko && window.FormData || plupload.ua.webkit)
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the upload runtime.
|
||||
*
|
||||
* @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) {
|
||||
uploader.bind("Init", function(up) {
|
||||
var container = document.body, iframe, url = "javascript", currentFile,
|
||||
input, currentFileId, fileIds = [], IE = /MSIE/.test(navigator.userAgent), mimes = [],
|
||||
filters = up.settings.filters, i, ext, type, y;
|
||||
|
||||
// Convert extensions to mime types list
|
||||
no_type_restriction:
|
||||
for (i = 0; i < filters.length; i++) {
|
||||
ext = filters[i].extensions.split(/,/);
|
||||
|
||||
for (y = 0; y < ext.length; y++) {
|
||||
|
||||
// If there's an asterisk in the list, then accept attribute is not required
|
||||
if (ext[y] === '*') {
|
||||
mimes = [];
|
||||
break no_type_restriction;
|
||||
}
|
||||
|
||||
type = plupload.mimeTypes[ext[y]];
|
||||
|
||||
if (type && plupload.inArray(type, mimes) === -1) {
|
||||
mimes.push(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mimes = mimes.join(',');
|
||||
|
||||
function createForm() {
|
||||
var form, input, bgcolor, browseButton;
|
||||
|
||||
// Setup unique id for form
|
||||
currentFileId = plupload.guid();
|
||||
|
||||
// Save id for Destroy handler
|
||||
fileIds.push(currentFileId);
|
||||
|
||||
// Create form
|
||||
form = document.createElement('form');
|
||||
form.setAttribute('id', 'form_' + currentFileId);
|
||||
form.setAttribute('method', 'post');
|
||||
form.setAttribute('enctype', 'multipart/form-data');
|
||||
form.setAttribute('encoding', 'multipart/form-data');
|
||||
form.setAttribute("target", up.id + '_iframe');
|
||||
form.style.position = 'absolute';
|
||||
|
||||
// Create input and set attributes
|
||||
input = document.createElement('input');
|
||||
input.setAttribute('id', 'input_' + currentFileId);
|
||||
input.setAttribute('type', 'file');
|
||||
input.setAttribute('accept', mimes);
|
||||
input.setAttribute('size', 1);
|
||||
|
||||
browseButton = getById(up.settings.browse_button);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Set input styles
|
||||
plupload.extend(input.style, {
|
||||
width : '100%',
|
||||
height : '100%',
|
||||
opacity : 0,
|
||||
fontSize: '99px', // force input element to be bigger then needed to occupy whole space
|
||||
cursor: 'pointer'
|
||||
});
|
||||
|
||||
plupload.extend(form.style, {
|
||||
overflow: 'hidden'
|
||||
});
|
||||
|
||||
// Show the container if shim_bgcolor is specified
|
||||
bgcolor = up.settings.shim_bgcolor;
|
||||
if (bgcolor) {
|
||||
form.style.background = bgcolor;
|
||||
}
|
||||
|
||||
// no opacity in IE
|
||||
if (IE) {
|
||||
plupload.extend(input.style, {
|
||||
filter : "alpha(opacity=0)"
|
||||
});
|
||||
}
|
||||
|
||||
// add change event
|
||||
plupload.addEvent(input, 'change', function(e) {
|
||||
var element = e.target, name, files = [], topElement;
|
||||
|
||||
if (element.value) {
|
||||
getById('form_' + currentFileId).style.top = -0xFFFFF + "px";
|
||||
|
||||
// Get file name
|
||||
name = element.value.replace(/\\/g, '/');
|
||||
name = name.substring(name.length, name.lastIndexOf('/') + 1);
|
||||
|
||||
// Push files
|
||||
files.push(new plupload.File(currentFileId, name));
|
||||
|
||||
// Clean-up events - they won't be needed anymore
|
||||
if (!up.features.triggerDialog) {
|
||||
plupload.removeAllEvents(form, up.id);
|
||||
} else {
|
||||
plupload.removeEvent(browseButton, 'click', up.id);
|
||||
}
|
||||
plupload.removeEvent(input, 'change', up.id);
|
||||
|
||||
// Create and position next form
|
||||
createForm();
|
||||
|
||||
// Fire FilesAdded event
|
||||
if (files.length) {
|
||||
uploader.trigger("FilesAdded", files);
|
||||
}
|
||||
}
|
||||
}, up.id);
|
||||
|
||||
// append to container
|
||||
form.appendChild(input);
|
||||
container.appendChild(form);
|
||||
|
||||
up.refresh();
|
||||
}
|
||||
|
||||
|
||||
function createIframe() {
|
||||
var temp = document.createElement('div');
|
||||
|
||||
// Create iframe using a temp div since IE 6 won't be able to set the name using setAttribute or iframe.name
|
||||
temp.innerHTML = '<iframe id="' + up.id + '_iframe" name="' + up.id + '_iframe" src="' + url + ':""" style="display:none"></iframe>';
|
||||
iframe = temp.firstChild;
|
||||
container.appendChild(iframe);
|
||||
|
||||
// Add IFrame onload event
|
||||
plupload.addEvent(iframe, 'load', function(e) {
|
||||
var n = e.target, el, result;
|
||||
|
||||
// Ignore load event if there is no file
|
||||
if (!currentFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
el = n.contentWindow.document || n.contentDocument || window.frames[n.id].document;
|
||||
} catch (ex) {
|
||||
// Probably a permission denied error
|
||||
up.trigger('Error', {
|
||||
code : plupload.SECURITY_ERROR,
|
||||
message : plupload.translate('Security error.'),
|
||||
file : currentFile
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Get result
|
||||
result = el.documentElement.innerText || el.documentElement.textContent;
|
||||
|
||||
// Assume no error
|
||||
if (result) {
|
||||
currentFile.status = plupload.DONE;
|
||||
currentFile.loaded = 1025;
|
||||
currentFile.percent = 100;
|
||||
|
||||
up.trigger('UploadProgress', currentFile);
|
||||
up.trigger('FileUploaded', currentFile, {
|
||||
response : result
|
||||
});
|
||||
}
|
||||
}, up.id);
|
||||
} // end createIframe
|
||||
|
||||
if (up.settings.container) {
|
||||
container = getById(up.settings.container);
|
||||
if (plupload.getStyle(container, 'position') === 'static') {
|
||||
container.style.position = 'relative';
|
||||
}
|
||||
}
|
||||
|
||||
// Upload file
|
||||
up.bind("UploadFile", function(up, file) {
|
||||
var form, input;
|
||||
|
||||
// File upload finished
|
||||
if (file.status == plupload.DONE || file.status == plupload.FAILED || up.state == plupload.STOPPED) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the form and input elements
|
||||
form = getById('form_' + file.id);
|
||||
input = getById('input_' + file.id);
|
||||
|
||||
// Set input element name attribute which allows it to be submitted
|
||||
input.setAttribute('name', up.settings.file_data_name);
|
||||
|
||||
// Store action
|
||||
form.setAttribute("action", up.settings.url);
|
||||
|
||||
// Append multipart parameters
|
||||
plupload.each(plupload.extend({name : file.target_name || file.name}, up.settings.multipart_params), function(value, name) {
|
||||
var hidden = document.createElement('input');
|
||||
|
||||
plupload.extend(hidden, {
|
||||
type : 'hidden',
|
||||
name : name,
|
||||
value : value
|
||||
});
|
||||
|
||||
form.insertBefore(hidden, form.firstChild);
|
||||
});
|
||||
|
||||
currentFile = file;
|
||||
|
||||
// Hide the current form
|
||||
getById('form_' + currentFileId).style.top = -0xFFFFF + "px";
|
||||
|
||||
form.submit();
|
||||
});
|
||||
|
||||
|
||||
|
||||
up.bind('FileUploaded', function(up) {
|
||||
up.refresh(); // just to get the form back on top of browse_button
|
||||
});
|
||||
|
||||
up.bind('StateChanged', function(up) {
|
||||
if (up.state == plupload.STARTED) {
|
||||
createIframe();
|
||||
} else if (up.state == plupload.STOPPED) {
|
||||
window.setTimeout(function() {
|
||||
plupload.removeEvent(iframe, 'load', up.id);
|
||||
if (iframe.parentNode) { // #382
|
||||
iframe.parentNode.removeChild(iframe);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
plupload.each(up.files, function(file, i) {
|
||||
if (file.status === plupload.DONE || file.status === plupload.FAILED) {
|
||||
var form = getById('form_' + file.id);
|
||||
|
||||
if(form){
|
||||
form.parentNode.removeChild(form);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Refresh button, will reposition the input form
|
||||
up.bind("Refresh", function(up) {
|
||||
var browseButton, topElement, hoverClass, activeClass, browsePos, browseSize, inputContainer, inputFile, zIndex;
|
||||
|
||||
browseButton = getById(up.settings.browse_button);
|
||||
if (browseButton) {
|
||||
browsePos = plupload.getPos(browseButton, getById(up.settings.container));
|
||||
browseSize = plupload.getSize(browseButton);
|
||||
inputContainer = getById('form_' + currentFileId);
|
||||
inputFile = getById('input_' + currentFileId);
|
||||
|
||||
plupload.extend(inputContainer.style, {
|
||||
top : browsePos.y + 'px',
|
||||
left : browsePos.x + 'px',
|
||||
width : browseSize.w + 'px',
|
||||
height : browseSize.h + 'px'
|
||||
});
|
||||
|
||||
// for IE and WebKit place input element underneath the browse button and route onclick event
|
||||
// TODO: revise when browser support for this feature will change
|
||||
if (up.features.triggerDialog) {
|
||||
if (plupload.getStyle(browseButton, 'position') === 'static') {
|
||||
plupload.extend(browseButton.style, {
|
||||
position : 'relative'
|
||||
});
|
||||
}
|
||||
|
||||
zIndex = parseInt(browseButton.style.zIndex, 10);
|
||||
|
||||
if (isNaN(zIndex)) {
|
||||
zIndex = 0;
|
||||
}
|
||||
|
||||
plupload.extend(browseButton.style, {
|
||||
zIndex : zIndex
|
||||
});
|
||||
|
||||
plupload.extend(inputContainer.style, {
|
||||
zIndex : zIndex - 1
|
||||
});
|
||||
}
|
||||
|
||||
/* Since we have to place input[type=file] on top of the browse_button for some browsers (FF, Opera),
|
||||
browse_button loses interactivity, here we try to neutralize this issue highlighting browse_button
|
||||
with a special class
|
||||
TODO: needs to be revised as things will change */
|
||||
hoverClass = up.settings.browse_button_hover;
|
||||
activeClass = up.settings.browse_button_active;
|
||||
topElement = up.features.triggerDialog ? browseButton : inputContainer;
|
||||
|
||||
if (hoverClass) {
|
||||
plupload.addEvent(topElement, 'mouseover', function() {
|
||||
plupload.addClass(browseButton, hoverClass);
|
||||
}, up.id);
|
||||
plupload.addEvent(topElement, 'mouseout', function() {
|
||||
plupload.removeClass(browseButton, hoverClass);
|
||||
}, up.id);
|
||||
}
|
||||
|
||||
if (activeClass) {
|
||||
plupload.addEvent(topElement, 'mousedown', function() {
|
||||
plupload.addClass(browseButton, activeClass);
|
||||
}, up.id);
|
||||
plupload.addEvent(document.body, 'mouseup', function() {
|
||||
plupload.removeClass(browseButton, activeClass);
|
||||
}, up.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Remove files
|
||||
uploader.bind("FilesRemoved", function(up, files) {
|
||||
var i, n;
|
||||
|
||||
for (i = 0; i < files.length; i++) {
|
||||
n = getById('form_' + files[i].id);
|
||||
if (n) {
|
||||
n.parentNode.removeChild(n);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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) {
|
||||
var name, element, form,
|
||||
elements = {
|
||||
inputContainer: 'form_' + currentFileId,
|
||||
inputFile: 'input_' + currentFileId,
|
||||
browseButton: up.settings.browse_button
|
||||
};
|
||||
|
||||
// Unbind event handlers
|
||||
for (name in elements) {
|
||||
element = getById(elements[name]);
|
||||
if (element) {
|
||||
plupload.removeAllEvents(element, up.id);
|
||||
}
|
||||
}
|
||||
plupload.removeAllEvents(document.body, up.id);
|
||||
|
||||
// Remove mark-up
|
||||
plupload.each(fileIds, function(id, i) {
|
||||
form = getById('form_' + id);
|
||||
if (form) {
|
||||
form.parentNode.removeChild(form);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Create initial form
|
||||
createForm();
|
||||
});
|
||||
|
||||
callback({success : true});
|
||||
}
|
||||
});
|
||||
})(window, document, plupload);
|
||||
|
||||