Skip to content

Instantly share code, notes, and snippets.

@cyokodog
Last active December 14, 2015 06:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyokodog/5044329 to your computer and use it in GitHub Desktop.
Save cyokodog/5044329 to your computer and use it in GitHub Desktop.
;(function($){
$.isEnabled = function(){
var o = this, callee = arguments.callee;
if(!(o instanceof callee)) return new callee(o,arguments);
var body = $('body'),isHide = body.is(':hidden');
!isHide || body.show();
for(var i in o) if(typeof o[i] == 'function') callee[i] = o[i]();
!isHide || body.hide();
}
$.isEnabled.prototype.htmlScroll = function(){
var html = $('html'), top = html.scrollTop();
var el = $('<div/>').height(10000).prependTo('body');
html.scrollTop(10000);
var rs = !!html.scrollTop();
html.scrollTop(top);
el.remove();
return rs;
}
$.isEnabled.prototype.positionFixed = function(){
var el = $('<div/>').add('<div/>').css({height:8,position:'fixed',top:0}).prependTo('body');
var rs = el.eq(0).offset().top == el.eq(1).offset().top
el.remove();
return rs;
};
$.isEnabled.prototype.displayInlineBlock = function(){
var el = $('<div/>').add('<div/>').css({height:8,display:'inline-block'}).prependTo('body');
var rs = el.eq(0).offset().top == el.eq(1).offset().top
el.remove();
return rs;
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment