Changeset 775 for branches/ray/modules


Ignore:
Timestamp:
03/13/07 12:47:30 (13 years ago)
Author:
ray
Message:

update branch with changes from trunk

Location:
branches/ray/modules
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/ray/modules/ColorPicker/ColorPicker.js

    r762 r775  
    143143    td.unselectable = "on"; 
    144144    td.style.MozUserSelect = "none"; 
     145    td.style.cursor = "default"; 
    145146    td.appendChild(document.createTextNode(Xinha._lc('Click a color...'))); 
    146147    td.style.borderBottom = '1px solid WindowFrame'; 
     
    319320      return colors; 
    320321    } 
    321  
     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    } 
    322334    /** Open the color picker 
    323335     * 
     
    343355      } 
    344356 
     357      Xinha._addEvent(document.body,'mousedown',closeOnBodyClick); 
     358       
    345359      // Find position of the element 
    346360      this.table.style.position = 'absolute'; 
     
    357371 
    358372      var x, y; 
    359       if(/top/.test(anchorage)) 
     373      if(/top/.test(anchorage) || (top + this.table.offsetHeight > document.body.offsetHeight)) 
    360374      { 
    361375        if(top - this.table.offsetHeight > 0) 
     
    373387      } 
    374388 
    375       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 
    376401      { 
    377402        this.table.style.left = left + 'px'; 
    378       } 
    379       else 
    380       { 
    381         if(left - (this.table.offsetWidth - element.offsetWidth) > 0) 
    382         { 
    383           this.table.style.left = (left - (this.table.offsetWidth - element.offsetWidth)) + 'px'; 
    384         } 
    385         else 
    386         { 
    387                   this.table.style.left = 0; 
    388         } 
    389403      } 
    390404     // IE ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker 
     
    779793    this.close = function() 
    780794    { 
     795      Xinha._removeEvent(document.body,'mousedown',closeOnBodyClick); 
    781796      this.table.style.display = 'none'; 
    782797      // IE ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker 
     
    831846  return Xinha._lc(string); 
    832847} 
    833 Xinha.colorPicker.inputBinding = function(input) 
     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) 
    834859{ 
    835860  var main = document.createElement('span'); 
     
    838863  var chooser = this.chooser = document.createElement('span'); 
    839864  chooser.className = "chooser"; 
    840   chooser.onmouseover = function() {main.style.borderColor='black';chooser.style.borderColor='black'}; 
    841   chooser.onmouseout = function() {main.style.borderColor='ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight',chooser.style.borderColor='ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight'}; 
     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";}; 
    842868  chooser.appendChild(document.createTextNode('\u00a0')); 
    843869  main.appendChild(chooser); 
    844870  var clearColor = document.createElement('span'); 
    845871  clearColor.className = "nocolor"; 
    846   clearColor.onmouseover = function() {clearColor.style.color='#f00'}; 
    847   clearColor.onmouseout = function() {clearColor.style.color='#000'}; 
     872  clearColor.onmouseover = function() {clearColor.className = "nocolor buttonColor-hilite"; clearColor.style.color='#f00'}; 
     873  clearColor.onmouseout = function() {clearColor.className = "nocolor"; clearColor.style.color='#000'}; 
    848874  clearColor.onclick = function() {input.value ='';chooser.style.backgroundColor = ''}; 
    849875  clearColor.appendChild(document.createTextNode('\u00d7')); 
     
    853879   
    854880  Xinha._addEvent(input,'change',function() {chooser.style.backgroundColor = this.value;}) 
    855    
     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 
    856885  chooser.onclick = function()  
    857886  {  
    858           var colPicker = new Xinha.colorPicker({cellsize:'5px',callback:function(color) {chooser.style.backgroundColor = color;input.value=color}}); 
    859           colPicker.open('left',chooser, input.value );  
     887    var colPicker = new Xinha.colorPicker(pickerConfig); 
     888          colPicker.open("",chooser, input.value );  
    860889  } 
    861890} 
    862 Xinha.colorPicker.inputBinding.prototype.setColor = function(color) 
     891Xinha.colorPicker.InputBinding.prototype.setColor = function (color) 
    863892{ 
    864893  this.chooser.style.backgroundColor = color; 
  • branches/ray/modules/Gecko/Gecko.js

    r761 r775  
    739739   
    740740  return result; 
    741 } 
     741}; 
     742 
     743/** Return the doctype of a document, if set 
     744 *  
     745 * @param doc DOM element document 
     746 * @returns string the actual doctype 
     747 */ 
     748Xinha.getDoctype = function (doc) 
     749{ 
     750  var d = ''; 
     751  if (doc.doctype) 
     752  { 
     753    d += '<!DOCTYPE ' + doc.doctype.name + " PUBLIC "; 
     754    d +=  doc.doctype.publicId ? '"' + doc.doctype.publicId + '"' : '';   
     755    d +=  doc.doctype.systemId ? ' "'+ doc.doctype.systemId + '"' : '';  
     756    d += ">"; 
     757  } 
     758  return d; 
     759}; 
  • branches/ray/modules/InsertTable/InsertTable.js

    r762 r775  
    8787        dialog.getElementById('cancel').onclick = function() { self.dialog.hide()}; 
    8888   
    89         this.borderColorPicker = new Xinha.colorPicker.inputBinding(dialog.getElementById('border_color')); 
     89        this.borderColorPicker = new Xinha.colorPicker.InputBinding(dialog.getElementById('border_color')); 
    9090 
    9191        this.dialog.onresize = function () 
  • branches/ray/modules/InternetExplorer/InternetExplorer.js

    r761 r775  
    458458  if ( target == 'textarea' ) this._textArea.focus(); 
    459459}; 
     460 
     461/** Return a doctype or empty string depending on whether the document is in Qirksmode or Standards Compliant Mode 
     462 *  It's hardly possible to detect the actual doctype without unreasonable effort, so we set HTML 4.01 just to trigger the rendering mode 
     463 *  
     464 * @param doc DOM element document 
     465 * @returns string doctype || empty 
     466 */ 
     467Xinha.getDoctype = function (doc) 
     468{ 
     469  return (doc.compatMode == "CSS1Compat") ? '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' : ''; 
     470}; 
Note: See TracChangeset for help on using the changeset viewer.