Skip to content

Instantly share code, notes, and snippets.

@Anderson-Juhasc
Forked from arextar/gist:2324454
Created March 28, 2013 21:07
Show Gist options
  • Save Anderson-Juhasc/5266796 to your computer and use it in GitHub Desktop.
Save Anderson-Juhasc/5266796 to your computer and use it in GitHub Desktop.
;(function($){
var _is = $.fn.is, _filter = $.fn.filter;
function visible(elem){
elem = $(elem);
return !!(elem.width() || elem.height()) && elem.css("display") !== "none";
}
$.fn.is = function(sel){
if(sel === ":visible"){
return visible(this);
}
if(sel === ":hidden"){
return !visible(this);
}
return _is.call(this, sel);
}
$.fn.filter = function(sel){
if(sel === ":visible"){
return $([].filter.call(this, visible));
}
if(sel === ":hidden"){
return $([].filter.call(this, function(elem){
return !visible(elem);
}));
}
return _filter.call(this, sel);
}
})(Zepto);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment