1 /**
  2  * @fileOverview
  3  * @author <a href="https://www.labkey.org">LabKey</a> (<a href="mailto:info@labkey.com">info@labkey.com</a>)
  4  * @license Copyright (c) 2008-2016 LabKey Corporation
  5  * <p/>
  6  * Licensed under the Apache License, Version 2.0 (the "License");
  7  * you may not use this file except in compliance with the License.
  8  * You may obtain a copy of the License at
  9  * <p/>
 10  * http://www.apache.org/licenses/LICENSE-2.0
 11  * <p/>
 12  * Unless required by applicable law or agreed to in writing, software
 13  * distributed under the License is distributed on an "AS IS" BASIS,
 14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  * See the License for the specific language governing permissions and
 16  * limitations under the License.
 17  * <p/>
 18  */
 19 
 20 Ext.namespace('LABKEY', 'LABKEY.ext');
 21 
 22 LABKEY.ext.LongTextField = Ext.extend(Ext.form.TriggerField, {
 23 
 24     triggerClass : 'labkey-trigger-elipsis',
 25     
 26     initComponent : function() {
 27         LABKEY.ext.LongTextField.superclass.initComponent.call(this);
 28     },
 29     
 30     onTriggerClick : function() {
 31         //create the window if necessary
 32         if(!this.popup)
 33         {
 34             this.popup = new Ext.Window({
 35                 closeAction: 'hide',
 36                 height: this.height || 400,
 37                 width: this.width || 300,
 38                 layout: 'fit',
 39                 items: [new Ext.form.TextArea()],
 40                 buttons: [
 41                     {
 42                         text: 'Save Changes',
 43                         handler: this.onSaveChanges,
 44                         scope: this
 45                     },
 46                     {
 47                         text: 'Cancel',
 48                         handler: this.onCancel,
 49                         scope: this
 50                     }
 51                 ],
 52                 closable: true,
 53                 modal: true,
 54                 animateTarget: this.getEl(),
 55                 align: "tl-bl",
 56                 title: "Edit " + this.columnName || "Edit"
 57             });
 58         }
 59 
 60         this.popup.getComponent(0).setValue(this.getValue());
 61         this.popup.show();
 62 
 63         this.hide();
 64         this.suspendEvents();
 65 
 66         this.popup.getComponent(0).getEl().focus();
 67 
 68     },
 69 
 70     onSaveChanges : function() {
 71         this.hidePopup();
 72         this.setValue(this.popup.getComponent(0).getValue());
 73     },
 74 
 75     onCancel : function() {
 76         this.hidePopup();
 77     },
 78 
 79     hidePopup : function() {
 80         this.popup.hide();
 81         this.show();
 82         this.resumeEvents();
 83         this.getEl().focus();
 84     },
 85 
 86     onDestroy : function() {
 87         if(this.popup)
 88             this.popup.destroy();
 89         LABKEY.ext.LongTextField.superclass.onDestroy.call(this);
 90     }
 91 });