Permalink
Browse files

fix: 解决grid超过10列之后交换最后一列导致显示错误的问题

  • Loading branch information...
LiuYueKai committed Mar 8, 2017
1 parent 230af94 commit 01592de9c7e388f7c8845e5426ad8f4cbd86bae0
Showing with 6,942 additions and 11,835 deletions.
  1. +2 −1 .babelrc
  2. +1 −1 dist/tinper-neoui-grid.js
  3. +2 −2 dist/tinper-neoui-grid.min.js
  4. +0 −305 lib/ColumnMenu.js
  5. +0 −456 lib/Edit.js
  6. +0 −63 lib/Fixed.js
  7. +0 −70 lib/FormShow.js
  8. +0 −87 lib/HeaderLevel.js
  9. +0 −95 lib/LocalStorage.js
  10. +0 −59 lib/OverWidthHidden.js
  11. +0 −307 lib/Sort.js
  12. +0 −217 lib/SumRow.js
  13. +0 −230 lib/Swap.js
  14. +0 −10 lib/Test.js
  15. +0 −388 lib/Tree.js
  16. +45 −0 lib/column.js
  17. +88 −0 lib/columnInit.js
  18. +50 −0 lib/dataSource.js
  19. +100 −0 lib/dataSourceInit.js
  20. +67 −0 lib/gridBrowser.js
  21. +215 −2,782 lib/gridComp.js
  22. +121 −0 lib/gridCompClick.js
  23. +719 −0 lib/gridCompCreate.js
  24. +153 −0 lib/gridCompCreateCal.js
  25. +147 −0 lib/gridCompEvent.js
  26. +196 −0 lib/gridCompGet.js
  27. +308 −0 lib/gridCompInit.js
  28. +791 −0 lib/gridCompOperateRow.js
  29. +166 −0 lib/gridCompOther.js
  30. +242 −0 lib/gridCompRenderType.js
  31. +168 −0 lib/gridCompSet.js
  32. +228 −0 lib/gridCompWDChange.js
  33. +33 −3 lib/index.js
  34. +0 −31 lib/js/column.js
  35. +0 −74 lib/js/columnInit.js
  36. +0 −38 lib/js/dataSource.js
  37. +0 −86 lib/js/dataSourceInit.js
  38. +0 −53 lib/js/gridBrowser.js
  39. +0 −273 lib/js/gridComp.js
  40. +0 −107 lib/js/gridCompClick.js
  41. +0 −707 lib/js/gridCompCreate.js
  42. +0 −139 lib/js/gridCompCreateCal.js
  43. +0 −135 lib/js/gridCompEvent.js
  44. +0 −182 lib/js/gridCompGet.js
  45. +0 −301 lib/js/gridCompInit.js
  46. +0 −777 lib/js/gridCompOperateRow.js
  47. +0 −152 lib/js/gridCompOther.js
  48. +0 −228 lib/js/gridCompRenderType.js
  49. +0 −154 lib/js/gridCompSet.js
  50. +0 −214 lib/js/gridCompWDChange.js
  51. +0 −27 lib/js/index.js
  52. +0 −207 lib/js/re_gridCompColMenu.js
  53. +0 −148 lib/js/re_gridCompDrag.js
  54. +0 −626 lib/js/re_gridCompEdit.js
  55. +0 −57 lib/js/re_gridCompEditForm.js
  56. +0 −70 lib/js/re_gridCompFixed.js
  57. +0 −73 lib/js/re_gridCompFormShow.js
  58. +0 −112 lib/js/re_gridCompHeaderLevel.js
  59. +0 −99 lib/js/re_gridCompLocalStorage.js
  60. +0 −58 lib/js/re_gridCompOverWidthHidden.js
  61. +0 −162 lib/js/re_gridCompRowDrag.js
  62. +0 −308 lib/js/re_gridCompSort.js
  63. +0 −311 lib/js/re_gridCompSumRow.js
  64. +0 −235 lib/js/re_gridCompSwap.js
  65. +0 −401 lib/js/re_gridCompTree.js
  66. +0 −160 lib/js/ut_utility.js
  67. +218 −0 lib/re_gridCompColMenu.js
  68. +67 −33 lib/{Drag.js → re_gridCompDrag.js}
  69. +637 −0 lib/re_gridCompEdit.js
  70. +30 −17 lib/{EditForm.js → re_gridCompEditForm.js}
  71. +82 −0 lib/re_gridCompFixed.js
  72. +87 −0 lib/re_gridCompFormShow.js
  73. +126 −0 lib/re_gridCompHeaderLevel.js
  74. +113 −0 lib/re_gridCompLocalStorage.js
  75. +72 −0 lib/re_gridCompOverWidthHidden.js
  76. +175 −0 lib/re_gridCompRowDrag.js
  77. +321 −0 lib/re_gridCompSort.js
  78. +325 −0 lib/re_gridCompSumRow.js
  79. +248 −0 lib/re_gridCompSwap.js
  80. +415 −0 lib/re_gridCompTree.js
  81. +176 −0 lib/ut_utility.js
  82. +6 −2 package.json
  83. +2 −2 src/js/re_gridCompSwap.js
