Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
Conflicts:
	intro.js
	introjs.css
	minified/intro.min.js
	minified/introjs.min.css
  • Loading branch information
MikeTheReader committed Sep 21, 2014
2 parents 88448fb + 3a2d855 commit 7d64fe0
Show file tree
Hide file tree
Showing 8 changed files with 351 additions and 49 deletions.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ You can obtain your local copy of Intro.js from:

**2)** Using bower ```bower install intro.js --save```

**3)** Download it from CDN ([1](http://www.jsdelivr.com/#!intro.js), [2](http://cdnjs.com/#introjs))
**3)** Using npm ```npm install intro.js --save```

**4)** Download it from CDN ([1](http://www.jsdelivr.com/#!intro.js), [2](http://cdnjs.com/#introjs))


## How to use
Expand All @@ -19,7 +21,7 @@ Intro.js can be added to your site in three simple steps:

> CDN hosted files are available at [jsDelivr](http://www.jsdelivr.com/#!intro.js) (click Show More) & [cdnjs](http://cdnjs.com/#introjs).
**2)** Add `data-intro` and `data-step` to your HTML elements.
**2)** Add `data-intro` and `data-step` to your HTML elements.

For example:

Expand All @@ -38,7 +40,7 @@ Optionally, pass one parameter to `introJs` function to limit the presentation s

**For example** `introJs(".introduction-farm").start();` runs the introduction only for elements with `class='introduction-farm'`.

<p align="center"><img src="http://usablica.github.com/intro.js/img/introjs-demo.png"></p>
<p align="center"><img src="http://usablica.github.com/intro.js/img/introjs-demo.png"></p>

## Using templates

Expand Down Expand Up @@ -242,7 +244,7 @@ introJs().oncomplete(function() {
###introJs.onexit(providedCallback)
Set callback to exit of introduction. Exit also means pressing `ESC` key and clicking on the overlay layer by the user.
Set callback to exit of introduction. Exit also means pressing `ESC` key and clicking on the overlay layer by the user.
**Available since:** v0.2.0
Expand Down Expand Up @@ -276,7 +278,7 @@ The callback function receives the element of the new step as an argument.

**Example:**
```javascript
introJs().onchange(function(targetElement) {
introJs().onchange(function(targetElement) {
alert("new step");
});
````
Expand All @@ -297,7 +299,7 @@ Given callback function will be called before starting a new step of introductio

**Example:**
```javascript
introJs().onbeforechange(function(targetElement) {
introJs().onbeforechange(function(targetElement) {
alert("before new step");
});
````
Expand All @@ -318,7 +320,7 @@ Given callback function will be called after starting a new step of introduction

**Example:**
```javascript
introJs().onafterchange(function(targetElement) {
introJs().onafterchange(function(targetElement) {
alert("after new step");
});
````
Expand Down Expand Up @@ -347,6 +349,7 @@ introJs().onafterchange(function(targetElement) {
- `showBullets`: Show introduction bullets or not, `true` or `false`
- `scrollToElement`: Auto scroll to highlighted element if it's outside of viewport, `true` or `false`
- `overlayOpacity`: Adjust the overlay opacity, `Number`
- `disableInteraction`: Disable an interaction inside element or not, `true` or `false`
See [setOption](https://github.com/usablica/intro.js/#introjssetoptionoption-value) to see an example.
Expand Down Expand Up @@ -379,11 +382,11 @@ Now you can run this command to minify all static resources:
## Instant IntroJs
Want to learn faster and easier? Here we have **Instant IntroJs**, Packt Publishing.
Want to learn faster and easier? Here we have **Instant IntroJs**, Packt Publishing.
<p align="center">
<a target='_blank' href="http://www.packtpub.com/create-useful-introductions-for-websites-and-applications-with-introjs-library/book"><img src='http://dgdsbygo8mp3h.cloudfront.net/sites/default/files/imagecache/productview_larger/2517OS_Instant%20IntroJS%20Starter.jpg' /></a>
</p>
</p>

<p align="center">
<a target='_blank' href="http://www.packtpub.com/create-useful-introductions-for-websites-and-applications-with-introjs-library/book">Buy and Download</a>
Expand Down Expand Up @@ -489,7 +492,7 @@ Want to learn faster and easier? Here we have **Instant IntroJs**, Packt Publish
- [Twitter](https://twitter.com/afshinmeh)
- [Github](https://github.com/afshinm)
- [Personal page](http://afshinm.name/)
- [Personal page](http://afshinm.name/)
[Other contributors](https://github.com/usablica/intro.js/graphs/contributors)
Expand Down
48 changes: 41 additions & 7 deletions intro.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Intro.js v0.9.0
* Intro.js v1.0.0
* https://github.com/usablica/intro.js
* MIT licensed
*
Expand All @@ -19,7 +19,7 @@
}
} (this, function (exports) {
//Default config/variables
var VERSION = '0.9.0';
var VERSION = '1.0.0';

/**
* IntroJs main class
Expand Down Expand Up @@ -59,7 +59,9 @@
/* Set the overlay opacity */
overlayOpacity: 0.8,
/* Precedence of positions, when auto is enabled */
positionPrecedence: ["bottom", "top", "right", "left"]
positionPrecedence: ["bottom", "top", "right", "left"],
/* Disable an interaction with element? */
disableInteraction: false
};
}

Expand Down Expand Up @@ -217,13 +219,13 @@
window.addEventListener('keydown', self._onKeyDown, true);
}
//for window resize
window.addEventListener("resize", self._onResize, true);
window.addEventListener('resize', self._onResize, true);
} else if (document.attachEvent) { //IE
if (this._options.keyboardNavigation) {
document.attachEvent('onkeydown', self._onKeyDown);
}
//for window resize
document.attachEvent("onresize", self._onResize);
document.attachEvent('onresize', self._onResize);
}
}
return false;
Expand Down Expand Up @@ -345,6 +347,11 @@
var referenceLayer = targetElement.querySelector('.introjs-tooltipReferenceLayer');
if (referenceLayer) {
referenceLayer.parentNode.removeChild(referenceLayer);
}
//remove disableInteractionLayer
var disableInteractionLayer = targetElement.querySelector('.introjs-disableInteraction');
if (disableInteractionLayer) {
disableInteractionLayer.parentNode.removeChild(disableInteractionLayer);
}

//remove intro floating element
Expand Down Expand Up @@ -615,6 +622,23 @@
}
}

/**
* Add disableinteraction layer and adjust the size and position of the layer
*
* @api private
* @method _disableInteraction
*/
function _disableInteraction () {
var disableInteractionLayer = document.querySelector('.introjs-disableInteraction');
if (disableInteractionLayer === null) {
disableInteractionLayer = document.createElement('div');
disableInteractionLayer.className = 'introjs-disableInteraction';
this._targetElement.appendChild(disableInteractionLayer);
}

_setHelperLayerPosition.call(this, disableInteractionLayer);
}

/**
* Show an element on the page
*
Expand Down Expand Up @@ -669,6 +693,7 @@
//remove old classes
var oldShowElement = document.querySelector('.introjs-showElement');
oldShowElement.className = oldShowElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, '');

//we should wait until the CSS3 transition is competed (it's 0.3 sec) to prevent incorrect `height` and `width` calculation
if (self._lastShowElementTimer) {
clearTimeout(self._lastShowElementTimer);
Expand Down Expand Up @@ -724,6 +749,7 @@
bulletsLayer.style.display = 'none';
}


var ulContainer = document.createElement('ul');

for (var i = 0, stepsLength = this._introItems.length; i < stepsLength; i++) {
Expand All @@ -734,7 +760,7 @@
self.goToStep(this.getAttribute('data-stepnumber'));
};

if (i === 0) anchorLink.className = "active";
if (i === (targetElement.step-1)) anchorLink.className = 'active';

anchorLink.href = 'javascript:void(0);';
anchorLink.innerHTML = "&nbsp;";
Expand Down Expand Up @@ -762,6 +788,7 @@
helperNumberLayer.innerHTML = targetElement.step;
referenceLayer.appendChild(helperNumberLayer);
}

tooltipLayer.appendChild(arrowLayer);
referenceLayer.appendChild(tooltipLayer);

Expand Down Expand Up @@ -821,6 +848,11 @@
_placeTooltip.call(self, targetElement.element, tooltipLayer, arrowLayer, helperNumberLayer);
}

//disable interaction
if (this._options.disableInteraction === true) {
_disableInteraction.call(self);
}

if (this._currentStep == 0 && this._introItems.length > 1) {
prevTooltipButton.className = 'introjs-button introjs-prevbutton introjs-disabled';
nextTooltipButton.className = 'introjs-button introjs-nextbutton';
Expand Down Expand Up @@ -856,7 +888,8 @@
//More detail: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/The_stacking_context
var zIndex = _getPropValue(parentElm, 'z-index');
var opacity = parseFloat(_getPropValue(parentElm, 'opacity'));
if (/[0-9]+/.test(zIndex) || opacity < 1) {
var transform = _getPropValue(parentElm, 'transform') || _getPropValue(parentElm, '-webkit-transform') || _getPropValue(parentElm, '-moz-transform') || _getPropValue(parentElm, '-ms-transform') || _getPropValue(parentElm, '-o-transform');
if (/[0-9]+/.test(zIndex) || opacity < 1 || transform !== 'none') {
parentElm.className += ' introjs-fixParent';
}

Expand Down Expand Up @@ -1102,6 +1135,7 @@
},
exit: function() {
_exitIntro.call(this, this._targetElement);
return this;
},
refresh: function() {
_setHelperLayerPosition.call(this, document.querySelector('.introjs-helperLayer'));
Expand Down
21 changes: 21 additions & 0 deletions introjs.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
.introjs-fixParent {
z-index: auto !important;
opacity: 1.0 !important;
position: absolute;
-webkit-transform: none !important;
-moz-transform: none !important;
-ms-transform: none !important;
-o-transform: none !important;
transform: none !important;
}

.introjs-showElement,
Expand All @@ -30,6 +36,11 @@ tr.introjs-showElement > th {
z-index: 9999999 !important;
}

.introjs-disableInteraction {
z-index: 99999999 !important;
position: absolute;
}

.introjs-relativePosition,
tr.introjs-showElement > td,
tr.introjs-showElement > th {
Expand Down Expand Up @@ -58,6 +69,16 @@ tr.introjs-showElement > th {
background-color: transparent;
}

.introjs-helperLayer *,
.introjs-helperLayer *:before,
.introjs-helperLayer *:after {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
-ms-box-sizing: content-box;
-o-box-sizing: content-box;
box-sizing: content-box;
}

.introjs-helperNumberLayer {
position: absolute;
top: -16px;
Expand Down
Loading

0 comments on commit 7d64fe0

Please sign in to comment.