+
+ if(window.localStorage) {
+ text = window.localStorage.getItem(getLocalStorageKey());
+ if(text) {
+ logger.debug('Local draft exists');
+ var dialog = Dialog.create({
+ title: gettext('Local draft of a document exists'),
+ text: gettext('Unsaved local draft of this version of the document exists in your browser. Do you want to load it instead?'),
+ submitButtonText: gettext('Yes, restore local draft'),
+ cancelButtonText: gettext('No, use version loaded from the server')
+ });
+ dialog.on('cancel', function() {
+ logger.debug('Bootstrapped version chosen');
+ text = sandbox.getBootstrappedData().document;
+
+ });
+ dialog.on('save', function(event) {
+ logger.debug('Local draft chosen');
+ event.success();
+ });
+ dialog.show();
+ dialog.on('close', function() {
+ loadDocument(text);
+ });
+ } else {
+ loadDocument(sandbox.getBootstrappedData().document);
+ }
+ } else {
+ loadDocument(sandbox.getBootstrappedData().document);
+ }