Pman.Dialog.CoreEmail.bjs
[Pman.Core] / Pman.Dialog.CoreEmail.js
index 0049578..c73f782 100644 (file)
@@ -301,7 +301,7 @@ Pman.Dialog.CoreEmail = {
                       method: 'POST',
                       mask : "Loading",
                       params : {
-                            importUrl : l.protocol +'//' + l.host +   rootURL + '/Pman/Crm/mail_templates/responsive1.html',
+                            importUrl : l.protocol +'//' + l.host +   rootURL + '/Pman/Crm/mail_templates/responsive1.html'
                      },
                       success : function (res) {
               
@@ -471,6 +471,13 @@ Pman.Dialog.CoreEmail = {
            preValidate : function(done_callback) {
                
                Roo.MessageBox.progress("Uploading Images", "Uploading");
+               
+               if(!_this.form.findField('bodytext').editorcore.sourceEditMode){
+                   _this.form.findField('bodytext').syncValue();
+               }else{
+                   _this.form.findField('bodytext').pushValue();
+               }
+               
                var html = _this.form.findField('bodytext').getValue();
                
                var s = Roo.get(_this.form.findField('bodytext').editorcore.doc.documentElement);
@@ -500,7 +507,7 @@ Pman.Dialog.CoreEmail = {
                        return;
                    }
                    
-                   n = i.getAttribute('src').match(/^http(.*)/)
+                   n = i.getAttribute('src').match(/^http(.*)/);
                   
                    if(!n ){
                        mkimg();
@@ -683,7 +690,7 @@ Pman.Dialog.CoreEmail = {
                      'vertical-align',
                      'cursor',
                      'z-index',
-                     'right',
+                     'right'
                   ],
                  height : 250,
                  name : 'bodytext',
@@ -743,12 +750,23 @@ Pman.Dialog.CoreEmail = {
                                combo.setValue('');
                            }).defer(100);
                            var editor = _this.form.findField('bodytext').editorcore;
-                           editor.insertAtCursor(
+                           
+                           var curnode = editor.getSelectedNode();
+                           if (curnode && curnode.tagName == 'IMG') {
+                               curnode.src= String.format('{0}/Images/{1}/{2}#image-{1}',
+                                       baseURL,  record.data.id, record.data.filename
+                                   );
+                                   // note -forces an update... hopefully...
+                               editor.owner.fireEvent('editorevent', editor, false);
+                           } else {
+                           
+                               editor.insertAtCursor(
                                    String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
                                    baseURL,  record.data.id, record.data.filename
                                    )
-                            );
+                               );
                        
+                           }
                            
                         }
                      },
@@ -767,7 +785,7 @@ Pman.Dialog.CoreEmail = {
                                 Roo.MessageBox.alert("Error", "Save email template first");
                                 return false;
                             }
-                            o.params.onid = id
+                            o.params.onid = id;
                             o.params.ontable = (_this.data.module) ? _this.data.module : 'crm_mailing_list_message';
                             
                            // o.params.imgtype = 'PressRelease';
@@ -1221,10 +1239,10 @@ Pman.Dialog.CoreEmail = {
              var height = r.data.height;
              
              if(width > 50){
-                 width = 50;
                  height = Math.round(height * 50 / width);
+                 width = 50;
              }
-             Roo.log((height));
+             
             return '<img src="' + baseURL + '/Images/' + r.data.id + '/' + r.data.filename + '" width="' + width + '" height="' + height + '" />';
          },
          width : 300,