new style, drag and drop and progressbar

This commit is contained in:
Abdulrahman
2019-01-14 21:08:56 +03:00
parent 2ba938e17c
commit 52b41e6ce3
22 changed files with 1201 additions and 0 deletions

8
styles/dragdrop/.idea/dragdrop.iml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,48 @@
/* Essential FileDrop zone element configuration: */
.fd-zone {
border: 2px solid #abb0b7 !important;
position: relative;
overflow: hidden;
/* The following are not required but create a pretty box: */
width: 100%;
padding: 40px 0;
margin: 0 auto;
text-align: center;
color: #414446 !important;
border-radius: 20px;
background: #d9edf7 url(../images/striped_lens.png);
}
.fd-zone-current{
background: #76858e !important;
color: #414446 !important;
}
.fd-zone p span, .fd-zone h3 span{
text-shadow: 2px 2px #fff;
}
.fd-zone p.img{
width: 120px;
margin: 0 auto;
height: 120px;
background-size: 120px 120px;
background-repeat: no-repeat;
background-image: url(../images/download2.png);
}
/* Hides <input type="file"> while simulating "Browse" button: */
.fd-file {
opacity: 0;
font-size: 118px;
position: absolute;
right: 0;
top: 0;
z-index: 1;
padding: 0;
margin: 0;
cursor: pointer;
filter: alpha(opacity=0);
font-family: sans-serif;
}

1
styles/dragdrop/css/index.html Executable file
View File

@@ -0,0 +1 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1256" /><title>Powered by Kleeja</title><style type="text/css">* {font-size: 100%;margin:0;padding: 0; color:#CECFCE;}body { font-family: Tahoma ,Arial, sans-serif;font-size: 100%;color: #69788E; margin: 10px 30px;background: #F7F7F7;}a:link, a:visited {text-decoration: none;color:#CECFCE;}a:active, a:hover {text-decoration: underline;color: #111;}h1 {font-family: "Trebuchet MS", Helvetica, sans-serif; font-size: 1.70em;font-weight: normal;color: #333333;margin-top: 0; margin-bottom: 10px;}.content_box {border: 1px dashed #CECFCE;background: #FFFFFF;padding: 10px;margin-right: auto;margin-left: auto;}</style> </head> <body title="&#1603;&#1604;&#1610;&#1580;&#1575;"><br /><div class="content_box"><p><a target="_blank" href="http://www.kleeja.com" title="kleeja"><img border="0" src="http://kleeja.com/index.png"></a></p><br /><h1><span style="font-size:250%;color:#D80000;">403 - Access forbidden!</span></h1></div><br /><div class="content_box"><span style="font-size: 140%">Powered by Kleeja &gt;&gt;&gt; the best uploader ...</span > >> <a target="_blank" href="http://www.kleeja.com/bugs/ar/">Bugs</a> | <a target="_blank" href="http://www.kleeja.com/plugins/">Plugins</a> | <a target="_blank" href="http://www.kleeja.com/styles/">Styles</a> | </div></body></html>

208
styles/dragdrop/footer.html Executable file
View File

