From 23473d602e81cb2ceadd5193f74276fc71ffe4bc Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 22 Mar 2017 11:15:08 +0800 Subject: [PATCH] add --- src/core/proto/jquery.js | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/core/proto/jquery.js diff --git a/src/core/proto/jquery.js b/src/core/proto/jquery.js new file mode 100644 index 000000000..408285a4f --- /dev/null +++ b/src/core/proto/jquery.js @@ -0,0 +1,61 @@ +/*! + * jLayout JQuery Plugin v0.11 + * + * Licensed under the revised BSD License. + * Copyright 2008, Bram Stein + * All rights reserved. + */ +if (jQuery) { + (function($){ + // richer:容器在其各个边缘留出的空间 + $.fn.insets = function () { + var p = this.padding(), + b = this.border(); + return { + 'top': p.top, + 'bottom': p.bottom + b.bottom + b.top, + 'left': p.left, + 'right': p.right + b.right + b.left + }; + }; + + // richer:获取 && 设置jQuery元素的边界 + $.fn.bounds = function (value) { + var tmp = {hasIgnoredBounds : true}; + + if (value) { + if (!isNaN(value.x)) { + tmp.left = value.x; + } + if (!isNaN(value.y)) { + tmp.top = value.y; + } + if (value.width != null) { + tmp.width = (value.width - (this.outerWidth(true) - this.width())); + tmp.width = (tmp.width >= 0) ? tmp.width : value.width; + // fix chrome + //tmp.width = (tmp.width >= 0) ? tmp.width : 0; + } + if (value.height != null) { + tmp.height = value.height - (this.outerHeight(true) - this.height()); + tmp.height = (tmp.height >= 0) ? tmp.height : value.height; + // fix chrome + //tmp.height = (tmp.height >= 0) ? tmp.height : value.0; + } + this.css(tmp); + return this; + } + else { + // richer:注意此方法只对可见元素有效 + tmp = this.position(); + return { + 'x': tmp.left, + 'y': tmp.top, + // richer:这里计算外部宽度和高度的时候,都不包括边框 + 'width': this.outerWidth(), + 'height': this.outerHeight() + }; + } + }; + })(jQuery); +}; \ No newline at end of file