raimund@548: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
raimund@548: * Software engineering by Intevation GmbH
raimund@548: *
raimund@548: * This file is Free Software under the GNU GPL (v>=3)
raimund@548: * and comes with ABSOLUTELY NO WARRANTY! Check out
raimund@548: * the documentation coming with IMIS-Labordaten-Application for details.
raimund@548: */
raimund@548:
raimund@548: Ext.define('Lada.view.widget.base.FieldSet', {
raimund@548: extend: 'Ext.form.FieldSet',
raimund@548: alias: 'widget.fset',
raimund@548:
raimund@548: plainTitle: '',
raimund@548: origColor: '',
raimund@633: errorText: '',
raimund@633: warningText: '',
dustin@717: tooltip: null,
raimund@548:
raimund@548: showWarningOrError: function(warning, warningText, error, errorText) {
dustin@717: this.clearMessages(); //Clear Errors and Warning first
raimund@548: var ndx = 0;
raimund@548: if (this.collapsible === true) {
raimund@548: ndx = 1;
raimund@548: }
raimund@633: if (this.errorText && this.errorText !== '') {
raimund@633: this.errorText += '\n';
raimund@633: }
raimund@633: this.errorText += errorText;
raimund@633: if (this.warningText && this.warningText !== '') {
raimund@633: this.warningText += '\n';
raimund@633: }
raimund@633: this.warningText += warningText;
raimund@548: this.plainTitle = this.getEl().dom.firstChild
raimund@548: .firstChild.firstChild
raimund@548: .children[ndx].innerHTML;
raimund@548: this.origColor = this.getEl().dom.style['border-color'];
raimund@548: if (error) {
raimund@548: this.getEl().dom.style['border-color'] = '#FF0000';
raimund@548: this.getEl().dom.firstChild.firstChild.firstChild
raimund@548: .children[ndx].innerHTML =
raimund@632: ' ' +
raimund@548: this.plainTitle;
raimund@548: if (errorText) {
dustin@717: if (!this.tooltip) {
dustin@717: Ext.create('Ext.tip.ToolTip', {
dustin@717: target: this.getEl().dom.firstChild.firstChild.firstChild.children[ndx],
dustin@717: html: errorText
dustin@717: });
dustin@717: }
dustin@717: else {
dustin@717: tooltip.html = errorText;
dustin@717: }
raimund@548: }
raimund@548: return;
raimund@548: }
raimund@548: if (warning) {
raimund@548: this.getEl().dom.style['border-color'] = '#FFE25D';
raimund@548: this.getEl().dom.firstChild.firstChild.firstChild
raimund@548: .children[ndx].innerHTML =
raimund@632: ' ' +
raimund@548: this.plainTitle;
raimund@548: if (warningText) {
dustin@717: if (!this.tooltip) {
dustin@717: Ext.create('Ext.tip.ToolTip', {
dustin@717: target: this.getEl().dom.firstChild.firstChild.firstChild.children[ndx],
dustin@717: html: warningText
dustin@717: });
dustin@717: }
dustin@717: else {
dustin@717: tooltip.html = warningText;
dustin@717: }
raimund@548: }
raimund@548: return;
raimund@548: }
raimund@548: },
raimund@548:
raimund@548: clearMessages: function() {
raimund@548: var ndx = 0;
raimund@548: if (this.collapsible === true) {
raimund@548: ndx = 1;
raimund@548: }
raimund@548: if (this.plainTitle !== '') {
raimund@548: this.getEl().dom.firstChild
raimund@548: .firstChild.firstChild
raimund@548: .children[ndx].innerHTML = this.plainTitle;
raimund@548: this.getEl().dom.style['border-color'] = this.origColor;
raimund@548: }
raimund@548: }
raimund@548: });