Skip to content

Instantly share code, notes, and snippets.

View termi's full-sized avatar

Егор Халимоненко termi

View GitHub Profile
@termi
termi / IElt9_getComputedStyle.js
Last active December 12, 2015 01:28
getComputedStyle for IE < 9
void function() {
var global = this
/** @const */
, _Array_slice = Array.prototype.slice
/** @const */
, _Function_apply = Function.prototype.apply
@termi
termi / build.js
Created November 19, 2012 09:32
JS GCC compile or remove GCC globals
#!/usr/bin/env node
if (process.argv.length < 3) {
console.error('No enough parameters');
process.exit();
}
const fs = require('fs')
, path = require('path')
;
@termi
termi / index.js
Created November 7, 2012 12:15
offset[Left/Top]
var getScrollX
, getScrollX
, _document_documentElement = document.documentElement
;
document.compatMode === "CSS1Compat" ?
((_getScrollX = function(){return _document_documentElement.scrollLeft}), (_getScrollY = function(){return _document_documentElement.scrollTop}))
:
((_getScrollX = function(){return document.body.scrollTop}), (_getScrollY = function(){return document.body.scrollLeft}))
;
@termi
termi / index.js
Created November 6, 2012 08:36
Add/Remove listeners
void function(exports) {
var _browser_msie = window["eval"] && window["eval"]("/*@cc_on 1;@*/") && +((/msie (\d+)/i.exec(navigator.userAgent) || [])[1] || 0) || void 0
, _document_documentElement = document.documentElement
, _document_body = document.body
, _append = function(obj, extention) {
for(var key in extention)
@termi
termi / index.js
Created November 1, 2012 14:33
getElementsByClassName-like function for all browsers (IE6+ / w3c)
var
/** @type {RegExp} @const */
RE__getElementsByClassName = /\s*(\S+)\s*/g
/** @type {string} @const */
, STRING_FOR_RE__getElementsByClassName = '(?=(^|.*\\s)$1(\\s|$))'
/** @type {boolean} @const */
, IS_IELT9 = !/\[native\s+code\]/i.test(document.getElementsByClass + "")
/** @type {RegExp} @const */
, RE__querySelector__dottes = /\./g
;
@termi
termi / index.js
Created October 25, 2012 11:07
New DOM4 classList polyfill for browsers with classList support
void function(global, tmp) {
if("classList" in tmp) {
void function(_add, _remove, _Array_forEach_) {
this["add"] = function() {
_Array_forEach_.call(arguments, _add, this);
};
this["remove"] = function() {
_Array_forEach_.call(arguments, _remove, this);
};
this["toggle"] = function(token, forse) {
@termi
termi / index.js
Created September 25, 2012 21:52
:scope support test
function testForRealScopePreudoClassSupport() {
var scopeSupport = false
, tmp = document.createElement("b")
;
tmp.innerHTML = "<i>t</i>";
try {
scopeSupport = tmp.querySelector(":scope>i");
scopeSupport = scopeSupport && scopeSupport.innerHTML == "t";
@termi
termi / polyfill.js
Created September 18, 2012 15:21 — forked from Raynos/polyfill.js
RadioNodeList polyfill
/*
demo :- http://jsfiddle.net/termi/pyFXW/
Implements RadioNodeList :- http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#radionodelist
Implementation just adds `.value` as a property to `NodeList`.
Requires ES5 shim and ES5 shimmable browser. (Modern and IE8)
*/
;(function () {
@termi
termi / bug_examples.html
Created August 30, 2012 19:41
Fix Safari bug with [radio input with no form].cloneNode()
<html>
<form>
<div id="test3">
test1 :
<input id="test1" type="radio" name="test" checked />
</div>
test 2:
<input type="radio" name="test" />
</form>
@termi
termi / LICENSE.txt
Created May 1, 2012 17:32 — forked from 140bytes/LICENSE.txt
event delegation
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
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