@@ -0,0 +1,208 @@
<UNLESS NAME="is_embedded">
<IF NAME="extras.footer">
<div class="extras_footer mt-5">{extras.footer}</div>
</IF>
</UNLESS>
<footer class="mt-5">
<!-- Powered by kleeja.com -->
<div class="row justify-content-between">
<small class="col col-md-auto">{lang.COPYRIGHTS_X} &copy; <a href="{config.siteurl}">{config.sitename}</a></small>
<IF NAME="admin_page"><div class="col col-md-auto"><span class="btn btn-outline-primary">{admin_page}</span></div></IF>
</div>
<IF NAME="page_stats">
<!-- footer stats -->
<div class="text-muted">
<small>{page_stats}</small>
</div>
</IF>
</footer>
</div><!-- end container -->
{googleanalytics}
<script type="text/javascript" src="{STYLE_PATH}js/jquery.min.js"></script>
<script type="text/javascript" src="{STYLE_PATH}js/tether.min.js"></script>
<script type="text/javascript" src="{STYLE_PATH}js/bootstrap.min.js"></script>
<script type="text/javascript" src="{THIS_STYLE_PATH}js/filedrop.js"></script>
<!-- don't ever delete this -->
{run_queue}
<script type="text/javascript">
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
<IF NAME="isset({js_allowed_extensions_types})">
function show_messages(json_obj)
{
if(typeof json_obj === 'string'){
json_obj = JSON.parse(json_obj);
}
var output="";
var message_type = "";
for (var i in json_obj)
{
message_type = json_obj[i].message_type === "info" ? '' : ' list-group-item-danger hide_after_seconds';
output+="<li class=\"list-group-item" + message_type + "\">" + json_obj[i].message_content +"</li>";
}
$('#messages').append(output);
setTimeout(function() {
$('.hide_after_seconds').fadeOut('fast');
}, 3000);
}
$(function () {
$('#zone').filedrop({
fallback_id: 'fallbackFile', // an identifier of a standard file input element, becomes the target of "click" events on the dropzone
url: '{action}', // upload handler, handles each file separately, can also be a function taking the file and returning a url
paramname: 'file', // POST parameter name used on serverside to reference file, can also be a function taking the filename and returning the paramname
// withCredentials: true, // make a cross-origin request with cookies
data: {
submitr: 1,
ajax: 1
},
error: function (err, file) {
switch (err) {
case 'BrowserNotSupported':
alert('browser does not support HTML5 drag and drop');
break;
case 'TooManyFiles':
// user uploaded more than 'maxfiles'
break;
case 'FileTooLarge':
// program encountered a file whose size is greater than 'maxfilesize'
// FileTooLarge also has access to the file which was too large
// use file.name to reference the filename of the culprit file
break;
case 'FileTypeNotAllowed':
// The file type is not in the specified list 'allowedfiletypes'
break;
case 'FileExtensionNotAllowed':
// The file extension is not in the specified list 'allowedfileextensions'
break;
default:
break;
}
$('#loadbox').css('display', 'none');
},
maxfiles: 25,
uploadStarted: function (i, file, len) {
// a file began uploading
// i = index => 0, 1, 2, 3, 4 etc
// file is the actual file of the index
// len = total files user dropped
console.log('uploadStarted');
$('#loadbox').css('display', 'block');
$('#zone').addClass('fd-zone-current');
},
uploadFinished: function (i, file, response, time) {
console.log('uploadFinished');
// response is the data you got back from server in JSON format.
$('#loadbox').css('display', 'none');
show_messages(response);
},
progressUpdated: function (i, file, progress) {
console.log('progressUpdated');
// this function is used for large files and updates intermittently
// progress is the integer value of file being uploaded percentage to completion
},
globalProgressUpdated: function (progress) {
console.log('globalProgressUpdated');
// progress for all the files uploaded on the current instance (percentage)
// ex: $('#progress div').width(progress+"%");
$('#progress_data').html(progress + '/100');
},
speedUpdated: function (i, file, speed) {
console.log('speedUpdated');
// speed in kb/s
},
beforeEach: function (file) {
console.log('beforeEach');
// file is a file object
// return false to cancel upload
return check_selected_file(file);
},
beforeSend: function (file, i, done) {
console.log('beforeSend');
// file is a file object
// i is the file index
// call done() to start the upload
$('#loadbox').css('display', 'block');
done();
},
afterAll: function () {
console.log('afterAll');
// runs after all files have been uploaded or otherwise dealt with
$('#loadbox').css('display', 'none');
$('#zone').removeClass('fd-zone-current');
}
});
});
var allowed_exts = {js_allowed_extensions_types};
var allowed_sizes = {js_allowed_extensions_sizes};
function check_selected_file(selected_file) {
var file_name = selected_file.name;
var ext_dot_position = file_name.lastIndexOf(".");
if(ext_dot_position === -1){
alert('{lang.WRONG_F_NAME}'.replace('%s', file_name));
return false;
}
var file_extension = file_name.substring(ext_dot_position + 1);
var file_size = selected_file.size;
if(!(allowed_exts.indexOf(file_extension) > -1)){
//extension not allowed message alert
alert('{lang.FORBID_EXT}'.replace('%s', file_extension));
return false;
}else{
//check size
var ext_allowed_size = allowed_sizes[allowed_exts.indexOf(file_extension)];
if(file_size > ext_allowed_size){
//size is larger than allowed message alert
alert('{lang.SIZE_F_BIG}'.replace('%1$s', file_name).replace('%2$s', (ext_allowed_size/1048576).toFixed(2) + ' MB'));
return false;
}
}
return true;
}
</IF>
function update_kleeja_captcha(captcha_file, input_id)
{
document.getElementById(input_id).value = '';
//Get a reference to CAPTCHA image
img = document.getElementById('kleeja_img_captcha');
//Change the image
img.src = captcha_file + '&' + Math.random();
}
</script>
</body>
</html>

