2013-04-01 94 views
0

我使用jscolor並注意到它會根據所選顏色自動更改文本顏色。示例:如果我選擇了黑色背景色,它會自動將文本顏色更改爲白色。反正有禁用此功能?JSColor自動文本顏色變化

+0

@BriceCoustillas - 謝謝刪除 – ncm

回答

0

儒略:

註釋出的代碼從JSColor

this.styleElement = target; // where to reflect current color 

以下行它調用設定目標輸入字段的樣式的功能。

0

試圖找到這樣的:

this.exportColor = function(flags) { 
      if(!(flags & leaveValue) && valueElement) { 
       var value = this.toString(); 
       if(this.caps) { value = value.toUpperCase(); } 
       if(this.hash) { value = '#'+value; } 
       valueElement.value = value; 
      } 
      if(!(flags & leaveStyle) && styleElement) { 
       styleElement.style.backgroundImage = "none"; 
       styleElement.style.backgroundColor = 
        '#'+this.toString(); 
       styleElement.style.color = 
        0.213 * this.rgb[0] + 
        0.715 * this.rgb[1] + 
        0.072 * this.rgb[2] 
        < 0.5 ? '#FFF' : '#000'; 
      } 
      if(!(flags & leavePad) && isPickerOwner()) { 
       redrawPad(); 
      } 
      if(!(flags & leaveSld) && isPickerOwner()) { 
       redrawSld(); 
      } 
     }; 

編輯這些行:

    styleElement.style.color = 
        0.213 * this.rgb[0] + 
        0.715 * this.rgb[1] + 
        0.072 * this.rgb[2] 
        < 0.5 ? '#FFF' : '#000'; 

到也許

   styleElement.style.color = 
        0.213 * this.rgb[0] + 
        0.715 * this.rgb[1] + 
        0.072 * this.rgb[2] 
        < 0.5 ? '#000' : '#000'; 
,如果你想讓它稍微整齊

styleElement.style.color = '#000'; 

這部作品隱藏文本完全

styleElement.style.color = 'transparent'; 
0

加入styleElement.style.color = 'transparent';可以從輸入字段中刪除文本值,但那麼它不會對「字體顏色」的工作屬性。

相反,我施加

styleElement.style.color = '#' + this.toString(); 

從輸入字段和字體顏色屬性此除去文本值也在努力。

感謝

0

發現下面的源文件代碼:

if (this.valueElement) { 
      if (jsc.isElementType(this.valueElement, 'input')) { 
       var updateField = function() { 
        THIS.fromString(THIS.valueElement.value, jsc.leaveValue); 
        jsc.dispatchFineChange(THIS); 
       }; 
       jsc.attachEvent(this.valueElement, 'keyup', updateField); 
       jsc.attachEvent(this.valueElement, 'input', updateField); 
       jsc.attachEvent(this.valueElement, 'blur', blurValue); 
       this.valueElement.setAttribute('autocomplete', 'off'); 
      } 
     } 

只是評論者的attachEvent 例如,如果你不想要的文本框,從顏色面板中選取顏色後更新它的背景色,只是評論「輸入」行。