[ Index ]

MailPress 7.2

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/js/fileupload/ -> htm.js (source)

   1  if(!String.sprintf){String.sprintf=function(b){var a=Array.prototype.slice.call(arguments,1);return b.replace(/{(\d+)}/g,function(c,d){return typeof a[d]!="undefined"?a[d]:c})}};
   2  
   3  var mp_fileupload = {
   4  
   5      nbfiles : -1,
   6      class_icon : false,
   7  /*
   8      changed : function(id, file) {
   9          return true;
  10      },
  11  */
  12      parsexml : function(xml){
  13          xml = xml.replace(/\>/g,'>');
  14          xml = xml.replace(/\&lt;/g,'<');
  15          xml = xml.replace(/><!--\[CDATA\[/g,'><![CDATA[');
  16          xml = xml.replace(/\]\]--></g,']]><');
  17          if( window.ActiveXObject && window.GetObject ) {
  18              var dom = new ActiveXObject( 'Microsoft.XMLDOM' );
  19              dom.loadXML( xml );
  20              return dom;
  21          }
  22          if( window.DOMParser )
  23              return new DOMParser().parseFromString( xml, 'text/xml' );
  24          throw new Error( 'No XML parser available' );
  25      },
  26  
  27      loaded : function(id, filename, xml, oldid) {
  28          jQuery('span.mp_fileupload_txt').html();
  29          jQuery('iframe#mp_fileupload_iframe_' + oldid).remove();
  30          xml = mp_fileupload.parsexml(xml);
  31          var upload = jQuery(xml).find('mp_fileupload').each(function() {
  32              var error = jQuery(this).find('error').text();
  33              var id    = jQuery(this).find('id').text();
  34              var url   = jQuery(this).find('url').text();
  35              var file  = jQuery(this).find('file').text();
  36              if (error)
  37                  jQuery('#attachment-item-u-' + oldid).html(error);
  38              else
  39              {
  40                  jQuery('#attachment-item-u-' + oldid).replaceWith(mp_fileupload.html(filename, id, url, true ));
  41                  mp_fileupload.class_icon = false;
  42              }
  43          });
  44          jQuery('iframe#mp_fileupload_iframe_' + oldid).remove();
  45          mp_fileupload.add();
  46      var toto = 0;
  47      },
  48  
  49      html : function (name, id, url, ok) {
  50  
  51          var maybe = (ok) ? '<input type="checkbox" class="" disabled=disabled />' : '';
  52  
  53          if (name && !mp_fileupload.class_icon)
  54          {
  55              // ajax
  56              var f_data = { action: "mp_ajax", mp_action: "html_mail_icon", fname: name };
  57  
  58              jQuery.ajax({
  59                  data: f_data,
  60                  type: "POST",
  61                  url: htmuploadL10n.iframeurl,
  62                  async: false,
  63                  success: function( r ) { mp_fileupload.class_icon = r; if ( !mp_fileupload.class_icon ) mp_fileupload.class_icon = 'mp_ext mp_ext_unknown'; }
  64              });
  65          }
  66  
  67  
  68          var html = '';
  69  
  70          html += String.sprintf( '<div id="attachment-item-u-{0}" class="attachment-item child-of-{1}">', id, draft_id );
  71          html += '<table><tr><td>';
  72  
  73          html += ( url ) ?  String.sprintf( '<input type="checkbox" name="Files[{0}]" value="{0}" class="mp_fileupload_cb" checked="checked" />', id )
  74                  :  maybe;
  75  
  76          html += '</td><td>';
  77  
  78          html += ( url ) ? String.sprintf( '<div class="{0}"></div><div><a href="{2}" class="attachme" title="{1}">{1}</a></div>', mp_fileupload.class_icon, name, url )
  79                  : String.sprintf( '<div class="{0}"></div><div>{1}</div>', 'mp_ext_uploading', name );
  80  
  81          html += '</td></tr></table></div>';
  82          html += String.sprintf( '<div id="mp_htmlupload_input_file_{0}" class="hidden"></div>', id );
  83  
  84          return html;
  85      },
  86  
  87      submitted : function(id, file) {
  88          jQuery('span.mp_fileupload_txt').html(htmuploadL10n.uploading);
  89          jQuery('#attachment-items').append(mp_fileupload.html(file, id, false, true));
  90      },
  91  
  92      iframe_loaded : function(id) {
  93          var i = document.getElementById('mp_fileupload_iframe_' + id);
  94          i.onload = null;
  95          var count = jQuery('input.mp_fileupload_cb').size();
  96          jQuery('span.mp_fileupload_txt').html((count == 0)  ? htmuploadL10n.attachfirst : htmuploadL10n.attachseveral);
  97      },
  98  
  99      add    : function() {
 100          mp_fileupload.nbfiles++;
 101  
 102          var i = document.createElement('iframe');
 103          i.setAttribute('class', 'mp_fileupload_iframe');
 104          i.setAttribute('id', 'mp_fileupload_iframe_' + mp_fileupload.nbfiles);
 105          i.setAttribute('name', 'mp_fileupload_iframe_' + mp_fileupload.nbfiles);
 106          i.setAttribute('style', 'height:24px;width:132px;');
 107          i.setAttribute('onload', 'mp_fileupload.iframe_loaded('+ mp_fileupload.nbfiles + ')');
 108          iframeurl = htmuploadL10n.iframeurl + '?action=mp_ajax&mp_action=upload_iframe_html&draft_id=' + draft_id + '&id=' + mp_fileupload.nbfiles;
 109          i.setAttribute('src', iframeurl);
 110          i.style.height = '24px';
 111          i.style.width = '132px';
 112          i.style.overflow = 'hidden';
 113          var d = document.getElementById('mp_fileupload_file_div');
 114          d.appendChild(i);
 115      },
 116  
 117      init : function () {
 118          if (draft_id != 0)     mp_fileupload.add();
 119          else                 jQuery('#attachmentsdiv').hide();
 120      }
 121  };


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1