[제나플러스] cheditor5 에디터 - 모바일, 파이어폭스(파폭) 색상 문제 해결 방법 > 팁앤테크

본문 바로가기
사이트 내 전체검색

팁앤테크

[제나플러스] cheditor5 에디터 - 모바일, 파이어폭스(파폭) 색상 문제 해결 방법

페이지 정보

본문

cheditor5/cheditor.js 파일에서 아래 2가지를 수정/추가합니다.

1. 수정

changeFontColor 을 찾아 코드를 수정합니다. (빨강색 부분만 수정)


changeFontColor : function (color, type) {
 if (type == 'BackColor' && !GB.browser.msie) {
  type = 'HiliteColor';
 }
 this.doCmdPopup(type, this.colorConvert(color, 'hex'));
},


2. 추가

위 changeFontColor 코드  아래에 추가합니다. (사실 순서는 상관없습니다. 편한 곳에 붙여주세요,위아래 콤마주의)

changeFontColor : function (color, type) {  
 if (type == 'BackColor' && !GB.browser.msie) {
  type = 'HiliteColor';
 }
 this.doCmdPopup(type, this.colorConvert(color, 'hex'));
},
colorConvert : function (color, which, opacity) {
    if (!which) {
        which = "rgba";
 }
 
    color = color.replace( /^\s*#|\s*$/g, "" );
 if (color.length === 3) {
        color = color.replace( /(.)/g, "$1$1" );
 }
 
    color = color.toLowerCase();
 which = which.toLowerCase();
    
 var colorDefs = [{
        re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
            process: function (bits) {
                return [
                    parseInt(bits[1], 10),
                    parseInt(bits[2], 10),
                    parseInt(bits[3], 10),
                    1
                ];
            }
        },
        {
            re : /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d+(?:\.\d+)?|\.\d+)\s*\)/,
            process: function (bits) {
                return [
                    parseInt(bits[1], 10),
                    parseInt(bits[2], 10),
                    parseInt(bits[3], 10),
                    parseFloat(bits[4])
                ];
            }
        },
        {
            re: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
            process: function (bits) {
                return [
                    parseInt(bits[1], 16),
                    parseInt(bits[2], 16),
                    parseInt(bits[3], 16),
                    1
                ];
            }
        },
        {
            re: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
            process: function (bits) {
                return [
                    parseInt(bits[1] * 2, 16),
                    parseInt(bits[2] * 2, 16),
                    parseInt(bits[3] * 2, 16),
                    1
                ];
            }
        }
    ];
    var r, g, b, a, i, re, processor, bits, channels, min, rData;
            
    for (i = 0; i < colorDefs.length; i++) {
        re = colorDefs[i].re;
        processor = colorDefs[i].process;
        bits = re.exec(color);
        if (bits) {
            channels = processor(bits);
            r = channels[0];
            g = channels[1];
            b = channels[2];
            a = channels[3];
        }
    }
    
    r = (r < 0 || isNaN(r)) ? 0 : ((r > 255) ? 255 : r);
    g = (g < 0 || isNaN(g)) ? 0 : ((g > 255) ? 255 : g);
    b = (b < 0 || isNaN(b)) ? 0 : ((b > 255) ? 255 : b);
    a = (a < 0 || isNaN(a)) ? 0 : ((a > 1) ? 1 : a);
    
    function hex(x) {
        return ("0" + parseInt(x).toString(16)).slice(-2);
    }
    
    switch (which) {
        case "rgba":
            if (opacity) {
                a = (255 - (min = Math.min(r, g, b))) / 255;
                r = (0 || (r - min) / a).toFixed(0);
                g = (0 || (g - min) / a).toFixed(0);
                b = (0 || (b - min) / a).toFixed(0);
                a = a.toFixed(4);
            }
            rData = "rgba(" + r + "," + g + "," + b + "," + a + ")";
            break;
        case "rgb":
            rData = "rgb(" + r + "," + g + "," + b + ")";
            break;
        case "hex":
            rData = "#" + hex(r) + hex(g) + hex(b);
            break;
    }
    return rData;
},

getElement : function (elem, tag) { // 다른 함수일 수도 있어요.
     while (elem != null && elem.tagName != tag) {
          if (elem.nodeName == 'BODY') break;
          elem = elem.parentNode;
     }
     return elem;
},
추천0

댓글목록

등록된 댓글이 없습니다.

Total 825건 9 페이지
  • RSS
팁앤테크 목록
번호 제목 글쓴이 조회 추천 날짜
665 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 11584 0 02-20
664 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 10434 0 02-20
663 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 10872 0 02-10
662 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 13560 0 01-28
661 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 9908 0 01-28
660 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 10257 0 01-25
659 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 11642 0 01-23
658 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 17092 0 01-05
657 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 11182 0 12-19
656 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 12068 0 12-17
655 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 17886 0 12-02
654 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 17996 0 11-20
653 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 42371 0 11-19
652 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 14096 0 11-17
651 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 13854 0 11-17
650 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 11403 0 11-07
649 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 21527 0 10-24
648 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 15504 0 10-22
647 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 16791 0 10-07
646 제로쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 10549 0 07-02

검색

회원로그인

회원가입

사이트 정보

株式会社YHPLUS / 대표 : ZERO
〒140-0011 東京都品川区東大井2-5-9-203
050-5539-7787
오픈카카오톡 (YHPLUS) :
https://open.kakao.com/o/slfDj15d

접속자집계

오늘
3,013
어제
4,566
최대
6,509
전체
1,067,674
Copyright (c) 株式会社YHPLUS. All rights reserved.