113
styles/dragdrop/header.html Executable file
View File

@@ -0,0 +1,113 @@
<!DOCTYPE html>
<html lang="{lang.LANG_SMALL_NAME}" dir="{dir}">
<head>
<meta charset="{charset}">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="author" content="Kleeja.com">
<title>{title}(title? - :){config.sitename}</title>
<link rel="shortcut icon" href="images/favicon.ico" />
<link rel="icon" type="image/gif" href="images/favicon.gif" />
<link rel="apple-touch-icon" href="images/apple-touch-icon.png" />
<link rel="apple-touch-startup-image" href="images/iPhone.png" />
<!-- Bootstrap core CSS -->
<link href="{STYLE_PATH}css/bootstrap.min.css" rel="stylesheet">
<link href="{STYLE_PATH}css/stylesheet.css" rel="stylesheet">
<link href="{THIS_STYLE_PATH}css/basic.css" rel="stylesheet">
<IF NAME="lang.DIR==rtl">
<style type="text/css">
body{font-family: "Tahoma",Arial,sans-serif;}
body{
direction: rtl; /* placing it here fixes the issue with jquery white page bug */
}
</style>
<link rel="stylesheet" type="text/css" media="all" href="{STYLE_PATH}css/bootstrap.rtl.min.css" />
</IF>
<script type="text/javascript">
<!--
var LANG_PAST_URL_HERE = "{lang.PAST_URL_HERE}";
var LANG_MORE_F_FILES = "{lang.MORE_F_FILES}";
var STYLE_PATH = "{STYLE_PATH}";
-->
</script>
<!-- Extra code -->
{EXTRA_CODE_META}
</head>
<body>
<!-- header -->
<nav class="navbar navbar-toggleable-md navbar-light bg-primary navbar-inverse">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#TopMenuNavbar" aria-controls="TopMenuNavbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="{config.siteurl}">
<img src="{STYLE_PATH}images/logo.png" width="30" height="30" class="d-inline-block align-top" alt="{username}">
{config.sitename}
</a>
<UNLESS NAME="is_embedded">
<div class="collapse navbar-collapse" id="TopMenuNavbar">
<ul class="navbar-nav mr-auto">
<LOOP NAME="top_menu">
<IF LOOP="show">
<li class="nav-item"><a href="{{url}}" class="nav-link(go_current=={{name}}? active:)">{{title}}</a></li>
</IF>
</LOOP>
</ul>
</div>
</UNLESS>
</nav>
<!-- use related menu -->
<UNLESS NAME="is_embedded">
<nav class="navbar navbar-toggleable-md bg-faded navbar-light">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<span class="navbar-brand">
<img src="{STYLE_PATH}images/user.png" width="26" height="26" class="d-inline-block align-top" alt="{username}">
</span>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<LOOP NAME="side_menu">
<IF LOOP="show">
<li class="nav-item"><a href="{{url}}" class="nav-link(go_current=={{name}}? active:)">{{title}}</a></li>
</IF>
</LOOP>
</ul>
<IF NAME="user_is">
<span class="navbar-text">
{username}
</span>
</IF>
</div>
</nav>
</UNLESS>
<div class="container mt-4">
<UNLESS NAME="is_embedded">
<IF NAME="extras.header">
<div class="extras_header mb-5">{extras.header}</div>
</IF>
</UNLESS>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