View
@@ -4,6 +4,7 @@
],
"plugins": [
"transform-es3-property-literals",
- "transform-es3-member-expression-literals"
+ "transform-es3-member-expression-literals",
+ "babel-plugin-transform-es2015-modules-umd"
]
}
@@ -6731,7 +6731,7 @@
swapToColumnIndex = $(swapToColumnEle).attr('index'),
swapGridCompColumn = this.gridCompColumnArr[swapColumnIndex];
this.gridCompColumnArr.splice(parseInt(swapToColumnIndex) + 1, 0, swapGridCompColumn);
- if (swapColumnIndex < swapToColumnIndex) this.gridCompColumnArr.splice(swapColumnIndex, 1);else this.gridCompColumnArr.splice(parseInt(swapColumnIndex) + 1, 1);
+ if (parseInt(swapColumnIndex) < parseInt(swapToColumnIndex)) this.gridCompColumnArr.splice(parseInt(swapColumnIndex), 1);else this.gridCompColumnArr.splice(parseInt(swapColumnIndex) + 1, 1);
this.saveGridCompColumnArrToLocal();
this.repaintGridDivs();
}

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,305 +0,0 @@
-'use strict';
-
-;
-(function ($, window, document, undefined) {
- var gridComp = $.fn.grid.gridComp,
- gridCompProto = gridComp.prototype,
- initGridCompColumnFun = gridCompProto.initGridCompColumn,
- initEventFunFun = gridCompProto.initEventFun,
- initGridEventFunFun = gridCompProto.initGridEventFun;
-
- gridCompProto.initGridCompColumnColumnMenuFun = function (columnOptions) {
- var column1 = new this.gridCompColumn(columnOptions, this);
- column1.options.realWidth = column1.options.width;
- this.basicGridCompColumnArr.push(column1);
- };
-
- gridCompProto.initGridCompColumn = function () {
- // 执行原有方法
- initGridCompColumnFun.apply(this, arguments);
- // 扩展方法
- this.menuColumnsHeight = this.gridCompColumnArr.length * this.columnMenuHeight;
- };
-
- gridCompProto.createColumnMenu = function () {
- var oThis = this;
- var htmlStr = '<div class="u-grid-column-menu" id="' + this.options.id + '_column_menu">';
- htmlStr += '<ul data-role="menu" role="menubar" class="u-grid-column-menu-ul" id="' + this.options.id + '_column_menu_ul">';
-
- // 创建显示/隐藏列
- /*htmlStr += '<li class="u-grid-column-menu-li" role="menuitem">';
- htmlStr += '<div class="u-grid-column-menu-div1" id="' + this.options.id + '_showColumn">';
- htmlStr += '<span class="u-grid-column-menu-span">' + this.transMap.ml_show_column + '</span>';
- htmlStr += '<div class="u-grid-column-menu-div3 uf uf-arrowheadpointingtotheright"></div>';
- htmlStr += '</div></li>';*/
-
- // 创建清除设置
- htmlStr += '<li class="u-grid-column-menu-li" role="menuitem">';
- htmlStr += '<div class="u-grid-column-menu-div1" id="' + this.options.id + '_clearSet">';
- htmlStr += '<span class="u-grid-column-menu-span">' + this.transMap.ml_clear_set + '</span>';
- htmlStr += '</div></li>';
-
- htmlStr += '<div class="u-grid-column-menu-columns" id="' + this.options.id + '_column_menu_columns">';
- htmlStr += '<ul data-role="menu" role="menubar" class="u-grid-column-menu-columns-ul" id="' + this.options.id + '_column_menu_columns_ul">';
- $.each(this.gridCompColumnArr, function (i) {
- if (oThis.getString(this.options.title, '') != '') {
- htmlStr += '<li class="u-grid-column-menu-columns-li" role="menuitem" index="' + i + '">';
- htmlStr += '<div class="u-grid-column-menu-columns-div1">';
- var checkedStr = "";
- if (this.options.visible) checkedStr = ' checked';
- if (!this.options.canVisible) checkedStr += ' style="display:none;"';
- htmlStr += '<div class="u-grid-column-menu-columns-div2"><input type="checkbox" ' + checkedStr + '></div>';
- htmlStr += '<span class="u-grid-column-menu-columns-span">' + this.options.title + '</span>';
- htmlStr += '</div></li>';
- }
- });
- htmlStr += '</ul></div>';
-
- htmlStr += '</ul></div>';
-
- // 创建数据列区域
-
- return htmlStr;
- };
-
- gridCompProto.initEventFun = function () {
- // 执行原有方法
- initEventFunFun.apply(this, arguments);
- // 扩展方法
- var oThis = this;
- $('#' + this.options.id).on('mouseup', function (e) {
- if ($(e.target).closest('#' + oThis.options.id + '_header').length > 0) {
- // 点击的是header区域
- oThis.mouseUpX = e.clientX;
- oThis.mouseUpY = e.clientY;
- //点击过程中鼠标没有移动
- if (oThis.mouseDownX == oThis.mouseUpX && oThis.mouseDownY == oThis.mouseUpY) {
- //或者移动距离小于5px(由于移动之后会显示屏幕div,暂时不做处理)
- // if( Math.abs(parseInt(oThis.mouseDownX) - parseInt(oThis.mouseUpX)) <=5 && Math.abs(parseInt(oThis.mouseDownY) - parseInt(oThis.mouseUpY)) <=5){
- oThis.columnClickX = e.clientX;
- oThis.columnClickY = e.clientY;
- var eleTh = $(e.target).closest('th')[0];
- if ($(e.target).hasClass('u-grid-header-columnmenu')) {
- //点击的是columnmenu
- $('#' + oThis.options.id + '_column_menu').css('display', 'block');
-
- // 根据点击位置来显示column menu区域
- var left = e.clientX - 160;
- if (left < 0) left = 0;
- var top = e.clientY + 10;
- $('#' + oThis.options.id + '_column_menu').css('left', left);
- $('#' + oThis.options.id + '_column_menu').css('top', top);
- /*数据列多的情况下处理显示的高度*/
-
- var sX = $(window).width();
- var sH = $(window).height();
-
- // 如果数据列高度高于屏幕高度则数据列高度设置为屏幕高度-10;
- var columnsHeight = oThis.menuColumnsHeight;
- if (oThis.menuColumnsHeight + top + 34 > sH) {
- columnsHeight = sH - top - 34;
- $('#' + oThis.options.id + '_column_menu_columns').css('height', columnsHeight + 'px');
- } else {
- $('#' + oThis.options.id + '_column_menu_columns').css('height', '');
- }
-
- /*var left = eleTh.attrRightTotalWidth - oThis.scrollLeft + oThis.leftW + oThis.fixedWidth - 20;
- if(left + oThis.columnMenuWidth > oThis.wholeWidth)
- left = eleTh.attrRightTotalWidth - oThis.scrollLeft + oThis.leftW + oThis.fixedWidth - oThis.columnMenuWidth + 1;
- $('#' + oThis.options.id + '_column_menu').css('right',0);
- $('#' + oThis.options.id + '_column_menu').css('top',oThis.headerHeight);
- // 获取grid顶层div的位置
- var ele = $('#' + oThis.options.id)[0];
- off = u.getOffset(ele),scroll = u.getScroll(ele),
- var columnsTop = oThis.headerHeight;
- var cY = e.clientY;
- // 如果数据列高度高于屏幕高度则数据列高度设置为屏幕高度-10;
- var columnsHeight = oThis.menuColumnsHeight;
- var hh = 0;
- if((oThis.menuColumnsHeight + 74) > sH){
- columnsHeight = sH - 74;
- $('#' + oThis.options.id + '_column_menu_columns').css('height',columnsHeight + 'px');
- }else{
- $('#' + oThis.options.id + '_column_menu_columns').css('height','');
- }
- */
- oThis.ele.createColumnMenuFlag = true;
- } else {}
- }
- } else if ($(e.target).closest('#' + oThis.options.id + '_content').length > 0) {
- // 点击的是数据区域
-
- }
- });
-
- $(document).on('click', function () {
- if (oThis.columnMenuMove == false && oThis.ele.createColumnMenuFlag == false) {
- $('#' + oThis.options.id + '_column_menu', oThis.$ele).css('display', 'none');
- }
- oThis.ele.createColumnMenuFlag = false;
- });
- };
-
- gridCompProto.initGridEventFun = function () {
- // 执行原有方法
- initGridEventFunFun.apply(this, arguments);
- // 扩展方法
- var oThis = this;
- // 列头按钮显示/隐藏
- /*$('#' + this.options.id + '_header_table th').on('mousemove',function(e){
- $('.u-grid-header-columnmenu',$(this)).css('display','block');
- });
- $('#' + this.options.id + '_header_table th').on('mouseout',function(e){
- $('.u-grid-header-columnmenu',$(this)).css('display','none');
- });*/
-
- /*header 按钮处理开始*/
- // column按钮
- $('#' + this.options.id + '_column_menu_ul').on('mousemove', function (e) {
- oThis.columnMenuMove = true;
- });
- $('#' + this.options.id + '_column_menu_ul').on('mouseout', function (e) {
- oThis.columnMenuMove = false;
- });
-
- // 显示/隐藏列按钮
- /*$('#' + this.options.id + '_showColumn').on('mousemove', function(e) {
- //待完善 考虑屏幕高度决定columnMenu显示形式
- if(oThis.hideMenuColumns)
- clearTimeout(oThis.hideMenuColumns);
- if($('#' + oThis.options.id + '_column_menu_columns').css('display') == 'block')
- return;
- var sX = $(window).width();
- var sH = $(window).height();
- var menuLeft = $('#' + oThis.options.id + '_column_menu').css('left');
- var columnsLeft = parseInt(menuLeft) + oThis.columnMenuWidth;
- var maxLeft = oThis.columnClickX + oThis.columnMenuWidth * 2;
- if(maxLeft > sX)
- columnsLeft = parseInt(menuLeft) - oThis.columnMenuWidth;
- $('#' + oThis.options.id + '_column_menu_columns').css('left',columnsLeft);
- var columnsTop = oThis.headerHeight;
- var cY = e.clientY;
- // 如果数据列高度高于屏幕高度则数据列高度设置为屏幕高度-10;
- var columnsHeight = oThis.menuColumnsHeight;
- var hh = 0;
- if((oThis.menuColumnsHeight + 30) > sH){
- columnsHeight = sH - 30;
- $('#' + oThis.options.id + '_column_menu_columns').css('height',columnsHeight + 'px');
- }else{
- $('#' + oThis.options.id + '_column_menu_columns').css('height','');
- }
- var maxHeight = cY + columnsHeight;
- if(maxHeight > sH)
- columnsTop = (cY - (sH - columnsHeight)) * -1 + 30;
- $('#' + oThis.options.id + '_column_menu_columns').css('top',columnsTop);
- $('#' + oThis.options.id + '_column_menu_columns').css('display','block');
- oThis.columnMenuMove = true;
- });
- $('#' + this.options.id + '_showColumn').on('mouseout', function(e) {
- oThis.hideMenuColumns = setTimeout(function(){
- $('#' + oThis.options.id + '_column_menu_columns').css('display','none');
- oThis.columnMenuMove = false;
- },200);
- });*/
- /*$('#' + this.options.id + '_column_menu_columns').on('mousemove', function(e) {
- if(oThis.hideMenuColumns)
- clearTimeout(oThis.hideMenuColumns);
- $('#' + oThis.options.id + '_column_menu_columns').css('display','block');
- oThis.columnMenuMove = true;
- });
- $('#' + this.options.id + '_column_menu_columns').on('mouseout', function(e) {
- oThis.hideMenuColumns = setTimeout(function(){
- $('#' + oThis.options.id + '_column_menu_columns').css('display','none');
- oThis.columnMenuMove = false;
- },200);
- });*/
-
- // 清除设置按钮
- $('#' + this.options.id + '_clearSet').on('click', function (e) {
- oThis.clearLocalData();
- oThis.initGridCompColumn();
- // 清除排序
- oThis.dataSourceObj.sortRows();
- oThis.repaintGridDivs();
- if (typeof oThis.options.onClearSetFun == 'function') {
- oThis.options.onClearSetFun(oThis);
- }
- });
- // 显示/隐藏列 对应所有列的点击处理
- $('#' + this.options.id + '_column_menu_columns_ul li input').on('click', function (e) {
- //待完善 优化与li的click的代码整合
- var index = $(this).closest('li').attr('index');
-
- if (oThis.gridCompColumnArr[index].options.visible) {
- $(this)[0].checked = false;
- var ll = $('input:checked', $('#' + oThis.options.id + '_column_menu_columns_ul')).length;
- if (ll == 0) {
- $(this)[0].checked = true;
- return;
- }
-
- if (document.documentMode == 8) {
- var oldScrollTop = $('#' + oThis.options.id + '_column_menu_columns')[0].scrollTop;
- var oldTop = $('#' + oThis.options.id + '_column_menu_columns')[0].style.top;
- oThis.gridCompColumnArr[index].options.visible = false;
- oThis.repaintGridDivs();
- $('#' + oThis.options.id + '_column_menu').css('display', 'block');
- $('#' + oThis.options.id + '_column_menu').css('right', '0px');
- $('#' + oThis.options.id + '_column_menu').css('top', oldTop);
- $('#' + oThis.options.id + '_column_menu_columns')[0].scrollTop = oldScrollTop;
- } else {
- oThis.setColumnVisibleByIndex(index, false);
- oThis.gridCompColumnArr[index].options.visible = false;
- }
- } else {
- $(this)[0].checked = true;
-
- if (document.documentMode == 8) {
- var oldScrollTop = $('#' + oThis.options.id + '_column_menu_columns')[0].scrollTop;
- var oldTop = $('#' + oThis.options.id + '_column_menu_columns')[0].style.top;
- oThis.gridCompColumnArr[index].options.visible = true;
- oThis.repaintGridDivs();
- $('#' + oThis.options.id + '_column_menu').css('display', 'block');
- $('#' + oThis.options.id + '_column_menu').css('right', '0px');
- $('#' + oThis.options.id + '_column_menu').css('top', oldTop);
- $('#' + oThis.options.id + '_column_menu_columns')[0].scrollTop = oldScrollTop;
- } else {
- oThis.setColumnVisibleByIndex(index, true);
- oThis.gridCompColumnArr[index].options.visible = true;
- }
- }
- oThis.saveGridCompColumnArrToLocal();
- e.stopPropagation();
- });
- $('#' + this.options.id + '_column_menu_columns_ul li').on('click', function (e) {
- var index = $(this).attr('index');
- var gridCompColumn = oThis.gridCompColumnArr[index];
- if (!gridCompColumn.options.canVisible) {
- return false;
- }
- //获取选中列数量,不能小于1
- if (gridCompColumn.options.visible) {
- $('input', $(this))[0].checked = false;
- var ll = $('input:checked', $('#' + oThis.options.id + '_column_menu_columns_ul')).length;
- if (ll == 0) {
- $('input', $(this))[0].checked = true;
- return;
- }
- oThis.setColumnVisibleByIndex(index, false);
- oThis.gridCompColumnArr[index].options.visible = false;
- } else {
- $('input', $(this))[0].checked = true;
- oThis.setColumnVisibleByIndex(index, true);
- oThis.gridCompColumnArr[index].options.visible = true;
- }
- oThis.saveGridCompColumnArrToLocal();
- });
- /*header 按钮处理结束*/
- };
- if (typeof gridCompProto.saveGridCompColumnArrToLocal == 'undefined') {
- gridCompProto.saveGridCompColumnArrToLocal = function () {};
- }
- if (typeof gridCompProto.clearLocalData == 'undefined') {
- gridCompProto.clearLocalData = function () {};
- }
-})(jQuery, window, document);
Oops, something went wrong.

0 comments on commit 01592de

Please sign in to comment.