refactor(dom) promptNew

This commit is contained in:
coderaiser 2014-10-05 08:00:53 -04:00
parent 77debf311d
commit edc14b5f29

View file

@ -449,20 +449,24 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
function promptNew(typeName, type) {
var RESTful = DOM.RESTful,
lName = Cmd.getCurrentName(),
lDir = Cmd.getCurrentDirPath(),
lMsg = 'New ' + typeName || 'File',
lType = Util.type.string(type) ? type : '';
path = '',
name = Cmd.getCurrentName(),
dir = Cmd.getCurrentDirPath(),
msg = 'New ' + typeName || 'File';
if (lName === '..')
lName = '';
if (name === '..')
name = '';
lName = Dialog.prompt(lMsg, lName);
name = Dialog.prompt(msg, name);
path = dir + name;
if (lName)
RESTful.write(lDir + lName + lType, null, function() {
if (type)
path += type;
if (name)
RESTful.write(path, null, function() {
CloudCmd.refresh(null, null, function() {
var current = DOM.getCurrentFileByName(lName);
var current = DOM.getCurrentFileByName(name);
DOM.setCurrentFile(current);
});