58
styles/dragdrop/index.html Executable file
View File

@@ -0,0 +1,58 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256"/>
<title>Powered by Kleeja</title>
<style type="text/css">* {
font-size: 100%;
margin: 0;
padding: 0;
color: #CECFCE;
}
body {
font-family: Tahoma, Arial, sans-serif;
font-size: 100%;
color: #69788E;
margin: 10px 30px;
background: #F7F7F7;
}
a:link, a:visited {
text-decoration: none;
color: #CECFCE;
}
a:active, a:hover {
text-decoration: underline;
color: #111;
}
h1 {
font-family: "Trebuchet MS", Helvetica, sans-serif;
font-size: 1.70em;
font-weight: normal;
color: #333333;
margin-top: 0;
margin-bottom: 10px;
}
.content_box {
border: 1px dashed #CECFCE;
background: #FFFFFF;
padding: 10px;
margin-right: auto;
margin-left: auto;
}</style>
</head>
<body title="&#1603;&#1604;&#1610;&#1580;&#1575;"><br/>
<div class="content_box">
<p>
<a target="_blank" href="http://www.kleeja.com" title="kleeja"></a>
</p>
<br/>
<h1><span style="font-size:250%;color:#D80000;">403 - Access forbidden!</span></h1></div>
<br/>
<div class="content_box"style="font-size: 140%">Powered by Kleeja</div>
</body>
</html>

75
styles/dragdrop/index_body.html Executable file
View File

@@ -0,0 +1,75 @@
<!-- Powered by kleeja -->
<div id="content_index">
<!-- welcome -->
<UNLESS NAME="is_embedded">
<div class="jumbotron">
<h5><span class="glyphicon glyphicon-heart" aria-hidden="true"></span> {lang.WELCOME} <IF NAME="user_is">[ {username} ]</IF></h5>
<p>{welcome_msg}</p>
</div>
</UNLESS>
<!-- messages: error or info -->
<div class="card mb-5">
<ul class="list-group list-group-flush" id="messages">
<LOOP NAME="info">
<IF LOOP="message_type == info">
<li class="list-group-item">
{{message_content}}
</li>
<ELSE>
<!-- error -->
<li class="list-group-item list-group-item-danger">
<strong>{lang.INFORMATION}</strong> : {{message_content}}
</li>
</IF>
</LOOP>
</ul>
</div>
<!-- box loading -->
<div id="zone" class="fd-zone">
<div id="loadbox" class="card">
<div class="card-block">
{lang.WAIT_LOADING} <span id="progress_data"></span>
<br>
<img src="{STYLE_PATH}images/loading.gif" alt="{lang.LOADING}" />
</div>
</div>
<p class="img"></p>
<p><h3><span>{lang.DRAG_AND_DROP}</span></h3></p>
<p><span>{lang.OR_MANUAL_SELECT}</span></p>
</div>
<div class="fallabackZone">
<input type="file" name="file" class="fd-file" id="fallbackFile" />
</div>
<IF NAME="show_online">
<!-- who's onLine -->
<div class="card who-online">
<div class="card-header">
{lang.NUMBER_ONLINE}: <b>{current_online_users}</b>
</div>
<IF NAME="show_names">
<div class="card-block">
<LOOP NAME="show_names">
<span class="badge badge-pill badge-default">{{name}}</span>
</LOOP>
</div>
</IF>
</div>
</IF>
</div>

28
styles/dragdrop/info.txt Executable file
View File

@@ -0,0 +1,28 @@
#
# This is a configuration file of the style.
# Change those values when you create
# your style ...
#
#Style name
name = DragDrop
#Style desc
desc:en = Based on Bootstrap style, has Drag & Drop feature
desc:ar = مبني على ستايل بوت ستراب الافتراضي، لديه ميزة الجر والاسقاط للتحميل
#Style copyright
copyright = 2017 Kleeja.com
#Version of style
version = 1.0
#Min. required version of kleeja
kleeja_version = 2.0
#name of the style required by this style
depend_on = bootstrap
#plugins required to install this style
#plugins_required = test, test2

