[ Index ]

PHP Cross Reference of Nuke-Evolution v2.0.5

title

Body

[close]

/themes/ -> rmw_jslib.js (source)

   1  /*
   2  
   3     "Resize Posted Images Based on Max Width" 2.4.5
   4     A phpBB MOD originally created by Christian Fecteau.
   5  
   6     This MOD is copyright (c) Christian Fecteau 2004-2005
   7  
   8     This MOD is released under the Creative Commons licence:
   9     http://creativecommons.org/licenses/by-nc-sa/2.0/
  10     Read carefully this licence before making any use of my code.
  11  
  12     Credits must be given with my full name (Christian Fecteau)
  13     and a link to my portfolio: http://portfolio.christianfecteau.com/
  14  
  15     Removal or alteration of this notice is strongly prohibited.
  16  
  17  */
  18  
  19  // don't change anything below
  20  
  21  function rmw_go()
  22  {
  23      var rmw_img_array = document.getElementsByTagName("IMG");
  24      for (var i = 0; i < rmw_img_array.length; i++)
  25      {
  26          var rmw_img = rmw_img_array[i];
  27          if (String(rmw_img.getAttribute('resizemod')) == 'on')
  28          {
  29              if (rmw_wait_for_width && rmw_img.width && !isNaN(rmw_img.width))
  30              {
  31                  if ((rmw_img.width > Number(rmw_max_width)) || (rmw_img.height > Number(rmw_max_height)))
  32                  {
  33                      rmw_img.setAttribute('resizemod','off');
  34                      rmw_img.onload = null;
  35                      rmw_img.removeAttribute('onload');
  36                      var rmw_clone = rmw_img.cloneNode(false);
  37                      var rmw_parent = rmw_img.parentNode;
  38                      rmw_clone.setAttribute('width',String(rmw_max_width));
  39                      rmw_parent.replaceChild(rmw_clone,rmw_img);
  40                      rmw_make_pop(rmw_clone, rmw_img.width, rmw_img.height);
  41                  }
  42              }
  43              else if (!rmw_wait_for_width)
  44              {
  45                  if ((rmw_img.width > Number(rmw_max_width)) || (rmw_img.height > Number(rmw_max_height))) {
  46                      rmw_img.setAttribute('resizemod','off');
  47                      var rmw_clone = rmw_img.cloneNode(false);
  48                      rmw_img.onload = null;
  49                      rmw_img.removeAttribute('onload');
  50                      var rmw_parent = rmw_img.parentNode;
  51                      var rmw_ind = rmw_count++;
  52                      rmw_clone.setAttribute('resizemod',String(rmw_ind));
  53                      rmw_preload[rmw_ind] = new Image();
  54                      rmw_preload[rmw_ind].src = rmw_img.src;
  55                      if (window.showModelessDialog)
  56                      {
  57                          rmw_clone.style.margin = '2px';
  58                      }
  59                      rmw_clone.style.border = rmw_border_1;
  60                      rmw_clone.style.width = '28px';
  61                      rmw_parent.replaceChild(rmw_clone,rmw_img);
  62                      rmw_make_pop(rmw_clone, rmw_img.width, rmw_img.height);
  63                  }
  64              }
  65          }
  66      }
  67      if (!rmw_over && document.getElementById('resizemod'))
  68      {
  69          rmw_over = true;
  70          rmw_go();
  71      }
  72      else if (!rmw_over)
  73      {
  74          window.setTimeout('rmw_go()',2000);
  75      }
  76  }
  77  function rmw_img_loaded(rmw_obj)
  78  {
  79      if (!document.getElementsByTagName || !document.createElement) {return;}
  80      var rmw_att = String(rmw_obj.getAttribute('resizemod'));
  81      var rmw_real_width = false;
  82      if ((rmw_att != 'on') && (rmw_att != 'off'))
  83      {
  84          var rmw_index = Number(rmw_att);
  85          if (rmw_preload[rmw_index].width)
  86          {
  87              rmw_real_width = rmw_preload[rmw_index].width;
  88              rmw_real_height = rmw_preload[rmw_index].height;
  89          }
  90      }
  91      else
  92      {
  93          rmw_obj.setAttribute('resizemod','off');
  94          if (rmw_obj.width)
  95          {
  96              rmw_real_width = rmw_obj.width;
  97              rmw_real_height = rmw_obj.height;
  98          }
  99      }
 100      if (!rmw_real_width || isNaN(rmw_real_width) || (rmw_real_width <= 0))
 101      {
 102          var rmw_rand1 = String(rmw_count++);
 103          eval("rmw_retry" + rmw_rand1 + " = rmw_obj;");
 104          eval("window.setTimeout('rmw_img_loaded(rmw_retry" + rmw_rand1 + ")',2000);");
 105          return;
 106      }
 107      if ((rmw_real_width > Number(rmw_max_width)) || (rmw_real_height > Number(rmw_max_height)))
 108      {
 109          if (window.showModelessDialog)
 110          {
 111              rmw_obj.style.margin = '2px';
 112          }
 113          rmw_make_pop(rmw_obj, rmw_real_width, rmw_real_height);
 114      }
 115      else if (!rmw_wait_for_width)
 116      {
 117          rmw_obj.style.width = String(rmw_real_width) + 'px';
 118          rmw_obj.style.border = '0';
 119          if (window.showModelessDialog)
 120          {
 121              rmw_obj.style.margin = '0px';
 122          }
 123      }
 124      if (window.ActiveXObject) // IE on Mac and Windows
 125      {
 126          window.clearTimeout(rmw_timer1);
 127          rmw_timer1 = window.setTimeout('rmw_refresh_tables()',10000);
 128      }
 129  }
 130  function rmw_refresh_tables()
 131  {
 132      var rmw_tables = document.getElementsByTagName("TABLE");
 133      for (var j = 0; j < rmw_tables.length; j++)
 134      {
 135          rmw_tables[j].refresh();
 136      }
 137  }
 138  function rmw_make_pop(rmw_ref, width, height)
 139  {
 140      rmw_ref.style.border = rmw_border_2;
 141      if ((width > rmw_max_width) && (height > rmw_max_height)) {
 142          if (width > height) {
 143              rmw_ref.style.width = String(rmw_max_width) + 'px';
 144              off = rmw_max_width / width;
 145              percent = Math.round(height * off);
 146              if (percent > 0) {
 147                  rmw_ref.style.height = String(percent) + 'px';
 148              } else {
 149                  rmw_ref.style.height = String(height) + 'px';
 150              }
 151          } else {
 152              rmw_ref.style.height = String(rmw_max_height) + 'px';
 153              off = rmw_max_height / height;
 154              percent = Math.round(width * off);
 155              if (percent > 0) {
 156                  rmw_ref.style.width = String(percent) + 'px';
 157              } else {
 158                  rmw_ref.style.width = String(width) + 'px';
 159              }
 160          }
 161      } else if (width > rmw_max_width){
 162          rmw_ref.style.width = String(rmw_max_width) + 'px';
 163          off = rmw_max_width / width;
 164          percent = Math.round(height * off);
 165          if (percent > 0) {
 166              rmw_ref.style.height = String(percent) + 'px';
 167          } else {
 168              rmw_ref.style.height = String(height) + 'px';
 169          }
 170      } else if (height > rmw_max_height){
 171          rmw_ref.style.height = String(rmw_max_height) + 'px';
 172          off = rmw_max_height / height;
 173          percent = Math.round(width * off);
 174          if (percent > 0) {
 175              rmw_ref.style.width = String(percent) + 'px';
 176          } else {
 177              rmw_ref.style.width = String(width) + 'px';
 178          }
 179      }
 180  
 181      if (!window.opera)
 182      {
 183          rmw_ref.onclick = function()
 184          {
 185              if (!rmw_pop.closed)
 186              {
 187                  rmw_pop.close();
 188              }
 189              rmw_pop = window.open('about:blank','christianfecteaudotcom',rmw_pop_features);
 190              if (height == 0) {
 191                  height = window.screen.availHeight;
 192              } else if (height > window.screen.availHeight) {
 193                  height = window.screen.availHeight;
 194              }
 195              if (width == 0) {
 196                  width = window.screen.availWidth;
 197              } else if (width > window.screen.availWidth) {
 198                  width = window.screen.availWidth;
 199              }
 200              rmw_pop.resizeTo(width,height);
 201              rmw_pop.moveTo(0,0);
 202              rmw_pop.focus();
 203              rmw_pop.location.href = this.src;
 204          }
 205      }
 206      else
 207      {
 208          var rmw_rand2 = String(rmw_count++);
 209          eval("rmw_pop" + rmw_rand2 + " = new Function(\"rmw_pop = window.open('" + rmw_ref.src + "','christianfecteaudotcom','" + rmw_pop_features + "'); if (rmw_pop) {rmw_pop.focus();}\")");
 210          eval("rmw_ref.onclick = rmw_pop" + rmw_rand2 + ";");
 211      }
 212      document.all ? rmw_ref.style.cursor = 'hand' : rmw_ref.style.cursor = 'pointer';
 213      rmw_ref.title = rmw_image_title;
 214      if (window.showModelessDialog)
 215      {
 216          rmw_ref.style.margin = '0px';
 217      }
 218  }
 219  if (document.getElementsByTagName && document.createElement) // W3C DOM browsers
 220  {
 221      rmw_preload = new Array();
 222      if (window.GeckoActiveXObject || window.showModelessDialog) // Firefox, NN7.1+, and IE5+ for Win
 223      {
 224          rmw_wait_for_width = false;
 225      }
 226      else
 227      {
 228          rmw_wait_for_width = true;
 229      }
 230      rmw_pop_features = 'top=0,left=0,width=' + String(window.screen.width-80) + ',height=' + String(window.screen.height-190) + ',scrollbars=1,resizable=1';
 231      rmw_over = false;
 232      rmw_count = 1;
 233      rmw_timer1 = null;
 234      if (!window.opera)
 235      {
 236          rmw_pop = new Object();
 237          rmw_pop.closed = true;
 238          rmw_old_onunload = window.onunload;
 239          window.onunload = function()
 240          {
 241              /*if (rmw_old_onunload)
 242              {
 243                  rmw_old_onunload();
 244                  rmw_old_onunload = null;
 245              }*/
 246              if (!rmw_pop.closed)
 247              {
 248                  rmw_pop.close();
 249              }
 250          }
 251      }
 252      //window.setTimeout('rmw_go()',2000);
 253  }
 254  
 255  if (window.addEventListener)
 256      window.addEventListener("load", rmw_go, false)
 257  else if (window.attachEvent)
 258      window.attachEvent("onload", rmw_go)
 259  else if (document.getElementById)
 260      womAdd('rmw_go()');


Generated: Wed Jun 6 11:38:01 2007 Cross-referenced by PHPXref 0.7