[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/filemanager/ImageManager/assets/ -> editor.js (source)

   1  /**
   2   * Functions for the ImageEditor interface, used by editor.php only    
   3   * @author $Author: Wei Zhuo $
   4   * @version $Id: editor.js 26 2004-03-31 02:35:21Z Wei Zhuo $
   5   * @package ImageManager
   6   */
   7  
   8      var current_action = null;
   9      var actions = ['crop', 'scale', 'rotate', 'measure', 'save'];
  10      var orginal_width = null, orginal_height=null;
  11  	function toggle(action) 
  12      {
  13          if(current_action != action)
  14          {
  15  
  16              for (var i in actions)
  17              {
  18                  if(actions[i] != action)
  19                  {
  20                      var tools = document.getElementById('tools_'+actions[i]);
  21                      tools.style.display = 'none';
  22                      var icon = document.getElementById('icon_'+actions[i]);
  23                      icon.className = '';
  24                  }
  25              }
  26  
  27              current_action = action;
  28              
  29              var tools = document.getElementById('tools_'+action);
  30              tools.style.display = 'block';
  31              var icon = document.getElementById('icon_'+action);
  32              icon.className = 'iconActive';
  33  
  34              var indicator = document.getElementById('indicator_image');
  35              indicator.src = 'img/'+action+'.gif';
  36  
  37              editor.setMode(current_action);
  38  
  39              //constraints on the scale,
  40              //code by Frédéric Klee <fklee@isuisse.com>
  41              if(action == 'scale') 
  42              {
  43                  var theImage = editor.window.document.getElementById('theImage');
  44                  orginal_width = theImage.width ;
  45                  orginal_height = theImage.height;
  46  
  47                  var w = document.getElementById('sw');
  48                  w.value = orginal_width ;
  49                  var h = document.getElementById('sh') ;
  50                  h.value = orginal_height ;
  51              }
  52  
  53          }
  54      }
  55  
  56  	function toggleMarker() 
  57      {
  58          var marker = document.getElementById("markerImg");
  59          
  60          if(marker != null && marker.src != null) {
  61              if(marker.src.indexOf("t_black.gif") >= 0)
  62                  marker.src = "img/t_white.gif";
  63              else
  64                  marker.src = "img/t_black.gif";
  65  
  66              editor.toggleMarker();
  67          }
  68      }
  69  
  70      //Togggle constraints, by Frédéric Klee <fklee@isuisse.com>
  71  	function toggleConstraints() 
  72      {
  73          var lock = document.getElementById("scaleConstImg");
  74          var checkbox = document.getElementById("constProp");
  75          
  76          if(lock != null && lock.src != null) {
  77              if(lock.src.indexOf("unlocked2.gif") >= 0)
  78              {
  79                  lock.src = "img/islocked2.gif";
  80                  checkbox.checked = true;
  81                  checkConstrains('width');
  82  
  83              }
  84              else
  85              {
  86                  lock.src = "img/unlocked2.gif";
  87                  checkbox.checked = false;
  88              }
  89          }
  90      }
  91      
  92      //check the constraints, by Frédéric Klee <fklee@isuisse.com>
  93  	function checkConstrains(changed) 
  94      {
  95          var constrained = document.getElementById('constProp');
  96          if(constrained.checked) 
  97          {
  98              var w = document.getElementById('sw') ;
  99              var width = w.value ;
 100              var h = document.getElementById('sh') ;
 101              var height = h.value ;
 102              
 103              if(orginal_width > 0 && orginal_height > 0) 
 104              {
 105                  if(changed == 'width' && width > 0) 
 106                      h.value = parseInt((width/orginal_width)*orginal_height);
 107                  else if(changed == 'height' && height > 0) 
 108                      w.value = parseInt((height/orginal_height)*orginal_width);
 109              }
 110          }
 111          
 112          updateMarker('scale') ;
 113      }
 114  
 115  
 116  	function updateMarker(mode) 
 117      {
 118          if (mode == 'crop')
 119          {
 120              var t_cx = document.getElementById('cx');
 121              var t_cy = document.getElementById('cy');
 122              var t_cw = document.getElementById('cw');
 123              var t_ch = document.getElementById('ch');
 124  
 125              editor.setMarker(parseInt(t_cx.value), parseInt(t_cy.value), parseInt(t_cw.value), parseInt(t_ch.value));
 126          }
 127          else if(mode == 'scale') {
 128              var s_sw = document.getElementById('sw');
 129              var s_sh = document.getElementById('sh');
 130              editor.setMarker(0, 0, parseInt(s_sw.value), parseInt(s_sh.value));
 131          }
 132      }
 133  
 134      
 135  	function rotatePreset(selection) 
 136      {
 137          var value = selection.options[selection.selectedIndex].value;
 138          
 139          if(value.length > 0 && parseInt(value) != 0) {
 140              var ra = document.getElementById('ra');
 141              ra.value = parseInt(value);
 142          }
 143      }
 144  
 145  	function updateFormat(selection) 
 146      {
 147          var selected = selection.options[selection.selectedIndex].value;
 148  
 149          var values = selected.split(",");
 150          if(values.length >1) {
 151              updateSlider(parseInt(values[1]));
 152          }
 153  
 154      }
 155  	function addEvent(obj, evType, fn)
 156      { 
 157          if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; } 
 158          else if (obj.attachEvent) {  var r = obj.attachEvent("on"+evType, fn);  return r;  } 
 159          else {  return false; } 
 160      } 
 161  
 162      init = function()
 163      {
 164          var bottom = document.getElementById('bottom');
 165          if(window.opener)
 166          {
 167              __dlg_init(bottom);
 168              __dlg_translate(I18N);
 169          }
 170      }
 171  
 172      addEvent(window, 'load', init);


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7