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.
 
 
 

75 lines
2.1 KiB

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);
});
}
disqus_init = false;
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
}
} else {
dom.className += ' hide';
}
return false;
}
$('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));