Ext.define('My.patch.form.HtmlEditor', { override: 'Ext.form.field.HtmlEditor', initComponent: function() { this.callParent(); }, onFirstFocus: function(){ var me = this, selection, range; me.activated = true; me.disableItems(me.readOnly); if (Ext.isGecko) { me.win.focus(); selection = me.win.getSelection(); if (selection && (!selection.focusNode || selection.focusNode.nodeType !== 3)) { range = selection.getRangeAt(0); range.selectNodeContents(me.getEditorBody()); range.collapse(true); me.deferFocus(); } try { me.execCmd('useCSS', true); me.execCmd('styleWithCSS', false); } catch(e) { // ignore (why?) } } me.fireEvent('activate', me); } }); Ext.define('My.patch.form.TimeField', { override: 'Ext.form.field.Time', getValue: function() { var v = this.callParent(arguments); if(this.format) return(Ext.util.Format.date(v, this.format)); else return(Ext.util.Format.date(v, 'g:i A')); }, createPicker: function() { var me = this, picker; // the following apply will allow typeahead // filtered selections in timefield me.listConfig = Ext.apply({}, { typeAhead: me.typeAhead, minChars: me.minChars, triggerAction: me.triggerAction }); me.listConfig = Ext.apply({ xtype: 'timepicker', selModel: { mode: 'SINGLE' }, cls: undefined, minValue: me.minValue, maxValue: me.maxValue, increment: me.increment, format: me.format, maxHeight: me.pickerMaxHeight }, me.listConfig); picker = me.callParent(); me.bindStore(picker.store); return picker; }, isEqual: function(date1, date2) { return date1==date2; } }); Ext.define('My.patch.data.Store', { override:'Ext.data.Store', //grid performance bug onProxyLoad: function(operation) { var me = this, resultSet = operation.getResultSet(), records = operation.getRecords(), successful = operation.wasSuccessful(); if (me.isDestroyed) { return; } if (resultSet) { me.totalCount = resultSet.total; } // Loading should be set to false before loading the records. // loadRecords doesn't expose any hooks or events until refresh // and datachanged, so by that time loading should be false Ext.suspendLayouts(); //add me.loading = false; if (successful) { me.loadRecords(records, operation); } if (me.hasListeners.load) { me.fireEvent('load', me, records, successful); } //TODO: deprecate this event, it should always have been 'load' instead. 'load' is now documented, 'read' is not. //People are definitely using this so can't deprecate safely until 2.x if (me.hasListeners.read) { me.fireEvent('read', me, records, successful); } //this is a callback that would have been passed to the 'read' function and is optional Ext.callback(operation.callback, operation.scope || me, [records, operation, successful]); Ext.resumeLayouts(true); //add } }); /** This is the loaded code when viewing the plugin from the client perspective **/ // // globals used by preplanningform.js.php // var preplanform; // globals needed by obitgrid.js.php var panel; function openWindow1(url, rheight, rwidth, rname) { if(typeof(rheight) != "undefined") var height = rheight; else var height = 600; if(typeof(rwidth) != "undefined") var width = rwidth; else var width = 800; if(typeof(rname) != "undefined") var name = rname; else name = 'sub_window1'; window.open(url, name, 'toolbar=no,location=yes,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no,copyhistory=no,width='+width+',height='+height); } var obitview; var fw_search; // called by submit button on search form and on init of search module var funeralworks_obituary_plugin_search = function(){ var searchform = Ext.getCmp('funeralworks_obituary_search_form'); if(searchform.getForm().findField('searchterm')){ // obitview.setBaseParams(searchform.getForm().findField('searchterm').getValue()); // searchform.getForm().findField('searchterm').setValue(''); } obitview.load(); } // // function to load and eval external files into the // current scope - calls afterfn when all modules have // been loaded. // // global variable of the same name as the script.fn // required at this level so that each module has scope access. // constructor in loaded module must be script.fn + "_m" // // fwStatusWin must already exist on entry. and be closed // in the afterfn callback /* args: scripts - array of loader objects of the form { file: 'srcname', fn: 'constructor callback', text: 'status info msg', status: .1 }, i - current index, always 0 on initial call, src - source file directory location, afterfn - function to call when complete */ function system_loader(scripts, i, src, afterfn, dest){ if(typeof afterfn == 'undefined'){ alert("Impropper use of system_loader. Args required."); } if(typeof i == "undefined") i = 0; // url path below should be adjusted to suit the application Ext.Ajax.request({ url: '/js/' + scripts[i].file, method: 'POST', success: function(resp){ // fwStatusWin.updateProgress(scripts[i].status, scripts[i].text); Ext.getBody().mask(scripts[i].text); var t = resp.responseText; eval(resp.responseText); if(typeof scripts[i].fn == "string") { // the following line should be modified to suit the application if(dest == "preplanform") { if(i > 0){ eval(dest + ".add(new " + scripts[i].fn + "_m());"); } else { eval(scripts[i].fn + " = new " + scripts[i].fn + "_m();"); } } else { eval(scripts[i].fn + " = new " + scripts[i].fn + "_m();"); } } if(++i < scripts.length){ // recursive call to get all files system_loader(scripts, i, src, afterfn, dest); } else { eval(afterfn + "();"); } }, failure: function(resp){ Ext.MessageBox.alert("Communication Error", "Unable to communicate with remote server."); }, scope: this }); } function loadPanel(){ var ow = Ext.get('obitswrapper'); var op = Ext.get('preplanningwrapper'); var cl = Ext.get('currentobitslist'); if(op) { var id = 'preplan'; var div = op; var items = [preplanform]; var bbar = {}; var cookie = Ext.util.Cookies.get("fw_preplanning_form"); if(cookie != null) { // do whatever is needed to retrieve the viewers data preplanform.addListener({ render: function() { function myHandler(json, e){ if(json.statusText == "OK") { eval("var d = "+json.responseText+";"); eval("var data = "+d.jsondata+";"); preplanform.getForm().setValues(data); } else { if(json.message) alert(json.message); if(e.message) alert(e.message); } } // FW.Preplan.getPlan({plan_id: cookie}, myHandler, this); Ext.Ajax.request({ url: "/wp-content/plugins/funeralworks_obituary_plugin/getPlan.php", success: myHandler, failure: function(e){ alert("There was an unspecified error processing your request."); } }); } }); } } if(ow) { var id = 'obits'; var div = ow; var bbar = new Ext.PagingToolbar({ // id: 'obitpager', autoEl: {tag: 'div', cls: 'obitpager'}, style: 'width: 100%; background: transparent; border-top: 1px solid black;', store: obitview.getStore(), displayInfo: true, totalProperty: 'count', pageSize: 5, displayMsg: 'Displaying items {0} - {1} of {2}', listeners: { change: function(tb, page, eOpts) { if(this.needsScroll) { var sc = new Ext.util.DelayedTask(function() { this.refreshView(); window.scrollTo(0, document.getElementById('obitswrapper').offsetTop); }, this); sc.delay(350); } else { this.needsScroll = true; } }, scope: obitview } }); var items = [fw_search, obitview]; } else if(cl) { var id = 'obitschedule'; var div = cl var items = [obitschedules]; var bbar = {}; } // turn on spinner window for AJAX activities from here out Ext.Ajax.request({ url: '/session_start.php', params: {lid: "", lpw: "", type: 'long'}, success: function(resp){ var j = Ext.decode(resp.responseText); if(j.success){ panel = Ext.create('Ext.Panel', { id: id, border: false, layoutConfig: { type: 'hbox', align: 'stretch' }, renderTo: div, items: items, // [fw_search, viewwrapper] bbar: bbar }); // fwStatusWin.hide(); Ext.getBody().unmask(); if(ow) { funeralworks_obituary_plugin_search(); } } }, failure: function(resp){ Ext.MessageBox.alert('Communcations failure', 'Unable to load initial values from server.'); } }, this); } function system_init() { // fwStatusWin.updateProgress(.1, "Preparing preplannig form"); Ext.getBody().mask('Preparing preplanning form.'); } Ext.onReady( function() { Ext.tip.QuickTipManager.init(); Ext.apply(Ext.tip.QuickTipManager.getQuickTip(), { dismissDelay: 30000 }); var ow = Ext.get('obitswrapper'); var op = Ext.get('preplanningwrapper'); var cl = Ext.get('currentobitslist'); var srcdir = '/js/'; if( ow || op || cl){ // only exists if in page view with hot tag embedded if(op){ // fwStatusWin = Ext.MessageBox.progress('Funeralworks', "Loading components. Standby."); Ext.getBody().mask('Loading components. Stand by.'); var scripts = [ {file: 'preplanning.js.php', fn: 'preplanform', text: 'Preparing panel. Stand by.', status: .05}, {file: 'filerinfo.js.php', fn: 'ppaboutfiler', text: 'Loading form filer profile', status: .1}, {file: 'ppplanset.js.php', fn: 'ppplanset', text: 'Loading individual\' profile', status: .2}, {file: 'ppfatherset.js.php', fn: 'ppfatherset', text: 'Loading father\' module', status: .25}, {file: 'ppmotherset.js.php', fn: 'ppmotherset', text: 'Loading mother\'s module', status: .3}, {file: 'ppliveset.js.php', fn: 'ppliveset', text: 'Loading residency module', status: .35}, {file: 'ppmaritalset.js.php', fn: 'ppmaritalset', text: 'Loading marriage module', status: .4}, {file: 'ppemploymentset.js.php', fn: 'ppemploymentset', text: 'Loading employment module', status: .5}, {file: 'ppeduset.js.php', fn: 'ppeduset', text: 'Loading education module', status: .55}, {file: 'ppmilset.js.php', fn: 'ppmilset', text: 'Loading military module', status: .6}, {file: 'ppsurvivorsset.js.php', fn: 'ppsurvivorsset', text: 'Loading survivors module', status: .68}, {file: 'ppclubsset.js.php',fn: 'ppclubsset', text: 'Loading clubs module', status: .75}, {file: 'pphobbiesset.js.php', fn: 'pphobbiesset', text: 'Loading hobbies module', status: .8}, {file: 'ppinfoset.js.php', fn: 'ppinfoset', text: 'Loading funeralservice module', status: .82}, {file: 'ppdispositionset.js.php', fn: 'ppdispositionset', text: 'Loading final disposition module', status: .85}, {file: 'ppexecset.js.php', fn: 'ppexecset', text: 'Loading executor module', status: .9}/* , {file: 'ppwhat.js.php', fn: 'ppwhat', text: 'Preparing form for display', status: .97}*/ ]; var dest = "preplanform"; } if(ow) { /* fwStatusWin = Ext.MessageBox.show({ title: 'Funeralworks', msg: "Loading components.", progressTextr: "Standby.", progress: true }); */ Ext.getBody().mask("Loading components. Stand by."); var scripts = [ {file: 'fw_search.js.php', fn: 'fw_search', text: 'Loading search form.', status: .1}, {file: 'obitpager.js.php', fn: 'obitview', text: 'Loading paging toolbar', status: .5} ]; var dest = ""; } else if(cl) { /* fwStatusWin = Ext.MessageBox.show({ title: 'Funeralworks', msg: "Loading current obituary schedules.", progress: true }); */ Ext.getBody().mask('Loading current obituary schedules.'); var scripts = [ {file: 'fw_obitschedule.js.php', fn: 'obitschedules', text: 'Retrieving schedules.', status: .5} ]; var dest = "currentobitslist"; } system_loader(scripts, 0, srcdir, 'loadPanel', dest); } });