/** * * @class Ext.form.LabelField * @extends Ext.form.Field * * label class - makes label a form field allowing to add it to forms anywhere */ Ext.define('Ext.form.LabelField', { extend : 'Ext.form.Field', constructor : function (config) { me = this; me.superclass.constructor.call(this, config); }, defaultAutoCreate : {tag: 'span'}, fieldClass: 'x-form-label', value: '', setValue:function(val) { if(this.rendered){ this.el.update(val); } } }); Ext.define('Ext.app.SearchField', { extend : 'Ext.form.field.Trigger', alias :'widget.searchfield', hideMode: 'display', // not working trigger2Cls: 'iconSearch', //same as x-form-search-trigger except with !important flag which seems to be required to work trigger1Cls : 'x-form-clear-trigger', hasSearch : false, emptyText : 'Search...', // Search onTrigger2Click: function() { var v = this.getRawValue(); if(v.length < 1){ this.onTrigger1Click(); return; } // set store search param this.store.getProxy().extraParams.search = v; // reset the grid page/start params this.store.currentPage = 1; this.store.load(); this.hasSearch = true; // this.triggerEl.item(0).show(); // this.doComponentLayout(); // not working }, // Clear onTrigger1Click: function() { this.setRawValue(''); if (this.hasSearch){ // reset store search param this.store.getProxy().extraParams.search = ''; // reset the grid page/start params this.store.currentPage = 1; this.store.load(); this.hasSearch = false; // this.triggerEl.item(0).hide(); // this.doComponentLayout(); // not working // this.fireEvent('blur'); // not working } }, initComponent : function(){ // SearchField.superclass.initComponent.call(this); // what does this do ? this.on('specialkey', function(f, e){ // allow 'enter' to submit search if (e.getKey() == e.ENTER){ this.onTrigger2Click(); } }, this); }, listeners: { render: function() { // this.triggerEl.item(0).hide(); // this.doComponentLayout(); // not working } } }); /** * setup a timer that will launch every 1440 seconds * or 24 minutes (current default length of a session in apache) * plus 10 seconds to ensure that the session has expired */ function startSessionTimer() { //1445000 var sessionTimer = setTimeout("getUserInfoFromSession()", 14410000); // - testing, set to a minute (5000) } /** * get user information * @return */ function getUserInfoFromSession() { // check if user is logged in Ext.Ajax.request({ method: 'post', scope: this, url: 'ajax/session_ajax.php', success: function(action, response) { var obj = Ext.JSON.decode(action.responseText); if (obj.session == '') { var loginWindow = new EnertechXchange.CMS.Login(); loginWindow.show(); } else { startSessionTimer(); } }, failure: function(action, response) { } }); } /** * VType definitions */ Ext.apply(Ext.form.VTypes, { 'phone' : function () { var re = /^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})(\s*x\s*\d*)?$/; return function (v) { return re.test(v); }; } (), 'phoneText' : 'The format is incorrect, ie: 123-456-7890 (dashes optional)' }); Ext.apply(Ext.form.VTypes, { 'postal' : function () { var re = /^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z]\s?\d[A-Z]\d$/; return function (v) { return re.test(v); }; } (), 'postalText' : 'The format is incorrect L2L 2L2 or 12345' }); Ext.apply(Ext.form.VTypes, { 'numeric': function() { var re = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/; return function(v) { return re.test(v); }; }(), 'numericText' : 'Not a valid numeric number. Must be numbers', 'numericMask' : /[\-\.0-9]/ }); Ext.apply(Ext.form.VTypes, { 'latitude': function() { var re = /(^\+?([1-8])?\d(\.\d+)?$)|(^-90$)|(^-(([1-8])?\d(\.\d+)?$))/; return function(v) { return re.test(v); }; }(), 'latitudeText' : 'Not a valid Latitude. Must be >= -90 And < 90.', 'latitudeMask' : /[\-\.0-9]/ }); Ext.apply(Ext.form.VTypes, { 'longitude': function() { var re = /(^\+?1[0-7]\d(\.\d+)?$)|(^\+?([1-9])?\d(\.\d+)?$)|(^-180$)|(^-1[1-7]\d(\.\d+)?$)|(^-[1-9]\d(\.\d+)?$)|(^\-\d(\.\d+)?$) /; return function(v) { return re.test(v); }; }(), 'longitudeText' : 'Not a valid Longitude. Must >- -180 And < 180.', 'longitudeMask' : /[\-\.0-9]/ });