Skip to content

Instantly share code, notes, and snippets.

View csuwildcat's full-sized avatar

Daniel Buchner csuwildcat

View GitHub Profile
(function () {
var ua = /iPhone|iP[oa]d/.test(navigator.userAgent)
? 'iOS'
: /Android/.test(navigator.userAgent)
? 'Android'
: 'PC'
;
document.addEventListener('DOMContentLoaded', function (event) {
if(ua == 'PC'){
@csuwildcat
csuwildcat / x-tag position mixin
Created November 9, 2013 22:24
position script for x-tag mixin
var doc = document,
root = doc.documentElement,
positions = {
'top-left': function(node, target){
return {
fit: node.height <= target.top &&
target.left >= 0,
top: target.top,
left: target.left,
// This case:
<x-deck id="foo">
<x-card>Card 1</x-card>
<x-card>Card 2</x-card>
<x-card>Card 3</x-card>
</x-deck>
<menu>
<x-command label="Tab 1" targets="#foo x-card:nth-child(1)"></x-command>
xtag.register('bb-header', {
lifecycle: {
created: function() { Helpers.created.call(this, 'header'); }
},
accessors: {
'nav': {
attribute: {}
},
'navId': {
// the attribute: {} declaration here auto-links
xtag.mixins.responsive = {
lifecycle: {
created: function(){
// do stuff based on anything you add to
// this tag via: xtag.tags['x-foo']
}
},
methods: {
foo: function(){}
@csuwildcat
csuwildcat / Element Resize CSS
Last active July 21, 2019 03:50
Detect resize of elements in all browsers + IE down to version 6
.resize-triggers {
visibility: hidden;
}
.resize-triggers, .resize-triggers > div, .contract-trigger:before {
content: " ";
display: block;
position: absolute;
top: 0;
left: 0;
{
"activities": {
"crypto-payment": {
"href": "./pay.html",
"disposition": "inline",
"filters": {
"type": ["bitcoin", "litecoin", "namecoin"]
},
"returnValue": true
}
var activity = new MozActivity({
name: "crypto-payment",
data: {
type: "bitcoin",
price: "0.50",
currency: "USD",
wallet: "1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj",
callback: "https://somegame.com/reciepts.html"
}
});
@csuwildcat
csuwildcat / Element Resize
Last active December 2, 2022 22:17
Legit detection of element resize - all modern browsers + IE down to version 6
(function(){
var attachEvent = document.attachEvent;
if (!attachEvent) {
var requestFrame = (function(){
var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame ||
function(fn){ return window.setTimeout(fn, 20); };
return function(fn){ return raf(fn); };
})();
@csuwildcat
csuwildcat / prefix-detection.js
Last active August 29, 2015 13:57
User's browser prefix detection
var prefix = (function () {
var styles = window.getComputedStyle(document.documentElement, ''),
pre = (Array.prototype.slice
.call(styles)
.join('')
.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
)[1];
return {
dom: pre == 'ms' ? 'MS' : pre,
lowercase: pre,