Skip to content

Instantly share code, notes, and snippets.

View mcbrwr's full-sized avatar

Matthijs Brouwer mcbrwr

View GitHub Profile
@mcbrwr
mcbrwr / hisrc
Created May 21, 2014 09:24
Dynamicly load hires image based on window width
# hisrc: load low src image by default and on defined breakpoint load hires image
# html markup: <img data-breakpoint="450" data-hisrc="large-image.jpg" src="default-image.jpg" alt=" ">
# data-breakpoint="450" is not needed, 450 is default
hisrc = () ->
window_width = $(window).width()
$('[data-hisrc]').each () ->
$(this).attr('data-breakpoint', '450') if not $(this).attr('data-breakpoint')
$(this).attr('data-losrc', $(this).attr('src') ) if not $(this).attr('data-losrc')
@mcbrwr
mcbrwr / documentready
Created June 1, 2014 10:00
Do something when the document is ready
var readyStateCheckInterval = setInterval(function() {
if (document.readyState === "complete") {
// do stuff
init();
clearInterval(readyStateCheckInterval);
}
}, 10);
@mcbrwr
mcbrwr / overlay-video-play-icon.less
Created June 2, 2014 08:42
LESS overlay video play icon
.vidicon(@size) {
@trisize: (@size / 3);
position: relative;
z-index: 1;
&:before,
&:after {
content: "";
opacity: .7;
display: block;
position: absolute;
@mcbrwr
mcbrwr / iconizr-template.less
Last active August 29, 2015 14:02
iconizr LESS template - not very lean.. but it is full featured
{{#svg}}
{{#selector}}.{{expression}}{{^last}},
{{/last}}{{/selector}} { {{#sprite}}
background-position: {{position}};{{/sprite}}{{^common}}
background-repeat: no-repeat;{{#dimensions}}
display: block;
text-indent: -999em;
width: {{width}}px;
height: {{height}}px;{{/dimensions}}
background-image: url(/assets/sprite/{{#sprite}}{{sprite}}{{/sprite}}{{^sprite}}{{#encode}}"{{encoded}}"{{/encode}}{{^encode}}{{path}}{{/encode}}{{/sprite}});{{/common}}
@mcbrwr
mcbrwr / nav.less
Last active August 29, 2015 14:04
CSS logic to show/hide a wrapper with navigation on small screens using the target selector instead of Javascript.
// --------------------------------- */
// menu logic
// --------------------------------- */
#siteheader {
.menu-wrapper {
max-height: 0;
overflow: hidden;
}
.hidemenu {
@mcbrwr
mcbrwr / popupLink-alt.js
Last active May 31, 2016 14:05
vanilla JS to open href of a link in popup window (ie for custom share buttons)
@mcbrwr
mcbrwr / jquery.smooth.js
Last active August 29, 2016 14:44
jquery smooth scroll on all <a> tags
// smooth scroll
$('a[href*="#"]:not([href="#"])').on("click", function() {
if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
var toppie = target.offset().top - 50;
$('html,body').animate({
scrollTop: toppie
}, 600);
@mcbrwr
mcbrwr / no-ad-no-suggested-no-sidebar-facebook.css
Created September 2, 2015 05:21
Use stylebot or any other CSS replacement plugin in your browser with this bit of CSS to clean up Facebook timeline. It removes sidebars, ads & suggested posts and some "people you know liked this company" posts.
#contentArea {
float: none;
margin: 0 auto;
max-width: 700px;
width: 100%;
}
#contentCol {
margin-left: 0;
padding-left: 0;
@mcbrwr
mcbrwr / chrome_console_filter.regex
Created January 6, 2016 13:30
regex to filter out XHR & Security messages from the Chrome JS console
^((?!Security|XHR).)*$
@mcbrwr
mcbrwr / clear-columns.less
Created January 27, 2016 19:38
Bootstrap 3 - clear columns
.row {
> .col-sm-4 {
@media screen and (min-width: @screen-sm-min){
&:nth-child(3n + 1) {
clear: left;
}
}
}
> .col-sm-3 {
@media screen and (min-width: @screen-sm-min){