Skip to content

Commit

Permalink
direct upload upon simple file uploads #247
Browse files Browse the repository at this point in the history
  • Loading branch information
psolom committed Oct 29, 2017
1 parent debe3d5 commit 49fab4c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 166 deletions.
13 changes: 2 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
<link rel="stylesheet" type="text/css" href="scripts/custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css" />
<link rel="stylesheet" type="text/css" href="scripts/alertify.js/dist/css/alertify.css">

<!--[if IE 9]>
<link rel="stylesheet" type="text/css" href="styles/ie9.css" />
<![endif]-->

<style type="text/css">
.fm-container .fm-loading-wrap {
position: fixed;
Expand Down Expand Up @@ -97,13 +93,8 @@
<div class="button-group upload-controls">
<form class="fm-uploader" method="post">
<input id="mode" type="hidden" value="add"/>
<div id="file-input-container">
<div id="alt-fileinput">
<input id="filepath" name="filepath" type="text"/>
<button class="btn" id="browse" type="button" data-bind="attr: {title: lg.browse}">+</button>
</div>
<input id="newfile" name="newfile" type="file" />
</div>
<input id="newfile" class="hidden-file-input" name="newfile" type="file" />

<button class="btn fm-upload" type="button">
<span data-bind="text: lg.action_upload"></span>
</button>
Expand Down
30 changes: 7 additions & 23 deletions scripts/filemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,6 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
};
}

// input file replacement
$("#newfile").change(function() {
$("#filepath").val($(this).val().replace(/.+[\\\/]/, ""));
});

prepareFileTree();
prepareFileView();
setupUploader();
Expand Down Expand Up @@ -3599,7 +3594,6 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
if(config.security.extensions.policy == 'DISALLOW_LIST') {
str += '<p>' + lg('DISALLOWED_FILE_TYPE').replace('%s', config.security.extensions.restrictions.join(', ')) + '.</p>';
}
$("#filepath").val('');
fm.error(str);
return;
}
Expand Down Expand Up @@ -4072,9 +4066,6 @@ $.richFilemanagerPlugin = function(element, pluginOptions)

// Multiple Uploads
if(config.upload.multiple) {
// remove simple file upload element
$('#file-input-container').remove();

$uploadButton.unbind().click(function() {
if(capabilities.indexOf('upload') === -1) {
fm.error(lg('NOT_ALLOWED'));
Expand Down Expand Up @@ -4432,24 +4423,18 @@ $.richFilemanagerPlugin = function(element, pluginOptions)

// Simple Upload
} else {
$uploadButton.unbind().click(function() {
if(capabilities.indexOf('upload') === -1) {
fm.error(lg('NOT_ALLOWED'));
return false;
}

$uploadButton.click(function() {
if(capabilities.indexOf('upload') === -1) {
fm.error(lg('NOT_ALLOWED'));
return false;
}

var data = $(this).data();
if($.isEmptyObject(data)) {
fm.error(lg('upload_choose_file'));
} else {
data.submit();
}
$("#newfile").trigger('click');
});

$uploader
.fileupload({
autoUpload: false,
autoUpload: true,
dataType: 'json',
url: buildConnectorUrl(),
paramName: 'files',
Expand All @@ -4470,7 +4455,6 @@ $.richFilemanagerPlugin = function(element, pluginOptions)
})

.on('fileuploadalways', function(e, data) {
$("#filepath").val('');
$uploadButton.removeData().removeClass('loading').prop('disabled', false);
$uploadButton.children('span').text(lg('action_upload'));
var response = data.result;
Expand Down
2 changes: 1 addition & 1 deletion scripts/filemanager.min.js

Large diffs are not rendered by default.

97 changes: 13 additions & 84 deletions styles/filemanager.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ html[data-useragent*='MSIE 10.0'] .fm-container .fm-header button,
html[data-useragent*='MSIE 11.0'] .fm-container .fm-header button {
vertical-align: top;
}
html[data-useragent*='MSIE 10.0'] .fm-container #file-input-container,
html[data-useragent*='MSIE 11.0'] .fm-container #file-input-container {
width: 220px;
height: 32px;
overflow: hidden;
}
html[data-useragent*='MSIE 10.0'] .fm-container #filepath,
html[data-useragent*='MSIE 11.0'] .fm-container #filepath {
height: 22px;
}
html[data-useragent*='MSIE 10.0'] .fm-container #newfile,
html[data-useragent*='MSIE 11.0'] .fm-container #newfile {
height: 23px;
}

.fm-container * {
font-family: Lucida Sans Unicode, Lucida Grande, sans-serif;
Expand All @@ -43,6 +29,19 @@ html[data-useragent*='MSIE 11.0'] .fm-container #newfile {
overflow: hidden;
}

.fm-container input {
vertical-align: text-top;
}

.fm-container .hidden-file-input {
position: absolute;
overflow: hidden;
visibility: hidden;
left: -1000px;
width: 1px;
z-index: -1;
}

.fm-container .fm-wrapper {
height: 100%;
padding: 10px;
Expand Down Expand Up @@ -560,76 +559,6 @@ html[data-useragent*='MSIE 11.0'] .fm-container #newfile {
background: url(../images/copy.png) no-repeat center center;
}


/** Input file Replacement */

.fm-container input {
vertical-align: text-top;
}

.fm-container #file-input-container {
display: inline;
margin: 0;
position: relative;
top: 0;
width: 255px;
height: 32px;
overflow: hidden;
}

.fm-container #newfile {
position: absolute;
top: 0;
right: 0;
height: 28px;
width: 100%;
opacity: 0;
filter: alpha(opacity=0);
cursor: pointer;
border: 1px solid blue;
}

.fm-container .hidden-file-input {
display: inline-block;
overflow: hidden;
visibility: hidden;
width: 1px;
z-index:-1;
}

.fm-container #alt-fileinput {
display: inline;
}

.fm-container #filepath {
margin: 0;
padding: 0 5px;
line-height: 26px;
background-color: #F4F1ED;
border: 1px solid #dcdcdc;
}

.fm-container button#browse {
margin-left:0;
-webkit-border-top-left-radius: 0;
-webkit-border-bottom-left-radius: 0;
-moz-border-radius-topleft: 0;
-moz-border-radius-bottomleft: 0;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
min-height: 16px;
min-width: 40px;
}
.fm-container button#browse span {
margin:0;
padding:0;
background: url(../images/plus.png) no-repeat center center;
display: block;
color:#666;
text-shadow: none;
}
/** Input file Replacement - end */

.fm-container .fm-footer .right {
float: right;
}
Expand Down
29 changes: 0 additions & 29 deletions styles/ie9.css

This file was deleted.

9 changes: 0 additions & 9 deletions themes/default/styles/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@
background-color: #ffffff;
}

.fm-container #filepath {
-webkit-border-top-left-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
-moz-border-radius-topleft: 6px;
-moz-border-radius-bottomleft: 6px;
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}

.fm-container #folder-info {
color: #777;
}
Expand Down
9 changes: 0 additions & 9 deletions themes/flat-dark/styles/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@
background-color: #C3D2F7;
}

.fm-container #filepath {
-webkit-border-top-left-radius: 2px;
-webkit-border-bottom-left-radius: 2px;
-moz-border-radius-topleft: 2px;
-moz-border-radius-bottomleft: 2px;
border-top-left-radius: 2px;
border-bottom-left-radius: 2px;
}

.fm-container #folder-info {
color: #bbb;
}
Expand Down

0 comments on commit 49fab4c

Please sign in to comment.