changed: plugin jQuery File Upload has been updated to version 9.7.0

(changed 'upload' and 'rm' winix functions)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@958 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2014-08-06 20:14:10 +00:00
parent 6614919c13
commit bfa5d8cc05
6 changed files with 229 additions and 221 deletions

View File

@ -465,18 +465,28 @@ void Rm::Clear()
void Rm::CreateJSON(bool status)
{
auto & out = cur->request->out_streams[0];
out << "{\"files\": [{\"";
JSONescape(out, cur->request->item.url);
out << "\": ";
if( status )
cur->request->out_streams[0] << "[true]\n";
out << "true";
else
cur->request->out_streams[0] << "[false]\n";
out << "false";
out << "}]}";
cur->request->page_generated = true;
cur->request->use_html_filter[0] = false;
}
void Rm::MakePost()
{
Prepare();

View File

@ -35,7 +35,7 @@ Upload::Upload()
void Upload::Init()
{
json_serializer.TreatAsTable(L"infospace");
json_serializer.TreatAsTable(L"files");
json_serializer.TreatAsNumeric(L"size");
}
@ -268,11 +268,11 @@ void Upload::MakePost()
void Upload::CreateAnswer()
{
Request & req = *cur->request;
req.info.name = L"infospace"; // 'infospace' will be serialized to an array
PT::Space & files = req.info.AddSpace(L"files"); // 'files' will be serialized to an array
for(size_t i=0 ; i<req.item_tab.size() ; ++i)
{
PT::Space & file = req.info.AddSpace(L"");
PT::Space & file = files.AddSpace(L"");
file.Add(L"name", req.item_tab[i].url);
file.Add(L"size", req.item_tab[i].file_size);
@ -280,23 +280,31 @@ void Upload::CreateAnswer()
std::wstring & link = file.Add(L"url", L"");
system->CreateItemLink(req.item_tab[i], link);
std::wstring & del_url = file.Add(L"delete_url", link);
std::wstring & del_url = file.Add(L"deleteUrl", link);
del_url += L"/rm/jquery_upload";
file.Add(L"delete_type", L"POST");
file.Add(L"deleteType", L"POST");
if( req.item_tab[i].file_type == WINIX_ITEM_FILETYPE_IMAGE )
{
std::wstring & thumb = file.Add(L"thumbnail_url", link);
std::wstring & thumb = file.Add(L"thumbnailUrl", link);
if( req.item_tab[i].has_thumb )
thumb += L"/-/thumb";
}
/*
* if there was an error add "error" item e.g.
* "error": "Filetype not allowed"
*/
}
cur->request->return_json = true;
cur->request->return_info_only = true;
cur->request->info_serializer = &json_serializer;
//cur->request->out_headers.Add(L"Content-Type", L"text/html");
}

View File

@ -5,190 +5,144 @@
[end]
[if winix_function_param_is "jquery_upload"]
\[
[for item_tab]
\{
"name":"[item_tab_url]",
"size":[item_tab_file_size],
"url":"[item_tab_link]",
[if item_tab_filetype_is_image]"thumbnail_url":"[if item_tab_has_thumb][item_tab_link]/-/thumb[else][item_tab_link][end]",[end]
"delete_url":"[item_tab_link]/rm/jquery_upload",
"delete_type":"POST"
\}
[if item_tab_has_next],[end]
[end]
\]
[end]
[if-any-no winix_function_param_is "ckeditor_upload" winix_function_param_is "jquery_upload"]
<div class="winix">
<h1>{upload_header}</h1>
[# The file upload form used as target for the file upload widget]
<form id="fileupload" action="[doc_base_url][dir]upload" method="post" enctype="multipart/form-data">
[# The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload]
<div class="row fileupload-buttonbar">
<div class="span7">
[# The fileinput-button span is used to style the file input field as button]
<span class="btn btn-success fileinput-button">
<i class="icon-plus icon-white"></i>
<span>{upload_button_add_files}</span>
<input type="file" name="files\[\]" multiple>
</span>
<button type="submit" class="btn btn-primary start">
<i class="icon-upload icon-white"></i>
<span>{upload_button_start_upload}</span>
</button>
<button type="reset" class="btn btn-warning cancel">
<i class="icon-ban-circle icon-white"></i>
<span>{upload_button_cancel_upload}</span>
</button>
<button type="button" class="btn btn-danger delete">
<i class="icon-trash icon-white"></i>
<span>{upload_button_delete}</span>
</button>
<input type="checkbox" class="toggle">
</div>
[# The global progress information]
<div class="span5 fileupload-progress fade">
[# The global progress bar]
<div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
<div class="bar" style="width:0%;"></div>
</div>
[# The extended global progress information]
<div class="progress-extended">&nbsp;</div>
</div>
[# the code below are copied from common/fileupload/jquery-ui.html]
[# The file upload form used as target for the file upload widget]
<form id="fileupload" action="[doc_base_url][dir]/upload" method="POST" enctype="multipart/form-data">
[# The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload]
<div class="fileupload-buttonbar">
<div class="fileupload-buttons">
[# The fileinput-button span is used to style the file input field as button]
<span class="fileinput-button">
<span>{upload_button_add_files}</span>
<input type="file" name="files\[\]" multiple>
</span>
<button type="submit" class="start">{upload_button_start_upload}</button>
<button type="reset" class="cancel">{upload_button_cancel_upload}</button>
<button type="button" class="delete">{upload_button_delete}</button>
<input type="checkbox" class="toggle">
[# The global file processing state]
<span class="fileupload-process"></span>
</div>
[# The global progress state]
<div class="fileupload-progress fade" style="display:none">
[# The global progress bar]
<div class="progress" role="progressbar" aria-valuemin="0" aria-valuemax="100"></div>
[# The extended global progress state]
<div class="progress-extended">&nbsp;</div>
</div>
[# The loading indicator is shown during file processing]
<div class="fileupload-loading"></div>
<br>
[# The table listing the files available for upload/download]
<table role="presentation" class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
</form>
[# modal-gallery is the modal dialog used for the image gallery]
<div id="modal-gallery" class="modal modal-gallery hide fade" data-filter=":odd">
<div class="modal-header">
<a class="close" data-dismiss="modal">&times;</a>
<h3 class="modal-title"></h3>
</div>
<div class="modal-body"><div class="modal-image"></div></div>
<div class="modal-footer">
<a class="btn modal-download" target="_blank">
<i class="icon-download"></i>
<span>{upload_button_download}</span>
</a>
<a class="btn btn-success modal-play modal-slideshow" data-slideshow="5000">
<i class="icon-play icon-white"></i>
<span>{upload_button_slideshow}</span>
</a>
<a class="btn btn-info modal-prev">
<i class="icon-arrow-left icon-white"></i>
<span>{upload_button_previous}</span>
</a>
<a class="btn btn-primary modal-next">
<span>{upload_button_next}</span>
<i class="icon-arrow-right icon-white"></i>
</a>
</div>
</div>
[# The table listing the files available for upload/download]
<table role="presentation"><tbody class="files"></tbody></table>
</form>
[# The template to display files available for upload]
<script id="template-upload" type="text/x-tmpl">
\{% for (var i=0, file; file=o.files\[i\]; i++) \{ %\}
<tr class="template-upload fade">
<td class="preview"><span class="fade"></span></td>
<td class="name"><span>\{%=file.name%\}</span></td>
<td class="size"><span>\{%=o.formatFileSize(file.size)%\}</span></td>
\{% if (file.error) \{ %\}
<td class="error" colspan="2"><span class="label label-important">\{%=locale.fileupload.error%\}</span> \{%=locale.fileupload.errors\[file.error\] || file.error%\}</td>
\{% \} else if (o.files.valid && !i) \{ %\}
<td>
<div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
</td>
<td class="start">\{% if (!o.options.autoUpload) \{ %\}
<button class="btn btn-primary">
<i class="icon-upload icon-white"></i>
<span>\{%=locale.fileupload.start%\}</span>
</button>
\{% \} %\}</td>
\{% \} else \{ %\}
<td colspan="2"></td>
\{% \} %\}
<td class="cancel">\{% if (!i) \{ %\}
<button class="btn btn-warning">
<i class="icon-ban-circle icon-white"></i>
<span>\{%=locale.fileupload.cancel%\}</span>
</button>
\{% \} %\}</td>
</tr>
\{% \} %\}
</script>
[# The template to display files available for download]
<script id="template-download" type="text/x-tmpl">
\{% for (var i=0, file; file=o.files\[i\]; i++) \{ %\}
<tr class="template-download fade">
\{% if (file.error) \{ %\}
<td></td>
<td class="name"><span>\{%=file.name%\}</span></td>
<td class="size"><span>\{%=o.formatFileSize(file.size)%\}</span></td>
<td class="error" colspan="2"><span class="label label-important">\{%=locale.fileupload.error%\}</span> \{%=locale.fileupload.errors\[file.error\] || file.error%\}</td>
\{% \} else \{ %\}
<td class="preview">\{% if (file.thumbnail_url) \{ %\}
<a href="\{%=file.url%\}" title="\{%=file.name%\}" rel="gallery" download="\{%=file.name%\}"><img src="\{%=file.thumbnail_url%\}"></a>
\{% \} %\}</td>
<td class="name">
<a href="\{%=file.url%\}" title="\{%=file.name%\}" rel="\{%=file.thumbnail_url&&'gallery'%\}" download="\{%=file.name%\}">\{%=file.name%\}</a>
</td>
<td class="size"><span>\{%=o.formatFileSize(file.size)%\}</span></td>
<td colspan="2"></td>
\{% \} %\}
<td class="delete">
<button class="btn btn-danger" data-type="\{%=file.delete_type%\}" data-url="\{%=file.delete_url%\}">
<i class="icon-trash icon-white"></i>
<span>{upload_button_delete}</span>
</button>
<input type="checkbox" name="delete" value="1">
</td>
</tr>
\{% \} %\}
</script>
[# The blueimp Gallery widget]
<div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls" data-filter=":even">
<div class="slides"></div>
<h3 class="title"></h3>
<a class="prev"></a>
<a class="next"></a>
<a class="close">×</a>
<a class="play-pause"></a>
<ol class="indicator"></ol>
</div>
[# The template to display files available for upload]
<script id="template-upload" type="text/x-tmpl">
\{% for (var i=0, file; file=o.files\[i\]; i++) \{ %\}
<tr class="template-upload fade">
<td>
<span class="preview"></span>
</td>
<td>
<p class="name">\{%=file.name%\}</p>
<strong class="error"></strong>
</td>
<td>
<p class="size">{upload_button_processing}</p>
<div class="progress"></div>
</td>
<td>
\{% if (!i && !o.options.autoUpload) \{ %\}
<button class="start" disabled>{upload_button_start}</button>
\{% \} %\}
\{% if (!i) \{ %\}
<button class="cancel">{upload_button_cancel}</button>
\{% \} %\}
</td>
</tr>
\{% \} %\}</script>
[# The template to display files available for download]
<script id="template-download" type="text/x-tmpl">
\{% for (var i=0, file; file=o.files\[i\]; i++) \{ %\}
<tr class="template-download fade">
<td>
<span class="preview">
\{% if (file.thumbnailUrl) \{ %\}
<a href="\{%=file.url%\}" title="\{%=file.name%\}" download="\{%=file.name%\}" data-gallery><img src="\{%=file.thumbnailUrl%\}"></a>
\{% \} %\}
</span>
</td>
<td>
<p class="name">
<a href="\{%=file.url%\}" title="\{%=file.name%\}" download="\{%=file.name%\}" \{%=file.thumbnailUrl?'data-gallery':''%\}>\{%=file.name%\}</a>
</p>
\{% if (file.error) \{ %\}
<div><span class="error">{upload_error}</span> \{%=file.error%\}</div>
\{% \} %\}
</td>
<td>
<span class="size">\{%=o.formatFileSize(file.size)%\}</span>
</td>
<td>
<button class="delete" data-type="\{%=file.deleteType%\}" data-url="\{%=file.deleteUrl%\}"\{% if (file.deleteWithCredentials) \{ %\} data-xhr-fields='\{"withCredentials":true\}'\{% \} %\}>{upload_button_delete}</button>
<input type="checkbox" name="delete" value="1" class="toggle">
</td>
</tr>
\{% \} %\}</script>
<script type="text/javascript">
$('#fileupload button.start').css('display', 'none');
$('#fileupload button.start').css('display', 'none');
$('#fileupload').fileupload(\{
"url": "[doc_base_url][dir]upload/jquery_upload",
"autoUpload": true
\});
$('#fileupload').fileupload(\{
"url": "[doc_base_url][dir]upload/jquery_upload",
"autoUpload": true
\});
$('#fileupload').fileupload(
'option',
'redirect',
window.location.href.replace(
/\/\[^\/\]*$/,
'/cors/result.html?%s'
)
);
$('#fileupload').fileupload(
'option',
'redirect',
window.location.href.replace(
/\/\[^\/\]*$/,
'/cors/result.html?%s'
));
$("div.winix #fileupload button.cancel").css('display','inline');
[# loading existing files]
[# copied from common/fileupload/js/main.js]
$('#fileupload').addClass('fileupload-processing');
$.ajax(\{
[# // Uncomment the following to send cross-domain cookies:]
[# //xhrFields: \{withCredentials: true\},]
url: $('#fileupload').fileupload('option', 'url'),
dataType: 'json',
context: $('#fileupload')\[0\]
\}).always(function () \{
$(this).removeClass('fileupload-processing');
\}).done(function (result) \{
$(this).fileupload('option', 'done')
.call(this, $.Event('done'), \{result: result\});
\});</script>
$('#fileupload').each(function () \{
var that = this;
$.getJSON(this.action + '/jquery_upload', function (result) \{
if (result && result.length) \{
$(that).fileupload('option', 'done')
.call(that, null, \{result: result\});
\}
\});
\});</script>
</div>

View File

@ -114,68 +114,104 @@
[if winix_function_is "upload"]
[# http://blueimp.github.io/jQuery-File-Upload/jquery-ui.html]
[# https://github.com/blueimp/jQuery-File-Upload]
[# we are using the *jQuery UI version* of the plugin]
[# Bootstrap CSS Toolkit styles]
[# I downloaded bootstrap.min.css and removed some normal elements from it such as html, body etc ]
[# I left only items with a class set]
[# <link rel="stylesheet" href="http://blueimp.github.com/cdn/css/bootstrap.min.css"> ]
<link rel="stylesheet" href="[doc_base_url_common]/fileupload/others/bootstrap_custom_for_jqupload.css" type="text/css">
[# Force latest IE rendering engine or ChromeFrame if installed]
<!--\[if IE\]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!\[endif\]-->
[# Generic page styles, removed, only one item there is there]
[# <link rel="stylesheet" href=".../fileupload/css/style.css"> ]
[# Bootstrap styles for responsive website layout, supporting different screen sizes]
<link rel="stylesheet" href="[doc_base_url_common]/fileupload/others/bootstrap-responsive.min.css" type="text/css">
[# Bootstrap CSS fixes for IE6]
<!--\[if lt IE 7\]><link rel="stylesheet" href="[doc_base_url_common]/fileupload/others/bootstrap-ie6.min.css" type="text/css"><!\[endif\]-->
[# jQuery UI styles]
[# original http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/dark-hive/jquery-ui.css]
<link rel="stylesheet" href="[doc_base_url_common]/jquery-ui-1.10.4.custom/css/smoothness/jquery-ui-1.10.4.custom.min.css" id="theme">
[# Bootstrap Image Gallery styles]
<link rel="stylesheet" href="[doc_base_url_common]/fileupload/others/Bootstrap-Image-Gallery/css/bootstrap-image-gallery.min.css" type="text/css">
[if false]
<!-- Demo styles -->
<link rel="stylesheet" href="[doc_base_url_common]/fileupload/css/demo.css">
<!--\[if lte IE 8\]>
<link rel="stylesheet" href="[doc_base_url_common]/fileupload/css/demo-ie8.css">
<!\[endif\]-->
[end]
[# blueimp Gallery styles]
[# original http://blueimp.github.io/Gallery/css/blueimp-gallery.min.css]
<link rel="stylesheet" href="[doc_base_url_common]/gallery-2.15.1/css/blueimp-gallery.min.css">
[# CSS to style the file input field as button and adjust the Bootstrap progress bars]
<link rel="stylesheet" href="[doc_base_url_common]/fileupload/css/jquery.fileupload-ui.css" type="text/css">
<link rel="stylesheet" href="[doc_base_url_common]/fileupload/css/jquery.fileupload.css">
<link rel="stylesheet" href="[doc_base_url_common]/fileupload/css/jquery.fileupload-ui.css">
[# Shim to make HTML5 elements usable in older Internet Explorer versions]
<!--\[if lt IE 9\]><script src="[doc_base_url_common]/fileupload/others/html5.js" type="text/javascript"></script><!\[endif\]-->
[# CSS adjustments for browsers with JavaScript disabled]
<noscript><link rel="stylesheet" href="[doc_base_url_common]/fileupload/css/jquery.fileupload-noscript.css"></noscript>
<noscript><link rel="stylesheet" href="[doc_base_url_common]/fileupload/css/jquery.fileupload-ui-noscript.css"></noscript>
[# can be moved to the end of a page (before </html> tag) ]
<script type="text/javascript" src="[doc_base_url_common]/jquery-1.7.2.min.js"></script>
[# those below can be moved to the bottom of the page (outside of <head>]
[# The jQuery UI widget factory, can be omitted if jQuery UI is already included]
<script type="text/javascript" src="[doc_base_url_common]/fileupload/js/vendor/jquery.ui.widget.js"></script>
[# original //ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js]
<script src="[doc_base_url_common]/jquery-1.11.0.min.js"></script>
[# original //ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js]
<script src="[doc_base_url_common]/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
[# The Templates plugin is included to render the upload/download listings]
<script type="text/javascript" src="[doc_base_url_common]/fileupload/others/JavaScript-Templates/tmpl.min.js"></script>
[# original http://blueimp.github.io/JavaScript-Templates/js/tmpl.min.js]
<script src="[doc_base_url_common]/fileupload/others/tmpl.min.js"></script>
[# The Load Image plugin is included for the preview images and image resizing functionality]
<script type="text/javascript" src="[doc_base_url_common]/fileupload/others/JavaScript-Load-Image/load-image.min.js"></script>
[# original http://blueimp.github.io/JavaScript-Load-Image/js/load-image.min.js]
<script src="[doc_base_url_common]/fileupload/others/load-image.min.js"></script>
[# The Canvas to Blob plugin is included for image resizing functionality]
<script type="text/javascript" src="[doc_base_url_common]/fileupload/others/JavaScript-Canvas-to-Blob/canvas-to-blob.min.js"></script>
[# original http://blueimp.github.io/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js]
<script src="[doc_base_url_common]/fileupload/others/canvas-to-blob.min.js"></script>
[# Bootstrap JS and Bootstrap Image Gallery are not required, but included for the demo]
<script type="text/javascript" src="[doc_base_url_common]/fileupload/others/bootstrap.min.js"></script>
<script type="text/javascript" src="[doc_base_url_common]/fileupload/others/Bootstrap-Image-Gallery/js/bootstrap-image-gallery.min.js"></script>
[# blueimp Gallery script]
[# original http://blueimp.github.io/Gallery/js/jquery.blueimp-gallery.min.js]
<script src="[doc_base_url_common]/gallery-2.15.1/js/jquery.blueimp-gallery.min.js"></script>
[# The Iframe Transport is required for browsers without support for XHR file uploads]
<script type="text/javascript" src="[doc_base_url_common]/fileupload/js/jquery.iframe-transport.js"></script>
<script src="[doc_base_url_common]/fileupload/js/jquery.iframe-transport.js"></script>
[# The basic File Upload plugin]
<script type="text/javascript" src="[doc_base_url_common]/fileupload/js/jquery.fileupload.js"></script>
[# The File Upload file processing plugin]
<script type="text/javascript" src="[doc_base_url_common]/fileupload/js/jquery.fileupload-fp.js"></script>
<script src="[doc_base_url_common]/fileupload/js/jquery.fileupload.js"></script>
[# The File Upload processing plugin]
<script src="[doc_base_url_common]/fileupload/js/jquery.fileupload-process.js"></script>
[# The File Upload image preview & resize plugin]
<script src="[doc_base_url_common]/fileupload/js/jquery.fileupload-image.js"></script>
[# The File Upload audio preview plugin]
<script src="[doc_base_url_common]/fileupload/js/jquery.fileupload-audio.js"></script>
[# The File Upload video preview plugin]
<script src="[doc_base_url_common]/fileupload/js/jquery.fileupload-video.js"></script>
[# The File Upload validation plugin]
<script src="[doc_base_url_common]/fileupload/js/jquery.fileupload-validate.js"></script>
[# The File Upload user interface plugin]
<script type="text/javascript" src="[doc_base_url_common]/fileupload/js/jquery.fileupload-ui.js"></script>
[# The localization script]
<script type="text/javascript" src="[doc_base_url_common]/fileupload/js/locale.js"></script>
<script src="[doc_base_url_common]/fileupload/js/jquery.fileupload-ui.js"></script>
[# do not load main.js - it is at the end of fun_upload.html ]
[# The File Upload jQuery UI plugin]
<script src="[doc_base_url_common]/fileupload/js/jquery.fileupload-jquery-ui.js"></script>
[if false]
[# code from fileupload/js/main.js we are using in fun_upload.html (at the bottom)]
<!-- The main application script -->
<script src="[doc_base_url_common]/fileupload/js/main.js"></script>
[end]
[# The XDomainRequest Transport is included for cross-domain file deletion for IE8+]
<!--\[if gte IE 8\]><script type="text/javascript" src="[doc_base_url_common]/fileupload/js/cors/jquery.xdr-transport.js"></script><!\[endif\]-->
[# The XDomainRequest Transport is included for cross-domain file deletion for IE 8 and IE 9]
<!--\[if (gte IE 8)&(lt IE 10)\]>
<script src="[doc_base_url_common]/fileupload/js/cors/jquery.xdr-transport.js"></script>
<!\[endif\]-->
[end]

View File

@ -294,13 +294,14 @@ template_form_from_mount_point = from the mount point
upload_header = Files manager
upload_button_add_files = Add files...
upload_button_start = Start
upload_button_cancel = Cancel
upload_button_start_upload = Start upload
upload_button_cancel_upload = Cancel upload
upload_button_delete = Delete
upload_button_processing = Processing...
upload_button_download = Download
upload_button_slideshow = Slideshow
upload_button_previous = Previous
upload_button_next = Next
upload_error = Error:
who_header = Sessions
who_tab_index = Ind.

View File

@ -315,15 +315,14 @@ template_form_from_mount_point = z punktu montowania
upload_header = Menedżer plików
upload_button_add_files = Dodaj pliki...
upload_button_start = Wysyłaj
upload_button_cancel = Anuluj
upload_button_start_upload = Wysyłaj
upload_button_cancel_upload = Przerwij wysyłanie
upload_button_delete = Usuń
upload_button_processing = Wysyłanie...
upload_button_download = Ściągnij
upload_button_slideshow = Pokaz slajdów
upload_button_previous = Poprzedni
upload_button_next = Następny
upload_error = Błąd:
who_header = Lista sesji
who_tab_index = L.p.