Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
psolom committed May 18, 2016
1 parent e82cec1 commit 0d471e8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
13 changes: 7 additions & 6 deletions scripts/filemanager.config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
"lang": "php",
"theme": "flat-dark",
"defaultViewMode": "grid",
"localizeGUI": true,
"showFullPath": false,
"showTitleAttr": false,
"browseOnly": false,
"showConfirmation": true,
"showThumbs": true,
"searchBox": true,
"listFiles": true,
"fileSorting": "default",
"fileSorting": "NAME_ASC",
"folderPosition": "bottom",
"quickSelect": false,
"charsLatinOnly": true,
Expand All @@ -24,8 +25,8 @@
"fileConnector": false,
"fileRootSizeLimit": false,
"baseUrl": false,
"capabilities": ["select", "upload", "download", "rename", "move", "replace", "delete"],
"logger": false,
"capabilities": ["upload", "select", "download", "rename", "move", "delete", "replace"],
"plugins": []
},
"security": {
Expand Down Expand Up @@ -81,13 +82,13 @@
"unallowed_dirs_REGEXP": "/^\\./"
},
"upload": {
"multiple": true,
"paramName": "files",
"chunkSize": false,
"multiple": true,
"number": 5,
"numberOfFiles": 5,
"fileSizeLimit": 16000000,
"overwrite": false,
"imagesOnly": false,
"fileSizeLimit": 16000000
"imagesOnly": false
},
"images": {
"imagesExt": [
Expand Down
22 changes: 12 additions & 10 deletions scripts/filemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ var loadedFolderData = {};

// Defines sort params
var chunks = [];
if(config.options.fileSorting !== 'default') {
if(config.options.fileSorting) {
chunks = config.options.fileSorting.toLowerCase().split('_');
}
var configSortField = chunks[0] || 'name';
Expand Down Expand Up @@ -2299,10 +2299,12 @@ $(function() {
}

// finalize the FileManager UI initialization with localized text
$uploadButton.append(lg.upload);
$('#newfolder').append(lg.new_folder);
$('#grid').attr('title', lg.grid_view);
$('#list').attr('title', lg.list_view);
if(config.options.localizeGUI === true) {
$uploadButton.append(lg.upload);
$('#newfolder').append(lg.new_folder);
$('#grid').attr('title', lg.grid_view);
$('#list').attr('title', lg.list_view);
}

/** Adding a close button triggering callback function if CKEditorCleanUpFuncNum passed */
if($.urlParam('CKEditorCleanUpFuncNum')) {
Expand Down Expand Up @@ -2413,7 +2415,7 @@ $(function() {
currentPath = getCurrentPath(),
templateContainer = loadTemplate('upload-container', {
folder: lg.current_folder + currentPath,
info: lg.upload_files_number_limit.replace('%s', config.upload.number) + ' ' + lg.upload_file_size_limit + formatBytes(config.upload.fileSizeLimit, true),
info: lg.upload_files_number_limit.replace('%s', config.upload.numberOfFiles) + ' ' + lg.upload_file_size_limit + formatBytes(config.upload.fileSizeLimit, true),
lang: lg
});

Expand Down Expand Up @@ -2567,11 +2569,11 @@ $(function() {
},
// validation
// maxNumberOfFiles works only for single "add" call when "singleFileUploads" is set to "false"
maxNumberOfFiles: config.upload.number,
maxNumberOfFiles: config.upload.numberOfFiles,
acceptFileTypes: allowedFileTypes,
maxFileSize: (config.upload.fileSizeLimit != 'auto') ? config.upload.fileSizeLimit : 10000000, // 10 MB
maxFileSize: config.upload.fileSizeLimit,
messages: {
maxNumberOfFiles: lg.upload_files_number_limit.replace("%s", config.upload.number),
maxNumberOfFiles: lg.upload_files_number_limit.replace("%s", config.upload.numberOfFiles),
acceptFileTypes: lg.upload_file_type_invalid,
maxFileSize: lg.upload_file_too_big + ' ' + lg.upload_file_size_limit + formatBytes(config.upload.fileSizeLimit, true)
},
Expand All @@ -2585,7 +2587,7 @@ $(function() {
var $items = $dropzone.children('.upload-item');
$.each(data.files, function (index, file) {
// skip selected files if total files number exceed "maxNumberOfFiles"
if($items.length >= config.upload.number) {
if($items.length >= config.upload.numberOfFiles) {
return false;
}
// to display in item template
Expand Down
Loading

0 comments on commit 0d471e8

Please sign in to comment.