View File

@@ -0,0 +1,604 @@
/*global jQuery:false, alert:false */
/*
* Default text - jQuery plugin for html5 dragging files from desktop to browser
*
* Author: Weixi Yen
*
* Email: [Firstname][Lastname]@gmail.com
*
* Copyright (c) 2010 Resopollution
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* http://www.github.com/weixiyen/jquery-filedrop
*
* Version: 0.1.0
*
* Features:
* Allows sending of extra parameters with file.
* Works with Firefox 3.6+
* Future-compliant with HTML5 spec (will work with Webkit browsers and IE9)
* Usage:
* See README at project homepage
*
*/
;(function($) {
var default_opts = {
fallback_id: '',
fallback_dropzoneClick : true,
url: '',
refresh: 1000,
paramname: 'userfile',
requestType: 'POST', // just in case you want to use another HTTP verb
allowedfileextensions:[],
allowedfiletypes:[],
maxfiles: 25, // Ignored if queuefiles is set > 0
maxfilesize: 2000, // MB file size limit
queuefiles: 0, // Max files before queueing (for large volume uploads)
queuewait: 5, // Queue wait time if full
data: {},
headers: {},
drop: empty,
dragStart: empty,
dragEnter: empty,
dragOver: empty,
dragLeave: empty,
docEnter: empty,
docOver: empty,
docLeave: empty,
beforeEach: empty,
afterAll: empty,
rename: empty,
error: function(err, file, i, status) {
alert(err);
},
uploadStarted: empty,
uploadFinished: empty,
progressUpdated: empty,
globalProgressUpdated: empty,
speedUpdated: empty
},
errors = ["BrowserNotSupported", "TooManyFiles", "FileTooLarge", "FileTypeNotAllowed", "NotFound", "NotReadable", "AbortError", "ReadError", "FileExtensionNotAllowed"];
$.fn.filedrop = function(options) {
var opts = $.extend({}, default_opts, options),
global_progress = [],
doc_leave_timer, stop_loop = false,
files_count = 0,
files;
if ( opts.fallback_dropzoneClick === true )
{
$('#' + opts.fallback_id).css({
display: 'none',
width: 0,
height: 0
});
}
this.on('drop', drop).on('dragstart', opts.dragStart).on('dragenter', dragEnter).on('dragover', dragOver).on('dragleave', dragLeave);
$(document).on('drop', docDrop).on('dragenter', docEnter).on('dragover', docOver).on('dragleave', docLeave);
if ( opts.fallback_dropzoneClick === true )
{
if ( this.find('#' + opts.fallback_id).length > 0 )
{
throw "Fallback element ["+opts.fallback_id+"] cannot be inside dropzone, unless option fallback_dropzoneClick is false";
}
else
{
this.on('click', function(e){
$('#' + opts.fallback_id).trigger(e);
});
}
}
$('#' + opts.fallback_id).change(function(e) {
opts.drop(e);
files = e.target.files;
files_count = files.length;
upload();
});
function drop(e) {
if( opts.drop.call(this, e) === false ) return false;
if(!e.originalEvent.dataTransfer)
return;
files = e.originalEvent.dataTransfer.files;
if (files === null || files === undefined || files.length === 0) {
opts.error(errors[0]);
return false;
}
files_count = files.length;
upload();
e.preventDefault();
return false;
}
function getBuilder(filename, filedata, mime, boundary) {
var dashdash = '--',
crlf = '\r\n',
builder = '',
paramname = opts.paramname;
if (opts.data) {
var params = $.param(opts.data).replace(/\+/g, '%20').split(/&/);
$.each(params, function() {
var pair = this.split("=", 2),
name = decodeURIComponent(pair[0]),
val = decodeURIComponent(pair[1]);
if (pair.length !== 2) {
return;
}
builder += dashdash;
builder += boundary;
builder += crlf;
builder += 'Content-Disposition: form-data; name="' + name + '"';
builder += crlf;
builder += crlf;
builder += val;
builder += crlf;
});
}
if (jQuery.isFunction(paramname)){
paramname = paramname(filename);
}
builder += dashdash;
builder += boundary;
builder += crlf;
builder += 'Content-Disposition: form-data; name="' + (paramname||"") + '"';
builder += '; filename="' + encodeURIComponent(filename) + '"';
builder += crlf;
builder += 'Content-Type: ' + mime;
builder += crlf;
builder += crlf;
builder += filedata;
builder += crlf;
builder += dashdash;
builder += boundary;
builder += dashdash;
builder += crlf;
return builder;
}
function progress(e) {
if (e.lengthComputable) {
var percentage = Math.round((e.loaded * 100) / e.total);
if (this.currentProgress !== percentage) {
this.currentProgress = percentage;
opts.progressUpdated(this.index, this.file, this.currentProgress);
global_progress[this.global_progress_index] = this.currentProgress;
globalProgress();
var elapsed = new Date().getTime();
var diffTime = elapsed - this.currentStart;
if (diffTime >= opts.refresh) {
var diffData = e.loaded - this.startData;
var speed = diffData / diffTime; // KB per second
opts.speedUpdated(this.index, this.file, speed);
this.startData = e.loaded;
this.currentStart = elapsed;
}
}
}
}
function globalProgress() {
if (global_progress.length === 0) {
return;
}
var total = 0, index;
for (index in global_progress) {
if(global_progress.hasOwnProperty(index)) {
total = total + global_progress[index];
}
}
opts.globalProgressUpdated(Math.round(total / global_progress.length));
}
// Respond to an upload
function upload() {
stop_loop = false;
if (!files) {
opts.error(errors[0]);
return false;
}
if (opts.allowedfiletypes.push && opts.allowedfiletypes.length) {
for(var fileIndex = files.length;fileIndex--;) {
if(!files[fileIndex].type || $.inArray(files[fileIndex].type, opts.allowedfiletypes) < 0) {
opts.error(errors[3], files[fileIndex]);
return false;
}
}
}
if (opts.allowedfileextensions.push && opts.allowedfileextensions.length) {
for(var fileIndex = files.length;fileIndex--;) {
var allowedextension = false;
for (i=0;i<opts.allowedfileextensions.length;i++){
if (files[fileIndex].name.substr(files[fileIndex].name.length-opts.allowedfileextensions[i].length).toLowerCase()
== opts.allowedfileextensions[i].toLowerCase()
) {
allowedextension = true;
}
}
if (!allowedextension){
opts.error(errors[8], files[fileIndex]);
return false;
}
}
}
var filesDone = 0,
filesRejected = 0;
if (files_count > opts.maxfiles && opts.queuefiles === 0) {
opts.error(errors[1]);
return false;
}
// Define queues to manage upload process
var workQueue = [];
var processingQueue = [];
var doneQueue = [];
// Add everything to the workQueue
for (var i = 0; i < files_count; i++) {
workQueue.push(i);
}
// Helper function to enable pause of processing to wait
// for in process queue to complete
var pause = function(timeout) {
setTimeout(process, timeout);
return;
};
// Process an upload, recursive
var process = function() {
var fileIndex;
if (stop_loop) {
return false;
}
// Check to see if are in queue mode
if (opts.queuefiles > 0 && processingQueue.length >= opts.queuefiles) {
return pause(opts.queuewait);
} else {
// Take first thing off work queue
fileIndex = workQueue[0];
workQueue.splice(0, 1);
// Add to processing queue
processingQueue.push(fileIndex);
}
try {
if (beforeEach(files[fileIndex]) !== false) {
if (fileIndex === files_count) {
return;
}
var reader = new FileReader(),
max_file_size = 1048576 * opts.maxfilesize;
reader.index = fileIndex;
if (files[fileIndex].size > max_file_size) {
opts.error(errors[2], files[fileIndex], fileIndex);
// Remove from queue
processingQueue.forEach(function(value, key) {
if (value === fileIndex) {
processingQueue.splice(key, 1);
}
});
filesRejected++;
return true;
}
reader.onerror = function(e) {
switch(e.target.error.code) {
case e.target.error.NOT_FOUND_ERR:
opts.error(errors[4]);
return false;
case e.target.error.NOT_READABLE_ERR:
opts.error(errors[5]);
return false;
case e.target.error.ABORT_ERR:
opts.error(errors[6]);
return false;
default:
opts.error(errors[7]);
return false;
};
};
reader.onloadend = !opts.beforeSend ? send : function (e) {
opts.beforeSend(files[fileIndex], fileIndex, function () { send(e); });
};
reader.readAsDataURL(files[fileIndex]);
} else {
filesRejected++;
}
} catch (err) {
// Remove from queue
processingQueue.forEach(function(value, key) {
if (value === fileIndex) {
processingQueue.splice(key, 1);
}
});
opts.error(errors[0]);
return false;
}
// If we still have work to do,
if (workQueue.length > 0) {
process();
}
};
var send = function(e) {
var fileIndex = (e.srcElement || e.target).index;
// Sometimes the index is not attached to the
// event object. Find it by size. Hack for sure.
if (e.target.index === undefined) {
e.target.index = getIndexBySize(e.total);
}
var xhr = new XMLHttpRequest(),
upload = xhr.upload,
file = files[e.target.index],
index = e.target.index,
start_time = new Date().getTime(),
boundary = '------multipartformboundary' + (new Date()).getTime(),
global_progress_index = global_progress.length,
builder,
newName = rename(file.name),
mime = file.type;
if (opts.withCredentials) {
xhr.withCredentials = opts.withCredentials;
}
var encodedString = e.target.result.split(',')[1];
var data = encodedString === undefined ? '' : atob(encodedString);
if (typeof newName === "string") {
builder = getBuilder(newName, data, mime, boundary);
} else {
builder = getBuilder(file.name, data, mime, boundary);
}
upload.index = index;
upload.file = file;
upload.downloadStartTime = start_time;
upload.currentStart = start_time;
upload.currentProgress = 0;
upload.global_progress_index = global_progress_index;
upload.startData = 0;
upload.addEventListener("progress", progress, false);
// Allow url to be a method
if (jQuery.isFunction(opts.url)) {
xhr.open(opts.requestType, opts.url(upload), true);
} else {
xhr.open(opts.requestType, opts.url, true);
}
xhr.setRequestHeader('content-type', 'multipart/form-data; boundary=' + boundary);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
// Add headers
$.each(opts.headers, function(k, v) {
xhr.setRequestHeader(k, v);
});
if(!xhr.sendAsBinary){
xhr.sendAsBinary = function(datastr) {
function byteValue(x) {
return x.charCodeAt(0) & 0xff;
}
var ords = Array.prototype.map.call(datastr, byteValue);
var ui8a = new Uint8Array(ords);
this.send(ui8a.buffer);
}
}
xhr.sendAsBinary(builder);
global_progress[global_progress_index] = 0;
globalProgress();
opts.uploadStarted(index, file, files_count);
xhr.onload = function() {
var serverResponse = null;
if (xhr.responseText) {
try {
serverResponse = jQuery.parseJSON(xhr.responseText);
}
catch (e) {
serverResponse = xhr.responseText;
}
}
var now = new Date().getTime(),
timeDiff = now - start_time,
result = opts.uploadFinished(index, file, serverResponse, timeDiff, xhr);
filesDone++;
// Remove from processing queue
processingQueue.forEach(function(value, key) {
if (value === fileIndex) {
processingQueue.splice(key, 1);
}
});
// Add to donequeue
doneQueue.push(fileIndex);
// Make sure the global progress is updated
global_progress[global_progress_index] = 100;
globalProgress();
if (filesDone === (files_count - filesRejected)) {
afterAll();
}
if (result === false) {
stop_loop = true;
}
// Pass any errors to the error option
if (xhr.status < 200 || xhr.status > 299) {
opts.error(xhr.statusText, file, fileIndex, xhr.status);
}
};
};
// Initiate the processing loop
process();
}
function getIndexBySize(size) {
for (var i = 0; i < files_count; i++) {
if (files[i].size === size) {
return i;
}
}
return undefined;
}
function rename(name) {
return opts.rename(name);
}
function beforeEach(file) {
return opts.beforeEach(file);
}
function afterAll() {
return opts.afterAll();
}
function dragEnter(e) {
clearTimeout(doc_leave_timer);
e.preventDefault();
opts.dragEnter.call(this, e);
}
function dragOver(e) {
clearTimeout(doc_leave_timer);
e.preventDefault();
opts.docOver.call(this, e);
opts.dragOver.call(this, e);
}
function dragLeave(e) {
clearTimeout(doc_leave_timer);
opts.dragLeave.call(this, e);
e.stopPropagation();
}
function docDrop(e) {
e.preventDefault();
opts.docLeave.call(this, e);
return false;
}
function docEnter(e) {
clearTimeout(doc_leave_timer);
e.preventDefault();
opts.docEnter.call(this, e);
return false;
}
function docOver(e) {
clearTimeout(doc_leave_timer);
e.preventDefault();
opts.docOver.call(this, e);
return false;
}
function docLeave(e) {
doc_leave_timer = setTimeout((function(_this) {
return function() {
opts.docLeave.call(_this, e);
};
})(this), 200);
}
return this;
};
function empty() {}
try {
if (XMLHttpRequest.prototype.sendAsBinary) {
return;
}
XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
// function byteValue(x) {
// return x.charCodeAt(0) & 0xff;
// }
// var ords = Array.prototype.map.call(datastr, byteValue);
// var ui8a = new Uint8Array(datastr);
var ui8a = new Uint8Array(datastr.length);
// for (var nIdx = 0; nIdx < nBytes; nIdx++) {
// ui8a[nIdx] = datastr.charCodeAt(nIdx) & 0xff;
// }
var nIdx = datastr.length;
while (--nIdx >= 0) {
ui8a[nIdx] = datastr.charCodeAt(nIdx) & 0xff;
}
// Not pretty: Chrome 22 deprecated sending ArrayBuffer, moving instead
// to sending ArrayBufferView. Sadly, no proper way to detect this
// functionality has been discovered. Happily, Chrome 22 also introduced
// the base ArrayBufferView class, not present in Chrome 21.
if ('ArrayBufferView' in window)
this.send(ui8a);
else
this.send(ui8a.buffer);
};
} catch (e) {}
})(jQuery);

