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" %> -
+
<% if can_edit_canvas(@experiment) %> <%=link_to t('experiments.canvas.canvas_edit'), canvas_edit_experiment_url(@experiment), @@ -10,7 +10,13 @@ type: "button", id: "edit-canvas-button", class: "ajax btn btn-default", - "data-action" => "edit" %> + data: { + action: 'edit', + intro: t('tutorial.canvas_click_edit_workflow_html'), + step: '5', + position: 'left' + } + %> <% end %> <% if can_create_experiment(@project) && @experiment.active? %> <%= link_to t('experiments.new.create'), diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 7a42ba1b0..cf0129a2c 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -57,7 +57,9 @@ data-intro="<%=t 'tutorial.tutorial_welcome_title_html' %>" data-position='bottom' data-project-options-step-text="<%=t 'tutorial.project_options_html' %>" - data-archive-project-step-text="<%=t 'tutorial.archive_project_html' %>"> + data-archive-project-step-text="<%=t 'tutorial.archive_project_html' %>" + data-goodbye-tutorial="<%=t 'tutorial.goodbye_message' %>" + >
diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index b9f24ab66..2e8358677 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -3,16 +3,23 @@ <%= render partial: "shared/secondary_navigation" %>
-
+
<% if can_create_experiment(@project) %>
-
+
<%= link_to t('experiments.new.create'), new_project_experiment_url(@project), remote: true, type: "button", id: 'new-experiment', - class: "btn btn-primary center-btn" %> + class: "btn btn-primary center-btn", + data: { + intro: t('tutorial.create_experiment_html'), + step: '4', + position: 'left' + } %>
<% end %> diff --git a/app/views/projects/show/_experiment.html.erb b/app/views/projects/show/_experiment.html.erb index 14bbcffab..8a147ab88 100644 --- a/app/views/projects/show/_experiment.html.erb +++ b/app/views/projects/show/_experiment.html.erb @@ -1,6 +1,12 @@
+ data-id="<%= experiment.id %>" + data-intro="<%= t('tutorial.edit_experiment_html') %>" + data-step="5" + data-position="right" + data-canvas-link="<%= canvas_experiment_url(experiment) %>" + data-disableInteraction="false" + >
<% if can_view_experiment_actions experiment %>