Skip to content

Instantly share code, notes, and snippets.

View obenjiro's full-sized avatar
🎯
Focusing

Alexey Okhrimenko obenjiro

🎯
Focusing
View GitHub Profile
@obenjiro
obenjiro / get-all-events.js
Last active December 22, 2015 21:09
Gist that allows you to get all possible events for IE9+, Chrome, Safari and FF.
//long version
function getAllEvents() {
return Object.getOwnPropertyNames(document)
.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(Object.getPrototypeOf(document))))
.concat(Object.getOwnPropertyNames(Object.getPrototypeOf(window)))
.filter(function(i){return !i.indexOf('on')&&(document[i]==null||document[i].call)})
.filter(function(elem, pos, self){return self.indexOf(elem) == pos})
}
//short, one line version (262 chars)
@obenjiro
obenjiro / vertical-text.css
Last active April 4, 2020 20:23
CrossBrowser Vertical CSS Text
/**
* Works everywere ( IE7+, FF, Chrome, Safari, Opera )
* Example: http://jsbin.com/afAQAWA/2/
*/
.rotated-text {
display: inline-block;
overflow: hidden;
width: 1.5em;
}
.rotated-text__inner {
@obenjiro
obenjiro / querySelectorAll.js
Last active December 28, 2015 14:59
querySelectorAll polyfill
querySelectorAll = function(index, i, result, magicValue){
magicValue = 1000;
return function(rule){
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
var css = rule + ' { position:absolute; color:red; top: '+ magicValue + 'px;}';
style.setAttribute('type', 'text/css');
if(style.styleSheet && !style.sheet) style.styleSheet.cssText=css;
else style.innerHTML = css;
@obenjiro
obenjiro / star.css
Last active December 29, 2015 18:49
pure CSS rating component, that works without CSS :)
/* You can test this solution using this link
** http://jsbin.com/UwIwuTeG/9
**
** test results can be found here
** http://www.browserstack.com/screenshots/4cf227612539dfee2f50495a5b5c9b838d7928d3
**
** ':root' is a nice filter for modern browsers
** http://htmlbook.ru/css/root
**
** this solution is based on LEA VEROU css only switch
@obenjiro
obenjiro / progress-bar.css
Last active December 29, 2015 22:49
CSS progress bar ( incomplete and not perfect )
/* you can test this control using this link
** http://jsbin.com/orePosUh/4
**
** some test results
** http://www.browserstack.com/screenshots/194bf28709cddb6b361017a813e18d420f0a2c9c
*/
.progress_common {
width:220px;
height:15px;
border-radius: 10px;
@obenjiro
obenjiro / styled-button.css
Created December 1, 2013 20:43
HTML button styled with CSS
/* you can test this solution here
** http://jsbin.com/ItiCaTU/1
**
** some test results
** http://www.browserstack.com/screenshots/9fdce4d0529cfe944a90f7cbbfd33e24fe3feb70
*/
input[type='submit'],input[type='button']
{
/* disable problems with mobile platforms */
-webkit-appearance: none;
@obenjiro
obenjiro / crossbrowser-column.css
Last active December 30, 2015 18:59 — forked from anonymous/jsbin.oWepeVI.css
Cross browser 2 column text that 'works' without CSS
/* you can test it here
** http://jsbin.com/oWepeVI/4
**
** you can see some results here http://www.browserstack.com/screenshots/b82dc9a833f2aa3ec76a3737ba48d942a19cc5f2
*/
.article .textpart-left {
position: absolute;
width: 50%;
margin: 0;
@obenjiro
obenjiro / image-fallback.css
Last active December 31, 2015 02:38 — forked from anonymous/jsbin.IfaTodEW.css
Image fallback that is 'ok' if used without CSS
/* you can test this solution here
** http://jsbin.com/IfaTodEW/5
*/
.container {
display: table;
width: 100%;
}
.container .wraper {
display: table-cell;
@obenjiro
obenjiro / live-js-reload.js
Created January 3, 2014 13:56
Live reload JS proof of concept
function outer(t){
for (var i = 0; i<3; i++){
function test(){return gl()();
var a = 1;
console.log(a + b);
}
console.log(test());
}
}
@obenjiro
obenjiro / scrollTopBugFix.js
Created March 7, 2014 10:02
bugfix for browsers with weird scrollTop restoration after refresh policy
// weird Chrome, Y.browser bug with position been saved
// browser jumps to hash id and then jumps to last scrolled position
$(window).on('load', function(){
setTimeout(function(){
var initialUrlHash = getInitialUrlHash();
if (initialUrlHash) {
document.body.scrollTop = $(initialUrlHash).offset().top;
}
},0);
});