2021-09-08 07:23:10 +00:00
|
|
|
!window.common && (window.common = {});
|
|
|
|
!common.controller && (common.controller = {});
|
2021-09-15 21:32:19 +00:00
|
|
|
if (SSE === undefined) {
|
|
|
|
var SSE = {};
|
|
|
|
}
|
|
|
|
SSE.Keys={RETURN: 13};
|
2021-09-09 02:55:43 +00:00
|
|
|
|
2021-09-15 21:32:19 +00:00
|
|
|
SSE.CellEditorController = new(function(){
|
2021-09-08 07:23:10 +00:00
|
|
|
var me,
|
|
|
|
api,
|
|
|
|
editor,
|
|
|
|
created=false;
|
|
|
|
|
|
|
|
function onCellName(e){
|
2021-09-15 21:32:19 +00:00
|
|
|
if (e.keyCode == SSE.Keys.RETURN){
|
2021-09-08 07:23:10 +00:00
|
|
|
var name = editor.$cellname.val();
|
|
|
|
if (name && name.length) {
|
|
|
|
api.asc_findCell(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-09 02:55:43 +00:00
|
|
|
|
2021-09-08 07:23:10 +00:00
|
|
|
function onKeyupCellEditor(e) {
|
2021-09-15 21:32:19 +00:00
|
|
|
if(e.keyCode == SSE.Keys.RETURN && !e.altKey){
|
2021-09-08 07:23:10 +00:00
|
|
|
api.isCEditorFocused = 'clear';
|
|
|
|
}
|
|
|
|
}
|
2021-09-09 02:55:43 +00:00
|
|
|
|
2021-09-08 07:23:10 +00:00
|
|
|
function onBlurCellEditor() {
|
|
|
|
if (api.isCEditorFocused == 'clear')
|
|
|
|
api.isCEditorFocused = undefined;
|
|
|
|
else if (api.isCellEdited)
|
|
|
|
api.isCEditorFocused = true;
|
|
|
|
}
|
2021-09-09 02:55:43 +00:00
|
|
|
|
2021-09-15 21:32:19 +00:00
|
|
|
|
2021-09-13 01:38:49 +00:00
|
|
|
|
2021-09-08 07:23:10 +00:00
|
|
|
function events() {
|
|
|
|
editor.$el.find('#ce-cell-name').on( 'keyup', onCellName);
|
|
|
|
editor.$el.find('textarea#ce-cell-content').on( 'keyup', onKeyupCellEditor);
|
|
|
|
editor.$el.find('textarea#ce-cell-content').on('blur', onBlurCellEditor);
|
|
|
|
}
|
2021-09-09 02:55:43 +00:00
|
|
|
|
2021-09-08 07:23:10 +00:00
|
|
|
function onLaunch(){
|
2021-09-15 21:32:19 +00:00
|
|
|
SSE.CellEditorView.create();
|
|
|
|
editor = SSE.CellEditorView;
|
2021-09-08 07:23:10 +00:00
|
|
|
events();
|
|
|
|
|
|
|
|
editor.$el.parent().find('.after').css({zIndex: '4'}); // for spreadsheets - bug 23127
|
|
|
|
|
|
|
|
var val = common.localStorage.getItem('sse-celleditor-height');
|
2021-09-15 21:32:19 +00:00
|
|
|
editor.keep_height = 19;//(val!==null && parseInt(val)>0) ? parseInt(val) : 19;
|
2021-09-08 07:23:10 +00:00
|
|
|
if (common.localStorage.getBool('sse-celleditor-expand')) {
|
|
|
|
editor.$el.height(editor.keep_height);
|
|
|
|
}
|
|
|
|
this.namedrange_locked = false;
|
|
|
|
}
|
|
|
|
|
2021-09-13 01:38:49 +00:00
|
|
|
function createController() {
|
|
|
|
me = this;
|
|
|
|
if (created) return me;
|
|
|
|
|
|
|
|
created = true;
|
|
|
|
onLaunch();
|
|
|
|
return me;
|
|
|
|
}
|
|
|
|
|
2021-09-08 07:23:10 +00:00
|
|
|
function onApiCellSelection(info){
|
|
|
|
editor.cell.updateInfo(info);
|
|
|
|
}
|
2021-09-09 02:55:43 +00:00
|
|
|
|
2021-09-08 07:23:10 +00:00
|
|
|
function onApiEditCell(state) {
|
|
|
|
if (state == Asc.c_oAscCellEditorState.editStart){
|
|
|
|
api.isCellEdited = true;
|
|
|
|
editor.cell.nameDisabled(true);
|
|
|
|
} else if (state == Asc.c_oAscCellEditorState.editInCell) {
|
|
|
|
api.isCEditorFocused = 'clear';
|
|
|
|
} else if (state == Asc.c_oAscCellEditorState.editEnd) {
|
|
|
|
api.isCellEdited = false;
|
|
|
|
api.isCEditorFocused = false;
|
|
|
|
editor.cell.nameDisabled(false);
|
|
|
|
}
|
|
|
|
}
|
2021-09-09 02:55:43 +00:00
|
|
|
|
2021-09-08 07:23:10 +00:00
|
|
|
function setApi(apiF){
|
|
|
|
api=apiF;
|
|
|
|
|
|
|
|
api.isCEditorFocused = false;
|
|
|
|
api.asc_registerCallback('asc_onSelectionNameChanged', onApiCellSelection);
|
|
|
|
api.asc_registerCallback('asc_onEditCell', onApiEditCell);
|
|
|
|
}
|
2021-09-09 02:55:43 +00:00
|
|
|
|
2021-09-08 07:23:10 +00:00
|
|
|
|
2021-09-09 02:55:43 +00:00
|
|
|
|
2021-09-08 07:23:10 +00:00
|
|
|
return {
|
|
|
|
create: createController,
|
2021-09-15 22:35:51 +00:00
|
|
|
setApi: setApi
|
2021-09-08 07:23:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
})();
|