日期:2014-05-16 浏览次数:20430 次
别人写的jslayout插件 可以分为 north、center、south
/*!
* jLayout JQuery Plugin v0.17
*
* Licensed under the new BSD License.
* Copyright 2008-2009 Bram Stein
* All rights reserved.
*/
/*global jQuery jLayout*/
if (jQuery && jLayout) {
(function ($) {
/**
* This wraps jQuery objects in another object that supplies
* the methods required for the layout algorithms.
*/
function wrap(item, resize) {
var that = {};
$.each(['min', 'max'], function (i, name) {
that[name + 'imumSize'] = function (value) {
var l = item.data('jlayout');
if (l) {
return l[name + 'imum'](that);
} else {
return item[name + 'Size'](value);
}
};
});
$.extend(that, {
doLayout: function () {
var l = item.data('jlayout');
if (l) {
l.layout(that);
}
item.css({position: 'absolute'});
},
isVisible: function () {
return item.isVisible();
},
insets: function () {
var p = item.padding(),
b = item.border();
return {
'top': p.top,
'bottom': p.bottom + b.bottom + b.top,
'left': p.left,
'right': p.right + b.right + b.left
};
},
bounds: function (value) {
var tmp = {};
if (value) {
if (typeof value.x === 'number') {
tmp.left = value.x;
}
if (typeof value.y === 'number') {
tmp.top = value.y;
}
if (typeof value.width === 'number') {
tmp.width = (value.width - (item.outerWidth(true) - item.width()));
tmp.width = (tmp.width >= 0) ? tmp.width : 0;
}
if (typeof value.height === 'number') {
tmp.height = value.height - (item.outerHeight(true) - item.height());
tmp.height = (tmp.height >= 0) ? tmp.height : 0;
}
item.css(tmp);
return item;
} else {
tmp = item.position();
return {
'x': tmp.left,
'y': tmp.top,
'width': item.outerWidth(false),
'height': item.outerHeight(false)
};
}
},
preferredSize: function () {
var minSize,
maxSize,
margin = item.margin(),
size = {width: 0, height: 0},
l = item.data('jlayout');
if (l && resize) {
size = l.preferred(that);
minSize = that.minimumSize();
maxSize = that.maximumSize();
size.width += margin.left + margin.right;
size.height += margin.top + margin.bottom;
if (size.width &l