parent
920dbeabd1
commit
c3d2568d3c
@ -8,10 +8,12 @@ define([
|
|||||||
'/common/toolbar.js',
|
'/common/toolbar.js',
|
||||||
'json.sortify',
|
'json.sortify',
|
||||||
'/bower_components/chainpad-json-validator/json-ot.js',
|
'/bower_components/chainpad-json-validator/json-ot.js',
|
||||||
|
'/bower_components/file-saver/FileSaver.min.js',
|
||||||
'/bower_components/jquery/dist/jquery.min.js',
|
'/bower_components/jquery/dist/jquery.min.js',
|
||||||
'/customize/pad.js'
|
'/customize/pad.js'
|
||||||
], function (Config, /*RTCode,*/ Messages, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT) {
|
], function (Config, /*RTCode,*/ Messages, Crypto, Realtime, TextPatcher, Toolbar, JSONSortify, JsonOT) {
|
||||||
var $ = window.jQuery;
|
var $ = window.jQuery;
|
||||||
|
var saveAs = window.saveAs;
|
||||||
var module = window.APP = {};
|
var module = window.APP = {};
|
||||||
var ifrw = module.ifrw = $('#pad-iframe')[0].contentWindow;
|
var ifrw = module.ifrw = $('#pad-iframe')[0].contentWindow;
|
||||||
var stringify = function (obj) {
|
var stringify = function (obj) {
|
||||||
@ -57,6 +59,15 @@ define([
|
|||||||
editor.setOption('readOnly', !bool);
|
editor.setOption('readOnly', !bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var exportText = module.exportText = function () {
|
||||||
|
var text = editor.getValue();
|
||||||
|
var filename = window.prompt("What would you like to name your file?");
|
||||||
|
if (filename) {
|
||||||
|
var blob = new Blob([text], {type: "text/plain;charset=utf-8"});
|
||||||
|
saveAs(blob, filename);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var userList = {}; // List of pretty name of all users (mapped with their server ID)
|
var userList = {}; // List of pretty name of all users (mapped with their server ID)
|
||||||
var toolbarList; // List of users still connected to the channel (server IDs)
|
var toolbarList; // List of users still connected to the channel (server IDs)
|
||||||
var addToUserList = function(data) {
|
var addToUserList = function(data) {
|
||||||
@ -134,10 +145,13 @@ define([
|
|||||||
toolbarList = info.userList;
|
toolbarList = info.userList;
|
||||||
var config = {
|
var config = {
|
||||||
userData: userList,
|
userData: userList,
|
||||||
changeNameID: 'cryptpad-changeName'
|
changeNameID: 'cryptpad-changeName',
|
||||||
|
saveContentID: 'cryptpad-saveContent',
|
||||||
};
|
};
|
||||||
toolbar = info.realtime.toolbar = Toolbar.create($bar, info.myID, info.realtime, info.getLag, info.userList, config);
|
toolbar = info.realtime.toolbar = Toolbar.create($bar, info.myID, info.realtime, info.getLag, info.userList, config);
|
||||||
createChangeName('cryptpad-changeName', $bar);
|
createChangeName('cryptpad-changeName', $bar);
|
||||||
|
$bar.find('#cryptpad-saveContent').click(exportText);
|
||||||
|
|
||||||
window.location.hash = info.channel + key;
|
window.location.hash = info.channel + key;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,8 @@ define([
|
|||||||
/** Id of the div containing the lag info. */
|
/** Id of the div containing the lag info. */
|
||||||
var LAG_ELEM_CLS = 'rtwysiwyg-lag';
|
var LAG_ELEM_CLS = 'rtwysiwyg-lag';
|
||||||
|
|
||||||
|
var SAVE_ELEMENT_CLS = 'cryptpad-saveContent';
|
||||||
|
|
||||||
/** The toolbar class which contains the user list, debug link and lag. */
|
/** The toolbar class which contains the user list, debug link and lag. */
|
||||||
var TOOLBAR_CLS = 'rtwysiwyg-toolbar';
|
var TOOLBAR_CLS = 'rtwysiwyg-toolbar';
|
||||||
|
|
||||||
@ -96,6 +98,7 @@ define([
|
|||||||
'.' + DEBUG_LINK_CLS + ':link:hover { color:blue; }',
|
'.' + DEBUG_LINK_CLS + ':link:hover { color:blue; }',
|
||||||
'.gwt-TabPanelBottom { border-top: 0 none; }',
|
'.gwt-TabPanelBottom { border-top: 0 none; }',
|
||||||
'.' + TOOLBAR_CLS + ' button { box-sizing: border-box; height: 101%; background-color: inherit; border: 1px solid #A6A6A6; border-radius: 5px; margin-right: 5px;}',
|
'.' + TOOLBAR_CLS + ' button { box-sizing: border-box; height: 101%; background-color: inherit; border: 1px solid #A6A6A6; border-radius: 5px; margin-right: 5px;}',
|
||||||
|
'.' + TOOLBAR_CLS + ' ' + SAVE_ELEMENT_CLS + '{ float: right; margin-right: 5px; }',
|
||||||
|
|
||||||
'</style>'
|
'</style>'
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
@ -178,6 +181,11 @@ define([
|
|||||||
return $container.find('#'+id)[0];
|
return $container.find('#'+id)[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var createSaveElement = function (id, $container) {
|
||||||
|
$container.append('<button class="'+ SAVE_ELEMENT_CLS + '" id="' + id + '">SAVE</button>');
|
||||||
|
return $container.find('#'+id)[0];
|
||||||
|
};
|
||||||
|
|
||||||
var checkLag = function (getLag, lagElement) {
|
var checkLag = function (getLag, lagElement) {
|
||||||
if(typeof getLag !== "function") { return; }
|
if(typeof getLag !== "function") { return; }
|
||||||
var lag = getLag();
|
var lag = getLag();
|
||||||
@ -230,6 +238,8 @@ define([
|
|||||||
var lagElement = createLagElement(toolbar.find('.rtwysiwyg-toolbar-rightside'));
|
var lagElement = createLagElement(toolbar.find('.rtwysiwyg-toolbar-rightside'));
|
||||||
var userData = config.userData;
|
var userData = config.userData;
|
||||||
var changeNameID = config.changeNameID;
|
var changeNameID = config.changeNameID;
|
||||||
|
var saveContentID = config.saveContentID;
|
||||||
|
var saveElement;
|
||||||
|
|
||||||
// Check if the user is allowed to change his name
|
// Check if the user is allowed to change his name
|
||||||
if(changeNameID) {
|
if(changeNameID) {
|
||||||
@ -237,6 +247,10 @@ define([
|
|||||||
userListElement = createChangeName($container, userListElement, changeNameID);
|
userListElement = createChangeName($container, userListElement, changeNameID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (saveContentID) {
|
||||||
|
saveElement = createSaveElement(saveContentID, toolbar.find('.rtwysiwyg-toolbar-rightside'));
|
||||||
|
}
|
||||||
|
|
||||||
rememberPad();
|
rememberPad();
|
||||||
|
|
||||||
var connected = false;
|
var connected = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user