Merge branch 'staging' into dark2

pull/1/head
ansuz 4 years ago
commit 3a3b087fab

@ -1180,6 +1180,12 @@ define([
// so we can just use those and only check for errors
var $container = $('<span>', {'class':'cp-limit-container'});
var todo = function (err, data) {
if (err === 'RPC_NOT_READY') {
setTimeout(function () {
common.getPinUsage(teamId, todo);
}, 1000);
return;
}
if (err || !data) { return void console.error(err || 'No data'); }
var usage = data.usage;
@ -1849,6 +1855,13 @@ define([
var oldUrl = '';
var updateButton = function () {
var myData = metadataMgr.getUserData();
var privateData = metadataMgr.getPrivateData();
if (!priv.plan && privateData.plan) {
config.$initBlock.empty();
metadataMgr.off('change', updateButton);
UIElements.createUserAdminMenu(Common, config);
return;
}
if (!myData) { return; }
if (loadingAvatar) {
// Try again in 200ms

@ -3259,6 +3259,7 @@ define([
var $spinnerContainer = $(h('div.cp-app-drive-search-spinner'));
var spinner = UI.makeSpinner($spinnerContainer);
var searching = true;
var $input = APP.Search.$input = $('<input>', {
id: 'cp-app-drive-search-input',
placeholder: Messages.fm_searchName,
@ -3266,21 +3267,19 @@ define([
draggable: false,
tabindex: 1,
}).keyup(function (e) {
var lastValue = search.value;
search.value = $input.val().trim();
if (lastValue === search.value) { return; }
if (search.to) { window.clearTimeout(search.to); }
if (search.value === "") {
search.cursor = 0;
APP.displayDirectory([SEARCH]);
if (searching) {
e.preventDefault();
e.stopPropagation();
return;
}
spinner.spin();
var currentValue = $input.val().trim();
if (search.to) { window.clearTimeout(search.to); }
if (e.which === 13) {
spinner.spin();
var newLocation = [SEARCH, $input.val()];
search.cursor = $input[0].selectionStart;
if (!manager.comparePath(newLocation, currentPath.slice())) {
searching = true;
APP.displayDirectory(newLocation);
}
return;
@ -3288,27 +3287,30 @@ define([
if (e.which === 27) {
$input.val('');
search.cursor = 0;
searching = true;
APP.displayDirectory([SEARCH]);
return;
}
if ($input.val()) {
if (!$input.hasClass('cp-app-drive-search-active')) {
$input.addClass('cp-app-drive-search-active');
}
} else {
$input.removeClass('cp-app-drive-search-active');
if (currentValue === "") {
search.cursor = 0;
APP.displayDirectory([SEARCH]);
return;
}
if (currentValue.length < 2) { return; } // Don't autosearch 1 character
search.to = window.setTimeout(function () {
var newLocation = [SEARCH, $input.val()];
search.cursor = $input[0].selectionStart;
if (currentValue === search.value) { return; }
if (!manager.comparePath(newLocation, currentPath.slice())) {
searching = true;
APP.displayDirectory(newLocation);
}
}, 500);
}).on('click mousedown mouseup', function (e) {
e.stopPropagation();
}).val(value || '').appendTo($div);
if (value) { $input.addClass('cp-app-drive-search-active'); }
$input[0].selectionStart = search.cursor || 0;
$input[0].selectionEnd = search.cursor || 0;
@ -3329,6 +3331,7 @@ define([
if (typeof(value) === "string" && value.trim()) {
spinner.spin();
} else {
searching = false;
return;
}
@ -3402,6 +3405,7 @@ define([
});
setTimeout(collapseDrivePath);
spinner.hide();
searching = false;
});
};

@ -88,7 +88,7 @@
#cp-app-whiteboard-delete {
min-width: 40px;
}
.cp-whiteboard-type {
.cp-whiteboard-type, .cp-whiteboard-history {
button {
min-width: 40px;
text-align: center;

@ -53,6 +53,9 @@ define([
var $type = $('.cp-whiteboard-type');
var $brush = $('.cp-whiteboard-type .brush');
var $move = $('.cp-whiteboard-type .move');
var $history = $('.cp-whiteboard-history');
var $undo = $('.cp-whiteboard-history .undo');
var $redo = $('.cp-whiteboard-history .redo');
var $deleteButton = $('#cp-app-whiteboard-delete');
var metadataMgr = framework._.cpNfInner.metadataMgr;
@ -137,6 +140,27 @@ define([
$deleteButton.prop('disabled', '');
});
$undo.click(function () {
if (typeof(APP.canvas.undo) !== "function") { return; }
APP.canvas.undo();
APP.onLocal();
});
$redo.click(function () {
if (typeof(APP.canvas.undo) !== "function") { return; }
APP.canvas.redo();
APP.onLocal();
});
$('body').on('keydown', function (e) {
if (e.which === 90 && e.ctrlKey) {
$undo.click();
return;
}
if (e.which === 89 && e.ctrlKey) {
$redo.click();
return;
}
});
var deleteSelection = function () {
if (APP.draw) { return; }
if (canvas.getActiveObject()) {
@ -436,7 +460,15 @@ define([
};
});
var cleanHistory = function () {
if (Array.isArray(canvas.historyUndo)) {
canvas.historyUndo = canvas.historyUndo.slice(-100);
canvas.historyRedo = canvas.historyRedo.slice(-100);
}
};
framework.onContentUpdate(function (newContent, waitFor) {
cleanHistory();
var content = newContent.content;
canvas.loadFromJSON(content, waitFor(function () {
canvas.renderAll();
@ -445,6 +477,7 @@ define([
});
framework.setContentGetter(function () {
cleanHistory();
var content = canvas.toDatalessJSON();
return {
content: content
@ -475,6 +508,8 @@ define([
};
Messages.undo = "Undo"; // XXX
Messages.redo = "Redo"; // XXX
var initialContent = function () {
return [
h('div#cp-toolbar.cp-toolbar-container'),
@ -494,6 +529,10 @@ define([
h('button.btn.brush.fa.fa-paint-brush.btn-primary', {title: Messages.canvas_brush}),
h('button.btn.move.fa.fa-arrows', {title: Messages.canvas_select}),
]),
h('div.cp-whiteboard-history', [
h('button.btn.undo.fa.fa-undo', {title: Messages.undo}),
h('button.btn.redo.fa.fa-repeat', {title: Messages.redo}),
]),
h('button.btn.fa.fa-trash#cp-app-whiteboard-delete', {
disabled: 'disabled',
title: Messages.canvas_delete
@ -560,6 +599,7 @@ define([
$('body').append($div.html());
}));
}).nThen(function (waitFor) {
require(['/lib/fabric-history.min.js'], waitFor());
// Framework initialization
Framework.create({

Loading…
Cancel
Save