| Index: chrome/browser/resources/md_user_manager/user_manager_tutorial.js
|
| diff --git a/chrome/browser/resources/md_user_manager/user_manager_tutorial.js b/chrome/browser/resources/md_user_manager/user_manager_tutorial.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..13d7bf72d22e0ef4d192eeb01b41be2d13646429
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/md_user_manager/user_manager_tutorial.js
|
| @@ -0,0 +1,106 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +/**
|
| + * @fileoverview 'user-manager-tutorial' is the element that controls the
|
| + * tutorial steps for the user manager page.
|
| + *
|
| + * @element user-manager-tutorial
|
| + */
|
| +Polymer({
|
| + is: 'user-manager-tutorial',
|
| +
|
| + properties: {
|
| + /**
|
| + * True if the tutorial is currently hidden.
|
| + * @private {boolean}
|
| + */
|
| + hidden_: {
|
| + type: Boolean,
|
| + value: true
|
| + },
|
| +
|
| + /**
|
| + * Current tutorial step, index in the steps array.
|
| + * @type {number}
|
| + */
|
| + currentStep_: {
|
| + type: Number,
|
| + value: 0
|
| + }
|
| + },
|
| +
|
| + /** @override */
|
| + created: function() {
|
| + this.steps_ = ['yourChrome', 'friends', 'guests', 'complete', 'notYou'];
|
| + },
|
| +
|
| + /**
|
| + * Determines whether a given step is displaying.
|
| + * @param {string} currentStep Index of the current step
|
| + * @param {string} step Name of the given step
|
| + * @return {boolean}
|
| + * @private
|
| + */
|
| + isStepHidden_: function(currentStep, step) {
|
| + return this.steps_[currentStep] != step;
|
| + },
|
| +
|
| + /**
|
| + * Navigates to the next step.
|
| + * @private
|
| + */
|
| + onNextTap_: function() {
|
| + var nextStep = this.currentStep_ + 1;
|
| +
|
| + // The last tutorial step is an information bubble that ends the tutorial.
|
| + if (nextStep >= this.steps_.length)
|
| + this.onDissmissTap_();
|
| + else
|
| + this.currentStep_ = nextStep;
|
| + },
|
| +
|
| + /**
|
| + * Handler for the link in the last step. Takes user to the create-profile
|
| + * page in order to add a new profile.
|
| + * @param {!Event} event
|
| + * @private
|
| + */
|
| + onAddUserTap_: function(event) {
|
| + this.onDissmissTap_();
|
| + // Event is caught by user-manager-pages.
|
| + this.fire('change-page', {page: 'create-user-page'});
|
| + },
|
| +
|
| + /**
|
| + * Starts the tutorial.
|
| + */
|
| + startTutorial: function() {
|
| + this.currentStep_ = 0;
|
| + this.hidden_ = false;
|
| +
|
| + // If there's only one pod, show the steps to the side of the pod.
|
| + // Otherwise, center the steps and disable interacting with the pods
|
| + // while the tutorial is showing.
|
| + var podRow = /** @type {{focusPod: !function(), pods: !Array}} */
|
| + ($('pod-row'));
|
| +
|
| + if (podRow.pods.length == 1) {
|
| + this.$.yourChrome.classList.add('single-pod');
|
| + this.$.complete.classList.add('single-pod');
|
| + }
|
| +
|
| + podRow.focusPod(); // No focused pods.
|
| + $('inner-container').classList.add('disabled');
|
| + },
|
| +
|
| + /**
|
| + * Ends the tutorial.
|
| + * @private
|
| + */
|
| + onDissmissTap_: function() {
|
| + $('inner-container').classList.remove('disabled');
|
| + this.hidden_ = true;
|
| + }
|
| +});
|
|
|