PageRenderTime 69ms CodeModel.GetById 66ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Frameworks/Debug/AppKit/rhino.platform/CPCompatibility.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 115 lines | 114 code | 1 blank | 0 comment | 0 complexity | 50f6c419d81b1557896ae33a5a594a4f MD5 | raw file
  1i;9;CPEvent.jc;4432;
  2CPUnknownBrowserEngine = 0;
  3CPGeckoBrowserEngine = 1;
  4CPInternetExplorerBrowserEngine = 2;
  5CPKHTMLBrowserEngine = 3;
  6CPOperaBrowserEngine = 4;
  7CPWebKitBrowserEngine = 5;
  8CPCSSRGBAFeature = 1 << 5;
  9CPHTMLCanvasFeature = 1 << 6;
 10CPHTMLContentEditableFeature = 1 << 7;
 11CPJavascriptInnerTextFeature = 1 << 8;
 12CPJavascriptTextContentFeature = 1 << 9;
 13CPJavascriptClipboardEventsFeature = 1 << 10;
 14CPJavascriptClipboardAccessFeature = 1 << 11;
 15CPJavaScriptCanvasDrawFeature = 1 << 12;
 16CPJavaScriptCanvasTransformFeature = 1 << 13;
 17CPVMLFeature = 1 << 14;
 18CPJavascriptRemedialKeySupport = 1 << 15;
 19CPJavaScriptShadowFeature = 1 << 20;
 20CPJavaScriptNegativeMouseWheelValues = 1 << 22;
 21CPJavaScriptMouseWheelValues_8_15 = 1 << 23
 22CPOpacityRequiresFilterFeature = 1 << 24;
 23CPInputTypeCanBeChangedFeature = 1 << 25;
 24var USER_AGENT = "",
 25    PLATFORM_ENGINE = CPUnknownBrowserEngine,
 26    PLATFORM_FEATURES = 0;
 27PLATFORM_FEATURES |= CPInputTypeCanBeChangedFeature;
 28if (typeof window != "undfined" && typeof window.navigator != "undefined")
 29    USER_AGENT = window.navigator.userAgent;
 30if (window.opera)
 31{
 32    PLATFORM_ENGINE = CPOperaBrowserEngine;
 33    PLATFORM_FEATURES |= CPJavaScriptCanvasDrawFeature;
 34}
 35else if (window.attachEvent)
 36{
 37    PLATFORM_ENGINE = CPInternetExplorerBrowserEngine;
 38    PLATFORM_FEATURES |= CPVMLFeature;
 39    PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
 40    PLATFORM_FEATURES |= CPJavaScriptShadowFeature;
 41    PLATFORM_FEATURES |= CPOpacityRequiresFilterFeature;
 42    PLATFORM_FEATURES &= ~CPInputTypeCanBeChangedFeature;
 43}
 44else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
 45{
 46    PLATFORM_ENGINE = CPWebKitBrowserEngine;
 47    PLATFORM_FEATURES |= CPCSSRGBAFeature;
 48    PLATFORM_FEATURES |= CPHTMLContentEditableFeature;
 49    PLATFORM_FEATURES |= CPJavascriptClipboardEventsFeature;
 50    PLATFORM_FEATURES |= CPJavascriptClipboardAccessFeature;
 51    PLATFORM_FEATURES |= CPJavaScriptShadowFeature;
 52    var versionStart = USER_AGENT.indexOf("AppleWebKit/") + "AppleWebKit/".length,
 53        versionEnd = USER_AGENT.indexOf(" ", versionStart),
 54        version = parseFloat(USER_AGENT.substring(versionStart, versionEnd), 10);
 55    if(USER_AGENT.indexOf("Plainview") == -1 && version >= 525.14 || USER_AGENT.indexOf("Chrome") != -1)
 56        PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
 57}
 58else if (USER_AGENT.indexOf("KHTML") != -1)
 59{
 60    PLATFORM_ENGINE = CPKHTMLBrowserEngine;
 61}
 62else if (USER_AGENT.indexOf("Gecko") != -1)
 63{
 64    PLATFORM_ENGINE = CPGeckoBrowserEngine;
 65    PLATFORM_FEATURES |= CPJavaScriptCanvasDrawFeature;
 66    var index = USER_AGENT.indexOf("Firefox"),
 67        version = (index == -1) ? 2.0 : parseFloat(USER_AGENT.substring(index + "Firefox".length + 1));
 68    if (version >= 3.0)
 69        PLATFORM_FEATURES |= CPCSSRGBAFeature;
 70    var geckoIndex = USER_AGENT.indexOf("Gecko"),
 71        geckoVersion = (geckoIndex === -1) ? 0.0 : parseFloat(USER_AGENT.substring(geckoIndex + "Gecko".length + 1, USER_AGENT.indexOf(' ', geckoIndex)));
 72    if (version < 20061028)
 73        PLATFORM_FEATURES |= CPJavaScriptMouseWheelValues_8_15;
 74}
 75if (typeof document != "undefined")
 76{
 77    var canvasElement = document.createElement("canvas");
 78    if (canvasElement && canvasElement.getContext)
 79    {
 80        PLATFORM_FEATURES |= CPHTMLCanvasFeature;
 81        var context = document.createElement("canvas").getContext("2d");
 82        if (context && context.setTransform && context.transform)
 83            PLATFORM_FEATURES |= CPJavaScriptCanvasTransformFeature;
 84    }
 85    var DOMElement = document.createElement("div");
 86    if (DOMElement.innerText != undefined)
 87        PLATFORM_FEATURES |= CPJavascriptInnerTextFeature;
 88    else if (DOMElement.textContent != undefined)
 89        PLATFORM_FEATURES |= CPJavascriptTextContentFeature;
 90}
 91CPFeatureIsCompatible= function(aFeature)
 92{
 93    return PLATFORM_FEATURES & aFeature;
 94}
 95CPBrowserIsEngine= function(anEngine)
 96{
 97    return PLATFORM_ENGINE == anEngine;
 98}
 99if (USER_AGENT.indexOf("Mac") != -1)
100{
101    CPPlatformActionKeyMask = CPCommandKeyMask;
102    CPUndoKeyEquivalent = "Z";
103    CPRedoKeyEquivalent = "Z";
104    CPUndoKeyEquivalentModifierMask = CPCommandKeyMask;
105    CPRedoKeyEquivalentModifierMask = CPCommandKeyMask | CPShiftKeyMask;
106}
107else
108{
109    CPPlatformActionKeyMask = CPControlKeyMask;
110    CPUndoKeyEquivalent = "Z";
111    CPRedoKeyEquivalent = "Y";
112    CPUndoKeyEquivalentModifierMask = CPControlKeyMask;
113    CPRedoKeyEquivalentModifierMask = CPControlKeyMask;
114}
115