Skip to content

Instantly share code, notes, and snippets.

@Huskie
Huskie / social-share.js
Last active August 29, 2015 13:57
Social share
twitterShare.onclick = function(e) {
e.preventDefault();
var twitterWindow = window.open('https://twitter.com/share?url=' + document.URL, 'twitter-popup', 'height=350,width=600');
if(twitterWindow.focus) { twitterWindow.focus(); }
return false;
}
facebookShare.onclick = function(e) {
e.preventDefault();
var facebookWindow = window.open('https://www.facebook.com/sharer/sharer.php?u=' + document.URL, 'facebook-popup', 'height=350,width=600');
@Huskie
Huskie / autoprefixer-example.scss
Created March 25, 2014 13:38
Grunt Autoprefixer plugin usage syntax
/*
Autoprefixer
https://github.com/nDmitry/grunt-autoprefixer
Adds vendor prefixes automatically
https://github.com/nDmitry/grunt-autoprefixer
*/
autoprefixer: {
options: {
browsers: [
@Huskie
Huskie / bem-module-example.html
Last active August 29, 2015 14:03
BEM module example
<!-- This is the Block -->
<div class="carousel" data-widgettype="carousel">
<!-- This is an Element. Notice that Elements class names use the name of the Block followed by a double underscore, then the name of the Element -->
<ul class="carousel__list" data-js="carousel-list">
<li class="carousel__item">
<span>List item</span>
</li>
<li class="carousel__item carousel__item--is-active"> <!-- This is an Element, which also contains a Modifier, Modifiers are named the same as the Element, but with a double dash followed by a modifier description -->
<span>List item</span>
</li>
@Huskie
Huskie / sublime.txt
Created January 9, 2015 15:42
Sublime
{
"always_show_minimap_viewport": true,
"auto_close_tags": false,
"auto_complete": false,
"auto_indent": true,
"auto_match_enabled": false,
"bold_folder_labels": true,
"caret_style": "phase",
"close_windows_when_empty": true,
"color_scheme": "Packages/User/predawn (SL).tmTheme",
@Huskie
Huskie / detect-character-16-32-bit.js
Created April 17, 2015 09:16
Detect whether character is 16 or 32 bit
var is32Bit = function (c) {
return c.codePointAt(0) > 0xFFFF;
}
console.log(is32Bit('𠮷')); // true
console.log(is32Bit('a')); // false
@Huskie
Huskie / rel-external.js
Created April 26, 2012 22:40
jQuery to open links in with rel="external" in new tab/window
$('a[rel*=external]').click(function() {
window.open(this.href);
return false;
});
@Huskie
Huskie / fixed-element.js
Created July 19, 2012 08:32
Fixed element only when page scrolled
var placeholder = $('.how-to-order');
var orderSidebar = $('.how-to-order .bodyRPanelContent');
var view = $(window);
view.bind(
'scroll resize',
function () {
var placeholderTop = placeholder.offset().top;
var viewTop = view.scrollTop();
@Huskie
Huskie / cross-browser-opacity.css
Created November 15, 2012 12:56
Cross Browser Opacity
.opacity-class{
-ms-filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=50); // IE8
filter:alpha(opacity=50); // IE5-7
-moz-opacity:0.5; // Netscape
-khtml-opacity:0.5; // Safari 1.x
opacity:0.5; // Good browsers
}
@Huskie
Huskie / iframe-facebook.js
Created December 6, 2012 12:11
Correctly resize Facebook app iframe
FB.init({
appId: '383046638449372',
status: true,
cookie: true,
xfbml: true
});
FB.Canvas.setSize({ height: 600 });
setTimeout('FB.Canvas.setAutoGrow()', 500);
FB.Canvas.scrollTo(0,0);
@Huskie
Huskie / scss-clearfix-placeholder.scss
Last active December 11, 2015 00:19
SCSS Clearfix placeholder
%clearfix {
*zoom: 1;
&:before, &:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
}