Skip to content

Commit

Permalink
feat(onboarding): Added onboarding feature. Closes #299.
Browse files Browse the repository at this point in the history
Added introjs and angular-introjs dependencies.
Created component for info button that invokes introjs onboarding tour.
Created inital tour for bristlebird citizen science project.
  • Loading branch information
peichins committed Mar 2, 2017
1 parent 140d7ae commit edaf3a7
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 53 deletions.
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
"filesize": "^3.2.1",
"angular-ui-ace": "bower",
"angular-messages": "^1.5.0",
"c3": "git://github.com/masayuki0812/c3.git#98769492d07b6103bfc30a0254ccb1e1ec1cca50"
"c3": "git://github.com/masayuki0812/c3.git#98769492d07b6103bfc30a0254ccb1e1ec1cca50",
"angular-intro.js": "~3.0.1"
},
"dependencies": {},
"private": true,
"resolutions": {
"angular": "1.5.x",
"get-size": "~2.0.2",
"font-awesome": "^4.5.0"
}
}
9 changes: 7 additions & 2 deletions buildConfig/build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ module.exports = {
"vendor/ace-builds/src-min-noconflict/mode-yaml.js",
"vendor/ace-builds/src-min-noconflict/mode-xml.js",
"vendor/ace-builds/src-min-noconflict/theme-xcode.js",
"vendor/angular-ui-ace/ui-ace.js"
"vendor/angular-ui-ace/ui-ace.js",

"vendor/intro.js/intro.js",
"vendor/angular-intro.js/src/angular-intro.js"
],
css: [
// NOTE: bootstrap css imported in application.tpl.scss
Expand All @@ -167,7 +170,9 @@ module.exports = {

"vendor/angular-loading-bar/build/loading-bar.css",

"vendor/c3/c3.css"
"vendor/c3/c3.css",

"vendor/intro.js/introjs.css"
],
assets: [
// jquery-ui is stoopid, special case
Expand Down
1 change: 1 addition & 0 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ angular.module("baw",
"angular-growl",
"LocalStorageModule",
"angular-loading-bar",
"angular-intro",
"bawApp.vendorServices", /* Loads all vendor libraries that are automatically wrapped in a module */


Expand Down
32 changes: 30 additions & 2 deletions src/app/citizenScience/bristlebird/bristlebird.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ class BristlebirdController {
// to be populated after getting samples from dataset
$scope.media = null;


$scope.onboardingSteps = [
{
element: document.querySelector(".citizen-science .spectrogram-wrapper"),
intro: "This shows a picture of the audio as a spectrogram."
},
{
element: document.querySelector("dataset-progress"),
intro: "This shows how many clips you have listened do, and lets you navigate between clips"
},
{
element: document.querySelector(".autoplay"),
intro: "Switch this on to automatically progress to the next clip and play it."
}
];

/**
* Labels that the user can select.
* applies one or more tags which are not shown to the user.
Expand Down Expand Up @@ -105,7 +121,18 @@ class BristlebirdController {
}
});


/**
* Get settings from sheet
*/
$http.get(CitizenScienceCommon.apiUrl(
"settings",
$scope.csProject
)).then(function (response) {
$scope.settings = response.data;
if ($scope.settings.hasOwnProperty("sampleDuration")) {
self.sampleDuration = $scope.settings.sampleDuration;
}
});

/**
* Sets the current sample to sampleNum
Expand Down Expand Up @@ -161,7 +188,8 @@ angular
"bawApp.components.progress",
"bawApp.citizenScience.common",
"bawApp.components.citizenScienceLabels",
"bawApp.components.citizenScienceExamples"
"bawApp.components.citizenScienceExamples",
"bawApp.components.onboarding"
])
.controller(
"BristlebirdController",
Expand Down
108 changes: 61 additions & 47 deletions src/app/citizenScience/bristlebird/listen.tpl.html
Original file line number Diff line number Diff line change
@@ -1,61 +1,75 @@
<cs-backgrounds backgrounds="['1.jpg','2.jpg','3.jpg','4.jpg',]" change-on="currentSampleNum"></cs-backgrounds>

<div class="citizen-science bristlebird">

<h2>Eastern Bristlebird Search</h2>
<cs-backgrounds backgrounds="['1.jpg','2.jpg','3.jpg','4.jpg',]" change-on="currentSampleNum"></cs-backgrounds>

<div class="cs-main-container">
<div class="main wrapper clearfix">
<div class="citizen-science bristlebird">

<div class="citsci-debug">
<p>Currently viewing: Sample {{ currentSample }}</p>
<p>Audio id: {{ samples[currentSample].recordingId }}</p>
<p>Start Offset: {{ samples[currentSample].startOffset }}</p>
</div>
<h2>Eastern Bristlebird Search <onboarding steps="onboardingSteps"></onboarding></h2>

<div class="audio-outer">
<div class="audio-inner">
<div class="spectrogram-wrapper">
<img id="spectrogram" class="spectrogram" ng-src="{{media.available.image.png.url}}">
<div position-line media="media" audio-data="model.audioElement" image-id="'spectrogram'"></div>
</div>
<audio id="citsci-sample" ng-audio="model.audioElement" controls>
<source ng-repeat="key in media.available.audioOrder"
ng-src="{{media.available.audio[key].url}}" src=""
type="{{media.available.audio[key].mimeType}}">
Your browser does not support the audio element.
</audio>
<div class="cs-main-container">

<div class="main wrapper clearfix">

<div class="citsci-debug">
<p>Currently viewing: Sample {{ currentSample }}</p>
<p>Audio id: {{ samples[currentSample].recordingId }}</p>
<p>Start Offset: {{ samples[currentSample].startOffset }}</p>
</div>
</div>

<nav class="cs-progress">

<dataset-progress items="samples" selected="currentSampleNum"></dataset-progress>

<div class="autoplay progressCell">
<toggle-switch model="model.audioElement.autoPlay" disabled="disabled" mode="push-toggle"
title="Enable/disable autoplay">
<toggle-switch-state switch-state="on">
<span class="glyphicon glyphicon-play-circle"></span>
</toggle-switch-state>
<toggle-switch-state switch-state="off">
<span class="glyphicon glyphicon-play-circle"></span>
</toggle-switch-state>
</toggle-switch>

<div class="audio-outer">
<div class="audio-inner">
<div class="spectrogram-wrapper">
<img id="spectrogram" class="spectrogram" ng-src="{{media.available.image.png.url}}">
<div position-line media="media" audio-data="model.audioElement" image-id="'spectrogram'"></div>
</div>
<audio id="citsci-sample" ng-audio="model.audioElement" controls>
<source ng-repeat="key in media.available.audioOrder"
ng-src="{{media.available.audio[key].url}}" src=""
type="{{media.available.audio[key].mimeType}}">
Your browser does not support the audio element.
</audio>
</div>
</div>

</nav>
<div class="row">

<div class="col-md-6">

<nav class="cs-progress">

<dataset-progress items="samples" selected="currentSampleNum"></dataset-progress>

<citizen-science-labels labels="labels"
samples="samples"
current-sample-num="currentSampleNum"
cs-project="csProject"></citizen-science-labels>
<div class="autoplay progressCell">
<toggle-switch model="model.audioElement.autoPlay" disabled="disabled" mode="push-toggle"
title="Enable/disable autoplay">
<toggle-switch-state switch-state="on">
<span class="glyphicon glyphicon-play-circle"></span>
</toggle-switch-state>
<toggle-switch-state switch-state="off">
<span class="glyphicon glyphicon-play-circle"></span>
</toggle-switch-state>
</toggle-switch>
</div>

<citizen-science-examples labels="labels"></citizen-science-examples>
</nav>

<citizen-science-labels labels="labels"
samples="samples"
current-sample-num="currentSampleNum"
cs-project="csProject"></citizen-science-labels>


</div> <!-- #main -->
</div> <!-- #main-container -->
</div>
<div class="col-md-6">

<citizen-science-examples labels="labels"></citizen-science-examples>

</div>


</div>

</div> <!-- #main -->
</div> <!-- #main-container -->

</div>
</div>
24 changes: 24 additions & 0 deletions src/app/onboarding/_onboarding.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.info-launch {
cursor: pointer;
opacity: 0.8;

&:before {
/* questionmark: f059
information: f05a */
content: "\f05a";
font-family: FontAwesome;

}

&:hover {
opacity: 1;
}

}

h1, h2, h3 {
.info-launch {
float: right;
}
}

6 changes: 6 additions & 0 deletions src/app/onboarding/infoButton.tpl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<span class="info-launch"
title="Launch the tour"
ng-click="launchTour()"
ng-intro-options="introOptions"
ng-intro-method="launchTour"
></span>
69 changes: 69 additions & 0 deletions src/app/onboarding/onboarding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Wrapper for the angular-introjs directive with info-button and consistent styling
*/

angular.module("bawApp.components.onboarding", ["bawApp.citizenScience.common"])
.component("onboarding", {
templateUrl: "onboarding/infoButton.tpl.html",
bindings: {
steps: "=steps",
options: "=options"
},
controller: [
"$scope",
function ($scope) {

//var self = this;

$scope.CompletedEvent = function (scope) {
console.log("Completed Event called");
};

$scope.ExitEvent = function (scope) {
console.log("Exit Event called");
};

$scope.ChangeEvent = function (targetElement, scope) {
console.log("Change Event called");
console.log(targetElement); //The target element
console.log(this); //The IntroJS object
};

$scope.BeforeChangeEvent = function (targetElement, scope) {
console.log("Before Change Event called");
console.log(targetElement);
};

$scope.AfterChangeEvent = function (targetElement, scope) {
console.log("After Change Event called");
console.log(targetElement);
};

this.introOptionsDefaults = {
steps: [],
showStepNumbers: false,
exitOnOverlayClick: true,
exitOnEsc: true,
nextLabel: "<strong>NEXT!</strong>",
prevLabel: "<span style='color:green'>Previous</span>",
skipLabel: "Exit",
doneLabel: "Thanks"
};


$scope.introOptions = Object.assign({}, this.introOptionsDefaults, this.options);

if (Array.isArray(this.steps)) {

this.steps = this.steps.map(function (step) {
if (typeof step.element === "string") {
step.element = document.querySelector(step.element);
}
return step;
});

$scope.introOptions.steps = this.steps;
}

}]
});

0 comments on commit edaf3a7

Please sign in to comment.