mirror of
https://github.com/Studio-42/elFinder
synced 2026-06-08 12:37:09 +00:00
48576af671
* Refactor touch event binding in elfinder.js (#3762) for jquery 4.0 * Refactor name trimming in elFinder.resources.js (#3763) for jquery 4.0 * Replace jQuery methods with native JavaScript equivalents (#3764) for jquery 4.0 * Refactor command binding to use bind method (#3765) for jquery 4.0 * Refactor search input value handling and buttonset (#3766) for jquery 4.0 * Refactor function calls to use bind instead of proxy (#3767) for jquery 4.0 * Refactor text trimming method in parseUploadData (#3768) for jquery 4.0 * Fix mime trimming and whitespace handling (#3769) for jquery 4.0 * Refactor value trimming to use native trim method (#3772) for jquery 4.0 * Fix binding of 'make' method in mkfile.js (#3773) for jquery 4.0 * Fix binding of make function in mkdir command (#3774) for jquery 4.0 * Fix string trimming for translator names (#3775) for jquery 4.0 * Fix binding of mixin make function in edit.js (#3776) For jquery 4 * Refactor permission value trimming method (#3777) For jquery 4.0 * fix: to support jQuery 4.0.0 * update: use jQuery 4.0.0/jQueyUI 1.14.2 --------- Co-authored-by: Brian Stone <brianstone@hotmail.com.au>
58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
/**
|
|
* @class elFinder command "mkfile"
|
|
* Create new empty file
|
|
*
|
|
* @author Dmitry (dio) Levashov
|
|
**/
|
|
elFinder.prototype.commands.mkfile = function() {
|
|
"use strict";
|
|
var self = this;
|
|
|
|
this.disableOnSearch = true;
|
|
this.updateOnSelect = false;
|
|
this.mime = 'text/plain';
|
|
this.prefix = 'untitled file.txt';
|
|
this.variants = [];
|
|
|
|
this.getTypeName = function(mime, type) {
|
|
var fm = self.fm,
|
|
name;
|
|
if (name = fm.messages['kind' + fm.kinds[mime]]) {
|
|
name = fm.i18n(['extentiontype', type.toUpperCase(), name]);
|
|
} else {
|
|
name = fm.i18n(['extentionfile', type.toUpperCase()]);
|
|
}
|
|
return name;
|
|
};
|
|
|
|
this.fm.bind('open reload canMakeEmptyFile', function() {
|
|
var fm = self.fm,
|
|
hides = fm.getCommand('edit').getMkfileHides();
|
|
self.variants = [];
|
|
if (fm.mimesCanMakeEmpty) {
|
|
$.each(fm.mimesCanMakeEmpty, function(mime, type) {
|
|
type && !hides[mime] && fm.uploadMimeCheck(mime) && self.variants.push([mime, self.getTypeName(mime, type)]);
|
|
});
|
|
}
|
|
self.change();
|
|
});
|
|
|
|
this.getstate = function() {
|
|
return this.fm.cwd().write ? 0 : -1;
|
|
};
|
|
|
|
this.exec = function(_dum, mime) {
|
|
var fm = self.fm,
|
|
type, err;
|
|
if (type = fm.mimesCanMakeEmpty[mime]) {
|
|
if (fm.uploadMimeCheck(mime)) {
|
|
this.mime = mime;
|
|
this.prefix = fm.i18n(['untitled file', type]);
|
|
return fm.res('mixin', 'make').bind(self)();
|
|
}
|
|
err = ['errMkfile', self.getTypeName(mime, type)];
|
|
}
|
|
return $.Deferred().reject(err);
|
|
};
|
|
};
|