[DE] Watermark: disable Ok button when image is not loaded
This commit is contained in:
parent
3113e79881
commit
62dbe2e80d
|
@ -116,6 +116,7 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template',
|
||||||
this.fontName = 'Arial';
|
this.fontName = 'Arial';
|
||||||
this.lang = 'en';
|
this.lang = 'en';
|
||||||
this.isAutoColor = false;
|
this.isAutoColor = false;
|
||||||
|
this.isImageLoaded = false;
|
||||||
|
|
||||||
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
|
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
|
||||||
},
|
},
|
||||||
|
@ -361,6 +362,11 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template',
|
||||||
});
|
});
|
||||||
this.textControls.push(this.radioHor);
|
this.textControls.push(this.radioHor);
|
||||||
|
|
||||||
|
this.btnOk = new Common.UI.Button({
|
||||||
|
el: this.$window.find('.primary'),
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
|
||||||
this.afterRender();
|
this.afterRender();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -399,6 +405,16 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template',
|
||||||
|
|
||||||
this.updateThemeColors();
|
this.updateThemeColors();
|
||||||
this._setDefaults(this.props);
|
this._setDefaults(this.props);
|
||||||
|
|
||||||
|
var me = this;
|
||||||
|
var onApiWMLoaded = function() {
|
||||||
|
me.isImageLoaded = true;
|
||||||
|
me.btnOk.setDisabled(false);
|
||||||
|
};
|
||||||
|
this.api.asc_registerCallback('asc_onWatermarkImageLoaded', onApiWMLoaded);
|
||||||
|
this.on('close', function(obj){
|
||||||
|
me.api.asc_unregisterCallback('asc_onWatermarkImageLoaded', onApiWMLoaded);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function() {
|
show: function() {
|
||||||
|
@ -471,15 +487,17 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template',
|
||||||
props.put_DivId('watermark-texture-img');
|
props.put_DivId('watermark-texture-img');
|
||||||
props.put_Api(this.api);
|
props.put_Api(this.api);
|
||||||
|
|
||||||
var val = props.get_Type();
|
var val,
|
||||||
if (val == Asc.c_oAscWatermarkType.None) {
|
type = props.get_Type();
|
||||||
this.radioNone.setValue(true);
|
if (type == Asc.c_oAscWatermarkType.None) {
|
||||||
} else if (val == Asc.c_oAscWatermarkType.Image) {
|
this.radioNone.setValue(true, true);
|
||||||
this.radioImage.setValue(true);
|
} else if (type == Asc.c_oAscWatermarkType.Image) {
|
||||||
|
this.radioImage.setValue(true, true);
|
||||||
|
this.isImageLoaded = !!props.get_ImageUrl();
|
||||||
val = props.get_Scale() || -1;
|
val = props.get_Scale() || -1;
|
||||||
this.cmbScale.setValue((val<0) ? -1 : Math.round(val*100), Math.round(val*100) + ' %');
|
this.cmbScale.setValue((val<0) ? -1 : Math.round(val*100), Math.round(val*100) + ' %');
|
||||||
} else {
|
} else {
|
||||||
this.radioText.setValue(true);
|
this.radioText.setValue(true, true);
|
||||||
!props.get_IsDiagonal() && this.radioHor.setValue(true);
|
!props.get_IsDiagonal() && this.radioHor.setValue(true);
|
||||||
this.chTransparency.setValue(props.get_Opacity()<255);
|
this.chTransparency.setValue(props.get_Opacity()<255);
|
||||||
|
|
||||||
|
@ -538,6 +556,7 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template',
|
||||||
val = props.get_Text();
|
val = props.get_Text();
|
||||||
val && this.cmbText.setValue(val);
|
val && this.cmbText.setValue(val);
|
||||||
}
|
}
|
||||||
|
this.disableControls(type);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -592,13 +611,24 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template',
|
||||||
item.setDisabled(disable);
|
item.setDisabled(disable);
|
||||||
});
|
});
|
||||||
this.cmbLang.setDisabled(disable || this.languages.length<1);
|
this.cmbLang.setDisabled(disable || this.languages.length<1);
|
||||||
|
this.btnOk.setDisabled(type==Asc.c_oAscWatermarkType.Image && !this.isImageLoaded);
|
||||||
},
|
},
|
||||||
|
|
||||||
onDlgBtnClick: function(event) {
|
onDlgBtnClick: function(event) {
|
||||||
var me = this;
|
this._handleInput(event.currentTarget.attributes['result'].value);
|
||||||
var state = (typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event;
|
},
|
||||||
if (state == 'ok') {
|
|
||||||
this.handler && this.handler.call(this, state, this.getSettings());
|
onPrimary: function() {
|
||||||
|
this._handleInput('ok');
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
_handleInput: function(state) {
|
||||||
|
if (this.handler) {
|
||||||
|
if (state == 'ok' && this.btnOk.isDisabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.handler.call(this, state, this.getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
|
|
Loading…
Reference in a new issue