2.0.1 • Published 12 months ago

@ndnci/mentorjs v2.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
12 months ago

MentorJS

JavaScript user guiding and tutorial library

Demo

https://ndnci.github.io/mentorjs/

Dependencies

No dependencies

Installation

Download from npm.io

Extract js and css

...
	<link rel="stylesheet" href="build/index.css">
</head>
...
	<script src="build/index.js"></script>
</body>

Usage

Basic
<script>
// don't forget to load MentorJS after all loaded contents
window.addEventListener('load', function () {

new MentorJS().steps([
                {
                    title: "Hello World !",
                    message: "Your message",
                }]);
});
</script>
With target
<div id="test">Your Text</div>
new MentorJS().steps([
                {
		target: "#test",
		title: "Hello World !",
		message: "Your message",
                }]);
With multiple steps
new MentorJS().steps([
                {
		title: "Hello World !",
		message: "Your message",
                },
		{	
		title: "Second test !",
		message: "Second message",
                }]);
With specific parameters for each step
new MentorJS().steps([
                {
		theme: "dark",
		closeButton: "true",
		title: "Hello World !",
	    	message: "Your message",
                },
		{
		theme: "light",
	   	message: "Without title !",
                }]);
With general parameters
new MentorJS({
		theme: "dark",
		})
		.steps([
                {
		title: "Hello World !",
	    	message: "Your message",
                },
		{
		/* it will overwrite constructor value for this step */
		theme: "light",
		message: "Without title !",
                }]);

Settings

NameParametersDefaultDescription
autoRuntrue, falsetrueBy default script run automatically
stepFromstep index0Any existing step

Options

NameParametersDefaultDescription
themedark, lightlight
animationzoom, pulse, bounce, toLeft, toRight, toTop, toBottomnull
backgroundAreaany selectordocument.querySelector("body")
backgroundEffectClassany classnamementor-blur
targetNoEffectClassany classnamementor-noblur
targetToggleClassany classnamementor-toggle
modalDivClassany classnamementor-modal
modalDivHeaderClassany classnamementor-modal-header
modalDivHeaderCloseClassany classnameclose
modalDivBodyClassany classnamementor-modal-body
modalDivFooterClassany classnamementor-modal-footer
previousButtonClassany classnamementor-btn mentor-modal-previous
nextButtonClassany classnamementor-btn mentor-modal-next
endButtonClassany classnamementor-btn mentor-modal-end
autoScrolltrue, falsetrue
scrollMethodscrollIntoView, scrollToscrollTo
scrollOntarget, modalmodal
scrollBehaviorauto, smoothsmooth
scrollBlockstart, center, end, nearestcenter
scrollInlinestart, center, end, nearestcenter
openButtonIdany unique idnullMust be unique for each step
closeButtonIdany idmodalCloseClose current step
previousButtonTexttext« BackAllow HTML
nextButtonTexttextNext »Allow HTML
endButtonTexttextThanks
ordernumbernullOrder of step
titletextnullAllow HTML
messagetextnullAllow HTML
targetany selectornullExample "#test", or ".test"
closeButtontrue, falsefalseClose button on header
showHeadertrue, falsetrue
showFootertrue, falsetrue
showArrowtrue, falsetrue
outsideClicktrue, falsefalseDetect outside click for close modal
targetAutoShowtrue, falsefalseIf target is hidden by default, you can set it to true
marginnumber10Space between modal and target, only number, max 10 recommended
horizontalleft, center, right, autoauto
verticaltop, center, bottom, autoauto
responsivetrue, falsetrue
waittime ( ms )0Wait time ( for actual modal ) when user click to next or previous button default is 0 for modal speed
eventsjavascript eventsclickYou can define events with space " " for listener function, for example : "click touchstart"
mobileSupporttrue, falsetrue

Functions

NameDescription
run()Run script if autoRun is disabled
goToStep($index)Go to ($index) specific step
backStep()Go to previous step
nextStep()Go to next step

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT