Skip to content

Commit 7d64fe0

Browse files
committed
Merge remote-tracking branch 'upstream/master'
Conflicts: intro.js introjs.css minified/intro.min.js minified/introjs.min.css
2 parents 88448fb + 3a2d855 commit 7d64fe0

File tree

8 files changed

+351
-49
lines changed

8 files changed

+351
-49
lines changed

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ You can obtain your local copy of Intro.js from:
99

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

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

1416

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

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

2426
For example:
2527

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

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

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

4345
## Using templates
4446

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

277279
**Example:**
278280
```javascript
279-
introJs().onchange(function(targetElement) {
281+
introJs().onchange(function(targetElement) {
280282
alert("new step");
281283
});
282284
````
@@ -297,7 +299,7 @@ Given callback function will be called before starting a new step of introductio
297299

298300
**Example:**
299301
```javascript
300-
introJs().onbeforechange(function(targetElement) {
302+
introJs().onbeforechange(function(targetElement) {
301303
alert("before new step");
302304
});
303305
````
@@ -318,7 +320,7 @@ Given callback function will be called after starting a new step of introduction
318320

319321
**Example:**
320322
```javascript
321-
introJs().onafterchange(function(targetElement) {
323+
introJs().onafterchange(function(targetElement) {
322324
alert("after new step");
323325
});
324326
````
@@ -347,6 +349,7 @@ introJs().onafterchange(function(targetElement) {
347349
- `showBullets`: Show introduction bullets or not, `true` or `false`
348350
- `scrollToElement`: Auto scroll to highlighted element if it's outside of viewport, `true` or `false`
349351
- `overlayOpacity`: Adjust the overlay opacity, `Number`
352+
- `disableInteraction`: Disable an interaction inside element or not, `true` or `false`
350353
351354
See [setOption](https://github.com/usablica/intro.js/#introjssetoptionoption-value) to see an example.
352355
@@ -379,11 +382,11 @@ Now you can run this command to minify all static resources:
379382
380383
## Instant IntroJs
381384
382-
Want to learn faster and easier? Here we have **Instant IntroJs**, Packt Publishing.
385+
Want to learn faster and easier? Here we have **Instant IntroJs**, Packt Publishing.
383386
384387
<p align="center">
385388
<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>
386-
</p>
389+
</p>
387390

388391
<p align="center">
389392
<a target='_blank' href="http://www.packtpub.com/create-useful-introductions-for-websites-and-applications-with-introjs-library/book">Buy and Download</a>
@@ -489,7 +492,7 @@ Want to learn faster and easier? Here we have **Instant IntroJs**, Packt Publish
489492
490493
- [Twitter](https://twitter.com/afshinmeh)
491494
- [Github](https://github.com/afshinm)
492-
- [Personal page](http://afshinm.name/)
495+
- [Personal page](http://afshinm.name/)
493496
494497
[Other contributors](https://github.com/usablica/intro.js/graphs/contributors)
495498

intro.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Intro.js v0.9.0
2+
* Intro.js v1.0.0
33
* https://github.com/usablica/intro.js
44
* MIT licensed
55
*
@@ -19,7 +19,7 @@
1919
}
2020
} (this, function (exports) {
2121
//Default config/variables
22-
var VERSION = '0.9.0';
22+
var VERSION = '1.0.0';
2323

2424
/**
2525
* IntroJs main class
@@ -59,7 +59,9 @@
5959
/* Set the overlay opacity */
6060
overlayOpacity: 0.8,
6161
/* Precedence of positions, when auto is enabled */
62-
positionPrecedence: ["bottom", "top", "right", "left"]
62+
positionPrecedence: ["bottom", "top", "right", "left"],
63+
/* Disable an interaction with element? */
64+
disableInteraction: false
6365
};
6466
}
6567

@@ -217,13 +219,13 @@
217219
window.addEventListener('keydown', self._onKeyDown, true);
218220
}
219221
//for window resize
220-
window.addEventListener("resize", self._onResize, true);
222+
window.addEventListener('resize', self._onResize, true);
221223
} else if (document.attachEvent) { //IE
222224
if (this._options.keyboardNavigation) {
223225
document.attachEvent('onkeydown', self._onKeyDown);
224226
}
225227
//for window resize
226-
document.attachEvent("onresize", self._onResize);
228+
document.attachEvent('onresize', self._onResize);
227229
}
228230
}
229231
return false;
@@ -345,6 +347,11 @@
345347
var referenceLayer = targetElement.querySelector('.introjs-tooltipReferenceLayer');
346348
if (referenceLayer) {
347349
referenceLayer.parentNode.removeChild(referenceLayer);
350+
}
351+
//remove disableInteractionLayer
352+
var disableInteractionLayer = targetElement.querySelector('.introjs-disableInteraction');
353+
if (disableInteractionLayer) {
354+
disableInteractionLayer.parentNode.removeChild(disableInteractionLayer);
348355
}
349356

350357
//remove intro floating element
@@ -615,6 +622,23 @@
615622
}
616623
}
617624

625+
/**
626+
* Add disableinteraction layer and adjust the size and position of the layer
627+
*
628+
* @api private
629+
* @method _disableInteraction
630+
*/
631+
function _disableInteraction () {
632+
var disableInteractionLayer = document.querySelector('.introjs-disableInteraction');
633+
if (disableInteractionLayer === null) {
634+
disableInteractionLayer = document.createElement('div');
635+
disableInteractionLayer.className = 'introjs-disableInteraction';
636+
this._targetElement.appendChild(disableInteractionLayer);
637+
}
638+
639+
_setHelperLayerPosition.call(this, disableInteractionLayer);
640+
}
641+
618642
/**
619643
* Show an element on the page
620644
*
@@ -669,6 +693,7 @@
669693
//remove old classes
670694
var oldShowElement = document.querySelector('.introjs-showElement');
671695
oldShowElement.className = oldShowElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, '');
696+
672697
//we should wait until the CSS3 transition is competed (it's 0.3 sec) to prevent incorrect `height` and `width` calculation
673698
if (self._lastShowElementTimer) {
674699
clearTimeout(self._lastShowElementTimer);
@@ -724,6 +749,7 @@
724749
bulletsLayer.style.display = 'none';
725750
}
726751

752+
727753
var ulContainer = document.createElement('ul');
728754

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

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

739765
anchorLink.href = 'javascript:void(0);';
740766
anchorLink.innerHTML = "&nbsp;";
@@ -762,6 +788,7 @@
762788
helperNumberLayer.innerHTML = targetElement.step;
763789
referenceLayer.appendChild(helperNumberLayer);
764790
}
791+
765792
tooltipLayer.appendChild(arrowLayer);
766793
referenceLayer.appendChild(tooltipLayer);
767794

@@ -821,6 +848,11 @@
821848
_placeTooltip.call(self, targetElement.element, tooltipLayer, arrowLayer, helperNumberLayer);
822849
}
823850

851+
//disable interaction
852+
if (this._options.disableInteraction === true) {
853+
_disableInteraction.call(self);
854+
}
855+
824856
if (this._currentStep == 0 && this._introItems.length > 1) {
825857
prevTooltipButton.className = 'introjs-button introjs-prevbutton introjs-disabled';
826858
nextTooltipButton.className = 'introjs-button introjs-nextbutton';
@@ -856,7 +888,8 @@
856888
//More detail: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/The_stacking_context
857889
var zIndex = _getPropValue(parentElm, 'z-index');
858890
var opacity = parseFloat(_getPropValue(parentElm, 'opacity'));
859-
if (/[0-9]+/.test(zIndex) || opacity < 1) {
891+
var transform = _getPropValue(parentElm, 'transform') || _getPropValue(parentElm, '-webkit-transform') || _getPropValue(parentElm, '-moz-transform') || _getPropValue(parentElm, '-ms-transform') || _getPropValue(parentElm, '-o-transform');
892+
if (/[0-9]+/.test(zIndex) || opacity < 1 || transform !== 'none') {
860893
parentElm.className += ' introjs-fixParent';
861894
}
862895

@@ -1102,6 +1135,7 @@
11021135
},
11031136
exit: function() {
11041137
_exitIntro.call(this, this._targetElement);
1138+
return this;
11051139
},
11061140
refresh: function() {
11071141
_setHelperLayerPosition.call(this, document.querySelector('.introjs-helperLayer'));

introjs.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
.introjs-fixParent {
2323
z-index: auto !important;
2424
opacity: 1.0 !important;
25+
position: absolute;
26+
-webkit-transform: none !important;
27+
-moz-transform: none !important;
28+
-ms-transform: none !important;
29+
-o-transform: none !important;
30+
transform: none !important;
2531
}
2632

2733
.introjs-showElement,
@@ -30,6 +36,11 @@ tr.introjs-showElement > th {
3036
z-index: 9999999 !important;
3137
}
3238

39+
.introjs-disableInteraction {
40+
z-index: 99999999 !important;
41+
position: absolute;
42+
}
43+
3344
.introjs-relativePosition,
3445
tr.introjs-showElement > td,
3546
tr.introjs-showElement > th {
@@ -58,6 +69,16 @@ tr.introjs-showElement > th {
5869
background-color: transparent;
5970
}
6071

72+
.introjs-helperLayer *,
73+
.introjs-helperLayer *:before,
74+
.introjs-helperLayer *:after {
75+
-webkit-box-sizing: content-box;
76+
-moz-box-sizing: content-box;
77+
-ms-box-sizing: content-box;
78+
-o-box-sizing: content-box;
79+
box-sizing: content-box;
80+
}
81+
6182
.introjs-helperNumberLayer {
6283
position: absolute;
6384
top: -16px;

0 commit comments

Comments
 (0)