mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-09 13:28:53 +08:00
Refactored and added back button for tutorial for step 18. Tutorial function now also works with one page step.
This commit is contained in:
parent
00ed91e856
commit
47c1308ba6
2 changed files with 44 additions and 81 deletions
|
@ -16,6 +16,31 @@
|
||||||
|
|
||||||
var checkedReports = [];
|
var checkedReports = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes page
|
||||||
|
*/
|
||||||
|
function init() {
|
||||||
|
// Initialize selectors
|
||||||
|
newReportModal = $('#new-report-modal');
|
||||||
|
newReportModalBody = newReportModal.find('.modal-body');
|
||||||
|
newReportCreateButton = $('#create-new-report-btn');
|
||||||
|
deleteReportsModal = $('#delete-reports-modal');
|
||||||
|
deleteReportsInput = $('#report-ids');
|
||||||
|
newReportButton = $('#new-report-btn');
|
||||||
|
editReportButton = $('#edit-report-btn');
|
||||||
|
deleteReportsButton = $('#delete-reports-btn');
|
||||||
|
checkAll = $('.check-all-reports');
|
||||||
|
allChecks = $('.check-report');
|
||||||
|
allRows = $('.report-row');
|
||||||
|
|
||||||
|
initNewReportModal();
|
||||||
|
initCheckboxesAndEditing();
|
||||||
|
updateButtons();
|
||||||
|
initEditReport();
|
||||||
|
initDeleteReports();
|
||||||
|
initTutorial();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the new report modal.
|
* Initialize the new report modal.
|
||||||
*/
|
*/
|
||||||
|
@ -138,88 +163,21 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initilize first-time tutorial if needed */
|
/**
|
||||||
|
* Initializes tutorial
|
||||||
|
*/
|
||||||
function initTutorial() {
|
function initTutorial() {
|
||||||
var currentStep = Cookies.get('current_tutorial_step');
|
var nextPage = $('#new-report-btn').attr('href');
|
||||||
if (showTutorial() && (currentStep > 17 && currentStep < 20)) {
|
var steps = [
|
||||||
var reportsClickNewReportTutorial = $("#content").attr("data-reports-click-new-report-step-text");
|
|
||||||
introJs()
|
|
||||||
.setOptions({
|
|
||||||
steps: [
|
|
||||||
{},
|
|
||||||
{
|
{
|
||||||
element: document.getElementById("new-report-btn"),
|
element: $('#new-report-btn')[0],
|
||||||
intro: reportsClickNewReportTutorial,
|
intro: $('#content').attr('data-reports-click-new-report-step-text'),
|
||||||
position: 'right',
|
position: 'right'
|
||||||
tooltipClass: "custom next-page-link"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
overlayOpacity: '0.1',
|
|
||||||
nextLabel: 'Next',
|
|
||||||
doneLabel: 'End tutorial',
|
|
||||||
skipLabel: 'End tutorial',
|
|
||||||
showBullets: false,
|
|
||||||
showStepNumbers: false,
|
|
||||||
exitOnOverlayClick: false,
|
|
||||||
exitOnEsc: false,
|
|
||||||
tooltipClass: 'custom'
|
|
||||||
})
|
|
||||||
.onafterchange(function (tarEl) {
|
|
||||||
Cookies.set('current_tutorial_step', this._currentStep + 18);
|
|
||||||
|
|
||||||
if (this._currentStep == 1) {
|
|
||||||
setTimeout(function() {
|
|
||||||
$('.next-page-link a.introjs-nextbutton')
|
|
||||||
.removeClass('introjs-disabled')
|
|
||||||
.attr('href', tarEl.href);
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.goToStep(2)
|
|
||||||
.start();
|
|
||||||
|
|
||||||
// Destroy first-time tutorial cookies when skip tutorial
|
|
||||||
// or end tutorial is clicked
|
|
||||||
$(".introjs-skipbutton").each(function (){
|
|
||||||
$(this).click(function (){
|
|
||||||
Cookies.remove('tutorial_data');
|
|
||||||
Cookies.remove('current_tutorial_step');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
];
|
||||||
|
initPageTutorialSteps(18, 18, nextPage, function() {}, function() {},
|
||||||
|
steps);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTutorial() {
|
$(document).ready(init);
|
||||||
var tutorialData;
|
|
||||||
if (Cookies.get('tutorial_data'))
|
|
||||||
tutorialData = JSON.parse(Cookies.get('tutorial_data'));
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
var tutorialProjectId = tutorialData[0].project;
|
|
||||||
var currentProjectId = $(".report-table").attr("data-project-id");
|
|
||||||
return tutorialProjectId == currentProjectId;
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
// Initialize selectors
|
|
||||||
newReportModal = $("#new-report-modal");
|
|
||||||
newReportModalBody = newReportModal.find(".modal-body");
|
|
||||||
newReportCreateButton = $("#create-new-report-btn");
|
|
||||||
deleteReportsModal = $("#delete-reports-modal");
|
|
||||||
deleteReportsInput = $("#report-ids");
|
|
||||||
newReportButton = $("#new-report-btn");
|
|
||||||
editReportButton = $("#edit-report-btn");
|
|
||||||
deleteReportsButton = $("#delete-reports-btn");
|
|
||||||
checkAll = $(".check-all-reports");
|
|
||||||
allChecks = $(".check-report");
|
|
||||||
allRows = $(".report-row");
|
|
||||||
|
|
||||||
initNewReportModal();
|
|
||||||
initCheckboxesAndEditing();
|
|
||||||
updateButtons();
|
|
||||||
initEditReport();
|
|
||||||
initDeleteReports();
|
|
||||||
initTutorial();
|
|
||||||
});
|
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -104,6 +104,11 @@ function initPageTutorialSteps(pageFirstStep, pageLastStep, nextPagePath,
|
||||||
.goToStep(stepNum - (pageFirstStep - 1))
|
.goToStep(stepNum - (pageFirstStep - 1))
|
||||||
.start();
|
.start();
|
||||||
} else {
|
} else {
|
||||||
|
if (pageFirstStep === pageLastStep) {
|
||||||
|
// Only one page step, so add another fake one, so the back and next
|
||||||
|
// buttons are added to the popup
|
||||||
|
steps.push({});
|
||||||
|
}
|
||||||
introJs()
|
introJs()
|
||||||
.setOptions({
|
.setOptions({
|
||||||
overlayOpacity: '0.2',
|
overlayOpacity: '0.2',
|
||||||
|
|
Loading…
Add table
Reference in a new issue