diff --git a/app/assets/javascripts/projects/index.js b/app/assets/javascripts/projects/index.js index 746b790aa..304b8d9e4 100644 --- a/app/assets/javascripts/projects/index.js +++ b/app/assets/javascripts/projects/index.js @@ -414,7 +414,9 @@ $introjs .setOptions({ overlayOpacity: '0.2', + hidePrev: true, nextLabel: 'Next', + prevLabel: 'Back', doneLabel: 'End tutorial', skipLabel: 'End tutorial', showBullets: false, @@ -461,6 +463,7 @@ } else if (goToStep > 18) { var archiveProjectTutorial = $("#projects-toolbar").attr("data-archive-project-step-text"); + var goodbye_message = $("#projects-toolbar").attr("data-goodbye-tutorial"); Cookies.set('current_tutorial_step', '20'); var position = "right"; if (demoProject.offset().left > window.innerWidth / 2 || window.innerWidth < demoProject.width() + 100) { @@ -477,15 +480,20 @@ element: document.getElementById(demoProjectId), intro: archiveProjectTutorial, position: position + },{ + element: document.getElementById("projects-toolbar"), + intro: goodbye_message }], overlayOpacity: '0.2', doneLabel: 'Start using sciNote', + nextLabel: 'Next', + skipLabel: 'End tutorial', showBullets: false, showStepNumbers: false, disableInteraction: true, exitOnOverlayClick: false, exitOnEsc: false, - tooltipClass: 'custom disabled-next' + tooltipClass: 'custom next-page-link' }) .oncomplete(function () { Cookies.remove('tutorial_data'); diff --git a/app/assets/javascripts/projects/show.js b/app/assets/javascripts/projects/show.js index ef963b50f..a5da9def9 100644 --- a/app/assets/javascripts/projects/show.js +++ b/app/assets/javascripts/projects/show.js @@ -63,3 +63,77 @@ // init init(); })(); + + +/* Initialize the first-time demo tutorial if needed. */ +(function(){ + function initializeTutorial() { + if (showTutorial()) { + introJs() + .setOptions({ + overlayOpacity: '0.2', + hidePrev: true, + nextLabel: 'Next', + doneLabel: 'End tutorial', + skipLabel: 'End tutorial', + showBullets: false, + showStepNumbers: false, + exitOnOverlayClick: false, + exitOnEsc: false, + tooltipClass: 'custom next-page-link', + disableInteraction: true + }) + .onafterchange(function (tarEl) { + Cookies.set('current_tutorial_step', this._currentStep + 2); + + if (this._currentStep == 1) { + setTimeout(function() { + $('.next-page-link a.introjs-nextbutton') + .removeClass('introjs-disabled') + .attr('href', $('[data-canvas-link]').data('canvasLink')); + $('.introjs-disableInteraction').remove(); + }, 500); + } else { + + } + }) + .start(); + + window.onresize = function() { + if (Cookies.get('current_tutorial_step') == 4 ) { + $(".introjs-tooltip").css("right", ($(".new-element.initial").width() + 60) + "px"); + } + }; + + // 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'); + }); + }); + } + } + + function showTutorial() { + var tutorialData; + + if (Cookies.get('tutorial_data')) + tutorialData = JSON.parse(Cookies.get('tutorial_data')); + else + return false; + var currentStep = Cookies.get('current_tutorial_step'); + if (currentStep < 3 || currentStep > 5) + return false; + var tutorialProjectId = tutorialData[0].project; + var currentProjectId = $("#data-holder").attr("data-project-id"); + + return tutorialProjectId == currentProjectId; + } + + $(document).ready(function(){ + initializeTutorial(); + }); + +})(); diff --git a/app/assets/javascripts/samples/samples.js b/app/assets/javascripts/samples/samples.js index 9c6b82a37..973cd15b7 100644 --- a/app/assets/javascripts/samples/samples.js +++ b/app/assets/javascripts/samples/samples.js @@ -171,7 +171,7 @@ function initTutorial() { .setOptions({ steps: [ { - element: document.getElementById("samples-toolbar"), + element: document.getElementById("importSamplesButton"), intro: samplesTutorial }, { diff --git a/app/assets/stylesheets/themes/scinote.scss b/app/assets/stylesheets/themes/scinote.scss index 138eeaeb1..9588a5ec4 100644 --- a/app/assets/stylesheets/themes/scinote.scss +++ b/app/assets/stylesheets/themes/scinote.scss @@ -1168,4 +1168,4 @@ html.turbolinks-progress-bar::before { height: 20px; display: inline-block; margin-right: 5px; -} \ No newline at end of file +} diff --git a/app/utilities/first_time_data_generator.rb b/app/utilities/first_time_data_generator.rb index 565189e23..2150ca79f 100644 --- a/app/utilities/first_time_data_generator.rb +++ b/app/utilities/first_time_data_generator.rb @@ -813,6 +813,9 @@ module FirstTimeDataGenerator ) ) + # create thumbnail + experiment.generate_workflow_img + # Lastly, create cookie with according ids # so tutorial steps can be properly positioned JSON.generate([ diff --git a/app/views/experiments/canvas.html.erb b/app/views/experiments/canvas.html.erb index fe217fe8a..5d8b1ce58 100644 --- a/app/views/experiments/canvas.html.erb +++ b/app/views/experiments/canvas.html.erb @@ -2,7 +2,7 @@ <%= render partial: "shared/sidebar" %> <%= render partial: "shared/secondary_navigation" %> -