[SSE] Refactoring range selection
This commit is contained in:
parent
2d1b26a6aa
commit
709cf9fb79
|
@ -258,7 +258,7 @@ define([
|
||||||
click: function(e) {
|
click: function(e) {
|
||||||
if (me.api) {
|
if (me.api) {
|
||||||
me.api.isTextAreaBlur = false;
|
me.api.isTextAreaBlur = false;
|
||||||
if (e.target.localName == 'canvas' && !me.isEditFormula) {
|
if (e.target.localName == 'canvas' && (!me.isEditFormula || me.rangeSelectionMode)) {
|
||||||
if (me._preventClick)
|
if (me._preventClick)
|
||||||
me._preventClick = false;
|
me._preventClick = false;
|
||||||
else
|
else
|
||||||
|
@ -2030,7 +2030,7 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onFormulaCompleteMenu: function(funcarr) {
|
onFormulaCompleteMenu: function(funcarr) {
|
||||||
if (!this.documentHolder.funcMenu || Common.Utils.ModalWindow.isVisible()) return;
|
if (!this.documentHolder.funcMenu || Common.Utils.ModalWindow.isVisible() || this.rangeSelectionMode) return;
|
||||||
|
|
||||||
if (funcarr) {
|
if (funcarr) {
|
||||||
var me = this,
|
var me = this,
|
||||||
|
|
|
@ -103,11 +103,11 @@ define([
|
||||||
setSettings: function(settings) {
|
setSettings: function(settings) {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
|
this.settings = settings;
|
||||||
this.inputRange.setValue(settings.range ? settings.range : '');
|
this.inputRange.setValue(settings.range ? settings.range : '');
|
||||||
|
|
||||||
if (settings.type===undefined)
|
if (settings.type===undefined)
|
||||||
settings.type = Asc.c_oAscSelectionDialogType.Chart;
|
settings.type = Asc.c_oAscSelectionDialogType.Chart;
|
||||||
this.type = settings.type;
|
|
||||||
|
|
||||||
if (settings.api) {
|
if (settings.api) {
|
||||||
me.api = settings.api;
|
me.api = settings.api;
|
||||||
|
@ -122,12 +122,16 @@ define([
|
||||||
if (settings.validation) {
|
if (settings.validation) {
|
||||||
return settings.validation.call(me, value);
|
return settings.validation.call(me, value);
|
||||||
} else {
|
} else {
|
||||||
|
if (settings.type === Asc.c_oAscSelectionDialogType.Function) {
|
||||||
|
settings.argvalues[settings.argindex] = value;
|
||||||
|
me.api.asc_insertArgumentsInFormula(settings.argvalues);
|
||||||
|
}
|
||||||
var isvalid = (settings.type === Asc.c_oAscSelectionDialogType.Function) || me.api.asc_checkDataRange(settings.type, value, false);
|
var isvalid = (settings.type === Asc.c_oAscSelectionDialogType.Function) || me.api.asc_checkDataRange(settings.type, value, false);
|
||||||
return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.txtInvalidRange : true;
|
return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.txtInvalidRange : true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (me.type == Asc.c_oAscSelectionDialogType.Function) {
|
if (settings.type == Asc.c_oAscSelectionDialogType.Function) {
|
||||||
_.delay(function(){
|
_.delay(function(){
|
||||||
me.inputRange._input.focus();
|
me.inputRange._input.focus();
|
||||||
if (settings.selection) {
|
if (settings.selection) {
|
||||||
|
@ -147,7 +151,7 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onApiRangeChanged: function(name) {
|
onApiRangeChanged: function(name) {
|
||||||
if (this.type == Asc.c_oAscSelectionDialogType.Function) {
|
if (this.settings.type == Asc.c_oAscSelectionDialogType.Function) {
|
||||||
var oldlen = this._addedTextLength || 0,
|
var oldlen = this._addedTextLength || 0,
|
||||||
val = this.inputRange.getValue(),
|
val = this.inputRange.getValue(),
|
||||||
input = this.inputRange._input[0],
|
input = this.inputRange._input[0],
|
||||||
|
@ -159,6 +163,9 @@ define([
|
||||||
val = val.substring(0, start) + add + name + val.substring(end, val.length);
|
val = val.substring(0, start) + add + name + val.substring(end, val.length);
|
||||||
this.inputRange.setValue(val);
|
this.inputRange.setValue(val);
|
||||||
input.selectionStart = input.selectionEnd = start + add.length + this._addedTextLength;
|
input.selectionStart = input.selectionEnd = start + add.length + this._addedTextLength;
|
||||||
|
|
||||||
|
this.settings.argvalues[this.settings.argindex] = val;
|
||||||
|
this.api.asc_insertArgumentsInFormula(this.settings.argvalues);
|
||||||
} else
|
} else
|
||||||
this.inputRange.setValue(name);
|
this.inputRange.setValue(name);
|
||||||
if (this.inputRange.cmpEl.hasClass('error'))
|
if (this.inputRange.cmpEl.hasClass('error'))
|
||||||
|
|
|
@ -263,10 +263,8 @@ define([
|
||||||
}).on('changing', function(input, newValue, oldValue, e) {
|
}).on('changing', function(input, newValue, oldValue, e) {
|
||||||
if (newValue == oldValue) return;
|
if (newValue == oldValue) return;
|
||||||
var index = input.options.index,
|
var index = input.options.index,
|
||||||
arg = me.args[index],
|
arg = me.args[index];
|
||||||
values = me.getArgumentsValue();
|
var res = me.api.asc_insertArgumentsInFormula(me.getArgumentsValue(), index, arg.argType),
|
||||||
(index<values.length) && (values[index] = newValue);
|
|
||||||
var res = me.api.asc_insertArgumentsInFormula(values, index, arg.argType),
|
|
||||||
argres = res ? res.asc_getArgumentsResult() : undefined;
|
argres = res ? res.asc_getArgumentsResult() : undefined;
|
||||||
argres = argres ? argres[index] : undefined;
|
argres = argres ? argres[index] : undefined;
|
||||||
arg.lblValue.html('= '+ (argres!==null && argres !==undefined ? argres : '<span style="opacity: 0.5; font-weight: bold;">' + arg.argTypeName + '</span>' ));
|
arg.lblValue.html('= '+ (argres!==null && argres !==undefined ? argres : '<span style="opacity: 0.5; font-weight: bold;">' + arg.argTypeName + '</span>' ));
|
||||||
|
@ -367,7 +365,9 @@ define([
|
||||||
api : me.api,
|
api : me.api,
|
||||||
range : !_.isEmpty(input.getValue()) ? input.getValue() : '',
|
range : !_.isEmpty(input.getValue()) ? input.getValue() : '',
|
||||||
type : Asc.c_oAscSelectionDialogType.Function,
|
type : Asc.c_oAscSelectionDialogType.Function,
|
||||||
selection: {start: input._input[0].selectionStart, end: input._input[0].selectionEnd}
|
selection: {start: input._input[0].selectionStart, end: input._input[0].selectionEnd},
|
||||||
|
argvalues : me.getArgumentsValue(),
|
||||||
|
argindex : input.options.index
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue