[ Index ]

MailPress 7.2

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

title

Body

[close]

/mp-includes/js/ -> mp_refresh_i.js (source)

   1  var mp_refresh = {
   2      reg         : new RegExp("(%i%)", "g"),
   3      message     : '',
   4  
   5      div : '<div id="mailpress-refresh-counter-wrap"></div>',
   6      button : '<button type="button" id="mailpress-refresh-link" class="button show-settings mp_refresh">%i%</button>',
   7      span : '<span id="mp_refresh_chrono">%i%</span>',
   8  
   9      slide        : 2,
  10      slideTime    : 2,
  11      lastScroll     : 10000000,
  12      newScroll     : 0,
  13  
  14      init  : function() {
  15  
  16      // adding form in Screen Options 
  17          adminMpRefreshL10n.option = adminMpRefreshL10n.option.replace(/\&gt;/g,'>').replace(/\&lt;/g,'<');
  18          if (jQuery('div#tab-panel-autorefresh')) jQuery('div#tab-panel-autorefresh').append(adminMpRefreshL10n.option);
  19          else                      jQuery('#screen-options-wrap').append(adminMpRefreshL10n.option);
  20  
  21      // adding button
  22          jQuery('#screen-meta-links').append(mp_refresh.div);
  23          mp_refresh.message = mp_refresh.button.replace(mp_refresh.reg, adminMpRefreshL10n.message.replace(mp_refresh.reg, mp_refresh.span ));
  24          //mp_refresh.message = mp_refresh.button.replace(mp_refresh.reg, adminMpRefreshL10n.message.replace(mp_refresh.reg, "%i%"));
  25  
  26      // checked checkbox
  27          if (jQuery('#MP_Refresh').is(':checked')) mp_refresh.start();
  28      // onchange checkbox
  29          jQuery('#MP_Refresh').change( function() { (jQuery('#MP_Refresh').is(':checked')) ? mp_refresh.start() : mp_refresh.stop(); } );
  30      // onclick message
  31          jQuery('div#mailpress-refresh-counter-wrap').click( function() { mp_refresh.stop(); } );
  32  
  33      // onload iframe
  34          jQuery('iframe#' + adminMpRefreshL10n.iframe).load(function() { mp_refresh.scrolldown(); } );
  35      // onresize window
  36          mp_refresh.resize(15);
  37          jQuery(window).resize( function() { mp_refresh.resize(15); } );
  38      },
  39  
  40      get_time : function() {
  41          var time = jQuery('input#MP_Refresh_every').val();
  42          time     = (isNaN(time)) ? adminMpRefreshL10n.every : time;
  43          time      = (adminMpRefreshL10n.every > time) ? adminMpRefreshL10n.every : time;
  44          jQuery('input#MP_Refresh_every').val(time);
  45          return time;
  46      },
  47  
  48      start : function() {
  49          var message = mp_refresh.message.replace(mp_refresh.reg, mp_refresh.get_time());
  50          mp_refresh.display(message);
  51  
  52          jQuery.schedule({    id    : 'mp_refresh.update',
  53                      time    : 1000, 
  54                      func    : mp_refresh.update,
  55                      repeat  : true, 
  56                      protect : true
  57          });
  58      },
  59  
  60      stop : function() {
  61          jQuery.cancel( 'mp_refresh.update' );
  62          jQuery('#MP_Refresh').attr('checked',false);
  63          mp_refresh.display('');
  64      },
  65  
  66      update : function() {
  67          var time = jQuery('span#mp_refresh_chrono').html();
  68          if (isNaN(time)) return;
  69          time--;
  70          var message = mp_refresh.message.replace(mp_refresh.reg, time);
  71          mp_refresh.display(message);
  72  
  73          if (time == (mp_refresh.get_time() -1))
  74          {
  75              //# ajax
  76              jQuery.ajax({
  77                  data: {z:0},
  78                  beforeSend: null,
  79                  type: "POST",
  80                  url: adminMpRefreshL10n.url,
  81                  success: null
  82              });
  83          }
  84          if (time > 0) return;
  85          mp_refresh.refresh();
  86      },
  87  
  88      display : function(message) {
  89          jQuery('div#mailpress-refresh-counter-wrap').html(message);
  90      },
  91  
  92      refresh : function() {
  93          jQuery('iframe#mp').attr('src', adminMpRefreshL10n.src);
  94          jQuery('span#mp_refresh_chrono').html(mp_refresh.get_time());
  95      },
  96  
  97      scrolldown : function() {
  98          var h_viewport = jQuery('iframe#' + adminMpRefreshL10n.iframe).innerHeight();
  99          var h_iframe   = window[adminMpRefreshL10n.iframe].document.body.scrollHeight;
 100          mp_refresh.newScroll = h_iframe - h_viewport + 100;
 101          window[adminMpRefreshL10n.iframe].scrollTo(0, (mp_refresh.lastScroll));
 102          jQuery.schedule({ id    : 'mp_refresh.slideUp',
 103                      time    : mp_refresh.slideTime,
 104                      func     : mp_refresh.slideUp,
 105                      repeat: true, 
 106                      protect: true
 107          });
 108      },
 109  
 110      slideUp : function() {
 111          mp_refresh.lastScroll = mp_refresh.lastScroll + mp_refresh.slide;
 112          window[adminMpRefreshL10n.iframe].scrollTo(0, (mp_refresh.lastScroll));
 113          if (mp_refresh.lastScroll >= mp_refresh.newScroll)
 114          {
 115              jQuery.cancel( 'mp_refresh.slideUp' );
 116              mp_refresh.lastScroll = mp_refresh.newScroll;
 117          }
 118      },
 119  
 120      resize : function(h) {
 121          var i = document.getElementById(adminMpRefreshL10n.iframe);
 122          i.style.height = (document.documentElement.clientHeight - i.offsetTop) - h +"px";
 123          mp_refresh.scrolldown();
 124      }
 125  };
 126  jQuery(document).ready( function(){ mp_refresh.init(); } );


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