Stackedit/public/res/extensions/welcomeTour.js

90 lines
2.6 KiB
JavaScript
Raw Normal View History

2013-09-03 10:37:59 +00:00
define([
2014-08-10 23:43:46 +00:00
'underscore',
'jquery',
'storage',
2018-01-07 16:23:22 +00:00
'utils',
2014-08-10 23:43:46 +00:00
'classes/Extension',
'bootstrap-tour'
2018-01-07 16:23:22 +00:00
], function(_, $, storage, utils, Extension, Tour) {
2013-09-03 10:37:59 +00:00
2014-08-10 23:43:46 +00:00
var welcomeTour = new Extension('welcomeTour', 'Welcome tour', false, true);
2014-08-10 23:43:46 +00:00
var eventMgr;
welcomeTour.onEventMgrCreated = function(eventMgrParam) {
eventMgr = eventMgrParam;
};
2013-09-03 10:37:59 +00:00
2014-08-10 23:43:46 +00:00
welcomeTour.onReady = function() {
function infoTooltip(btnSelector, title, placement) {
var tooltip = $(btnSelector).tooltip({
html: true,
//container: $('.extension-preview-buttons'),
placement: placement,
trigger: 'manual',
title: title
}).tooltip('show').addClass('info-tooltip');
tooltip.parent().addClass('info-tooltip-container');
tooltip.one('click', function() {
tooltip.tooltip('hide').removeClass('info-tooltip').parent().removeClass('info-tooltip-container');
});
setTimeout(function() {
tooltip.tooltip('hide').removeClass('info-tooltip').parent().removeClass('info-tooltip-container');
2014-08-27 23:04:27 +00:00
}, 30000);
2014-08-10 23:43:46 +00:00
}
2013-09-03 10:37:59 +00:00
2014-08-10 23:43:46 +00:00
var tour = new Tour({
keyboard: false,
storage: {
getItem: function() {
},
setItem: function() {
},
removeItem: function() {
}
},
onEnd: function() {
2018-01-07 16:23:22 +00:00
// storage.welcomeTour = 'done';
// infoTooltip('.drag-me', 'Drag me!', 'left');
// infoTooltip('.layout-toggler-preview', 'Toggle preview', 'right');
2014-08-10 23:43:46 +00:00
},
template: [
'<div class="popover tour">',
' <div class="arrow"></div>',
' <h3 class="popover-title"></h3>',
' <div class="popover-content"></div>',
' <nav class="popover-navigation">',
' <button class="btn btn-primary" data-role="next">Next</button>',
2018-01-07 16:23:22 +00:00
' <button class="btn btn-default" data-role="end">OK</button>',
2014-08-10 23:43:46 +00:00
' </nav>',
'</div>'
].join("")
});
tour.addSteps([
{
element: '.navbar-inner',
2018-01-07 16:23:22 +00:00
title: 'StackEdit 4 is deprecated',
2014-08-10 23:43:46 +00:00
content: [
2018-01-07 16:23:22 +00:00
'<p><b>StackEdit 5</b> is now ready for production!</p>',
'<p>If you want to migrate, <a href="#" class="action-export-docs-tour">click here</a> to export a backup of your files.</p>',
'<p>To import the backup in StackEdit 5, go to Menu > More > Import workspace backup.</p>',
'<p><a href="app" target="_blank">Click here</a> to open StackEdit 5 now!</p>',
'You can always click <b>OK</b> to continue with StackEdit 4.'
2014-08-10 23:43:46 +00:00
].join(""),
placement: 'bottom',
onShown: function() {
2018-01-07 16:23:22 +00:00
$(".action-export-docs-tour").click(function() {
utils.saveAs(JSON.stringify(storage), "StackEdit local storage.json");
});
2014-08-10 23:43:46 +00:00
}
2018-01-07 16:23:22 +00:00
},
2014-08-10 23:43:46 +00:00
]);
2018-01-07 16:23:22 +00:00
tour.start();
2014-08-10 23:43:46 +00:00
$('.action-welcome-tour').click(function() {
tour.restart();
});
};
return welcomeTour;
2013-09-03 10:37:59 +00:00
});