00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 @import "CPEvent.j"
00024
00025
00026 CPUnknownBrowserEngine = 0;
00027 CPGeckoBrowserEngine = 1;
00028 CPInternetExplorerBrowserEngine = 2;
00029 CPKHTMLBrowserEngine = 3;
00030 CPOperaBrowserEngine = 4;
00031 CPWebKitBrowserEngine = 5;
00032
00033
00034 CPCSSRGBAFeature = 1 << 5;
00035
00036 CPHTMLCanvasFeature = 1 << 6;
00037 CPHTMLContentEditableFeature = 1 << 7;
00038
00039 CPJavascriptInnerTextFeature = 1 << 8;
00040 CPJavascriptTextContentFeature = 1 << 9;
00041 CPJavascriptClipboardEventsFeature = 1 << 10;
00042 CPJavascriptClipboardAccessFeature = 1 << 11;
00043 CPJavaScriptCanvasDrawFeature = 1 << 12;
00044 CPJavaScriptCanvasTransformFeature = 1 << 13;
00045
00046 CPVMLFeature = 1 << 14;
00047
00048 CPJavascriptRemedialKeySupport = 1 << 15;
00049 CPJavaScriptShadowFeature = 1 << 20;
00050
00051 CPJavaScriptNegativeMouseWheelValues = 1 << 22;
00052 CPJavaScriptMouseWheelValues_8_15 = 1 << 23
00053
00054 CPOpacityRequiresFilterFeature = 1 << 24;
00055
00056
00057 CPInputTypeCanBeChangedFeature = 1 << 25;
00058
00059
00060
00061 var USER_AGENT = "",
00062 PLATFORM_ENGINE = CPUnknownBrowserEngine,
00063 PLATFORM_FEATURES = 0;
00064
00065
00066
00067 PLATFORM_FEATURES |= CPInputTypeCanBeChangedFeature;
00068
00069 if (typeof window != "undfined" && typeof window.navigator != "undefined")
00070 USER_AGENT = window.navigator.userAgent;
00071
00072
00073 if (window.opera)
00074 {
00075 PLATFORM_ENGINE = CPOperaBrowserEngine;
00076
00077 PLATFORM_FEATURES |= CPJavaScriptCanvasDrawFeature;
00078 }
00079
00080
00081 else if (window.attachEvent)
00082 {
00083 PLATFORM_ENGINE = CPInternetExplorerBrowserEngine;
00084
00085
00086 PLATFORM_FEATURES |= CPVMLFeature;
00087 PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
00088 PLATFORM_FEATURES |= CPJavaScriptShadowFeature;
00089
00090 PLATFORM_FEATURES |= CPOpacityRequiresFilterFeature;
00091
00092 PLATFORM_FEATURES &= ~CPInputTypeCanBeChangedFeature;
00093 }
00094
00095
00096 else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
00097 {
00098 PLATFORM_ENGINE = CPWebKitBrowserEngine;
00099
00100
00101 PLATFORM_FEATURES |= CPCSSRGBAFeature;
00102 PLATFORM_FEATURES |= CPHTMLContentEditableFeature;
00103 PLATFORM_FEATURES |= CPJavascriptClipboardEventsFeature;
00104 PLATFORM_FEATURES |= CPJavascriptClipboardAccessFeature;
00105 PLATFORM_FEATURES |= CPJavaScriptShadowFeature;
00106
00107 var versionStart = USER_AGENT.indexOf("AppleWebKit/") + "AppleWebKit/".length,
00108 versionEnd = USER_AGENT.indexOf(" ", versionStart),
00109 version = parseFloat(USER_AGENT.substring(versionStart, versionEnd), 10);
00110
00111 if(USER_AGENT.indexOf("Plainview") == -1 && version >= 525.14 || USER_AGENT.indexOf("Chrome") != -1)
00112 PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
00113 }
00114
00115
00116 else if (USER_AGENT.indexOf("KHTML") != -1)
00117 {
00118 PLATFORM_ENGINE = CPKHTMLBrowserEngine;
00119 }
00120
00121
00122 else if (USER_AGENT.indexOf("Gecko") != -1)
00123 {
00124 PLATFORM_ENGINE = CPGeckoBrowserEngine;
00125
00126 PLATFORM_FEATURES |= CPJavaScriptCanvasDrawFeature;
00127
00128 var index = USER_AGENT.indexOf("Firefox"),
00129 version = (index == -1) ? 2.0 : parseFloat(USER_AGENT.substring(index + "Firefox".length + 1));
00130
00131 if (version >= 3.0)
00132 PLATFORM_FEATURES |= CPCSSRGBAFeature;
00133
00134 var geckoIndex = USER_AGENT.indexOf("Gecko"),
00135 geckoVersion = (geckoIndex === -1) ? 0.0 : parseFloat(USER_AGENT.substring(geckoIndex + "Gecko".length + 1, USER_AGENT.indexOf(' ', geckoIndex)));
00136
00137 if (version < 20061028)
00138 PLATFORM_FEATURES |= CPJavaScriptMouseWheelValues_8_15;
00139 }
00140
00141
00142 if (typeof document != "undefined")
00143 {
00144 var canvasElement = document.createElement("canvas");
00145
00146 if (canvasElement && canvasElement.getContext)
00147 {
00148 PLATFORM_FEATURES |= CPHTMLCanvasFeature;
00149
00150
00151 var context = document.createElement("canvas").getContext("2d");
00152
00153 if (context && context.setTransform && context.transform)
00154 PLATFORM_FEATURES |= CPJavaScriptCanvasTransformFeature;
00155 }
00156
00157 var DOMElement = document.createElement("div");
00158
00159
00160 if (DOMElement.innerText != undefined)
00161 PLATFORM_FEATURES |= CPJavascriptInnerTextFeature;
00162 else if (DOMElement.textContent != undefined)
00163 PLATFORM_FEATURES |= CPJavascriptTextContentFeature;
00164 }
00165
00166 function CPFeatureIsCompatible(aFeature)
00167 {
00168 return PLATFORM_FEATURES & aFeature;
00169 }
00170
00171 function CPBrowserIsEngine(anEngine)
00172 {
00173 return PLATFORM_ENGINE == anEngine;
00174 }
00175
00176 if (USER_AGENT.indexOf("Mac") != -1)
00177 {
00178 CPPlatformActionKeyMask = CPCommandKeyMask;
00179
00180 CPUndoKeyEquivalent = @"Z";
00181 CPRedoKeyEquivalent = @"Z";
00182
00183 CPUndoKeyEquivalentModifierMask = CPCommandKeyMask;
00184 CPRedoKeyEquivalentModifierMask = CPCommandKeyMask | CPShiftKeyMask;
00185 }
00186 else
00187 {
00188 CPPlatformActionKeyMask = CPControlKeyMask;
00189
00190 CPUndoKeyEquivalent = @"Z";
00191 CPRedoKeyEquivalent = @"Y";
00192
00193 CPUndoKeyEquivalentModifierMask = CPControlKeyMask;
00194 CPRedoKeyEquivalentModifierMask = CPControlKeyMask;
00195 }