|
| 1 | +sap.ui.define(['jquery.sap.global', 'sap/m/Input'], |
| 2 | + function(jQuery, Parent) { |
| 3 | + "use strict"; |
| 4 | + |
| 5 | + var Control = Parent.extend('ui5lib.controls.Input', { |
| 6 | + init: function() { |
| 7 | + this.setShowValueHelp(true); |
| 8 | + this.attachLiveChange(this.checkInputForReset); |
| 9 | + }, |
| 10 | + |
| 11 | + renderer: {}, |
| 12 | + |
| 13 | + onAfterRendering: function() { |
| 14 | + if (sap.m.Input.prototype.onAfterRendering) { |
| 15 | + sap.m.Input.prototype.onAfterRendering.apply(this, arguments); |
| 16 | + } |
| 17 | + |
| 18 | + var icon = this._getValueHelpIcon(); |
| 19 | + icon.setSrc("sap-icon://sys-cancel"); |
| 20 | + icon.setSize('1.25rem'); |
| 21 | + if(!this.__initIcon){ // small hack to get the icon to load so it can appear immediately as something is typed into it. |
| 22 | + this.__initIcon = true; |
| 23 | + this.setShowValueHelp(false); |
| 24 | + } |
| 25 | + }, |
| 26 | + |
| 27 | + checkInputForReset: function(evt){ |
| 28 | + //var args = arguments; |
| 29 | + //debugger; |
| 30 | + var sVal = typeof(evt)==='string'? evt: evt.getParameter("newValue") |
| 31 | + if(!sVal){ |
| 32 | + this.setShowValueHelp(false); |
| 33 | + }else{ |
| 34 | + this.setShowValueHelp(true); |
| 35 | + } |
| 36 | + }, |
| 37 | + |
| 38 | + setValue: function(sVal){ |
| 39 | + this.checkInputForReset(sVal); |
| 40 | + if (sap.m.Input.prototype.setValue) { |
| 41 | + sap.m.Input.prototype.setValue.apply(this, arguments); |
| 42 | + } |
| 43 | + }, |
| 44 | + |
| 45 | + fireValueHelpRequest: function(){ |
| 46 | + this.setValue(""); |
| 47 | + } |
| 48 | + }); |
| 49 | + |
| 50 | + return Control; |
| 51 | + |
| 52 | + }, /* bExport = */ true); |
0 commit comments