Skip to content

Instantly share code, notes, and snippets.

@brobertsaz
Created April 25, 2013 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brobertsaz/5456631 to your computer and use it in GitHub Desktop.
Save brobertsaz/5456631 to your computer and use it in GitHub Desktop.
JS Welcome Dialog
:javascript
$(document).ready(function()
{
checkForWelcome();
}
);
function checkForWelcome() {
var userWelcome = "#{@current_user.hide_welcome}";
if (userWelcome == "false") {
checkForSessionCookie();
}else{
$('.welcome').hide();
}
}
function checkForSessionCookie() {
if ($.cookie('session') != 'true') {
launchWelcome();
}
}
function launchWelcome() {
$('.welcome').dialog({
minHeight: 350,
width: 500,
modal: true,
title: "Welcome!",
buttons: [ { text: "Close", click: function() {
$( this ).dialog( "close" );
$.cookie('session', 'true', { path: "/", expires: 1});
} } ]
});
}
$('.hide-welcome').change(function(){
$.ajax({
url: "/users/#{@current_user.id}/update_welcome",
type: 'GET',
data: {
update_welcome: this.checked
},
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment