DataObjects/Core_domain.php
[Pman.Core] / Pman.Dialog.CoreEmail.js
index bc72eb4..69318ef 100644 (file)
@@ -546,7 +546,7 @@ Pman.Dialog.CoreEmail = {
                 
                  if (action.type == 'setdata') {
                  
-                     setInterval(_this.form.findField('bodytext').autosave, 60000);
+                     setInterval(_this.form.findField('bodytext').autosave, 5000);
                      
                      _this.data.module = _this.data.module || 'crm_mailing_list_message';
                      
@@ -571,6 +571,9 @@ Pman.Dialog.CoreEmail = {
                  }
                  if (action.type == 'load') {
                      _this.dialog.el.unmask();
+                     
+                     _this.form.findField('bodytext').originalValue = _this.form.findField('bodytext').getValue();
+                     
                      return;
                  }
                  if (action.type =='submit') {
@@ -668,7 +671,6 @@ Pman.Dialog.CoreEmail = {
                      Roo.log('body dirty, auto save!');
                      
                      body.fireEvent('autosave', body);
-                         
                     
                  },
                  clearUp : false,
@@ -717,10 +719,44 @@ Pman.Dialog.CoreEmail = {
                  '|xns' : 'Roo.form',
                  xtype : 'HtmlEditor',
                  listeners : {
-                  savedpreview : function (_self)
+                  autosave : function (_self)
                    {
-                       Roo.log('saved preview');
+                       Roo.log('autosave');
+                       
+                       var id = _this.form.findField('id').getValue() * 1;
+                       
+                       /*
+                       if(!_self.editorcore.sourceEditMode){
+                           _self.syncValue();
+                       }else{
+                           _self.pushValue();
+                       }
+                       */
+                       
+                       new Pman.Request({
+                           url : baseURL + '/Roo/Events.php',
+                           method :'POST',
+                           params : {
+                               id : 0,
+                               action : 'AUTOSAVE',
+                               on_id : (id > 0) ? id : 0,
+                               on_table : 'crm_mailing_list_message',
+                               remarks : 'BODY',
+                               source: _self.getValue()
+                           },
+                           success : function() {
+                               _self.originalValue = _self.getValue();
+                               
+                           },
+                           failure : function() 
+                           {
+                               Roo.log('body autosave failed?!');
+                           }
+                       });
                        
+                   },
+                  savedpreview : function (_self)
+                   {
                        var id = _this.form.findField('id').getValue() * 1;
                        
                        var successFn = function(res){
@@ -925,6 +961,7 @@ Pman.Dialog.CoreEmail = {
                      xtype : 'Separator'
                     },
                     {
+                     cls : 'x-init-enable',
                      text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
                      xns : Roo.Toolbar,
                      '|xns' : 'Roo.Toolbar',
@@ -933,6 +970,7 @@ Pman.Dialog.CoreEmail = {
                       click : function (_self, e)
                        {
                            this.scope.owner.fireEvent('savedpreview', this.scope.owner);
+                           
                        }
                      }
                     }