<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>src/jquery.coords.js</title> <link rel="stylesheet" href="http://yui.yahooapis.com/3.5.1/build/cssgrids/cssgrids-min.css"> <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css"> <link rel="stylesheet" href="../assets/css/main.css" id="site_styles"> <link rel="shortcut icon" type="image/png" href="../assets/favicon.png"> <script src="http://yui.yahooapis.com/combo?3.5.1/build/yui/yui-min.js"></script> </head> <body class="yui3-skin-sam"> <div id="doc"> <div id="hd" class="yui3-g header"> <div class="yui3-u-3-4"> <!-- <h1><img src="../assets/css/logo.png" title=""></h1> --> <h1><img src="http://ducksboard.com/wp-content/themes/blog-theme-ducksboard/images/ducksboard.png" title=""></h1> </div> <div class="yui3-u-1-4 version"> <em>API Docs for: </em> </div> </div> <div id="bd" class="yui3-g"> <div class="yui3-u-1-4"> <div id="docs-sidebar" class="sidebar apidocs"> <div id="api-list"> <h2 class="off-left">APIs</h2> <div id="api-tabview" class="tabview"> <ul class="tabs"> <li><a href="#api-classes">Classes</a></li> <li><a href="#api-modules">Modules</a></li> </ul> <div id="api-tabview-filter"> <input type="search" id="api-filter" placeholder="Type to filter APIs"> </div> <div id="api-tabview-panel"> <ul id="api-classes" class="apis classes"> <li><a href="../classes/Collision.html">Collision</a></li> <li><a href="../classes/Coords.html">Coords</a></li> <li><a href="../classes/Gridster.html">Gridster</a></li> </ul> <ul id="api-modules" class="apis modules"> </ul> </div> </div> </div> </div> </div> <div class="yui3-u-3-4"> <div id="api-options"> Show: <label for="api-show-inherited"> <input type="checkbox" id="api-show-inherited" checked> Inherited </label> <label for="api-show-protected"> <input type="checkbox" id="api-show-protected"> Protected </label> <label for="api-show-private"> <input type="checkbox" id="api-show-private"> Private </label> <label for="api-show-deprecated"> <input type="checkbox" id="api-show-deprecated"> Deprecated </label> </div> <div class="apidocs"> <div id="docs-main"> <div class="content"> <h1 class="file-heading">File: src/jquery.coords.js</h1> <div class="file"> <pre class="code prettyprint linenums"> /* * jquery.coords * https://github.com/ducksboard/gridster.js * * Copyright (c) 2012 ducksboard * Licensed under the MIT, GPL licenses. */ ;(function($, window, document, undefined){ /** * Coords description * * @class Coords * @param {HTMLElement|Object} obj HTMLElement or a literal Object with the left, top, width and height properties. * @constructor */ function Coords(obj) { if (obj[0] && $.isPlainObject(obj[0])) { this.data = obj[0]; }else { this.el = obj; } this.isCoords = true; this.coords = {}; this.init(); return this; } var fn = Coords.prototype; fn.init = function(){ this.set(); this.original_coords = this.get(); }; fn.set = function() { var el = this.el; if (el) { this.data = el.offset(); this.data.width || (this.data.width = el.width()); this.data.height || (this.data.height = el.height()); } var d = this.data; this.coords.x1 = d.left; this.coords.y1 = d.top; this.coords.x2 = d.left + d.width; this.coords.y2 = d.top + d.height; this.coords.cx = d.left + (d.width / 2); this.coords.cy = d.top + (d.height / 2); this.coords.width = d.width; this.coords.height = d.height; this.coords.el = el || false ; return this; }; fn.update = function(data){ if (!data && !this.el) { return this; } if (data) { var new_data = $.extend(this.data, data); this.data = new_data; } this.set(); return this; }; fn.get = function(){ return this.coords; }; //jQuery adapter $.fn.coords = function() { if (this.data('coords') ) { return this.data('coords'); } var ins = new Coords(this, arguments[0]); this.data('coords', ins); return ins; }; }(jQuery, window, document)); </pre> </div> </div> </div> </div> </div> </div> </div> <script src="../assets/vendor/prettify/prettify-min.js"></script> <script>prettyPrint();</script> <script src="../assets/js/yui-prettify.js"></script> <script src="../assets/../api.js"></script> <script src="../assets/js/api-filter.js"></script> <script src="../assets/js/api-list.js"></script> <script src="../assets/js/api-search.js"></script> <script src="../assets/js/apidocs.js"></script> </body> </html>