Solved

How to hide jquery hemiintro in returning user?

Posted on 2016-08-26
1
100 Views
Last Modified: 2016-08-29
Hi i want to hide intro in returning users only showing intro in first time user visit in website is it possible? please help me. Below and attached my code.

<script type="text/javascript">
				//<!--
				$(function () {
					var intro = $.hemiIntro({
						debug: false,
						steps: [
							{
								selector: ".Downloads",
								placement: "bottom",
								content: "Text text text text text text text text text text",
								showButtons: true,
                                scrollToElement: true,
								offsetTop: 300
								
							},
							{
								selector: ".list-lenders",
								placement: "bottom",
								content: "Text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2 text2",
								offsetTop: 300
							},
							{
								selector: ".support",
								placement: "bottom",
								content: "Text2 text2 text2 text2 text2 text2",
								offsetTop: 300
							},
							{
								selector: ".login",
								placement: "bottom",
								content: "Text2 text2 ",
								offsetTop: 300
								
							},
							{
								selector: ".index",
								placement: "top",
								content: "Text3 text3 text3 text3 text3 text3 text3",
								offsetTop: 300
							},
						],
						startFromStep: 0,
						backdrop: {
							element: $("<div>"),
							class: "hemi-intro-backdrop"
						},
						popover: {
							template: '<div class="popover hemi-intro-popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
						},
						buttons: {
							holder: {
								element: $("<div>"),
								class: "hemi-intro-buttons-holder"
							},
							next: {
								element: $("<span>Next: Steps</span>"),
								class: "btn button-md button-rounded btn-info"
							},
							finish: {
								element: $("<span>Finish</span>"),
								class: "btn button-md button-rounded btn-success"
							}
						},
						welcomeDialog: {
							show: true,
							selector: "#myModal"
						},
						scroll: {
							anmationSpeed: 0
						},
						currentStep: {
							selectedClass: "hemi-intro-selected"
						},
						init: function (plugin) {
							console.log("init:");
						},
						onLoad: function (plugin) {
							console.log("onLoad:");
						},
						onStart: function (plugin) {
							console.log("onStart:");
						},
						onBeforeChangeStep: function () {
							console.log("onBeforeChangeStep:");
						},
						onAfterChangeStep: function () {
							console.log("onAfterChangeStep:");
						},
						onShowModalDialog: function (plugin, modal) {
							console.log("onShowModalDialog:");
						},
						onHideModalDialog: function (plugin, modal) {
							console.log("onHideModalDialog:");
						},
						onComplete: function (plugin) {
							console.log("onComplete:");
						}
					});
					if (sessionStorage.getItem('fTime') === null)
				 { 
						 sessionStorage.setItem("fTime", true);
						 intro.start();
				 }   
                           }); 
				//-->
			</script>
    <!-- LOAD JS FILES -->

Open in new window

jquery.hemiIntro.js
0
Comment
Question by:Johnson Thomas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41771470
Take a look at this question https://www.experts-exchange.com/questions/28965779/Back-Button-Causing-Issues-With-Hidden-Divs.html
The question is about how to show hidden divs and then to keep them shown when back button is pressed.

The principle is the same here.

Working sample here

CSS
<style type="text/css">
.hidden-div {
  display: none;
}
body.has-state .hidden-div {
  display: block;
}
body.has-state .show-divs {
  display: none;
}
</style>

Open in new window

HTML
    <div>
      <button class="btn btn-danger" id="reset">Reset</button>
      <input type="radio" value="localstorage" id="localstorage" name="storage" checked/> Local Storage <input type="radio" value="cookie" name="storage" id="cookie"/> Cookie
	  <a href="#" class="show-divs btn btn-primary">Show</a>
    </div>
    <div class="hidden-div"> This is invisible on first read</div>
    <div class="hidden-div"> This is invisible on first read</div>

Open in new window

jQuery
<script>
$(function() {
  if (typeof Storage === 'undefined') {
  $('#localstorage').prop({checked: false, disabled: true});
  $('#cookie').prop('checked', true);
  }
  var state = getState();
  if (state) {
    $('body').addClass('has-state');
  }
  
  $('.show-divs').click(function(e) {
    e.preventDefault();
    $('body').addClass('has-state');
    var type = $('input[name="storage"]:checked').val();

    setState(type);
  });
  
  $('#reset').click(function(){
  if (typeof Storage !== 'undefined') {
    localStorage.clear();
  }
  document.cookie = "__state=; expires=0";
  location.reload();
  });
});
function getState()
{
  var state = false;
  if (typeof Storage !== 'undefined') { // Localstorage
    state = localStorage.getItem('__state');
  }
  
  if (!state) {
    state = getCookie('__state');
  }
  
  return state;
}

function setState(type)
{
  if (type == 'localstorage' && typeof Storage !== 'undefined') { // Localstorage
    localStorage.setItem('__state', '1');
  }
  else { // Cookies
    document.cookie = "__state=1";
  }
}

function getCookie(cookie) {
  var ret = false;
  var cookies = document.cookie;
  var pattern = cookie +'=(.*?);';
  var regex = new RegExp(pattern);
  var val = cookies.match(regex);
console.log(val);  
  if (val) ret = val[1];
  
    return ret;
}
</script>

Open in new window

1

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question