Skip to content

Instantly share code, notes, and snippets.

View kpozin's full-sized avatar

Konstantin Pozin kpozin

View GitHub Profile
@kpozin
kpozin / removeUseStrict.js
Created July 10, 2012 13:35
Temporary workaround for parser bug in JSDoc Toolkit 3 / Rhino 1.7R3
/**
* @module plugins/removeUseStrict
* @author kpozin
*/
exports.handlers = {
beforeParse: function (e) {
e.source = e.source.replace(/(['"])use strict\1;/g, "");
}
};
@kpozin
kpozin / fixScrollAndTapHold.js
Created July 29, 2011 14:43
Fix for jQuery Mobile's scrolling and taphold behavior
(function fixScrollAndTapHold() {
var $document = $(document);
var isScrolling = false;
var lastX, lastY, lastT, scrollTimeout;
$document.bind("touchstart mousedown click", function(e) {
lastT = e.originalEvent.timeStamp;
});
function Person(){}
Person.prototype.greet = function(){ alert("Hi!"); };
var p = new Person();
JSON.parse(JSON.stringify(p)).greet(); // throws Object #<an Object> has no method 'greet' in Chrome
@kpozin
kpozin / gist:779141
Created January 14, 2011 03:49
isDisconnected
// A painfully simple check to see if an element is disconnected
// from a document (should be improved, where feasible).
function isDisconnected( node ) {
return !node || !node.parentNode || node.parentNode.nodeType === 11;
}
@kpozin
kpozin / inDom.js
Created January 14, 2011 03:40
jQuery.fn.inDom()
/**
* Returns true if this selection is part of the current DOM;
* false if it's a fragment.
* @return {Boolean}
*/
jQuery.fn.inDom() = function() {
// Get the first element in the jQuery selection
var node = this[0];
while (node) {