Skip to content

Instantly share code, notes, and snippets.

@zerosignalproductions
Created October 10, 2012 16:09
Show Gist options
  • Save zerosignalproductions/3866607 to your computer and use it in GitHub Desktop.
Save zerosignalproductions/3866607 to your computer and use it in GitHub Desktop.
Global Code
function Set_Cookie( name, value, expires, path, domain, secure ) {
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
function Get_Cookie( check_name ) {
// first we'll split this cookie up into name/value pairs
// note: document.cookie only returns name=value, not the other components
var a_all_cookies = document.cookie.split( ';' );
var a_temp_cookie = '';
var cookie_name = '';
var cookie_value = '';
var b_cookie_found = false; // set boolean t/f default f
for ( i = 0; i < a_all_cookies.length; i++ ) {
// now we'll split apart each name=value pair
a_temp_cookie = a_all_cookies[i].split( '=' );
// and trim left/right whitespace while we're at it
cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
// if the extracted name matches passed check_name
if ( cookie_name == check_name ) {
b_cookie_found = true;
// we need to handle case where cookie has no value but exists (no = sign, that is):
if ( a_temp_cookie.length > 1 ) {
cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
}
// note that in cases where cookie is initialized but no value, null is returned
return cookie_value;
break;
}
a_temp_cookie = null;
cookie_name = '';
}
if ( !b_cookie_found ) {
return null;
}
}
/* IE7 line-height hack */
sup { *vertical-align: baseline; *position: relative; *bottom: .45em; }
/*Use inline on OFT files to prevent line-height collapse */
//TODO: Clean up and put into a class
function setupFurls() {
$('.furl-trigger').click(function() {
var $containerTrigger, $menuTrigger;
//if we're in a furl container, use the normal method
if($(this).parents('.furl-item-container').length) {
$containerTrigger = $(this);
$(this).parent().next().slideToggle('fast', function() { checkFurlState($containerTrigger) });
//check for furl-menu
$menuTrigger = $('.furl-menu ul li').eq($containerTrigger.parents('.furl-item').index()).find('.furl-trigger');
} else if($(this).parents('.furl-menu').length) {
//we're using an outside menu to control the furls
//match the index in the furl container, then get the main furl-trigger
$menuTrigger = $(this);
$menuTrigger.parents('.furl-menu').find('.furl-trigger').removeClass('furl-open');
$containerTrigger = $('.furl-item-container .furl-item').eq($(this).parent().index()).find('.furl-trigger');
$containerTrigger.parents('.furl-item-container').find('.furl-trigger').removeClass('furl-open');
//we need to close all current furls and open the one selected
$containerTrigger.parents('.furl-item-container').find('.furl-item-body').slideUp('fast');
$containerTrigger.parent().next().slideToggle('fast', function() { checkFurlState($containerTrigger) });
} else {
var $trigger = $(this);
$(this).parent().next().slideToggle('fast', function() { $trigger.toggleClass('furl-open'); });
return false;
}
if (!$containerTrigger.hasClass("furl-open")) {
$containerTrigger.addClass('furl-open');
$menuTrigger.addClass('furl-open');
} else if ($containerTrigger.hasClass('furl-open')) {
$containerTrigger.removeClass('furl-open');
$menuTrigger.removeClass('furl-open');
}
return false;
});
$('.expand-all-furls').click(function() {
expandAllFurls(this, false, $('#'+$(this).attr('rel')));
return false;
});
}
function checkFurlState(element) {
//if all furls have a .furl-open class or no containers have .furl-open
var $container = $(element).parents('.furl-item-container');
var element = '.expand-all-furls';
//If we have a container id and a matching anchor tag, set the container
if($('a[rel='+$container.attr('id')+']')) {
$container = $('#'+$container.attr('id'));
element = 'a[rel='+$container.attr('id')+']';
}
if (($container.find('.furl-trigger.furl-open').length == $container.find('.furl-trigger').length) ||
($container.find('.furl-trigger.furl-open').length == 0) && ($(element).hasClass('expanded')) ||
(($container.find('.furl-trigger.furl-open').length < $container.find('.furl-trigger').length)) && ($(element).hasClass('expanded'))) {
expandAllFurls(element, true, $container);
}
}
function expandAllFurls(element, manual, container) {
var manual = (arguments.length == 2) ? true : manual;
var $container;
if(typeof(container) != 'undefined') {
$container = container;
} else {
$container = $('body');
}
if($(element).hasClass('expanded'))
{
$(element).removeClass('expanded').fadeOut('fast', function() {
$(element).html('Show all').fadeIn('fast');
})
if(!manual) {
$container.find('.furl-item-body').slideUp('fast');
$container.find('.furl-trigger').removeClass('furl-open');
}
} else {
$(element).addClass('expanded').fadeOut('fast', function() {
$(element).html('Hide all').fadeIn('fast');
})
if(!manual) {
$container.find('.furl-item-body').slideDown('fast');
$container.find('.furl-trigger').addClass('furl-open');
}
}
}
<div class="furl-item-container cf" id="furl-container-id">
<div class="furl-item">
<h3 class="furl-item-text"><a class="furl-trigger" href="#">Furl Trigger</a></h3>
<div class="furl-item-body cf">
<!-- put your content here -->
</div><!-- .furl-item-body -->
</div><!-- .furl-item -->
</div><!-- .furl-item-container -->
.cf:before, .cf:after { content: " "; display: table; }
.cf:after { clear: both; }
.cf { *zoom: 1; }
/* Add .click-tracking to any element you want to implement doubleclick tracking on */
function setupClickTracking(src, type, globalTrackingID) {
$('.click-tracking').click(function() {
var trackingID = $(this).attr('id') ? $(this).addr('id') : globalTrackingID;
if (trackingID){$('body').append('<iframe src="http://fls.doubleclick.net/activityi;src='+src+';type='+type+';cat=' + trackingID + ';ord=1;num=' + Math.random() * 10000000000000 + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>');}
});
}
<script type="text/javascript">
var axel = Math.random() + "";
var a = axel * 10000000000000;
document.write('<iframe src="http://fls.doubleclick.net/activityi;src=2530996;type=advisor;cat=rialp089;ord=1;num=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>');
</script>
<noscript>
<iframe src="http://fls.doubleclick.net/activityi;src=2530996;type=advisor;cat=rialp089;ord=1;num=1?" width="1" height="1" frameborder="0" style="display:none"></iframe>
</noscript>
/* Share Center
-------------------------------------------------------------------------------*/
.shareCntr {
position: absolute;
top: 15px;
right: -42px;
z-index: 44444;
display: none;
padding-top: 15px;
width: 290px;
background: url(../images/share-box-arrow.png) no-repeat center top;
}
.shareHeadline {
overflow: hidden;
padding: 0 13px 0 15px;
height: 36px;
background-color: #005cb3;
color: #fff;
font-size: 13px;
line-height: 36px;
}
.shareClose {
display: block;
float: right;
margin-top: 6px;
padding-right: 20px;
width: 24px;
height: 20px;
background: url(../images/share-icons-sprite.png) no-repeat scroll 29px -354px;
color: #fff;
font-size: 10px;
line-height: 22px;
}
.shareClose:hover {
cursor: pointer
}
.shareContent {
padding: 12px 0 4px 12px;
border: 2px solid #d9d9d9;
border-top: none;
background-color: #fff;
}
.shareContent p {
margin-right: 10px;
color: #333;
font-size: 11px;
}
.shareList {
overflow: hidden;
margin: 0;
}
.shareList li {
float: left;
margin-bottom: 18px;
padding: 0;
width: 122px;
}
.shareList li.spacer {
margin-right: 30px
}
.shareList a {
display: inline-block;
padding-left: 45px;
height: 37px;
color: #333;
font-size: 15px;
line-height: 36px;
}
.facebook { background: url(../images/share-icons-sprite.png) no-repeat scroll 0 -183px }
.twitter { background: url(../images/share-icons-sprite.png) no-repeat scroll 0 -227px }
.linkedin { background: url(../images/share-icons-sprite.png) no-repeat scroll 0 -271px }
.digg { background: url(../images/share-icons-sprite.png) no-repeat scroll 0 -314px }
.endShareList {
display: block;
padding: 0 0 0 12px;
}
.endShare a {
display: inline-block;
float: left;
margin: 0 20px 4px 0;
width: 23px;
height: 21px;
}
.endShare a.facebook {
background: url(../images/share-icons-sprite.png) no-repeat scroll 0 0
}
.endShare a.twitter {
background: url(../images/share-icons-sprite.png) no-repeat scroll 0 -80px
}
.endShare a.linkedin {
background: url(../images/share-icons-sprite.png) no-repeat scroll 0 -40px
}
.endShare a.digg {
background: url(../images/share-icons-sprite.png) no-repeat scroll 0 -120px
}
.endShare a.email {
margin-right: 0;
padding: 0;
background: url(../images/share-icons-sprite.png) no-repeat scroll 0 -160px;
}
<a href="#" class="share">Share</a>
<div class="shareCntr">
<div class="shareHeadline"><span class="shareClose">Close</span>Share</div>
<div class="shareContent">
<ul class="shareList">
<li class="spacer"><a href="http://www.facebook.com/sharer.php?u=http%3A//content.schwab.com/web/retail/public/talk_to_a_pro/&amp;t=Schwab Golf" class="facebook newWindow" id="&amp;lid=global_share_facebook" name="&amp;lid=global_share_facebook">Facebook</a></li>
<li><a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A//content.schwab.com/web/retail/public/talk_to_a_pro/&amp;title=Schwab Golf&amp;summary=Watch the documentary film series, Hank's golf tips, and more&amp;source=Charles+Schwab" class="linkedin newWindow" id="&amp;lid=global_share_linkedin" name="&amp;lid=global_share_linkedin">LinkedIn</a></li>
<li class="spacer"><a href="http://twitter.com/home?status=Watch%20the%20documentary%20film%20series%2C%20Hank%27s%20golf%20tips%2C%20and%20morehttp%3A//content.schwab.com/web/retail/public/talk_to_a_pro/" class="twitter newWindow" id="&amp;lid=global_share_twitter" name="&amp;lid=global_share_twitter">Twitter</a></li>
<li><a href="http://digg.com/submit?url=http%3A//content.schwab.com/web/retail/public/talk_to_a_pro/&amp;title=Schwab Golf&amp;bodytext=Watch the documentary film series, Hank's golf tips, and more&amp;media=news&amp;topic=business_finance" class="digg newWindow" id="&amp;lid=global_share_digg" name="&amp;lid=global_share_digg">Digg</a></li>
</ul>
<p class="stdP">You can share this content with others through social networking sites. To do so you will be leaving Schwab.com and accessing a third-party site. Please note that Schwab does not endorse these sites or the products and services you might find there.</p>
</div><!-- .shareContent -->
</div><!-- .shareCntr -->
Copyright - ©
Registered - ®
Tradmark - ™
Em Dash - 一
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment