Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging
This commit is contained in:
@@ -11,5 +11,6 @@ define(function () {
|
||||
oldStorageKey: 'CryptPad_RECENTPADS',
|
||||
storageKey: 'filesData',
|
||||
tokenKey: 'loginToken',
|
||||
displayPadCreationScreen: 'displayPadCreationScreen'
|
||||
};
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ define([
|
||||
'/common/common-hash.js',
|
||||
'/common/common-language.js',
|
||||
'/common/common-interface.js',
|
||||
'/common/common-constants.js',
|
||||
'/common/common-feedback.js',
|
||||
'/common/hyperscript.js',
|
||||
'/common/media-tag.js',
|
||||
@@ -13,8 +14,8 @@ define([
|
||||
'/bower_components/nthen/index.js',
|
||||
|
||||
'css!/common/tippy.css',
|
||||
], function ($, Config, Util, Hash, Language, UI, Feedback, h, MediaTag, Messages, AppConfig,
|
||||
NThen) {
|
||||
], function ($, Config, Util, Hash, Language, UI, Constants, Feedback, h, MediaTag, Messages,
|
||||
AppConfig, NThen) {
|
||||
var UIElements = {};
|
||||
|
||||
// Configure MediaTags to use our local viewer
|
||||
@@ -1263,6 +1264,64 @@ define([
|
||||
return $blockContainer;
|
||||
};
|
||||
|
||||
UIElements.createNewPadModal = function (common) {
|
||||
var $modal = UIElements.createModal({
|
||||
id: 'cp-app-toolbar-creation-dialog',
|
||||
$body: $('body')
|
||||
});
|
||||
var $title = $('<h3>').text(Messages.fm_newFile);
|
||||
var $description = $('<p>').text(Messages.creation_newPadModalDescription);
|
||||
$modal.find('.cp-modal').append($title);
|
||||
$modal.find('.cp-modal').append($description);
|
||||
|
||||
var $advanced;
|
||||
|
||||
var $advancedContainer = $('<div>');
|
||||
if (common.isLoggedIn()) {
|
||||
$advanced = $('<input>', {
|
||||
type: 'checkbox',
|
||||
checked: 'checked',
|
||||
id: 'cp-app-toolbar-creation-advanced'
|
||||
}).appendTo($advancedContainer);
|
||||
$('<label>', {
|
||||
for: 'cp-app-toolbar-creation-advanced'
|
||||
}).text(Messages.creation_newPadModalAdvanced).appendTo($advancedContainer);
|
||||
}
|
||||
|
||||
var $container = $('<div>');
|
||||
AppConfig.availablePadTypes.forEach(function (p) {
|
||||
if (p === 'drive') { return; }
|
||||
if (p === 'contacts') { return; }
|
||||
if (p === 'todo') { return; }
|
||||
if (p === 'file') { return; }
|
||||
if (!common.isLoggedIn() && AppConfig.registeredOnlyTypes &&
|
||||
AppConfig.registeredOnlyTypes.indexOf(p) !== -1) { return; }
|
||||
var $element = $('<li>', {
|
||||
'class': 'cp-icons-element'
|
||||
}).prepend(UI.getIcon(p)).appendTo($container);
|
||||
$element.append($('<span>', {'class': 'cp-icons-name'})
|
||||
.text(Messages.type[p]));
|
||||
$element.attr('data-type', p);
|
||||
$element.click(function () {
|
||||
$modal.hide();
|
||||
if ($advanced && $advanced.is(':checked')) {
|
||||
common.sessionStorage.put(Constants.displayPadCreationScreen, true, function () {
|
||||
common.openURL('/' + p + '/');
|
||||
});
|
||||
return;
|
||||
}
|
||||
common.sessionStorage.put(Constants.displayPadCreationScreen, "", function () {
|
||||
common.openURL('/' + p + '/');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/*var $content = createNewPadIcons($modal, isInRoot);*/
|
||||
$modal.find('.cp-modal').append($container).append($advancedContainer);
|
||||
window.setTimeout(function () { $modal.show(); });
|
||||
//addNewPadHandlers($modal, isInRoot);
|
||||
};
|
||||
|
||||
UIElements.initFilePicker = function (common, cfg) {
|
||||
var onSelect = cfg.onSelect || $.noop;
|
||||
|
||||
@@ -407,7 +407,7 @@ define([
|
||||
var priv = common.getMetadataMgr().getPrivateData();
|
||||
if (priv.isNewFile) {
|
||||
var c = (priv.settings.general && priv.settings.general.creation) || {};
|
||||
if (c.skip) { return void common.createPad(c, waitFor()); }
|
||||
if (c.skip && !priv.forceCreationScreen) { return void common.createPad(c, waitFor()); }
|
||||
common.getPadCreationScreen(c, waitFor());
|
||||
}
|
||||
}).nThen(function (waitFor) {
|
||||
|
||||
@@ -148,6 +148,9 @@ define([
|
||||
if (!parsed.type) { throw new Error(); }
|
||||
var defaultTitle = Utils.Hash.getDefaultName(parsed);
|
||||
var edPublic;
|
||||
var forceCreationScreen = cfg.useCreationScreen &&
|
||||
sessionStorage[Utils.Constants.displayPadCreationScreen];
|
||||
delete sessionStorage[Utils.Constants.displayPadCreationScreen];
|
||||
var updateMeta = function () {
|
||||
//console.log('EV_METADATA_UPDATE');
|
||||
var metaObj, isTemplate;
|
||||
@@ -182,7 +185,8 @@ define([
|
||||
upgradeURL: Cryptpad.upgradeURL
|
||||
},
|
||||
isNewFile: isNewFile,
|
||||
isDeleted: window.location.hash.length > 0
|
||||
isDeleted: window.location.hash.length > 0,
|
||||
forceCreationScreen: forceCreationScreen
|
||||
};
|
||||
for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; }
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ define([
|
||||
funcs.createLanguageSelector = callWithCommon(UIElements.createLanguageSelector);
|
||||
funcs.createMarkdownToolbar = callWithCommon(UIElements.createMarkdownToolbar);
|
||||
funcs.getPadCreationScreen = callWithCommon(UIElements.getPadCreationScreen);
|
||||
funcs.createNewPadModal = callWithCommon(UIElements.createNewPadModal);
|
||||
|
||||
// Thumb
|
||||
funcs.displayThumbnail = callWithCommon(Thumb.displayThumbnail);
|
||||
|
||||
@@ -933,6 +933,21 @@ define([
|
||||
content: $('<div>').append(UI.getIcon(p)).html() + Messages.type[p]
|
||||
});
|
||||
});
|
||||
if (Config.displayCreationScreen) {
|
||||
pads_options.push({
|
||||
tag: 'a',
|
||||
attributes: {
|
||||
id: 'cp-app-toolbar-creation-advanced',
|
||||
href: origin
|
||||
},
|
||||
content: '<span class="fa fa-plus-circle"></span> ' + Messages.creation_appMenuName
|
||||
});
|
||||
$(window).keydown(function (e) {
|
||||
if (e.which === 69 && e.ctrlKey) {
|
||||
Common.createNewPadModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
var dropdownConfig = {
|
||||
text: '', // Button initial text
|
||||
options: pads_options, // Entries displayed in the menu
|
||||
@@ -945,6 +960,10 @@ define([
|
||||
var $newPadBlock = UIElements.createDropdown(dropdownConfig);
|
||||
$newPadBlock.find('button').attr('title', Messages.newButtonTitle);
|
||||
$newPadBlock.find('button').addClass('fa fa-th');
|
||||
$newPadBlock.find('#cp-app-toolbar-creation-advanced').click(function (e) {
|
||||
e.preventDefault();
|
||||
Common.createNewPadModal();
|
||||
});
|
||||
return $newPadBlock;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user