Index: ssts-web/src/main/webapp/js/extCompOperationUtil.js =================================================================== diff -u -r15795 -r16893 --- ssts-web/src/main/webapp/js/extCompOperationUtil.js (.../extCompOperationUtil.js) (revision 15795) +++ ssts-web/src/main/webapp/js/extCompOperationUtil.js (.../extCompOperationUtil.js) (revision 16893) @@ -4,18 +4,55 @@ var extCompOperationUtil = (function () { var gOperation; + + var motionObj; + + //动作的常量 + var constants = { + UP: 'up', + DOWN: 'down', + BOTTOM: 'bottom', + TOP: 'top' + }; /** * extJS组件操作工具类工厂,用来返回需要创建的对象,以后扩展可以通过增加对应的组件操作对象,然后用这个工厂返回 * @constructor */ var ExtCompOperationUtilFactory = function () { this.getGridOperation = function () { - if (isUndefinedOrNullOrEmpty(gOperation)){ + if (isUndefinedOrNullOrEmpty(gOperation)) { gOperation = new GridOperation(); } return gOperation; + }; + this.getMotionObj = function () { + if (isUndefinedOrNullOrEmpty(motionObj)) { + motionObj = new MotionObj(); + } + return motionObj; } } + + //动作的类,用于获取上下最上最下的动作 + var MotionObj = function () { + this.getConstant = function (name) { + return constants[name]; + }; + this.getUp = function () { + return constants.UP; + }; + this.getDown = function () { + return constants.DOWN; + }; + this.getBottom = function () { + return constants.BOTTOM; + }; + this.getTop = function () { + return constants.TOP; + }; + }; + + //grid表单操作对象,支持每行上,下,置顶,置底操作 var GridOperation = function () { /** @@ -52,11 +89,11 @@ var operation = {}; // border是边界值判断(即最上和最低的位置) // pos是要插入的对应位置 - if (motion == 'up') { + if (motion == motionObj.getUp()) { operation.border = 0; operation.pos = rowIndex - 1; } - else if (motion == 'down') { + else if (motion == motionObj.getDown()) { operation.border = size - 1; operation.pos = rowIndex + 1; } @@ -71,8 +108,7 @@ } return operation; } - } - + }; return new ExtCompOperationUtilFactory(); })(); \ No newline at end of file