Created
March 17, 2010 17:26
-
-
Save brianjlandau/335485 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function($) { | |
| $.fn.disable = function(){ | |
| return this.attr('disabled', 'disabled'); | |
| }; | |
| $.fn.enable = function(){ | |
| return this.removeAttr('disabled'); | |
| }; | |
| $.fn.findOrAppend = function(selector, html){ | |
| var results = this.find(selector); | |
| if (results.length > 0){ | |
| return results; | |
| } else { | |
| html = $(html); | |
| this.append(html); | |
| return html; | |
| } | |
| }; | |
| $.fn.margin = function(side){ | |
| return this[0] && parseInt( jQuery.curCSS(this[0], ('margin'+side), true), 10 ) || 0; | |
| }; | |
| $.overlap = function(e1, e2){ | |
| var el1 = $(e1), el2 = $(e2); | |
| var e1x1 = (el1.position().left-el1.margin('Left')), e1x2 = (el1.position().left+el1.outerHeight()+el1.margin('Right')), | |
| e1y1 = (el1.position().top-el1.margin('Top')), e1y2 = (el1.position().top+el1.outerHeight()+el1.margin('Bottom')); | |
| var e2top = (el2.position().top-el2.margin('Top')), e2left = (el2.position().left-el2.margin('Left')), | |
| e2width = el2.outerWidth(true), e2height = el2.outerHeight(true); | |
| return ($.ui.isOver(e1y1, e1x1, e2top, e2left, e2height, e2width) || | |
| $.ui.isOver(e1y1, e1x2, e2top, e2left, e2height, e2width) || | |
| $.ui.isOver(e1y2, e1x1, e2top, e2left, e2height, e2width) || | |
| $.ui.isOver(e1y2, e1x2, e2top, e2left, e2height, e2width)); | |
| }; | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment