Skip to content

Instantly share code, notes, and snippets.

View korof's full-sized avatar

Krzysztof Kornacki korof

  • Katowice, Poland
View GitHub Profile
@korof
korof / gist:9873643
Created March 30, 2014 14:39
jQuery: Placeholder polyfill
$(function() {
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@korof
korof / gist:a790c83ece89645f94a3
Created November 18, 2014 11:12
html5: number type and placeholder on android
<input type="text" onfocus="this.type='number'" onblur="this.type='text'" placeholder="placeholder text"/>
https://code.google.com/p/android/issues/detail?id=24626
This issue seems to be fixed in 4.2.2.
@korof
korof / gist:3b53e620f49d59a29c16
Created January 14, 2015 18:49
css: Fix jumping scrollbar
html {
margin-left: calc(100vw - 100%);
margin-right: 0;
}
/*Note: calculating the scrollbar width this way only works when the <html> element has overflow: auto;.
There's one small issue: when using responsive web design (which you should!), it gets quite obvious that the margin at the left is bigger than at the right when the page is made smaller. This won't be an issue on mobile because scrollbars aren't normally shown there, but it just looks ugly on a desktop browser when the browser is resized. This can be fixed by only enabling this feature on wider viewports:
*/
@media screen and (min-width: 960px) {
var getDir = function( elem, e ) {
/** the width and height of the current div **/
var w = elem.width();
var h = elem.height();
var offset = elem.offset();
/** calculate the x and y to get an angle to the center of the div from that x and y. **/
/** gets the x value relative to the center of the DIV and "normalize" it **/
var x = (e.pageX - offset.left - (w/2)) * ( w > h ? (h/w) : 1 );
@korof
korof / gist:7e8a91cb6a5aec6aa109
Created August 30, 2015 16:57
css hover na urządzeniach dotykowych
<body ontouchstart="">
...
</body>
@korof
korof / LICENSE
Last active September 13, 2015 12:24 — forked from AKalbarczyk/LICENSE
Arrayzing - The JavaScript array cheatsheet
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@korof
korof / what-forces-layout.md
Last active September 22, 2015 06:54 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@korof
korof / gist:8161076
Created December 28, 2013 16:09
HTML: Starting template
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
@korof
korof / Package Control.sublime-settings
Last active January 1, 2016 15:09
Sublime Text: Package Control.sublime-settings
{
"installed_packages":
[
"BracketHighlighter",
"CSScomb",
"DocBlockr",
"Emmet",
"Gist",
"HTML Boilerplate",
"jQuery Snippets pack",