Ignore:
Timestamp:
03/12/07 20:25:19 (12 years ago)
Author:
ray
Message:

Ticket #980 ImageManager? color format bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/ColorPicker/ColorPicker.js

    r759 r770  
    132132    this.table.appendChild(this.tbody); 
    133133    this.table.style.border = '1px solid WindowFrame'; 
    134     this.table.style.zIndex = '1000'; 
     134    this.table.style.zIndex = '1050'; 
    135135    // Add a title bar and close button 
    136136    var tr = document.createElement('tr'); 
     
    141141    td.style.fontFamily = 'small-caption,caption,sans-serif'; 
    142142    td.style.fontSize = 'x-small'; 
     143    td.unselectable = "on"; 
     144    td.style.MozUserSelect = "none"; 
     145    td.style.cursor = "default"; 
    143146    td.appendChild(document.createTextNode(Xinha._lc('Click a color...'))); 
    144147    td.style.borderBottom = '1px solid WindowFrame'; 
     
    317320      return colors; 
    318321    } 
    319  
     322    var self = this; 
     323    function closeOnBodyClick (ev) 
     324    { 
     325      ev = ev ? ev : window.event; 
     326      el = ev.target ? ev.target : ev.srcElement; 
     327      do 
     328      { 
     329        if (el == self.table) return; 
     330      } 
     331      while (el = el.parentNode); 
     332      self.close(); 
     333    } 
    320334    /** Open the color picker 
    321335     * 
     
    341355      } 
    342356 
     357      Xinha._addEvent(document.body,'mousedown',closeOnBodyClick); 
     358       
    343359      // Find position of the element 
    344360      this.table.style.position = 'absolute'; 
     
    355371 
    356372      var x, y; 
    357       if(/top/.test(anchorage)) 
     373      if(/top/.test(anchorage) || (top + this.table.offsetHeight > document.body.offsetHeight)) 
    358374      { 
    359375        if(top - this.table.offsetHeight > 0) 
     
    371387      } 
    372388 
    373       if(/left/.test(anchorage)) 
     389      if(/left/.test(anchorage) || (left + this.table.offsetWidth > document.body.offsetWidth)) 
     390      { 
     391        if(left - (this.table.offsetWidth - element.offsetWidth) > 0 ) 
     392        { 
     393          this.table.style.left = (left - (this.table.offsetWidth - element.offsetWidth)) + 'px'; 
     394        } 
     395        else 
     396        { 
     397                  this.table.style.left = 0; 
     398        } 
     399      } 
     400      else 
    374401      { 
    375402        this.table.style.left = left + 'px'; 
    376       } 
    377       else 
    378       { 
    379         if(left - (this.table.offsetWidth - element.offsetWidth) > 0) 
    380         { 
    381           this.table.style.left = (left - (this.table.offsetWidth - element.offsetWidth)) + 'px'; 
    382         } 
    383         else 
    384         { 
    385                   this.table.style.left = 0; 
    386         } 
    387403      } 
    388404     // IE ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker 
     
    777793    this.close = function() 
    778794    { 
     795      Xinha._removeEvent(document.body,'mousedown',closeOnBodyClick); 
    779796      this.table.style.display = 'none'; 
    780797      // IE ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker 
     
    829846  return Xinha._lc(string); 
    830847} 
     848 
     849 
     850/** Create a neat little box next to an input field 
     851 *    * shows actual color 
     852 *    * opens colorPicker on click 
     853 *    * has a button to clear the color with a click 
     854 * 
     855 *  @param input (DOM element)  
     856 *  @param optional pickerConfig configuration object for Xinha.colorPicker() 
     857 */ 
     858Xinha.colorPicker.InputBinding = function(input,pickerConfig) 
     859{ 
     860  var main = document.createElement('span'); 
     861  main.className = "buttonColor"; 
     862   
     863  var chooser = this.chooser = document.createElement('span'); 
     864  chooser.className = "chooser"; 
     865  if (input.value) chooser.style.backgroundColor = input.value; 
     866  chooser.onmouseover = function() {chooser.className = "chooser buttonColor-hilite";}; 
     867  chooser.onmouseout = function() {chooser.className = "chooser";}; 
     868  chooser.appendChild(document.createTextNode('\u00a0')); 
     869  main.appendChild(chooser); 
     870  var clearColor = document.createElement('span'); 
     871  clearColor.className = "nocolor"; 
     872  clearColor.onmouseover = function() {clearColor.className = "nocolor buttonColor-hilite"; clearColor.style.color='#f00'}; 
     873  clearColor.onmouseout = function() {clearColor.className = "nocolor"; clearColor.style.color='#000'}; 
     874  clearColor.onclick = function() {input.value ='';chooser.style.backgroundColor = ''}; 
     875  clearColor.appendChild(document.createTextNode('\u00d7')); 
     876  main.appendChild(clearColor); 
     877   
     878  input.parentNode.insertBefore(main,input.nextSibling); 
     879   
     880  Xinha._addEvent(input,'change',function() {chooser.style.backgroundColor = this.value;}) 
     881 
     882  pickerConfig = (pickerConfig) ? Xinha.cloneObject(pickerConfig) : { cellsize:'5px' }; 
     883  pickerConfig.callback = (pickerConfig.callback) ? pickerConfig.callback : function(color) {chooser.style.backgroundColor = color;input.value=color}; 
     884 
     885  chooser.onclick = function()  
     886  {  
     887    var colPicker = new Xinha.colorPicker(pickerConfig); 
     888          colPicker.open("",chooser, input.value );  
     889  } 
     890} 
Note: See TracChangeset for help on using the changeset viewer.