My personal blog
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.1 KiB

11 years ago
function testFeatures() {
var features = ['maskImage'];
$(features).map(function(i, feature) {
if (Modernizr.testAllProps(feature)) {
$('html').addClass(feature);
} else {
$('html').addClass('no-'+feature);
}
});
if ("placeholder" in document.createElement("input")) {
$('html').addClass('placeholder');
} else {
$('html').addClass('no-placeholder');
}
}
function addCodeLineNumbers() {
if (navigator.appName === 'Microsoft Internet Explorer') { return; }
$('div.gist-highlight').each(function(code) {
var tableStart = '<table><tbody><tr><td class="gutter">',
lineNumbers = '<pre class="line-numbers">',
tableMiddle = '</pre></td><td class="code">',
tableEnd = '</td></tr></tbody></table>',
count = $('.line', code).length;
for (var i=1;i<=count; i++) {
lineNumbers += '<span class="line-number">'+i+'</span>\n';
}
var table = tableStart + lineNumbers + tableMiddle + '<pre>'+$('pre', code).html()+'</pre>' + tableEnd;
$(code).html(table);
});
}
11 years ago
disqus_init = false;
11 years ago
11 years ago
function toggleDisqus() {
var dom = document.getElementById('disqus_thread');
if (dom.className.indexOf('hide') != -1) {
dom.className = dom.className.replace(/\bhide\b/,'');
if (!disqus_init) {
loadDisqus();
disqus_init = true;
// hacking for disqus bad height
11 years ago
}
11 years ago
} else {
dom.className += ' hide';
11 years ago
}
11 years ago
return false;
11 years ago
}
$('document').ready(function() {
testFeatures();
addCodeLineNumbers();
});
// iOS scaling bug fix
// Rewritten version
// By @mathias, @cheeaun and @jdalton
// Source url: https://gist.github.com/901295
(function(doc) {
var addEvent = 'addEventListener',
type = 'gesturestart',
qsa = 'querySelectorAll',
scales = [1, 1],
meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
function fix() {
meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
doc.removeEventListener(type, fix, true);
}
if ((meta = meta[meta.length - 1]) && addEvent in doc) {
fix();
scales = [0.25, 1.6];
doc[addEvent](type, fix, true);
}
}(document));