Skip to content

Instantly share code, notes, and snippets.

@Ajnasz
Ajnasz / gist:318378
Created March 1, 2010 13:46
YUI 2 toggleClass
YAHOO.util.Dom.toggleClass = function(el, cn) {
return YAHOO.util.Dom.hasClass(el, cn) ? YAHOO.util.Dom.removeClass(el, cn) : YAHOO.util.Dom.addClass(el, cn);
};
YAHOO.util.Element.prototype.toggleClass = function(cn) {
return YAHOO.util.Dom.toggleClass(this.get('element'), cn);
};
YAHOO.util.Dom.toggleClass('elementid', 'hidden');
// or

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@getify
getify / gist:710231
Created November 22, 2010 16:48
how to detect IE from JavaScript using conditional comments
// stripped down version just detecting IE
(function(global){
global._isIE = false;
try {
var div = document.createElement("div");
div.innerHTML = "<!--[if IE]><i></i><![endif]-->";
global._isIE = (div.getElementsByTagName("i").length > 0);
} catch(err) { }
})(window);
@jcroft
jcroft / grid.sass
Created March 21, 2011 18:09
The grid component from my personal front-end framework. Brief demo here: http://jeffcroft.com/static/misc/grid_frameworks.mov
// REQUIRED VARS. Defaults to a 950px wide, 24-column grid that has 30px wide units and 10px wide
// gutters. If you do the fluid grid, then this 950/24/30/10px size will become the maximum size.
$grid_type: fixed !default
$grid_columns: 24 !default
$grid_column_width: 30 !default
$grid_gutter_width: 10 !default
// GENERATED VARS. You can ignore these.
$grid_full_width: $grid_columns * $grid_column_width + $grid_columns * $grid_gutter_width - $grid_gutter_width
$grid_column_width_percent: ($grid_column_width / $grid_full_width * 100) * 1%
@Craga89
Craga89 / ios-version.js
Created May 29, 2012 16:39
JavaScript iOS version detection
/*
* Outputs a float representing the iOS version if user is using an iOS browser i.e. iPhone, iPad
* Possible values include:
* 3 - v3.0
* 4.0 - v4.0
* 4.14 - v4.1.4
* false - Not iOS
*/
var iOS = parseFloat(
@jonathan-fielding
jonathan-fielding / gist:5867484
Created June 26, 2013 13:46
JS State Manager (none library based)
var stateManager = (function () {
var state = null;
var setState = function () {
if ($('body').width() < 768) {
if (state !== "mobile") {
state = "mobile";
displayMobile();
}
}
@lavoiesl
lavoiesl / bs3-stacked-tabs.less
Created September 18, 2013 15:21
Add tabs-left, tabs-right and tabs-below in bootstrap 3 Credit: http://stackoverflow.com/questions/18432577/stacked-tabs-in-bootstrap-3
// http://stackoverflow.com/questions/18432577/stacked-tabs-in-bootstrap-3
.tabs-below, .tabs-right, .tabs-left {
.nav-tabs {
border-bottom: 0;
}
}
.tab-content > .tab-pane,
.pill-content > .pill-pane {
display: none;
@WebReflection
WebReflection / ietouches.md
Last active December 27, 2015 10:49
moved to a repo instead of a gist
@dlo
dlo / Auto-layout-keyboard-adjustment.md
Last active February 26, 2021 07:33
How to adjust a view's height with Auto Layout when a keyboard appears or disappears in iOS 7.

This gist outlines how to resize a view when a keyboard appears using Auto Layout (there are a bunch of code samples out there that manually adjust the view's frame, but that's just so 2013). The method I outline below works universally on both iPhone and iPad, portrait and landscape, and is pretty darn simple.

Setting Up

The first thing to do is to define our containing view controller, the view, and the bottom constraint that we'll use to adjust its size.

Here's HeightAdjustingViewController.h. We don't need to expose any public properties, so it's pretty bare.

@addyosmani
addyosmani / LICENSE.txt
Last active April 8, 2024 20:15 — forked from 140bytes/LICENSE.txt
Offline Text Editor in < 140 bytes (115 bytes). Powered by localStorage & contentEditable
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Copyright (C) 2014 ADDY OSMANI <addyosmani.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION