Fix pad creation from the context menu
This commit is contained in:
@@ -29,10 +29,10 @@
|
||||
<div id="contentContextMenu" class="contextMenu dropdown clearfix" oncontextmenu="return false;">
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" style="display:block;position:static;margin-bottom:5px;">
|
||||
<li><a tabindex="-1" href="#" class="newfolder editable dropdown-item" data-localization="fc_newfolder">New folder</a></li>
|
||||
<li><a tabindex="-1" href="#" class="newdoc own editable dropdown-item" data-type="pad" data-localization="fc_newpad" target="_blank">New pad</a></li>
|
||||
<li><a tabindex="-1" href="#" class="newdoc own editable dropdown-item" data-type="code" data-localization="fc_newcode" target="_blank">New code</a></li>
|
||||
<li><a tabindex="-1" href="#" class="newdoc own editable dropdown-item" data-type="slide" data-localization="fc_newslide" target="_blank">New slide</a></li>
|
||||
<li><a tabindex="-1" href="#" class="newdoc own editable dropdown-item" data-type="poll" data-localization="fc_newpoll" target="_blank">New poll</a></li>
|
||||
<li><a tabindex="-1" href="#" class="newdoc own editable dropdown-item" data-type="pad" data-localization="fc_newpad">New pad</a></li>
|
||||
<li><a tabindex="-1" href="#" class="newdoc own editable dropdown-item" data-type="code" data-localization="fc_newcode">New code</a></li>
|
||||
<li><a tabindex="-1" href="#" class="newdoc own editable dropdown-item" data-type="slide" data-localization="fc_newslide">New slide</a></li>
|
||||
<li><a tabindex="-1" href="#" class="newdoc own editable dropdown-item" data-type="poll" data-localization="fc_newpoll">New poll</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="defaultContextMenu" class="contextMenu dropdown clearfix" oncontextmenu="return false;">
|
||||
|
||||
@@ -855,6 +855,18 @@ define([
|
||||
return $block;
|
||||
};
|
||||
|
||||
var createPadFromRootHandler = function (e) {
|
||||
var type = $(this).data('type');
|
||||
if (!type) {
|
||||
throw new Error("Unable to get the pad type...");
|
||||
}
|
||||
var onNamed = function (name) {
|
||||
if (!name) { return; }
|
||||
var path = '/#?name=' + encodeURIComponent(name) + '&path=' + encodeURIComponent(currentPath);
|
||||
window.open('/' + type + path);
|
||||
};
|
||||
Cryptpad.prompt(Messages.fm_nameFile, Cryptpad.getDefaultName({type: type}), onNamed);
|
||||
};
|
||||
var createNewButton = function (isInRoot) {
|
||||
if (!APP.editable) { return; }
|
||||
|
||||
@@ -904,18 +916,7 @@ define([
|
||||
};
|
||||
filesOp.createNewFolder(currentPath, null, onCreated);
|
||||
});
|
||||
$block.find('a.newdoc').click(function () {
|
||||
var type = $(this).data('type');
|
||||
if (!type) {
|
||||
throw new Error("Unable to get the pad type...");
|
||||
}
|
||||
var onNamed = function (name) {
|
||||
var path = '/#?name=' + encodeURIComponent(name) + '&path=' + encodeURIComponent(currentPath);
|
||||
console.log(path);
|
||||
window.open('/' + type + path);
|
||||
};
|
||||
Cryptpad.prompt("How would you like to name your file?", Cryptpad.getDefaultName({type: type}), onNamed);
|
||||
});
|
||||
$block.find('a.newdoc').click(createPadFromRootHandler);
|
||||
}
|
||||
|
||||
return $block;
|
||||
@@ -1587,7 +1588,8 @@ define([
|
||||
}
|
||||
else if ($(this).hasClass("newdoc")) {
|
||||
var type = $(this).data('type') || 'pad';
|
||||
$(this).attr('href','/' + type + '/#?path=' + encodeURIComponent(path));
|
||||
createPadFromRootHandler.apply(this);
|
||||
e.preventDefault();
|
||||
}
|
||||
module.hideMenu();
|
||||
});
|
||||
@@ -1853,7 +1855,6 @@ define([
|
||||
$backupButton.attr('title', Messages.fm_backup_title);
|
||||
$backupButton.on('click', function() {
|
||||
var url = window.location.origin + window.location.pathname + '#' + editHash;
|
||||
//TODO change text & transalte
|
||||
Cryptpad.alert(Messages._getKey('fm_alert_backupUrl', [url]));
|
||||
$('#fm_backupUrl').val(url);
|
||||
$('#fm_backupUrl').click(function () {
|
||||
|
||||
Reference in New Issue
Block a user