您的位置:首页 > 产品设计 > UI/UE

js玩具——UI组件:边距

2011-09-19 17:04 316 查看
/*

 * 边距

 *  author: 吴安国

 * version: 1.0

 */ 
function Margin() {
switch(arguments.length) {
case 0:
throw new Error("Margin参数错误");
break;
case 1:
this.left = this.right = this.top = this.bottom = arguments[0];
break;
case 2:
this.top = this.bottom = arguments[0];
this.left = this.right = arguments[1];
break;
case 3:
this.top = arguments[0];
this.left = this.right = arguments[1];
this.bottom = arguments[2];
break;
case 4:
default:
this.top = arguments[0];
this.right = arguments[1];
this.bottom = arguments[2];
this.left = arguments[3];
break;
}
}

/**
* 左边边距
* @return left
*/
Margin.prototype.getLeft = function() {
return "'" + this.left + "'";
};

/**
* 右边边距
* @return right
*/
Margin.prototype.getRight = function() {
return "'" + this.right + "'";
};

/**
* 上边边距
* @return top
*/
Margin.prototype.getTop = function() {
return "'" + this.top + "'";
};

/**
* 下边边距
* @return bottom
*/
Margin.prototype.getBottom = function() {
return "'" + this.bottom + "'";
};

Margin.prototype.toString = function() {
var sb = new StringBuffer("'");
sb.append(this.top).append(" ");
sb.append(this.right).append(" ");
sb.append(this.bottom).append(" ");
sb.append(this.left).append("'");
return sb.toString();
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ui function