14 changed files with 6401 additions and 6197 deletions
File diff suppressed because it is too large
@ -0,0 +1,293 @@ |
|||||
|
import menuButton from './menuButton'; |
||||
|
import luckysheetupdateCell from './updateCell'; |
||||
|
import { keycode } from './constant'; |
||||
|
import { |
||||
|
luckysheetMoveHighlightCell, |
||||
|
} from './sheetMove'; |
||||
|
|
||||
|
import insertFormula from './insertFormula'; |
||||
|
import { |
||||
|
rowLocation, |
||||
|
colLocation, |
||||
|
mouseposition |
||||
|
} from '../global/location'; |
||||
|
import { isEditMode } from '../global/validate'; |
||||
|
import formula from '../global/formula'; |
||||
|
import tooltip from '../global/tooltip'; |
||||
|
import locale from '../locale/locale'; |
||||
|
import Store from '../store'; |
||||
|
|
||||
|
export function formulaBarInitial(){ |
||||
|
//公式栏处理
|
||||
|
|
||||
|
const _locale = locale(); |
||||
|
const locale_formula= _locale.formula; |
||||
|
|
||||
|
$("#luckysheet-functionbox-cell").focus(function () { |
||||
|
if(isEditMode()){//此模式下禁用公式栏
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if(Store.luckysheet_select_save.length > 0){ |
||||
|
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; |
||||
|
|
||||
|
let row_index = last["row_focus"], col_index = last["column_focus"]; |
||||
|
let row = Store.visibledatarow[row_index], |
||||
|
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; |
||||
|
let col = Store.visibledatacolumn[col_index], |
||||
|
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; |
||||
|
|
||||
|
let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index); |
||||
|
if(!!margeset){ |
||||
|
row = margeset.row[1]; |
||||
|
row_pre = margeset.row[0]; |
||||
|
row_index = margeset.row[2]; |
||||
|
col = margeset.column[1]; |
||||
|
col_pre = margeset.column[0]; |
||||
|
col_index = margeset.column[2]; |
||||
|
} |
||||
|
|
||||
|
luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata, null, true); |
||||
|
formula.rangeResizeTo = $("#luckysheet-functionbox-cell"); |
||||
|
} |
||||
|
}).keydown(function (event) { |
||||
|
if(isEditMode()){//此模式下禁用公式栏
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let ctrlKey = event.ctrlKey; |
||||
|
let altKey = event.altKey; |
||||
|
let shiftKey = event.shiftKey; |
||||
|
let kcode = event.keyCode; |
||||
|
let $inputbox = $("#luckysheet-input-box"); |
||||
|
|
||||
|
if (kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0) { |
||||
|
if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { |
||||
|
formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); |
||||
|
} |
||||
|
else { |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
Store.luckysheet_select_save = [{ "row": [Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[0]], "column": [Store.luckysheetCellUpdate[1], Store.luckysheetCellUpdate[1]], "row_focus": Store.luckysheetCellUpdate[0], "column_focus": Store.luckysheetCellUpdate[1] }]; |
||||
|
luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); |
||||
|
$("#luckysheet-functionbox-cell").blur(); |
||||
|
} |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.ESC && parseInt($inputbox.css("top")) > 0) { |
||||
|
formula.dontupdate(); |
||||
|
luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.F4 && parseInt($inputbox.css("top")) > 0) { |
||||
|
formula.setfreezonFuc(event); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.UP && parseInt($inputbox.css("top")) > 0) { |
||||
|
if ($("#luckysheet-formula-search-c").is(":visible")) { |
||||
|
let $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").prev(); |
||||
|
if ($up.length == 0) { |
||||
|
$up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").last(); |
||||
|
} |
||||
|
$("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").removeClass("luckysheet-formula-search-item-active"); |
||||
|
$up.addClass("luckysheet-formula-search-item-active"); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
} |
||||
|
else if (kcode == keycode.DOWN && parseInt($inputbox.css("top")) > 0) { |
||||
|
if ($("#luckysheet-formula-search-c").is(":visible")) { |
||||
|
let $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").next(); |
||||
|
if ($up.length == 0) { |
||||
|
$up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").first(); |
||||
|
} |
||||
|
$("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").removeClass("luckysheet-formula-search-item-active"); |
||||
|
$up.addClass("luckysheet-formula-search-item-active"); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
} |
||||
|
else if (kcode == keycode.LEFT && parseInt($inputbox.css("top")) > 0) { |
||||
|
formula.rangeHightlightselected($("#luckysheet-functionbox-cell")); |
||||
|
} |
||||
|
else if (kcode == keycode.RIGHT && parseInt($inputbox.css("top")) > 0) { |
||||
|
formula.rangeHightlightselected($("#luckysheet-functionbox-cell")); |
||||
|
} |
||||
|
else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40))) || kcode == 8 || kcode == 32 || kcode == 46 || (event.ctrlKey && kcode == 86)) { |
||||
|
formula.functionInputHanddler($("#luckysheet-rich-text-editor"), $("#luckysheet-functionbox-cell"), kcode); |
||||
|
} |
||||
|
}).click(function () { |
||||
|
if(isEditMode()){//此模式下禁用公式栏
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
formula.rangeHightlightselected($("#luckysheet-functionbox-cell")); |
||||
|
}); |
||||
|
|
||||
|
//公式栏 取消(X)按钮
|
||||
|
$("#luckysheet-wa-functionbox-cancel").click(function () { |
||||
|
if (!$(this).hasClass("luckysheet-wa-calculate-active")) { |
||||
|
return; |
||||
|
} |
||||
|
//若有参数弹出框,隐藏
|
||||
|
if($("#luckysheet-search-formula-parm").is(":visible")){ |
||||
|
$("#luckysheet-search-formula-parm").hide(); |
||||
|
} |
||||
|
//若有参数选取范围弹出框,隐藏
|
||||
|
if($("#luckysheet-search-formula-parm-select").is(":visible")){ |
||||
|
$("#luckysheet-search-formula-parm-select").hide(); |
||||
|
} |
||||
|
|
||||
|
formula.dontupdate(); |
||||
|
luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); |
||||
|
}); |
||||
|
|
||||
|
//公式栏 确认()按钮
|
||||
|
$("#luckysheet-wa-functionbox-confirm").click(function () { |
||||
|
if (!$(this).hasClass("luckysheet-wa-calculate-active")) { |
||||
|
return; |
||||
|
} |
||||
|
//若有参数弹出框,隐藏
|
||||
|
if($("#luckysheet-search-formula-parm").is(":visible")){ |
||||
|
$("#luckysheet-search-formula-parm").hide(); |
||||
|
} |
||||
|
//若有参数选取范围弹出框,隐藏
|
||||
|
if($("#luckysheet-search-formula-parm-select").is(":visible")){ |
||||
|
$("#luckysheet-search-formula-parm-select").hide(); |
||||
|
} |
||||
|
|
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); |
||||
|
}); |
||||
|
|
||||
|
//公式栏 fx按钮
|
||||
|
$("#luckysheet-wa-functionbox-fx").click(function () { |
||||
|
//点击函数查找弹出框
|
||||
|
if(Store.luckysheet_select_save.length == 0){ |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_formula.tipSelectCell); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info(locale_formula.tipSelectCell,""); |
||||
|
} |
||||
|
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; |
||||
|
|
||||
|
let row_index = last["row_focus"], col_index = last["column_focus"]; |
||||
|
let row = Store.visibledatarow[row_index], |
||||
|
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; |
||||
|
let col = Store.visibledatacolumn[col_index], |
||||
|
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; |
||||
|
|
||||
|
luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata); |
||||
|
|
||||
|
let cell = Store.flowdata[row_index][col_index]; |
||||
|
if(cell != null && cell.f != null){ |
||||
|
//单元格有计算
|
||||
|
let functionStr = formula.getfunctionParam(cell.f); |
||||
|
if(functionStr.fn != null){ |
||||
|
//有函数公式
|
||||
|
insertFormula.formulaParmDialog(functionStr.fn, functionStr.param); |
||||
|
} |
||||
|
else{ |
||||
|
//无函数公式
|
||||
|
insertFormula.formulaListDialog(); |
||||
|
} |
||||
|
} |
||||
|
else{ |
||||
|
//单元格无计算
|
||||
|
$("#luckysheet-rich-text-editor").html('<span dir="auto" class="luckysheet-formula-text-color">=</span>'); |
||||
|
$("#luckysheet-functionbox-cell").html($("#luckysheet-rich-text-editor").html()); |
||||
|
insertFormula.formulaListDialog(); |
||||
|
} |
||||
|
|
||||
|
insertFormula.init(); |
||||
|
}); |
||||
|
|
||||
|
//公式选区操作
|
||||
|
$("#luckysheet-formula-functionrange").on("mousedown", ".luckysheet-copy", function (event) { |
||||
|
formula.rangeMove = true; |
||||
|
Store.luckysheet_scroll_status = true; |
||||
|
formula.rangeMoveObj = $(this).parent(); |
||||
|
formula.rangeMoveIndex = $(this).parent().attr("rangeindex"); |
||||
|
|
||||
|
let mouse = mouseposition(event.pageX, event.pageY); |
||||
|
let x = mouse[0] + $("#luckysheet-cell-main").scrollLeft(); |
||||
|
let y = mouse[1] + $("#luckysheet-cell-main").scrollTop(); |
||||
|
$("#luckysheet-formula-functionrange-highlight-" + formula.rangeMoveIndex).find(".luckysheet-selection-copy-hc").css("opacity", 0.13); |
||||
|
|
||||
|
let type = $(this).data("type"); |
||||
|
if (type == "top") { |
||||
|
y += 3; |
||||
|
} |
||||
|
else if (type == "right") { |
||||
|
x -= 3; |
||||
|
} |
||||
|
else if (type == "bottom") { |
||||
|
y -= 3; |
||||
|
} |
||||
|
else if (type == "left") { |
||||
|
x += 3; |
||||
|
} |
||||
|
|
||||
|
let row_index = rowLocation(y)[2]; |
||||
|
let col_index = colLocation(x)[2]; |
||||
|
|
||||
|
formula.rangeMovexy = [row_index, col_index]; |
||||
|
$("#luckysheet-sheettable").css("cursor", "move"); |
||||
|
event.stopPropagation(); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheet-formula-functionrange").on("mousedown", ".luckysheet-highlight", function (e) { |
||||
|
formula.rangeResize = $(this).data("type");//开始状态resize
|
||||
|
formula.rangeResizeIndex = $(this).parent().attr("rangeindex"); |
||||
|
|
||||
|
let mouse = mouseposition(e.pageX, e.pageY), |
||||
|
scrollLeft = $("#luckysheet-cell-main").scrollLeft(), |
||||
|
scrollTop = $("#luckysheet-cell-main").scrollTop(); |
||||
|
let x = mouse[0] + scrollLeft; |
||||
|
let y = mouse[1] + scrollTop; |
||||
|
formula.rangeResizeObj = $(this).parent(); |
||||
|
$("#luckysheet-formula-functionrange-highlight-" + formula.rangeResizeIndex).find(".luckysheet-selection-copy-hc").css("opacity", 0.13); |
||||
|
|
||||
|
if (formula.rangeResize == "lt") { |
||||
|
x += 3; |
||||
|
y += 3; |
||||
|
} |
||||
|
else if (formula.rangeResize == "lb") { |
||||
|
x += 3; |
||||
|
y -= 3; |
||||
|
} |
||||
|
else if (formula.rangeResize == "rt") { |
||||
|
x -= 3; |
||||
|
y += 3; |
||||
|
} |
||||
|
else if (formula.rangeResize == "rb") { |
||||
|
x -= 3; |
||||
|
y -= 3; |
||||
|
} |
||||
|
|
||||
|
let row_location = rowLocation(y), |
||||
|
row = row_location[1], |
||||
|
row_pre = row_location[0], |
||||
|
row_index = row_location[2]; |
||||
|
let col_location = colLocation(x), |
||||
|
col = col_location[1], |
||||
|
col_pre = col_location[0], |
||||
|
col_index = col_location[2]; |
||||
|
|
||||
|
let position = formula.rangeResizeObj.position(); |
||||
|
formula.rangeResizexy = [ |
||||
|
col_pre, |
||||
|
row_pre, |
||||
|
formula.rangeResizeObj.width(), |
||||
|
formula.rangeResizeObj.height(), |
||||
|
position.left + scrollLeft, |
||||
|
position.top + scrollTop, col, row |
||||
|
]; |
||||
|
formula.rangeResizeWinH = $("#luckysheet-cell-main")[0].scrollHeight; |
||||
|
formula.rangeResizeWinW = $("#luckysheet-cell-main")[0].scrollWidth; |
||||
|
Store.luckysheet_scroll_status = true; |
||||
|
event.stopPropagation(); |
||||
|
}); |
||||
|
} |
||||
File diff suppressed because it is too large
@ -0,0 +1,917 @@ |
|||||
|
import luckysheetConfigsetting from './luckysheetConfigsetting'; |
||||
|
import menuButton from './menuButton'; |
||||
|
import conditionformat from './conditionformat'; |
||||
|
import server from './server'; |
||||
|
import luckysheetupdateCell from './updateCell'; |
||||
|
import { keycode } from './constant'; |
||||
|
import { |
||||
|
luckysheetMoveHighlightCell, |
||||
|
luckysheetMoveHighlightCell2, |
||||
|
luckysheetMoveHighlightRange, |
||||
|
luckysheetMoveHighlightRange2 |
||||
|
} from './sheetMove'; |
||||
|
import { selectHightlightShow, selectIsOverlap } from './select'; |
||||
|
import selection from './selection'; |
||||
|
import searchReplace from './searchReplace'; |
||||
|
import controlHistory from './controlHistory'; |
||||
|
|
||||
|
import { |
||||
|
getByteLen, |
||||
|
luckysheetactiveCell, |
||||
|
} from '../utils/util'; |
||||
|
import { getSheetIndex } from '../methods/get'; |
||||
|
import { hasPartMC, isEditMode } from '../global/validate'; |
||||
|
import formula from '../global/formula'; |
||||
|
import cleargridelement from '../global/cleargridelement'; |
||||
|
import tooltip from '../global/tooltip'; |
||||
|
import locale from '../locale/locale'; |
||||
|
import Store from '../store'; |
||||
|
|
||||
|
|
||||
|
let luckysheet_shiftkeydown = false; |
||||
|
|
||||
|
function formulaMoveEvent(dir, ctrlKey, shiftKey){ |
||||
|
if ($("#luckysheet-formula-search-c").is(":visible")) { |
||||
|
let $up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active").next(); |
||||
|
if ($up.length == 0) { |
||||
|
$up = $("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").first(); |
||||
|
} |
||||
|
|
||||
|
$("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item").removeClass("luckysheet-formula-search-item-active"); |
||||
|
$up.addClass("luckysheet-formula-search-item-active"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else{ |
||||
|
if($("#luckysheet-formula-functionrange-select").is(":visible")){ |
||||
|
if(ctrlKey && shiftKey){ |
||||
|
luckysheetMoveHighlightRange2(dir, "rangeOfFormula"); |
||||
|
} |
||||
|
else if(ctrlKey){ |
||||
|
luckysheetMoveHighlightCell2(dir, "rangeOfFormula"); |
||||
|
} |
||||
|
else if(shiftKey){ |
||||
|
let dir_n = dir, step = 1; |
||||
|
if(dir == 'up'){ |
||||
|
dir_n = 'down'; |
||||
|
step = -1; |
||||
|
} |
||||
|
if(dir == 'left'){ |
||||
|
dir_n = 'right'; |
||||
|
step = -1; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightRange(dir_n, step, "rangeOfFormula"); |
||||
|
} |
||||
|
else{ |
||||
|
let dir_n = dir, step = 1; |
||||
|
if(dir == 'up'){ |
||||
|
dir_n = 'down'; |
||||
|
step = -1; |
||||
|
} |
||||
|
if(dir == 'left'){ |
||||
|
dir_n = 'right'; |
||||
|
step = -1; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightCell(dir_n, step, "rangeOfFormula"); |
||||
|
} |
||||
|
} |
||||
|
else if(formula.israngeseleciton()){ |
||||
|
let anchor = $(window.getSelection().anchorNode); |
||||
|
|
||||
|
if(anchor.parent().next().text() == null || anchor.parent().next().text() == ""){ |
||||
|
let vText = $("#luckysheet-input-box #luckysheet-input-box-index").text(); |
||||
|
let range = formula.getcellrange(vText); |
||||
|
|
||||
|
if(range == null){ |
||||
|
range = formula.getcellrange($("#luckysheet-input-box-index").text()); |
||||
|
} |
||||
|
|
||||
|
let r1 = range["row"][0], r2 = range["row"][1]; |
||||
|
let c1 = range["column"][0], c2 = range["column"][1]; |
||||
|
|
||||
|
let row = Store.visibledatarow[r2], |
||||
|
row_pre = r1 - 1 == -1 ? 0 : Store.visibledatarow[r1 - 1]; |
||||
|
let col = Store.visibledatacolumn[c2], |
||||
|
col_pre = c1 - 1 == -1 ? 0 : Store.visibledatacolumn[c1 - 1]; |
||||
|
|
||||
|
formula.func_selectedrange = { |
||||
|
"left": col_pre, |
||||
|
"width": col - col_pre - 1, |
||||
|
"top": row_pre, |
||||
|
"height": row - row_pre - 1, |
||||
|
"left_move": col_pre, |
||||
|
"width_move": col - col_pre - 1, |
||||
|
"top_move": row_pre, |
||||
|
"height_move": row - row_pre - 1, |
||||
|
"row": [r1, r2], |
||||
|
"column": [c1, c2], |
||||
|
"row_focus": r1, |
||||
|
"column_focus": c1 |
||||
|
}; |
||||
|
|
||||
|
formula.rangeSetValue({ "row": [r1, r2], "column": [c1, c2] }); |
||||
|
|
||||
|
formula.rangestart = true; |
||||
|
formula.rangedrag_column_start = false; |
||||
|
formula.rangedrag_row_start = false; |
||||
|
|
||||
|
if(ctrlKey && shiftKey){ |
||||
|
luckysheetMoveHighlightRange2(dir, "rangeOfFormula"); |
||||
|
} |
||||
|
else if(ctrlKey){ |
||||
|
luckysheetMoveHighlightCell2(dir, "rangeOfFormula"); |
||||
|
} |
||||
|
else if(shiftKey){ |
||||
|
let dir_n = dir, step = 1; |
||||
|
if(dir == 'up'){ |
||||
|
dir_n = 'down'; |
||||
|
step = -1; |
||||
|
} |
||||
|
if(dir == 'left'){ |
||||
|
dir_n = 'right'; |
||||
|
step = -1; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightRange(dir_n, step, "rangeOfFormula"); |
||||
|
} |
||||
|
else{ |
||||
|
let dir_n = dir, step = 1; |
||||
|
if(dir == 'up'){ |
||||
|
dir_n = 'down'; |
||||
|
step = -1; |
||||
|
} |
||||
|
if(dir == 'left'){ |
||||
|
dir_n = 'right'; |
||||
|
step = -1; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightCell(dir_n, step, "rangeOfFormula"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
else if(!ctrlKey && !shiftKey){ |
||||
|
let anchor = $(window.getSelection().anchorNode); |
||||
|
let anchorOffset = window.getSelection().anchorOffset; |
||||
|
|
||||
|
if(dir == 'up'){ |
||||
|
if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
} |
||||
|
else if(dir == 'down'){ |
||||
|
if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
} |
||||
|
else if(dir == 'left'){ |
||||
|
if(anchor.parent().is("span") && anchor.parent().prev().length == 0 && anchorOffset == 0){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if(anchor.is("#luckysheet-rich-text-editor") && anchorOffset == 1){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchorOffset == 0){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
} |
||||
|
else if(dir == 'right'){ |
||||
|
if(anchor.parent().is("span") && anchor.parent().next().length == 0 && anchorOffset > 0){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if(anchor.is("#luckysheet-rich-text-editor") && anchor.context.childElementCount == anchorOffset){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if(anchor.parent().is("#luckysheet-rich-text-editor") && anchor.context.length == anchorOffset){ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export function keyboardInitial(){ |
||||
|
const _locale = locale(); |
||||
|
const locale_drag = _locale.drag; |
||||
|
|
||||
|
//单元格编辑输入
|
||||
|
$("#luckysheet-input-box").click(function () { |
||||
|
formula.rangeHightlightselected($("#luckysheet-rich-text-editor")); |
||||
|
}).add("#" + Store.container).on("keydown", function (event) { |
||||
|
if ($("#luckysheet-modal-dialog-mask").is(":visible") || $(event.target).hasClass("luckysheet-mousedown-cancel") || $(event.target).hasClass("formulaInputFocus")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let ctrlKey = event.ctrlKey; |
||||
|
let altKey = event.altKey; |
||||
|
let shiftKey = event.shiftKey; |
||||
|
let kcode = event.keyCode; |
||||
|
|
||||
|
if ($("#luckysheet-modal-dialog-mask").is(":visible") || $(event.target).hasClass("luckysheet-mousedown-cancel") || $(event.target).hasClass("sp-input") || (parseInt($("#luckysheet-input-box").css("top")) > 0 && $(event.target).closest(".luckysheet-input-box").length > 0 && kcode != keycode.ENTER && kcode != keycode.TAB && kcode != keycode.UP && kcode != keycode.DOWN && kcode != keycode.LEFT && kcode != keycode.RIGHT)) { |
||||
|
let anchor = $(window.getSelection().anchorNode); |
||||
|
|
||||
|
if(anchor.parent().is("#luckysheet-helpbox-cell") || anchor.is("#luckysheet-helpbox-cell")){ |
||||
|
if(kcode == keycode.ENTER){ |
||||
|
let helpboxValue = $("#luckysheet-helpbox-cell").text(); |
||||
|
|
||||
|
if(formula.iscelldata(helpboxValue)){ |
||||
|
let cellrange = formula.getcellrange(helpboxValue); |
||||
|
|
||||
|
Store.luckysheet_select_save = [{ "row": cellrange["row"], "column": cellrange["column"], "row_focus": cellrange["row"][0], "column_focus": cellrange["column"][0] }]; |
||||
|
selectHightlightShow(); |
||||
|
|
||||
|
$("#luckysheet-helpbox-cell").blur(); |
||||
|
|
||||
|
let scrollLeft = $("#luckysheet-cell-main").scrollLeft(), |
||||
|
scrollTop = $("#luckysheet-cell-main").scrollTop(); |
||||
|
let winH = $("#luckysheet-cell-main").height(), |
||||
|
winW = $("#luckysheet-cell-main").width(); |
||||
|
|
||||
|
let row = Store.visibledatarow[cellrange["row"][1]], |
||||
|
row_pre = cellrange["row"][0] - 1 == -1 ? 0 : Store.visibledatarow[cellrange["row"][0] - 1]; |
||||
|
let col = Store.visibledatacolumn[cellrange["column"][1]], |
||||
|
col_pre = cellrange["column"][0] - 1 == -1 ? 0 : Store.visibledatacolumn[cellrange["column"][0] - 1]; |
||||
|
|
||||
|
if (col - scrollLeft - winW + 20 > 0) { |
||||
|
$("#luckysheet-scrollbar-x").scrollLeft(col - winW + 20); |
||||
|
} |
||||
|
else if (col_pre - scrollLeft - 20 < 0) { |
||||
|
$("#luckysheet-scrollbar-x").scrollLeft(col_pre - 20); |
||||
|
} |
||||
|
|
||||
|
if (row - scrollTop - winH + 20 > 0) { |
||||
|
$("#luckysheet-scrollbar-y").scrollTop(row - winH + 20); |
||||
|
} |
||||
|
else if (row_pre - scrollTop - 20 < 0) { |
||||
|
$("#luckysheet-scrollbar-y").scrollTop(row_pre - 20); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let $inputbox = $("#luckysheet-input-box"); |
||||
|
|
||||
|
if (kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0) { |
||||
|
if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { |
||||
|
formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); |
||||
|
} |
||||
|
else { |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
Store.luckysheet_select_save = [{ |
||||
|
"row": [Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[0]], |
||||
|
"column": [Store.luckysheetCellUpdate[1], Store.luckysheetCellUpdate[1]], |
||||
|
"row_focus": Store.luckysheetCellUpdate[0], |
||||
|
"column_focus": Store.luckysheetCellUpdate[1] |
||||
|
}]; |
||||
|
luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); |
||||
|
} |
||||
|
|
||||
|
//若有参数弹出框,隐藏
|
||||
|
if($("#luckysheet-search-formula-parm").is(":visible")){ |
||||
|
$("#luckysheet-search-formula-parm").hide(); |
||||
|
} |
||||
|
//若有参数选取范围弹出框,隐藏
|
||||
|
if($("#luckysheet-search-formula-parm-select").is(":visible")){ |
||||
|
$("#luckysheet-search-formula-parm-select").hide(); |
||||
|
} |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.TAB) { |
||||
|
if (parseInt($inputbox.css("top")) > 0) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if(kcode == keycode.F2){ |
||||
|
if (parseInt($inputbox.css("top")) > 0) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; |
||||
|
|
||||
|
let row_index = last["row_focus"], col_index = last["column_focus"]; |
||||
|
let row = Store.visibledatarow[row_index], |
||||
|
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; |
||||
|
let col = Store.visibledatacolumn[col_index], |
||||
|
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; |
||||
|
|
||||
|
luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.F4 && parseInt($inputbox.css("top")) > 0) { |
||||
|
formula.setfreezonFuc(event); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.ESC && parseInt($inputbox.css("top")) > 0) { |
||||
|
formula.dontupdate(); |
||||
|
luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.ENTER) { |
||||
|
if($(event.target).hasClass("formulaInputFocus") || $("#luckysheet-conditionformat-dialog").is(":visible")){ |
||||
|
return; |
||||
|
} |
||||
|
else if (String.fromCharCode(kcode) != null && $("#luckysheet-cell-selected").is(":visible")) { |
||||
|
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; |
||||
|
|
||||
|
let row_index = last["row_focus"], col_index = last["column_focus"]; |
||||
|
let row = Store.visibledatarow[row_index], |
||||
|
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; |
||||
|
let col = Store.visibledatacolumn[col_index], |
||||
|
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; |
||||
|
|
||||
|
let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index); |
||||
|
if(!!margeset){ |
||||
|
row = margeset.row[1]; |
||||
|
row_pre = margeset.row[0]; |
||||
|
row_index = margeset.row[2]; |
||||
|
col = margeset.column[1]; |
||||
|
col_pre = margeset.column[0]; |
||||
|
col_index = margeset.column[2]; |
||||
|
} |
||||
|
|
||||
|
luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
} |
||||
|
else { |
||||
|
if (ctrlKey || event.metaKey) { |
||||
|
if (shiftKey) { |
||||
|
if (!luckysheet_shiftkeydown) { |
||||
|
Store.luckysheet_shiftpositon = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); |
||||
|
Store.luckysheet_shiftkeydown = true; |
||||
|
} |
||||
|
|
||||
|
//Ctrl + shift + 方向键 调整选区
|
||||
|
if (kcode == keycode.UP) { |
||||
|
if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightRange2("up", "rangeOfSelect"); |
||||
|
} |
||||
|
else if (kcode == keycode.DOWN) { |
||||
|
if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightRange2("down", "rangeOfSelect"); |
||||
|
} |
||||
|
else if (kcode == keycode.LEFT) { |
||||
|
if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightRange2("left", "rangeOfSelect"); |
||||
|
} |
||||
|
else if (kcode == keycode.RIGHT) { |
||||
|
if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightRange2("right", "rangeOfSelect"); |
||||
|
} |
||||
|
} |
||||
|
else if (kcode == 66) {//Ctrl + B 加粗
|
||||
|
$("#luckysheet-icon-bold").click(); |
||||
|
} |
||||
|
else if (kcode == 67) {//Ctrl + C 复制
|
||||
|
//复制时存在格式刷状态,取消格式刷
|
||||
|
if(menuButton.luckysheetPaintModelOn){ |
||||
|
menuButton.cancelPaintModel(); |
||||
|
} |
||||
|
|
||||
|
if(Store.luckysheet_select_save.length == 0){ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
//复制范围内包含部分合并单元格,提示
|
||||
|
if(Store.config["merge"] != null){ |
||||
|
let has_PartMC = false; |
||||
|
|
||||
|
for(let s = 0; s < Store.luckysheet_select_save.length; s++){ |
||||
|
let r1 = Store.luckysheet_select_save[s].row[0], |
||||
|
r2 = Store.luckysheet_select_save[s].row[1]; |
||||
|
let c1 = Store.luckysheet_select_save[s].column[0], |
||||
|
c2 = Store.luckysheet_select_save[s].column[1]; |
||||
|
|
||||
|
has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); |
||||
|
|
||||
|
if(has_PartMC){ |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if(has_PartMC){ |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_drag.noMerge); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info(locale_drag.noMerge, ""); |
||||
|
} |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//多重选区 有条件格式时 提示
|
||||
|
let cdformat = Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].luckysheet_conditionformat_save; |
||||
|
if(Store.luckysheet_select_save.length > 1 && cdformat != null && cdformat.length > 0){ |
||||
|
let hasCF = false; |
||||
|
|
||||
|
let cf_compute = conditionformat.getComputeMap(); |
||||
|
|
||||
|
label: |
||||
|
for(let s = 0; s < Store.luckysheet_select_save.length; s++){ |
||||
|
if(hasCF){ |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
let r1 = Store.luckysheet_select_save[s].row[0], |
||||
|
r2 = Store.luckysheet_select_save[s].row[1]; |
||||
|
let c1 = Store.luckysheet_select_save[s].column[0], |
||||
|
c2 = Store.luckysheet_select_save[s].column[1]; |
||||
|
|
||||
|
for(let r = r1; r <= r2; r++){ |
||||
|
for(let c = c1; c <= c2; c++){ |
||||
|
if(conditionformat.checksCF(r, c, cf_compute) != null){ |
||||
|
hasCF = true; |
||||
|
continue label; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if(hasCF){ |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_drag.noMulti); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info(locale_drag.noMulti, ""); |
||||
|
} |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//多重选区 行不一样且列不一样时 提示
|
||||
|
if(Store.luckysheet_select_save.length > 1){ |
||||
|
let isSameRow = true, |
||||
|
str_r = luckysheet_select_save[0].row[0], |
||||
|
end_r = luckysheet_select_save[0].row[1]; |
||||
|
let isSameCol = true, |
||||
|
str_c = luckysheet_select_save[0].column[0], |
||||
|
end_c = luckysheet_select_save[0].column[1]; |
||||
|
|
||||
|
for(let s = 1; s < luckysheet_select_save.length; s++){ |
||||
|
if(luckysheet_select_save[s].row[0] != str_r || luckysheet_select_save[s].row[1] != end_r){ |
||||
|
isSameRow = false; |
||||
|
} |
||||
|
if(luckysheet_select_save[s].column[0] != str_c || luckysheet_select_save[s].column[1] != end_c){ |
||||
|
isSameCol = false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if((!isSameRow && !isSameCol) || selectIsOverlap()){ |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_drag.noMulti); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info(locale_drag.noMulti, ""); |
||||
|
} |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
selection.copy(event); |
||||
|
|
||||
|
Store.luckysheet_paste_iscut = false; |
||||
|
luckysheetactiveCell(); |
||||
|
|
||||
|
event.stopPropagation(); |
||||
|
return; |
||||
|
} |
||||
|
else if (kcode == 70) {//Ctrl + F 查找
|
||||
|
searchReplace.createDialog(0); |
||||
|
searchReplace.init(); |
||||
|
|
||||
|
$("#luckysheet-search-replace #searchInput input").focus(); |
||||
|
} |
||||
|
else if (kcode == 72) {//Ctrl + H 替换
|
||||
|
searchReplace.createDialog(1); |
||||
|
searchReplace.init(); |
||||
|
|
||||
|
$("#luckysheet-search-replace #searchInput input").focus(); |
||||
|
} |
||||
|
else if (kcode == 73) {//Ctrl + I 斜体
|
||||
|
$("#luckysheet-icon-italic").click(); |
||||
|
} |
||||
|
else if (kcode == 86) {//Ctrl + V 粘贴
|
||||
|
if(isEditMode()){//此模式下禁用粘贴
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if($(event.target).hasClass("formulaInputFocus")){ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if(Store.luckysheet_select_save.length > 1){ |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_drag.noPaste); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info(locale_drag.noPaste, ""); |
||||
|
} |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
selection.isPasteAction = true; |
||||
|
luckysheetactiveCell(); |
||||
|
|
||||
|
event.stopPropagation(); |
||||
|
return; |
||||
|
} |
||||
|
else if (kcode == 88) {//Ctrl + X 剪切
|
||||
|
//复制时存在格式刷状态,取消格式刷
|
||||
|
if(menuButton.luckysheetPaintModelOn){ |
||||
|
menuButton.cancelPaintModel(); |
||||
|
} |
||||
|
|
||||
|
if(Store.luckysheet_select_save.length == 0){ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
//复制范围内包含部分合并单元格,提示
|
||||
|
if(Store.config["merge"] != null){ |
||||
|
let has_PartMC = false; |
||||
|
|
||||
|
for(let s = 0; s < Store.luckysheet_select_save.length; s++){ |
||||
|
let r1 = Store.luckysheet_select_save[s].row[0], |
||||
|
r2 = Store.luckysheet_select_save[s].row[1]; |
||||
|
let c1 = Store.luckysheet_select_save[s].column[0], |
||||
|
c2 = Store.luckysheet_select_save[s].column[1]; |
||||
|
|
||||
|
has_PartMC = hasPartMC(Store.config, r1, r2, c1, c2); |
||||
|
|
||||
|
if(has_PartMC){ |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if(has_PartMC){ |
||||
|
if(luckysheetConfigsetting.editMode){ |
||||
|
alert(_locale_drag.noMerge); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info(_locale_drag.noMerge, ""); |
||||
|
} |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//多重选区时 提示
|
||||
|
if(Store.luckysheet_select_save.length > 1){ |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_drag.noMulti); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info(locale_drag.noMulti, ""); |
||||
|
} |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
selection.copy(event); |
||||
|
|
||||
|
Store.luckysheet_paste_iscut = true; |
||||
|
luckysheetactiveCell(); |
||||
|
|
||||
|
event.stopPropagation(); |
||||
|
return; |
||||
|
} |
||||
|
else if (kcode == 90) {//Ctrl + Z 撤销
|
||||
|
controlHistory.redo(event); |
||||
|
luckysheetactiveCell(); |
||||
|
event.stopPropagation(); |
||||
|
return; |
||||
|
} |
||||
|
else if (kcode == 89) {//Ctrl + Y 重做
|
||||
|
controlHistory.undo(event); |
||||
|
luckysheetactiveCell(); |
||||
|
event.stopPropagation(); |
||||
|
return; |
||||
|
} |
||||
|
else if (kcode == keycode.UP) {//Ctrl + up 调整单元格
|
||||
|
if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightCell2("up", "rangeOfSelect"); |
||||
|
} |
||||
|
else if (kcode == keycode.DOWN) {//Ctrl + down 调整单元格
|
||||
|
if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightCell2("down", "rangeOfSelect"); |
||||
|
} |
||||
|
else if (kcode == keycode.LEFT) {//Ctrl + top 调整单元格
|
||||
|
if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightCell2("left", "rangeOfSelect"); |
||||
|
} |
||||
|
else if (kcode == keycode.RIGHT) {//Ctrl + right 调整单元格
|
||||
|
if (parseInt($inputbox.css("top")) > 0 || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightCell2("right", "rangeOfSelect"); |
||||
|
} |
||||
|
else if (String.fromCharCode(kcode).toLocaleUpperCase() == "A") {//Ctrl + A 全选
|
||||
|
$("#luckysheet-left-top").trigger("mousedown"); |
||||
|
$(document).trigger("mouseup"); |
||||
|
} |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
return; |
||||
|
} |
||||
|
else if (shiftKey && (kcode == keycode.UP || kcode == keycode.DOWN || kcode == keycode.LEFT || kcode == keycode.RIGHT || (altKey && (kcode == 53 || kcode == 101)))) { |
||||
|
if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (!luckysheet_shiftkeydown) { |
||||
|
Store.luckysheet_shiftpositon = $.extend(true, {}, Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]); |
||||
|
Store.luckysheet_shiftkeydown = true; |
||||
|
} |
||||
|
|
||||
|
//shift + 方向键 调整选区
|
||||
|
if (kcode == keycode.UP) { |
||||
|
if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightRange("down", -1, "rangeOfSelect"); |
||||
|
} |
||||
|
else if (kcode == keycode.DOWN) { |
||||
|
if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightRange("down", 1, "rangeOfSelect"); |
||||
|
} |
||||
|
else if (kcode == keycode.LEFT) { |
||||
|
if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightRange("right", -1, "rangeOfSelect"); |
||||
|
} |
||||
|
else if (kcode == keycode.RIGHT) { |
||||
|
if($("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")){ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightRange("right", 1, "rangeOfSelect"); |
||||
|
} |
||||
|
else if (altKey && (kcode == 53 || kcode == 101)) { |
||||
|
//Alt + Shift + 5(删除线)
|
||||
|
$("#luckysheet-icon-strikethrough").click(); |
||||
|
} |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.ESC) { |
||||
|
if(menuButton.luckysheetPaintModelOn){ |
||||
|
menuButton.cancelPaintModel(); |
||||
|
} |
||||
|
else{ |
||||
|
cleargridelement(event); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
|
||||
|
selectHightlightShow(); |
||||
|
} |
||||
|
else if (kcode == keycode.DELETE) { |
||||
|
$("#luckysheet-delete-text").click(); |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.UP) { |
||||
|
if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightCell("down", -1, "rangeOfSelect"); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.DOWN) { |
||||
|
if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightCell("down", 1, "rangeOfSelect"); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.LEFT) { |
||||
|
if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightCell("right", -1, "rangeOfSelect"); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.RIGHT) { |
||||
|
if (parseInt($inputbox.css("top")) > 0 || $(event.target).hasClass("formulaInputFocus") || $("#luckysheet-singleRange-dialog").is(":visible") || $("#luckysheet-multiRange-dialog").is(":visible")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40))) || kcode == 8 || kcode == 32 || kcode == 46 || kcode == 0 || (event.ctrlKey && kcode == 86)) { |
||||
|
if (String.fromCharCode(kcode) != null && $("#luckysheet-cell-selected").is(":visible") && (kcode != keycode.CAPSLOCK && kcode != keycode.WIN && kcode != 18)) { |
||||
|
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1]; |
||||
|
|
||||
|
let row_index = last["row_focus"], col_index = last["column_focus"]; |
||||
|
let row = Store.visibledatarow[row_index], |
||||
|
row_pre = row_index - 1 == -1 ? 0 : Store.visibledatarow[row_index - 1]; |
||||
|
let col = Store.visibledatacolumn[col_index], |
||||
|
col_pre = col_index - 1 == -1 ? 0 : Store.visibledatacolumn[col_index - 1]; |
||||
|
|
||||
|
let margeset = menuButton.mergeborer(Store.flowdata, row_index, col_index); |
||||
|
if(!!margeset){ |
||||
|
row = margeset.row[1]; |
||||
|
row_pre = margeset.row[0]; |
||||
|
row_index = margeset.row[2]; |
||||
|
col = margeset.column[1]; |
||||
|
col_pre = margeset.column[0]; |
||||
|
col_index = margeset.column[2]; |
||||
|
} |
||||
|
|
||||
|
luckysheetupdateCell(row, row_pre, row_index, col, col_pre, col_index, Store.flowdata, true); |
||||
|
if(kcode == 8){ |
||||
|
$("#luckysheet-rich-text-editor").html("<br/>"); |
||||
|
} |
||||
|
formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
luckysheetactiveCell(); |
||||
|
|
||||
|
event.stopPropagation(); |
||||
|
}); |
||||
|
|
||||
|
//单元格编辑 keydown (公式 上下左右键移动)
|
||||
|
$("#" + Store.container).add("#luckysheet-input-box").keydown(function (event) { |
||||
|
if ($("#luckysheet-modal-dialog-mask").is(":visible") || $(event.target).hasClass("luckysheet-mousedown-cancel") || $(event.target).hasClass("formulaInputFocus")) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let ctrlKey = event.ctrlKey; |
||||
|
let altKey = event.altKey; |
||||
|
let shiftKey = event.shiftKey; |
||||
|
let kcode = event.keyCode; |
||||
|
|
||||
|
let $inputbox = $("#luckysheet-input-box"); |
||||
|
if (kcode == keycode.ESC && parseInt($("#luckysheet-input-box").css("top")) > 0) { |
||||
|
formula.dontupdate(); |
||||
|
luckysheetMoveHighlightCell("down", 0, "rangeOfSelect"); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.ENTER && parseInt($inputbox.css("top")) > 0) { |
||||
|
if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { |
||||
|
formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
} |
||||
|
else if(kcode == keycode.TAB && parseInt($inputbox.css("top")) > 0){ |
||||
|
if ($("#luckysheet-formula-search-c").is(":visible") && formula.searchFunctionCell != null) { |
||||
|
formula.searchFunctionEnter($("#luckysheet-formula-search-c").find(".luckysheet-formula-search-item-active")); |
||||
|
} |
||||
|
else{ |
||||
|
formula.updatecell(Store.luckysheetCellUpdate[0], Store.luckysheetCellUpdate[1]); |
||||
|
luckysheetMoveHighlightCell("right", 1, "rangeOfSelect"); |
||||
|
} |
||||
|
|
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.F4 && parseInt($inputbox.css("top")) > 0) { |
||||
|
formula.setfreezonFuc(event); |
||||
|
event.preventDefault(); |
||||
|
} |
||||
|
else if (kcode == keycode.UP && parseInt($inputbox.css("top")) > 0) { |
||||
|
formulaMoveEvent("up", ctrlKey, shiftKey); |
||||
|
} |
||||
|
else if (kcode == keycode.DOWN && parseInt($inputbox.css("top")) > 0) { |
||||
|
formulaMoveEvent("down", ctrlKey, shiftKey); |
||||
|
} |
||||
|
else if (kcode == keycode.LEFT && parseInt($inputbox.css("top")) > 0) { |
||||
|
formulaMoveEvent("left", ctrlKey, shiftKey); |
||||
|
} |
||||
|
else if (kcode == keycode.RIGHT && parseInt($inputbox.css("top")) > 0) { |
||||
|
formulaMoveEvent("right", ctrlKey, shiftKey); |
||||
|
} |
||||
|
else if (!((kcode >= 112 && kcode <= 123) || kcode <= 46 || kcode == 144 || kcode == 108 || event.ctrlKey || event.altKey || (event.shiftKey && (kcode == 37 || kcode == 38 || kcode == 39 || kcode == 40))) || kcode == 8 || kcode == 32 || kcode == 46 || (event.ctrlKey && kcode == 86)) { |
||||
|
formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode); |
||||
|
} |
||||
|
}).keyup(function (e) { |
||||
|
let kcode = e.keyCode; |
||||
|
|
||||
|
if (!e.shiftKey && kcode == 16) { |
||||
|
Store.luckysheet_shiftkeydown = false; |
||||
|
Store.luckysheet_shiftpositon = null; |
||||
|
} |
||||
|
|
||||
|
//输入框中文输入后 shift 和 空格 处理
|
||||
|
if(parseInt($("#luckysheet-input-box").css("top")) > 0 && (kcode == 13 || kcode == 16 || kcode == 32)){ |
||||
|
formula.functionInputHanddler($("#luckysheet-functionbox-cell"), $("#luckysheet-rich-text-editor"), kcode); |
||||
|
} |
||||
|
|
||||
|
e.preventDefault(); |
||||
|
}); |
||||
|
|
||||
|
//top workBook rename
|
||||
|
$("#luckysheet_info_detail_input").val(server.title).css("width", getByteLen(server.title) * 10).keydown(function(){ |
||||
|
let ctrlKey = event.ctrlKey; |
||||
|
let altKey = event.altKey; |
||||
|
let shiftKey = event.shiftKey; |
||||
|
let kcode = event.keyCode; |
||||
|
let $t = $(this); |
||||
|
if(kcode == keycode.ENTER){ |
||||
|
$t.blur().change(); |
||||
|
} |
||||
|
}).bind('input propertychange', function() { |
||||
|
let $t = $(this); |
||||
|
let inputlen = getByteLen($t.val())*10; |
||||
|
let updatelen = $("#luckysheet_info_detail_update").outerWidth(); |
||||
|
let savelen = $("#luckysheet_info_detail_save").outerWidth(); |
||||
|
let userlen = $("#luckysheet_info_detail_user").parent().outerWidth()+60; |
||||
|
let containerlen = $("#" + Store.container).outerWidth(); |
||||
|
let otherlen = 100; |
||||
|
|
||||
|
let minuslen = containerlen- savelen - updatelen - userlen - otherlen; |
||||
|
if(inputlen > minuslen){ |
||||
|
$("#luckysheet_info_detail_input").css("width", minuslen); |
||||
|
} |
||||
|
else{ |
||||
|
$("#luckysheet_info_detail_input").css("width", inputlen); |
||||
|
} |
||||
|
}).change(function(){ |
||||
|
server.saveParam("na", null, $(this).val()); |
||||
|
}); |
||||
|
} |
||||
File diff suppressed because it is too large
@ -0,0 +1,273 @@ |
|||||
|
|
||||
|
import { modelHTML } from './constant'; |
||||
|
|
||||
|
import { selectHightlightShow } from './select'; |
||||
|
|
||||
|
import { |
||||
|
replaceHtml, |
||||
|
chatatABC, |
||||
|
} from '../utils/util'; |
||||
|
import { rowlenByRange } from '../global/getRowlen'; |
||||
|
import { isEditMode } from '../global/validate'; |
||||
|
import cleargridelement from '../global/cleargridelement'; |
||||
|
import { |
||||
|
jfrefreshgrid, |
||||
|
} from '../global/refresh'; |
||||
|
import { getcellvalue } from '../global/getdata'; |
||||
|
import { orderbydata, sortColumnSeletion } from '../global/sort'; |
||||
|
import tooltip from '../global/tooltip'; |
||||
|
import editor from '../global/editor'; |
||||
|
import { isdatatype } from '../global/datecontroll'; |
||||
|
import Store from '../store'; |
||||
|
import locale from '../locale/locale'; |
||||
|
|
||||
|
|
||||
|
export function orderByInitial(){ |
||||
|
const _locale = locale(); |
||||
|
//菜单栏 排序按钮
|
||||
|
$("#luckysheetorderbyasc, #luckysheetorderbyasc_t").mousedown(function (event) { |
||||
|
cleargridelement(event); |
||||
|
sortColumnSeletion(Store.orderbyindex, true); |
||||
|
selectHightlightShow(); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheetorderbydesc, #luckysheetorderbydesc_t").click(function (event) { |
||||
|
cleargridelement(event); |
||||
|
sortColumnSeletion(Store.orderbyindex, false); |
||||
|
selectHightlightShow(); |
||||
|
}); |
||||
|
|
||||
|
//排序事件
|
||||
|
let luckysheet_sort_initial = true; |
||||
|
$("#luckysheetorderby").click(function () { |
||||
|
$("body .luckysheet-cols-menu").hide(); |
||||
|
const locale_sort = _locale.sort; |
||||
|
if(Store.luckysheet_select_save.length > 1){ |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_sort.noRangeError); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info(locale_sort.noRangeError, ""); |
||||
|
} |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let last = Store.luckysheet_select_save[0]; |
||||
|
let r1 = last["row"][0], r2 = last["row"][1]; |
||||
|
let c1 = last["column"][0], c2 = last["column"][1]; |
||||
|
|
||||
|
if (luckysheet_sort_initial) { |
||||
|
luckysheet_sort_initial = false; |
||||
|
|
||||
|
let content = `<div style="overflow: hidden;" class="luckysheet-sort-modal"><div><label><input type="checkbox" id="luckysheet-sort-haveheader"/><span>${locale_sort.hasTitle}</span></label></div><div style="overflow-y:auto;" id="luckysheet-sort-dialog-tablec"><table data-itemcount="0" cellspacing="0"> <tr><td>${locale_sort.hasTitle} <select name="sort_0"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </td> <td> <div><label><input value="asc" type="radio" checked="checked" name="sort_0"><span>${locale_sort.asc}A-Z</span></label></div> <div><label><input value="desc" type="radio" name="sort_0"><span>${locale_sort.desc}Z-A</span></label></div></td></tr></table></div><div style="background: #e5e5e5;border-top: 1px solid #f5f5f5; height: 1px; width: 100%;margin:2px 0px;margin-bottom:10px;"></div> <div> <span style="font-weight: bold; text-decoration: underline;text-align:center;color: blue;cursor: pointer;" class="luckysheet-sort-dialog-additem">+ ${locale_sort.addOthers}</span> </div> </div>`; |
||||
|
|
||||
|
$("body").append(replaceHtml(modelHTML, { "id": "luckysheet-sort-dialog", "addclass": "", "title": _locale.sort.sortTitle, "content": content, "botton": `<button id="luckysheet-sort-modal-confirm" class="btn btn-primary">${locale_sort.confirm}</button><button class="btn btn-default luckysheet-model-close-btn">${locale_sort.close}</button>`})); |
||||
|
|
||||
|
$("#luckysheet-sort-dialog .luckysheet-sort-dialog-additem").click(function () { |
||||
|
let last = Store.luckysheet_select_save[0]; |
||||
|
let r1 = last["row"][0], r2 = last["row"][1]; |
||||
|
let c1 = last["column"][0], c2 = last["column"][1]; |
||||
|
|
||||
|
let option = "", i = $("#luckysheet-sort-dialog table").data("itemcount") + 1; |
||||
|
let t = $("#luckysheet-sort-haveheader").is(':checked'); |
||||
|
|
||||
|
for (let c = c1; c <= c2; c++) { |
||||
|
if (t) { |
||||
|
let v = getcellvalue(r1, c, Store.flowdata, "m"); |
||||
|
|
||||
|
if(v == null){ |
||||
|
v = locale_sort.columnOperation + (c - c1 + 1); |
||||
|
} |
||||
|
|
||||
|
option += '<option value="' + c + '">' + v + '</option>'; |
||||
|
} |
||||
|
else { |
||||
|
option += '<option value="' + c + '">' + chatatABC(c) + '</option>'; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$("#luckysheet-sort-dialog table").append(` |
||||
|
<tr class="luckysheet-sort-dialog-tr"> |
||||
|
<td><span class="luckysheet-sort-item-close" onclick="$(this).parent().parent().remove();"><i class="fa fa-times" |
||||
|
aria-hidden="true"></i></span>${locale_sort.secondaryTitle} <select |
||||
|
name="sort_${i}">${option}</select> </td> |
||||
|
<td> |
||||
|
<div><label><input value="asc" type="radio" checked="checked" |
||||
|
name="sort_${i}"><span>${locale_sort.asc}A-Z</span></label></div> |
||||
|
<div><label><input value="desc" type="radio" name="sort_${i}"><span>${locale_sort.desc}Z-A</span></label> |
||||
|
</div> |
||||
|
</td> |
||||
|
</tr> |
||||
|
`);
|
||||
|
$("#luckysheet-sort-dialog table").data("itemcount", i); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheet-sort-haveheader").change(function () { |
||||
|
let last = Store.luckysheet_select_save[0]; |
||||
|
let r1 = last["row"][0], r2 = last["row"][1]; |
||||
|
let c1 = last["column"][0], c2 = last["column"][1]; |
||||
|
|
||||
|
let t = $(this).is(':checked'); |
||||
|
let option = ""; |
||||
|
|
||||
|
for (let c = c1; c <= c2; c++) { |
||||
|
if (t) { |
||||
|
let v = getcellvalue(r1, c, Store.flowdata, "m"); |
||||
|
|
||||
|
if(v == null){ |
||||
|
v = locale_sort.columnOperation + (c - c1 + 1); |
||||
|
} |
||||
|
|
||||
|
option += '<option value="' + c + '">' + v + '</option>'; |
||||
|
} |
||||
|
else { |
||||
|
option += '<option value="' + c + '">' + chatatABC(c) + '</option>'; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$("#luckysheet-sort-dialog tr select").each(function () { |
||||
|
$(this).html(option); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
//Custom sort
|
||||
|
$("#luckysheet-sort-modal-confirm").click(function () { |
||||
|
if(Store.luckysheet_select_save.length > 1){ |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_sort.noRangeError); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info(locale_sort.noRangeError, ""); |
||||
|
} |
||||
|
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let d = editor.deepCopyFlowData(Store.flowdata); |
||||
|
|
||||
|
let last = Store.luckysheet_select_save[0]; |
||||
|
let r1 = last["row"][0], r2 = last["row"][1]; |
||||
|
let c1 = last["column"][0], c2 = last["column"][1]; |
||||
|
|
||||
|
//Data has header row
|
||||
|
let t = $("#luckysheet-sort-haveheader").is(':checked'); |
||||
|
|
||||
|
let str; |
||||
|
if(t){ |
||||
|
str = r1 + 1; |
||||
|
} |
||||
|
else{ |
||||
|
str = r1; |
||||
|
} |
||||
|
|
||||
|
let hasMc = false; //Whether the sort selection has merged cells
|
||||
|
|
||||
|
let data = []; |
||||
|
|
||||
|
for(let r = str; r <= r2; r++){ |
||||
|
let data_row = []; |
||||
|
|
||||
|
for(let c = c1; c <= c2; c++){ |
||||
|
if(d[r][c] != null && d[r][c].mc != null){ |
||||
|
hasMc = true; |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
data_row.push(d[r][c]); |
||||
|
} |
||||
|
|
||||
|
data.push(data_row); |
||||
|
} |
||||
|
|
||||
|
if(hasMc){ |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_sort.mergeError); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info(locale_sort.mergeError, ""); |
||||
|
} |
||||
|
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
$($("#luckysheet-sort-dialog table tr").toArray().reverse()).each(function () { |
||||
|
let i = $(this).find("select").val(), |
||||
|
asc = $(this).find('input:radio:checked').val(); |
||||
|
|
||||
|
i -= c1; |
||||
|
|
||||
|
if (asc == "asc") { |
||||
|
asc = true; |
||||
|
} |
||||
|
else { |
||||
|
asc = false; |
||||
|
} |
||||
|
|
||||
|
data = orderbydata([].concat(data), i, asc); |
||||
|
}); |
||||
|
|
||||
|
for(let r = str; r <= r2; r++){ |
||||
|
for(let c = c1; c <= c2; c++){ |
||||
|
d[r][c] = data[r - str][c - c1]; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if(Store.config["rowlen"] != null){ |
||||
|
let cfg = $.extend(true, {}, Store.config); |
||||
|
cfg = rowlenByRange(d, str, r2, cfg); |
||||
|
|
||||
|
jfrefreshgrid(d, [{ "row": [str, r2], "column": [c1, c2] }], cfg, null, true); |
||||
|
} |
||||
|
else{ |
||||
|
jfrefreshgrid(d, [{ "row": [str, r2], "column": [c1, c2] }]); |
||||
|
} |
||||
|
|
||||
|
$("#luckysheet-sort-dialog").hide(); |
||||
|
$("#luckysheet-modal-dialog-mask").hide(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
let option = ""; |
||||
|
for (let c = c1; c <= c2; c++) { |
||||
|
option += '<option value="' + c + '">' + chatatABC(c) + '</option>'; |
||||
|
} |
||||
|
|
||||
|
$("#luckysheet-sort-dialog select").html(option); |
||||
|
|
||||
|
$("#luckysheet-sort-dialog .luckysheet-sort-dialog-tr").remove(); |
||||
|
|
||||
|
$("#luckysheet-sort-haveheader").prop("checked", false); |
||||
|
$("#luckysheet-sort-dialog input:radio:first").prop("checked", "checked"); |
||||
|
|
||||
|
$("#luckysheet-sort-dialog .luckysheet-modal-dialog-title-text").html(locale_sort.sortRangeTitle+"<span>" + chatatABC(c1) + (r1 + 1) + "</span>"+ locale_sort.sortRangeTitleTo +"<span>" + chatatABC(c2) + (r2 + 1) + "</span>"); |
||||
|
|
||||
|
let $t = $("#luckysheet-sort-dialog"), myh = $t.outerHeight(), myw = $t.outerWidth(); |
||||
|
let winw = $(window).width(), winh = $(window).height(); |
||||
|
let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop(); |
||||
|
|
||||
|
$("#luckysheet-sort-dialog-tablec").css("max-height", (winh - myh) / 2); |
||||
|
$("#luckysheet-sort-dialog").css({ "left": (winw + scrollLeft - myw) / 2, "top": (winh + scrollTop - myh) / 2 }).show(); |
||||
|
$("#luckysheet-modal-dialog-mask").show(); |
||||
|
|
||||
|
if (r1 < r2) { |
||||
|
setTimeout(function () { |
||||
|
let flowrowdata1 = Store.flowdata[r1], |
||||
|
flowrowdata2 = Store.flowdata[r1 + 1], |
||||
|
hastitle = false; |
||||
|
|
||||
|
for (let i = c1; i <= c2; i++) { |
||||
|
let isdatatype_r1 = isdatatype(flowrowdata1[i]), |
||||
|
isdatatype_r2 = isdatatype(flowrowdata2[i]); |
||||
|
|
||||
|
if (isdatatype_r1 != isdatatype_r2) { |
||||
|
hastitle = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (hastitle) { |
||||
|
$("#luckysheet-sort-haveheader").prop("checked", true).change(); |
||||
|
} |
||||
|
}, 10); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
File diff suppressed because it is too large
@ -0,0 +1,454 @@ |
|||||
|
|
||||
|
import sheetmanage from './sheetmanage'; |
||||
|
import server from './server'; |
||||
|
import { sheetselectlistitemHTML, sheetselectlistHTML, keycode } from './constant'; |
||||
|
import { |
||||
|
replaceHtml, |
||||
|
mouseclickposition, |
||||
|
} from '../utils/util'; |
||||
|
import { getSheetIndex } from '../methods/get'; |
||||
|
import { isEditMode } from '../global/validate'; |
||||
|
import formula from '../global/formula'; |
||||
|
import cleargridelement from '../global/cleargridelement'; |
||||
|
import tooltip from '../global/tooltip'; |
||||
|
import locale from '../locale/locale'; |
||||
|
import Store from '../store'; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
//表格底部名称栏区域 相关事件(增、删、改、隐藏显示、颜色等等)
|
||||
|
let isInitialSheetConfig = false, luckysheetcurrentSheetitem = null, jfdbclicklagTimeout = null; |
||||
|
function showsheetconfigmenu() { |
||||
|
if (!isInitialSheetConfig) { |
||||
|
isInitialSheetConfig = true; |
||||
|
const _locale = locale(); |
||||
|
let locale_toolbar = _locale.toolbar; |
||||
|
$("#luckysheetsheetconfigcolorur").spectrum({ |
||||
|
showPalette: true, |
||||
|
preferredFormat: "hex", |
||||
|
clickoutFiresChange: false, |
||||
|
showInitial: true, |
||||
|
showInput: true, |
||||
|
flat: true, |
||||
|
hideAfterPaletteSelect: false, |
||||
|
showSelectionPalette: true, |
||||
|
maxPaletteSize: 10, |
||||
|
cancelText: _locale.sheetconfig.cancelText, |
||||
|
chooseText: _locale.sheetconfig.chooseText, |
||||
|
togglePaletteMoreText: locale_toolbar.toolMore, |
||||
|
togglePaletteLessText: locale_toolbar.toolLess, |
||||
|
clearText: locale_toolbar.clearText, |
||||
|
noColorSelectedText: locale_toolbar.noColorSelectedText, |
||||
|
palette: [["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)", "rgb(204, 204, 204)", "rgb(217, 217, 217)", "rgb(255, 255, 255)"], ["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"], ["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)", "rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)"], ["rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)", "rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)"], ["rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)", "rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)"], ["rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)", "rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)"], ["rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)", "rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"], ["#c1232b", "#27727b", "#fcce10", "#e87c25", "#b5c334", "#fe8463", "#9bca63", "#fad860", "#f3a43b", "#60c0dd", "#d7504b", "#c6e579", "#f4e001", "#f0805a", "#26c0c0", "#c12e34", "#e6b600", "#0098d9", "#2b821d", "#005eaa", "#339ca8", "#cda819", "#32a487", "#3fb1e3", "#6be6c1", "#626c91", "#a0a7e6", "#c4ebad", "#96dee8"]], |
||||
|
change: function (color) { |
||||
|
let $input = $(this); |
||||
|
if (color != null) { |
||||
|
color = color.toHexString(); |
||||
|
} |
||||
|
else { |
||||
|
color = "rgb(0, 0, 0)"; |
||||
|
} |
||||
|
|
||||
|
let oldcolor = null; |
||||
|
if(luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").length>0){ |
||||
|
oldcolor = luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").css("background-color"); |
||||
|
} |
||||
|
|
||||
|
luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").remove(); |
||||
|
luckysheetcurrentSheetitem.append('<div class="luckysheet-sheets-item-color" style=" position: absolute; width: 100%; height: 3px; bottom: 0px; left: 0px; background-color: ' + color + ';"></div>'); |
||||
|
let index = getSheetIndex(Store.currentSheetIndex); |
||||
|
Store.luckysheetfile[index].color = color; |
||||
|
server.saveParam("all", Store.currentSheetIndex, color, { "k": "color" }); |
||||
|
|
||||
|
if (Store.clearjfundo) { |
||||
|
let redo = {}; |
||||
|
redo["type"] = "sheetColor"; |
||||
|
redo["sheetIndex"] = Store.currentSheetIndex; |
||||
|
|
||||
|
redo["oldcolor"] = oldcolor; |
||||
|
redo["color"] = color; |
||||
|
|
||||
|
Store.jfundo = []; |
||||
|
Store.jfredo.push(redo); |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheetsheetconfigcolorreset").click(function () { |
||||
|
let oldcolor = null; |
||||
|
if(luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").length>0){ |
||||
|
oldcolor = luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").css("background-color"); |
||||
|
} |
||||
|
|
||||
|
luckysheetcurrentSheetitem.find(".luckysheet-sheets-item-color").remove(); |
||||
|
let index = getSheetIndex(Store.currentSheetIndex); |
||||
|
Store.luckysheetfile[index].color = null; |
||||
|
server.saveParam("all", Store.currentSheetIndex, null, { "k": "color" } ); |
||||
|
|
||||
|
if (Store.clearjfundo) { |
||||
|
let redo = {}; |
||||
|
redo["type"] = "sheetColor"; |
||||
|
redo["sheetIndex"] = Store.currentSheetIndex; |
||||
|
|
||||
|
redo["oldcolor"] = oldcolor; |
||||
|
redo["color"] = null; |
||||
|
|
||||
|
Store.jfundo = []; |
||||
|
Store.jfredo.push(redo); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
let index = getSheetIndex(Store.currentSheetIndex); |
||||
|
if (Store.luckysheetfile[index].color != null && Store.luckysheetfile[index].color.length > 0) { |
||||
|
$("#luckysheetsheetconfigcolorur").spectrum("set", Store.luckysheetfile[index].color); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
$("#luckysheetsheetconfigcolorur").parent().find("span, div, button, input, a").addClass("luckysheet-mousedown-cancel"); |
||||
|
setTimeout(function(){ |
||||
|
mouseclickposition($("#luckysheet-rightclick-sheet-menu"), luckysheetcurrentSheetitem.offset().left + luckysheetcurrentSheetitem.width(), luckysheetcurrentSheetitem.offset().top - 18, "leftbottom"); |
||||
|
},1); |
||||
|
} |
||||
|
|
||||
|
let luckysheetsheetrightclick = function ($t, $cur, e) { |
||||
|
clearTimeout(jfdbclicklagTimeout); |
||||
|
if ($cur.hasClass("luckysheet-sheets-item-name") && $cur.attr("contenteditable") == "true") { |
||||
|
return; |
||||
|
} |
||||
|
if (formula.rangestart || formula.rangedrag_column_start || formula.rangedrag_row_start || formula.israngeseleciton()) { |
||||
|
setTimeout(function () { |
||||
|
formula.setCaretPosition(formula.rangeSetValueTo.get(0), 0, formula.rangeSetValueTo.text().length); |
||||
|
formula.createRangeHightlight(); |
||||
|
$("#luckysheet-input-box-index").find(".luckysheet-input-box-index-sheettxt").remove().end().prepend("<span class='luckysheet-input-box-index-sheettxt'>" + sheetmanage.getSheetName(formula.rangetosheet) + "!</span>").show(); |
||||
|
$("#luckysheet-input-box-index").css({"left": $("#luckysheet-input-box").css("left"), "top": (parseInt($("#luckysheet-input-box").css("top")) - 20) + "px", "z-index": $("#luckysheet-input-box").css("z-index")}); |
||||
|
}, 1); |
||||
|
} |
||||
|
else { |
||||
|
$("#luckysheet-input-box").removeAttr("style"); |
||||
|
$("#luckysheet-formula-functionrange .luckysheet-formula-functionrange-highlight").remove(); |
||||
|
} |
||||
|
|
||||
|
$("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active"); |
||||
|
$t.addClass("luckysheet-sheets-item-active"); |
||||
|
cleargridelement(e); |
||||
|
sheetmanage.changeSheet($t.data("index")); |
||||
|
|
||||
|
$("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); |
||||
|
|
||||
|
if ($cur.hasClass("luckysheet-sheets-item-menu") || $cur.hasClass("fa-sort-desc") || e.which == "3") { |
||||
|
luckysheetcurrentSheetitem = $cur.closest(".luckysheet-sheets-item"); |
||||
|
showsheetconfigmenu(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
export function initialSheetBar(){ |
||||
|
const _locale = locale(); |
||||
|
const locale_sheetconfig = _locale.sheetconfig; |
||||
|
|
||||
|
$("#luckysheet-sheet-area").on("mousedown", "div.luckysheet-sheets-item", function (e) { |
||||
|
if(isEditMode()){ |
||||
|
// alert("非编辑模式下不允许该操作!");
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let $t = $(this), $cur = $(e.target), $item = $cur.closest(".luckysheet-sheets-item"); |
||||
|
|
||||
|
if (e.which == "3") { |
||||
|
luckysheetsheetrightclick($t, $cur, e); |
||||
|
luckysheetcurrentSheetitem = $item; |
||||
|
showsheetconfigmenu(); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if ($item.hasClass("luckysheet-sheets-item-active") && $item.find(".luckysheet-sheets-item-name").attr("contenteditable") == "false") { |
||||
|
jfdbclicklagTimeout = setTimeout(function () { |
||||
|
Store.luckysheet_sheet_move_status = true; |
||||
|
Store.luckysheet_sheet_move_data = {}; |
||||
|
Store.luckysheet_sheet_move_data.widthlist = []; |
||||
|
|
||||
|
$("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").each(function (i) { |
||||
|
if (i == 0) { |
||||
|
Store.luckysheet_sheet_move_data.widthlist.push(parseInt($(this).outerWidth())); |
||||
|
} |
||||
|
else { |
||||
|
Store.luckysheet_sheet_move_data.widthlist.push(parseInt($(this).outerWidth()) + Store.luckysheet_sheet_move_data.widthlist[i - 1]); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
Store.luckysheet_sheet_move_data.curindex = $("#luckysheet-sheet-area div.luckysheet-sheets-item").index($item); |
||||
|
let x = e.pageX; |
||||
|
Store.luckysheet_sheet_move_data.curleft = x - $item.offset().left; |
||||
|
Store.luckysheet_sheet_move_data.pageX = x; |
||||
|
Store.luckysheet_sheet_move_data.activeobject = $item; |
||||
|
Store.luckysheet_sheet_move_data.cursorobject = $cur; |
||||
|
let $itemclone = $item.clone().css("visibility", "hidden").attr("id", "luckysheet-sheets-item-clone"); |
||||
|
$item.after($itemclone); |
||||
|
$item.css({ "position": "absolute", "opacity": 0.8, "cursor": "move", "transition": "initial", "z-index": 10 }); |
||||
|
}, 200); |
||||
|
} |
||||
|
}).on("click", "div.luckysheet-sheets-item", function (e) { |
||||
|
if(isEditMode()){ |
||||
|
// alert("非编辑模式下不允许该操作!");
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let $t = $(this), $cur = $(e.target); |
||||
|
luckysheetsheetrightclick($t, $cur, e); |
||||
|
}); |
||||
|
|
||||
|
let luckysheetsheetnameeditor = function ($t) { |
||||
|
$t.attr("contenteditable", "true").addClass("luckysheet-mousedown-cancel").data("oldtxt", $t.text()); |
||||
|
|
||||
|
setTimeout(function () { |
||||
|
if (document.selection) { |
||||
|
let range = document.body.createTextRange(); |
||||
|
range.moveToElementText($t.get(0)); |
||||
|
range.select(); |
||||
|
} else if (window.getSelection) { |
||||
|
let range = document.createRange(); |
||||
|
range.selectNodeContents($t.get(0)); |
||||
|
window.getSelection().removeAllRanges(); |
||||
|
window.getSelection().addRange(range); |
||||
|
} |
||||
|
}, 1); |
||||
|
} |
||||
|
|
||||
|
$("#luckysheet-sheet-area").on("dblclick", "span.luckysheet-sheets-item-name", function (e) { |
||||
|
luckysheetsheetnameeditor($(this)); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheet-sheet-area").on("blur", "span.luckysheet-sheets-item-name", function (e) { |
||||
|
let $t = $(this); |
||||
|
let txt = $t.text(), oldtxt = $t.data("oldtxt"); |
||||
|
|
||||
|
let index = getSheetIndex(Store.currentSheetIndex); |
||||
|
for (let i = 0; i < Store.luckysheetfile.length; i++) { |
||||
|
if (index != i && Store.luckysheetfile[i].name == txt) { |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_sheetconfig.tipNameRepeat); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info("", locale_sheetconfig.tipNameRepeat); |
||||
|
} |
||||
|
$t.text(oldtxt).attr("contenteditable", "false"); |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
let winW = $(window).width(); |
||||
|
|
||||
|
let c_width = 0; |
||||
|
$("#luckysheet-sheet-container-c > div.luckysheet-sheets-item:visible").each(function(){ |
||||
|
c_width += $(this).outerWidth(); |
||||
|
}); |
||||
|
|
||||
|
if (c_width >= winW * 0.7) { |
||||
|
$("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block"); |
||||
|
$("#luckysheet-sheet-container .docs-sheet-fade-left").show(); |
||||
|
} |
||||
|
|
||||
|
Store.luckysheetfile[index].name = txt; |
||||
|
server.saveParam("all", Store.currentSheetIndex, txt, { "k": "name" }); |
||||
|
|
||||
|
$t.attr("contenteditable", "false").removeClass("luckysheet-mousedown-cancel"); |
||||
|
|
||||
|
if (Store.clearjfundo) { |
||||
|
let redo = {}; |
||||
|
redo["type"] = "sheetName"; |
||||
|
redo["sheetIndex"] = Store.currentSheetIndex; |
||||
|
|
||||
|
redo["oldtxt"] = oldtxt; |
||||
|
redo["txt"] = txt; |
||||
|
|
||||
|
Store.jfundo = []; |
||||
|
Store.jfredo.push(redo); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheet-sheet-area").on("keydown", "span.luckysheet-sheets-item-name", function (e) { |
||||
|
let kcode = e.keyCode; |
||||
|
let $t = $(this); |
||||
|
if (kcode == keycode.ENTER) { |
||||
|
let index = getSheetIndex(Store.currentSheetIndex); |
||||
|
Store.luckysheetfile[index].name = $t.text(); |
||||
|
$t.attr("contenteditable", "false"); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheetsheetconfigrename").click(function () { |
||||
|
luckysheetsheetnameeditor(luckysheetcurrentSheetitem.find("span.luckysheet-sheets-item-name")); |
||||
|
$("#luckysheet-input-box").removeAttr("style"); |
||||
|
$("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheetsheetconfigshow").click(function () { |
||||
|
$("#luckysheet-sheets-m").click(); |
||||
|
$("#luckysheet-input-box").removeAttr("style"); |
||||
|
$("#luckysheet-rightclick-sheet-menu").hide(); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheetsheetconfigmoveleft").click(function () { |
||||
|
if (luckysheetcurrentSheetitem.prevAll(":visible").length > 0) { |
||||
|
luckysheetcurrentSheetitem.insertBefore(luckysheetcurrentSheetitem.prevAll(":visible").eq(0)); |
||||
|
sheetmanage.reOrderAllSheet(); |
||||
|
} |
||||
|
$("#luckysheet-input-box").removeAttr("style"); |
||||
|
$("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheetsheetconfigmoveright").click(function () { |
||||
|
if (luckysheetcurrentSheetitem.nextAll(":visible").length > 0) { |
||||
|
luckysheetcurrentSheetitem.insertAfter(luckysheetcurrentSheetitem.nextAll(":visible").eq(0)); |
||||
|
sheetmanage.reOrderAllSheet(); |
||||
|
} |
||||
|
$("#luckysheet-input-box").removeAttr("style"); |
||||
|
$("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheetsheetconfigdelete").click(function (e) { |
||||
|
$("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); |
||||
|
|
||||
|
if($("#luckysheet-sheet-container-c .luckysheet-sheets-item:visible").length <= 1){ |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_sheetconfig.noMoreSheet); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info(locale_sheetconfig.noMoreSheet, ""); |
||||
|
} |
||||
|
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let index = getSheetIndex(Store.currentSheetIndex); |
||||
|
|
||||
|
tooltip.confirm(locale_sheetconfig.confirmDelete+"【" + Store.luckysheetfile[index].name + "】?", "<span style='color:#9e9e9e;font-size:12px;'>"+locale_sheetconfig.redoDelete+"</span>", function () { |
||||
|
sheetmanage.deleteSheet(luckysheetcurrentSheetitem.data("index")); |
||||
|
}, null); |
||||
|
|
||||
|
$("#luckysheet-input-box").removeAttr("style"); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheetsheetconfigcopy").click(function (e) { |
||||
|
sheetmanage.copySheet(luckysheetcurrentSheetitem.data("index"), e); |
||||
|
$("#luckysheet-input-box").removeAttr("style"); |
||||
|
$("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheetsheetconfighide").click(function () { |
||||
|
if ($("#luckysheet-sheet-area div.luckysheet-sheets-item:visible").length == 1) { |
||||
|
if(isEditMode()){ |
||||
|
alert(locale_sheetconfig.noHide); |
||||
|
} |
||||
|
else{ |
||||
|
tooltip.info("", locale_sheetconfig.noHide); |
||||
|
} |
||||
|
return; |
||||
|
} |
||||
|
sheetmanage.setSheetHide(luckysheetcurrentSheetitem.data("index")); |
||||
|
$("#luckysheet-input-box").removeAttr("style"); |
||||
|
$("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide(); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheet-sheets-add").click(function (e) { |
||||
|
sheetmanage.addNewSheet(e); |
||||
|
sheetmanage.locationSheet(); |
||||
|
$("#luckysheet-input-box").removeAttr("style"); |
||||
|
}); |
||||
|
|
||||
|
let sheetscrollani = null, sheetscrollstart = 0, sheetscrollend = 0, sheetscrollstep = 150; |
||||
|
$("#luckysheet-sheets-leftscroll").click(function () { |
||||
|
let $c = $("#luckysheet-sheet-container-c"); |
||||
|
sheetscrollstart = $c.scrollLeft(); |
||||
|
sheetscrollend = $c.scrollLeft() - sheetscrollstep; |
||||
|
|
||||
|
if (sheetscrollend <= 0) { |
||||
|
$("#luckysheet-sheet-container .docs-sheet-fade-left").hide(); |
||||
|
} |
||||
|
$("#luckysheet-sheet-container .docs-sheet-fade-right").show(); |
||||
|
|
||||
|
clearInterval(sheetscrollani); |
||||
|
sheetscrollani = setInterval(function () { |
||||
|
sheetscrollstart -= 4; |
||||
|
$c.scrollLeft(sheetscrollstart); |
||||
|
if (sheetscrollstart <= sheetscrollend) { |
||||
|
clearInterval(sheetscrollani); |
||||
|
} |
||||
|
}, 1); |
||||
|
}); |
||||
|
|
||||
|
$("#luckysheet-sheets-rightscroll").click(function () { |
||||
|
let $c = $("#luckysheet-sheet-container-c"); |
||||
|
sheetscrollstart = $c.scrollLeft(); |
||||
|
sheetscrollend = $c.scrollLeft() + sheetscrollstep; |
||||
|
|
||||
|
if (sheetscrollstart > 0) { |
||||
|
$("#luckysheet-sheet-container .docs-sheet-fade-right").hide(); |
||||
|
} |
||||
|
$("#luckysheet-sheet-container .docs-sheet-fade-left").show(); |
||||
|
|
||||
|
clearInterval(sheetscrollani); |
||||
|
sheetscrollani = setInterval(function () { |
||||
|
sheetscrollstart += 4; |
||||
|
$c.scrollLeft(sheetscrollstart); |
||||
|
if (sheetscrollstart >= sheetscrollend) { |
||||
|
clearInterval(sheetscrollani); |
||||
|
} |
||||
|
}, 1); |
||||
|
}); |
||||
|
|
||||
|
let initialOpenSheet = true; |
||||
|
$("#luckysheet-sheets-m").click(function (e) { |
||||
|
$("#luckysheet-sheet-list").html(""); |
||||
|
|
||||
|
let item = ""; |
||||
|
for (let i = 0; i < Store.luckysheetfile.length; i++) { |
||||
|
let f = Store.luckysheetfile[i], icon = '', style = ""; |
||||
|
if (f["status"] == 1) { |
||||
|
icon = '<i class="fa fa-check" aria-hidden="true"></i>'; |
||||
|
} |
||||
|
|
||||
|
if (f["hide"] == 1) { |
||||
|
icon = '<i class="fa fa-low-vision" aria-hidden="true"></i>'; |
||||
|
style += "color:#BBBBBB;"; |
||||
|
} |
||||
|
|
||||
|
if (f["color"] != null && f["color"].length > 0) { |
||||
|
style += "border-right:4px solid " + f["color"] + ";"; |
||||
|
} |
||||
|
|
||||
|
item += replaceHtml(sheetselectlistitemHTML, { "index": f["index"], "name": f["name"], "icon": icon, "style": style }); |
||||
|
} |
||||
|
|
||||
|
if (initialOpenSheet) { |
||||
|
$("#" + Store.container).append(replaceHtml(sheetselectlistHTML, { "item": item })); |
||||
|
$("#luckysheet-sheet-list").on("click", ".luckysheet-cols-menuitem", function (e) { |
||||
|
if(isEditMode()){ |
||||
|
// tooltip.info("提示", "图表编辑模式下不允许该操作!");
|
||||
|
alert(locale_sheetconfig.chartEditNoOpt); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
let $item = $(this), index = $item.data("index"); |
||||
|
|
||||
|
if ($item.data("index") != Store.currentSheetIndex) { |
||||
|
sheetmanage.setSheetShow(index); |
||||
|
sheetmanage.locationSheet(); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
initialOpenSheet = false; |
||||
|
} |
||||
|
else { |
||||
|
$("#luckysheet-sheet-list").html(item); |
||||
|
} |
||||
|
|
||||
|
let $t = $("#luckysheet-sheet-list"); |
||||
|
|
||||
|
mouseclickposition($t, $(this).offset().left, $(this).offset().top - 12, "leftbottom"); |
||||
|
$("#luckysheet-input-box").removeAttr("style"); |
||||
|
}); |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue