[ Index ]
 

Code source de Phorum 5.1.25

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/mods/editor_tools/ -> smileys_js.php (source)

   1  <?php if(!defined("PHORUM")) return; ?>
   2  
   3  <script type="text/javascript">
   4  
   5  /* ------------------------------------------------------------------------
   6   * Javascript functions for Smiley tools.
   7   * ------------------------------------------------------------------------ 
   8   */
   9  
  10  var smileys_state = -1;
  11  var smileys_count = 0;
  12  var loaded_count = 0;
  13  var loadingobj;
  14  
  15  function toggle_smileys()
  16  {
  17      // On the first request to open the smiley help, load all smiley images.
  18      if (smileys_state == -1) 
  19      {
  20          // Load smiley images.
  21          <?php
  22          $smileys_count = 0;
  23          $c = '';
  24          foreach ($PHORUM["mod_smileys"]["smileys"] as $id => $smiley) {
  25              if (! $smiley["active"] || $smiley["is_alias"] || $smiley["uses"] == 1) continue;
  26              $smileys_count ++;
  27              $src = htmlspecialchars($prefix . $smiley['smiley']);
  28              $c.="document.getElementById('smiley-button-{$id}').src='$src';\n";
  29          }
  30          print "smileys_count = $smileys_count;\n$c\n"; 
  31          ?>
  32  
  33          smileys_state = 0;
  34      }
  35  
  36      // Toggle smiley panel.
  37      smileys_state = ! smileys_state;
  38      if (smileys_state) show_smileys(); else hide_smileys();
  39  }
  40  
  41  function show_smileys()
  42  {
  43      // We wait with displaying the smiley help until all smileys are loaded.
  44      if (loaded_count < smileys_count) return false;
  45  
  46      document.getElementById('phorum_mod_editor_tools_smileys').style.display = 'block';
  47      document.getElementById('phorum_mod_editor_tools_smileys_dots').style.display = 'none';
  48      return false;
  49  }
  50  
  51  function hide_smileys()
  52  {
  53      document.getElementById('phorum_mod_editor_tools_smileys').style.display = 'none';
  54      document.getElementById('phorum_mod_editor_tools_smileys_dots').style.display = 'inline';
  55      return false;
  56  }
  57  
  58  function phorum_mod_smileys_insert_smiley(string) 
  59  {
  60      var area = document.getElementById("phorum_textarea");
  61      string = unescape(string);
  62      
  63      if (area) 
  64      {
  65          if (area.createTextRange) /* MSIE */
  66          {
  67              area.focus(area.caretPos);
  68              area.caretPos = document.selection.createRange().duplicate();
  69              curtxt = area.caretPos.text;
  70              area.caretPos.text = string + curtxt;
  71          } 
  72          else /* Other browsers */
  73          {
  74              var pos = area.selectionStart;              
  75              area.value = 
  76                  area.value.substring(0,pos) + 
  77                  string +
  78                  area.value.substring(pos);
  79              area.focus();
  80              area.selectionStart = pos + string.length;
  81              area.selectionEnd = area.selectionStart;
  82          }
  83      } else {
  84          alert('There seems to be a technical problem. The textarea ' +
  85                'cannot be found in the page. ' +
  86                'The textarea should have id="phorum_textarea" in the ' +
  87                'definition for this feature to be able to find it. ' +
  88                'If you are not the owner of this forum, then please ' +
  89                'alert the forum owner about this.');
  90      }
  91  }
  92  
  93  function phorum_mod_smileys_load_smiley (imgobj)
  94  {
  95      loadingobj = document.getElementById('phorum_mod_editor_tools_smileys_loading');
  96  
  97      // Another smiley image was loaded. If we have loaded all
  98      // smiley images, then show the smileys panel.
  99      if (imgobj.src != '') {
 100          loaded_count ++;
 101          imgobj.onload = '';
 102          if (loaded_count == smileys_count) {
 103              loadingobj.style.display = 'none';
 104              show_smileys();
 105          } else {
 106              // Visual feedback for the user while loading the images.
 107              loadingobj.style.display = 'inline';
 108              loadingobj.innerHTML = "("
 109                + "<?php print $PHORUM["DATA"]["LANG"]["LoadingSmileys"]; ?> "
 110                + Math.floor(loaded_count/smileys_count*100) + "%)";
 111          }
 112      }
 113  }
 114  
 115  </script>


Généré le : Thu Nov 29 12:22:27 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics