resolve merge conflict
This commit is contained in:
@@ -555,8 +555,11 @@ define([
|
||||
$loading = $('#' + LOADING); //.show();
|
||||
$loading.css('display', '');
|
||||
$loading.removeClass('cp-loading-hidden');
|
||||
$('.cp-loading-spinner-container').show();
|
||||
if (loadingText) {
|
||||
$('#' + LOADING).find('p').text(loadingText);
|
||||
} else {
|
||||
$('#' + LOADING).find('p').text('');
|
||||
}
|
||||
$container = $loading.find('.cp-loading-container');
|
||||
} else {
|
||||
@@ -612,7 +615,10 @@ define([
|
||||
if (exitable) {
|
||||
$(window).focus();
|
||||
$(window).keydown(function (e) {
|
||||
if (e.which === 27) { $('#' + LOADING).hide(); }
|
||||
if (e.which === 27) {
|
||||
$('#' + LOADING).hide();
|
||||
if (typeof(exitable) === "function") { exitable(); }
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -662,7 +668,6 @@ define([
|
||||
position: 'bottom',
|
||||
distance: 0,
|
||||
performance: true,
|
||||
dynamicTitle: true,
|
||||
delay: [delay, 0],
|
||||
sticky: true
|
||||
});
|
||||
@@ -672,6 +677,12 @@ define([
|
||||
setInterval(UI.clearTooltips, delay);
|
||||
var checkRemoved = function (x) {
|
||||
var out = false;
|
||||
var xId = $(x).attr('aria-describedby');
|
||||
if (xId) {
|
||||
if (xId.indexOf('tippy-tooltip-') === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$(x).find('[aria-describedby]').each(function (i, el) {
|
||||
var id = el.getAttribute('aria-describedby');
|
||||
if (id.indexOf('tippy-tooltip-') !== 0) { return; }
|
||||
@@ -685,6 +696,9 @@ define([
|
||||
mutations.forEach(function(mutation) {
|
||||
if (mutation.type === "childList") {
|
||||
for (var i = 0; i < mutation.addedNodes.length; i++) {
|
||||
if ($(mutation.addedNodes[i]).attr('title')) {
|
||||
addTippy(0, mutation.addedNodes[i]);
|
||||
}
|
||||
$(mutation.addedNodes[i]).find('[title]').each(addTippy);
|
||||
}
|
||||
for (var j = 0; j < mutation.removedNodes.length; j++) {
|
||||
|
||||
@@ -177,6 +177,7 @@ define([
|
||||
window.html2canvas = undefined;
|
||||
Thumb.fromDOM = function (opts, cb) {
|
||||
var element = opts.getContainer();
|
||||
if (!element) { return; }
|
||||
var todo = function () {
|
||||
if (opts.filter) { opts.filter(element, true); }
|
||||
window.html2canvas(element, {
|
||||
@@ -202,8 +203,8 @@ define([
|
||||
var mkThumbnail = function () {
|
||||
var content = opts.getContent();
|
||||
if (content === oldThumbnailState) { return; }
|
||||
oldThumbnailState = content;
|
||||
Thumb.fromDOM(opts, function (err, b64) {
|
||||
oldThumbnailState = content;
|
||||
Thumb.setPadThumbnail(common, opts.href, b64);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -463,12 +463,11 @@ define([
|
||||
UIElements.createButton = function (common, type, rightside, data, callback) {
|
||||
var AppConfig = common.getAppConfig();
|
||||
var button;
|
||||
var size = "17px";
|
||||
var sframeChan = common.getSframeChannel();
|
||||
switch (type) {
|
||||
case 'export':
|
||||
button = $('<button>', {
|
||||
'class': 'fa fa-download',
|
||||
'class': 'fa fa-download cp-toolbar-icon-export',
|
||||
title: Messages.exportButtonTitle,
|
||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.exportButton));
|
||||
|
||||
@@ -479,7 +478,7 @@ define([
|
||||
break;
|
||||
case 'import':
|
||||
button = $('<button>', {
|
||||
'class': 'fa fa-upload',
|
||||
'class': 'fa fa-upload cp-toolbar-icon-import',
|
||||
title: Messages.importButtonTitle,
|
||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.importButton));
|
||||
if (callback) {
|
||||
@@ -525,7 +524,8 @@ define([
|
||||
if (!common.isLoggedIn()) { return; }
|
||||
button = $('<button>', {
|
||||
title: Messages.saveTemplateButton,
|
||||
}).append($('<span>', {'class':'fa fa-bookmark', style: 'font:'+size+' FontAwesome'}));
|
||||
class: 'fa fa-bookmark cp-toolbar-icon-template'
|
||||
});
|
||||
if (data.rt) {
|
||||
button
|
||||
.click(function () {
|
||||
@@ -570,37 +570,44 @@ define([
|
||||
break;
|
||||
case 'forget':
|
||||
button = $('<button>', {
|
||||
id: 'cryptpad-forget',
|
||||
title: Messages.forgetButtonTitle,
|
||||
'class': "fa fa-trash cryptpad-forget",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
'class': "fa fa-trash cp-toolbar-icon-forget"
|
||||
});
|
||||
if (callback) {
|
||||
button
|
||||
.click(common.prepareFeedback(type))
|
||||
.click(function() {
|
||||
var msg = common.isLoggedIn() ? Messages.forgetPrompt : Messages.fm_removePermanentlyDialog;
|
||||
UI.confirm(msg, function (yes) {
|
||||
if (!yes) { return; }
|
||||
sframeChan.query('Q_MOVE_TO_TRASH', null, function (err) {
|
||||
if (err) { return void callback(err); }
|
||||
var cMsg = common.isLoggedIn() ? Messages.movedToTrash : Messages.deleted;
|
||||
UI.alert(cMsg, undefined, true);
|
||||
callback();
|
||||
return;
|
||||
});
|
||||
callback = typeof callback === "function" ? callback : function () {};
|
||||
button
|
||||
.click(common.prepareFeedback(type))
|
||||
.click(function() {
|
||||
var msg = common.isLoggedIn() ? Messages.forgetPrompt : Messages.fm_removePermanentlyDialog;
|
||||
UI.confirm(msg, function (yes) {
|
||||
if (!yes) { return; }
|
||||
sframeChan.query('Q_MOVE_TO_TRASH', null, function (err) {
|
||||
if (err) { return void callback(err); }
|
||||
var cMsg = common.isLoggedIn() ? Messages.movedToTrash : Messages.deleted;
|
||||
UI.alert(cMsg, undefined, true);
|
||||
callback();
|
||||
return;
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'present':
|
||||
button = $('<button>', {
|
||||
title: Messages.presentButtonTitle,
|
||||
'class': "fa fa-play-circle cp-app-slide-present-button", // used in slide.js
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
'class': "fa fa-play-circle cp-toolbar-icon-present", // used in slide.js
|
||||
});
|
||||
break;
|
||||
case 'preview':
|
||||
button = $('<button>', {
|
||||
title: Messages.previewButtonTitle,
|
||||
'class': "fa fa-eye cp-toolbar-icon-preview",
|
||||
});
|
||||
break;
|
||||
case 'print':
|
||||
button = $('<button>', {
|
||||
title: Messages.printButtonTitle,
|
||||
'class': "fa fa-print cp-toolbar-icon-print",
|
||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.printText));
|
||||
break;
|
||||
case 'history':
|
||||
if (!AppConfig.enableHistory) {
|
||||
button = $('<span>');
|
||||
@@ -608,7 +615,7 @@ define([
|
||||
}
|
||||
button = $('<button>', {
|
||||
title: Messages.historyButton,
|
||||
'class': "fa fa-history history",
|
||||
'class': "fa fa-history cp-toolbar-icon-history",
|
||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'}).text(Messages.historyText));
|
||||
if (data.histConfig) {
|
||||
button
|
||||
@@ -622,19 +629,25 @@ define([
|
||||
button = $('<button>', {
|
||||
title: Messages.moreActions,
|
||||
'class': "cp-toolbar-drawer-button fa fa-ellipsis-h",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
});
|
||||
break;
|
||||
case 'mediatag':
|
||||
button = $('<button>', {
|
||||
'class': 'fa fa-picture-o cp-toolbar-icon-mediatag',
|
||||
title: Messages.filePickerButton,
|
||||
})
|
||||
.click(common.prepareFeedback(type));
|
||||
break;
|
||||
case 'savetodrive':
|
||||
button = $('<button>', {
|
||||
'class': 'fa fa-cloud-upload',
|
||||
'class': 'fa fa-cloud-upload cp-toolbar-icon-savetodrive',
|
||||
title: Messages.canvas_saveToDrive,
|
||||
})
|
||||
.click(common.prepareFeedback(type));
|
||||
break;
|
||||
case 'hashtag':
|
||||
button = $('<button>', {
|
||||
'class': 'fa fa-hashtag',
|
||||
'class': 'fa fa-hashtag cp-toolbar-icon-hashtag',
|
||||
title: Messages.tags_title,
|
||||
})
|
||||
.click(common.prepareFeedback(type))
|
||||
@@ -642,7 +655,7 @@ define([
|
||||
break;
|
||||
case 'toggle':
|
||||
button = $('<button>', {
|
||||
'class': 'fa fa-caret-down',
|
||||
'class': 'fa fa-caret-down cp-toolbar-icon-toggle',
|
||||
})
|
||||
.click(common.prepareFeedback(type));
|
||||
window.setTimeout(function () {
|
||||
@@ -657,13 +670,18 @@ define([
|
||||
data.element.toggle();
|
||||
var isVisible = data.element.is(':visible');
|
||||
if (callback) { callback(isVisible); }
|
||||
if (isVisible) {
|
||||
button.addClass('cp-toolbar-button-active');
|
||||
} else {
|
||||
button.removeClass('cp-toolbar-button-active');
|
||||
}
|
||||
updateIcon(isVisible);
|
||||
});
|
||||
updateIcon(data.element.is(':visible'));
|
||||
break;
|
||||
case 'properties':
|
||||
button = $('<button>', {
|
||||
'class': 'fa fa-info-circle',
|
||||
'class': 'fa fa-info-circle cp-toolbar-icon-properties',
|
||||
title: Messages.propertiesButtonTitle,
|
||||
}).append($('<span>', {'class': 'cp-toolbar-drawer-element'})
|
||||
.text(Messages.propertiesButton))
|
||||
@@ -679,11 +697,24 @@ define([
|
||||
});
|
||||
break;
|
||||
default:
|
||||
data = data || {};
|
||||
var icon = data.icon || "fa-question";
|
||||
button = $('<button>', {
|
||||
'class': "fa fa-question",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
'class': "fa " + icon,
|
||||
})
|
||||
.click(common.prepareFeedback(type));
|
||||
if (data.title) { button.attr('title', data.title); }
|
||||
if (data.style) { button.attr('style', data.style); }
|
||||
if (data.id) { button.attr('id', data.id); }
|
||||
if (data.hiddenReadOnly) { button.addClass('cp-hidden-if-readonly'); }
|
||||
if (data.name) {
|
||||
button.addClass('cp-toolbar-icon-'+data.name);
|
||||
button.click(common.prepareFeedback(data.name));
|
||||
}
|
||||
if (data.text) {
|
||||
$('<span>', {'class': 'cp-toolbar-drawer-element'}).text(data.text)
|
||||
.appendTo(button);
|
||||
}
|
||||
}
|
||||
if (rightside) {
|
||||
button.addClass('cp-toolbar-rightside-button');
|
||||
@@ -855,6 +886,51 @@ define([
|
||||
};
|
||||
};
|
||||
|
||||
UIElements.createHelpMenu = function (common) {
|
||||
var type = common.getMetadataMgr().getMetadata().type || 'pad';
|
||||
|
||||
var text = h('p.cp-help-text');
|
||||
var closeButton = h('span.cp-help-close.fa.fa-window-close');
|
||||
var $toolbarButton = common.createButton('', true, {
|
||||
title: Messages.hide_help_button,
|
||||
text: Messages.help_button,
|
||||
name: 'help'
|
||||
}).addClass('cp-toolbar-button-active');
|
||||
var help = h('div.cp-help-container', [
|
||||
closeButton,
|
||||
text
|
||||
]);
|
||||
|
||||
var toggleHelp = function (forceClose) {
|
||||
if ($(help).hasClass('cp-help-hidden')) {
|
||||
if (forceClose) { return; }
|
||||
common.setAttribute(['hideHelp', type], false);
|
||||
$toolbarButton.addClass('cp-toolbar-button-active');
|
||||
$toolbarButton.attr('title', Messages.hide_help_button);
|
||||
return void $(help).removeClass('cp-help-hidden');
|
||||
}
|
||||
$toolbarButton.removeClass('cp-toolbar-button-active');
|
||||
$toolbarButton.attr('title', Messages.show_help_button);
|
||||
$(help).addClass('cp-help-hidden');
|
||||
common.setAttribute(['hideHelp', type], true);
|
||||
};
|
||||
|
||||
$(closeButton).click(function () { toggleHelp(true); });
|
||||
$toolbarButton.click(function () {
|
||||
toggleHelp();
|
||||
});
|
||||
|
||||
common.getAttribute(['hideHelp', type], function (err, val) {
|
||||
if (val === true) { toggleHelp(true); }
|
||||
});
|
||||
|
||||
return {
|
||||
menu: help,
|
||||
button: $toolbarButton,
|
||||
text: text
|
||||
};
|
||||
};
|
||||
|
||||
// Avatars
|
||||
|
||||
// Enable mediatags
|
||||
@@ -1489,6 +1565,7 @@ define([
|
||||
if (!$blockContainer.length) {
|
||||
$blockContainer = $('<div>', {
|
||||
'class': 'cp-modal-container',
|
||||
tabindex: 1,
|
||||
'id': cfg.id
|
||||
});
|
||||
}
|
||||
@@ -1520,14 +1597,16 @@ define([
|
||||
$body: $('body')
|
||||
});
|
||||
var $title = $('<h3>').text(Messages.fm_newFile);
|
||||
var $description = $('<p>').text(Messages.creation_newPadModalDescription);
|
||||
var $description = $('<p>').html(Messages.creation_newPadModalDescription);
|
||||
$modal.find('.cp-modal').append($title);
|
||||
$modal.find('.cp-modal').append($description);
|
||||
|
||||
var $advanced;
|
||||
|
||||
var $advancedContainer = $('<div>');
|
||||
if (common.isLoggedIn()) {
|
||||
var priv = common.getMetadataMgr().getPrivateData();
|
||||
var c = (priv.settings.general && priv.settings.general.creation) || {};
|
||||
if (AppConfig.displayCreationScreen && common.isLoggedIn() && c.skip) {
|
||||
$advanced = $('<input>', {
|
||||
type: 'checkbox',
|
||||
checked: 'checked',
|
||||
@@ -1536,9 +1615,12 @@ define([
|
||||
$('<label>', {
|
||||
for: 'cp-app-toolbar-creation-advanced'
|
||||
}).text(Messages.creation_newPadModalAdvanced).appendTo($advancedContainer);
|
||||
$description.append('<br>');
|
||||
$description.append(Messages.creation_newPadModalDescriptionAdvanced);
|
||||
}
|
||||
|
||||
var $container = $('<div>');
|
||||
var i = 0;
|
||||
AppConfig.availablePadTypes.forEach(function (p) {
|
||||
if (p === 'drive') { return; }
|
||||
if (p === 'contacts') { return; }
|
||||
@@ -1547,7 +1629,8 @@ define([
|
||||
if (!common.isLoggedIn() && AppConfig.registeredOnlyTypes &&
|
||||
AppConfig.registeredOnlyTypes.indexOf(p) !== -1) { return; }
|
||||
var $element = $('<li>', {
|
||||
'class': 'cp-icons-element'
|
||||
'class': 'cp-icons-element',
|
||||
'id': 'cp-newpad-icons-'+ (i++)
|
||||
}).prepend(UI.getIcon(p)).appendTo($container);
|
||||
$element.append($('<span>', {'class': 'cp-icons-name'})
|
||||
.text(Messages.type[p]));
|
||||
@@ -1555,7 +1638,7 @@ define([
|
||||
$element.click(function () {
|
||||
$modal.hide();
|
||||
if ($advanced && $advanced.is(':checked')) {
|
||||
common.sessionStorage.put(Constants.displayPadCreationScreen, true, function () {
|
||||
common.sessionStorage.put(Constants.displayPadCreationScreen, true, function (){
|
||||
common.openURL('/' + p + '/');
|
||||
});
|
||||
return;
|
||||
@@ -1566,11 +1649,41 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
var selected = -1;
|
||||
var next = function () {
|
||||
selected = ++selected % 5;
|
||||
$container.find('.cp-icons-element-selected').removeClass('cp-icons-element-selected');
|
||||
$container.find('#cp-newpad-icons-'+selected).addClass('cp-icons-element-selected');
|
||||
};
|
||||
|
||||
$modal.off('keydown');
|
||||
$modal.keydown(function (e) {
|
||||
if (e.which === 9) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if (e.which === 13) {
|
||||
if ($container.find('.cp-icons-element-selected').length === 1) {
|
||||
$container.find('.cp-icons-element-selected').click();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (e.which === 32 && $advanced) {
|
||||
$advanced.prop('checked', !$advanced.prop('checked'));
|
||||
$modal.focus();
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*var $content = createNewPadIcons($modal, isInRoot);*/
|
||||
$modal.find('.cp-modal').append($container).append($advancedContainer);
|
||||
window.setTimeout(function () { $modal.show(); });
|
||||
//addNewPadHandlers($modal, isInRoot);
|
||||
window.setTimeout(function () {
|
||||
$modal.show();
|
||||
$modal.focus();
|
||||
});
|
||||
};
|
||||
|
||||
UIElements.initFilePicker = function (common, cfg) {
|
||||
@@ -1663,7 +1776,7 @@ define([
|
||||
|
||||
var $body = $('body');
|
||||
var $creationContainer = $('<div>', { id: 'cp-creation-container' }).appendTo($body);
|
||||
var $creation = $('<div>', { id: 'cp-creation' }).appendTo($creationContainer);
|
||||
var $creation = $('<div>', { id: 'cp-creation', tabindex: 1 }).appendTo($creationContainer);
|
||||
|
||||
var setHTML = function (e, html) {
|
||||
e.innerHTML = html;
|
||||
@@ -1763,7 +1876,7 @@ define([
|
||||
UIElements.setExpirationValue(cfg.expire, $creation);
|
||||
|
||||
// Create the pad
|
||||
var create = function (template) {
|
||||
var getFormValues = function (template) {
|
||||
// Type of pad
|
||||
var ownedVal = parseInt($('input[name="cp-creation-owned"]:checked').val());
|
||||
// Life time
|
||||
@@ -1779,12 +1892,16 @@ define([
|
||||
expireVal = ($('#cp-creation-expire-val').val() || 0) * unit;
|
||||
}
|
||||
|
||||
common.createPad({
|
||||
return {
|
||||
owned: ownedVal,
|
||||
expire: expireVal,
|
||||
template: template
|
||||
}, function () {
|
||||
$creationContainer.remove();
|
||||
};
|
||||
};
|
||||
var create = function (template) {
|
||||
$creationContainer.remove();
|
||||
|
||||
common.createPad(getFormValues(template), function () {
|
||||
cb();
|
||||
});
|
||||
};
|
||||
@@ -1829,10 +1946,62 @@ define([
|
||||
|
||||
// Settings button
|
||||
var origin = common.getMetadataMgr().getPrivateData().origin;
|
||||
$(h('div.cp-creation-settings', h('a', {
|
||||
href: origin + '/settings/#creation',
|
||||
target: '_blank'
|
||||
}, Messages.creation_settings))).appendTo($creation);
|
||||
var $ok = $('<span>', {'class': 'fa fa-check', title: Messages.saved}).hide();
|
||||
var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'}).hide();
|
||||
var okTo;
|
||||
var $saveButton = $('<button>').text(Messages.creation_saveSettings).click(function () {
|
||||
if (okTo) { clearTimeout(okTo); }
|
||||
$ok.hide();
|
||||
$spinner.show();
|
||||
var val = getFormValues();
|
||||
NThen(function (waitFor) {
|
||||
common.setAttribute(['general', 'creation', 'owned'], val.owned, waitFor(function (e) {
|
||||
if (e) { return void console.error(e); }
|
||||
}));
|
||||
common.setAttribute(['general', 'creation', 'expire'], val.expire, waitFor(function (e) {
|
||||
if (e) { return void console.error(e); }
|
||||
}));
|
||||
}).nThen(function () {
|
||||
$spinner.hide();
|
||||
$ok.show();
|
||||
okTo = setTimeout(function () {
|
||||
$ok.hide();
|
||||
}, 5000);
|
||||
});
|
||||
});
|
||||
$(h('div.cp-creation-settings', [
|
||||
$saveButton[0],
|
||||
h('br'),
|
||||
h('a', {
|
||||
href: origin + '/settings/#creation',
|
||||
target: '_blank'
|
||||
}, Messages.creation_settings),
|
||||
$ok[0],
|
||||
$spinner[0]
|
||||
])).appendTo($creation);
|
||||
|
||||
var selected = -1;
|
||||
var next = function () {
|
||||
selected = ++selected % $creation.find('button').length;
|
||||
$creation.find('button').removeClass('cp-creation-button-selected');
|
||||
$($creation.find('button').get(selected)).addClass('cp-creation-button-selected');
|
||||
};
|
||||
|
||||
$creation.keydown(function (e) {
|
||||
if (e.which === 9) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if (e.which === 13) {
|
||||
if ($creation.find('.cp-creation-button-selected').length === 1) {
|
||||
$creation.find('.cp-creation-button-selected').click();
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
$creation.focus();
|
||||
};
|
||||
|
||||
UIElements.onServerError = function (common, err, toolbar, cb) {
|
||||
|
||||
@@ -116,6 +116,7 @@ define([
|
||||
|
||||
/* remove listeners from the DOM */
|
||||
var removeListeners = function (root) {
|
||||
if (!root) { return; }
|
||||
slice(root.attributes).map(function (attr) {
|
||||
if (/^on/i.test(attr.name)) {
|
||||
console.log('removing attribute', attr.name, root.attributes[attr.name]);
|
||||
@@ -171,7 +172,9 @@ define([
|
||||
return mt + '</media-tag>';
|
||||
});
|
||||
|
||||
var safe_newHtmlFixed = domFromHTML(unsafe_newHtmlFixed).body.outerHTML;
|
||||
var newDomFixed = domFromHTML(unsafe_newHtmlFixed);
|
||||
if (!newDomFixed || !newDomFixed.body) { return; }
|
||||
var safe_newHtmlFixed = newDomFixed.body.outerHTML;
|
||||
var $div = $('<div>', {id: id}).append(safe_newHtmlFixed);
|
||||
|
||||
var Dom = domFromHTML($('<div>').append($div).html());
|
||||
|
||||
@@ -398,11 +398,7 @@ define([
|
||||
'" data-crypto-key="cryptpad:' + data.key + '"></media-tag>'), data);
|
||||
}
|
||||
});
|
||||
$embedButton = $('<button>', {
|
||||
title: Messages.filePickerButton,
|
||||
'class': 'cp-toolbar-rightside-button fa fa-picture-o',
|
||||
style: 'font-size: 17px'
|
||||
}).click(function () {
|
||||
$embedButton = common.createButton('mediatag', true).click(function () {
|
||||
common.openFilePicker({
|
||||
types: ['file'],
|
||||
where: ['root']
|
||||
@@ -426,15 +422,7 @@ define([
|
||||
common.getSframeChannel().onReady(waitFor());
|
||||
}).nThen(function (waitFor) {
|
||||
Test.registerInner(common.getSframeChannel());
|
||||
if (!AppConfig.displayCreationScreen) { return; }
|
||||
var priv = common.getMetadataMgr().getPrivateData();
|
||||
if (priv.isNewFile) {
|
||||
var c = (priv.settings.general && priv.settings.general.creation) || {};
|
||||
if (c.skip && !priv.forceCreationScreen) {
|
||||
return void common.createPad(c, waitFor());
|
||||
}
|
||||
common.getPadCreationScreen(c, waitFor());
|
||||
}
|
||||
common.handleNewFile(waitFor);
|
||||
}).nThen(function (waitFor) {
|
||||
cpNfInner = common.startRealtime({
|
||||
// really basic operational transform
|
||||
|
||||
@@ -141,7 +141,6 @@ define([
|
||||
mode: defaultMode || "javascript",
|
||||
readOnly: true
|
||||
});
|
||||
//editor.setValue(Messages.codeInitialState);
|
||||
editor.focus();
|
||||
|
||||
var setMode = exp.setMode = function (mode, cb) {
|
||||
|
||||
@@ -187,7 +187,7 @@ define([
|
||||
upgradeURL: Cryptpad.upgradeURL
|
||||
},
|
||||
isNewFile: isNewFile,
|
||||
isDeleted: window.location.hash.length > 0,
|
||||
isDeleted: isNewFile && window.location.hash.length > 0,
|
||||
forceCreationScreen: forceCreationScreen
|
||||
};
|
||||
for (var k in additionalPriv) { metaObj.priv[k] = additionalPriv[k]; }
|
||||
@@ -666,8 +666,9 @@ define([
|
||||
Utils.Feedback.reportAppUsage();
|
||||
|
||||
if (!realtime) { return; }
|
||||
if (isNewFile && Utils.LocalStore.isLoggedIn()
|
||||
&& AppConfig.displayCreationScreen && cfg.useCreationScreen) { return; }
|
||||
if (isNewFile && cfg.useCreationScreen) { return; }
|
||||
//if (isNewFile && Utils.LocalStore.isLoggedIn()
|
||||
// && AppConfig.displayCreationScreen && cfg.useCreationScreen) { return; }
|
||||
|
||||
startRealtime();
|
||||
});
|
||||
|
||||
@@ -90,6 +90,7 @@ define([
|
||||
funcs.updateTags = callWithCommon(UIElements.updateTags);
|
||||
funcs.createLanguageSelector = callWithCommon(UIElements.createLanguageSelector);
|
||||
funcs.createMarkdownToolbar = callWithCommon(UIElements.createMarkdownToolbar);
|
||||
funcs.createHelpMenu = callWithCommon(UIElements.createHelpMenu);
|
||||
funcs.getPadCreationScreen = callWithCommon(UIElements.getPadCreationScreen);
|
||||
funcs.createNewPadModal = callWithCommon(UIElements.createNewPadModal);
|
||||
funcs.onServerError = callWithCommon(UIElements.onServerError);
|
||||
@@ -167,6 +168,30 @@ define([
|
||||
};
|
||||
|
||||
// Store
|
||||
funcs.handleNewFile = function (waitFor) {
|
||||
var priv = ctx.metadataMgr.getPrivateData();
|
||||
if (priv.isNewFile) {
|
||||
var c = (priv.settings.general && priv.settings.general.creation) || {};
|
||||
var skip = !AppConfig.displayCreationScreen || (c.skip && !priv.forceCreationScreen);
|
||||
// If this is a new file but we have a hash in the URL and pad creation screen is
|
||||
// not displayed, then display an error...
|
||||
if (priv.isDeleted && (!funcs.isLoggedIn() || skip)) {
|
||||
UI.errorLoadingScreen(Messages.inactiveError, false, function () {
|
||||
UI.addLoadingScreen();
|
||||
return void funcs.createPad({}, waitFor());
|
||||
});
|
||||
return;
|
||||
}
|
||||
// Otherwise, if we don't display the screen, it means it is not a deleted pad
|
||||
// so we can continue and start realtime...
|
||||
if (!funcs.isLoggedIn() || skip) {
|
||||
return void funcs.createPad(c, waitFor());
|
||||
}
|
||||
// If we display the pad creation screen, it will handle deleted pads directly
|
||||
console.log('here');
|
||||
funcs.getPadCreationScreen(c, waitFor());
|
||||
}
|
||||
};
|
||||
funcs.createPad = function (cfg, cb) {
|
||||
ctx.sframeChan.query("Q_CREATE_PAD", {
|
||||
owned: cfg.owned,
|
||||
|
||||
@@ -318,7 +318,7 @@ define([
|
||||
$span.append($rightCol);
|
||||
} else {
|
||||
Common.displayAvatar($span, data.avatar, name, function ($img) {
|
||||
if (data.avatar && $img.length) {
|
||||
if (data.avatar && $img && $img.length) {
|
||||
avatars[data.avatar] = $img[0].outerHTML;
|
||||
}
|
||||
$span.append($rightCol);
|
||||
@@ -377,38 +377,15 @@ define([
|
||||
config.$contentContainer.prepend($content);
|
||||
}
|
||||
|
||||
var $ck = config.$container.find('.cke_toolbox_main');
|
||||
var mobile = $('body').width() <= 600;
|
||||
var hide = function () {
|
||||
$content.hide();
|
||||
$button.removeClass('cp-toolbar-button-active');
|
||||
$ck.css({
|
||||
'padding-left': '',
|
||||
});
|
||||
};
|
||||
var show = function () {
|
||||
if (Bar.isEmbed) { $content.hide(); return; }
|
||||
$content.show();
|
||||
if (mobile) {
|
||||
$ck.hide();
|
||||
}
|
||||
$button.addClass('cp-toolbar-button-active');
|
||||
$ck.css({
|
||||
'padding-left': '175px',
|
||||
});
|
||||
var h = $ck.is(':visible') ? -$ck.height() : 0;
|
||||
$content.css('margin-top', h+'px');
|
||||
};
|
||||
$(window).on('cryptpad-ck-toolbar', function () {
|
||||
if (mobile && $ck.is(':visible')) { return void hide(); }
|
||||
if ($content.is(':visible')) { return void show(); }
|
||||
hide();
|
||||
});
|
||||
$(window).on('resize', function () {
|
||||
mobile = $('body').width() <= 600;
|
||||
var h = $ck.is(':visible') ? -$ck.height() : 0;
|
||||
$content.css('margin-top', h+'px');
|
||||
});
|
||||
$closeIcon.click(function () {
|
||||
Common.setAttribute(['toolbar', 'userlist-drawer'], false);
|
||||
hide();
|
||||
@@ -423,7 +400,7 @@ define([
|
||||
});
|
||||
show();
|
||||
Common.getAttribute(['toolbar', 'userlist-drawer'], function (err, val) {
|
||||
if (val === false || mobile) { return void hide(); }
|
||||
if (val === false) { return void hide(); }
|
||||
show();
|
||||
});
|
||||
|
||||
@@ -593,7 +570,7 @@ define([
|
||||
};
|
||||
|
||||
var createUnpinnedWarning0 = function (toolbar, config) {
|
||||
if (true) { return; } // stub this call since it won't make it into the next release
|
||||
//if (true) { return; } // stub this call since it won't make it into the next release
|
||||
if (Common.isLoggedIn()) { return; }
|
||||
var pd = config.metadataMgr.getPrivateData();
|
||||
var o = pd.origin;
|
||||
@@ -633,7 +610,7 @@ define([
|
||||
});
|
||||
});
|
||||
$('.cp-toolbar-top').append($msg);
|
||||
UI.addTooltips();
|
||||
//UI.addTooltips();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -791,21 +768,19 @@ 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
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 || (navigator.platform === "MacIntel" && e.metaKey))) {
|
||||
Common.createNewPadModal();
|
||||
}
|
||||
});
|
||||
var dropdownConfig = {
|
||||
text: '', // Button initial text
|
||||
options: pads_options, // Entries displayed in the menu
|
||||
|
||||
Reference in New Issue
Block a user