Permalink
Browse files

Add step bullets option for tour

  • Loading branch information...
1 parent 27c7dcd commit b0c63c0e281bbc9aeae97c7cff2dbe4922c8cebe @afshinm afshinm committed Nov 8, 2013
Showing with 237 additions and 13 deletions.
  1. +72 −0 example/hello-world/withoutBullets.html
  2. +72 −0 example/hello-world/withoutButtons.html
  3. +62 −13 intro.js
  4. +31 −0 introjs.css
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Without Bullets</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="Intro.js - Better introductions for websites and features with a step-by-step guide for your projects.">
+ <meta name="author" content="Afshin Mehrabani (@afshinmeh) in usabli.ca group">
+
+ <!-- styles -->
+ <link href="../assets/css/bootstrap.min.css" rel="stylesheet">
+ <link href="../assets/css/demo.css" rel="stylesheet">
+
+ <!-- Add IntroJs styles -->
+ <link href="../../introjs.css" rel="stylesheet">
+
+ <link href="../assets/css/bootstrap-responsive.min.css" rel="stylesheet">
+ </head>
+
+ <body>
+
+ <div class="container-narrow">
+
+ <div class="masthead">
+ <ul class="nav nav-pills pull-right" data-step="5" data-intro="Get it, use it.">
+ <li><a href="https://github.com/usablica/intro.js/tags"><i class='icon-black icon-download-alt'></i> Download</a></li>
+ <li><a href="https://github.com/usablica/intro.js">Github</a></li>
+ <li><a href="https://twitter.com/usablica">@usablica</a></li>
+ </ul>
+ <h3 class="muted">Intro.js</h3>
+ </div>
+
+ <hr>
+
+ <div class="jumbotron">
+ <h1 data-step="1" data-intro="This is a tooltip!">Without Bullets</h1>
+ <p class="lead" data-step="4" data-intro="Another step.">This is the basic usage of IntroJs, with <code>data-step</code> and <code>data-intro</code> attributes.</p>
+ <a class="btn btn-large btn-success" href="javascript:void(0);" onclick="javascript:introJs().setOption('showBullets', false).start();">Show me how</a>
+ </div>
+
+ <hr>
+
+ <div class="row-fluid marketing">
+ <div class="span6" data-step="2" data-intro="Ok, wasn't that fun?" data-position='right'>
+ <h4>Section One</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+
+ <h4>Section Two</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+
+ <h4>Section Three</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+ </div>
+
+ <div class="span6" data-step="3" data-intro="More features, more fun." data-position='left'>
+ <h4>Section Four</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+
+ <h4>Section Five</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+
+ <h4>Section Six</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+
+ </div>
+ </div>
+
+ <hr>
+ </div>
+ <script type="text/javascript" src="../../intro.js"></script>
+ </body>
+</html>
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Without Buttons</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="Intro.js - Better introductions for websites and features with a step-by-step guide for your projects.">
+ <meta name="author" content="Afshin Mehrabani (@afshinmeh) in usabli.ca group">
+
+ <!-- styles -->
+ <link href="../assets/css/bootstrap.min.css" rel="stylesheet">
+ <link href="../assets/css/demo.css" rel="stylesheet">
+
+ <!-- Add IntroJs styles -->
+ <link href="../../introjs.css" rel="stylesheet">
+
+ <link href="../assets/css/bootstrap-responsive.min.css" rel="stylesheet">
+ </head>
+
+ <body>
+
+ <div class="container-narrow">
+
+ <div class="masthead">
+ <ul class="nav nav-pills pull-right" data-step="5" data-intro="Get it, use it.">
+ <li><a href="https://github.com/usablica/intro.js/tags"><i class='icon-black icon-download-alt'></i> Download</a></li>
+ <li><a href="https://github.com/usablica/intro.js">Github</a></li>
+ <li><a href="https://twitter.com/usablica">@usablica</a></li>
+ </ul>
+ <h3 class="muted">Intro.js</h3>
+ </div>
+
+ <hr>
+
+ <div class="jumbotron">
+ <h1 data-step="1" data-intro="This is a tooltip!">Without Buttons</h1>
+ <p class="lead" data-step="4" data-intro="Another step.">This is the basic usage of IntroJs, with <code>data-step</code> and <code>data-intro</code> attributes.</p>
+ <a class="btn btn-large btn-success" href="javascript:void(0);" onclick="javascript:introJs().setOption('showButtons', false).start();">Show me how</a>
+ </div>
+
+ <hr>
+
+ <div class="row-fluid marketing">
+ <div class="span6" data-step="2" data-intro="Ok, wasn't that fun?" data-position='right'>
+ <h4>Section One</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+
+ <h4>Section Two</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+
+ <h4>Section Three</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+ </div>
+
+ <div class="span6" data-step="3" data-intro="More features, more fun." data-position='left'>
+ <h4>Section Four</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+
+ <h4>Section Five</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+
+ <h4>Section Six</h4>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis mollis augue a neque cursus ac blandit orci faucibus. Phasellus nec metus purus.</p>
+
+ </div>
+ </div>
+
+ <hr>
+ </div>
+ <script type="text/javascript" src="../../intro.js"></script>
+ </body>
+</html>
View
@@ -49,7 +49,11 @@
/* Show step numbers in introduction? */
showStepNumbers: true,
/* Let user use keyboard to navigate the tour? */
- keyboardNavigation: true
+ keyboardNavigation: true,
+ /* Show tour control buttons? */
+ showButtons: true,
+ /* Show tour bullets? */
+ showBullets: true
};
}
@@ -222,7 +226,7 @@
++this._currentStep;
}
- if((this._introItems.length) <= this._currentStep) {
+ if ((this._introItems.length) <= this._currentStep) {
//end of the intro
//check if any callback is defined
if (typeof (this._introCompleteCallback) === 'function') {
@@ -409,7 +413,7 @@
skipTooltipButton = oldHelperLayer.querySelector('.introjs-skipbutton'),
prevTooltipButton = oldHelperLayer.querySelector('.introjs-prevbutton'),
nextTooltipButton = oldHelperLayer.querySelector('.introjs-nextbutton');
-
+
//hide the tooltip
oldtooltipContainer.style.opacity = 0;
@@ -440,14 +444,22 @@
oldtooltipLayer.innerHTML = targetElement.intro;
//set the tooltip position
_placeTooltip.call(self, targetElement.element, oldtooltipContainer, oldArrowLayer);
+
+ //change active bullet
+ oldHelperLayer.querySelector('.introjs-bullets li > a.active').className = '';
+ oldHelperLayer.querySelector('.introjs-bullets li > a[data-stepnumber="' + targetElement.step + '"]').className = 'active';
+
//show the tooltip
oldtooltipContainer.style.opacity = 1;
}, 350);
} else {
- var helperLayer = document.createElement('div'),
- arrowLayer = document.createElement('div'),
- tooltipLayer = document.createElement('div');
+ var helperLayer = document.createElement('div'),
+ arrowLayer = document.createElement('div'),
+ tooltipLayer = document.createElement('div'),
+ tooltipTextLayer = document.createElement('div'),
+ bulletsLayer = document.createElement('div'),
+ buttonsLayer = document.createElement('div');
helperLayer.className = 'introjs-helperLayer';
@@ -459,9 +471,45 @@
arrowLayer.className = 'introjs-arrow';
- tooltipLayer.innerHTML = '<div class="introjs-tooltiptext">' +
- targetElement.intro +
- '</div><div class="introjs-tooltipbuttons"></div>';
+ tooltipTextLayer.className = 'introjs-tooltiptext';
+ tooltipTextLayer.innerHTML = targetElement.intro;
+
+ bulletsLayer.className = 'introjs-bullets';
+
+ if (this._options.showBullets === false) {
+ bulletsLayer.style.display = 'none';
+ }
+
+ var ulContainer = document.createElement('ul');
+
+ for (var i = 0, stepsLength = this._introItems.length; i < stepsLength; i++) {
+ var innerLi = document.createElement('li');
+ var anchorLink = document.createElement('a');
+
+ anchorLink.onclick = function() {
+ self.goToStep(this.getAttribute('data-stepnumber'));
+ };
+
+ if (i === 0) anchorLink.className = "active";
+
+ anchorLink.href = 'javascript:void(0);';
+ anchorLink.innerHTML = "&nbsp;";
+ anchorLink.setAttribute('data-stepnumber', this._introItems[i].step);
+
+ innerLi.appendChild(anchorLink);
+ ulContainer.appendChild(innerLi);
+ }
+
+ bulletsLayer.appendChild(ulContainer);
+
+ buttonsLayer.className = 'introjs-tooltipbuttons';
+ if (this._options.showButtons === false) {
+ buttonsLayer.style.display = 'none';
+ }
+
+ tooltipLayer.className = 'introjs-tooltip';
+ tooltipLayer.appendChild(tooltipTextLayer);
+ tooltipLayer.appendChild(bulletsLayer);
//add helper layer number
if (this._options.showStepNumbers == true) {
@@ -515,15 +563,16 @@
_exitIntro.call(self, self._targetElement);
};
- var tooltipButtonsLayer = tooltipLayer.querySelector('.introjs-tooltipbuttons');
- tooltipButtonsLayer.appendChild(skipTooltipButton);
+ buttonsLayer.appendChild(skipTooltipButton);
//in order to prevent displaying next/previous button always
if (this._introItems.length > 1) {
- tooltipButtonsLayer.appendChild(prevTooltipButton);
- tooltipButtonsLayer.appendChild(nextTooltipButton);
+ buttonsLayer.appendChild(prevTooltipButton);
+ buttonsLayer.appendChild(nextTooltipButton);
}
+ tooltipLayer.appendChild(buttonsLayer);
+
//set proper position
_placeTooltip.call(self, targetElement.element, tooltipLayer, arrowLayer);
}
View
@@ -214,3 +214,34 @@
background-image: none;
text-decoration: none;
}
+
+.introjs-bullets {
+ text-align: center;
+}
+.introjs-bullets ul {
+ clear: both;
+ margin: 15px auto 0;
+ padding: 0;
+ display: inline-block;
+}
+.introjs-bullets ul li {
+ list-style: none;
+ float: left;
+ margin: 0 2px;
+}
+.introjs-bullets ul li a {
+ display: block;
+ width: 6px;
+ height: 6px;
+ background: #ccc;
+ border-radius: 10px;
+ -moz-border-radius: 10px;
+ -webkit-border-radius: 10px;
+ text-decoration: none;
+}
+.introjs-bullets ul li a:hover {
+ background: #999;
+}
+.introjs-bullets ul li a.active {
+ background: #999;
+}

0 comments on commit b0c63c0

Please sign in to comment.