Rich Text (YUI-2.5.2) Editor Broken on IE11

1.1k Views Asked by At

I'm facing same issue mentioned in this link(Rich Text (YUI) Editor Broken on IE11 they have given solution for YUI(2.9) but I'm using YUI(2.5.2) in my application.I didn't find YAHOO.env.parseUA in yahoo-dom-event.js.I have searched for YAHOO.env.parseUA property in YUI(2.5.2) libraries.Can anyone suggest how to fix this for YUI(2.5.2).

3

There are 3 best solutions below

2
Paul Sweatte On

Use the following change to simple-editor.js:

  • Find all instances of this.browser.ie
  • Replace all with !!window.MSInputMethodContext || this.browser.ie
0
jacobfogg On

I'm using 2.7.0b on a legacy site. Just understand that none of these "fixes" will be exact for you unless you are using the exact version of the library. This is because as each one was "minimized" various characters were used for the sake of minimization. So you may have to do some hunting. ALSO, bear in mind, this may be different for you depending on if you are using yahoo.js by itself, yahoo-dom-event.js or as in my case, utilities.js. So you will need to make adjustments accordingly.

Step 1:

In utilities/utilities.js & yahoo-dom-event/yahoo-dom-event.js on ln 7 Character 1592 (ln 396 of yahoo.js): Right after: if(A&&A[1]){C.caja=parseFloat(A[1]);}

But before: return C;}();

Add this: if (C.ie==0&&B.indexOf('Trident')!=-1){C.ie=11;}

Step 2:

In editor/editor-min.js & editor/simpleeditor-min.js on line 13 Character 2078 (ln 3135 of editor.js & ln 3135 of simpleeditor.js)

Right after: (navigator.userAgent.indexOf("Firefox/1.5")!=-1)){

But before: try{if(this.browser.air)

Add this: if(this.browser.ie==11){this.browser.ie=0;}

0
Alex Meridian On

While not having YAHOO.env.parseUA, yahoo-dom-event.js does have YAHOO.env.ua in 2.5.2 instead. I was able to make this work by adding

else{A=B.match(/rv:([^\s\)]*)/);if(A&&A[1]){C.ie=parseFloat(A[1]);}}

between

A=B.match(/Gecko\/([^\s]*)/);if(A){C.gecko=1;A=B.match(/rv:([^\s\)]*)/);if(A&&A[1]){C.gecko=parseFloat(A[1]);}}

and

}}}return C;}();

at line 7, column 1514.

This looks for the revision number in the User Agent string, and sets it to be ie if it doesn't match any others. When using Edge this will return with ie = 11.

For readability, the code for YAHOO.env.ua looks like this after adding my section

YAHOO.env.ua = function () {
    var C = { ie: 0, opera: 0, gecko: 0, webkit: 0, mobile: null, air: 0 };
    var B = navigator.userAgent, A;
    if ((/KHTML/).test(B)) {
        C.webkit = 1;
    }
    A = B.match(/AppleWebKit\/([^\s]*)/);
    if (A && A[1]) {
        C.webkit = parseFloat(A[1]);
        if (/ Mobile\//.test(B)) {
            C.mobile = "Apple";
        } else {
            A = B.match(/NokiaN[^\/]*/);
            if (A) {
                C.mobile = A[0];
            }
        }
        A = B.match(/AdobeAIR\/([^\s]*)/);
        if (A) {
            C.air = A[0];
        }
    }
    if (!C.webkit) {
        A = B.match(/Opera[\s\/]([^\s]*)/);
        if (A && A[1]) {
            C.opera = parseFloat(A[1]);
            A = B.match(/Opera Mini[^;]*/);
            if (A) {
                C.mobile = A[0];
            }
        } else {
            A = B.match(/MSIE\s([^;]*)/);
            if (A && A[1]) {
                C.ie = parseFloat(A[1]);
            } else {
                A = B.match(/Gecko\/([^\s]*)/);
                if (A) {
                    C.gecko = 1;
                    A = B.match(/rv:([^\s\)]*)/);
                    if (A && A[1]) {
                        C.gecko = parseFloat(A[1]);
                    }
                } else {
                    A = B.match(/rv:([^\s\)]*)/);
                    if (A && A[1]) {
                        C.ie = parseFloat(A[1]);
                    }
                }
            }
        }
    }
    return C;
}();