1 /** 2 * @fileOverview position and visible extension,可定位的隐藏层 3 * @author yiminghe@gmail.com 4 */ 5 KISSY.add("component/uibase/position", function (S) { 6 7 /** 8 * @name Position 9 * @class 10 * Position extension class. 11 * Make component positionable 12 * @memberOf Component.UIBase 13 */ 14 function Position() { 15 } 16 17 Position.ATTRS = 18 /** 19 * @lends Component.UIBase.Position# 20 */ 21 { 22 /** 23 * Horizontal axis 24 * @type Number 25 */ 26 x:{ 27 view:1 28 }, 29 /** 30 * Vertical axis 31 * @type Number 32 */ 33 y:{ 34 view:1 35 }, 36 /** 37 * Horizontal and vertical axis. 38 * @type Number[] 39 */ 40 xy:{ 41 // 相对 page 定位, 有效值为 [n, m], 为 null 时, 选 align 设置 42 setter:function (v) { 43 var self = this, 44 xy = S.makeArray(v); 45 /* 46 属性内分发特别注意: 47 xy -> x,y 48 */ 49 if (xy.length) { 50 xy[0] && self.set("x", xy[0]); 51 xy[1] && self.set("y", xy[1]); 52 } 53 return v; 54 }, 55 /** 56 * xy 纯中转作用 57 */ 58 getter:function () { 59 return [this.get("x"), this.get("y")]; 60 } 61 }, 62 /** 63 * z-index value. 64 * @type Number 65 */ 66 zIndex:{ 67 view:1 68 } 69 }; 70 71 72 Position.prototype = 73 /** 74 * @lends Component.UIBase.Position.prototype 75 */ 76 { 77 /** 78 * Move to absolute position. 79 * @param {Number|Number[]} x 80 * @param {Number} [y] 81 * @example 82 * <code> 83 * move(x, y); 84 * move(x); 85 * move([x,y]) 86 * </code> 87 */ 88 move:function (x, y) { 89 var self = this; 90 if (S.isArray(x)) { 91 y = x[1]; 92 x = x[0]; 93 } 94 self.set("xy", [x, y]); 95 return self; 96 } 97 }; 98 99 return Position; 100 });