58
styles/dragdrop/js/index.html Executable file
View File

@@ -0,0 +1,58 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256"/>
<title>Powered by Kleeja</title>
<style type="text/css">* {
font-size: 100%;
margin: 0;
padding: 0;
color: #CECFCE;
}
body {
font-family: Tahoma, Arial, sans-serif;
font-size: 100%;
color: #69788E;
margin: 10px 30px;
background: #F7F7F7;
}
a:link, a:visited {
text-decoration: none;
color: #CECFCE;
}
a:active, a:hover {
text-decoration: underline;
color: #111;
}
h1 {
font-family: "Trebuchet MS", Helvetica, sans-serif;
font-size: 1.70em;
font-weight: normal;
color: #333333;
margin-top: 0;
margin-bottom: 10px;
}
.content_box {
border: 1px dashed #CECFCE;
background: #FFFFFF;
padding: 10px;
margin-right: auto;
margin-left: auto;
}</style>
</head>
<body title="&#1603;&#1604;&#1610;&#1580;&#1575;"><br/>
<div class="content_box">
<p>
<a target="_blank" href="http://www.kleeja.com" title="kleeja"></a>
</p>
<br/>
<h1><span style="font-size:250%;color:#D80000;">403 - Access forbidden!</span></h1></div>
<br/>
<div class="content_box"style="font-size: 140%">Powered by Kleeja</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB