Change the hash in the address bar when browsing a shared folder
This commit is contained in:
@@ -223,6 +223,8 @@ define({
|
||||
// Refresh the drive when the drive has changed ('change' or 'remove' events)
|
||||
'EV_DRIVE_CHANGE': true,
|
||||
'EV_DRIVE_REMOVE': true,
|
||||
// Set shared folder hash in the address bar
|
||||
'EV_DRIVE_SET_HASH': true,
|
||||
|
||||
// Remove an owned pad from the server
|
||||
'Q_REMOVE_OWNED_CHANNEL': true,
|
||||
|
||||
@@ -1895,8 +1895,8 @@ define([
|
||||
'class': 'cp-toolbar-share-button',
|
||||
title: Messages.shareButton
|
||||
});
|
||||
var $icon = $sharedIcon.clone().appendTo($shareBlock);
|
||||
var $text = $('<span>').text(Messages.shareButton).appendTo($shareBlock);
|
||||
$sharedIcon.clone().appendTo($shareBlock);
|
||||
$('<span>').text(Messages.shareButton).appendTo($shareBlock);
|
||||
var data = manager.getSharedFolderData(id);
|
||||
var parsed = Hash.parsePadUrl(data.href);
|
||||
if (!parsed || !parsed.hash) { return void console.error("Invalid href: "+data.href); }
|
||||
@@ -2579,7 +2579,12 @@ define([
|
||||
createNewButton(isInRoot, $toolbar.find('.cp-app-drive-toolbar-leftside'));
|
||||
var sfId = manager.isInSharedFolder(currentPath);
|
||||
if (sfId) {
|
||||
var sfData = manager.getSharedFolderData(sfId);
|
||||
var parsed = Hash.parsePadUrl(sfData.href);
|
||||
sframeChan.event('EV_DRIVE_SET_HASH', parsed.hash || '');
|
||||
createShareButton(sfId, $toolbar.find('.cp-app-drive-toolbar-leftside'));
|
||||
} else {
|
||||
sframeChan.event('EV_DRIVE_SET_HASH', '');
|
||||
}
|
||||
|
||||
createTitle($toolbar.find('.cp-app-drive-path'), path);
|
||||
|
||||
@@ -87,6 +87,14 @@ define([
|
||||
cb(obj);
|
||||
});
|
||||
});
|
||||
sframeChan.on('EV_DRIVE_SET_HASH', function (hash) {
|
||||
// Update the hash in the address bar
|
||||
var ohc = window.onhashchange;
|
||||
window.onhashchange = function () {};
|
||||
window.location.hash = hash || '';
|
||||
window.onhashchange = ohc;
|
||||
ohc({reset:true});
|
||||
});
|
||||
Cryptpad.onNetworkDisconnect.reg(function () {
|
||||
sframeChan.event('EV_NETWORK_DISCONNECT');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user